From 9f97f4279e8c39c3a8308c418ff72132bae36710 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 14 Mar 2024 19:17:42 -0500 Subject: [PATCH 1/9] Prepare for 8.1.0 (#980) Signed-off-by: Addisu Z. Taddese --- CMakeLists.txt | 2 +- Changelog.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acc9c7ca4..6f7c1144b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(gz-rendering8 VERSION 8.0.0) +project(gz-rendering8 VERSION 8.1.0) #============================================================================ # Find gz-cmake diff --git a/Changelog.md b/Changelog.md index 3484f7731..380205530 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,65 @@ ### Gazebo Rendering 8.X +### Gazebo Rendering 8.1.0 (2024-03-14) + +1. Fix setting normal map when not all submeshes have texcoords (ogre2) + * [Pull request #976](https://github.com/gazebosim/gz-rendering/pull/976) + +1. Update ogre2 symbol visibility macro in private classes + * [Pull request #972](https://github.com/gazebosim/gz-rendering/pull/972) + +1. Improve Ogre2DepthCamera performance + * [Pull request #971](https://github.com/gazebosim/gz-rendering/pull/971) + * [Pull request #965](https://github.com/gazebosim/gz-rendering/pull/965) + +1. Fix repeatedly loading engine when calling sceneFromFirstEngine + * [Pull request #961](https://github.com/gazebosim/gz-rendering/pull/961) + +1. Improve Ogre2GpuRays performance + * [Pull request #955](https://github.com/gazebosim/gz-rendering/pull/955) + * [Pull request #973](https://github.com/gazebosim/gz-rendering/pull/973) + +1. Correctly set position-independent code + * [Pull request #950](https://github.com/gazebosim/gz-rendering/pull/950) + +1. Remove todo in gpu ray test + * [Pull request #949](https://github.com/gazebosim/gz-rendering/pull/949) + +1. Update CI badges to point to release branch job + * [Pull request #948](https://github.com/gazebosim/gz-rendering/pull/948) + * [Pull request #947](https://github.com/gazebosim/gz-rendering/pull/947) + +1. Set projector emissive texture + * [Pull request #946](https://github.com/gazebosim/gz-rendering/pull/946) + +1. Add minor comments to BaseGizmoVisual + * [Pull request #881](https://github.com/gazebosim/gz-rendering/pull/881) + +1. Update examples to use metal as default graphics API on mac + * [Pull request #937](https://github.com/gazebosim/gz-rendering/pull/937) + +1. Extend ogre 1.x custom shaders support + * [Pull request #908](https://github.com/gazebosim/gz-rendering/pull/908) + +1. Support skybox in wide angle cam view + * [Pull request #901](https://github.com/gazebosim/gz-rendering/pull/901) + +1. Minor fix for projector visibility flags + * [Pull request #920](https://github.com/gazebosim/gz-rendering/pull/920) + +1. Fix use of srgb format for texture map data + * [Pull request #931](https://github.com/gazebosim/gz-rendering/pull/931) + +1. Infrastructure + * [Pull request #925](https://github.com/gazebosim/gz-rendering/pull/925) + * [Pull request #939](https://github.com/gazebosim/gz-rendering/pull/939) + * [Pull request #940](https://github.com/gazebosim/gz-rendering/pull/940) + * [Pull request #967](https://github.com/gazebosim/gz-rendering/pull/967) + +1. Fix float comparison warnings in test + * [Pull request #929](https://github.com/gazebosim/gz-rendering/pull/929) + ### Gazebo Rendering 8.0.0 (2023-09-29) 1. Remove gazebo scene viewer example From e187f52869d856fefeb1fb84e76a388a896fda89 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 22 Mar 2024 16:52:12 -0700 Subject: [PATCH 2/9] Handle null mesh pointers in examples (#982) Signed-off-by: Ian Chen --- examples/actor_animation/Main.cc | 6 ++++ examples/boundingbox_camera/Main.cc | 27 ++++++++++++------ examples/depth_camera/Main.cc | 21 +++++++++----- examples/global_illumination/Main.cc | 23 +++++++++------ examples/lux_core_engine/Main.cc | 24 ++++++++++------ examples/mesh_viewer/Main.cc | 38 +++++++++++++++++-------- examples/ogre2_demo/Main.cc | 21 +++++++++----- examples/particles_demo/Main.cc | 19 +++++++++---- examples/segmentation_camera/Main.cc | 21 +++++++++----- examples/thermal_camera/Main.cc | 23 +++++++++------ examples/waves/Main.cc | 31 ++++++++++++-------- ogre/src/OgreMeshFactory.cc | 1 - ogre2/src/Ogre2Marker.cc | 3 -- ogre2/src/Ogre2MeshFactory.cc | 1 - src/base/BaseScene.cc | 1 - test/common_test/MeshDescriptor_TEST.cc | 2 +- test/common_test/Mesh_TEST.cc | 2 ++ test/integration/waves.cc | 1 + 18 files changed, 173 insertions(+), 92 deletions(-) diff --git a/examples/actor_animation/Main.cc b/examples/actor_animation/Main.cc index 42d54a658..17dc99a10 100644 --- a/examples/actor_animation/Main.cc +++ b/examples/actor_animation/Main.cc @@ -69,6 +69,12 @@ void buildScene(ScenePtr _scene, std::vector &_visuals, common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); //! [load mesh] + if (!descriptor.mesh) + { + gzerr << "Failed to load mesh: " << descriptor.meshName << std::endl; + // Do not launch example if actor mesh is not found. + return; + } // add bvh animation //! [add animation] diff --git a/examples/boundingbox_camera/Main.cc b/examples/boundingbox_camera/Main.cc index 1cf00c590..0154fe85e 100644 --- a/examples/boundingbox_camera/Main.cc +++ b/examples/boundingbox_camera/Main.cc @@ -53,18 +53,26 @@ VisualPtr createDuck(ScenePtr _scene, n_ducks++; // create a mesh - VisualPtr mesh = _scene->CreateVisual( - "duck" + std::to_string(n_ducks)); - mesh->SetLocalPosition(_position); - mesh->SetLocalRotation(_rotation); + VisualPtr mesh; MeshDescriptor descriptor; descriptor.meshName = common::joinPaths(RESOURCE_PATH, "duck.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); - MeshPtr meshGeom = _scene->CreateMesh(descriptor); - mesh->AddGeometry(meshGeom); - mesh->SetMaterial(_material); - mesh->SetUserData("label", 5); + if (descriptor.mesh) + { + mesh = _scene->CreateVisual( + "duck" + std::to_string(n_ducks)); + mesh->SetLocalPosition(_position); + mesh->SetLocalRotation(_rotation); + MeshPtr meshGeom = _scene->CreateMesh(descriptor); + mesh->AddGeometry(meshGeom); + mesh->SetMaterial(_material); + mesh->SetUserData("label", 5); + } + else + { + gzerr << "Failed load mesh: " << descriptor.meshName << std::endl; + } return mesh; } @@ -168,7 +176,8 @@ void buildScene(ScenePtr _scene, BoundingBoxType _type) // create a mesh auto duck = createDuck(_scene, math::Vector3d(5, 0, 0), skyBlue); - root->AddChild(duck); + if (duck) + root->AddChild(duck); // create a sphere1 auto sphere1 = createSphere(_scene, math::Vector3d(3, -1.5, 0), green); diff --git a/examples/depth_camera/Main.cc b/examples/depth_camera/Main.cc index ff90e5f87..ac715ce5c 100644 --- a/examples/depth_camera/Main.cc +++ b/examples/depth_camera/Main.cc @@ -57,17 +57,24 @@ void buildScene(ScenePtr _scene) root->AddChild(plane); // create a mesh - VisualPtr mesh = _scene->CreateVisual(); - mesh->SetLocalPosition(3, 0, 0); - mesh->SetLocalRotation(1.5708, 0, 2.0); MeshDescriptor descriptor; descriptor.meshName = common::joinPaths(RESOURCE_PATH, "duck.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); - MeshPtr meshGeom = _scene->CreateMesh(descriptor); - mesh->AddGeometry(meshGeom); - mesh->SetUserData("label", 5); - root->AddChild(mesh); + if (descriptor.mesh) + { + VisualPtr mesh = _scene->CreateVisual(); + mesh->SetLocalPosition(3, 0, 0); + mesh->SetLocalRotation(1.5708, 0, 2.0); + MeshPtr meshGeom = _scene->CreateMesh(descriptor); + mesh->AddGeometry(meshGeom); + mesh->SetUserData("label", 5); + root->AddChild(mesh); + } + else + { + gzerr << "Failed load mesh: " << descriptor.meshName << std::endl; + } // create a box VisualPtr box = _scene->CreateVisual("box"); diff --git a/examples/global_illumination/Main.cc b/examples/global_illumination/Main.cc index 6eda827df..a66f75e73 100644 --- a/examples/global_illumination/Main.cc +++ b/examples/global_illumination/Main.cc @@ -70,18 +70,25 @@ void buildScene(ScenePtr _scene) matPBR->SetEnvironmentMap(environmentMap); // create mesh for PBR - VisualPtr meshPBR = _scene->CreateVisual("pump"); - meshPBR->SetLocalPosition(2, 0.0, -0.3); - meshPBR->SetLocalRotation(0, 0, 0); MeshDescriptor descriptorPBR; descriptorPBR.meshName = common::joinPaths(RESOURCE_PATH, "pump.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptorPBR.mesh = meshManager->Load(descriptorPBR.meshName); - MeshPtr meshPBRGeom = _scene->CreateMesh(descriptorPBR); - meshPBRGeom->SetMaterial(matPBR); - meshPBR->AddGeometry(meshPBRGeom); - meshPBR->SetStatic(true); - root->AddChild(meshPBR); + if (descriptorPBR.mesh) + { + VisualPtr meshPBR = _scene->CreateVisual("pump"); + meshPBR->SetLocalPosition(2, 0.0, -0.3); + meshPBR->SetLocalRotation(0, 0, 0); + MeshPtr meshPBRGeom = _scene->CreateMesh(descriptorPBR); + meshPBRGeom->SetMaterial(matPBR); + meshPBR->AddGeometry(meshPBRGeom); + meshPBR->SetStatic(true); + root->AddChild(meshPBR); + } + else + { + gzerr << "Failed load mesh: " << descriptorPBR.meshName << std::endl; + } // create green material MaterialPtr green = _scene->CreateMaterial(); diff --git a/examples/lux_core_engine/Main.cc b/examples/lux_core_engine/Main.cc index 296ea4f89..7191f6f9d 100644 --- a/examples/lux_core_engine/Main.cc +++ b/examples/lux_core_engine/Main.cc @@ -123,19 +123,25 @@ void buildScene(ScenePtr _scene) box2->SetMaterial(boxMaterial2); // Duck Scene - MaterialPtr matte = _scene->CreateMaterial(); - matte->SetDiffuse(1.0, 0.0, 0.0); - - VisualPtr mesh = _scene->CreateVisual(); MeshDescriptor descriptor; descriptor.meshName = "media/duck.dae"; common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); - MeshPtr meshGeom = _scene->CreateMesh(descriptor); - mesh->AddGeometry(meshGeom); - mesh->SetLocalRotation(GZ_PI / 2, 0, -GZ_PI / 4); - mesh->SetLocalPosition(-0.25, -1.25, 1.25); - mesh->SetMaterial(matte); + if (descriptor.mesh) + { + VisualPtr mesh = _scene->CreateVisual(); + MeshPtr meshGeom = _scene->CreateMesh(descriptor); + mesh->AddGeometry(meshGeom); + mesh->SetLocalRotation(GZ_PI / 2, 0, -GZ_PI / 4); + mesh->SetLocalPosition(-0.25, -1.25, 1.25); + MaterialPtr matte = _scene->CreateMaterial(); + matte->SetDiffuse(1.0, 0.0, 0.0); + mesh->SetMaterial(matte); + } + else + { + gzerr << "Failed load mesh: " << descriptor.meshName << std::endl; + } } ////////////////////////////////////////////////// diff --git a/examples/mesh_viewer/Main.cc b/examples/mesh_viewer/Main.cc index a0c32a156..03e8c97e0 100644 --- a/examples/mesh_viewer/Main.cc +++ b/examples/mesh_viewer/Main.cc @@ -56,27 +56,41 @@ void buildScene(ScenePtr _scene) root->AddChild(light0); //! [create a mesh] - VisualPtr mesh = _scene->CreateVisual(); - mesh->SetLocalPosition(3, 0, 0); - mesh->SetLocalRotation(1.5708, 0, 2.0); MeshDescriptor descriptor; descriptor.meshName = common::joinPaths(RESOURCE_PATH, "duck.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); - MeshPtr meshGeom = _scene->CreateMesh(descriptor); - mesh->AddGeometry(meshGeom); - root->AddChild(mesh); + if (descriptor.mesh) + { + VisualPtr mesh = _scene->CreateVisual(); + mesh->SetLocalPosition(3, 0, 0); + mesh->SetLocalRotation(1.5708, 0, 2.0); + MeshPtr meshGeom = _scene->CreateMesh(descriptor); + mesh->AddGeometry(meshGeom); + root->AddChild(mesh); + } + else + { + gzerr << "Failed load mesh: " << descriptor.meshName << std::endl; + } //! [create a mesh] // create a pbr glb mesh - mesh = _scene->CreateVisual(); - mesh->SetLocalPosition(3, 2, 0); - mesh->SetLocalRotation(0, 0, 0); descriptor.meshName = common::joinPaths(RESOURCE_PATH, "AmbulanceStretcher.glb"); descriptor.mesh = meshManager->Load(descriptor.meshName); - meshGeom = _scene->CreateMesh(descriptor); - mesh->AddGeometry(meshGeom); - root->AddChild(mesh); + if (descriptor.mesh) + { + VisualPtr mesh = _scene->CreateVisual(); + mesh->SetLocalPosition(3, 2, 0); + mesh->SetLocalRotation(0, 0, 0); + MeshPtr meshGeom = _scene->CreateMesh(descriptor); + mesh->AddGeometry(meshGeom); + root->AddChild(mesh); + } + else + { + gzerr << "Failed load mesh: " << descriptor.meshName << std::endl; + } // create gray material MaterialPtr gray = _scene->CreateMaterial(); diff --git a/examples/ogre2_demo/Main.cc b/examples/ogre2_demo/Main.cc index 999b00252..1007a96eb 100644 --- a/examples/ogre2_demo/Main.cc +++ b/examples/ogre2_demo/Main.cc @@ -72,17 +72,24 @@ void buildScene(ScenePtr _scene) matPBR->SetEnvironmentMap(environmentMap); // create mesh for PBR - VisualPtr meshPBR = _scene->CreateVisual("pump"); - meshPBR->SetLocalPosition(2, 0.0, -0.3); - meshPBR->SetLocalRotation(0, 0, 0); MeshDescriptor descriptorPBR; descriptorPBR.meshName = common::joinPaths(RESOURCE_PATH, "pump.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptorPBR.mesh = meshManager->Load(descriptorPBR.meshName); - MeshPtr meshPBRGeom = _scene->CreateMesh(descriptorPBR); - meshPBRGeom->SetMaterial(matPBR); - meshPBR->AddGeometry(meshPBRGeom); - root->AddChild(meshPBR); + if (descriptorPBR.mesh) + { + VisualPtr meshPBR = _scene->CreateVisual("pump"); + meshPBR->SetLocalPosition(2, 0.0, -0.3); + meshPBR->SetLocalRotation(0, 0, 0); + MeshPtr meshPBRGeom = _scene->CreateMesh(descriptorPBR); + meshPBRGeom->SetMaterial(matPBR); + meshPBR->AddGeometry(meshPBRGeom); + root->AddChild(meshPBR); + } + else + { + gzerr << "Failed load mesh: " << descriptorPBR.meshName << std::endl; + } // create green material MaterialPtr green = _scene->CreateMaterial(); diff --git a/examples/particles_demo/Main.cc b/examples/particles_demo/Main.cc index 9ed66c568..1a42127b3 100644 --- a/examples/particles_demo/Main.cc +++ b/examples/particles_demo/Main.cc @@ -56,16 +56,23 @@ void buildScene(ScenePtr _scene) root->AddChild(light0); //! [create a mesh] - VisualPtr mesh = _scene->CreateVisual(); - mesh->SetLocalPosition(3, 0, 0); - mesh->SetLocalRotation(1.5708, 0, 2.0); MeshDescriptor descriptor; descriptor.meshName = common::joinPaths(RESOURCE_PATH, "duck.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); - MeshPtr meshGeom = _scene->CreateMesh(descriptor); - mesh->AddGeometry(meshGeom); - root->AddChild(mesh); + if (descriptor.mesh) + { + VisualPtr mesh = _scene->CreateVisual(); + mesh->SetLocalPosition(3, 0, 0); + mesh->SetLocalRotation(1.5708, 0, 2.0); + MeshPtr meshGeom = _scene->CreateMesh(descriptor); + mesh->AddGeometry(meshGeom); + root->AddChild(mesh); + } + else + { + gzerr << "Failed load mesh: " << descriptor.meshName << std::endl; + } //! [create a mesh] // create gray material diff --git a/examples/segmentation_camera/Main.cc b/examples/segmentation_camera/Main.cc index 0dda4ecd7..28a45675a 100644 --- a/examples/segmentation_camera/Main.cc +++ b/examples/segmentation_camera/Main.cc @@ -57,17 +57,24 @@ void buildScene(ScenePtr _scene) root->AddChild(plane); // create a mesh - VisualPtr mesh = _scene->CreateVisual(); - mesh->SetLocalPosition(3, 0, 0); - mesh->SetLocalRotation(1.5708, 0, 2.0); MeshDescriptor descriptor; descriptor.meshName = common::joinPaths(RESOURCE_PATH, "duck.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); - MeshPtr meshGeom = _scene->CreateMesh(descriptor); - mesh->AddGeometry(meshGeom); - mesh->SetUserData("label", 5); - root->AddChild(mesh); + if (descriptor.mesh) + { + VisualPtr mesh = _scene->CreateVisual(); + mesh->SetLocalPosition(3, 0, 0); + mesh->SetLocalRotation(1.5708, 0, 2.0); + MeshPtr meshGeom = _scene->CreateMesh(descriptor); + mesh->AddGeometry(meshGeom); + mesh->SetUserData("label", 5); + root->AddChild(mesh); + } + else + { + gzerr << "Failed load mesh: " << descriptor.meshName << std::endl; + } // create a box VisualPtr box = _scene->CreateVisual("box"); diff --git a/examples/thermal_camera/Main.cc b/examples/thermal_camera/Main.cc index 68157a0c9..abcd3da20 100644 --- a/examples/thermal_camera/Main.cc +++ b/examples/thermal_camera/Main.cc @@ -56,18 +56,25 @@ void buildScene(ScenePtr _scene) root->AddChild(plane); // create a mesh - VisualPtr mesh = _scene->CreateVisual(); - mesh->SetLocalPosition(3, 0, 0); - mesh->SetLocalRotation(1.5708, 0, 2.0); + float temperature = 315.0; MeshDescriptor descriptor; descriptor.meshName = common::joinPaths(RESOURCE_PATH, "duck.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); - MeshPtr meshGeom = _scene->CreateMesh(descriptor); - mesh->AddGeometry(meshGeom); - float temperature = 315.0; - mesh->SetUserData("temperature", temperature); - root->AddChild(mesh); + if (descriptor.mesh) + { + VisualPtr mesh = _scene->CreateVisual(); + mesh->SetLocalPosition(3, 0, 0); + mesh->SetLocalRotation(1.5708, 0, 2.0); + MeshPtr meshGeom = _scene->CreateMesh(descriptor); + mesh->AddGeometry(meshGeom); + mesh->SetUserData("temperature", temperature); + root->AddChild(mesh); + } + else + { + gzerr << "Failed load mesh: " << descriptor.meshName << std::endl; + } // create a box VisualPtr box = _scene->CreateVisual("box"); diff --git a/examples/waves/Main.cc b/examples/waves/Main.cc index 44889751e..11a8f691b 100644 --- a/examples/waves/Main.cc +++ b/examples/waves/Main.cc @@ -106,18 +106,25 @@ void buildScene(ScenePtr _scene, shader->SetVertexShader(vertexShaderPath); shader->SetFragmentShader(fragmentShaderPath); - // create waves visual - VisualPtr waves = _scene->CreateVisual("waves"); - MeshDescriptor descriptor; - descriptor.meshName = common::joinPaths(RESOURCE_PATH, "mesh.dae"); - common::MeshManager *meshManager = common::MeshManager::Instance(); - descriptor.mesh = meshManager->Load(descriptor.meshName); - MeshPtr meshGeom = _scene->CreateMesh(descriptor); - waves->AddGeometry(meshGeom); - waves->SetLocalPosition(3, 0, 0); - waves->SetLocalScale(1, 1, 1); - waves->SetMaterial(shader); - root->AddChild(waves); + // create waves visual + MeshDescriptor descriptor; + descriptor.meshName = common::joinPaths(RESOURCE_PATH, "mesh.dae"); + common::MeshManager *meshManager = common::MeshManager::Instance(); + descriptor.mesh = meshManager->Load(descriptor.meshName); + if (descriptor.mesh) + { + VisualPtr waves = _scene->CreateVisual("waves"); + MeshPtr meshGeom = _scene->CreateMesh(descriptor); + waves->AddGeometry(meshGeom); + waves->SetLocalPosition(3, 0, 0); + waves->SetLocalScale(1, 1, 1); + waves->SetMaterial(shader); + root->AddChild(waves); + } + else + { + gzerr << "Failed load mesh: " << descriptor.meshName << std::endl; + } // create camera CameraPtr camera = _scene->CreateCamera("camera"); diff --git a/ogre/src/OgreMeshFactory.cc b/ogre/src/OgreMeshFactory.cc index 81a55bb18..b3d7ff1f6 100644 --- a/ogre/src/OgreMeshFactory.cc +++ b/ogre/src/OgreMeshFactory.cc @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/ogre2/src/Ogre2Marker.cc b/ogre2/src/Ogre2Marker.cc index 4aaf6af27..f63b79225 100644 --- a/ogre2/src/Ogre2Marker.cc +++ b/ogre2/src/Ogre2Marker.cc @@ -27,9 +27,6 @@ #include -#include -#include - #include "gz/rendering/ogre2/Ogre2Capsule.hh" #include "gz/rendering/ogre2/Ogre2Conversions.hh" #include "gz/rendering/ogre2/Ogre2DynamicRenderable.hh" diff --git a/ogre2/src/Ogre2MeshFactory.cc b/ogre2/src/Ogre2MeshFactory.cc index 54bc8e20e..23cf57564 100644 --- a/ogre2/src/Ogre2MeshFactory.cc +++ b/ogre2/src/Ogre2MeshFactory.cc @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/src/base/BaseScene.cc b/src/base/BaseScene.cc index a316053bf..e4161a2aa 100644 --- a/src/base/BaseScene.cc +++ b/src/base/BaseScene.cc @@ -21,7 +21,6 @@ #include #include -#include #include "gz/rendering/ArrowVisual.hh" #include "gz/rendering/AxisVisual.hh" diff --git a/test/common_test/MeshDescriptor_TEST.cc b/test/common_test/MeshDescriptor_TEST.cc index 381552783..07983efd9 100644 --- a/test/common_test/MeshDescriptor_TEST.cc +++ b/test/common_test/MeshDescriptor_TEST.cc @@ -29,7 +29,7 @@ using namespace gz; using namespace rendering; -class MeshDescriptorTest : public CommonRenderingTest +class MeshDescriptorTest : public CommonRenderingTest { }; diff --git a/test/common_test/Mesh_TEST.cc b/test/common_test/Mesh_TEST.cc index d4008e734..802f2ce9c 100644 --- a/test/common_test/Mesh_TEST.cc +++ b/test/common_test/Mesh_TEST.cc @@ -103,6 +103,7 @@ TEST_F(MeshTest, MeshSkeleton) descriptor.meshName = common::joinPaths(TEST_MEDIA_PATH, "walk.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); + ASSERT_NE(nullptr, descriptor.mesh); MeshPtr mesh = scene->CreateMesh(descriptor); actorVisual->AddGeometry(mesh); @@ -181,6 +182,7 @@ TEST_F(MeshTest, MeshSkeletonAnimation) descriptor.meshName = common::joinPaths(TEST_MEDIA_PATH, "walk.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); + ASSERT_NE(nullptr, descriptor.mesh); MeshPtr mesh = scene->CreateMesh(descriptor); EXPECT_TRUE(mesh->HasSkeleton()); diff --git a/test/integration/waves.cc b/test/integration/waves.cc index 284c4544a..ac24edda7 100644 --- a/test/integration/waves.cc +++ b/test/integration/waves.cc @@ -119,6 +119,7 @@ TEST_F(WavesTest, Waves) TEST_MEDIA_PATH, "meshes", "mesh.dae"); common::MeshManager *meshManager = common::MeshManager::Instance(); descriptor.mesh = meshManager->Load(descriptor.meshName); + ASSERT_NE(nullptr, descriptor.mesh); MeshPtr meshGeom = scene->CreateMesh(descriptor); waves->AddGeometry(meshGeom); waves->SetLocalPosition(3, 0, 0); From 2e9fa26afdb0b57b6d1f86ecc678fba0ec5001b9 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Wed, 10 Apr 2024 15:17:55 -0500 Subject: [PATCH 3/9] Use relative install paths for plugin shared libraries and media files (#984) Signed-off-by: Addisu Z. Taddese --- doc/CMakeLists.txt | 2 +- ogre/src/CMakeLists.txt | 4 ++-- ogre/src/media/fonts/CMakeLists.txt | 4 ++-- ogre/src/media/materials/programs/CMakeLists.txt | 2 +- ogre/src/media/materials/scripts/CMakeLists.txt | 2 +- ogre/src/media/materials/textures/CMakeLists.txt | 2 +- ogre/src/media/rtshaderlib150/CMakeLists.txt | 2 +- ogre2/src/CMakeLists.txt | 6 +++--- optix/src/CMakeLists.txt | 4 ++-- src/base/media/materials/textures/CMakeLists.txt | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index b6abfef55..9ea68c931 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -31,5 +31,5 @@ if (DOXYGEN_FOUND) COMMENT "Generating API documentation with Doxygen" VERBATIM) install(FILES ${CMAKE_BINARY_DIR}/doc/${PROJECT_NAME_LOWER}.tag.xml - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/gz/${PROJECT_NAME_LOWER}_${PROJECT_VERSION_MINOR}) + DESTINATION share/gz/${PROJECT_NAME_LOWER}_${PROJECT_VERSION_MINOR}) endif() diff --git a/ogre/src/CMakeLists.txt b/ogre/src/CMakeLists.txt index c50430c0e..ff5615a36 100644 --- a/ogre/src/CMakeLists.txt +++ b/ogre/src/CMakeLists.txt @@ -46,7 +46,7 @@ gz_build_tests(TYPE UNIT ENVIRONMENT GZ_RENDERING_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) # Note that plugins are currently being installed in 2 places: /lib and the engine-plugins dir -install(TARGETS ${ogre_target} DESTINATION ${GZ_RENDERING_ENGINE_INSTALL_DIR}) +install(TARGETS ${ogre_target} DESTINATION ${GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR}) if(WIN32) # tests needs .dll in the same directory @@ -66,7 +66,7 @@ if (WIN32) ${GZ_RENDERING_ENGINE_INSTALL_DIR}\/${unversioned})") else() EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${versioned} ${unversioned}) - INSTALL(FILES ${PROJECT_BINARY_DIR}/${unversioned} DESTINATION ${GZ_RENDERING_ENGINE_INSTALL_DIR}) + INSTALL(FILES ${PROJECT_BINARY_DIR}/${unversioned} DESTINATION ${GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR}) endif() add_subdirectory(media) diff --git a/ogre/src/media/fonts/CMakeLists.txt b/ogre/src/media/fonts/CMakeLists.txt index 67ee66c4a..5a21ac22b 100644 --- a/ogre/src/media/fonts/CMakeLists.txt +++ b/ogre/src/media/fonts/CMakeLists.txt @@ -1,4 +1,4 @@ file(GLOB files "*ttf" "*png" "*fontdef") -install(FILES ${files} DESTINATION ${GZ_RENDERING_RESOURCE_PATH}/ogre/media/fonts) -install(DIRECTORY liberation-sans DESTINATION ${GZ_RENDERING_RESOURCE_PATH}/ogre/media/fonts) +install(FILES ${files} DESTINATION ${GZ_RENDERING_RELATIVE_RESOURCE_PATH}/ogre/media/fonts) +install(DIRECTORY liberation-sans DESTINATION ${GZ_RENDERING_RELATIVE_RESOURCE_PATH}/ogre/media/fonts) diff --git a/ogre/src/media/materials/programs/CMakeLists.txt b/ogre/src/media/materials/programs/CMakeLists.txt index 8d19dd395..a3391dbc7 100644 --- a/ogre/src/media/materials/programs/CMakeLists.txt +++ b/ogre/src/media/materials/programs/CMakeLists.txt @@ -1,4 +1,4 @@ file(GLOB files "*.glsl") -install(FILES ${files} DESTINATION ${GZ_RENDERING_RESOURCE_PATH}/ogre/media/materials/programs) +install(FILES ${files} DESTINATION ${GZ_RENDERING_RELATIVE_RESOURCE_PATH}/ogre/media/materials/programs) diff --git a/ogre/src/media/materials/scripts/CMakeLists.txt b/ogre/src/media/materials/scripts/CMakeLists.txt index b739e94f8..3d43bb392 100644 --- a/ogre/src/media/materials/scripts/CMakeLists.txt +++ b/ogre/src/media/materials/scripts/CMakeLists.txt @@ -1,4 +1,4 @@ file(GLOB files "*.material" "*.compositor") -install(FILES ${files} DESTINATION ${GZ_RENDERING_RESOURCE_PATH}/ogre/media/materials/scripts) +install(FILES ${files} DESTINATION ${GZ_RENDERING_RELATIVE_RESOURCE_PATH}/ogre/media/materials/scripts) diff --git a/ogre/src/media/materials/textures/CMakeLists.txt b/ogre/src/media/materials/textures/CMakeLists.txt index 90f0fc4de..abcd5f9fb 100644 --- a/ogre/src/media/materials/textures/CMakeLists.txt +++ b/ogre/src/media/materials/textures/CMakeLists.txt @@ -1,3 +1,3 @@ file(GLOB files "*.png") -install(FILES ${files} DESTINATION ${GZ_RENDERING_RESOURCE_PATH}/ogre/media/materials/textures) +install(FILES ${files} DESTINATION ${GZ_RENDERING_RELATIVE_RESOURCE_PATH}/ogre/media/materials/textures) diff --git a/ogre/src/media/rtshaderlib150/CMakeLists.txt b/ogre/src/media/rtshaderlib150/CMakeLists.txt index 2cb12d93f..2aae04baf 100644 --- a/ogre/src/media/rtshaderlib150/CMakeLists.txt +++ b/ogre/src/media/rtshaderlib150/CMakeLists.txt @@ -10,5 +10,5 @@ SGXLib_NormalMapLighting.glsl SGXLib_PerPixelLighting.glsl ) -install(FILES ${files} DESTINATION ${GZ_RENDERING_RESOURCE_PATH}/ogre/media/rtshaderlib150) +install(FILES ${files} DESTINATION ${GZ_RENDERING_RELATIVE_RESOURCE_PATH}/ogre/media/rtshaderlib150) diff --git a/ogre2/src/CMakeLists.txt b/ogre2/src/CMakeLists.txt index ef328190a..0111d3200 100644 --- a/ogre2/src/CMakeLists.txt +++ b/ogre2/src/CMakeLists.txt @@ -72,7 +72,7 @@ set (versioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_LOWER}-${engine_name set (unversioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_NO_VERSION_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) # Note that plugins are currently being installed in 2 places: /lib and the engine-plugins dir -install(TARGETS ${ogre2_target} DESTINATION ${GZ_RENDERING_ENGINE_INSTALL_DIR}) +install(TARGETS ${ogre2_target} DESTINATION ${GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR}) if (WIN32) # disable MSVC inherit via dominance warning @@ -82,7 +82,7 @@ if (WIN32) ${GZ_RENDERING_ENGINE_INSTALL_DIR}\/${unversioned})") else() EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${versioned} ${unversioned}) - INSTALL(FILES ${PROJECT_BINARY_DIR}/${unversioned} DESTINATION ${GZ_RENDERING_ENGINE_INSTALL_DIR}) + INSTALL(FILES ${PROJECT_BINARY_DIR}/${unversioned} DESTINATION ${GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR}) endif() if (NOT (APPLE OR WIN32)) @@ -100,4 +100,4 @@ gz_build_tests(TYPE UNIT LIB_DEPS ${ogre2_target} ENVIRONMENT GZ_RENDERING_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) -install(DIRECTORY "media" DESTINATION ${GZ_RENDERING_RESOURCE_PATH}/ogre2) +install(DIRECTORY "media" DESTINATION ${GZ_RENDERING_RELATIVE_RESOURCE_PATH}/ogre2) diff --git a/optix/src/CMakeLists.txt b/optix/src/CMakeLists.txt index daa896a29..d8bb16d7b 100644 --- a/optix/src/CMakeLists.txt +++ b/optix/src/CMakeLists.txt @@ -46,7 +46,7 @@ gz_build_tests(TYPE UNIT ENVIRONMENT GZ_RENDERING_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) # Note that plugins are currently being installed in 2 places: /lib and the engine-plugins dir -install(TARGETS ${optix_target} DESTINATION ${GZ_RENDERING_ENGINE_INSTALL_DIR}) +install(TARGETS ${optix_target} DESTINATION ${GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR}) set (versioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) set (unversioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_NO_VERSION_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) @@ -59,7 +59,7 @@ if (WIN32) ${GZ_RENDERING_ENGINE_INSTALL_DIR}\/${unversioned})") else() EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${versioned} ${unversioned}) - INSTALL(FILES ${PROJECT_BINARY_DIR}/${unversioned} DESTINATION ${GZ_RENDERING_ENGINE_INSTALL_DIR}) + INSTALL(FILES ${PROJECT_BINARY_DIR}/${unversioned} DESTINATION ${GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR}) endif() if("${CUDA_VERSION}" VERSION_LESS "9") diff --git a/src/base/media/materials/textures/CMakeLists.txt b/src/base/media/materials/textures/CMakeLists.txt index 5d9f3f249..c76e3cd25 100644 --- a/src/base/media/materials/textures/CMakeLists.txt +++ b/src/base/media/materials/textures/CMakeLists.txt @@ -1,4 +1,4 @@ file(GLOB files "*.png") -install(FILES ${files} DESTINATION ${GZ_RENDERING_RESOURCE_PATH}/media/materials/textures) +install(FILES ${files} DESTINATION ${GZ_RENDERING_RELATIVE_RESOURCE_PATH}/media/materials/textures) From df019bb4c01956f0431abd9417d0c178fe56f8ac Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Wed, 10 Apr 2024 16:53:00 -0500 Subject: [PATCH 4/9] Prepare for 8.1.1 (#985) Signed-off-by: Addisu Z. Taddese --- CMakeLists.txt | 2 +- Changelog.md | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f7c1144b..c245df538 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(gz-rendering8 VERSION 8.1.0) +project(gz-rendering8 VERSION 8.1.1) #============================================================================ # Find gz-cmake diff --git a/Changelog.md b/Changelog.md index 380205530..c0bd4253e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,14 @@ ### Gazebo Rendering 8.X +### Gazebo Rendering 8.1.1 (2024-04-10) + +1. Use relative install paths for plugin shared libraries and media files + * [Pull request #984](https://github.com/gazebosim/gz-rendering/pull/984) + +1. Handle null mesh pointers in examples + * [Pull request #982](https://github.com/gazebosim/gz-rendering/pull/982) + ### Gazebo Rendering 8.1.0 (2024-03-14) 1. Fix setting normal map when not all submeshes have texcoords (ogre2) From 69f56bda19f96a6311f384084f0b0ffa296f0afe Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Wed, 24 Apr 2024 17:49:14 +0200 Subject: [PATCH 5/9] Ogre2RenderEngine: on Windows if useCurrentGLContext is specified, set the externalWindowsHandle ogre-next option (#992) Signed-off-by: Silvio Traversaro --- ogre2/src/Ogre2RenderEngine.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index c83edd987..93ee74c41 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -1263,6 +1263,22 @@ std::string Ogre2RenderEngine::CreateRenderWindow(const std::string &_handle, { params["externalGLControl"] = "true"; params["currentGLContext"] = "true"; + +#if defined(_MSC_VER) + if (!this->winID.empty()) + { + params["externalWindowHandle"] = this->winID; + } + else + { + gzerr << "useCurrentGLContext option specified, " + << "but no winID specified." << std::endl + << "On Windows if useCurrentGLContext is specified, " + << "the ogre2 rendering requires that also winID is specified." + << std::endl; + return std::string(); + } +#endif } #if !defined(__APPLE__) && !defined(_MSC_VER) From 9f397e12fb013a4ce94f629d1a65df0bbe41f675 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Fri, 26 Apr 2024 19:24:10 +0200 Subject: [PATCH 6/9] Workaround on warnings for Ubuntu Noble (#995) * Add pragma ignores for Woverloaded-virtual * Ignore the warning on FindCUDA removal --------- Signed-off-by: Jose Luis Rivero --- CMakeLists.txt | 5 +++++ include/gz/rendering/Camera.hh | 12 ++++++++++++ include/gz/rendering/Object.hh | 13 +++++++++++++ include/gz/rendering/Visual.hh | 13 +++++++++++++ include/gz/rendering/base/BaseRenderTarget.hh | 13 +++++++++++++ 5 files changed, 56 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c245df538..ec42958b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,6 +171,11 @@ set(GZ_RENDERING_ENGINE_INSTALL_DIR if(NOT MSVC) #-------------------------------------- # Find CUDA + # Module is being removed in CMake and needs a non trivial + # migration https://cmake.org/cmake/help/latest/policy/CMP0146.html + if(POLICY CMP0146) + cmake_policy(SET CMP0146 OLD) + endif() find_package(CUDA) #-------------------------------------- diff --git a/include/gz/rendering/Camera.hh b/include/gz/rendering/Camera.hh index 91dcbbd5a..6e4303509 100644 --- a/include/gz/rendering/Camera.hh +++ b/include/gz/rendering/Camera.hh @@ -28,6 +28,13 @@ #include "gz/rendering/Sensor.hh" #include "gz/rendering/Scene.hh" +// overloaded-virtuals warnings appeared on Ubuntu Noble +// GCC-13. it is not easy to fix them without breaking ABI +// ignore them to preserve current ABI. +#if defined(__GNUC__) || defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif namespace gz { @@ -369,4 +376,9 @@ namespace gz } } } + +#if defined(__GNUC__) || defined(__clang__) +# pragma GCC diagnostic pop +#endif + #endif diff --git a/include/gz/rendering/Object.hh b/include/gz/rendering/Object.hh index 90e6ef0aa..573c7edf0 100644 --- a/include/gz/rendering/Object.hh +++ b/include/gz/rendering/Object.hh @@ -22,6 +22,14 @@ #include "gz/rendering/RenderTypes.hh" #include "gz/rendering/Export.hh" +// overloaded-virtuals warnings appeared on Ubuntu Noble +// GCC-13. it is not easy to fix them without breaking ABI +// ignore them to preserve current ABI. +#if defined(__GNUC__) || defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif + namespace gz { namespace rendering @@ -69,4 +77,9 @@ namespace gz } } } + +#if defined(__GNUC__) || defined(__clang__) +# pragma GCC diagnostic pop +#endif + #endif diff --git a/include/gz/rendering/Visual.hh b/include/gz/rendering/Visual.hh index cfabb3708..809855b9d 100644 --- a/include/gz/rendering/Visual.hh +++ b/include/gz/rendering/Visual.hh @@ -22,6 +22,14 @@ #include "gz/rendering/config.hh" #include "gz/rendering/Node.hh" +// overloaded-virtuals warnings appeared on Ubuntu Noble +// GCC-13. it is not easy to fix them without breaking ABI +// ignore them to preserve current ABI. +#if defined(__GNUC__) || defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif + namespace gz { namespace rendering @@ -206,4 +214,9 @@ namespace gz } } } + +#if defined(__GNUC__) || defined(__clang__) +# pragma GCC diagnostic pop +#endif + #endif diff --git a/include/gz/rendering/base/BaseRenderTarget.hh b/include/gz/rendering/base/BaseRenderTarget.hh index b7d3da76e..c1ef16a1c 100644 --- a/include/gz/rendering/base/BaseRenderTarget.hh +++ b/include/gz/rendering/base/BaseRenderTarget.hh @@ -25,6 +25,14 @@ #include "gz/rendering/Scene.hh" #include "gz/rendering/base/BaseRenderTypes.hh" +// overloaded-virtuals warnings appeared on Ubuntu Noble +// GCC-13. it is not easy to fix them without breaking ABI +// ignore them to preserve current ABI. +#if defined(__GNUC__) || defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif + namespace gz { namespace rendering @@ -406,4 +414,9 @@ namespace gz } } } + +#if defined(__GNUC__) || defined(__clang__) +# pragma GCC diagnostic pop +#endif + #endif From ade744276ffa537f76639df6cd7c859da312060b Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 2 May 2024 22:06:48 -0500 Subject: [PATCH 7/9] Add package.xml (#981) Signed-off-by: Addisu Z. Taddese --- .github/workflows/package_xml.yml | 11 ++++++++++ package.xml | 34 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .github/workflows/package_xml.yml create mode 100644 package.xml diff --git a/.github/workflows/package_xml.yml b/.github/workflows/package_xml.yml new file mode 100644 index 000000000..4bd4a9aa0 --- /dev/null +++ b/.github/workflows/package_xml.yml @@ -0,0 +1,11 @@ +name: Validate package.xml + +on: + pull_request: + +jobs: + package-xml: + runs-on: ubuntu-latest + name: Validate package.xml + steps: + - uses: gazebo-tooling/action-gz-ci/validate_package_xml@jammy diff --git a/package.xml b/package.xml new file mode 100644 index 000000000..12995cd6b --- /dev/null +++ b/package.xml @@ -0,0 +1,34 @@ + + + + gz-rendering8 + 8.1.1 + Gazebo Rendering: Rendering library for robot applications + Ian Chen + Apache License 2.0 + https://github.com/gazebosim/gz-rendering + + cmake + + gz-cmake + + glut + gz-common5 + gz-math7 + gz-plugin2 + gz-utils2 + libfreeimage-dev + libglew-dev + libogre-dev + libogre-next-2.3-dev + libvulkan-dev + libxi-dev + libxmu-dev + uuid + + xvfb + + + cmake + + From 9436d7bbc80484f3503d96eb609031a9a8b15d78 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Wed, 22 May 2024 19:01:11 +0200 Subject: [PATCH 8/9] Fix gz-cmake declaration on package.xml (Fix windows builds) (#1005) Signed-off-by: Jose Luis Rivero --- package.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.xml b/package.xml index 12995cd6b..bacc2bd89 100644 --- a/package.xml +++ b/package.xml @@ -10,7 +10,7 @@ cmake - gz-cmake + gz-cmake3 glut gz-common5 From f3d30738726d11d240907e30699ce4c66e8a0f50 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 29 May 2024 21:15:02 +0900 Subject: [PATCH 9/9] ogre2: Set custom projection matrix for other types of cameras (#1002) Signed-off-by: Ian Chen --- ogre2/src/Ogre2BoundingBoxCamera.cc | 16 ++++ ogre2/src/Ogre2DepthCamera.cc | 14 ++++ ogre2/src/Ogre2SegmentationCamera.cc | 15 ++++ ogre2/src/Ogre2ThermalCamera.cc | 15 ++++ test/integration/depth_camera.cc | 121 +++++++++++++++++++++++++++ 5 files changed, 181 insertions(+) diff --git a/ogre2/src/Ogre2BoundingBoxCamera.cc b/ogre2/src/Ogre2BoundingBoxCamera.cc index 986a44326..0adb97017 100644 --- a/ogre2/src/Ogre2BoundingBoxCamera.cc +++ b/ogre2/src/Ogre2BoundingBoxCamera.cc @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "gz/rendering/RenderTypes.hh" @@ -464,6 +465,21 @@ void Ogre2BoundingBoxCamera::PreRender() if (!this->dataPtr->ogreRenderTexture) this->CreateBoundingBoxTexture(); + // todo(iche033) Override BaseCamera::SetProjectionMatrix() function in + // main / gz-rendering9 instead of checking and setting the custom + // projection matrix here + if (this->dataPtr->ogreCamera && + this->projectionMatrix != gz::math::Matrix4d::Zero) + { + if (this->projectionMatrix != + Ogre2Conversions::Convert( + this->dataPtr->ogreCamera->getProjectionMatrix())) + { + this->dataPtr->ogreCamera->setCustomProjectionMatrix(true, + Ogre2Conversions::Convert(this->projectionMatrix)); + } + } + this->dataPtr->outputBoxes.clear(); } diff --git a/ogre2/src/Ogre2DepthCamera.cc b/ogre2/src/Ogre2DepthCamera.cc index 2f255a421..db9ad5d99 100644 --- a/ogre2/src/Ogre2DepthCamera.cc +++ b/ogre2/src/Ogre2DepthCamera.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include "gz/rendering/RenderTypes.hh" #include "gz/rendering/ogre2/Ogre2Conversions.hh" @@ -1056,6 +1057,19 @@ void Ogre2DepthCamera::PreRender() if (!this->dataPtr->ogreCompositorWorkspace) this->CreateWorkspaceInstance(); + // todo(iche033) Override BaseCamera::SetProjectionMatrix() function in + // main / gz-rendering9 instead of checking and setting the custom + // projection matrix here + if (this->ogreCamera && + this->projectionMatrix != gz::math::Matrix4d::Zero) + { + if (this->projectionMatrix != + Ogre2Conversions::Convert(this->ogreCamera->getProjectionMatrix())) + { + this->ogreCamera->setCustomProjectionMatrix(true, + Ogre2Conversions::Convert(this->projectionMatrix)); + } + } // Disable color target (set to clear pass) if there are no rgb point cloud // connections diff --git a/ogre2/src/Ogre2SegmentationCamera.cc b/ogre2/src/Ogre2SegmentationCamera.cc index ef0c4e106..4028daccc 100644 --- a/ogre2/src/Ogre2SegmentationCamera.cc +++ b/ogre2/src/Ogre2SegmentationCamera.cc @@ -19,6 +19,7 @@ #include #include +#include #include "gz/rendering/ogre2/Ogre2Camera.hh" #include "gz/rendering/ogre2/Ogre2Conversions.hh" @@ -164,6 +165,20 @@ void Ogre2SegmentationCamera::PreRender() { if (!this->dataPtr->ogreSegmentationTexture) this->CreateSegmentationTexture(); + + // todo(iche033) Override BaseCamera::SetProjectionMatrix() function in + // main / gz-rendering9 instead of checking and setting the custom + // projection matrix here + if (this->ogreCamera && + this->projectionMatrix != gz::math::Matrix4d::Zero) + { + if (this->projectionMatrix != + Ogre2Conversions::Convert(this->ogreCamera->getProjectionMatrix())) + { + this->ogreCamera->setCustomProjectionMatrix(true, + Ogre2Conversions::Convert(this->projectionMatrix)); + } + } } ///////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2ThermalCamera.cc b/ogre2/src/Ogre2ThermalCamera.cc index 11f2d5bcd..fa06f380f 100644 --- a/ogre2/src/Ogre2ThermalCamera.cc +++ b/ogre2/src/Ogre2ThermalCamera.cc @@ -43,6 +43,7 @@ #include #include #include +#include #include "gz/rendering/RenderTypes.hh" #include "gz/rendering/ogre2/Ogre2Conversions.hh" @@ -1130,6 +1131,20 @@ void Ogre2ThermalCamera::PreRender() { if (!this->dataPtr->ogreThermalTexture) this->CreateThermalTexture(); + + // todo(iche033) Override BaseCamera::SetProjectionMatrix() function in + // main / gz-rendering9 instead of checking and setting the custom + // projection matrix here + if (this->ogreCamera && + this->projectionMatrix != gz::math::Matrix4d::Zero) + { + if (this->projectionMatrix != + Ogre2Conversions::Convert(this->ogreCamera->getProjectionMatrix())) + { + this->ogreCamera->setCustomProjectionMatrix(true, + Ogre2Conversions::Convert(this->projectionMatrix)); + } + } } ////////////////////////////////////////////////// diff --git a/test/integration/depth_camera.cc b/test/integration/depth_camera.cc index 5e28a00cd..710bab0e9 100644 --- a/test/integration/depth_camera.cc +++ b/test/integration/depth_camera.cc @@ -16,6 +16,7 @@ */ #include +#include #include "CommonRenderingTest.hh" @@ -735,3 +736,123 @@ TEST_F(DepthCameraTest, DepthCameraParticles) engine->DestroyScene(scene); } + +///////////////////////////////////////////////// +TEST_F(DepthCameraTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(DepthCameraProjection)) +{ + CHECK_SUPPORTED_ENGINE("ogre2"); + + int imgWidth = 256; + int imgHeight = 256; + double aspectRatio = imgWidth / imgHeight; + + double unitBoxSize = 1.0; + gz::math::Vector3d boxPosition(1.8, 0.0, 0.0); + + gz::rendering::ScenePtr scene = engine->CreateScene("scene"); + ASSERT_NE(nullptr, scene); + + // Create an scene with a box in it + gz::rendering::VisualPtr root = scene->RootVisual(); + + // create box visual + gz::rendering::VisualPtr box = scene->CreateVisual(); + box->AddGeometry(scene->CreateBox()); + box->SetLocalPosition(boxPosition); + box->SetLocalScale(unitBoxSize, unitBoxSize, unitBoxSize); + root->AddChild(box); + { + // Create depth camera + auto depthCamera = scene->CreateDepthCamera("DepthCamera"); + ASSERT_NE(depthCamera, nullptr); + + gz::math::Pose3d testPose(gz::math::Vector3d(0, 0, 0), + gz::math::Quaterniond::Identity); + depthCamera->SetLocalPose(testPose); + + // Set initial camera parameters using a wide horizontal FOV + double farDist = 100.0; + double nearDist = 0.01; + double hfov = 1.5; + depthCamera->SetImageWidth(imgWidth); + EXPECT_EQ(depthCamera->ImageWidth(), + static_cast(imgWidth)); + depthCamera->SetImageHeight(imgHeight); + EXPECT_EQ(depthCamera->ImageHeight(), + static_cast(imgHeight)); + depthCamera->SetFarClipPlane(farDist); + EXPECT_DOUBLE_EQ(depthCamera->FarClipPlane(), farDist); + depthCamera->SetNearClipPlane(nearDist); + EXPECT_DOUBLE_EQ(depthCamera->NearClipPlane(), nearDist); + depthCamera->SetAspectRatio(aspectRatio); + EXPECT_DOUBLE_EQ(depthCamera->AspectRatio(), aspectRatio); + depthCamera->SetHFOV(hfov); + EXPECT_DOUBLE_EQ(depthCamera->HFOV().Radian(), hfov); + + depthCamera->CreateDepthTexture(); + scene->RootVisual()->AddChild(depthCamera); + + // Set a callback on the camera sensor to get a depth camera frame + float *scan = new float[imgHeight * imgWidth]; + gz::common::ConnectionPtr connection = + depthCamera->ConnectNewDepthFrame( + std::bind(&::OnNewDepthFrame, scan, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, + std::placeholders::_4, std::placeholders::_5)); + + g_depthCounter = 0u; + depthCamera->Update(); + scene->SetTime(scene->Time() + std::chrono::milliseconds(16)); + EXPECT_EQ(1u, g_depthCounter); + + float expectedRange = boxPosition.X() - unitBoxSize * 0.5; + unsigned int hasInfValues = 0u; + unsigned int hasBoxValues = 0u; + for (unsigned int i = 0; i < depthCamera->ImageHeight(); ++i) + { + for (unsigned int j = 0; j < depthCamera->ImageWidth(); ++j) + { + float x = scan[i * depthCamera->ImageWidth() + j]; + if (gz::math::equal(expectedRange, x)) + hasBoxValues++; + else if (std::isinf(x)) + hasInfValues++; + else + FAIL() << "Unexpected range value: " << x; + } + } + EXPECT_LT(0u, hasBoxValues); + EXPECT_LT(0u, hasInfValues); + + // Now override with a custom projection matrix + // This projection matrix corresponds to a small horizontal FOV + // (hfov = 0.5) + gz::math::Matrix4d projectionMatrix( + 3.91632, 0, 0, 0, + 0, 3.91632, 0, 0, + 0, 0, -1.0002, -0.20002, + 0, 0, -1, 0); + depthCamera->SetProjectionMatrix(projectionMatrix); + depthCamera->Update(); + scene->SetTime(scene->Time() + std::chrono::milliseconds(16)); + EXPECT_EQ(2u, g_depthCounter); + + // The camera should use the updated projection matrix and + // the box should fill the whole image. + // Verify all range values at the expected box range + for (unsigned int i = 0; i < depthCamera->ImageHeight(); ++i) + { + for (unsigned int j = 0; j < depthCamera->ImageWidth(); ++j) + { + float x = scan[i * depthCamera->ImageWidth() + j]; + EXPECT_FLOAT_EQ(expectedRange, x); + } + } + + // Clean up + connection.reset(); + delete [] scan; + } + + engine->DestroyScene(scene); +}