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/CMakeLists.txt b/CMakeLists.txt index 6d3b1cb5d..247aecb05 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/Changelog.md b/Changelog.md index 5df59a721..d4487f62c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,73 @@ ### 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) + * [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 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/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/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 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/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/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/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 6d182dbd8..38d0b29a5 100644 --- a/ogre2/src/Ogre2DepthCamera.cc +++ b/ogre2/src/Ogre2DepthCamera.cc @@ -1069,6 +1069,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/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/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) 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/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/package.xml b/package.xml new file mode 100644 index 000000000..8083274df --- /dev/null +++ b/package.xml @@ -0,0 +1,34 @@ + + + + gz-rendering9 + 9.0.0 + Gazebo Rendering: Rendering library for robot applications + Ian Chen + Apache License 2.0 + https://github.com/gazebosim/gz-rendering + + cmake + + gz-cmake4 + + glut + gz-common6 + gz-math8 + gz-plugin3 + gz-utils3 + libfreeimage-dev + libglew-dev + libogre-dev + libogre-next-2.3-dev + libvulkan-dev + libxi-dev + libxmu-dev + uuid + + xvfb + + + cmake + + 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/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) 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/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); +} 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);