diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e36175c3a..53e67b817 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,7 @@ jobs: uses: ignition-tooling/action-ignition-ci@bionic with: codecov-enabled: true + doxygen-enabled: true focal-ci: runs-on: ubuntu-latest name: Ubuntu Focal CI diff --git a/CMakeLists.txt b/CMakeLists.txt index a4f7c85f4..ee1d1ceba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ ign_configure_project(VERSION_SUFFIX) # Set project-specific options #============================================================================ -# ignition-rendering currently has no options that are unique to it +option(USE_UNOFFICAL_OGRE_VERSIONS "Accept unsupported Ogre versions in the build" OFF) #============================================================================ # Search for project-specific dependencies @@ -63,10 +63,26 @@ endif() # Find OGRE list(APPEND ign_ogre_components "RTShaderSystem" "Terrain" "Overlay") -ign_find_package(IgnOGRE VERSION 1.8.0 - COMPONENTS ${ign_ogre_components} - REQUIRED_BY ogre - PRIVATE_FOR ogre) +# Ogre versions greater than 1.9 are not officialy supported. +# Display a warning for the users on this setup unless they provide +# USE_UNOFFICAL_OGRE_VERSIONS flag +if (NOT USE_UNOFFICAL_OGRE_VERSIONS) + ign_find_package(IgnOGRE VERSION 1.10 + COMPONENTS ${ign_ogre_components}) + + if (OGRE_FOUND) + 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") + 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() if (OGRE_FOUND) # find boost - mainly needed on macOS and also by the terrain component @@ -154,6 +170,7 @@ configure_file(${CMAKE_SOURCE_DIR}/tutorials.md.in ${CMAKE_BINARY_DIR}/tutorials ign_create_docs( API_MAINPAGE_MD "${CMAKE_BINARY_DIR}/api.md" TUTORIALS_MAINPAGE_MD "${CMAKE_BINARY_DIR}/tutorials.md" + IMAGE_PATH_DIRS "${CMAKE_SOURCE_DIR}/tutorials/img" TAGFILES "${IGNITION-COMMON_DOXYGEN_TAGFILE} = ${IGNITION-COMMON_API_URL}" "${IGNITION-MATH_DOXYGEN_TAGFILE} = ${IGNITION-MATH_API_URL}" diff --git a/Changelog.md b/Changelog.md index 3711be38c..229b553d5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -366,6 +366,10 @@ ### Ignition Rendering 3.X.X (2021-XX-XX) +1. CMake warning on Ogre versions that are not officially supported. + To disable the new warning, it is enough to enable the cmake option USE_UNOFFICAL_OGRE_VERSIONS + * [Pull request 376](https://github.com/ignitionrobotics/ign-rendering/pull/376) + ### Ignition Rendering 3.5.0 (2021-05-25) 1. Include MoveTo Helper class to ign-rendering diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml deleted file mode 100644 index d09fb6c21..000000000 --- a/bitbucket-pipelines.yml +++ /dev/null @@ -1,57 +0,0 @@ -image: ubuntu:bionic - -pipelines: - default: - - step: - script: # Modify the commands below to build your repository. - - apt update - - apt -y install wget lsb-release gnupg - - sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' - - wget http://packages.osrfoundation.org/gazebo.key -O - | apt-key add - - - apt-get update - - apt-get -y install - cmake pkg-config cppcheck libogre-1.9-dev libogre-2.1-dev libglew-dev libfreeimage-dev doxygen ruby-ronn freeglut3-dev libxmu-dev libxi-dev curl git g++-8 uuid-dev xvfb - - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 - - gcc -v - - g++ -v - - gcov -v - # Dependency: Ignition packages - - apt-get -y install - libignition-cmake2-dev - libignition-math6-dev - libignition-plugin-dev - # libignition-common4-dev - # Ignition common (uncomment if a specific branch is needed) - - apt-get -y install - libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev - libfreeimage-dev libgts-dev libswscale-dev libtinyxml2-dev - - git clone http://github.com/ignitionrobotics/ign-common -b main - - cd ign-common - - mkdir build - - cd build - - cmake .. - - make -j4 install - - cd ../.. - # lcov - - git clone https://github.com/linux-test-project/lcov.git - - cd lcov - - make install - - cd .. - # Ignition rendering - - mkdir build - - cd build - - cmake .. -DCMAKE_BUILD_TYPE=coverage - - make -j4 - - make install - - make codecheck - # Run tests - # - Xvfb :1 -screen 0 1280x1024x24 & - # - DISPLAY=:1.0 make test - # - DISPLAY=:1.0 RENDER_ENGINE_VALUES=ogre2 MESA_GL_VERSION_OVERRIDE=3.3 make test - # Build an example - - cd ../examples/simple_demo - - mkdir build - - cd build - - cmake .. - - make -j4 - diff --git a/include/ignition/rendering/Camera.hh b/include/ignition/rendering/Camera.hh index 65fb55f65..40fa56f03 100644 --- a/include/ignition/rendering/Camera.hh +++ b/include/ignition/rendering/Camera.hh @@ -81,8 +81,8 @@ namespace ignition public: virtual math::Angle HFOV() const = 0; /// \brief Set the camera's horizontal field-of-view - /// \param[in] _angle Desired horizontal field-of-view - public: virtual void SetHFOV(const math::Angle &_angle) = 0; + /// \param[in] _hfov Desired horizontal field-of-view + public: virtual void SetHFOV(const math::Angle &_hfov) = 0; /// \brief Get the camera's aspect ratio /// \return The camera's aspect ratio diff --git a/include/ignition/rendering/GaussianNoisePass.hh b/include/ignition/rendering/GaussianNoisePass.hh index d76218358..efb3cc7f8 100644 --- a/include/ignition/rendering/GaussianNoisePass.hh +++ b/include/ignition/rendering/GaussianNoisePass.hh @@ -58,7 +58,7 @@ namespace ignition public: virtual void SetMean(double _mean) = 0; /// \brief Set stddev. - /// \param[in] _stddev Standard deviation of Gaussian noise. + /// \param[in] _stdDev Standard deviation of Gaussian noise. public: virtual void SetStdDev(double _stdDev) = 0; /// \brief Set the mean of the bias value. Bias is computed based on diff --git a/include/ignition/rendering/Geometry.hh b/include/ignition/rendering/Geometry.hh index 51839a1a5..57889f5e7 100644 --- a/include/ignition/rendering/Geometry.hh +++ b/include/ignition/rendering/Geometry.hh @@ -55,13 +55,13 @@ namespace ignition /// \param[in] _name Name of registered Material /// \param[in] _unique True if the specified material should be cloned public: virtual void SetMaterial(const std::string &_name, - bool unique = true) = 0; + bool _unique = true) = 0; /// \brief Set the materials of this Geometry /// \param[in] _material New Material to be assigned /// \param[in] _unique True if the given material should be cloned public: virtual void SetMaterial(MaterialPtr _material, - bool unique = true) = 0; + bool _unique = true) = 0; /// \brief Get the material of this geometry /// \return Material used by this geometry diff --git a/include/ignition/rendering/GpuRays.hh b/include/ignition/rendering/GpuRays.hh index de435d72a..242eba088 100644 --- a/include/ignition/rendering/GpuRays.hh +++ b/include/ignition/rendering/GpuRays.hh @@ -54,7 +54,7 @@ namespace ignition /// \brief Configure behaviour for data values outside of camera range /// \param[in] _clamp True to clamp data to camera clip distances, // false to leave data values as +/-inf when out of camera range - public: virtual void SetClamp(const bool _value) = 0; + public: virtual void SetClamp(const bool _clamp) = 0; /// \brief Get behaviour for data values outside of camera range /// \return True if data values are clampped to camera clip distances, diff --git a/include/ignition/rendering/HeightmapDescriptor.hh b/include/ignition/rendering/HeightmapDescriptor.hh index 50f08760c..2717554c2 100644 --- a/include/ignition/rendering/HeightmapDescriptor.hh +++ b/include/ignition/rendering/HeightmapDescriptor.hh @@ -123,7 +123,7 @@ inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { public: double MinHeight() const; /// \brief Set the minimum height of the blend in meters. - /// \param[in] _uri The minimum height of the blend in meters. + /// \param[in] _minHeight The minimum height of the blend in meters. public: void SetMinHeight(double _minHeight); /// \brief Get the heightmap blend's fade distance. @@ -131,7 +131,7 @@ inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { public: double FadeDistance() const; /// \brief Set the distance over which the blend occurs. - /// \param[in] _uri The distance in meters. + /// \param[in] _fadeDistance The distance in meters. public: void SetFadeDistance(double _fadeDistance); /// \brief Private data pointer. @@ -149,7 +149,7 @@ inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { public: HeightmapDescriptor(); /// \brief Copy constructor - /// \param[in] _heightmap HeightmapDescriptor to copy. + /// \param[in] _desc HeightmapDescriptor to copy. public: HeightmapDescriptor(const HeightmapDescriptor &_desc); /// \brief Move constructor diff --git a/include/ignition/rendering/Light.hh b/include/ignition/rendering/Light.hh index ad1fffaa4..e620dcc10 100644 --- a/include/ignition/rendering/Light.hh +++ b/include/ignition/rendering/Light.hh @@ -96,7 +96,7 @@ namespace ignition public: virtual double AttenuationRange() const = 0; /// \brief Set the attenuation range - /// \param[in] _value New attenuation range + /// \param[in] _range New attenuation range public: virtual void SetAttenuationRange(double _range) = 0; /// \brief Determine if this light cast shadows @@ -179,7 +179,7 @@ namespace ignition public: virtual void SetInnerAngle(double _radians) = 0; /// \brief Set the inner angle of the spotlight - /// \param[in] _radians New inner angle of the spotlight + /// \param[in] _angle New inner angle of the spotlight public: virtual void SetInnerAngle(const math::Angle &_angle) = 0; /// \brief Get the outer angle of the spotlight @@ -191,7 +191,7 @@ namespace ignition public: virtual void SetOuterAngle(double _radians) = 0; /// \brief Set the outer angle of the spotlight - /// \param[in] _radians New outer angle of the spotlight + /// \param[in] _angle New outer angle of the spotlight public: virtual void SetOuterAngle(const math::Angle &_angle) = 0; /// \brief Get the falloff of the spotlight diff --git a/include/ignition/rendering/LightVisual.hh b/include/ignition/rendering/LightVisual.hh index 91a556bdf..cc8c6090f 100644 --- a/include/ignition/rendering/LightVisual.hh +++ b/include/ignition/rendering/LightVisual.hh @@ -60,20 +60,20 @@ namespace ignition /// \return The light visual type public: virtual LightVisualType Type() = 0; - /// \brief set inner angle for spot lights - /// \param[in] _type inner angle + /// \brief Set inner angle for spot lights + /// \param[in] _innerAngle Inner angle public: virtual void SetInnerAngle(double _innerAngle) = 0; /// \brief Get inner angle /// \return The light inner angle public: virtual double InnerAngle() = 0; - /// \brief set inner angle for spot lights - /// \param[in] _type inner angle + /// \brief Set outer angle for spot lights + /// \param[in] _outerAngle Outer angle public: virtual void SetOuterAngle(double _outerAngle) = 0; - /// \brief Get inner angle - /// \return The light inner angle + /// \brief Get outer angle + /// \return The light outer angle public: virtual double OuterAngle() = 0; }; } diff --git a/include/ignition/rendering/Marker.hh b/include/ignition/rendering/Marker.hh index 585293773..9b4844bdd 100644 --- a/include/ignition/rendering/Marker.hh +++ b/include/ignition/rendering/Marker.hh @@ -100,7 +100,7 @@ namespace ignition public: virtual int32_t Layer() const = 0; /// \brief Set the render type of this Marker - /// \param[in] The desired render type + /// \param[in] _markerType The desired render type public: virtual void SetType( const ignition::rendering::MarkerType _markerType) = 0; diff --git a/include/ignition/rendering/Material.hh b/include/ignition/rendering/Material.hh index 9cd54544d..6dc28e51a 100644 --- a/include/ignition/rendering/Material.hh +++ b/include/ignition/rendering/Material.hh @@ -220,8 +220,8 @@ namespace ignition public: virtual std::string Texture() const = 0; /// \brief Set the material texture - /// \param[in] _name URI of the new texture file - public: virtual void SetTexture(const std::string &_name) = 0; + /// \param[in] _texture URI of the new texture file + public: virtual void SetTexture(const std::string &_texture) = 0; /// \brief Removes any texture mapped to this material public: virtual void ClearTexture() = 0; @@ -235,8 +235,8 @@ namespace ignition public: virtual std::string NormalMap() const = 0; /// \brief Set the material normal map - /// \param[in] _name URI of the new normal map file - public: virtual void SetNormalMap(const std::string &_name) = 0; + /// \param[in] _normalMap URI of the new normal map file + public: virtual void SetNormalMap(const std::string &_normalMap) = 0; /// \brief Removes any normal map mapped to this material public: virtual void ClearNormalMap() = 0; @@ -250,8 +250,9 @@ namespace ignition public: virtual std::string RoughnessMap() const = 0; /// \brief Set the material roughness map - /// \param[in] _name URI of the new roughness map file - public: virtual void SetRoughnessMap(const std::string &_name) = 0; + /// \param[in] _roughnessMap URI of the new roughness map file + public: virtual void SetRoughnessMap( + const std::string &_roughnessMap) = 0; /// \brief Removes any roughness map mapped to this material public: virtual void ClearRoughnessMap() = 0; @@ -265,8 +266,9 @@ namespace ignition public: virtual std::string MetalnessMap() const = 0; /// \brief Set the material metalness map - /// \param[in] _name URI of the new metalness map file - public: virtual void SetMetalnessMap(const std::string &_name) = 0; + /// \param[in] _metalnessMap URI of the new metalness map file + public: virtual void SetMetalnessMap( + const std::string &_metalnessMap) = 0; /// \brief Removes any metalness map mapped to this material public: virtual void ClearMetalnessMap() = 0; @@ -280,8 +282,9 @@ namespace ignition public: virtual std::string EnvironmentMap() const = 0; /// \brief Set the material environment map - /// \param[in] _name URI of the new environment map file - public: virtual void SetEnvironmentMap(const std::string &_name) = 0; + /// \param[in] _metalnessMap URI of the new environment map file + public: virtual void SetEnvironmentMap( + const std::string &_metalnessMap) = 0; /// \brief Removes any environment map mapped to this material public: virtual void ClearEnvironmentMap() = 0; @@ -295,8 +298,9 @@ namespace ignition public: virtual std::string EmissiveMap() const = 0; /// \brief Set the material emissive map - /// \param[in] _name URI of the new emissive map file - public: virtual void SetEmissiveMap(const std::string &_name) = 0; + /// \param[in] _emissiveMap URI of the new emissive map file + public: virtual void SetEmissiveMap( + const std::string &_emissiveMap) = 0; /// \brief Removes any emissive map mapped to this material public: virtual void ClearEmissiveMap() = 0; @@ -314,9 +318,9 @@ namespace ignition public: virtual unsigned int LightMapTexCoordSet() const = 0; /// \brief Set the material light map - /// \param[in] _name URI of the new light map file + /// \param[in] _lightMap URI of the new light map file /// \param[in] _uvSet Texture coordinate set to use - public: virtual void SetLightMap(const std::string &_name, + public: virtual void SetLightMap(const std::string &_lightMap, unsigned int _uvSet = 0u) = 0; /// \brief Removes any light map mapped to this material diff --git a/include/ignition/rendering/Mesh.hh b/include/ignition/rendering/Mesh.hh index 9e5acd936..cd9b7bdb5 100644 --- a/include/ignition/rendering/Mesh.hh +++ b/include/ignition/rendering/Mesh.hh @@ -139,13 +139,13 @@ namespace ignition /// \param[in] _name Name of registered Material /// \param[in] _unique True if the specified material should be cloned public: virtual void SetMaterial(const std::string &_name, - bool unique = true) = 0; + bool _unique = true) = 0; /// \brief Set the materials of this SubMesh /// \param[in] _material New Material to be assigned /// \param[in] _unique True if the given material should be cloned public: virtual void SetMaterial(MaterialPtr _material, - bool unique = true) = 0; + bool _unique = true) = 0; }; } } diff --git a/include/ignition/rendering/RayQuery.hh b/include/ignition/rendering/RayQuery.hh index b3130e46d..b1402075e 100644 --- a/include/ignition/rendering/RayQuery.hh +++ b/include/ignition/rendering/RayQuery.hh @@ -45,6 +45,12 @@ namespace ignition /// \brief Intersected object id public: unsigned int objectId = 0; + /// \brief Returns false if result is not valid + public: operator bool() const + { + return distance > 0; + } + /// \brief Returns false if result is not valid public: operator bool() { @@ -69,7 +75,7 @@ namespace ignition public: virtual math::Vector3d Origin() const = 0; /// \brief Set ray direction - /// \param[in] _origin Ray origin + /// \param[in] _dir Ray origin public: virtual void SetDirection(const math::Vector3d &_dir) = 0; /// \brief Get ray direction @@ -83,8 +89,7 @@ namespace ignition const math::Vector2d &_coord) = 0; /// \brief Compute intersections - /// \param[out] A vector of intersection results - /// \return True if results are not empty + /// \return A vector of intersection results public: virtual RayQueryResult ClosestPoint() = 0; }; } diff --git a/include/ignition/rendering/RenderEngine.hh b/include/ignition/rendering/RenderEngine.hh index 4fc14ece4..53cf95a7e 100644 --- a/include/ignition/rendering/RenderEngine.hh +++ b/include/ignition/rendering/RenderEngine.hh @@ -164,7 +164,7 @@ namespace ignition const std::string &_name) = 0; /// \brief Add path to media resource location - /// \param[in] _paths Absolute path to resource location + /// \param[in] _path Absolute path to resource location public: virtual void AddResourcePath(const std::string &_path) = 0; /// \brief Get the render pass system for this engine. diff --git a/include/ignition/rendering/RenderTypes.hh b/include/ignition/rendering/RenderTypes.hh index 23ff5e202..f5fef7941 100644 --- a/include/ignition/rendering/RenderTypes.hh +++ b/include/ignition/rendering/RenderTypes.hh @@ -21,19 +21,19 @@ #include -/// \def IGN_VISIBILITY_ALL +/// \typedef IGN_VISIBILITY_ALL /// \brief Render everything visibility mask. #define IGN_VISIBILITY_ALL 0x0FFFFFFF -/// \def IGN_VISIBILITY_SELECTION +/// \typedef IGN_VISIBILITY_SELECTION /// \brief Renders only objects that can be selected. #define IGN_VISIBILITY_SELECTION 0x10000000 -/// \def IGN_VISIBILITY_GUI +/// \typedef IGN_VISIBILITY_GUI /// \brief Render GUI visuals mask. #define IGN_VISIBILITY_GUI 0x00000001 -/// \def IGN_VISIBILITY_SELECTABLE +/// \typedef IGN_VISIBILITY_SELECTABLE /// \brief Render visuals that are selectable mask. #define IGN_VISIBILITY_SELECTABLE 0x00000002 @@ -89,300 +89,300 @@ namespace ignition class Visual; class WireBox; - /// \def ArrowVisualPtr + /// \typedef ArrowVisualPtr /// \brief Shared pointer to ArrowVisual typedef shared_ptr ArrowVisualPtr; - /// \def AxisVisualPtr + /// \typedef AxisVisualPtr /// \brief Shared pointer to AxisVisual typedef shared_ptr AxisVisualPtr; - /// \def CameraPtr + /// \typedef CameraPtr /// \brief Shared pointer to Camera typedef shared_ptr CameraPtr; - /// \def DepthCameraPtr + /// \typedef DepthCameraPtr /// \brief Shared pointer to DepthCamera typedef shared_ptr DepthCameraPtr; - /// \def ThermalCameraPtr + /// \typedef ThermalCameraPtr /// \brief Shared pointer to ThermalCamera typedef shared_ptr ThermalCameraPtr; - /// \def GpuRaysPtr + /// \typedef GpuRaysPtr /// \brief Shared pointer to GpuRays typedef shared_ptr GpuRaysPtr; - /// \def DirectionalLightPtr + /// \typedef DirectionalLightPtr /// \brief Shared pointer to DirectionalLight typedef shared_ptr DirectionalLightPtr; - /// \def GaussianNoisePass + /// \typedef GaussianNoisePassPtr /// \brief Shared pointer to GaussianNoisePass typedef shared_ptr GaussianNoisePassPtr; - /// \def GeometryPtr + /// \typedef GeometryPtr /// \brief Shared pointer to Geometry typedef shared_ptr GeometryPtr; - /// \def GizmoVisualPtr + /// \typedef GizmoVisualPtr /// \brief Shared pointer to GizmoVisual typedef shared_ptr GizmoVisualPtr; - /// \def CapsulePtr + /// \typedef CapsulePtr /// \brief Shared pointer to Capsule typedef shared_ptr CapsulePtr; - /// \def GridPtr + /// \typedef GridPtr /// \brief Shared pointer to Grid typedef shared_ptr GridPtr; - /// \def JointVisualPtr + /// \typedef JointVisualPtr /// \brief Shared pointer to JointVisual typedef shared_ptr JointVisualPtr; - /// \def HeightmapPtr + /// \typedef HeightmapPtr /// \brief Shared pointer to Heightmap typedef shared_ptr HeightmapPtr; - /// \def ImagePtr + /// \typedef ImagePtr /// \brief Shared pointer to Image typedef shared_ptr ImagePtr; - /// \def LightPtr + /// \typedef LightPtr /// \brief Shared pointer to Light typedef shared_ptr LightPtr; - /// \def LightVisualPtr + /// \typedef LightVisualPtr /// \brief Shared pointer to Light typedef shared_ptr LightVisualPtr; - /// \def LidarVisualPtr + /// \typedef LidarVisualPtr /// \brief Shared pointer to LidarVisual typedef shared_ptr LidarVisualPtr; - /// \def MaterialPtr + /// \typedef MaterialPtr /// \brief Shared pointer to Material typedef shared_ptr MaterialPtr; - /// \def MarkerPtr + /// \typedef MarkerPtr /// \brief Shared pointer to Marker typedef shared_ptr MarkerPtr; - /// \def MeshPtr + /// \typedef MeshPtr /// \brief Shared pointer to Mesh typedef shared_ptr MeshPtr; - /// \def NodePtr + /// \typedef NodePtr /// \brief Shared pointer to Node typedef shared_ptr NodePtr; - /// \def ObjectPtr + /// \typedef ObjectPtr /// \brief Shared pointer to Object typedef shared_ptr ObjectPtr; - /// \def ObjectFactoryPtr + /// \typedef ObjectFactoryPtr /// \brief Shared pointer to ObjectFactory typedef shared_ptr ObjectFactoryPtr; - /// \def ParticleEmitterPtr + /// \typedef ParticleEmitterPtr /// \brief Shared pointer to ParticleEmitter typedef shared_ptr ParticleEmitterPtr; - /// \def PointLightPtr + /// \typedef PointLightPtr /// \brief Shared pointer to PointLight typedef shared_ptr PointLightPtr; - /// \def RayQueryPtr + /// \typedef RayQueryPtr /// \brief Shared pointer to RayQuery typedef shared_ptr RayQueryPtr; - /// \def RenderPassPtr + /// \typedef RenderPassPtr /// \brief Shared pointer to RenderPass typedef shared_ptr RenderPassPtr; - /// \def RenderPassSystemPtr + /// \typedef RenderPassSystemPtr /// \brief Shared pointer to RenderPassSystem typedef shared_ptr RenderPassSystemPtr; - /// \def RenderTargetPtr + /// \typedef RenderTargetPtr /// \brief Shared pointer to RenderTarget typedef shared_ptr RenderTargetPtr; - /// \def RenderTexturePtr + /// \typedef RenderTexturePtr /// \brief Shared pointer to RenderTexture typedef shared_ptr RenderTexturePtr; - /// \def RenderWindowPtr + /// \typedef RenderWindowPtr /// \brief Shared pointer to RenderWindow typedef shared_ptr RenderWindowPtr; - /// \def ScenePtr + /// \typedef ScenePtr /// \brief Shared pointer to Scene typedef shared_ptr ScenePtr; - /// \def SensorPtr + /// \typedef SensorPtr /// \brief Shared pointer to Sensor typedef shared_ptr SensorPtr; /// \brief Shared pointer to ShaderParams typedef shared_ptr ShaderParamsPtr; - /// \def SpotLightPtr + /// \typedef SpotLightPtr /// \brief Shared pointer to SpotLight typedef shared_ptr SpotLightPtr; - /// \def SubMeshPtr + /// \typedef SubMeshPtr /// \brief Shared pointer to SubMesh typedef shared_ptr SubMeshPtr; - /// \def TextPtr + /// \typedef TextPtr /// \brief Shared pointer to Text typedef shared_ptr TextPtr; - /// \def VisualPtr + /// \typedef VisualPtr /// \brief Shared pointer to Visual typedef shared_ptr VisualPtr; - /// \def WireBoxPtr + /// \typedef WireBoxPtr /// \brief Shared pointer to WireBox typedef shared_ptr WireBoxPtr; - /// \def const ArrowVisualPtr + /// \typedef const ArrowVisualPtr /// \brief Shared pointer to const ArrowVisual typedef shared_ptr ConstArrowVisualPtr; - /// \def const AxisVisualPtr + /// \typedef const AxisVisualPtr /// \brief Shared pointer to const AxisVisual typedef shared_ptr ConstAxisVisualPtr; - /// \def const CameraPtr + /// \typedef const CameraPtr /// \brief Shared pointer to const Camera typedef shared_ptr ConstCameraPtr; - /// \def const DepthCameraPtr + /// \typedef const DepthCameraPtr /// \brief Shared pointer to const DepthCamera typedef shared_ptr ConstDepthCameraPtr; - /// \def const ThermalCameraPtr + /// \typedef const ThermalCameraPtr /// \brief Shared pointer to const ThermalCamera typedef shared_ptr ConstThermalCameraPtr; - /// \def const GpuRaysPtr + /// \typedef const GpuRaysPtr /// \brief Shared pointer to const GpuRays typedef shared_ptr ConstGpuRaysPtr; - /// \def const DirectionalLightPtr + /// \typedef const DirectionalLightPtr /// \brief Shared pointer to const DirectionalLight typedef shared_ptr ConstDirectionalLightPtr; - /// \def const GaussianNoisePass + /// \typedef const ConstGaussianNoisePass /// \brief Shared pointer to const GaussianNoisePass typedef shared_ptr ConstGaussianNoisePass; - /// \def const GeometryPtr + /// \typedef const GeometryPtr /// \brief Shared pointer to const Geometry typedef shared_ptr ConstGeometryPtr; - /// \def const GizmoVisualPtr + /// \typedef const GizmoVisualPtr /// \brief Shared pointer to const GizmoVisual typedef shared_ptr ConstGizmoVisualPtr; - /// \def const JointVisualPtr + /// \typedef const JointVisualPtr /// \brief Shared pointer to const JointVisual typedef shared_ptr ConstJointVisualPtr; - /// \def const HeightmapPtr + /// \typedef const HeightmapPtr /// \brief Shared pointer to const Heightmap typedef shared_ptr ConstHeightmapPtr; - /// \def const ImagePtr + /// \typedef const ImagePtr /// \brief Shared pointer to const Image typedef shared_ptr ConstImagePtr; - /// \def const LightPtr + /// \typedef const LightPtr /// \brief Shared pointer to const Light typedef shared_ptr ConstLightPtr; - /// \def const LidarVisualPtr + /// \typedef const LidarVisualPtr /// \brief Shared pointer to const LidarVisual typedef shared_ptr ConstLidarVisualPtr; - /// \def const MaterialPtr + /// \typedef const MaterialPtr /// \brief Shared pointer to const Material typedef shared_ptr ConstMaterialPtr; - /// \def const MeshPtr + /// \typedef const MeshPtr /// \brief Shared pointer to const Mesh typedef shared_ptr ConstMeshPtr; - /// \def const NodePtr + /// \typedef const NodePtr /// \brief Shared pointer to const Node typedef shared_ptr ConstNodePtr; - /// \def const ObjectPtr + /// \typedef const ObjectPtr /// \brief Shared pointer to const Object typedef shared_ptr ConstObjectPtr; - /// \def const ObjectFactoryPtr + /// \typedef const ObjectFactoryPtr /// \brief Shared pointer to const ObjectFactory typedef shared_ptr ConstObjectFactoryPtr; - /// \def const ParticleEmitterPtr + /// \typedef const ParticleEmitterPtr /// \brief Shared pointer to const ParticleEmitter typedef shared_ptr ConstParticleEmitterPtr; - /// \def const PointLightPtr + /// \typedef const PointLightPtr /// \brief Shared pointer to const PointLight typedef shared_ptr ConstPointLightPtr; - /// \def RayQueryPtr + /// \typedef RayQueryPtr /// \brief Shared pointer to RayQuery typedef shared_ptr ConstRayQueryPtr; - /// \def const RenderPassPtr + /// \typedef const RenderPassPtr /// \brief Shared pointer to const RenderPass typedef shared_ptr ConstRenderPassPtr; - /// \def const RenderPassSystemPtr + /// \typedef const RenderPassSystemPtr /// \brief Shared pointer to const RenderPassSystem typedef shared_ptr ConstRenderPassSystemPtr; - /// \def const RenderTargetPtr + /// \typedef const RenderTargetPtr /// \brief Shared pointer to const RenderTarget typedef shared_ptr ConstRenderTargetPtr; - /// \def const RenderTexturePtr + /// \typedef const RenderTexturePtr /// \brief Shared pointer to const RenderTexture typedef shared_ptr ConstRenderTexturePtr; - /// \def const RenderWindowPtr + /// \typedef const RenderWindowPtr /// \brief Shared pointer to const RenderWindow typedef shared_ptr ConstRenderWindowPtr; - /// \def const ScenePtr + /// \typedef const ScenePtr /// \brief Shared pointer to const Scene typedef shared_ptr ConstScenePtr; - /// \def const SensorPtr + /// \typedef const SensorPtr /// \brief Shared pointer to const Sensor typedef shared_ptr ConstSensorPtr; /// \brief Shared pointer to const ShaderParams typedef shared_ptr ConstShaderParamsPtr; - /// \def const SpotLightPtr + /// \typedef const SpotLightPtr /// \brief Shared pointer to const SpotLight typedef shared_ptr ConstSpotLightPtr; - /// \def const SubMeshPtr + /// \typedef const SubMeshPtr /// \brief Shared pointer to const SubMesh typedef shared_ptr ConstSubMeshPtr; - /// \def const SubMeshPtr + /// \typedef const SubMeshPtr /// \brief Shared pointer to const SubMesh typedef shared_ptr ConstTextPtr; - /// \def const VisualPtr + /// \typedef const VisualPtr /// \brief Shared pointer to const Visual typedef shared_ptr ConstVisualPtr; } diff --git a/include/ignition/rendering/Scene.hh b/include/ignition/rendering/Scene.hh index b61404580..2dce70b52 100644 --- a/include/ignition/rendering/Scene.hh +++ b/include/ignition/rendering/Scene.hh @@ -226,7 +226,7 @@ namespace ignition /// scene, no work will be done. Depending on the _recursive argument, /// this function will either detach all child nodes from the scene graph /// or recursively destroy them. - /// \param[in] _id ID of the node to destroy + /// \param[in] _node Node pointer to destroy /// \param[in] _recursive True to recursively destroy the node and its /// children, false to destroy only this node and detach the children public: virtual void DestroyNode(NodePtr _node, @@ -298,7 +298,7 @@ namespace ignition /// scene, no work will be done. Depending on the _recursive argument, /// this function will either detach all child nodes from the scene graph /// or recursively destroy them. - /// \param[in] _id ID of the light to destroy + /// \param[in] _light Light pointer to destroy /// \param[in] _recursive True to recursively destroy the node and its /// children, false to destroy only this node and detach the children public: virtual void DestroyLight(LightPtr _light, @@ -370,7 +370,7 @@ namespace ignition /// this scene, no work will be done. Depending on the _recursive /// argument, this function will either detach all child nodes from the /// scene graph or recursively destroy them. - /// \param[in] _id ID of the sensor to destroy + /// \param[in] _sensor Sensor pointer to destroy /// \param[in] _recursive True to recursively destroy the node and its /// children, false to destroy only this node and detach the children public: virtual void DestroySensor(SensorPtr _sensor, @@ -443,7 +443,7 @@ namespace ignition /// this function will either detach all child nodes from the scene graph /// or recursively destroy them. /// consequently be detached from the scene graph, but not destroyed. - /// \param[in] _id ID of the node to destroy + /// \param[in] _node Visual pointer to destroy /// \param[in] _recursive True to recursively destroy the node and its /// children, false to destroy only this node and detach the children public: virtual void DestroyVisual(VisualPtr _node, diff --git a/include/ignition/rendering/Storage.hh b/include/ignition/rendering/Storage.hh index 5fb339f0d..a5e6a22c7 100644 --- a/include/ignition/rendering/Storage.hh +++ b/include/ignition/rendering/Storage.hh @@ -48,11 +48,11 @@ namespace ignition template class IGNITION_RENDERING_VISIBLE Map { - /// \def TPtr + /// \typedef TPtr /// \brief Shared pointer to T typedef std::shared_ptr TPtr; - /// \def const TPtr + /// \typedef const TPtr /// \brief Shared pointer to const T typedef std::shared_ptr ConstTPtr; @@ -97,7 +97,7 @@ namespace ignition /// \brief Remove the given element. If the given element does not exist /// no work will be done. - /// \param[in] _key Key of the element in question + /// \param[in] _value Key of the element in question public: virtual void Remove(TPtr _value) = 0; /// \brief Remove all elements from this map @@ -113,11 +113,11 @@ namespace ignition template class IGNITION_RENDERING_VISIBLE Store { - /// \def TPtr + /// \typedef TPtr /// \brief Shared pointer to T typedef std::shared_ptr TPtr; - /// \def const TPtr + /// \typedef const TPtr /// \brief Shared pointer to const T typedef std::shared_ptr ConstTPtr; @@ -218,7 +218,7 @@ namespace ignition public: virtual void DestroyAll() = 0; }; - /// \class CompositeStore CompositeStore.hh + /// \class CompositeStore Storage.hh ignition/rendering/Storage.hh /// ignition/rendering/CompositeStore.hh /// \brief Represents a collection of Store objects, collectively working as /// a single composite store. @@ -227,19 +227,19 @@ namespace ignition class IGNITION_RENDERING_VISIBLE CompositeStore : public Store { - /// \def TPtr + /// \typedef TPtr /// \brief Shared pointer to T typedef std::shared_ptr TPtr; - /// \def TPtr + /// \typedef TPtr /// \brief Store of T typedef Store TStore; - /// \def TStorePtr + /// \typedef TStorePtr /// \brief Shared pointer to TStore typedef std::shared_ptr TStorePtr; - /// \def const TStorePtr + /// \typedef const TStorePtr /// \brief Shared pointer to const TStore typedef std::shared_ptr ConstTStorePtr; @@ -280,7 +280,7 @@ namespace ignition public: virtual TStorePtr RemoveStore(unsigned int _index) = 0; }; - /// \class StoreWrapper StoreWrapper.hh ignition/rendering/StoreWrapper.hh + /// \class StoreWrapper Storage.hh ignition/rendering/StoreWrapper.hh /// \brief Simple wrapper class that allows a Store of type Derived to be /// treated as a Store of type Base, where Derived is some class derived /// from Base. This is useful in storing Stores of different derived types diff --git a/include/ignition/rendering/Text.hh b/include/ignition/rendering/Text.hh index 45a83dd87..bcd7d91e2 100644 --- a/include/ignition/rendering/Text.hh +++ b/include/ignition/rendering/Text.hh @@ -133,7 +133,7 @@ namespace ignition public: virtual TextVerticalAlign VerticalAlignment() const = 0; /// \brief Set the baseline height of the text - /// \param[in] _height Baseline height + /// \param[in] _baseline Baseline height /// \sa Baseline() public: virtual void SetBaseline(const float _baseline) = 0; @@ -143,7 +143,7 @@ namespace ignition public: virtual float Baseline() const = 0; /// \brief True = text always is displayed ontop. - /// \param[in] _show Set to true to render the text on top of + /// \param[in] _onTop Set to true to render the text on top of /// all other drawables. /// \sa ShowOnTop() public: virtual void SetShowOnTop(const bool _onTop) = 0; diff --git a/include/ignition/rendering/ThermalCamera.hh b/include/ignition/rendering/ThermalCamera.hh index 4890cfab2..643fed05a 100644 --- a/include/ignition/rendering/ThermalCamera.hh +++ b/include/ignition/rendering/ThermalCamera.hh @@ -107,7 +107,7 @@ namespace ignition /// If set, the temperature reading of heat sources will vary within /// a temperature of +/- range/2 instead of returning a fixed uniform /// temperature for the entire heat source - /// \param[in] _rnage Temperature variation range + /// \param[in] _range Temperature variation range /// \sa HeatSourceTemperatureRange public: virtual void SetHeatSourceTemperatureRange(float _range) = 0; diff --git a/include/ignition/rendering/TransformController.hh b/include/ignition/rendering/TransformController.hh index 3e537fa87..8f0be4f8c 100644 --- a/include/ignition/rendering/TransformController.hh +++ b/include/ignition/rendering/TransformController.hh @@ -64,7 +64,8 @@ namespace ignition public: virtual CameraPtr Camera() const; /// \brief Get the attached node - /// \param[in] _node Node the transform controller is attached to + /// \return The node which is being transformed, nullptr if there is no + /// node attached. public: virtual NodePtr Node() const; /// \brief Attach the transform controller to the specified node diff --git a/include/ignition/rendering/TransformType.hh b/include/ignition/rendering/TransformType.hh index 64b8e0529..faf1f66d5 100644 --- a/include/ignition/rendering/TransformType.hh +++ b/include/ignition/rendering/TransformType.hh @@ -29,7 +29,7 @@ namespace ignition { inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { // - /// \enum Transform axis + /// \enum TransformAxis /// \brief Unique identifiers for transformation axes. enum IGNITION_RENDERING_VISIBLE TransformAxis { @@ -55,7 +55,7 @@ namespace ignition TA_SCALE_Z = 0x00000400 }; - /// \enum Transform mode + /// \enum TransformMode /// \brief Unique identifiers for transformation modes. enum IGNITION_RENDERING_VISIBLE TransformMode { @@ -69,7 +69,7 @@ namespace ignition TM_SCALE = TA_SCALE_X | TA_SCALE_Y, TA_SCALEZ, }; - /// \enum Transform space + /// \enum TransformSpace /// \brief Unique identifiers for transformation spaces. enum IGNITION_RENDERING_VISIBLE TransformSpace { diff --git a/include/ignition/rendering/Utils.hh b/include/ignition/rendering/Utils.hh index 82483aac8..d1cea0cf8 100644 --- a/include/ignition/rendering/Utils.hh +++ b/include/ignition/rendering/Utils.hh @@ -21,11 +21,15 @@ #include #include +#include #include #include +#include "ignition/rendering/Camera.hh" #include "ignition/rendering/config.hh" #include "ignition/rendering/Export.hh" +#include "ignition/rendering/RayQuery.hh" + namespace ignition { @@ -35,6 +39,50 @@ namespace ignition // Inline bracket to help doxygen filtering. inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { // + /// \brief Retrieve the first point on a surface in the 3D scene hit by a + /// ray cast from the given 2D screen coordinates. + /// \param[in] _screenPos 2D coordinates on the screen, in pixels. + /// \param[in] _camera User camera + /// \param[in] _rayQuery Ray query for mouse clicks + /// \param[in] _maxDistance maximum distance to check the collision + /// \return 3D coordinates of a point in the 3D scene. + IGNITION_RENDERING_VISIBLE + math::Vector3d screenToScene( + const math::Vector2i &_screenPos, + const CameraPtr &_camera, + const RayQueryPtr &_rayQuery, + float _maxDistance = 10.0); + + /// \brief Retrieve the first point on a surface in the 3D scene hit by a + /// ray cast from the given 2D screen coordinates. + /// \param[in] _screenPos 2D coordinates on the screen, in pixels. + /// \param[in] _camera User camera + /// \param[in] _rayQuery Ray query for mouse clicks + /// \param[inout] _rayResult Ray query result + /// \param[in] _maxDistance maximum distance to check the collision + /// \return 3D coordinates of a point in the 3D scene. + IGNITION_RENDERING_VISIBLE + math::Vector3d screenToScene( + const math::Vector2i &_screenPos, + const CameraPtr &_camera, + const RayQueryPtr &_rayQuery, + RayQueryResult &_rayResult, + float _maxDistance = 10.0); + + /// \brief Retrieve the point on a plane at z = 0 in the 3D scene hit by a + /// ray cast from the given 2D screen coordinates. + /// \param[in] _screenPos 2D coordinates on the screen, in pixels. + /// \param[in] _camera User camera + /// \param[in] _rayQuery Ray query for mouse clicks + /// \param[in] _offset Offset along the plane normal + /// \return 3D coordinates of a point in the 3D scene. + IGNITION_RENDERING_VISIBLE + math::Vector3d screenToPlane( + const math::Vector2i &_screenPos, + const CameraPtr &_camera, + const RayQueryPtr &_rayQuery, + const float _offset = 0.0); + /// \brief Get the screen scaling factor. /// \return The screen scaling factor. IGNITION_RENDERING_VISIBLE @@ -43,7 +91,7 @@ namespace ignition /// \brief Transform a bounding box. /// \param[in] _box The bounding box. /// \param[in] _pose Pose used to transform the bounding box. - /// \param[out] _vertices Vertices of the transformed bounding box in + /// \return Vertices of the transformed bounding box in /// world coordinates. IGNITION_RENDERING_VISIBLE ignition::math::AxisAlignedBox transformAxisAlignedBox( diff --git a/include/ignition/rendering/Visual.hh b/include/ignition/rendering/Visual.hh index 922526e19..0e26fc233 100644 --- a/include/ignition/rendering/Visual.hh +++ b/include/ignition/rendering/Visual.hh @@ -84,25 +84,25 @@ namespace ignition /// \param[in] _name Name of the material to be assigned /// \param[in] _unique True if the specified material should be cloned public: virtual void SetMaterial(const std::string &_name, - bool unique = true) = 0; + bool _unique = true) = 0; /// \brief Set the material for all attached visuals and geometries - /// \param[in] _name Name of the material to be assigned + /// \param[in] _material Name of the material to be assigned /// \param[in] _unique True if the specified material should be cloned public: virtual void SetMaterial(MaterialPtr _material, - bool unique = true) = 0; + bool _unique = true) = 0; /// \brief Set the material for all attached visuals only - /// \param[in] _name Name of the material to be assigned + /// \param[in] _material Name of the material to be assigned /// \param[in] _unique True if the specified material should be cloned public: virtual void SetChildMaterial(MaterialPtr _material, - bool unique = true) = 0; + bool _unique = true) = 0; /// \brief Set the material for all attached geometries only - /// \param[in] _name Name of the material to be assigned + /// \param[in] _material Name of the material to be assigned /// \param[in] _unique True if the specified material should be cloned public: virtual void SetGeometryMaterial(MaterialPtr _material, - bool unique = true) = 0; + bool _unique = true) = 0; /// \brief Get the material assigned to attached visuals and geometries. /// \return the Pointer to the material assigned to this visual. If the @@ -123,11 +123,11 @@ namespace ignition public: virtual uint32_t VisibilityFlags() const = 0; /// \brief Add visibility flags - /// \param[in] _visibility flags + /// \param[in] _flags Visibility flags public: virtual void AddVisibilityFlags(uint32_t _flags) = 0; /// \brief Remove visibility flags - /// \param[in] _visibility flags + /// \param[in] _flags Visibility flags public: virtual void RemoveVisibilityFlags(uint32_t _flags) = 0; /// \brief Store any custom data associated with this visual @@ -138,7 +138,7 @@ namespace ignition /// \brief Get custom data stored in this visual /// \param[in] _key Unique key - /// \param[in] _value Value in any type + /// \return Data associated with the key. public: virtual Variant UserData(const std::string &_key) const = 0; /// \brief Get the bounding box in world frame coordinates. diff --git a/include/ignition/rendering/base/BaseGeometry.hh b/include/ignition/rendering/base/BaseGeometry.hh index 78578053f..6460f52dd 100644 --- a/include/ignition/rendering/base/BaseGeometry.hh +++ b/include/ignition/rendering/base/BaseGeometry.hh @@ -40,11 +40,13 @@ namespace ignition public: virtual void RemoveParent() override; - public: virtual void SetMaterial(const std::string &_name, - bool unique = true) override; + // Documentation inherited + public: virtual void SetMaterial(const std::string &_material, + bool _unique = true) override; + // Documentation inherited public: virtual void SetMaterial(MaterialPtr _material, - bool unique = true) override = 0; + bool _unique = true) override = 0; // Documentation inherited public: virtual void Destroy() override; diff --git a/include/ignition/rendering/base/BaseGizmoVisual.hh b/include/ignition/rendering/base/BaseGizmoVisual.hh index a00ffc982..c517f861f 100644 --- a/include/ignition/rendering/base/BaseGizmoVisual.hh +++ b/include/ignition/rendering/base/BaseGizmoVisual.hh @@ -87,7 +87,6 @@ namespace ignition protected: void CreateRotationVisual(); /// \brief Create gizmo visual for scale - /// \return Rotation visual protected: void CreateScaleVisual(); /// \brief Current gizmo mode diff --git a/include/ignition/rendering/base/BaseLight.hh b/include/ignition/rendering/base/BaseLight.hh index 516b46c26..540f0a9a8 100644 --- a/include/ignition/rendering/base/BaseLight.hh +++ b/include/ignition/rendering/base/BaseLight.hh @@ -34,26 +34,36 @@ namespace ignition public: virtual ~BaseLight(); + // Documentation inherited public: virtual void SetDiffuseColor(double _r, double _g, double _b, double _a = 1.0); + // Documentation inherited. public: virtual void SetDiffuseColor(const math::Color &_color) = 0; + // Documentation inherited. public: virtual void SetSpecularColor(double _r, double _g, double _b, double _a = 1.0); + // Documentation inherited. public: virtual void SetSpecularColor(const math::Color &_color) = 0; + // Documentation inherited. public: virtual void SetAttenuationConstant(double _value) = 0; + // Documentation inherited. public: virtual void SetAttenuationLinear(double _value) = 0; + // Documentation inherited. public: virtual void SetAttenuationQuadratic(double _value) = 0; + // Documentation inherited. public: virtual void SetAttenuationRange(double _range) = 0; + // Documentation inherited. public: virtual void SetCastShadows(bool _castShadows) = 0; + // Documentation inherited. protected: virtual void Reset(); }; diff --git a/include/ignition/rendering/base/BaseMaterial.hh b/include/ignition/rendering/base/BaseMaterial.hh index bc91c9aee..11bb6a11a 100644 --- a/include/ignition/rendering/base/BaseMaterial.hh +++ b/include/ignition/rendering/base/BaseMaterial.hh @@ -98,7 +98,7 @@ namespace ignition public: virtual void SetReflectivity(const double _reflectivity) override; // Documentation inherited - public: virtual void SetCastShadows(const bool _cast) override; + public: virtual void SetCastShadows(const bool _castShadows) override; // Documentation inherited public: virtual void SetReceiveShadows(const bool _receiveShadows) @@ -243,7 +243,7 @@ namespace ignition // Documentation inherited public: virtual void SetLightMap(const std::string &_lightMap, - unsigned int uvSet = 0u) override; + unsigned int _uvSet = 0u) override; // Documentation inherited public: virtual void ClearLightMap() override; @@ -269,8 +269,9 @@ namespace ignition // Documentation inherited public: virtual MaterialType Type() const override; - public: virtual void SetShaderType(enum ShaderType /*_type*/) override + public: virtual void SetShaderType(enum ShaderType _type) override { + (void)_type; // no op } @@ -526,9 +527,9 @@ namespace ignition ////////////////////////////////////////////////// template - void BaseMaterial::SetCastShadows(const bool _cast) + void BaseMaterial::SetCastShadows(const bool _castShadows) { - this->castShadows = _cast; + this->castShadows = _castShadows; } ////////////////////////////////////////////////// diff --git a/include/ignition/rendering/base/BaseMesh.hh b/include/ignition/rendering/base/BaseMesh.hh index c27edf703..4f55794db 100644 --- a/include/ignition/rendering/base/BaseMesh.hh +++ b/include/ignition/rendering/base/BaseMesh.hh @@ -50,7 +50,8 @@ namespace ignition // Documentation inherited. public: virtual void SetSkeletonLocalTransforms( - const std::map &) override; + const std::map &_tfs) + override; // Documentation inherited. public: virtual std::unordered_map SkeletonWeights() @@ -58,7 +59,8 @@ namespace ignition // Documentation inherited. public: virtual void SetSkeletonWeights( - const std::unordered_map &) override; + const std::unordered_map &_weights) + override; // Documentation inherited. public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, @@ -88,9 +90,11 @@ namespace ignition // Documentation inherited. public: virtual MaterialPtr Material() const override; + // Documentation inherited. public: virtual void SetMaterial(const std::string &_name, bool _unique = true) override; + // Documentation inherited. public: virtual void SetMaterial(MaterialPtr _material, bool _unique = true) override; diff --git a/include/ignition/rendering/base/BaseParticleEmitter.hh b/include/ignition/rendering/base/BaseParticleEmitter.hh index cebad5d67..c02395d53 100644 --- a/include/ignition/rendering/base/BaseParticleEmitter.hh +++ b/include/ignition/rendering/base/BaseParticleEmitter.hh @@ -110,8 +110,8 @@ namespace ignition public: virtual double MaxVelocity() const override; // Documentation inherited. - public: virtual void SetVelocityRange(double _minVel, - double _maxVel) override; + public: virtual void SetVelocityRange(double _minVelocity, + double _maxVelocity) override; // Documentation inherited. public: virtual ignition::math::Color ColorStart() const override; diff --git a/include/ignition/rendering/base/BaseScene.hh b/include/ignition/rendering/base/BaseScene.hh index 31670265b..71366f868 100644 --- a/include/ignition/rendering/base/BaseScene.hh +++ b/include/ignition/rendering/base/BaseScene.hh @@ -511,8 +511,11 @@ namespace ignition /// \param[in] _id Unique id /// \param[in] _name Name of thermal camera protected: virtual ThermalCameraPtr CreateThermalCameraImpl( - unsigned int /*_id*/, const std::string &/*_name*/) + unsigned int _id, const std::string &_name) { + // The following two lines will avoid doxygen warnings + (void)_id; + (void)_name; ignerr << "Thermal camera not supported by: " << this->Engine()->Name() << std::endl; return ThermalCameraPtr(); @@ -521,9 +524,11 @@ namespace ignition /// \brief Implementation for creating GpuRays sensor. /// \param[in] _id Unique id /// \param[in] _name Name of GpuRays sensor - protected: virtual GpuRaysPtr CreateGpuRaysImpl(unsigned int /*_id*/, - const std::string & /*_name*/) + protected: virtual GpuRaysPtr CreateGpuRaysImpl(unsigned int _id, + const std::string & _name) { + (void)_id; + (void)_name; ignerr << "GpuRays not supported by: " << this->Engine()->Name() << std::endl; return GpuRaysPtr(); @@ -541,9 +546,11 @@ namespace ignition /// \brief Implementation for creating a GizmoVisual. /// \param[in] _id Unique id /// \param[in] _name Name of GizmoVisual - protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int, - const std::string &) + protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id, + const std::string &_name) { + (void)_id; + (void)_name; ignerr << "GizmoVisual not supported by: " << this->Engine()->Name() << std::endl; return GizmoVisualPtr(); @@ -641,8 +648,10 @@ namespace ignition /// \param[in] _name Name of ParticleEmitter. /// \return Pointer to the created particle emitter. protected: virtual ParticleEmitterPtr CreateParticleEmitterImpl( - unsigned int, const std::string &) + unsigned int _id, const std::string &_name) { + (void)_id; + (void)_name; ignerr << "ParticleEmitter not supported by: " << this->Engine()->Name() << std::endl; return ParticleEmitterPtr(); diff --git a/ogre/include/ignition/rendering/ogre/OgreCamera.hh b/ogre/include/ignition/rendering/ogre/OgreCamera.hh index 862ffe957..765cd12d6 100644 --- a/ogre/include/ignition/rendering/ogre/OgreCamera.hh +++ b/ogre/include/ignition/rendering/ogre/OgreCamera.hh @@ -45,30 +45,41 @@ namespace ignition public: virtual ~OgreCamera(); - public: virtual void SetHFOV(const math::Angle &_angle) override; + // Documentation inherited. + public: virtual void SetHFOV(const math::Angle &_hfov) override; + // Documentation inherited. public: virtual double AspectRatio() const override; + // Documentation inherited. public: virtual void SetAspectRatio(const double _ratio) override; + // Documentation inherited. public: virtual unsigned int AntiAliasing() const override; + // Documentation inherited. public: virtual void SetAntiAliasing(const unsigned int _aa) override; + // Documentation inherited. public: virtual void SetFarClipPlane(const double _far) override; + // Documentation inherited. public: virtual void SetNearClipPlane(const double _near) override; public: virtual math::Color BackgroundColor() const; public: virtual void SetBackgroundColor(const math::Color &_color); + // Documentation inherited. public: virtual void Render() override; + // Documentation inherited. public: virtual RenderWindowPtr CreateRenderWindow() override; + // Documentation inherited. public: virtual math::Matrix4d ProjectionMatrix() const override; + // Documentation inherited. public: virtual math::Matrix4d ViewMatrix() const override; public: void SetVFOV(double cameraVFOV) const; diff --git a/ogre/include/ignition/rendering/ogre/OgreConversions.hh b/ogre/include/ignition/rendering/ogre/OgreConversions.hh index bacb29d72..0bb3b632e 100644 --- a/ogre/include/ignition/rendering/ogre/OgreConversions.hh +++ b/ogre/include/ignition/rendering/ogre/OgreConversions.hh @@ -93,7 +93,7 @@ namespace ignition public: static Ogre::Matrix4 Convert(const math::Matrix4d &_m); /// \brief Ign-rendering PixelFormat to Ogre PixelFormat - /// \param[in] _v Ign-rendering PixelFormat + /// \param[in] _format Ign-rendering PixelFormat /// return Ogre PixelFormat public: static Ogre::PixelFormat Convert(PixelFormat _format); diff --git a/ogre/include/ignition/rendering/ogre/OgreMaterial.hh b/ogre/include/ignition/rendering/ogre/OgreMaterial.hh index 2677edafa..ed9e8260c 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMaterial.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMaterial.hh @@ -98,6 +98,7 @@ namespace ignition public: virtual bool CastShadows() const override; + // Documentation inherited. public: virtual void SetCastShadows(const bool _castShadows) override; public: virtual bool ReceiveShadows() const override; @@ -122,7 +123,8 @@ namespace ignition public: virtual std::string Texture() const override; - public: virtual void SetTexture(const std::string &_name) override; + // Documentation inherited. + public: virtual void SetTexture(const std::string &_texture) override; public: virtual void ClearTexture() override; @@ -130,12 +132,14 @@ namespace ignition public: virtual std::string NormalMap() const override; - public: virtual void SetNormalMap(const std::string &_name) override; + // Documentation inherited. + public: virtual void SetNormalMap(const std::string &_normalMap) override; public: virtual void ClearNormalMap() override; public: virtual enum ShaderType ShaderType() const override; + // Documentation inherited. public: virtual void SetShaderType(enum ShaderType _type) override; public: virtual Ogre::MaterialPtr Material() const; diff --git a/ogre/include/ignition/rendering/ogre/OgreMesh.hh b/ogre/include/ignition/rendering/ogre/OgreMesh.hh index 11b2a6245..50d8e0b16 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMesh.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMesh.hh @@ -71,7 +71,7 @@ namespace ignition // Documentation inherited. public: virtual void SetSkeletonWeights( - const std::unordered_map &_weight) override; + const std::unordered_map &_weights) override; // Documentation inherited. public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, diff --git a/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh b/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh index f63a19173..56450b8fc 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRTShaderSystem.hh @@ -45,8 +45,8 @@ namespace ignition class IGNITION_RENDERING_OGRE_VISIBLE OgreRTShaderSystem : public common::SingletonT { - /// \enum LightingModel. - /// \brief The type of lighting. + /// \enum LightingModel + /// \brief The type of lighting public: enum LightingModel { /// \brief Per-Vertex lighting: best performance. @@ -83,11 +83,11 @@ namespace ignition public: void AddScene(OgreScenePtr _scene); /// \brief Remove a scene - /// \param[in] The scene to remove + /// \param[in] _scene The scene to remove public: void RemoveScene(OgreScenePtr _scene); /// \brief Remove a scene - /// \param[in] Name of the scene to remove. + /// \param[in] _scene Name of the scene to remove. public: void RemoveScene(const std::string &_scene); /// \brief Update the shaders. This should not be called frequently. @@ -95,7 +95,7 @@ namespace ignition /// \brief Set an Ogre::Entity to use RT shaders. /// \param[in] _vis OgreSubMesh that will use the OgreRTShaderSystem. - public: void AttachEntity(OgreSubMesh *vis); + public: void AttachEntity(OgreSubMesh *_vis); /// \brief Remove and entity. /// \param[in] _vis Remove this visual. diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh b/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh index 26b94d083..6003fbc3b 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh @@ -69,7 +69,7 @@ namespace ignition public virtual BaseRenderEngine, public common::SingletonT { - /// \enum RenderPathType + /// \enum OgreRenderPathType /// \brief The type of rendering path used by the rendering engine. public: enum OgreRenderPathType { @@ -186,4 +186,3 @@ namespace ignition } } #endif - diff --git a/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh b/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh index ac244a93f..51c76af25 100644 --- a/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh +++ b/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh @@ -47,7 +47,7 @@ namespace ignition class IGNITION_RENDERING_OGRE_VISIBLE OgreSelectionBuffer { /// \brief Constructor - /// \param[in] _camera Name of the camera to generate a selection + /// \param[in] _cameraName Name of the camera to generate a selection /// buffer for. /// \param[in] _mgr Pointer to the scene manager. public: OgreSelectionBuffer(const std::string &_cameraName, diff --git a/ogre/src/OgreMarker.cc b/ogre/src/OgreMarker.cc index c4f953e11..21874d7f1 100644 --- a/ogre/src/OgreMarker.cc +++ b/ogre/src/OgreMarker.cc @@ -91,7 +91,6 @@ Ogre::MovableObject *OgreMarker::OgreObject() const return this->dataPtr->geom->OgreObject(); } return nullptr; - break; } case MT_LINE_STRIP: case MT_LINE_LIST: diff --git a/ogre/src/OgreMeshFactory.cc b/ogre/src/OgreMeshFactory.cc index ff1a11390..c1101e825 100644 --- a/ogre/src/OgreMeshFactory.cc +++ b/ogre/src/OgreMeshFactory.cc @@ -450,6 +450,15 @@ bool OgreMeshFactory::LoadImpl(const MeshDescriptor &_desc) return false; } + if (ogreMesh->getNumSubMeshes() == 0u) + { + std::string msg = "Unable to load mesh: '" + _desc.meshName + "'"; + if (!_desc.subMeshName.empty()) + msg += ", submesh: '" + _desc.subMeshName + "'"; + msg += ". Mesh will be empty."; + ignwarn << msg << std::endl; + } + return true; } diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh index 8ce7a5688..2a2fa305b 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh @@ -49,7 +49,7 @@ namespace ignition public: virtual ~Ogre2Camera(); // Documentation inherited. - public: virtual void SetHFOV(const math::Angle &_angle) override; + public: virtual void SetHFOV(const math::Angle &_hfov) override; // Documentation inherited. public: virtual double AspectRatio() const override; diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh index 4db1120d9..11ae50cd5 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh @@ -105,7 +105,7 @@ namespace ignition public: static Ogre::Matrix4 Convert(const math::Matrix4d &_m); /// \brief Ign-rendering PixelFormat to Ogre PixelFormat - /// \param[in] _v Ign-rendering PixelFormat + /// \param[in] _format Ign-rendering PixelFormat /// return Ogre PixelFormat public: static Ogre::PixelFormat Convert(PixelFormat _format); diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh index d5578bd1e..4371c583a 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh @@ -107,7 +107,7 @@ namespace ignition public: virtual std::string Texture() const override; // Documentation inherited - public: virtual void SetTexture(const std::string &_name) override; + public: virtual void SetTexture(const std::string &_texture) override; // Documentation inherited public: virtual void ClearTexture() override; @@ -119,7 +119,7 @@ namespace ignition public: virtual std::string NormalMap() const override; // Documentation inherited - public: virtual void SetNormalMap(const std::string &_name) override; + public: virtual void SetNormalMap(const std::string &_normalMap) override; // Documentation inherited public: virtual void ClearNormalMap() override; @@ -131,7 +131,8 @@ namespace ignition public: virtual std::string RoughnessMap() const override; // Documentation inherited - public: virtual void SetRoughnessMap(const std::string &_name) override; + public: virtual void SetRoughnessMap( + const std::string &_roughnessMap) override; // Documentation inherited public: virtual void ClearRoughnessMap() override; @@ -143,7 +144,8 @@ namespace ignition public: virtual std::string MetalnessMap() const override; // Documentation inherited - public: virtual void SetMetalnessMap(const std::string &_name) override; + public: virtual void SetMetalnessMap( + const std::string &_metalnessMap) override; // Documentation inherited public: virtual void ClearMetalnessMap() override; @@ -155,7 +157,8 @@ namespace ignition public: virtual std::string EnvironmentMap() const override; // Documentation inherited - public: virtual void SetEnvironmentMap(const std::string &_name) override; + public: virtual void SetEnvironmentMap( + const std::string &_metalnessMap) override; // Documentation inherited public: virtual void ClearEnvironmentMap() override; @@ -170,7 +173,8 @@ namespace ignition public: virtual std::string EmissiveMap() const override; // Documentation inherited - public: virtual void SetEmissiveMap(const std::string &_name) override; + public: virtual void SetEmissiveMap( + const std::string &_emissiveMap) override; // Documentation inherited public: virtual void ClearEmissiveMap() override; @@ -185,7 +189,7 @@ namespace ignition public: virtual unsigned int LightMapTexCoordSet() const override; // Documentation inherited - public: virtual void SetLightMap(const std::string &_name, + public: virtual void SetLightMap(const std::string &_lightMap, unsigned int _uvSet = 0u) override; // Documentation inherited diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh index a6ae4c070..038c9c3b4 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Mesh.hh @@ -72,7 +72,7 @@ namespace ignition // Documentation inherited. public: virtual void SetSkeletonWeights( - const std::unordered_map &_weight) override; + const std::unordered_map &_weights) override; // Documentation inherited. public: virtual void SetSkeletonAnimationEnabled(const std::string &_name, diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh index fb1302a99..5a6be9005 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Node.hh @@ -98,7 +98,7 @@ namespace ignition protected: virtual math::Quaterniond RawLocalRotation() const; /// \brief Set the raw local rotation of the node - /// \param[in] _position Local rotation to set the node to + /// \param[in] _rotation Local rotation to set the node to protected: virtual void SetRawLocalRotation( const math::Quaterniond &_rotation); diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh index 677548f98..ed3a4e720 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh @@ -112,7 +112,7 @@ namespace ignition /// \brief Create a scene /// \param[in] _id Unique scene Id - /// \parampin] _name Name of scene + /// \param[in] _name Name of scene protected: virtual ScenePtr CreateSceneImpl(unsigned int _id, const std::string &_name) override; @@ -205,4 +205,3 @@ namespace ignition } } #endif - diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh index 32672db24..26128898c 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh @@ -127,7 +127,7 @@ namespace ignition /// \brief Returns true if this is a render window /// TODO(anyone): this function should be virtual. /// We didn't do it to preserve ABI. - /// Look in commit history for '#Ogre2IsRenderWindowABI' to + /// Look in commit history for 'Ogre2IsRenderWindowABI' to /// see changes made and revert public: bool IsRenderWindow() const; diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh index 35fd51332..0afec5482 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2SelectionBuffer.hh @@ -47,7 +47,7 @@ namespace ignition class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SelectionBuffer { /// \brief Constructor - /// \param[in] _camera Name of the camera to generate a selection + /// \param[in] _cameraName Name of the camera to generate a selection /// buffer for. /// \param[in] _scene Pointer to the scene public: Ogre2SelectionBuffer(const std::string &_cameraName, @@ -62,10 +62,6 @@ namespace ignition /// \return Returns the Ogre item at the coordinate. public: Ogre::Item *OnSelectionClick(const int _x, const int _y); - /// \brief Debug show overlay - /// \param[in] _show True to show the selection buffer in an overlay. - // public: void ShowOverlay(const bool _show); - /// \brief Call this to update the selection buffer contents public: void Update(); diff --git a/ogre2/src/Ogre2GpuRays.cc b/ogre2/src/Ogre2GpuRays.cc index 6d6aba0e9..157f8c033 100644 --- a/ogre2/src/Ogre2GpuRays.cc +++ b/ogre2/src/Ogre2GpuRays.cc @@ -191,6 +191,9 @@ class ignition::rendering::Ogre2GpuRaysPrivate /// \brief Listener for setting particle noise value based on particle /// emitter region public: std::unique_ptr particleNoiseListener[6]; + + /// \brief Min allowed angle in radians; + public: const math::Angle kMinAllowedAngle = 1e-4; }; using namespace ignition; @@ -474,6 +477,7 @@ void Ogre2GpuRays::ConfigureCamera() { // horizontal gpu rays setup auto hfovAngle = this->AngleMax() - this->AngleMin(); + hfovAngle = std::max(this->dataPtr->kMinAllowedAngle, hfovAngle); this->SetHFOV(hfovAngle); // vertical laser setup @@ -481,7 +485,8 @@ void Ogre2GpuRays::ConfigureCamera() if (this->VerticalRangeCount() > 1) { - vfovAngle = (this->VerticalAngleMax() - this->VerticalAngleMin()).Radian(); + vfovAngle = std::max(this->dataPtr->kMinAllowedAngle.Radian(), + (this->VerticalAngleMax() - this->VerticalAngleMin()).Radian()); } else { @@ -566,11 +571,16 @@ void Ogre2GpuRays::CreateSampleTexture() double max = this->AngleMax().Radian(); double vmin = this->VerticalAngleMin().Radian(); double vmax = this->VerticalAngleMax().Radian(); - double hStep = (max-min) / static_cast(this->dataPtr->w2nd-1); + + double hAngle = std::max(this->dataPtr->kMinAllowedAngle.Radian(), max - min); + double vAngle = std::max(this->dataPtr->kMinAllowedAngle.Radian(), + vmax - vmin); + + double hStep = hAngle / static_cast(this->dataPtr->w2nd-1); double vStep = 1.0; // non-planar case if (this->dataPtr->h2nd > 1) - vStep = (vmax-vmin) / static_cast(this->dataPtr->h2nd-1); + vStep = vAngle / static_cast(this->dataPtr->h2nd-1); // create an RGB texture (cubeUVTex) to pack info that tells the shaders how // to sample from the cubemap textures. diff --git a/ogre2/src/Ogre2Marker.cc b/ogre2/src/Ogre2Marker.cc index faa525191..01a1a5b57 100644 --- a/ogre2/src/Ogre2Marker.cc +++ b/ogre2/src/Ogre2Marker.cc @@ -104,7 +104,6 @@ Ogre::MovableObject *Ogre2Marker::OgreObject() const return this->dataPtr->geom->OgreObject(); } return nullptr; - break; } case MT_LINE_STRIP: case MT_LINE_LIST: @@ -118,7 +117,6 @@ Ogre::MovableObject *Ogre2Marker::OgreObject() const return this->dataPtr->dynamicRenderable->OgreObject(); } return nullptr; - break; } default: ignerr << "Invalid Marker type " << this->markerType << "\n"; diff --git a/ogre2/src/Ogre2MeshFactory.cc b/ogre2/src/Ogre2MeshFactory.cc index 0d21f5eac..0d460c0bc 100644 --- a/ogre2/src/Ogre2MeshFactory.cc +++ b/ogre2/src/Ogre2MeshFactory.cc @@ -497,6 +497,15 @@ bool Ogre2MeshFactory::LoadImpl(const MeshDescriptor &_desc) return false; } + if (ogreMesh->getNumSubMeshes() == 0u) + { + std::string msg = "Unable to load mesh: '" + _desc.meshName + "'"; + if (!_desc.subMeshName.empty()) + msg += ", submesh: '" + _desc.subMeshName + "'"; + msg += ". Mesh will be empty."; + ignwarn << msg << std::endl; + } + return true; } diff --git a/optix/include/ignition/rendering/optix/OptixCamera.hh b/optix/include/ignition/rendering/optix/OptixCamera.hh index a05491a8b..5a02e6c12 100644 --- a/optix/include/ignition/rendering/optix/OptixCamera.hh +++ b/optix/include/ignition/rendering/optix/OptixCamera.hh @@ -35,7 +35,7 @@ namespace ignition public: virtual ~OptixCamera(); - public: virtual void SetHFOV(const math::Angle &_angle); + public: virtual void SetHFOV(const math::Angle &_hfov); public: virtual void SetAspectRatio(const double _ratio); diff --git a/optix/include/ignition/rendering/optix/OptixMaterial.hh b/optix/include/ignition/rendering/optix/OptixMaterial.hh index 55b5f23b6..0c2605a2f 100644 --- a/optix/include/ignition/rendering/optix/OptixMaterial.hh +++ b/optix/include/ignition/rendering/optix/OptixMaterial.hh @@ -83,7 +83,7 @@ namespace ignition public: virtual std::string Texture() const; - public: virtual void SetTexture(const std::string &_name); + public: virtual void SetTexture(const std::string &_texture); public: virtual void ClearTexture(); @@ -91,7 +91,7 @@ namespace ignition public: virtual std::string NormalMap() const; - public: virtual void SetNormalMap(const std::string &_name); + public: virtual void SetNormalMap(const std::string &_normalMap); public: virtual void ClearNormalMap(); diff --git a/src/Utils.cc b/src/Utils.cc index 9896ea17f..0ac5902c5 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -20,6 +20,12 @@ #include #endif +#include "ignition/math/Plane.hh" +#include "ignition/math/Vector2.hh" +#include "ignition/math/Vector3.hh" + +#include "ignition/rendering/Camera.hh" +#include "ignition/rendering/RayQuery.hh" #include "ignition/rendering/Utils.hh" namespace ignition @@ -28,6 +34,71 @@ namespace rendering { inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { // +///////////////////////////////////////////////// +math::Vector3d screenToScene( + const math::Vector2i &_screenPos, + const CameraPtr &_camera, + const RayQueryPtr &_rayQuery, + RayQueryResult &_rayResult, + float _maxDistance) +{ + // Normalize point on the image + double width = _camera->ImageWidth(); + double height = _camera->ImageHeight(); + + double nx = 2.0 * _screenPos.X() / width - 1.0; + double ny = 1.0 - 2.0 * _screenPos.Y() / height; + + // Make a ray query + _rayQuery->SetFromCamera( + _camera, math::Vector2d(nx, ny)); + + _rayResult = _rayQuery->ClosestPoint(); + if (_rayResult) + return _rayResult.point; + + // Set point to be maxDistance m away if no intersection found + return _rayQuery->Origin() + + _rayQuery->Direction() * _maxDistance; +} + +///////////////////////////////////////////////// +math::Vector3d screenToScene( + const math::Vector2i &_screenPos, + const CameraPtr &_camera, + const RayQueryPtr &_rayQuery, + float _maxDistance) +{ + RayQueryResult rayResult; + return screenToScene(_screenPos, _camera, _rayQuery, rayResult, _maxDistance); +} + +///////////////////////////////////////////////// +math::Vector3d screenToPlane( + const math::Vector2i &_screenPos, + const CameraPtr &_camera, + const RayQueryPtr &_rayQuery, + const float offset) +{ + // Normalize point on the image + double width = _camera->ImageWidth(); + double height = _camera->ImageHeight(); + + double nx = 2.0 * _screenPos.X() / width - 1.0; + double ny = 1.0 - 2.0 * _screenPos.Y() / height; + + // Make a ray query + _rayQuery->SetFromCamera( + _camera, math::Vector2d(nx, ny)); + + ignition::math::Planed plane(ignition::math::Vector3d(0, 0, 1), offset); + + math::Vector3d origin = _rayQuery->Origin(); + math::Vector3d direction = _rayQuery->Direction(); + double distance = plane.Distance(origin, direction); + return origin + direction * distance; +} + ///////////////////////////////////////////////// float screenScalingFactor() { diff --git a/src/Utils_TEST.cc b/src/Utils_TEST.cc new file mode 100644 index 000000000..b88785969 --- /dev/null +++ b/src/Utils_TEST.cc @@ -0,0 +1,167 @@ +/* * 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 + +#include + +#include "ignition/rendering/Camera.hh" +#include "ignition/rendering/RayQuery.hh" +#include "ignition/rendering/RenderEngine.hh" +#include "ignition/rendering/RenderingIface.hh" +#include "ignition/rendering/Scene.hh" +#include "ignition/rendering/Utils.hh" +#include "ignition/rendering/Visual.hh" + +#include "test_config.h" // NOLINT(build/include) + +using namespace ignition; +using namespace rendering; + +class UtilTest : public testing::Test, + public testing::WithParamInterface +{ + // Documentation inherited + public: void SetUp() override + { + ignition::common::Console::SetVerbosity(4); + } + + public: void ClickToScene(const std::string &_renderEngine); +}; + +void UtilTest::ClickToScene(const std::string &_renderEngine) +{ + RenderEngine *engine = rendering::engine(_renderEngine); + if (!engine) + { + igndbg << "Engine '" << _renderEngine + << "' is not supported" << std::endl; + return; + } + ScenePtr scene = engine->CreateScene("scene"); + + CameraPtr camera(scene->CreateCamera()); + EXPECT_TRUE(camera != nullptr); + + camera->SetLocalPosition(0.0, 0.0, 15); + camera->SetLocalRotation(0.0, IGN_PI / 2, 0.0); + + unsigned int width = 640u; + unsigned int height = 480u; + camera->SetImageWidth(width); + camera->SetImageHeight(height); + + const int halfWidth = static_cast(width / 2); + const int halfHeight = static_cast(height / 2); + const ignition::math::Vector2i centerClick(halfWidth, halfHeight); + + RayQueryPtr rayQuery = scene->CreateRayQuery(); + EXPECT_TRUE(rayQuery != nullptr); + + // screenToPlane + math::Vector3d result = screenToPlane(centerClick, camera, rayQuery); + + EXPECT_NEAR(0.0, result.Z(), 1e-10); + EXPECT_NEAR(0.0, result.X(), 2e-6); + EXPECT_NEAR(0.0, result.Y(), 2e-6); + + // call with non-zero plane offset + result = screenToPlane(centerClick, camera, rayQuery, 5.0); + + EXPECT_NEAR(5.0, result.Z(), 1e-10); + EXPECT_NEAR(0.0, result.X(), 2e-6); + EXPECT_NEAR(0.0, result.Y(), 2e-6); + + // screenToScene + // API without RayQueryResult and default max distance + result = screenToScene(centerClick, camera, rayQuery); + + // No objects currently in the scene, so return a point max distance in + // front of camera + // The default max distance is 10 meters away + EXPECT_NEAR(5.0 - camera->NearClipPlane(), result.Z(), 4e-6); + EXPECT_NEAR(0.0, result.X(), 2e-6); + EXPECT_NEAR(0.0, result.Y(), 2e-6); + + // Try with different max distance + RayQueryResult rayResult; + result = screenToScene(centerClick, camera, rayQuery, rayResult, 20.0); + + EXPECT_NEAR(-5.0 - camera->NearClipPlane(), result.Z(), 4e-6); + EXPECT_NEAR(0.0, result.X(), 4e-6); + EXPECT_NEAR(0.0, result.Y(), 4e-6); + EXPECT_FALSE(rayResult); + EXPECT_EQ(0u, rayResult.objectId); + + VisualPtr root = scene->RootVisual(); + + // create box visual to collide with the ray + VisualPtr box = scene->CreateVisual(); + box->AddGeometry(scene->CreateBox()); + box->SetOrigin(0.0, 0.0, 0.0); + box->SetLocalPosition(0.0, 0.0, 0.0); + box->SetLocalRotation(0.0, 0.0, 0.0); + box->SetLocalScale(1.0, 1.0, 1.0); + root->AddChild(box); + + // API without RayQueryResult and default max distance + result = screenToScene(centerClick, camera, rayQuery, rayResult); + + EXPECT_NEAR(0.5, result.Z(), 1e-10); + 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_EQ(box->Id(), rayResult.objectId); + + result = screenToScene(centerClick, camera, rayQuery, rayResult, 20.0); + + EXPECT_NEAR(0.5, result.Z(), 1e-10); + 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_EQ(box->Id(), rayResult.objectId); + + // Move camera closer to box + camera->SetLocalPosition(0.0, 0.0, 7.0); + camera->SetLocalRotation(0.0, IGN_PI / 2, 0.0); + + result = screenToScene(centerClick, camera, rayQuery, rayResult); + + EXPECT_NEAR(0.5, result.Z(), 1e-10); + 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_EQ(box->Id(), rayResult.objectId); +} + +///////////////////////////////////////////////// +TEST_P(UtilTest, ClickToScene) +{ + ClickToScene(GetParam()); +} + +INSTANTIATE_TEST_CASE_P(ClickToScene, UtilTest, + RENDER_ENGINE_VALUES, + ignition::rendering::PrintToStringParam()); + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/integration/gpu_rays.cc b/test/integration/gpu_rays.cc index f0774b941..d1510a3a4 100644 --- a/test/integration/gpu_rays.cc +++ b/test/integration/gpu_rays.cc @@ -64,6 +64,9 @@ class GpuRaysTest: public testing::Test, // Test detection of particles public: void RaysParticles(const std::string &_renderEngine); + + // Test single ray box intersection + public: void SingleRay(const std::string &_renderEngine); }; ///////////////////////////////////////////////// @@ -163,7 +166,7 @@ void GpuRaysTest::Configure(const std::string &_renderEngine) void GpuRaysTest::RaysUnitBox(const std::string &_renderEngine) { #ifdef __APPLE__ - std::cerr << "Skipping test for apple, see issue #35." << std::endl; + ignerr << "Skipping test for apple, see issue #35." << std::endl; return; #endif @@ -348,7 +351,7 @@ void GpuRaysTest::RaysUnitBox(const std::string &_renderEngine) void GpuRaysTest::LaserVertical(const std::string &_renderEngine) { #ifdef __APPLE__ - std::cerr << "Skipping test for apple, see issue #35." << std::endl; + ignerr << "Skipping test for apple, see issue #35." << std::endl; return; #endif @@ -481,7 +484,7 @@ void GpuRaysTest::LaserVertical(const std::string &_renderEngine) void GpuRaysTest::RaysParticles(const std::string &_renderEngine) { #ifdef __APPLE__ - std::cerr << "Skipping test for apple, see issue #35." << std::endl; + ignerr << "Skipping test for apple, see issue #35." << std::endl; return; #endif @@ -690,6 +693,104 @@ void GpuRaysTest::RaysParticles(const std::string &_renderEngine) engine->DestroyScene(scene); rendering::unloadEngine(engine->Name()); } + +///////////////////////////////////////////////// +/// \brief Test single ray box intersection +void GpuRaysTest::SingleRay(const std::string &_renderEngine) +{ +#ifdef __APPLE__ + ignerr << "Skipping test for apple, see issue #35." << std::endl; + return; +#endif + + if (_renderEngine == "optix") + { + igndbg << "GpuRays not supported yet in rendering engine: " + << _renderEngine << std::endl; + return; + } + + // Test GPU single ray box intersection. + // Place GPU above box looking downwards + // ray should intersect with center of box + + const double hMinAngle = 0.0; + const double hMaxAngle = 0.0; + const double minRange = 0.05; + const double maxRange = 40.0; + const int hRayCount = 1; + const int vRayCount = 1; + + // create and populate scene + RenderEngine *engine = rendering::engine(_renderEngine); + if (!engine) + { + igndbg << "Engine '" << _renderEngine + << "' is not supported" << std::endl; + return; + } + + ScenePtr scene = engine->CreateScene("scene"); + ASSERT_TRUE(scene != nullptr); + + VisualPtr root = scene->RootVisual(); + + // Create first ray caster + ignition::math::Pose3d testPose(ignition::math::Vector3d(0, 0, 7), + ignition::math::Quaterniond(0, IGN_PI/2.0, 0)); + + GpuRaysPtr gpuRays = scene->CreateGpuRays("gpu_rays"); + gpuRays->SetWorldPosition(testPose.Pos()); + gpuRays->SetWorldRotation(testPose.Rot()); + gpuRays->SetNearClipPlane(minRange); + gpuRays->SetFarClipPlane(maxRange); + gpuRays->SetAngleMin(hMinAngle); + gpuRays->SetAngleMax(hMaxAngle); + gpuRays->SetRayCount(hRayCount); + + gpuRays->SetVerticalRayCount(vRayCount); + root->AddChild(gpuRays); + + // box in the center + ignition::math::Pose3d box01Pose(ignition::math::Vector3d(0, 0, 4.5), + ignition::math::Quaterniond::Identity); + VisualPtr visualBox1 = scene->CreateVisual("UnitBox1"); + visualBox1->AddGeometry(scene->CreateBox()); + visualBox1->SetWorldPosition(box01Pose.Pos()); + visualBox1->SetWorldRotation(box01Pose.Rot()); + root->AddChild(visualBox1); + + // Verify rays caster range readings + // listen to new gpu rays frames + unsigned int channels = gpuRays->Channels(); + float *scan = new float[hRayCount * vRayCount * channels]; + common::ConnectionPtr c = + gpuRays->ConnectNewGpuRaysFrame( + std::bind(&::OnNewGpuRaysFrame, scan, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, + std::placeholders::_4, std::placeholders::_5)); + + gpuRays->Update(); + + int mid = 0; + double unitBoxSize = 1.0; + double expectedRangeAtMidPointBox = testPose.Pos().Z() - + (abs(box01Pose.Pos().Z()) + unitBoxSize/2); + + // rays caster 1 should see box01 and box02 + EXPECT_NEAR(scan[mid], expectedRangeAtMidPointBox, LASER_TOL); + + c.reset(); + + delete [] scan; + + scan = nullptr; + + // Clean up + engine->DestroyScene(scene); + rendering::unloadEngine(engine->Name()); +} + ///////////////////////////////////////////////// TEST_P(GpuRaysTest, Configure) { @@ -714,6 +815,13 @@ TEST_P(GpuRaysTest, RaysParticles) RaysParticles(GetParam()); } +///////////////////////////////////////////////// +TEST_P(GpuRaysTest, SingleRay) +{ + SingleRay(GetParam()); +} + + INSTANTIATE_TEST_CASE_P(GpuRays, GpuRaysTest, RENDER_ENGINE_VALUES, ignition::rendering::PrintToStringParam());