From 8ce12a2c6e1f5c1b0221b0c71af7c6d76f86750b Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Tue, 28 Sep 2021 14:28:58 -0700 Subject: [PATCH 01/26] Fix ray query distance calculation (#438) * fix ray query dist calc Signed-off-by: Ian Chen * disable test Signed-off-by: Ian Chen --- ogre2/src/Ogre2RayQuery.cc | 7 ++++--- src/Utils_TEST.cc | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/ogre2/src/Ogre2RayQuery.cc b/ogre2/src/Ogre2RayQuery.cc index 41995f127..d2e1b3205 100644 --- a/ogre2/src/Ogre2RayQuery.cc +++ b/ogre2/src/Ogre2RayQuery.cc @@ -126,10 +126,11 @@ RayQueryResult Ogre2RayQuery::ClosestPointBySelectionBuffer() typeid(unsigned int)) { auto userAny = ogreItem->getUserObjectBindings().getUserAny(); - double pointLength = point.Length(); - if (!std::isinf(pointLength)) + double distance = this->dataPtr->camera->WorldPosition().Distance(point) + - this->dataPtr->camera->NearClipPlane(); + if (!std::isinf(distance)) { - result.distance = pointLength; + result.distance = distance; result.point = point; result.objectId = Ogre::any_cast(userAny); } diff --git a/src/Utils_TEST.cc b/src/Utils_TEST.cc index b88785969..ee6861fa5 100644 --- a/src/Utils_TEST.cc +++ b/src/Utils_TEST.cc @@ -66,7 +66,7 @@ void UtilTest::ClickToScene(const std::string &_renderEngine) const int halfWidth = static_cast(width / 2); const int halfHeight = static_cast(height / 2); - const ignition::math::Vector2i centerClick(halfWidth, halfHeight); + ignition::math::Vector2i centerClick(halfWidth, halfHeight); RayQueryPtr rayQuery = scene->CreateRayQuery(); EXPECT_TRUE(rayQuery != nullptr); @@ -117,23 +117,46 @@ void UtilTest::ClickToScene(const std::string &_renderEngine) box->SetLocalScale(1.0, 1.0, 1.0); root->AddChild(box); + root->AddChild(camera); + camera->Update(); + + // \todo(anyone) + // the centerClick var above is set to a screen pos of (width/2, height/2). + // This is off-by-1. The actual center pos should be at + // (width/2 - 1, height/2 - 1) so the result.X() and result.Y() is a bit off + // from the expected position. However, fixing the centerClick above caused + // the screenToPlane tests to fail so only modifying the pos here, and the + // cause of test failure need to be investigated. + centerClick = ignition::math::Vector2i(halfWidth-1, halfHeight-1); + // API without RayQueryResult and default max distance result = screenToScene(centerClick, camera, rayQuery, rayResult); - EXPECT_NEAR(0.5, result.Z(), 1e-10); + if (_renderEngine == "ogre2") + { + // tests using selection buffer fail on CI, see issue #170 + // https://github.com/ignitionrobotics/ign-rendering/issues/170 + igndbg << "Selection buffer based screenToScene test is disabled in " + << _renderEngine << "." << std::endl; + return; + } + + // high tol is used for z due to depth buffer precision. + // Do not merge the tol changes forward to ign-rendering6. + EXPECT_NEAR(0.5, result.Z(), 1e-3); EXPECT_NEAR(0.0, result.X(), 2e-6); EXPECT_NEAR(0.0, result.Y(), 2e-6); EXPECT_TRUE(rayResult); - EXPECT_NEAR(14.5 - camera->NearClipPlane(), rayResult.distance, 4e-6); + EXPECT_NEAR(14.5 - camera->NearClipPlane(), rayResult.distance, 1e-3); EXPECT_EQ(box->Id(), rayResult.objectId); result = screenToScene(centerClick, camera, rayQuery, rayResult, 20.0); - EXPECT_NEAR(0.5, result.Z(), 1e-10); + EXPECT_NEAR(0.5, result.Z(), 1e-3); EXPECT_NEAR(0.0, result.X(), 2e-6); EXPECT_NEAR(0.0, result.Y(), 2e-6); EXPECT_TRUE(rayResult); - EXPECT_NEAR(14.5 - camera->NearClipPlane(), rayResult.distance, 4e-6); + EXPECT_NEAR(14.5 - camera->NearClipPlane(), rayResult.distance, 1e-3); EXPECT_EQ(box->Id(), rayResult.objectId); // Move camera closer to box @@ -142,11 +165,11 @@ void UtilTest::ClickToScene(const std::string &_renderEngine) result = screenToScene(centerClick, camera, rayQuery, rayResult); - EXPECT_NEAR(0.5, result.Z(), 1e-10); + EXPECT_NEAR(0.5, result.Z(), 1e-3); EXPECT_NEAR(0.0, result.X(), 2e-6); EXPECT_NEAR(0.0, result.Y(), 2e-6); EXPECT_TRUE(rayResult); - EXPECT_NEAR(6.5 - camera->NearClipPlane(), rayResult.distance, 4e-6); + EXPECT_NEAR(6.5 - camera->NearClipPlane(), rayResult.distance, 1e-4); EXPECT_EQ(box->Id(), rayResult.objectId); } From dc2f1a487f907a6ddaebaa2b83cce17b410b23aa Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Thu, 30 Sep 2021 15:19:21 -0700 Subject: [PATCH 02/26] =?UTF-8?q?=F0=9F=8E=88=206.0.0=20(#445)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Louise Poubel --- CMakeLists.txt | 2 +- Changelog.md | 56 +++++++++++++++++++++++++++++--------------------- README.md | 8 ++++---- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f84ba440..38ebb612a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR}) #============================================================================ # Set up the project #============================================================================ -ign_configure_project(VERSION_SUFFIX pre2) +ign_configure_project(VERSION_SUFFIX) #============================================================================ # Set project-specific options diff --git a/Changelog.md b/Changelog.md index 5c6ea524c..4283d6527 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,15 +4,24 @@ ### Ignition Rendering 6.0.0 (20XX-XX-XX) +1. Avoid configure warning when checking ogre-1.10 + * [Pull request #411](https://github.com/ignitionrobotics/ign-rendering/pull/411) + * [Pull request #413](https://github.com/ignitionrobotics/ign-rendering/pull/413) + +1. Use selection buffer in ray queries (ogre2) + * [Pull request #378](https://github.com/ignitionrobotics/ign-rendering/pull/378) + +1. Fix particle effect randomness + * [Pull request #388](https://github.com/ignitionrobotics/ign-rendering/pull/388) + 1. Update test config to run ogre 1.x tests in ign-rendering6 on macOS * [Pull request #407](https://github.com/ignitionrobotics/ign-rendering/pull/407) * [Pull request #409](https://github.com/ignitionrobotics/ign-rendering/pull/409) - -1. Check if key exists in gpu lidar's user data - * [Pull request #396](https://github.com/ignitionrobotics/ign-rendering/pull/396) + * [Pull request #409](https://github.com/ignitionrobotics/ign-rendering/pull/409) 1. Clone visuals and geometries * [Pull request #397](https://github.com/ignitionrobotics/ign-rendering/pull/397) + * [Pull request #434](https://github.com/ignitionrobotics/ign-rendering/pull/434) 1. Add SetSize API for LidarVisual and markers * [Pull request #392](https://github.com/ignitionrobotics/ign-rendering/pull/392) @@ -23,16 +32,21 @@ 1. Prevent default-constructed variants from holding a type * [Pull request #371](https://github.com/ignitionrobotics/ign-rendering/pull/371) + * [Pull request #396](https://github.com/ignitionrobotics/ign-rendering/pull/396) 1. Temporarily set number of camera pass count per flush to 0 in ogre2 to prevent downstream build failures * [Pull request #367](https://github.com/ignitionrobotics/ign-rendering/pull/367) -1. Joint visual - * [Pull request #366](https://github.com/ignitionrobotics/ign-rendering/pull/366) - * [Pull request #387](https://github.com/ignitionrobotics/ign-rendering/pull/387) +1. New visuals + 1. Joint visual + * [Pull request #366](https://github.com/ignitionrobotics/ign-rendering/pull/366) + * [Pull request #387](https://github.com/ignitionrobotics/ign-rendering/pull/387) -1. Fixing camera projection type test - * [Pull request #361](https://github.com/ignitionrobotics/ign-rendering/pull/361) + 1. Center of mass visual + * [Pull request #345](https://github.com/ignitionrobotics/ign-rendering/pull/345) + + 1. Inertia visual + * [Pull request #326](https://github.com/ignitionrobotics/ign-rendering/pull/326) 1. UserData methods moved from Visual to Node * [Pull request #358](https://github.com/ignitionrobotics/ign-rendering/pull/358) @@ -40,19 +54,14 @@ 1. Replace renderOneFrame for per-workspace update calls * [Pull request #353](https://github.com/ignitionrobotics/ign-rendering/pull/353) -1. Center of mass visual - * [Pull request #345](https://github.com/ignitionrobotics/ign-rendering/pull/345) - 1. Segmentation Camera * [Pull request #329](https://github.com/ignitionrobotics/ign-rendering/pull/329) * [Pull request #419](https://github.com/ignitionrobotics/ign-rendering/pull/419) + * [Pull request #443](https://github.com/ignitionrobotics/ign-rendering/pull/443) 1. Stub bounding box camera APIs * [Pull request #420](https://github.com/ignitionrobotics/ign-rendering/pull/420) -1. Inertia visual - * [Pull request #326](https://github.com/ignitionrobotics/ign-rendering/pull/326) - 1. Changed calculation for range clipping * [Pull request #325](https://github.com/ignitionrobotics/ign-rendering/pull/325) @@ -61,9 +70,7 @@ 1. Add orthographic view controller * [Pull request #322](https://github.com/ignitionrobotics/ign-rendering/pull/322) - -1. Port codecov to new configuration - * [Pull request #318](https://github.com/ignitionrobotics/ign-rendering/pull/318) + * [Pull request #361](https://github.com/ignitionrobotics/ign-rendering/pull/361) 1. Visualize wireframes * [Pull request #314](https://github.com/ignitionrobotics/ign-rendering/pull/314) @@ -74,13 +81,16 @@ 1. From Ogre 2.1 to Ogre 2.2 * [Pull request #272](https://github.com/ignitionrobotics/ign-rendering/pull/272) * [Pull request #393](https://github.com/ignitionrobotics/ign-rendering/pull/393) + * [Pull request #436](https://github.com/ignitionrobotics/ign-rendering/pull/436) + * [Pull request #426](https://github.com/ignitionrobotics/ign-rendering/pull/426) + * [Pull request #440](https://github.com/ignitionrobotics/ign-rendering/pull/440) -1. All changes merged forward from ign-rendering5 - * [Pull request #310](https://github.com/ignitionrobotics/ign-rendering/pull/310) - * [Pull request #331](https://github.com/ignitionrobotics/ign-rendering/pull/331) - * [Pull request #350](https://github.com/ignitionrobotics/ign-rendering/pull/350) - * [Pull request #401](https://github.com/ignitionrobotics/ign-rendering/pull/401) - * [Pull request #406](https://github.com/ignitionrobotics/ign-rendering/pull/406) +1. Documentation updates + * [Pull request #425](https://github.com/ignitionrobotics/ign-rendering/pull/425) + * [Pull request #431](https://github.com/ignitionrobotics/ign-rendering/pull/431) + +1. Infrastructure + * [Pull request #318](https://github.com/ignitionrobotics/ign-rendering/pull/318) ### Ignition Rendering 5.X diff --git a/README.md b/README.md index e6e6cfed3..f3be7f0bb 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ Build | Status -- | -- -Test coverage | [![codecov](https://codecov.io/gh/ignitionrobotics/ign-rendering/branch/main/graph/badge.svg)](https://codecov.io/gh/ignitionrobotics/ign-rendering/branch/default) -Ubuntu Bionic | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_rendering-ci-main-bionic-amd64)](https://build.osrfoundation.org/job/ignition_rendering-ci-main-bionic-amd64) -Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_rendering-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_rendering-ci-main-homebrew-amd64) -Windows | [![Build Status](https://build.osrfoundation.org/job/ign_rendering-ci-win/badge/icon)](https://build.osrfoundation.org/job/ign_rendering-ci-win/) +Test coverage | [![codecov](https://codecov.io/gh/ignitionrobotics/ign-rendering/branch/ign-rendering6/graph/badge.svg)](https://codecov.io/gh/ignitionrobotics/ign-rendering/branch/ign-rendering6) +Ubuntu Bionic | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_rendering-ci-ign-rendering6-bionic-amd64)](https://build.osrfoundation.org/job/ignition_rendering-ci-ign-rendering6-bionic-amd64) +Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_rendering-ci-ign-rendering6-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_rendering-ci-ign-rendering6-homebrew-amd64) +Windows | [![Build Status](https://build.osrfoundation.org/job/ign_rendering-ign-6-win/badge/icon)](https://build.osrfoundation.org/job/ign_rendering-ign-6-win/) Ignition Rendering is a C++ library designed to provide an abstraction for different rendering engines. It offers unified APIs for creating From dd4b5206db102fb7830fd852daedf10680b2bf7d Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 1 Oct 2021 10:02:40 -0700 Subject: [PATCH 03/26] use ray triangle intersection for ray query (#447) Signed-off-by: Ian Chen --- ogre2/src/Ogre2RayQuery.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ogre2/src/Ogre2RayQuery.cc b/ogre2/src/Ogre2RayQuery.cc index ea2468004..fd9f1d1cc 100644 --- a/ogre2/src/Ogre2RayQuery.cc +++ b/ogre2/src/Ogre2RayQuery.cc @@ -95,6 +95,11 @@ RayQueryResult Ogre2RayQuery::ClosestPoint() { RayQueryResult result; + // ray query using selection buffer does not seem to work on some machines + // using cpu based ray-triangle intersection method + // \todo remove this line if selection buffer is working again + return this->ClosestPointByIntersection(); + #ifdef __APPLE__ return this->ClosestPointByIntersection(); #else From f93c796abffbfd979d2eebbfc7fb3e8b2d75ae75 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 1 Oct 2021 11:00:12 -0700 Subject: [PATCH 04/26] prepare for 6.0.1 patch release (#449) Signed-off-by: Ian Chen --- CMakeLists.txt | 2 +- Changelog.md | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38ebb612a..51328f1e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-rendering6 VERSION 6.0.0) +project(ignition-rendering6 VERSION 6.0.1) #============================================================================ # Find ignition-cmake diff --git a/Changelog.md b/Changelog.md index 4283d6527..ef411bde3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,7 +2,12 @@ ### Ignition Rendering 6.X -### Ignition Rendering 6.0.0 (20XX-XX-XX) +### Ignition Rendering 6.0.1 (2021-10-01) + +1. Disable using selection buffer for ray queries + * [Pull request #447](https://github.com/ignitionrobotics/ign-rendering/pull/447) + +### Ignition Rendering 6.0.0 (2021-09-30) 1. Avoid configure warning when checking ogre-1.10 * [Pull request #411](https://github.com/ignitionrobotics/ign-rendering/pull/411) From 6f3105b63d978bfe7f21be184e64d5d91341fb0b Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 4 Oct 2021 21:55:46 +0200 Subject: [PATCH 05/26] ogre: Add missing required Paging component (#452) Signed-off-by: Silvio --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ace98855..216aacc26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ endif() #-------------------------------------- # Find OGRE -list(APPEND ign_ogre_components "RTShaderSystem" "Terrain" "Overlay") +list(APPEND ign_ogre_components "RTShaderSystem" "Terrain" "Overlay" "Paging") # Ogre versions greater than 1.9 are not officialy supported. # Display a warning for the users on this setup unless they provide From e17fafd2d4b856c7f02d5b5905ac097476dc4faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Wed, 6 Oct 2021 18:57:11 +0200 Subject: [PATCH 06/26] Added macos instructions (#448) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added macos instructions Signed-off-by: Alejandro Hernández * Fix Signed-off-by: Alejandro Hernández Co-authored-by: Ian Chen --- tutorials/02_install.md | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/tutorials/02_install.md b/tutorials/02_install.md index 9fc5fbf7e..ac799ed39 100644 --- a/tutorials/02_install.md +++ b/tutorials/02_install.md @@ -196,6 +196,54 @@ This assumes you have created and activated a Conda environment while installing cmake --install . --config Release ``` +# macOS + +## Binary Installation + +On macOS, add OSRF packages: + ``` + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew tap osrf/simulation + ``` + +Install Ignition Rendering: + ``` + brew install ignition-rendering<#> + ``` + +Be sure to replace `<#>` with a number value, such as 5 or 6, depending on +which version you need. + +## Source Installation + +1. Clone the repository + ``` + git clone https://github.com/ignitionrobotics/ign-rendering -b ign-rendering<#> + ``` + Be sure to replace `<#>` with a number value, such as 5 or 6, depending on + which version you need. + +2. Install dependencies + ``` + brew install --only-dependencies ignition-rendering<#> + ``` + Be sure to replace `<#>` with a number value, such as 5 or 6, depending on + which version you need. + +3. Configure and build + ``` + cd ign-rendering + mkdir build + cd build + cmake .. + make + ``` + +4. Optionally, install + ``` + sudo make install + ``` + # Documentation API documentation can be generated using Doxygen @@ -226,4 +274,3 @@ To run tests specific to a render engine, set the `RENDER_ENGINE_VALUES` environ ``` RENDER_ENGINE_VALUES=ogre2 make test ``` - From c9e76e988768829f923a944b31c1739e65e0a5dc Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Thu, 7 Oct 2021 03:02:28 -0300 Subject: [PATCH 07/26] Fix heightmap crash if only shadow casting spotlights are one scene (#451) Fixes ignitionrobotics/ign-rendering#439 Signed-off-by: Matias N. Goldberg Co-authored-by: Ian Chen --- .../GLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl | 2 +- .../PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl | 2 +- .../HLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.hlsl | 2 +- .../PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.metal | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ogre2/src/media/Hlms/Terra/GLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl b/ogre2/src/media/Hlms/Terra/GLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl index 9162c3617..4f5449b1c 100644 --- a/ogre2/src/media/Hlms/Terra/GLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl +++ b/ogre2/src/media/Hlms/Terra/GLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl @@ -34,7 +34,7 @@ outVs.terrainShadow = mix( terraShadowData.x, 1.0, clamp( terraHeightWeight, 0.0, 1.0 ) ); @end -@property( hlms_num_shadow_map_lights ) +@property( hlms_lights_directional ) @piece( custom_ps_preLights )fShadow *= inPs.terrainShadow;@end @else @piece( custom_ps_preLights )float fShadow = inPs.terrainShadow;@end diff --git a/ogre2/src/media/Hlms/Terra/GLSLES/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl b/ogre2/src/media/Hlms/Terra/GLSLES/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl index f0436a884..0a13d01d6 100644 --- a/ogre2/src/media/Hlms/Terra/GLSLES/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl +++ b/ogre2/src/media/Hlms/Terra/GLSLES/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl @@ -28,7 +28,7 @@ outVs.terrainShadow = mix( terraShadowData.x, 1.0, clamp( terraHeightWeight, 0.0, 1.0 ) ); @end -@property( hlms_num_shadow_map_lights ) +@property( hlms_lights_directional ) @piece( custom_ps_preLights )fShadow *= inPs.terrainShadow;@end @end @property( !hlms_num_shadow_map_lights ) @piece( custom_ps_preLights )float fShadow = inPs.terrainShadow;@end diff --git a/ogre2/src/media/Hlms/Terra/HLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.hlsl b/ogre2/src/media/Hlms/Terra/HLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.hlsl index 3e26c06e4..b267fa8a0 100644 --- a/ogre2/src/media/Hlms/Terra/HLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.hlsl +++ b/ogre2/src/media/Hlms/Terra/HLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.hlsl @@ -36,7 +36,7 @@ outVs.terrainShadow = lerp( terraShadowData.x, 1.0, saturate( terraHeightWeight ) ); @end -@property( hlms_num_shadow_map_lights ) +@property( hlms_lights_directional ) @piece( custom_ps_preLights )fShadow *= inPs.terrainShadow;@end @else @piece( custom_ps_preLights )float fShadow = inPs.terrainShadow;@end diff --git a/ogre2/src/media/Hlms/Terra/Metal/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.metal b/ogre2/src/media/Hlms/Terra/Metal/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.metal index 28c99327d..09ff43e5f 100644 --- a/ogre2/src/media/Hlms/Terra/Metal/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.metal +++ b/ogre2/src/media/Hlms/Terra/Metal/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.metal @@ -36,7 +36,7 @@ outVs.terrainShadow = lerp( terraShadowData.x, 1.0, saturate( terraHeightWeight ) ); @end -@property( hlms_num_shadow_map_lights ) +@property( hlms_lights_directional ) @piece( custom_ps_preLights )fShadow *= inPs.terrainShadow;@end @else @piece( custom_ps_preLights )float fShadow = inPs.terrainShadow;@end From 19e1843f0259232cc915f93082a1a61d02a89bfa Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Thu, 7 Oct 2021 08:20:00 +0200 Subject: [PATCH 08/26] ogre: Do not assume that ogre plugins have lib prefix on macOS (#454) Signed-off-by: Silvio --- ogre/src/OgreRenderEngine.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ogre/src/OgreRenderEngine.cc b/ogre/src/OgreRenderEngine.cc index b9e394462..ed66934ec 100644 --- a/ogre/src/OgreRenderEngine.cc +++ b/ogre/src/OgreRenderEngine.cc @@ -421,20 +421,17 @@ void OgreRenderEngine::LoadPlugins() std::vector::iterator piter; #ifdef __APPLE__ - std::string prefix = "lib"; std::string extension = ".dylib"; #elif _WIN32 - std::string prefix = ""; std::string extension = ".dll"; #else - std::string prefix = ""; std::string extension = ".so"; #endif - plugins.push_back(path+"/"+prefix+"RenderSystem_GL"); - plugins.push_back(path+"/"+prefix+"Plugin_ParticleFX"); - plugins.push_back(path+"/"+prefix+"Plugin_BSPSceneManager"); - plugins.push_back(path+"/"+prefix+"Plugin_OctreeSceneManager"); + plugins.push_back(path+"/RenderSystem_GL"); + plugins.push_back(path+"/Plugin_ParticleFX"); + plugins.push_back(path+"/Plugin_BSPSceneManager"); + plugins.push_back(path+"/Plugin_OctreeSceneManager"); #ifdef HAVE_OCULUS plugins.push_back(path+"/Plugin_CgProgramManager"); From 50e1e5fa936176a570b6b4cccbbe081334af6057 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 7 Oct 2021 00:16:53 -0700 Subject: [PATCH 09/26] run ogre2 particles by default (#430) Signed-off-by: Ian Chen --- examples/particles_demo/Main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/particles_demo/Main.cc b/examples/particles_demo/Main.cc index 049bc736c..0652ccbb1 100644 --- a/examples/particles_demo/Main.cc +++ b/examples/particles_demo/Main.cc @@ -161,7 +161,7 @@ int main(int _argc, char** _argv) // Expose engine name to command line because we can't instantiate both // ogre and ogre2 at the same time - std::string ogreEngineName("ogre"); + std::string ogreEngineName("ogre2"); if (_argc > 1) { ogreEngineName = _argv[1]; From 67b5420890814b525d6b936947356a816a457eed Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 7 Oct 2021 11:20:02 -0700 Subject: [PATCH 10/26] fix point cloud material syntax error (#433) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ian Chen Co-authored-by: Alejandro Hernández Cordero --- ogre2/src/media/materials/scripts/point_cloud_point.material | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogre2/src/media/materials/scripts/point_cloud_point.material b/ogre2/src/media/materials/scripts/point_cloud_point.material index 00221692e..1745ab795 100644 --- a/ogre2/src/media/materials/scripts/point_cloud_point.material +++ b/ogre2/src/media/materials/scripts/point_cloud_point.material @@ -31,7 +31,7 @@ fragment_program PointCloudFS glsl source point_fs.glsl default_params { - param_named color vec4 1.0 1.0 1.0 1.0 + param_named color float4 1.0 1.0 1.0 1.0 } } From 43f53aaf53a9fa6af3067602d4d982f09468f4bd Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 11 Oct 2021 19:06:27 +0200 Subject: [PATCH 11/26] Fix compilation against Ogre 1.10.12 (#390) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: GitHub Co-authored-by: Alejandro Hernández Cordero Co-authored-by: Jose Luis Rivero --- ogre/src/CMakeLists.txt | 7 ++----- ogre/src/OgreGaussianNoisePass.cc | 4 ++-- ogre/src/OgreGpuRays.cc | 4 ++-- ogre/src/OgreMaterial.cc | 4 ++-- ogre/src/OgreMaterialSwitcher.cc | 2 +- ogre/src/OgreRTShaderSystem.cc | 14 +++++++------- ogre/src/OgreRenderEngine.cc | 4 ++-- ogre/src/OgreScene.cc | 2 +- ogre/src/OgreText.cc | 14 +++++++------- ogre/src/OgreThermalCamera.cc | 4 ++-- 10 files changed, 28 insertions(+), 31 deletions(-) diff --git a/ogre/src/CMakeLists.txt b/ogre/src/CMakeLists.txt index bb38fd8b6..2ea299b35 100644 --- a/ogre/src/CMakeLists.txt +++ b/ogre/src/CMakeLists.txt @@ -15,11 +15,8 @@ set(engine_name "ogre") ign_add_component(${engine_name} SOURCES ${sources} GET_TARGET_NAME ogre_target) -if(OGRE_VERSION VERSION_LESS 1.10.3) - add_definitions(-DOGRE_VERSION_LT_1_10_3) -endif() -if(OGRE_VERSION VERSION_LESS 1.10.1) - add_definitions(-DOGRE_VERSION_LT_1_10_1) +if(OGRE_VERSION VERSION_LESS 1.11.0) + add_definitions(-DOGRE_VERSION_LT_1_11_0) endif() if(OGRE_VERSION VERSION_LESS 1.12.0) add_definitions(-DOGRE_VERSION_LT_1_12_0) diff --git a/ogre/src/OgreGaussianNoisePass.cc b/ogre/src/OgreGaussianNoisePass.cc index 84a35e394..082c89f18 100644 --- a/ogre/src/OgreGaussianNoisePass.cc +++ b/ogre/src/OgreGaussianNoisePass.cc @@ -44,7 +44,7 @@ namespace ignition public: virtual void notifyMaterialRender(unsigned int _passId, Ogre::MaterialPtr &_mat) { -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 IGN_ASSERT(!_mat.isNull(), "Null OGRE material"); #else IGN_ASSERT(_mat, "Null OGRE material"); @@ -68,7 +68,7 @@ namespace ignition IGN_ASSERT(pass, "Null OGRE material pass"); Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters(); -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 IGN_ASSERT(!params.isNull(), "Null OGRE material GPU parameters"); #else IGN_ASSERT(params, "Null OGRE material GPU parameters"); diff --git a/ogre/src/OgreGpuRays.cc b/ogre/src/OgreGpuRays.cc index 2dba203b6..2c1381557 100644 --- a/ogre/src/OgreGpuRays.cc +++ b/ogre/src/OgreGpuRays.cc @@ -409,7 +409,7 @@ void OgreGpuRays::CreateGpuRaysTextures() Ogre::TextureManager::getSingleton().createManual( texName.str(), "General", Ogre::TEX_TYPE_2D, this->dataPtr->w1st, this->dataPtr->h1st, 0, -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 Ogre::PF_FLOAT32_RGB, Ogre::TU_RENDERTARGET).getPointer(); #else Ogre::PF_FLOAT32_RGB, Ogre::TU_RENDERTARGET).get(); @@ -445,7 +445,7 @@ void OgreGpuRays::CreateGpuRaysTextures() Ogre::TEX_TYPE_2D, this->dataPtr->w2nd, this->dataPtr->h2nd, 0, Ogre::PF_FLOAT32_RGB, -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 Ogre::TU_RENDERTARGET).getPointer(); #else Ogre::TU_RENDERTARGET).get(); diff --git a/ogre/src/OgreMaterial.cc b/ogre/src/OgreMaterial.cc index bcce577bb..29eb8a821 100644 --- a/ogre/src/OgreMaterial.cc +++ b/ogre/src/OgreMaterial.cc @@ -46,7 +46,7 @@ void OgreMaterial::Destroy() return; Ogre::MaterialManager &matManager = Ogre::MaterialManager::getSingleton(); -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 if (!this->ogreMaterial.isNull()) { matManager.remove(this->ogreMaterial->getName()); @@ -526,7 +526,7 @@ Ogre::TexturePtr OgreMaterial::CreateTexture(const std::string &_name) if (image.getWidth() == 0) { - #if OGRE_VERSION_LT_1_10_1 + #if OGRE_VERSION_LT_1_11_0 texture.setNull(); #else texture.reset(); diff --git a/ogre/src/OgreMaterialSwitcher.cc b/ogre/src/OgreMaterialSwitcher.cc index dc1b024c3..a75fd1768 100644 --- a/ogre/src/OgreMaterialSwitcher.cc +++ b/ogre/src/OgreMaterialSwitcher.cc @@ -79,7 +79,7 @@ Ogre::Technique *OgreMaterialSwitcher::handleSchemeNotFound( Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); // OGRE 1.9 changes the shared pointer definition - #if OGRE_VERSION_LT_1_10_1 + #if OGRE_VERSION_LT_1_11_0 Ogre::MaterialPtr plainMaterial = res.staticCast(); #else Ogre::MaterialPtr plainMaterial = diff --git a/ogre/src/OgreRTShaderSystem.cc b/ogre/src/OgreRTShaderSystem.cc index 657cef175..4bf49bea1 100644 --- a/ogre/src/OgreRTShaderSystem.cc +++ b/ogre/src/OgreRTShaderSystem.cc @@ -81,7 +81,7 @@ OgreRTShaderSystem::OgreRTShaderSystem() { this->dataPtr->initialized = false; this->dataPtr->shadowsApplied = false; -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 this->dataPtr->pssmSetup.setNull(); #else this->dataPtr->pssmSetup.reset(); @@ -157,7 +157,7 @@ void OgreRTShaderSystem::Fini() #endif this->dataPtr->shaderGenerator = nullptr; } -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 this->dataPtr->pssmSetup.setNull(); #else this->dataPtr->pssmSetup.reset(); @@ -300,7 +300,7 @@ void OgreRTShaderSystem::RemoveShaders(OgreSubMesh *_subMesh) #ifdef OGRE_VERSION_LT_1_12_0 this->dataPtr->shaderGenerator->removeShaderBasedTechnique( curMaterialName, - #ifndef OGRE_VERSION_LT_1_10_3 + #ifndef OGRE_VERSION_LT_1_11_0 curSubEntity->getMaterial()->getGroup(), #endif Ogre::MaterialManager::DEFAULT_SCHEME_NAME, @@ -380,7 +380,7 @@ void OgreRTShaderSystem::GenerateShaders(OgreSubMesh *subMesh) try { success = this->dataPtr->shaderGenerator->createShaderBasedTechnique( -#if OGRE_VERSION_LT_1_10_3 +#if OGRE_VERSION_LT_1_11_0 curMaterialName, #else *material->Material(), @@ -407,7 +407,7 @@ void OgreRTShaderSystem::GenerateShaders(OgreSubMesh *subMesh) this->dataPtr->scenes[s]->Name() + Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, curMaterialName, -#ifndef OGRE_VERSION_LT_1_10_3 +#ifndef OGRE_VERSION_LT_1_11_0 material->Material()->getGroup(), #endif 0); @@ -590,7 +590,7 @@ void OgreRTShaderSystem::ApplyShadows(OgreScenePtr _scene) sceneMgr->setShadowTextureSelfShadow(false); sceneMgr->setShadowCasterRenderBackFaces(true); -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 // Set up caster material - this is just a standard depth/shadow map caster sceneMgr->setShadowTextureCasterMaterial("PSSM/shadow_caster"); #else @@ -607,7 +607,7 @@ void OgreRTShaderSystem::ApplyShadows(OgreScenePtr _scene) // pssmCasterPass->setFog(true); // shadow camera setup -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 if (this->dataPtr->pssmSetup.isNull()) #else if (this->dataPtr->pssmSetup == nullptr) diff --git a/ogre/src/OgreRenderEngine.cc b/ogre/src/OgreRenderEngine.cc index ed66934ec..08b7abec2 100644 --- a/ogre/src/OgreRenderEngine.cc +++ b/ogre/src/OgreRenderEngine.cc @@ -212,7 +212,7 @@ void OgreRenderEngine::AddResourcePath(const std::string &_uri) fullPath); bool matPtrNotNull; -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 matPtrNotNull = !matPtr.isNull(); #else matPtrNotNull = matPtr != nullptr; @@ -721,7 +721,7 @@ void OgreRenderEngine::CheckCapabilities() bool hasVertexPrograms = capabilities->hasCapability(Ogre::RSC_VERTEX_PROGRAM); -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 bool hasFBO = capabilities->hasCapability(Ogre::RSC_FBO); #else diff --git a/ogre/src/OgreScene.cc b/ogre/src/OgreScene.cc index 19352a0f0..c43d6359b 100644 --- a/ogre/src/OgreScene.cc +++ b/ogre/src/OgreScene.cc @@ -207,7 +207,7 @@ void OgreScene::SetGradientBackgroundColor( // Create background rectangle covering the whole screen rect = new ColoredRectangle2D(); rect->setCorners(-1.0, 1.0, 1.0, -1.0); -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 rect->setMaterial("Background"); #else rect->setMaterial(material); diff --git a/ogre/src/OgreText.cc b/ogre/src/OgreText.cc index 7b0d4a238..32538f0fd 100644 --- a/ogre/src/OgreText.cc +++ b/ogre/src/OgreText.cc @@ -350,7 +350,7 @@ void OgreMovableText::SetFontNameImpl(const std::string &_newFontName) } if (this->fontName != _newFontName || -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 this->ogreMaterial.isNull() || !this->font) #else this->ogreMaterial == nullptr || !this->font) @@ -369,7 +369,7 @@ void OgreMovableText::SetFontNameImpl(const std::string &_newFontName) this->font->load(); -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 if (!this->ogreMaterial.isNull()) #else if (this->ogreMaterial) @@ -377,7 +377,7 @@ void OgreMovableText::SetFontNameImpl(const std::string &_newFontName) { Ogre::MaterialManager::getSingletonPtr()->remove( this->ogreMaterial->getName()); -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 this->ogreMaterial.setNull(); #else this->ogreMaterial = nullptr; @@ -403,7 +403,7 @@ void OgreMovableText::SetFontNameImpl(const std::string &_newFontName) void OgreMovableText::SetupGeometry() { IGN_ASSERT(this->font, "font class member is null"); -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 IGN_ASSERT(!this->ogreMaterial.isNull(), "ogreMaterial class member is null"); #else IGN_ASSERT(this->ogreMaterial, "ogreMaterial class member is null"); @@ -740,7 +740,7 @@ void OgreMovableText::UpdateColors() unsigned int i; IGN_ASSERT(this->font, "font class member is null"); -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 IGN_ASSERT(!this->ogreMaterial.isNull(), "ogreMaterial class member is null"); #else IGN_ASSERT(this->ogreMaterial, "ogreMaterial class member is null"); @@ -769,7 +769,7 @@ void OgreMovableText::UpdateColors() ////////////////////////////////////////////////// void OgreMovableText::UpdateMaterial() { -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 if (this->ogreMaterial.isNull()) #else if (!this->ogreMaterial) @@ -859,7 +859,7 @@ void OgreMovableText::getRenderOperation(Ogre::RenderOperation &_op) ////////////////////////////////////////////////// const Ogre::MaterialPtr &OgreMovableText::getMaterial(void) const { -#if OGRE_VERSION_LT_1_10_1 +#if OGRE_VERSION_LT_1_11_0 IGN_ASSERT(!this->ogreMaterial.isNull(), "ogreMaterial class member is null"); #else IGN_ASSERT(this->ogreMaterial, "ogreMaterial class member is null"); diff --git a/ogre/src/OgreThermalCamera.cc b/ogre/src/OgreThermalCamera.cc index cf8b7a7ac..84d6a76f8 100644 --- a/ogre/src/OgreThermalCamera.cc +++ b/ogre/src/OgreThermalCamera.cc @@ -149,7 +149,7 @@ OgreThermalCameraMaterialSwitcher::OgreThermalCameraMaterialSwitcher( Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); // OGRE 1.9 changes the shared pointer definition - #if OGRE_VERSION_LT_1_10_1 + #if OGRE_VERSION_LT_1_11_0 this->heatSourceMaterial = res.staticCast(); #else this->heatSourceMaterial = @@ -422,7 +422,7 @@ void OgreThermalCamera::CreateThermalTexture() Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); // OGRE 1.9 changes the shared pointer definition - #if OGRE_VERSION_LT_1_10_1 + #if OGRE_VERSION_LT_1_11_0 this->dataPtr->thermalMaterial = res.staticCast(); #else this->dataPtr->thermalMaterial = From cde3e08d94ae8134b4e72c6875437fe970ac43df Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Tue, 12 Oct 2021 19:44:39 +0100 Subject: [PATCH 12/26] [macOS] modify definition of bufferFetch1 to work when GL_ARB_texture_buffer_range is not available (#462) - The definition of bufferFetch1 was failing for OpenGL < 4.2 resulting in compile errors for lighting shaders Signed-off-by: Rhys Mainwaring --- .../media/Hlms/Common/GLSL/CrossPlatformSettings_piece_all.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogre2/src/media/Hlms/Common/GLSL/CrossPlatformSettings_piece_all.glsl b/ogre2/src/media/Hlms/Common/GLSL/CrossPlatformSettings_piece_all.glsl index fa0587f04..44b3e0af5 100644 --- a/ogre2/src/media/Hlms/Common/GLSL/CrossPlatformSettings_piece_all.glsl +++ b/ogre2/src/media/Hlms/Common/GLSL/CrossPlatformSettings_piece_all.glsl @@ -113,7 +113,7 @@ #define OGRE_Load3D( tex, iuv, lod ) texelFetch( tex, ivec3( iuv ), lod ) -#define bufferFetch1( buffer, idx ) texelFetch( buffer, idx ).x +#define bufferFetch1( buffer, idx ) bufferFetch( buffer, idx ).x #define OGRE_SAMPLER_ARG_DECL( samplerName ) #define OGRE_SAMPLER_ARG( samplerName ) From 5e183b5087df0d88e3f5ffb7dc81e130dc58c59c Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Tue, 12 Oct 2021 17:32:13 -0700 Subject: [PATCH 13/26] Fix selection buffer material script (#456) Signed-off-by: Ian Chen --- .../materials/scripts/selection_buffer.material | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ogre2/src/media/materials/scripts/selection_buffer.material b/ogre2/src/media/materials/scripts/selection_buffer.material index a23bcf287..62c3137d2 100644 --- a/ogre2/src/media/materials/scripts/selection_buffer.material +++ b/ogre2/src/media/materials/scripts/selection_buffer.material @@ -15,6 +15,16 @@ * */ +vertex_program selection_buffer_vs glsl +{ + // reuse depth camera vertex shader + source depth_camera_vs.glsl + default_params + { + param_named_auto worldViewProj worldviewproj_matrix + } +} + fragment_program selection_buffer_fs glsl { source selection_buffer_fs.glsl @@ -34,9 +44,7 @@ material SelectionBuffer pass { // Make this pass use the vertex shader defined above - vertex_program_ref DepthCameraVS - { - } + vertex_program_ref selection_buffer_vs { } // Make this pass use the pixel shader defined above fragment_program_ref selection_buffer_fs { } From 1c77a8ac05cce3ed5a5b99e56030db833ad67b0a Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Tue, 12 Oct 2021 22:02:05 -0700 Subject: [PATCH 14/26] fix grayscale albedo map (#466) Signed-off-by: Ian Chen --- ogre2/src/Ogre2Material.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ogre2/src/Ogre2Material.cc b/ogre2/src/Ogre2Material.cc index f3151f332..6e5215220 100644 --- a/ogre2/src/Ogre2Material.cc +++ b/ogre2/src/Ogre2Material.cc @@ -657,7 +657,10 @@ void Ogre2Material::SetTextureMapImpl(const std::string &_texture, // otherwise this becomes a transparent material if (_type == Ogre::PBSM_DIFFUSE) { - if (this->TextureAlphaEnabled()) + bool isGrayscale = (Ogre::PixelFormatGpuUtils::getNumberOfComponents( + tex->getPixelFormat()) == 1u); + + if (this->TextureAlphaEnabled() || isGrayscale) { if (tex) { @@ -665,15 +668,15 @@ void Ogre2Material::SetTextureMapImpl(const std::string &_texture, tex->waitForData(); // only enable alpha from texture if texture has alpha component - if (!Ogre::PixelFormatGpuUtils::hasAlpha(tex->getPixelFormat())) + if (this->TextureAlphaEnabled() && + !Ogre::PixelFormatGpuUtils::hasAlpha(tex->getPixelFormat())) { this->SetAlphaFromTexture(false, this->AlphaThreshold(), this->TwoSidedEnabled()); } // treat grayscale texture as RGB - if (Ogre::PixelFormatGpuUtils::getNumberOfComponents( - tex->getPixelFormat()) == 1u) + if (isGrayscale) { this->ogreDatablock->setUseDiffuseMapAsGrayscale(true); } From e61ff3c5bc448d4639ba9393035e494cfe9d28c1 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Wed, 13 Oct 2021 19:57:49 +0200 Subject: [PATCH 15/26] Avoid symbol redefition to fix armel builds (#457) * Avoid symbol redefiniition on armel builds Signed-off-by: Jose Luis Rivero --- include/ignition/rendering/Storage.hh | 5 +++++ ogre/include/ignition/rendering/ogre/OgreStorage.hh | 7 ++++++- ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh | 7 ++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/ignition/rendering/Storage.hh b/include/ignition/rendering/Storage.hh index 82f741045..653269932 100644 --- a/include/ignition/rendering/Storage.hh +++ b/include/ignition/rendering/Storage.hh @@ -294,6 +294,10 @@ namespace ignition public: virtual ~StoreWrapper() { } }; +// armhf failed to build with this code. It can not be removed for the rest +// of arches to keep ABI but should be removed in major versions unreleased +// see https://github.com/ignitionrobotics/ign-rendering/pull/457 +#ifndef __ARM_PCS_VFP template class Store; template class Store; template class Store; @@ -303,6 +307,7 @@ namespace ignition template class Store; template class Map; template class CompositeStore; +#endif /// \def SceneStore /// \brief Store of Scene diff --git a/ogre/include/ignition/rendering/ogre/OgreStorage.hh b/ogre/include/ignition/rendering/ogre/OgreStorage.hh index b0468277f..bd113c1fb 100644 --- a/ogre/include/ignition/rendering/ogre/OgreStorage.hh +++ b/ogre/include/ignition/rendering/ogre/OgreStorage.hh @@ -34,7 +34,11 @@ namespace ignition namespace rendering { inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // + +// armhf failed to build with this code. It can not be removed for the rest +// of arches to keep ABI but should be removed in major versions unreleased +// see https://github.com/ignitionrobotics/ign-rendering/pull/457 +#ifndef __ARM_PCS_VFP template class BaseSceneStore; template class BaseNodeStore; template class BaseLightStore; @@ -43,6 +47,7 @@ namespace ignition template class BaseGeometryStore; template class BaseSubMeshStore; template class BaseMaterialMap; +#endif typedef BaseSceneStore OgreSceneStore; typedef BaseNodeStore OgreNodeStore; diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh index b37291179..318cf7da5 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Storage.hh @@ -33,7 +33,11 @@ namespace ignition namespace rendering { inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { - // + +// armhf failed to build with this code. It can not be removed for the rest +// of arches to keep ABI but should be removed in major versions unreleased +// see https://github.com/ignitionrobotics/ign-rendering/pull/457 +#ifndef __ARM_PCS_VFP template class BaseGeometryStore; template class BaseLightStore; template class BaseNodeStore; @@ -41,6 +45,7 @@ namespace ignition template class BaseSensorStore; template class BaseSubMeshStore; template class BaseVisualStore; +#endif typedef BaseGeometryStore Ogre2GeometryStore; typedef BaseLightStore Ogre2LightStore; From a8ac08c804e61c32a19f4d65e04cc40fa9b4e6ce Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Thu, 14 Oct 2021 17:00:46 -0700 Subject: [PATCH 16/26] Merge pull request #458 from ignitionrobotics/chapulina/bump_7 Bump main to 7.0.0~pre1 --- CMakeLists.txt | 4 ++-- Changelog.md | 4 ++++ examples/actor_animation/CMakeLists.txt | 2 +- examples/camera_tracking/CMakeLists.txt | 2 +- examples/custom_scene_viewer/CMakeLists.txt | 2 +- examples/custom_shaders/CMakeLists.txt | 2 +- examples/custom_shaders_uniforms/CMakeLists.txt | 2 +- examples/gazebo_scene_viewer/CMakeLists.txt | 2 +- examples/heightmap/CMakeLists.txt | 2 +- examples/hello_world_plugin/CMakeLists.txt | 2 +- examples/lidar_visual/CMakeLists.txt | 2 +- examples/mesh_viewer/CMakeLists.txt | 2 +- examples/mouse_picking/CMakeLists.txt | 2 +- examples/ogre2_demo/CMakeLists.txt | 2 +- examples/particles_demo/CMakeLists.txt | 2 +- examples/render_pass/CMakeLists.txt | 2 +- examples/segmentation_camera/CMakeLists.txt | 2 +- examples/simple_demo/CMakeLists.txt | 2 +- examples/simple_demo_qml/CMakeLists.txt | 2 +- examples/text_geom/CMakeLists.txt | 2 +- examples/thermal_camera/CMakeLists.txt | 2 +- examples/transform_control/CMakeLists.txt | 2 +- examples/view_control/CMakeLists.txt | 2 +- examples/visualization_demo/CMakeLists.txt | 2 +- tutorials/17_render_pass_tutorial.md | 2 +- tutorials/18_simple_demo_tutorial.md | 2 +- tutorials/19_text_geom_tutorial.md | 2 +- tutorials/20_particles_tutorial.md | 2 +- tutorials/21_heightmap.md | 2 +- 29 files changed, 33 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f84ba440..15fbbbcdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-rendering6 VERSION 6.0.0) +project(ignition-rendering7 VERSION 7.0.0) #============================================================================ # Find ignition-cmake @@ -15,7 +15,7 @@ set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR}) #============================================================================ # Set up the project #============================================================================ -ign_configure_project(VERSION_SUFFIX pre2) +ign_configure_project(VERSION_SUFFIX pre1) #============================================================================ # Set project-specific options diff --git a/Changelog.md b/Changelog.md index 5c6ea524c..464f47ca8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ ## Ignition Rendering +### Ignition Rendering 7.X + +### Ignition Rendering 7.0.0 (202X-XX-XX) + ### Ignition Rendering 6.X ### Ignition Rendering 6.0.0 (20XX-XX-XX) diff --git a/examples/actor_animation/CMakeLists.txt b/examples/actor_animation/CMakeLists.txt index 1b2119d0d..caab3b48f 100644 --- a/examples/actor_animation/CMakeLists.txt +++ b/examples/actor_animation/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-actor-animation) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/camera_tracking/CMakeLists.txt b/examples/camera_tracking/CMakeLists.txt index 4c2b3b221..ff857e727 100644 --- a/examples/camera_tracking/CMakeLists.txt +++ b/examples/camera_tracking/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-camera-tracking) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) find_package(GLUT REQUIRED) include_directories(SYSTEM ${GLUT_INCLUDE_DIRS}) diff --git a/examples/custom_scene_viewer/CMakeLists.txt b/examples/custom_scene_viewer/CMakeLists.txt index 5846bbdb1..98ac3493d 100644 --- a/examples/custom_scene_viewer/CMakeLists.txt +++ b/examples/custom_scene_viewer/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-custom-scene-viewer) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/custom_shaders/CMakeLists.txt b/examples/custom_shaders/CMakeLists.txt index e9c922162..3da852c14 100644 --- a/examples/custom_shaders/CMakeLists.txt +++ b/examples/custom_shaders/CMakeLists.txt @@ -5,7 +5,7 @@ include_directories(SYSTEM ${PROJECT_BINARY_DIR} ) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) find_package(GLUT REQUIRED) include_directories(SYSTEM ${GLUT_INCLUDE_DIRS}) diff --git a/examples/custom_shaders_uniforms/CMakeLists.txt b/examples/custom_shaders_uniforms/CMakeLists.txt index 5fc59e542..ad95b14b9 100644 --- a/examples/custom_shaders_uniforms/CMakeLists.txt +++ b/examples/custom_shaders_uniforms/CMakeLists.txt @@ -5,7 +5,7 @@ include_directories(SYSTEM ${PROJECT_BINARY_DIR} ) -find_package(ignition-rendering6) +find_package(ignition-rendering7) set(TARGET_THIRD_PARTY_DEPENDS "") diff --git a/examples/gazebo_scene_viewer/CMakeLists.txt b/examples/gazebo_scene_viewer/CMakeLists.txt index 3ce7a5b5b..19c4dd01a 100644 --- a/examples/gazebo_scene_viewer/CMakeLists.txt +++ b/examples/gazebo_scene_viewer/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-gazebo-scene-viewer) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) find_package(gazebo REQUIRED) include_directories(SYSTEM ${GAZEBO_INCLUDE_DIRS}) diff --git a/examples/heightmap/CMakeLists.txt b/examples/heightmap/CMakeLists.txt index 4b7c2e060..d4e7a24eb 100644 --- a/examples/heightmap/CMakeLists.txt +++ b/examples/heightmap/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-heightmap) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/hello_world_plugin/CMakeLists.txt b/examples/hello_world_plugin/CMakeLists.txt index 94cae8f92..e1036550e 100644 --- a/examples/hello_world_plugin/CMakeLists.txt +++ b/examples/hello_world_plugin/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) set(IGN_PLUGIN_VER 1) set(IGN_COMMON_VER 3) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) find_package(ignition-plugin1 REQUIRED COMPONENTS all) add_library(HelloWorldPlugin SHARED HelloWorldPlugin.cc) diff --git a/examples/lidar_visual/CMakeLists.txt b/examples/lidar_visual/CMakeLists.txt index a9664be5f..3cad6641c 100644 --- a/examples/lidar_visual/CMakeLists.txt +++ b/examples/lidar_visual/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-lidar_visual) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/mesh_viewer/CMakeLists.txt b/examples/mesh_viewer/CMakeLists.txt index abf9ea18f..3bc3f6e76 100644 --- a/examples/mesh_viewer/CMakeLists.txt +++ b/examples/mesh_viewer/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-mesh-viewer) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/mouse_picking/CMakeLists.txt b/examples/mouse_picking/CMakeLists.txt index 1268d0bf1..f1db8b24f 100644 --- a/examples/mouse_picking/CMakeLists.txt +++ b/examples/mouse_picking/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-mouse-picking) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/ogre2_demo/CMakeLists.txt b/examples/ogre2_demo/CMakeLists.txt index 2ad666669..4ff93954e 100644 --- a/examples/ogre2_demo/CMakeLists.txt +++ b/examples/ogre2_demo/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) project(ignition-rendering-ogre2-demo) -find_package(ignition-rendering6) +find_package(ignition-rendering7) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/particles_demo/CMakeLists.txt b/examples/particles_demo/CMakeLists.txt index c03b334c7..53baebfc8 100644 --- a/examples/particles_demo/CMakeLists.txt +++ b/examples/particles_demo/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-particles-demo) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/render_pass/CMakeLists.txt b/examples/render_pass/CMakeLists.txt index eec9ca335..b25c2a99b 100644 --- a/examples/render_pass/CMakeLists.txt +++ b/examples/render_pass/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-render-pass) -find_package(ignition-rendering6) +find_package(ignition-rendering7) find_package(GLUT REQUIRED) include_directories(SYSTEM ${GLUT_INCLUDE_DIRS}) diff --git a/examples/segmentation_camera/CMakeLists.txt b/examples/segmentation_camera/CMakeLists.txt index 06816095b..5cfb5b471 100644 --- a/examples/segmentation_camera/CMakeLists.txt +++ b/examples/segmentation_camera/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-segmentation-camera) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/simple_demo/CMakeLists.txt b/examples/simple_demo/CMakeLists.txt index f182d176e..13f790dc2 100644 --- a/examples/simple_demo/CMakeLists.txt +++ b/examples/simple_demo/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-simple-demo) -find_package(ignition-rendering6) +find_package(ignition-rendering7) find_package(GLUT REQUIRED) include_directories(SYSTEM ${GLUT_INCLUDE_DIRS}) diff --git a/examples/simple_demo_qml/CMakeLists.txt b/examples/simple_demo_qml/CMakeLists.txt index a4dcf597e..1786c1e2f 100644 --- a/examples/simple_demo_qml/CMakeLists.txt +++ b/examples/simple_demo_qml/CMakeLists.txt @@ -14,7 +14,7 @@ set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR}) #------------------------------------------------------------------------ # Find ign-rendering -find_package(ignition-rendering6) +find_package(ignition-rendering7) #====================================== # Find Qt diff --git a/examples/text_geom/CMakeLists.txt b/examples/text_geom/CMakeLists.txt index 6859c39df..87b470cd0 100644 --- a/examples/text_geom/CMakeLists.txt +++ b/examples/text_geom/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-text-geom) -find_package(ignition-rendering6) +find_package(ignition-rendering7) find_package(GLUT REQUIRED) include_directories(SYSTEM ${GLUT_INCLUDE_DIRS}) diff --git a/examples/thermal_camera/CMakeLists.txt b/examples/thermal_camera/CMakeLists.txt index de0531a8f..dd68d67fe 100644 --- a/examples/thermal_camera/CMakeLists.txt +++ b/examples/thermal_camera/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-thermal-camera) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/transform_control/CMakeLists.txt b/examples/transform_control/CMakeLists.txt index ddeb66a91..8f8c15997 100644 --- a/examples/transform_control/CMakeLists.txt +++ b/examples/transform_control/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-transform-control) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) include_directories(SYSTEM ${PROJECT_BINARY_DIR} diff --git a/examples/view_control/CMakeLists.txt b/examples/view_control/CMakeLists.txt index e9334fe60..97c9fcfab 100644 --- a/examples/view_control/CMakeLists.txt +++ b/examples/view_control/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-view-control) -find_package(ignition-rendering6 REQUIRED) +find_package(ignition-rendering7 REQUIRED) find_package(GLUT REQUIRED) include_directories(SYSTEM ${GLUT_INCLUDE_DIRS}) diff --git a/examples/visualization_demo/CMakeLists.txt b/examples/visualization_demo/CMakeLists.txt index 21474cd5d..7001b2cf5 100644 --- a/examples/visualization_demo/CMakeLists.txt +++ b/examples/visualization_demo/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-visualization-demo) -find_package(ignition-rendering6) +find_package(ignition-rendering7) if (APPLE OR UNIX) find_package(GLUT REQUIRED) diff --git a/tutorials/17_render_pass_tutorial.md b/tutorials/17_render_pass_tutorial.md index 3d5e8e10d..fb0185fbd 100644 --- a/tutorials/17_render_pass_tutorial.md +++ b/tutorials/17_render_pass_tutorial.md @@ -23,7 +23,7 @@ Execute the example: You'll see: ```{.sh} -[Msg] Loading plugin [ignition-rendering6-ogre] +[Msg] Loading plugin [ignition-rendering7-ogre] Engine 'optix' is not supported =============================== TAB - Switch render engines diff --git a/tutorials/18_simple_demo_tutorial.md b/tutorials/18_simple_demo_tutorial.md index 373824769..11b54a9fb 100644 --- a/tutorials/18_simple_demo_tutorial.md +++ b/tutorials/18_simple_demo_tutorial.md @@ -23,7 +23,7 @@ Execute the example: You'll see: ```{.sh} -[Msg] Loading plugin [ignition-rendering6-ogre] +[Msg] Loading plugin [ignition-rendering7-ogre] Engine 'optix' is not supported =============================== TAB - Switch render engines diff --git a/tutorials/19_text_geom_tutorial.md b/tutorials/19_text_geom_tutorial.md index cad86252d..25166c8fb 100644 --- a/tutorials/19_text_geom_tutorial.md +++ b/tutorials/19_text_geom_tutorial.md @@ -23,7 +23,7 @@ Execute the example: You'll see: ```{.sh} -[Msg] Loading plugin [ignition-rendering6-ogre] +[Msg] Loading plugin [ignition-rendering7-ogre] Engine 'optix' is not supported =============================== TAB - Switch render engines diff --git a/tutorials/20_particles_tutorial.md b/tutorials/20_particles_tutorial.md index 7a74e0eeb..42dc9a506 100644 --- a/tutorials/20_particles_tutorial.md +++ b/tutorials/20_particles_tutorial.md @@ -23,7 +23,7 @@ Execute the example: You'll see: ```{.sh} -[Msg] Loading plugin [ignition-rendering6-ogre2] +[Msg] Loading plugin [ignition-rendering7-ogre2] =============================== TAB - Switch render engines ESC - Exit diff --git a/tutorials/21_heightmap.md b/tutorials/21_heightmap.md index 677ee5d30..8a2431d95 100644 --- a/tutorials/21_heightmap.md +++ b/tutorials/21_heightmap.md @@ -25,7 +25,7 @@ Execute the example: You'll see: ```{.sh} -[Msg] Loading plugin [ignition-rendering6-ogre] +[Msg] Loading plugin [ignition-rendering7-ogre] [Msg] Loading heightmap: scene::Heightmap(65528) [Msg] Heightmap loaded. Process took 217 ms. =============================== From 676321e8eb30d1125932618073cf47af9713782e Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Fri, 15 Oct 2021 01:23:54 +0100 Subject: [PATCH 17/26] [Ogre2] fix invalid anti-aliasing level warning (#470) - Fix a bug where the warning of an invalid anti-aliasing level in Ogre2RenderTarget was not being output - Set the FSAA level to 0 if the target level is invalid - Provide a list of valid options in the warning Signed-off-by: Rhys Mainwaring --- ogre2/src/Ogre2RenderTarget.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ogre2/src/Ogre2RenderTarget.cc b/ogre2/src/Ogre2RenderTarget.cc index 88b4679f2..a47321b60 100644 --- a/ogre2/src/Ogre2RenderTarget.cc +++ b/ogre2/src/Ogre2RenderTarget.cc @@ -560,10 +560,20 @@ uint8_t Ogre2RenderTarget::TargetFSAA() const { // output warning but only do it once static bool ogre2FSAAWarn = false; - if (ogre2FSAAWarn) + if (!ogre2FSAAWarn) { + std::ostringstream os; + os << "[ "; + for (auto &&level : fsaaLevels) + { + os << level << " "; + } + os << "]"; + ignwarn << "Anti-aliasing level of '" << this->antiAliasing << "' " - << "is not supported. Setting to 0" << std::endl; + << "is not supported; valid FSAA levels are: " << os.str() + << ". Setting to 0" << std::endl; + targetFSAA = 0u; ogre2FSAAWarn = true; } } From 53a188798b94121e8d273d197030f93c81f7bb7b Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Fri, 15 Oct 2021 20:15:15 +0200 Subject: [PATCH 18/26] Fix logic on warning for ogre versions different than 1.9.x (#465) * Fix logic on warning for ogre versions different than 1.9.x Signed-off-by: Jose Luis Rivero --- CMakeLists.txt | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95f568dc5..05cf326fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,28 +61,19 @@ endif() # Find OGRE list(APPEND ign_ogre_components "RTShaderSystem" "Terrain" "Overlay") -# Ogre versions greater than 1.9 are not officialy supported. +ign_find_package(IgnOGRE VERSION 1.9.0 + COMPONENTS ${ign_ogre_components} + REQUIRED_BY ogre + PRIVATE_FOR ogre) + +# Ogre versions greater than 1.9.x are not officialy supported. # Display a warning for the users on this setup unless they provide # USE_UNOFFICIAL_OGRE_VERSIONS flag if (NOT USE_UNOFFICIAL_OGRE_VERSIONS) - # Only for checking the ogre version - ign_find_package(IgnOGRE VERSION 1.10 QUIET) - - if (OGRE_FOUND) + if (${OGRE_VERSION} VERSION_GREATER_EQUAL 1.10.0) IGN_BUILD_WARNING("Ogre 1.x versions greater than 1.9 are not officially supported." "The software might compile and even work but support from upstream" "could be reduced to accepting patches for newer versions") - ign_find_package(IgnOGRE VERSION 1.10 - COMPONENTS ${ign_ogre_components} - REQUIRED_BY ogre - PRIVATE_FOR ogre) - else() - # If ogre 1.10 or greater was not found, then proceed to look for 1.9.x - # versions which are offically supported - ign_find_package(IgnOGRE VERSION 1.9.0 - COMPONENTS ${ign_ogre_components} - REQUIRED_BY ogre - PRIVATE_FOR ogre) endif() endif() From 0973b0b2fb7f9657f0d64abbfca8e249e8f1742f Mon Sep 17 00:00:00 2001 From: Hill Ma Date: Mon, 18 Oct 2021 17:10:15 -0700 Subject: [PATCH 19/26] Fix context attributes of glXCreateContextAttribsARB. (#460) Signed-off-by: Hill Ma --- ogre2/src/Ogre2RenderEngine.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index 32225c31f..77ffcebc1 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -374,7 +374,6 @@ void Ogre2RenderEngine::CreateContext() int contextAttribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 3, - GLX_CONTEXT_FLAGS_ARB , GLX_CONTEXT_CORE_PROFILE_BIT_ARB, None }; this->dummyContext = From 7c1430daf5100314c9791bf9dc5c9386c4096b0b Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 18 Oct 2021 22:13:00 -0700 Subject: [PATCH 20/26] Merge pull request #356 from ignitionrobotics/lidar_near_clip Fix lidar near plane clipping --- .../rendering/ogre2/Ogre2RenderEngine.hh | 5 + ogre2/src/Ogre2GpuRays.cc | 56 +++++++- ogre2/src/Ogre2IgnHlmsCustomizations.cc | 128 ++++++++++++++++++ ogre2/src/Ogre2IgnHlmsCustomizations.hh | 118 ++++++++++++++++ ogre2/src/Ogre2RenderEngine.cc | 19 +++ .../Ignition/IgnCustomStructs_piece_all.any | 11 ++ .../src/media/Hlms/Ignition/Ign_piece_vs.any | 15 ++ .../materials/programs/plain_color_vs.glsl | 16 +++ .../media/materials/scripts/gpu_rays.material | 3 + .../media/materials/scripts/picker.material | 3 + .../media/materials/scripts/thermal.material | 3 + 11 files changed, 374 insertions(+), 3 deletions(-) create mode 100644 ogre2/src/Ogre2IgnHlmsCustomizations.cc create mode 100644 ogre2/src/Ogre2IgnHlmsCustomizations.hh create mode 100644 ogre2/src/media/Hlms/Ignition/IgnCustomStructs_piece_all.any create mode 100644 ogre2/src/media/Hlms/Ignition/Ign_piece_vs.any diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh index 42d1f53ab..ffe3a2194 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh @@ -52,6 +52,7 @@ namespace ignition // // forward declaration class Ogre2RenderEnginePrivate; + class Ogre2IgnHlmsCustomizations; /// \brief Plugin for loading ogre render engine class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderEnginePlugin : @@ -173,6 +174,10 @@ namespace ignition /// \return a list of FSAA levels public: std::vector FSAALevels() const; + /// \brief Retrieves Hlms customizations for tweaking them + /// \return Ogre HLMS customizations + public: Ogre2IgnHlmsCustomizations &HlmsCustomizations(); + /// \internal /// \brief Get a pointer to the Ogre overlay system. /// \return Pointer to the ogre overlay system. diff --git a/ogre2/src/Ogre2GpuRays.cc b/ogre2/src/Ogre2GpuRays.cc index ea2d28103..26b0f2064 100644 --- a/ogre2/src/Ogre2GpuRays.cc +++ b/ogre2/src/Ogre2GpuRays.cc @@ -33,6 +33,7 @@ #include "ignition/rendering/ogre2/Ogre2Sensor.hh" #include "ignition/rendering/ogre2/Ogre2Visual.hh" +#include "Ogre2IgnHlmsCustomizations.hh" #include "Ogre2ParticleNoiseListener.hh" #ifdef _MSC_VER @@ -186,6 +187,9 @@ class ignition::rendering::Ogre2GpuRaysPrivate /// emitter region public: std::unique_ptr particleNoiseListener[6]; + /// \brief Near clip plane for cube camera + public: float nearClipCube = 0.0; + /// \brief Min allowed angle in radians; public: const math::Angle kMinAllowedAngle = 1e-4; }; @@ -212,6 +216,16 @@ Ogre2LaserRetroMaterialSwitcher::Ogre2LaserRetroMaterialSwitcher( void Ogre2LaserRetroMaterialSwitcher::cameraPreRenderScene( Ogre::Camera * /*_cam*/) { + { + auto engine = Ogre2RenderEngine::Instance(); + Ogre2IgnHlmsCustomizations &hlmsCustomizations = + engine->HlmsCustomizations(); + Ogre::Pass *pass = + this->laserRetroSourceMaterial->getBestTechnique()->getPass(0u); + pass->getVertexProgramParameters()->setNamedConstant( + "ignMinClipDistance", hlmsCustomizations.minDistanceClip ); + } + // swap item to use v1 shader material // Note: keep an eye out for performance impact on switching materials // on the fly. We are not doing this often so should be ok. @@ -309,6 +323,11 @@ void Ogre2LaserRetroMaterialSwitcher::cameraPostRenderScene( Ogre::SubItem *subItem = it.first; subItem->setDatablock(it.second); } + + Ogre::Pass *pass = + this->laserRetroSourceMaterial->getBestTechnique()->getPass(0u); + pass->getVertexProgramParameters()->setNamedConstant( + "ignMinClipDistance", 0.0f ); } @@ -515,8 +534,17 @@ void Ogre2GpuRays::ConfigureCamera() v |= v >> 8; v |= v >> 16; v++; + + // limit min texture size to 128 + // This is needed for large fov with low sample count, + // e.g. 360 degrees and only 4 samples. Otherwise the depth data returned are + // inaccurate. + // \todo(anyone) For small fov, we shouldn't need such a high min texture size + // requirement, e.g. a single ray lidar only needs 1x1 texture. Look for ways + // to compute the optimal min texture size + unsigned int min1stPassSamples = 128u; + // limit max texture size to 1024 - unsigned int min1stPassSamples = 2u; unsigned int max1stPassSamples = 1024u; unsigned int samples1stPass = std::clamp(v, min1stPassSamples, max1stPassSamples); @@ -527,7 +555,7 @@ void Ogre2GpuRays::ConfigureCamera() this->SetRangeCount(this->RangeCount(), this->VerticalRangeCount()); // Set ogre cam properties - this->dataPtr->ogreCamera->setNearClipDistance(this->NearClipPlane()); + this->dataPtr->ogreCamera->setNearClipDistance(this->dataPtr->nearClipCube); this->dataPtr->ogreCamera->setFarClipDistance(this->FarClipPlane()); } @@ -989,7 +1017,7 @@ void Ogre2GpuRays::Setup1stPass() this->ogreNode->attachObject(this->dataPtr->cubeCam[i]); this->dataPtr->cubeCam[i]->setFOVy(Ogre::Degree(90)); this->dataPtr->cubeCam[i]->setAspectRatio(1); - this->dataPtr->cubeCam[i]->setNearClipDistance(this->NearClipPlane()); + this->dataPtr->cubeCam[i]->setNearClipDistance(this->dataPtr->nearClipCube); this->dataPtr->cubeCam[i]->setFarClipDistance(this->FarClipPlane()); this->dataPtr->cubeCam[i]->setFixedYawAxis(false); this->dataPtr->cubeCam[i]->yaw(Ogre::Degree(-90)); @@ -1198,6 +1226,15 @@ void Ogre2GpuRays::Setup2ndPass() ///////////////////////////////////////////////////////// void Ogre2GpuRays::CreateGpuRaysTextures() { + // make cube cam near clip smaller than specified and manually clip range + // values in 1st pass shader (gpu_rays_1st_pass_fs.glsl). + // This is so that we don't incorrectly clip the range values near the + // corners of the cube cam viewport. + + // compute smallest box to fit in sphere with radius = this->NearClipPlane + double boxSize = this->NearClipPlane() * 2 / std::sqrt(3.0); + this->dataPtr->nearClipCube = boxSize * 0.5; + this->ConfigureCamera(); this->CreateSampleTexture(); this->Setup1stPass(); @@ -1247,8 +1284,21 @@ void Ogre2GpuRays::Render() { this->scene->StartRendering(nullptr); + auto engine = Ogre2RenderEngine::Instance(); + + // The Hlms customizations add a "spherical" clipping; which ignores depth + // clamping as it clips before sending vertices to the pixel shader. + // These customization can be used to implement multi-tiered + // "near plane distances" as proposed in: + // https://github.com/ignitionrobotics/ign-rendering/issues/395 + Ogre2IgnHlmsCustomizations &hlmsCustomizations = + engine->HlmsCustomizations(); + + hlmsCustomizations.minDistanceClip = + static_cast(this->NearClipPlane()); this->UpdateRenderTarget1stPass(); this->UpdateRenderTarget2ndPass(); + hlmsCustomizations.minDistanceClip = -1; this->scene->FlushGpuCommandsAndStartNewFrame(6u, false); } diff --git a/ogre2/src/Ogre2IgnHlmsCustomizations.cc b/ogre2/src/Ogre2IgnHlmsCustomizations.cc new file mode 100644 index 000000000..1cdeb5b0a --- /dev/null +++ b/ogre2/src/Ogre2IgnHlmsCustomizations.cc @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include "Ogre2IgnHlmsCustomizations.hh" + +#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" + +#ifdef _MSC_VER + #pragma warning(push, 0) +#endif +#include +#include +#include +#include +#include +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +using namespace ignition; +using namespace rendering; + +////////////////////////////////////////////////// +void Ogre2IgnHlmsCustomizations::preparePassHash( + const Ogre::CompositorShadowNode */*_shadowNode*/, + bool _casterPass, bool /*_dualParaboloid*/, + Ogre::SceneManager */*_sceneManager*/, + Ogre::Hlms *_hlms) +{ + this->needsWorldPos = false; + if (!_casterPass && this->MinDistanceClipEnabled()) + { + const Ogre::int32 numClipPlanes = + _hlms->_getProperty("hlms_pso_clip_distances"); + _hlms->_setProperty("ign_spherical_clip_min_distance", 1); + _hlms->_setProperty("ign_spherical_clip_idx", numClipPlanes); + _hlms->_setProperty("hlms_pso_clip_distances", numClipPlanes + 1); + + if (_hlms->getType() == Ogre::HLMS_UNLIT) + { + if (_hlms->_getProperty("hlms_global_clip_planes") == 0) + { + this->needsWorldPos = true; + _hlms->_setProperty("ign_spherical_clip_needs_worldPos", 1); + } + } + } +} + +////////////////////////////////////////////////// +Ogre::uint32 Ogre2IgnHlmsCustomizations::getPassBufferSize( + const Ogre::CompositorShadowNode */*_shadowNode*/, + bool _casterPass, bool /*_dualParaboloid*/, + Ogre::SceneManager */*_sceneManager*/) const +{ + if (_casterPass || !this->MinDistanceClipEnabled()) + return 0u; + + Ogre::uint32 bufferSize = sizeof(float) * 4u; + if (this->needsWorldPos) + bufferSize += sizeof(float) * 16u; + + return bufferSize; +} + +////////////////////////////////////////////////// +float* Ogre2IgnHlmsCustomizations::preparePassBuffer( + const Ogre::CompositorShadowNode */*_shadowNode*/, + bool _casterPass, bool /*_dualParaboloid*/, + Ogre::SceneManager *_sceneManager, + float *_passBufferPtr) +{ + if (!_casterPass && this->MinDistanceClipEnabled()) + { + const Ogre::Camera *camera = + _sceneManager->getCamerasInProgress().renderingCamera; + const Ogre::Vector3 &camPos = camera->getDerivedPosition(); + + // float4 ignMinClipDistance_ignCameraPos + *_passBufferPtr++ = this->minDistanceClip; + *_passBufferPtr++ = camPos.x; + *_passBufferPtr++ = camPos.y; + *_passBufferPtr++ = camPos.z; + + if (this->needsWorldPos) + { + // TODO(dark_sylinc): Modify Ogre to access HlmsUnlit::mPreparedPass + // so we get the view matrix that's going to be used instead of + // recalculating everything again (which can get complex if VR is + // being used) + auto engine = Ogre2RenderEngine::Instance(); + auto ogreRoot = engine->OgreRoot(); + Ogre::RenderPassDescriptor *renderPassDesc = + ogreRoot->getRenderSystem()->getCurrentPassDescriptor(); + Ogre::Matrix4 projectionMatrix = + camera->getProjectionMatrixWithRSDepth(); + if (renderPassDesc->requiresTextureFlipping()) + { + projectionMatrix[1][0] = -projectionMatrix[1][0]; + projectionMatrix[1][1] = -projectionMatrix[1][1]; + projectionMatrix[1][2] = -projectionMatrix[1][2]; + projectionMatrix[1][3] = -projectionMatrix[1][3]; + } + + Ogre::Matrix4 invViewProj = (projectionMatrix * + camera->getViewMatrix(true)).inverse(); + for (size_t i = 0; i < 16u; ++i) + { + *_passBufferPtr++ = static_cast(invViewProj[0][i]); + } + } + } + return _passBufferPtr; +} diff --git a/ogre2/src/Ogre2IgnHlmsCustomizations.hh b/ogre2/src/Ogre2IgnHlmsCustomizations.hh new file mode 100644 index 000000000..474b083b6 --- /dev/null +++ b/ogre2/src/Ogre2IgnHlmsCustomizations.hh @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef IGNITION_RENDERING_OGRE2_OGRE2IGNHLMSCUSTOMIZATIONS_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2IGNHLMSCUSTOMIZATIONS_HH_ + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/ogre2/Export.hh" + +#ifdef _MSC_VER + #pragma warning(push, 0) +#endif +#include +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + // + /// \brief Controls custom shader snippets of Hlms (both Pbs and Unlit): + /// + /// - Toggles them on/off + /// - Sends relevant data to the GPU buffers for shaders to use + /// + /// This listener requires Hlms to have been created with the piece data + /// files in ogre2/src/media/Hlms/Ignition registered + /// + /// \internal + /// \remark Public variables take effect immediately (i.e. for the + /// next render) + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2IgnHlmsCustomizations final : + public Ogre::HlmsListener + { + public: + virtual ~Ogre2IgnHlmsCustomizations() = default; + + /// \brief + /// \return Returns true if spherical clipping customizations should + /// be active + public: bool MinDistanceClipEnabled() const + { + return this->minDistanceClip >= 0.0f; + } + + /// \brief Determines which custom pieces we should activate + /// \param _casterPass + /// \param _hlms + private: virtual void preparePassHash( + const Ogre::CompositorShadowNode *_shadowNode, + bool _casterPass, bool _dualParaboloid, + Ogre::SceneManager *_sceneManager, + Ogre::Hlms *_hlms) override; + + /// \brief Tells Ogre the buffer data sent to GPU should be a little + /// bigger to fit our data we need to send + /// + /// This data is sent in Ogre2IgnHlmsCustomizations::preparePassBuffer + /// \param _casterPass + /// \param _hlms + private: virtual Ogre::uint32 getPassBufferSize( + const Ogre::CompositorShadowNode *_shadowNode, + bool _casterPass, bool _dualParaboloid, + Ogre::SceneManager *_sceneManager) const override; + + /// \brief Sends our custom data to GPU buffers that our + /// pieces activated in Ogre2IgnHlmsCustomizations::preparePassHash + /// will need. + /// + /// Bytes written must not exceed what we informed in getPassBufferSize + /// \param _casterPass + /// \param _sceneManager + /// \param _passBufferPtr + /// \return The pointer where Ogre should continue appending more data + private: virtual float* preparePassBuffer( + const Ogre::CompositorShadowNode *_shadowNode, + bool _casterPass, bool _dualParaboloid, + Ogre::SceneManager *_sceneManager, + float *_passBufferPtr) override; + + /// \brief Min distance to clip geometry against in a spherical manner + /// (i.e. vertices that are too close to camera are clipped) + /// Usually this means the min lidar distance + /// + /// Regular near clip distance clips in a rectangular way, so + /// it's not enough. + /// + /// Set to a negative value to disable (0 does NOT disable it!) + /// + /// See https://github.com/ignitionrobotics/ign-rendering/pull/356 + public: float minDistanceClip = -1.0f; + + /// \brief When true, we're currently dealing with HlmsUnlit + /// where we need to define and calculate `float3 worldPos` + /// \internal + private: bool needsWorldPos = false; + }; + } + } +} +#endif diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index cda537ea7..12ce79a5c 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -44,6 +44,7 @@ #include "Terra/Hlms/OgreHlmsTerra.h" #include "Terra/Hlms/PbsListener/OgreHlmsPbsTerraShadows.h" #include "Terra/TerraWorkspaceListener.h" +#include "Ogre2IgnHlmsCustomizations.hh" class ignition::rendering::Ogre2RenderEnginePrivate { @@ -54,6 +55,9 @@ class ignition::rendering::Ogre2RenderEnginePrivate /// \brief A list of supported fsaa levels public: std::vector fsaaLevels; + /// \brief Controls Hlms customizations for both PBS and Unlit + public: ignition::rendering::Ogre2IgnHlmsCustomizations hlmsCustomizations; + /// \brief Pbs listener that adds terra shadows public: std::unique_ptr hlmsPbsTerraShadows; @@ -677,6 +681,10 @@ void Ogre2RenderEngine::RegisterHlms() Ogre::ArchiveManager &archiveManager = Ogre::ArchiveManager::getSingleton(); + Ogre::Archive *customizationsArchiveLibrary = + archiveManager.load(common::joinPaths(rootHlmsFolder, "Hlms", "Ignition"), + "FileSystem", true); + { Ogre::HlmsUnlit *hlmsUnlit = 0; // Create & Register HlmsUnlit @@ -696,6 +704,8 @@ void Ogre2RenderEngine::RegisterHlms() ++libraryFolderPathIt; } + archiveUnlitLibraryFolders.push_back(customizationsArchiveLibrary); + // Create and register the unlit Hlms hlmsUnlit = OGRE_NEW Ogre::HlmsUnlit(archiveUnlit, &archiveUnlitLibraryFolders); @@ -703,6 +713,7 @@ void Ogre2RenderEngine::RegisterHlms() // disable writting debug output to disk hlmsUnlit->setDebugOutputPath(false, false); + hlmsUnlit->setListener(&this->dataPtr->hlmsCustomizations); } { @@ -726,6 +737,7 @@ void Ogre2RenderEngine::RegisterHlms() ++libraryFolderPathIt; } + archivePbsLibraryFolders.push_back(customizationsArchiveLibrary); { archivePbsLibraryFolders.push_back(archiveManager.load( rootHlmsFolder + common::joinPaths("Hlms", "Terra", "GLSL", @@ -740,6 +752,7 @@ void Ogre2RenderEngine::RegisterHlms() // disable writting debug output to disk hlmsPbs->setDebugOutputPath(false, false); + hlmsPbs->setListener(&this->dataPtr->hlmsCustomizations); } { @@ -942,6 +955,12 @@ std::vector Ogre2RenderEngine::FSAALevels() const return this->dataPtr->fsaaLevels; } +///////////////////////////////////////////////// +Ogre2IgnHlmsCustomizations& Ogre2RenderEngine::HlmsCustomizations() +{ + return this->dataPtr->hlmsCustomizations; +} + ///////////////////////////////////////////////// Ogre::v1::OverlaySystem *Ogre2RenderEngine::OverlaySystem() const { diff --git a/ogre2/src/media/Hlms/Ignition/IgnCustomStructs_piece_all.any b/ogre2/src/media/Hlms/Ignition/IgnCustomStructs_piece_all.any new file mode 100644 index 000000000..5c21d621d --- /dev/null +++ b/ogre2/src/media/Hlms/Ignition/IgnCustomStructs_piece_all.any @@ -0,0 +1,11 @@ +@property( ign_spherical_clip_min_distance ) + @piece( custom_passBuffer ) + #define ignMinClipDistance ignMinClipDistance_ignCameraPos.x + #define ignCameraPos ignMinClipDistance_ignCameraPos.yzw + float4 ignMinClipDistance_ignCameraPos; + + @property( ign_spherical_clip_needs_worldPos ) + float4x4 invViewProj; + @end + @end +@end diff --git a/ogre2/src/media/Hlms/Ignition/Ign_piece_vs.any b/ogre2/src/media/Hlms/Ignition/Ign_piece_vs.any new file mode 100644 index 000000000..757b8166a --- /dev/null +++ b/ogre2/src/media/Hlms/Ignition/Ign_piece_vs.any @@ -0,0 +1,15 @@ +@property( ign_spherical_clip_min_distance ) + @piece( custom_vs_posExecution ) + @property( ign_spherical_clip_needs_worldPos ) + // Unlit didn't declare this + float3 worldPos = (gl_Position * passBuf.invViewProj).xyz; + @end + + // Ogre 2.2 should use outVs_clipDistanceN for compatibility with all + // APIs + // Rare case of geometry without normals. + gl_ClipDistance[@value(ign_spherical_clip_idx)] = + distance( worldPos.xyz, passBuf.ignCameraPos.xyz ) - + passBuf.ignMinClipDistance; + @end +@end diff --git a/ogre2/src/media/materials/programs/plain_color_vs.glsl b/ogre2/src/media/materials/programs/plain_color_vs.glsl index 240d20d18..68a9047da 100644 --- a/ogre2/src/media/materials/programs/plain_color_vs.glsl +++ b/ogre2/src/media/materials/programs/plain_color_vs.glsl @@ -19,14 +19,30 @@ in vec4 vertex; uniform mat4 worldViewProj; +uniform mat4 worldView; +uniform float ignMinClipDistance; out gl_PerVertex { vec4 gl_Position; + float gl_ClipDistance[1]; }; void main() { // Calculate output position gl_Position = worldViewProj * vertex; + + if( ignMinClipDistance > 0.0f ) + { + // Frustum is rectangular; but the minimum lidar distance is spherical, + // so we can't rely on near plane to clip geometry that is too close, + // we have to do it by hand + vec3 viewSpacePos = (worldView * vertex).xyz; + gl_ClipDistance[0] = length( viewSpacePos.xyz ) - ignMinClipDistance; + } + else + { + gl_ClipDistance[0] = 1.0f; + } } diff --git a/ogre2/src/media/materials/scripts/gpu_rays.material b/ogre2/src/media/materials/scripts/gpu_rays.material index 6c1549360..2341df7e4 100644 --- a/ogre2/src/media/materials/scripts/gpu_rays.material +++ b/ogre2/src/media/materials/scripts/gpu_rays.material @@ -128,10 +128,13 @@ material GpuRaysScan2nd vertex_program laser_retro_vs glsl { source plain_color_vs.glsl + num_clip_distances 1 default_params { param_named_auto worldViewProj worldviewproj_matrix + param_named_auto worldView worldview_matrix + param_named ignMinClipDistance float 0.0 } } diff --git a/ogre2/src/media/materials/scripts/picker.material b/ogre2/src/media/materials/scripts/picker.material index 5bf67970e..2fec2bde3 100644 --- a/ogre2/src/media/materials/scripts/picker.material +++ b/ogre2/src/media/materials/scripts/picker.material @@ -1,10 +1,13 @@ vertex_program plaincolor_vs glsl { source plain_color_vs.glsl + num_clip_distances 1 default_params { param_named_auto worldViewProj worldviewproj_matrix + param_named_auto worldView worldview_matrix + param_named ignMinClipDistance float 0.0 } } diff --git a/ogre2/src/media/materials/scripts/thermal.material b/ogre2/src/media/materials/scripts/thermal.material index eecc3f19a..840c07e70 100644 --- a/ogre2/src/media/materials/scripts/thermal.material +++ b/ogre2/src/media/materials/scripts/thermal.material @@ -60,10 +60,13 @@ material ThermalCamera vertex_program heat_source_vs glsl { source plain_color_vs.glsl + num_clip_distances 1 default_params { param_named_auto worldViewProj worldviewproj_matrix + param_named_auto worldView worldview_matrix + param_named ignMinClipDistance float 0.0 } } From 63264a97ee97fc259303cbda275e7bc05c496cf0 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 28 Oct 2021 09:53:52 -0700 Subject: [PATCH 21/26] add 64 bit int support to user data (#479) Signed-off-by: Ian Chen --- include/ignition/rendering/Node.hh | 2 +- src/Visual_TEST.cc | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/ignition/rendering/Node.hh b/include/ignition/rendering/Node.hh index fc33d1794..077010e79 100644 --- a/include/ignition/rendering/Node.hh +++ b/include/ignition/rendering/Node.hh @@ -44,7 +44,7 @@ namespace ignition /// "empty variant" should be returned for keys that don't exist) using Variant = std::variant; + unsigned int, int64_t, uint64_t>; /// \class Node Node.hh ignition/rendering/Node.hh /// \brief Represents a single posable node in the scene graph diff --git a/src/Visual_TEST.cc b/src/Visual_TEST.cc index a15d8a467..9552b3f86 100644 --- a/src/Visual_TEST.cc +++ b/src/Visual_TEST.cc @@ -379,6 +379,24 @@ void VisualTest::UserData(const std::string &_renderEngine) value = visual->UserData(unsignedIntKey); EXPECT_EQ(unsignedIntValue, std::get(value)); + // int64_t + std::string int64Key = "int64_t"; + int64_t int64Value = -math::MAX_I64; + EXPECT_FALSE(visual->HasUserData(int64Key)); + visual->SetUserData(int64Key, int64Value); + EXPECT_TRUE(visual->HasUserData(int64Key)); + value = visual->UserData(int64Key); + EXPECT_EQ(int64Value, std::get(value)); + + // uint64_t + std::string uint64Key = "uint64_t"; + uint64_t uint64Value = math::MAX_UI64; + EXPECT_FALSE(visual->HasUserData(uint64Key)); + visual->SetUserData(uint64Key, uint64Value); + EXPECT_TRUE(visual->HasUserData(uint64Key)); + value = visual->UserData(uint64Key); + EXPECT_EQ(uint64Value, std::get(value)); + // test a key that does not exist (should return no data) value = visual->UserData("invalidKey"); EXPECT_FALSE(std::holds_alternative(value)); From 8554ec16053280025974954328b6e2c2d748d30d Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 28 Oct 2021 18:06:49 -0700 Subject: [PATCH 22/26] fix readme merge Signed-off-by: Ian Chen --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f3be7f0bb..e6e6cfed3 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ Build | Status -- | -- -Test coverage | [![codecov](https://codecov.io/gh/ignitionrobotics/ign-rendering/branch/ign-rendering6/graph/badge.svg)](https://codecov.io/gh/ignitionrobotics/ign-rendering/branch/ign-rendering6) -Ubuntu Bionic | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_rendering-ci-ign-rendering6-bionic-amd64)](https://build.osrfoundation.org/job/ignition_rendering-ci-ign-rendering6-bionic-amd64) -Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_rendering-ci-ign-rendering6-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_rendering-ci-ign-rendering6-homebrew-amd64) -Windows | [![Build Status](https://build.osrfoundation.org/job/ign_rendering-ign-6-win/badge/icon)](https://build.osrfoundation.org/job/ign_rendering-ign-6-win/) +Test coverage | [![codecov](https://codecov.io/gh/ignitionrobotics/ign-rendering/branch/main/graph/badge.svg)](https://codecov.io/gh/ignitionrobotics/ign-rendering/branch/default) +Ubuntu Bionic | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_rendering-ci-main-bionic-amd64)](https://build.osrfoundation.org/job/ignition_rendering-ci-main-bionic-amd64) +Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_rendering-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_rendering-ci-main-homebrew-amd64) +Windows | [![Build Status](https://build.osrfoundation.org/job/ign_rendering-ci-win/badge/icon)](https://build.osrfoundation.org/job/ign_rendering-ci-win/) Ignition Rendering is a C++ library designed to provide an abstraction for different rendering engines. It offers unified APIs for creating From bfb22fb1f9bee5643c4407ae05ec24857c200bbf Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 1 Nov 2021 10:33:06 -0700 Subject: [PATCH 23/26] Fix Utils unit test (#481) * update scaling ratio Signed-off-by: Ian Chen * update center click Signed-off-by: Ian Chen * revert change Signed-off-by: Ian Chen * sytle Signed-off-by: Ian Chen --- src/Utils_TEST.cc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Utils_TEST.cc b/src/Utils_TEST.cc index 5c61d1e73..d75e57daa 100644 --- a/src/Utils_TEST.cc +++ b/src/Utils_TEST.cc @@ -130,15 +130,6 @@ void UtilTest::ClickToScene(const std::string &_renderEngine) return; } - // \todo(anyone) - // the centerClick var above is set to a screen pos of (width/2, height/2). - // This is off-by-1. The actual center pos should be at - // (width/2 - 1, height/2 - 1) so the result.X() and result.Y() is a bit off - // from the expected position. However, fixing the centerClick above caused - // the screenToPlane tests to fail so only modifying the pos here, and the - // cause of test failure need to be investigated. - centerClick = ignition::math::Vector2i(halfWidth-1, halfHeight-1); - // API without RayQueryResult and default max distance result = screenToScene(centerClick, camera, rayQuery, rayResult); From 8ea86c93fada9f7266427edb7f4a29e9ff202aab Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Mon, 1 Nov 2021 10:46:36 -0700 Subject: [PATCH 24/26] Add a method to render targets and cameras to retrieve a Metal texture (#478) * [Metal] Add a method to render targets and cameras to retrieve the Metal texture id - These functions provide the Metal equivalent of GLId() and RenderTextureGLId() for OpenGL. - The argument is the address of a pointer to void* as the object required for Metal is an objective-c type id which we do not want exposed in the interface - There is a runtime dependency on an upstream change to ogre-next: https://github.com/OGRECave/ogre-next/pull/237/commits/3b1187398f3410b0ec82d3fbd8ce564ace4d02f7 Signed-off-by: Rhys Mainwaring * [Metal] Fix inconsistent parameter name in RenderTextureMetalId - Fix an inconsistent parameter name causing a CI failure. Signed-off-by: Rhys Mainwaring * [Metal] Fix unused parameter warning in RenderTextureMetalId - Fix an unused parameter warning causing a CI failure. Signed-off-by: Rhys Mainwaring Co-authored-by: Ian Chen --- include/ignition/rendering/Camera.hh | 8 ++++++++ include/ignition/rendering/RenderTarget.hh | 7 +++++++ include/ignition/rendering/base/BaseCamera.hh | 12 ++++++++++++ .../ignition/rendering/base/BaseRenderTarget.hh | 9 +++++++++ .../ignition/rendering/ogre2/Ogre2Camera.hh | 4 ++++ .../rendering/ogre2/Ogre2RenderTarget.hh | 6 ++++++ ogre2/src/Ogre2Camera.cc | 15 +++++++++++++++ ogre2/src/Ogre2RenderTarget.cc | 16 ++++++++++++++++ 8 files changed, 77 insertions(+) diff --git a/include/ignition/rendering/Camera.hh b/include/ignition/rendering/Camera.hh index f39108262..0d04cfb24 100644 --- a/include/ignition/rendering/Camera.hh +++ b/include/ignition/rendering/Camera.hh @@ -317,6 +317,14 @@ namespace ignition /// \return Texture Id of type GLuint. public: virtual unsigned int RenderTextureGLId() const = 0; + /// \brief Get the Metal texture id associated with the render texture + /// used by this camera. A valid Id is obtained only if the underlying + /// render engine is Metal based. + /// The pointer set by this function must be released to an + /// id using CFBridgingRelease. + /// \param[out] _textureIdPtr the address of a void* pointer. + public: virtual void RenderTextureMetalId(void *_textureIdPtr) const = 0; + /// \brief Add a render pass to the camera /// \param[in] _pass New render pass to add public: virtual void AddRenderPass(const RenderPassPtr &_pass) = 0; diff --git a/include/ignition/rendering/RenderTarget.hh b/include/ignition/rendering/RenderTarget.hh index 8a37987a1..532129d99 100644 --- a/include/ignition/rendering/RenderTarget.hh +++ b/include/ignition/rendering/RenderTarget.hh @@ -109,6 +109,13 @@ namespace ignition /// \brief Returns the OpenGL texture Id. A valid Id is returned only // if this is an OpenGL render texture public: virtual unsigned int GLId() const = 0; + + /// \brief Gets the Metal texture id. A valid Id is obtained only + /// if this is an Metal render texture. + /// The pointer set by this function must be released to an + /// id using CFBridgingRelease. + /// \param[out] _textureIdPtr the address of a void* pointer. + public: virtual void MetalId(void *_textureIdPtr) const = 0; }; /* \class RenderWindow RenderWindow.hh \ diff --git a/include/ignition/rendering/base/BaseCamera.hh b/include/ignition/rendering/base/BaseCamera.hh index e48fe887e..531a22147 100644 --- a/include/ignition/rendering/base/BaseCamera.hh +++ b/include/ignition/rendering/base/BaseCamera.hh @@ -179,6 +179,10 @@ namespace ignition // Documentation inherited. public: virtual unsigned int RenderTextureGLId() const override; + // Documentation inherited. + public: virtual void RenderTextureMetalId(void *_textureIdPtr) + const override; + // Documentation inherited. public: virtual void AddRenderPass(const RenderPassPtr &_pass) override; @@ -804,6 +808,14 @@ namespace ignition return 0u; } + ////////////////////////////////////////////////// + template + void BaseCamera::RenderTextureMetalId(void */*_textureIdPtr*/) const + { + ignerr << "RenderTextureMetalId is not supported by current render" + << " engine" << std::endl; + } + ////////////////////////////////////////////////// template void BaseCamera::AddRenderPass(const RenderPassPtr &_pass) diff --git a/include/ignition/rendering/base/BaseRenderTarget.hh b/include/ignition/rendering/base/BaseRenderTarget.hh index c0c795c79..c1311cef1 100644 --- a/include/ignition/rendering/base/BaseRenderTarget.hh +++ b/include/ignition/rendering/base/BaseRenderTarget.hh @@ -105,6 +105,9 @@ namespace ignition // Documentation inherited. public: virtual unsigned int GLId() const override; + + // Documentation inherited. + public: virtual void MetalId(void *_textureIdPtr) const override; }; template @@ -291,6 +294,12 @@ namespace ignition return 0u; } + ////////////////////////////////////////////////// + template + void BaseRenderTexture::MetalId(void */*_textureIdPtr*/) const + { + } + ////////////////////////////////////////////////// // BaseRenderWindow ////////////////////////////////////////////////// diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh index e5b7a0436..e7bd02c11 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh @@ -114,6 +114,10 @@ namespace ignition // Documentation inherited. public: virtual unsigned int RenderTextureGLId() const override; + // Documentation inherited. + public: virtual void RenderTextureMetalId(void *_textureIdPtr) + const override; + // Documentation inherited. public: void SetShadowsDirty() override; diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh index 229157378..e4df31750 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh @@ -136,6 +136,9 @@ namespace ignition // Documentation inherited public: unsigned int GLIdImpl() const; + // Documentation inherited + public: void MetalIdImpl(void *_textureIdPtr) const; + /// \brief Destroy the render texture protected: void DestroyTargetImpl(); @@ -253,6 +256,9 @@ namespace ignition // Documentation inherited public: virtual unsigned int GLId() const override; + // Documentation inherited + public: virtual void MetalId(void *_textureIdPtr) const override; + // Documentation inherited // TODO(anyone): this function should be removed. // We didn't do it to preserve ABI. diff --git a/ogre2/src/Ogre2Camera.cc b/ogre2/src/Ogre2Camera.cc index 86d1d7b96..ada411d69 100644 --- a/ogre2/src/Ogre2Camera.cc +++ b/ogre2/src/Ogre2Camera.cc @@ -207,6 +207,21 @@ unsigned int Ogre2Camera::RenderTextureGLId() const return rt->GLId(); } +////////////////////////////////////////////////// +void Ogre2Camera::RenderTextureMetalId(void *_textureIdPtr) const +{ + if (!this->renderTexture) + return; + + Ogre2RenderTexturePtr rt = + std::dynamic_pointer_cast(this->renderTexture); + + if (!rt) + return; + + rt->MetalId(_textureIdPtr); +} + ////////////////////////////////////////////////// void Ogre2Camera::SetShadowsDirty() { diff --git a/ogre2/src/Ogre2RenderTarget.cc b/ogre2/src/Ogre2RenderTarget.cc index 88b4679f2..7abd56e1a 100644 --- a/ogre2/src/Ogre2RenderTarget.cc +++ b/ogre2/src/Ogre2RenderTarget.cc @@ -547,6 +547,16 @@ unsigned int Ogre2RenderTarget::GLIdImpl() const return static_cast(texId); } +////////////////////////////////////////////////// +void Ogre2RenderTarget::MetalIdImpl(void *_textureIdPtr) const +{ + if (!this->dataPtr->ogreTexture[0]) + return; + + this->dataPtr->ogreTexture[1]-> + getCustomAttribute("msFinalTextureBuffer", _textureIdPtr); +} + ////////////////////////////////////////////////// uint8_t Ogre2RenderTarget::TargetFSAA() const { @@ -883,6 +893,12 @@ unsigned int Ogre2RenderTexture::GLId() const return Ogre2RenderTarget::GLIdImpl(); } +////////////////////////////////////////////////// +void Ogre2RenderTexture::MetalId(void *_textureIdPtr) const +{ + Ogre2RenderTarget::MetalIdImpl(_textureIdPtr); +} + ////////////////////////////////////////////////// void Ogre2RenderTexture::PreRender() { From a49ebcf9c6c0f839a260b32e603046c73971c99f Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Fri, 5 Nov 2021 16:26:54 -0700 Subject: [PATCH 25/26] Enable ray query for depth, segmentation and thermal cameras (#483) * Enable ray query for depth, segmentation and thermal cameras - Enable depth, segmentation and thermal cameras to set a ray query for ogre and ogre2 render engines - Make the RayQuery a friend of the various camera classes - Update the mouse handling in the segmentation_camera and thermal_camera examples Signed-off-by: Rhys Mainwaring * Fix style for code check - Remove line end whitespace and shorten long lines. Signed-off-by: Rhys Mainwaring * Enable ray query for depth, segmentation and thermal cameras - Enable depth, segmentation and thermal cameras to set a ray query for ogre and ogre2 render engines - Introduce mixin classes to the cameras to expose the underlying Ogre objects - Implement methods to access Ogre::Camera and Ogre::MovableObject pointers on camera implementations - Update ray query to use the new interface Signed-off-by: Rhys Mainwaring * Enable ray query for depth, segmentation and thermal cameras - Fix code check errors Signed-off-by: Rhys Mainwaring * Enable ray query for depth, segmentation and thermal cameras - Fix code check errors - unused parameters. Signed-off-by: Rhys Mainwaring * Enable ray query for depth, segmentation and thermal cameras - Provide default implementation for method `OgreMovableObject` and add file for definition. - Remove empty implementation of `OgreMovableObject` from cameras - Add export declaration to class Signed-off-by: Rhys Mainwaring * Enable ray query for depth, segmentation and thermal cameras - Fix incorrect include path Signed-off-by: Rhys Mainwaring * Enable ray query for depth, segmentation and thermal cameras - Fix issue with the configuration of class exports Signed-off-by: Rhys Mainwaring * Enable ray query for depth, segmentation and thermal cameras - Fix code check errors - unused parameters in default implementation. Signed-off-by: Rhys Mainwaring * Enable ray query for depth, segmentation and thermal cameras - Fix code check errors - unused parameters in default implementation. Signed-off-by: Rhys Mainwaring --- examples/segmentation_camera/GlutWindow.cc | 51 +++-- examples/thermal_camera/GlutWindow.cc | 187 ++++++++++++++++++ .../ignition/rendering/ogre/OgreCamera.hh | 8 +- .../rendering/ogre/OgreDepthCamera.hh | 7 +- .../rendering/ogre/OgreObjectInterface.hh | 50 +++++ .../rendering/ogre/OgreRenderTypes.hh | 2 + .../rendering/ogre/OgreThermalCamera.hh | 7 +- ogre/src/OgreCamera.cc | 12 +- ogre/src/OgreDepthCamera.cc | 6 + ogre/src/OgreObjectInterface.cc | 31 +++ ogre/src/OgreRayQuery.cc | 17 +- ogre/src/OgreThermalCamera.cc | 6 + .../ignition/rendering/ogre2/Ogre2Camera.hh | 9 +- .../rendering/ogre2/Ogre2DepthCamera.hh | 8 +- .../rendering/ogre2/Ogre2ObjectInterface.hh | 50 +++++ .../rendering/ogre2/Ogre2RenderTypes.hh | 2 + .../ogre2/Ogre2SegmentationCamera.hh | 7 +- .../rendering/ogre2/Ogre2ThermalCamera.hh | 8 +- ogre2/src/Ogre2Camera.cc | 12 +- ogre2/src/Ogre2DepthCamera.cc | 6 + ogre2/src/Ogre2ObjectInterface.cc | 31 +++ ogre2/src/Ogre2RayQuery.cc | 28 ++- ogre2/src/Ogre2SegmentationCamera.cc | 6 + ogre2/src/Ogre2ThermalCamera.cc | 6 + 24 files changed, 509 insertions(+), 48 deletions(-) create mode 100644 ogre/include/ignition/rendering/ogre/OgreObjectInterface.hh create mode 100644 ogre/src/OgreObjectInterface.cc create mode 100644 ogre2/include/ignition/rendering/ogre2/Ogre2ObjectInterface.hh create mode 100644 ogre2/src/Ogre2ObjectInterface.cc diff --git a/examples/segmentation_camera/GlutWindow.cc b/examples/segmentation_camera/GlutWindow.cc index 4c6c7f59c..6fa050ffa 100644 --- a/examples/segmentation_camera/GlutWindow.cc +++ b/examples/segmentation_camera/GlutWindow.cc @@ -136,8 +136,7 @@ void motionCB(int _x, int _y) void handleMouse() { std::lock_guard lock(g_mouseMutex); - // only ogre supports ray query for now so use - // ogre camera located at camera index = 0. + ir::CameraPtr rayCamera = g_camera; if (!g_rayQuery) { @@ -152,23 +151,44 @@ void handleMouse() if (g_mouse.buttonDirty) { g_mouse.buttonDirty = false; + + // TODO: enable for segmentation cameras +#if 0 + // test mouse picking + if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) + { + // Get visual using Selection Buffer from Camera + ir::VisualPtr visual; + ignition::math::Vector2i mousePos(g_mouse.x, g_mouse.y); + visual = rayCamera->VisualAt(mousePos); + if (visual) + { + std::cout << "Selected visual at position: "; + std::cout << g_mouse.x << " " << g_mouse.y << ": "; + std::cout << visual->Name() << "\n"; + } + else + { + std::cout << "No visual found at position: "; + std::cout << g_mouse.x << " " << g_mouse.y << std::endl; + } + } +#endif + + // camera orbit double nx = 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; double ny = 1.0 - 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); + g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_target = g_rayQuery->ClosestPoint(); + if (!g_target) + { + // set point to be 10m away if no intersection found + g_target.point = g_rayQuery->Origin() + g_rayQuery->Direction() * 10; + return; + } - // TODO(anyone) figure out why this code is causing a crash - // g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); - // g_target = g_rayQuery->ClosestPoint(); - // if (!g_target) - // { - // // set point to be 10m away if no intersection found - // g_target.point = g_rayQuery->Origin() + g_rayQuery->Direction() * 10; - // return; - // } - - // TODO(anyone) get mouse wheel scroll zoom to work (currently isn't - // working) // mouse wheel scroll zoom if ((g_mouse.button == 3 || g_mouse.button == 4) && g_mouse.state == GLUT_UP) @@ -203,8 +223,7 @@ void handleMouse() g_viewControl.SetTarget(g_target.point); g_viewControl.Orbit(drag); } - // TODO(anyone) get right mouse button zoom to work. Seems to crash when - // used with the RayQuery + // right mouse button zoom else if (g_mouse.button == GLUT_RIGHT_BUTTON && g_mouse.state == GLUT_DOWN) { diff --git a/examples/thermal_camera/GlutWindow.cc b/examples/thermal_camera/GlutWindow.cc index cee056897..2adbc8883 100644 --- a/examples/thermal_camera/GlutWindow.cc +++ b/examples/thermal_camera/GlutWindow.cc @@ -34,8 +34,10 @@ #include #include #include +#include #include #include +#include #include "GlutWindow.hh" @@ -68,6 +70,186 @@ bool g_initContext = false; GLXDrawable g_glutDrawable; #endif +// view control variables +ir::RayQueryPtr g_rayQuery; +ir::OrbitViewController g_viewControl; +ir::RayQueryResult g_target; +struct mouseButton +{ + int button = 0; + int state = GLUT_UP; + int x = 0; + int y = 0; + int motionX = 0; + int motionY = 0; + int dragX = 0; + int dragY = 0; + int scroll = 0; + bool buttonDirty = false; + bool motionDirty = false; +}; +struct mouseButton g_mouse; +std::mutex g_mouseMutex; + +////////////////////////////////////////////////// +void mouseCB(int _button, int _state, int _x, int _y) +{ + // ignore unknown mouse button numbers + if (_button >= 5) + return; + + std::lock_guard lock(g_mouseMutex); + g_mouse.button = _button; + g_mouse.state = _state; + g_mouse.x = _x; + g_mouse.y = _y; + g_mouse.motionX = _x; + g_mouse.motionY = _y; + g_mouse.buttonDirty = true; +} + +////////////////////////////////////////////////// +void motionCB(int _x, int _y) +{ + std::lock_guard lock(g_mouseMutex); + int deltaX = _x - g_mouse.motionX; + int deltaY = _y - g_mouse.motionY; + g_mouse.motionX = _x; + g_mouse.motionY = _y; + + if (g_mouse.motionDirty) + { + g_mouse.dragX += deltaX; + g_mouse.dragY += deltaY; + } + else + { + g_mouse.dragX = deltaX; + g_mouse.dragY = deltaY; + } + g_mouse.motionDirty = true; +} + +////////////////////////////////////////////////// +void handleMouse() +{ + std::lock_guard lock(g_mouseMutex); + // only ogre supports ray query for now so use + // ogre camera located at camera index = 0. + ir::CameraPtr rayCamera = g_cameras[0]; + if (!g_rayQuery) + { + g_rayQuery = rayCamera->Scene()->CreateRayQuery(); + if (!g_rayQuery) + { + ignerr << "Failed to create Ray Query" << std::endl; + return; + } + } + if (g_mouse.buttonDirty) + { + g_mouse.buttonDirty = false; + + // TODO: enable for thermal cameras +#if 0 + // test mouse picking + if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) + { + // Get visual using Selection Buffer from Camera + ir::VisualPtr visual; + ignition::math::Vector2i mousePos(g_mouse.x, g_mouse.y); + visual = rayCamera->VisualAt(mousePos); + if (visual) + { + std::cout << "Selected visual at position: "; + std::cout << g_mouse.x << " " << g_mouse.y << ": "; + std::cout << visual->Name() << "\n"; + } + else + { + std::cout << "No visual found at position: "; + std::cout << g_mouse.x << " " << g_mouse.y << std::endl; + } + } +#endif + + // camera orbit + double nx = + 2.0 * g_mouse.x / static_cast(rayCamera->ImageWidth()) - 1.0; + double ny = 1.0 - + 2.0 * g_mouse.y / static_cast(rayCamera->ImageHeight()); + g_rayQuery->SetFromCamera(rayCamera, ignition::math::Vector2d(nx, ny)); + g_target = g_rayQuery->ClosestPoint(); + if (!g_target) + { + // set point to be 10m away if no intersection found + g_target.point = g_rayQuery->Origin() + g_rayQuery->Direction() * 10; + return; + } + + // mouse wheel scroll zoom + if ((g_mouse.button == 3 || g_mouse.button == 4) && + g_mouse.state == GLUT_UP) + { + double scroll = (g_mouse.button == 3) ? -1.0 : 1.0; + double distance = rayCamera->WorldPosition().Distance( + g_target.point); + int factor = 1; + double amount = -(scroll * factor) * (distance / 5.0); + for (ir::CameraPtr camera : g_cameras) + { + g_viewControl.SetCamera(camera); + g_viewControl.SetTarget(g_target.point); + g_viewControl.Zoom(amount); + } + } + } + + if (g_mouse.motionDirty) + { + g_mouse.motionDirty = false; + auto drag = ignition::math::Vector2d(g_mouse.dragX, g_mouse.dragY); + + // left mouse button pan + if (g_mouse.button == GLUT_LEFT_BUTTON && g_mouse.state == GLUT_DOWN) + { + for (ir::CameraPtr camera : g_cameras) + { + g_viewControl.SetCamera(camera); + g_viewControl.SetTarget(g_target.point); + g_viewControl.Pan(drag); + } + } + else if (g_mouse.button == GLUT_MIDDLE_BUTTON && g_mouse.state == GLUT_DOWN) + { + for (ir::CameraPtr camera : g_cameras) + { + g_viewControl.SetCamera(camera); + g_viewControl.SetTarget(g_target.point); + g_viewControl.Orbit(drag); + } + } + // right mouse button zoom + else if (g_mouse.button == GLUT_RIGHT_BUTTON && g_mouse.state == GLUT_DOWN) + { + double hfov = rayCamera->HFOV().Radian(); + double vfov = 2.0f * atan(tan(hfov / 2.0f) / + rayCamera->AspectRatio()); + double distance = rayCamera->WorldPosition().Distance( + g_target.point); + double amount = ((-g_mouse.dragY / + static_cast(rayCamera->ImageHeight())) + * distance * tan(vfov/2.0) * 6.0); + for (ir::CameraPtr camera : g_cameras) + { + g_viewControl.SetCamera(camera); + g_viewControl.SetTarget(g_target.point); + g_viewControl.Zoom(amount); + } + } + } +} + ////////////////////////////////////////////////// void OnNewThermalFrame(const uint16_t *_scan, unsigned int _width, unsigned int _height, @@ -123,6 +305,8 @@ void displayCB() g_cameras[g_cameraIndex]->Update(); + handleMouse(); + #if __APPLE__ CGLSetCurrentContext(g_glutContext); #elif _WIN32 @@ -191,6 +375,9 @@ void initContext() glutDisplayFunc(displayCB); glutIdleFunc(idleCB); glutKeyboardFunc(keyboardCB); + + glutMouseFunc(mouseCB); + glutMotionFunc(motionCB); } ////////////////////////////////////////////////// diff --git a/ogre/include/ignition/rendering/ogre/OgreCamera.hh b/ogre/include/ignition/rendering/ogre/OgreCamera.hh index 5f8a4ac78..f21e2c8e5 100644 --- a/ogre/include/ignition/rendering/ogre/OgreCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreCamera.hh @@ -21,6 +21,7 @@ #include "ignition/rendering/base/BaseCamera.hh" #include "ignition/rendering/ogre/OgreRenderTypes.hh" +#include "ignition/rendering/ogre/OgreObjectInterface.hh" #include "ignition/rendering/ogre/OgreSensor.hh" #include "ignition/rendering/ogre/OgreSelectionBuffer.hh" @@ -39,7 +40,8 @@ namespace ignition class OgreSelectionBuffer; class IGNITION_RENDERING_OGRE_VISIBLE OgreCamera : - public BaseCamera + public virtual BaseCamera, + public virtual OgreObjectInterface { protected: OgreCamera(); @@ -118,8 +120,8 @@ namespace ignition // Documentation inherited. public: virtual void SetVisibilityMask(uint32_t _mask) override; - /// \brief Get underlying Ogre camera - public: Ogre::Camera *Camera() const; + // Documentation inherited. + public: virtual Ogre::Camera *Camera() const override; // Documentation inherited. // public: virtual uint32_t VisibilityMask() const override; diff --git a/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh b/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh index c989136ca..d04020dab 100644 --- a/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreDepthCamera.hh @@ -31,6 +31,7 @@ #include "ignition/rendering/base/BaseDepthCamera.hh" #include "ignition/rendering/ogre/OgreConversions.hh" #include "ignition/rendering/ogre/OgreIncludes.hh" +#include "ignition/rendering/ogre/OgreObjectInterface.hh" #include "ignition/rendering/ogre/OgreRenderTarget.hh" #include "ignition/rendering/ogre/OgreRenderTypes.hh" #include "ignition/rendering/ogre/OgreScene.hh" @@ -63,7 +64,8 @@ namespace ignition **/ /// \brief Depth camera used to render depth data into an image buffer class IGNITION_RENDERING_OGRE_VISIBLE OgreDepthCamera : - public BaseDepthCamera + public virtual BaseDepthCamera, + public virtual OgreObjectInterface { /// \brief Constructor protected: OgreDepthCamera(); @@ -125,6 +127,9 @@ namespace ignition // Documentation inherited public: virtual void Destroy() override; + // Documentation inherited. + public: virtual Ogre::Camera *Camera() const override; + /// \brief Update a render target /// \param[in] _target Render target to update /// \param[in] _material Material to use diff --git a/ogre/include/ignition/rendering/ogre/OgreObjectInterface.hh b/ogre/include/ignition/rendering/ogre/OgreObjectInterface.hh new file mode 100644 index 000000000..e5ee2717a --- /dev/null +++ b/ogre/include/ignition/rendering/ogre/OgreObjectInterface.hh @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_OGRE_OGREOBJECTINTERFACE_HH_ +#define IGNITION_RENDERING_OGRE_OGREOBJECTINTERFACE_HH_ + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/ogre/OgreIncludes.hh" +#include "ignition/rendering/ogre/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + /// \brief Mixin class to provide direct access to Ogre objects. + class IGNITION_RENDERING_OGRE_VISIBLE OgreObjectInterface + { + public: virtual ~OgreObjectInterface(); + + /// \brief Access to an Ogre::MovableObject. + // + /// \param[in] _typename Name of the object type to retrieve. + /// \return A pointer to an Ogre::MovableObject. Has default nullptr. + public: virtual Ogre::MovableObject *OgreMovableObject( + const char* _typename) const; + + /// \brief Access the Ogre::Camera object. + // + /// \return A pointer to an Ogre::Camera. Has default nullptr. + public: virtual Ogre::Camera *Camera() const = 0; + }; + } + } +} +#endif diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh index e1a60a0d1..9e8292e2b 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTypes.hh @@ -50,6 +50,7 @@ namespace ignition class OgreMeshFactory; class OgreNode; class OgreObject; + class OgreObjectInterface; class OgreParticleEmitter; class OgrePointLight; class OgreRayQuery; @@ -104,6 +105,7 @@ namespace ignition typedef shared_ptr OgreNodePtr; typedef shared_ptr OgreNodeStorePtr; typedef shared_ptr OgreObjectPtr; + typedef shared_ptr OgreObjectInterfacePtr; typedef shared_ptr OgreParticleEmitterPtr; typedef shared_ptr OgrePointLightPtr; typedef shared_ptr OgreRayQueryPtr; diff --git a/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh b/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh index 35e763aff..415618539 100644 --- a/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreThermalCamera.hh @@ -32,6 +32,7 @@ #include "ignition/rendering/ogre/Export.hh" #include "ignition/rendering/ogre/OgreConversions.hh" #include "ignition/rendering/ogre/OgreIncludes.hh" +#include "ignition/rendering/ogre/OgreObjectInterface.hh" #include "ignition/rendering/ogre/OgreRenderTarget.hh" #include "ignition/rendering/ogre/OgreRenderTypes.hh" #include "ignition/rendering/ogre/OgreScene.hh" @@ -61,7 +62,8 @@ namespace ignition **/ /// \brief Depth camera used to render thermal data into an image buffer class IGNITION_RENDERING_OGRE_VISIBLE OgreThermalCamera : - public BaseThermalCamera + public virtual BaseThermalCamera, + public virtual OgreObjectInterface { /// \brief Constructor protected: OgreThermalCamera(); @@ -94,6 +96,9 @@ namespace ignition // Documentation inherited public: virtual void Destroy() override; + // Documentation inherited. + public: virtual Ogre::Camera *Camera() const override; + /// \brief Get a pointer to the render target. /// \return Pointer to the render target protected: virtual RenderTargetPtr RenderTarget() const override; diff --git a/ogre/src/OgreCamera.cc b/ogre/src/OgreCamera.cc index 39a99c3f5..6a8ea4423 100644 --- a/ogre/src/OgreCamera.cc +++ b/ogre/src/OgreCamera.cc @@ -38,12 +38,6 @@ OgreCamera::~OgreCamera() this->Destroy(); } -////////////////////////////////////////////////// -Ogre::Camera *OgreCamera::Camera() const -{ - return this->ogreCamera; -} - ////////////////////////////////////////////////// void OgreCamera::Destroy() { @@ -344,3 +338,9 @@ void OgreCamera::SetVisibilityMask(uint32_t _mask) BaseCamera::SetVisibilityMask(_mask); this->renderTexture->SetVisibilityMask(_mask); } + +////////////////////////////////////////////////// +Ogre::Camera *OgreCamera::Camera() const +{ + return this->ogreCamera; +} diff --git a/ogre/src/OgreDepthCamera.cc b/ogre/src/OgreDepthCamera.cc index a3363be7c..716c7be1b 100644 --- a/ogre/src/OgreDepthCamera.cc +++ b/ogre/src/OgreDepthCamera.cc @@ -582,3 +582,9 @@ double OgreDepthCamera::FarClipPlane() const else return 0; } + +////////////////////////////////////////////////// +Ogre::Camera *OgreDepthCamera::Camera() const +{ + return this->ogreCamera; +} diff --git a/ogre/src/OgreObjectInterface.cc b/ogre/src/OgreObjectInterface.cc new file mode 100644 index 000000000..f1dea5605 --- /dev/null +++ b/ogre/src/OgreObjectInterface.cc @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "ignition/rendering/ogre/OgreObjectInterface.hh" + +using namespace ignition; +using namespace rendering; + +////////////////////////////////////////////////// +OgreObjectInterface::~OgreObjectInterface() = default; + +////////////////////////////////////////////////// +Ogre::MovableObject *OgreObjectInterface::OgreMovableObject( + const char* /*_typename*/) const +{ + return nullptr; +} diff --git a/ogre/src/OgreRayQuery.cc b/ogre/src/OgreRayQuery.cc index a6ffe43da..534d330d7 100644 --- a/ogre/src/OgreRayQuery.cc +++ b/ogre/src/OgreRayQuery.cc @@ -22,8 +22,11 @@ #include "ignition/rendering/ogre/OgreIncludes.hh" #include "ignition/rendering/ogre/OgreCamera.hh" #include "ignition/rendering/ogre/OgreConversions.hh" +#include "ignition/rendering/ogre/OgreDepthCamera.hh" +#include "ignition/rendering/ogre/OgreObjectInterface.hh" #include "ignition/rendering/ogre/OgreRayQuery.hh" #include "ignition/rendering/ogre/OgreScene.hh" +#include "ignition/rendering/ogre/OgreThermalCamera.hh" class ignition::rendering::OgreRayQueryPrivate { @@ -51,9 +54,17 @@ void OgreRayQuery::SetFromCamera(const CameraPtr &_camera, { // convert to nomalized screen pos for ogre math::Vector2d screenPos((_coord.X() + 1.0) / 2.0, (_coord.Y() - 1.0) / -2.0); - OgreCameraPtr camera = std::dynamic_pointer_cast(_camera); - Ogre::Ray ray = - camera->ogreCamera->getCameraToViewportRay(screenPos.X(), screenPos.Y()); + + OgreObjectInterfacePtr ogreObjectInterface = + std::dynamic_pointer_cast(_camera); + if (!ogreObjectInterface) + { + ignwarn << "Camera does not support ray query\n"; + return; + } + + Ogre::Ray ray = ogreObjectInterface->Camera()->getCameraToViewportRay( + screenPos.X(), screenPos.Y()); this->origin = OgreConversions::Convert(ray.getOrigin()); this->direction = OgreConversions::Convert(ray.getDirection()); diff --git a/ogre/src/OgreThermalCamera.cc b/ogre/src/OgreThermalCamera.cc index 84d6a76f8..c201d3d8d 100644 --- a/ogre/src/OgreThermalCamera.cc +++ b/ogre/src/OgreThermalCamera.cc @@ -569,3 +569,9 @@ RenderTargetPtr OgreThermalCamera::RenderTarget() const { return this->dataPtr->thermalTexture; } + +////////////////////////////////////////////////// +Ogre::Camera *OgreThermalCamera::Camera() const +{ + return this->ogreCamera; +} diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh index e7bd02c11..41d857aed 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh @@ -22,6 +22,7 @@ #include "ignition/rendering/base/BaseCamera.hh" #include "ignition/rendering/ogre2/Ogre2RenderTypes.hh" #include "ignition/rendering/ogre2/Ogre2Includes.hh" +#include "ignition/rendering/ogre2/Ogre2ObjectInterface.hh" #include "ignition/rendering/ogre2/Ogre2Sensor.hh" namespace Ogre @@ -41,7 +42,8 @@ namespace ignition /// \brief Ogre2.x implementation of the camera class class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Camera : - public BaseCamera + public virtual BaseCamera, + public virtual Ogre2ObjectInterface { /// \brief Constructor protected: Ogre2Camera(); @@ -124,8 +126,6 @@ namespace ignition // Documentation inherited. public: virtual void Destroy() override; - public: Ogre::Camera *OgreCamera() const; - // Documentation inherited. public: virtual void SetVisibilityMask(uint32_t _mask) override; @@ -133,6 +133,9 @@ namespace ignition /// \return the selection buffer object public: Ogre2SelectionBuffer *SelectionBuffer() const; + // Documentation inherited. + public: virtual Ogre::Camera *OgreCamera() const override; + // Documentation inherited. protected: virtual RenderTargetPtr RenderTarget() const override; diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh index 8c97445fd..84f94ba88 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh @@ -28,6 +28,7 @@ #include #include "ignition/rendering/base/BaseDepthCamera.hh" +#include "ignition/rendering/ogre2/Ogre2ObjectInterface.hh" #include "ignition/rendering/ogre2/Ogre2Sensor.hh" #include "ignition/common/Event.hh" @@ -52,7 +53,8 @@ namespace ignition /// \brief Depth camera used to render depth data into an image buffer class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2DepthCamera : - public BaseDepthCamera + public virtual BaseDepthCamera, + public virtual Ogre2ObjectInterface { /// \brief Constructor protected: Ogre2DepthCamera(); @@ -128,6 +130,9 @@ namespace ignition // Documentation inherited. public: void AddRenderPass(const RenderPassPtr &_pass) override; + // Documentation inherited. + public: virtual Ogre::Camera *OgreCamera() const override; + /// \brief Get a pointer to the render target. /// \return Pointer to the render target protected: virtual RenderTargetPtr RenderTarget() const override; @@ -155,6 +160,7 @@ namespace ignition /// \brief Pointer to private data. private: std::unique_ptr dataPtr; + /// \brief Make scene our friend so it can create a camera private: friend class Ogre2Scene; }; } diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ObjectInterface.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ObjectInterface.hh new file mode 100644 index 000000000..e58187fdc --- /dev/null +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ObjectInterface.hh @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef IGNITION_RENDERING_OGRE2_OGRE2OBJECTINTERFACE_HH_ +#define IGNITION_RENDERING_OGRE2_OGRE2OBJECTINTERFACE_HH_ + +#include "ignition/rendering/config.hh" +#include "ignition/rendering/ogre2/Ogre2Includes.hh" +#include "ignition/rendering/ogre2/Export.hh" + +namespace ignition +{ + namespace rendering + { + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { + + /// \brief Mixin class to provide direct access to Ogre objects. + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ObjectInterface + { + public: virtual ~Ogre2ObjectInterface(); + + /// \brief Access to an Ogre::MovableObject. + // + /// \param[in] _typename Name of the object type to retrieve. + /// \return A pointer to an Ogre::MovableObject. Has default nullptr. + public: virtual Ogre::MovableObject *OgreMovableObject( + const char* _typename) const; + + /// \brief Access the Ogre::Camera object. + // + /// \return A pointer to an Ogre::Camera. Has default nullptr. + public: virtual Ogre::Camera *OgreCamera() const = 0; + }; + } + } +} +#endif diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh index 3a21f81f3..c1cb4de7b 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTypes.hh @@ -51,6 +51,7 @@ namespace ignition class Ogre2MeshFactory; class Ogre2Node; class Ogre2Object; + class Ogre2ObjectInterface; class Ogre2ParticleEmitter; class Ogre2PointLight; class Ogre2RayQuery; @@ -101,6 +102,7 @@ namespace ignition typedef shared_ptr Ogre2MeshFactoryPtr; typedef shared_ptr Ogre2NodePtr; typedef shared_ptr Ogre2ObjectPtr; + typedef shared_ptr Ogre2ObjectInterfacePtr; typedef shared_ptr Ogre2ParticleEmitterPtr; typedef shared_ptr Ogre2PointLightPtr; typedef shared_ptr Ogre2RayQueryPtr; diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh index 89dea5436..66cdec820 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2SegmentationCamera.hh @@ -32,6 +32,7 @@ #include "ignition/rendering/base/BaseSegmentationCamera.hh" #include "ignition/rendering/ogre2/Ogre2Includes.hh" +#include "ignition/rendering/ogre2/Ogre2ObjectInterface.hh" #include "ignition/rendering/ogre2/Ogre2Sensor.hh" namespace ignition @@ -46,7 +47,8 @@ namespace ignition /// \brief Segmentation camera used to label each pixel with a label id. /// Supports Semantic / Panoptic Segmentation class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SegmentationCamera : - public BaseSegmentationCamera + public virtual BaseSegmentationCamera, + public virtual Ogre2ObjectInterface { /// \brief Constructor protected: Ogre2SegmentationCamera(); @@ -86,6 +88,9 @@ namespace ignition public: void LabelMapFromColoredBuffer( uint8_t * _labelBuffer) const override; + // Documentation inherited. + public: virtual Ogre::Camera *OgreCamera() const override; + /// \brief Create the camera. protected: void CreateCamera(); diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh index a6763e510..1afb11c91 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2ThermalCamera.hh @@ -29,6 +29,7 @@ #include "ignition/rendering/base/BaseThermalCamera.hh" #include "ignition/rendering/ogre2/Export.hh" +#include "ignition/rendering/ogre2/Ogre2ObjectInterface.hh" #include "ignition/rendering/ogre2/Ogre2Sensor.hh" #include "ignition/common/Event.hh" @@ -53,7 +54,8 @@ namespace ignition /// \brief Thermal camera used to render thermal data into an image buffer class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2ThermalCamera : - public BaseThermalCamera + public virtual BaseThermalCamera, + public virtual Ogre2ObjectInterface { /// \brief Constructor protected: Ogre2ThermalCamera(); @@ -83,6 +85,9 @@ namespace ignition /// \brief Implementation of the render call public: virtual void Render() override; + // Documentation inherited. + public: virtual Ogre::Camera *OgreCamera() const override; + /// \brief Get a pointer to the render target. /// \return Pointer to the render target protected: virtual RenderTargetPtr RenderTarget() const override; @@ -103,6 +108,7 @@ namespace ignition /// \brief Pointer to private data. private: std::unique_ptr dataPtr; + /// \brief Make scene our friend so it can create a camera private: friend class Ogre2Scene; }; } diff --git a/ogre2/src/Ogre2Camera.cc b/ogre2/src/Ogre2Camera.cc index ada411d69..a758c8b2a 100644 --- a/ogre2/src/Ogre2Camera.cc +++ b/ogre2/src/Ogre2Camera.cc @@ -362,12 +362,6 @@ void Ogre2Camera::SetFarClipPlane(const double _far) this->ogreCamera->setFarClipDistance(_far); } -////////////////////////////////////////////////// -Ogre::Camera *Ogre2Camera::OgreCamera() const -{ - return ogreCamera; -} - ////////////////////////////////////////////////// void Ogre2Camera::SetVisibilityMask(uint32_t _mask) { @@ -375,3 +369,9 @@ void Ogre2Camera::SetVisibilityMask(uint32_t _mask) if (this->renderTexture) this->renderTexture->SetVisibilityMask(_mask); } + +////////////////////////////////////////////////// +Ogre::Camera *Ogre2Camera::OgreCamera() const +{ + return this->ogreCamera; +} diff --git a/ogre2/src/Ogre2DepthCamera.cc b/ogre2/src/Ogre2DepthCamera.cc index 8efec74b2..4694d7bf0 100644 --- a/ogre2/src/Ogre2DepthCamera.cc +++ b/ogre2/src/Ogre2DepthCamera.cc @@ -1269,3 +1269,9 @@ void Ogre2DepthCamera::AddRenderPass(const RenderPassPtr &_pass) this->dataPtr->renderPasses.push_back(depthNoisePass); this->dataPtr->renderPassDirty = true; } + +////////////////////////////////////////////////// +Ogre::Camera *Ogre2DepthCamera::OgreCamera() const +{ + return this->ogreCamera; +} diff --git a/ogre2/src/Ogre2ObjectInterface.cc b/ogre2/src/Ogre2ObjectInterface.cc new file mode 100644 index 000000000..aad3b108d --- /dev/null +++ b/ogre2/src/Ogre2ObjectInterface.cc @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "ignition/rendering/ogre2/Ogre2ObjectInterface.hh" + +using namespace ignition; +using namespace rendering; + +////////////////////////////////////////////////// +Ogre2ObjectInterface::~Ogre2ObjectInterface() = default; + +////////////////////////////////////////////////// +Ogre::MovableObject *Ogre2ObjectInterface::OgreMovableObject( + const char* /*_typename*/) const +{ + return nullptr; +} diff --git a/ogre2/src/Ogre2RayQuery.cc b/ogre2/src/Ogre2RayQuery.cc index fd9f1d1cc..9f9910b02 100644 --- a/ogre2/src/Ogre2RayQuery.cc +++ b/ogre2/src/Ogre2RayQuery.cc @@ -22,9 +22,13 @@ #include "ignition/rendering/ogre2/Ogre2Camera.hh" #include "ignition/rendering/ogre2/Ogre2Conversions.hh" +#include "ignition/rendering/ogre2/Ogre2DepthCamera.hh" +#include "ignition/rendering/ogre2/Ogre2ObjectInterface.hh" #include "ignition/rendering/ogre2/Ogre2RayQuery.hh" #include "ignition/rendering/ogre2/Ogre2Scene.hh" +#include "ignition/rendering/ogre2/Ogre2SegmentationCamera.hh" #include "ignition/rendering/ogre2/Ogre2SelectionBuffer.hh" +#include "ignition/rendering/ogre2/Ogre2ThermalCamera.hh" #ifdef _MSC_VER #pragma warning(push, 0) @@ -75,19 +79,31 @@ void Ogre2RayQuery::SetFromCamera(const CameraPtr &_camera, { // convert to nomalized screen pos for ogre math::Vector2d screenPos((_coord.X() + 1.0) / 2.0, (_coord.Y() - 1.0) / -2.0); + Ogre2CameraPtr camera = std::dynamic_pointer_cast(_camera); - Ogre::Ray ray = - camera->ogreCamera->getCameraToViewportRay(screenPos.X(), screenPos.Y()); + if (camera) + { + this->dataPtr->camera = camera; + } + + Ogre2ObjectInterfacePtr ogre2ObjectInterface = + std::dynamic_pointer_cast(_camera); + if (!ogre2ObjectInterface) + { + ignwarn << "Camera does not support ray query\n"; + return; + } + + Ogre::Ray ray = ogre2ObjectInterface->OgreCamera()->getCameraToViewportRay( + screenPos.X(), screenPos.Y()); this->origin = Ogre2Conversions::Convert(ray.getOrigin()); this->direction = Ogre2Conversions::Convert(ray.getDirection()); - this->dataPtr->camera = camera; - this->dataPtr->imgPos.X() = static_cast( - screenPos.X() * this->dataPtr->camera->ImageWidth()); + screenPos.X() * _camera->ImageWidth()); this->dataPtr->imgPos.Y() = static_cast( - screenPos.Y() * this->dataPtr->camera->ImageHeight()); + screenPos.Y() * _camera->ImageHeight()); } ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2SegmentationCamera.cc b/ogre2/src/Ogre2SegmentationCamera.cc index bb9d1f8df..c31bb6606 100644 --- a/ogre2/src/Ogre2SegmentationCamera.cc +++ b/ogre2/src/Ogre2SegmentationCamera.cc @@ -414,3 +414,9 @@ void Ogre2SegmentationCamera::LabelMapFromColoredBuffer( } } } + +////////////////////////////////////////////////// +Ogre::Camera *Ogre2SegmentationCamera::OgreCamera() const +{ + return this->ogreCamera; +} diff --git a/ogre2/src/Ogre2ThermalCamera.cc b/ogre2/src/Ogre2ThermalCamera.cc index 9b052482a..439d9dbb2 100644 --- a/ogre2/src/Ogre2ThermalCamera.cc +++ b/ogre2/src/Ogre2ThermalCamera.cc @@ -949,3 +949,9 @@ RenderTargetPtr Ogre2ThermalCamera::RenderTarget() const { return this->dataPtr->thermalTexture; } + +////////////////////////////////////////////////// +Ogre::Camera *Ogre2ThermalCamera::OgreCamera() const +{ + return this->ogreCamera; +} From b1d2ac84375b2d68973312cc09f58c306f30c7c1 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 8 Nov 2021 10:51:10 -0800 Subject: [PATCH 26/26] fix windows warnings (#489) Signed-off-by: Ian Chen --- include/ignition/rendering/base/BaseCamera.hh | 2 +- include/ignition/rendering/base/BaseRenderTarget.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ignition/rendering/base/BaseCamera.hh b/include/ignition/rendering/base/BaseCamera.hh index 531a22147..948dfb4f1 100644 --- a/include/ignition/rendering/base/BaseCamera.hh +++ b/include/ignition/rendering/base/BaseCamera.hh @@ -810,7 +810,7 @@ namespace ignition ////////////////////////////////////////////////// template - void BaseCamera::RenderTextureMetalId(void */*_textureIdPtr*/) const + void BaseCamera::RenderTextureMetalId(void *) const { ignerr << "RenderTextureMetalId is not supported by current render" << " engine" << std::endl; diff --git a/include/ignition/rendering/base/BaseRenderTarget.hh b/include/ignition/rendering/base/BaseRenderTarget.hh index c1311cef1..6f4f0c0ff 100644 --- a/include/ignition/rendering/base/BaseRenderTarget.hh +++ b/include/ignition/rendering/base/BaseRenderTarget.hh @@ -296,7 +296,7 @@ namespace ignition ////////////////////////////////////////////////// template - void BaseRenderTexture::MetalId(void */*_textureIdPtr*/) const + void BaseRenderTexture::MetalId(void *) const { }