diff --git a/Changelog.md b/Changelog.md index 5fa537e91..530c4f1ec 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,7 +9,18 @@ ### Ignition Rendering 4.X -### Ignition Rendering 4.X.X (20XX-XX-XX) +### Ignition Rendering 4.2.0 (2021-01-22) + +1. Remove some windows warnings. + * [Pull request #183](https://github.com/ignitionrobotics/ign-rendering/pull/183) + +1. Fix transparency issue for textures without alpha channel. + * [Pull request #186](https://github.com/ignitionrobotics/ign-rendering/pull/186) + +1. Call XCloseDisplay in screenScalingFactor. + * [Pull request #204](https://github.com/ignitionrobotics/ign-rendering/pull/204) + +1. All changes up to version 3.3.0. ### Ignition Rendering 4.1.0 (2020-11-04) @@ -106,6 +117,23 @@ 1. Add support for transparency based on textures alpha channel for ogre1 and ogre2 * [BitBucket pull request 229](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-rendering/pull-requests/229) +### Ignition Rendering 3.3.0 (2021-01-22) + +1. Add Windows installation. + * [Pull request 196](https://github.com/ignitionrobotics/ign-rendering/pull/196) + +1. Make flaky VisualAt test more verbose. + * [Pull request 174](https://github.com/ignitionrobotics/ign-rendering/pull/174) + +1. Resolve updated codecheck issues. + * [Pull request 173](https://github.com/ignitionrobotics/ign-rendering/pull/173) + +1. Fix crash due to NaN pose values. + * [Pull request 169](https://github.com/ignitionrobotics/ign-rendering/pull/169) + +1. Improve fork experience. + * [Pull request 165](https://github.com/ignitionrobotics/ign-rendering/pull/165) + ### Ignition Rendering 3.2.0 (2020-10-13) 1. Add Custom Render Engine support diff --git a/README.md b/README.md index e9474ec47..3fb9983ab 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,6 @@ of libraries designed to rapidly develop robot applications. [Usage](#usage) -[Documentation](#documentation) - -[Testing](#testing) - [Folder Structure](#folder-structure) [Code of Conduct](#code-of-conduct) @@ -57,37 +53,11 @@ See the [installation tutorial](https://ignitionrobotics.org/api/rendering/4.0/i # Usage The Ign Rendering API can be found in the documentation. See the -[Documentation](#documentation) section on how to build the -documentation files using Doxygen. +[installation tutorial](https://ignitionrobotics.org/api/rendering/4.0/installation.html) +on how to build the documentation files using Doxygen. You can also take a look at the sample applications in the `examples` folder. -# Documentation - -API documentation can be generated using Doxygen - - sudo apt install -y doxygen - -Build documentation - - cd build - make doc - -View documentation - - firefox doxygen/html/index.html - -# Testing - -Tests can be run by building the `test` target: - - cd build - make test - -To run tests specific to a render engine, set the `RENDER_ENGINE_VALUES` environment variable, e.g. - - RENDER_ENGINE_VALUES=ogre2 make test - # Folder Structure * `include/ignition/rendering`: Contains all the public header files which will be installed diff --git a/examples/actor_animation/GlutWindow.cc b/examples/actor_animation/GlutWindow.cc index deba44082..6f8d49ce4 100644 --- a/examples/actor_animation/GlutWindow.cc +++ b/examples/actor_animation/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/camera_tracking/GlutWindow.cc b/examples/camera_tracking/GlutWindow.cc index 1dff2f557..3ed256c0c 100644 --- a/examples/camera_tracking/GlutWindow.cc +++ b/examples/camera_tracking/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/custom_scene_viewer/DemoWindow.cc b/examples/custom_scene_viewer/DemoWindow.cc index c01f04902..9cb9c645b 100644 --- a/examples/custom_scene_viewer/DemoWindow.cc +++ b/examples/custom_scene_viewer/DemoWindow.cc @@ -18,13 +18,13 @@ #if defined(__APPLE__) #include #include -#elif not defined(_WIN32) +#elif !defined(_WIN32) #include #include #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/gazebo_scene_viewer/CameraWindow.cc b/examples/gazebo_scene_viewer/CameraWindow.cc index cead02428..0a662990b 100644 --- a/examples/gazebo_scene_viewer/CameraWindow.cc +++ b/examples/gazebo_scene_viewer/CameraWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/mesh_viewer/GlutWindow.cc b/examples/mesh_viewer/GlutWindow.cc index 5e3da1986..d6eccb28d 100644 --- a/examples/mesh_viewer/GlutWindow.cc +++ b/examples/mesh_viewer/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/mouse_picking/GlutWindow.cc b/examples/mouse_picking/GlutWindow.cc index 052ba286d..1cb83339e 100644 --- a/examples/mouse_picking/GlutWindow.cc +++ b/examples/mouse_picking/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/ogre2_demo/GlutWindow.cc b/examples/ogre2_demo/GlutWindow.cc index 9c314dedc..44aab4f68 100644 --- a/examples/ogre2_demo/GlutWindow.cc +++ b/examples/ogre2_demo/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/render_pass/GlutWindow.cc b/examples/render_pass/GlutWindow.cc index 86a9ba81b..9887c8c92 100644 --- a/examples/render_pass/GlutWindow.cc +++ b/examples/render_pass/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/simple_demo/GlutWindow.cc b/examples/simple_demo/GlutWindow.cc index 93caf3816..4d0c9a27d 100644 --- a/examples/simple_demo/GlutWindow.cc +++ b/examples/simple_demo/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/text_geom/GlutWindow.cc b/examples/text_geom/GlutWindow.cc index f61d6aeb7..9dc6648ef 100644 --- a/examples/text_geom/GlutWindow.cc +++ b/examples/text_geom/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/thermal_camera/GlutWindow.cc b/examples/thermal_camera/GlutWindow.cc index b1983caab..cee056897 100644 --- a/examples/thermal_camera/GlutWindow.cc +++ b/examples/thermal_camera/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/transform_control/GlutWindow.cc b/examples/transform_control/GlutWindow.cc index 19621ca0c..3331cf226 100644 --- a/examples/transform_control/GlutWindow.cc +++ b/examples/transform_control/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/examples/view_control/GlutWindow.cc b/examples/view_control/GlutWindow.cc index d29e32760..c074783f6 100644 --- a/examples/view_control/GlutWindow.cc +++ b/examples/view_control/GlutWindow.cc @@ -25,7 +25,7 @@ #include #endif -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) #include #endif diff --git a/include/ignition/rendering/MeshDescriptor.hh b/include/ignition/rendering/MeshDescriptor.hh index ca71faf51..3ec101d56 100644 --- a/include/ignition/rendering/MeshDescriptor.hh +++ b/include/ignition/rendering/MeshDescriptor.hh @@ -63,7 +63,6 @@ namespace ignition IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief common::Mesh object public: const common::Mesh *mesh = nullptr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief Name of the registered Mesh diff --git a/include/ignition/rendering/RayQuery.hh b/include/ignition/rendering/RayQuery.hh index cafa06d41..b3130e46d 100644 --- a/include/ignition/rendering/RayQuery.hh +++ b/include/ignition/rendering/RayQuery.hh @@ -17,6 +17,7 @@ #ifndef IGNITION_RENDERING_RAYQUERY_HH_ #define IGNITION_RENDERING_RAYQUERY_HH_ +#include #include #include "ignition/rendering/config.hh" @@ -37,7 +38,9 @@ namespace ignition public: double distance = -1; /// \brief Intersection point in 3d space + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING public: math::Vector3d point; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING /// \brief Intersected object id public: unsigned int objectId = 0; diff --git a/include/ignition/rendering/RenderEnginePlugin.hh b/include/ignition/rendering/RenderEnginePlugin.hh index 441d907c4..c64c9558f 100644 --- a/include/ignition/rendering/RenderEnginePlugin.hh +++ b/include/ignition/rendering/RenderEnginePlugin.hh @@ -21,6 +21,8 @@ #include #include +#include + #include "ignition/rendering/config.hh" #include "ignition/rendering/Export.hh" @@ -52,7 +54,9 @@ namespace ignition public: virtual RenderEngine *Engine() const = 0; /// \brief Pointer to private data class + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING public: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/include/ignition/rendering/RenderPassSystem.hh b/include/ignition/rendering/RenderPassSystem.hh index 088de96cf..3bcb5466c 100644 --- a/include/ignition/rendering/RenderPassSystem.hh +++ b/include/ignition/rendering/RenderPassSystem.hh @@ -22,6 +22,8 @@ #include #include +#include + #include "ignition/rendering/config.hh" #include "ignition/rendering/Export.hh" #include "ignition/rendering/RenderPass.hh" @@ -78,11 +80,13 @@ namespace ignition private: RenderPassPtr CreateImpl(const std::string &_type); /// \brief A map of render pass type id name to its factory class + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING private: static std::map renderPassMap; /// \internal /// \brief Pointer to private data class private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING }; /// \brief Render pass registration macro diff --git a/include/ignition/rendering/ShaderParam.hh b/include/ignition/rendering/ShaderParam.hh index be3a7899e..eb9abb0c2 100644 --- a/include/ignition/rendering/ShaderParam.hh +++ b/include/ignition/rendering/ShaderParam.hh @@ -21,6 +21,8 @@ #include #include +#include + #include "ignition/rendering/config.hh" #include "ignition/rendering/Export.hh" @@ -86,7 +88,9 @@ namespace ignition public: bool Value(int *_value) const; /// \brief private implementation + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/include/ignition/rendering/TransformController.hh b/include/ignition/rendering/TransformController.hh index 77626fe5a..3e537fa87 100644 --- a/include/ignition/rendering/TransformController.hh +++ b/include/ignition/rendering/TransformController.hh @@ -19,6 +19,8 @@ #include +#include + #include #include #include @@ -210,7 +212,9 @@ namespace ignition const math::Planed &_plane, math::Vector3d &_result); /// \brief Private data pointer + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING public: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/include/ignition/rendering/base/BaseCamera.hh b/include/ignition/rendering/base/BaseCamera.hh index 4d21ff2b7..9f28c43db 100644 --- a/include/ignition/rendering/base/BaseCamera.hh +++ b/include/ignition/rendering/base/BaseCamera.hh @@ -24,6 +24,7 @@ #include #include +#include #include "ignition/rendering/Camera.hh" #include "ignition/rendering/Image.hh" @@ -185,6 +186,7 @@ namespace ignition protected: virtual RenderTargetPtr RenderTarget() const = 0; + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING protected: common::EventT newFrameEvent; @@ -221,6 +223,7 @@ namespace ignition /// \brief Target node to follow protected: NodePtr followNode; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING /// \brief Follow target in world frame. protected: bool followWorldFrame = false; diff --git a/include/ignition/rendering/base/BaseDepthCamera.hh b/include/ignition/rendering/base/BaseDepthCamera.hh index a68728310..1372ac69e 100644 --- a/include/ignition/rendering/base/BaseDepthCamera.hh +++ b/include/ignition/rendering/base/BaseDepthCamera.hh @@ -30,7 +30,7 @@ namespace ignition { inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { template - class IGNITION_RENDERING_VISIBLE BaseDepthCamera : + class BaseDepthCamera : public virtual DepthCamera, public virtual BaseCamera, public virtual T diff --git a/include/ignition/rendering/base/BaseGizmoVisual.hh b/include/ignition/rendering/base/BaseGizmoVisual.hh index a5e095e12..a00ffc982 100644 --- a/include/ignition/rendering/base/BaseGizmoVisual.hh +++ b/include/ignition/rendering/base/BaseGizmoVisual.hh @@ -21,6 +21,7 @@ #include #include #include +#include #include "ignition/rendering/base/BaseScene.hh" #include "ignition/rendering/base/BaseNode.hh" @@ -92,6 +93,7 @@ namespace ignition /// \brief Current gizmo mode protected: TransformMode mode = TransformMode::TM_NONE; + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief A map of gizmo axis and their visuals protected: std::map visuals; @@ -109,6 +111,7 @@ namespace ignition /// \brief A map of axis enums to materials protected: std::map materials; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING /// \brief Material used by axes protected: enum AxisMaterial @@ -531,15 +534,21 @@ namespace ignition common::MeshManager *meshMgr = common::MeshManager::Instance(); std::string rotMeshName = "gizmo_rotate"; if (!meshMgr->HasMesh(rotMeshName)) - meshMgr->CreateTube(rotMeshName, 1.0, 1.02, 0.02, 1, 64, IGN_PI); + meshMgr->CreateTube(rotMeshName, 1.0f, 1.02f, 0.02f, 1, 64, IGN_PI); std::string rotFullMeshName = "gizmo_rotate_full"; if (!meshMgr->HasMesh(rotFullMeshName)) - meshMgr->CreateTube(rotFullMeshName, 1.0, 1.02, 0.02, 1, 64, 2*IGN_PI); + { + meshMgr->CreateTube(rotFullMeshName, 1.0f, 1.02f, 0.02f, 1, 64, + 2 * IGN_PI); + } std::string rotHandleMeshName = "gizmo_rotate_handle"; if (!meshMgr->HasMesh(rotHandleMeshName)) - meshMgr->CreateTube(rotHandleMeshName, 0.95, 1.07, 0.1, 1, 64, IGN_PI); + { + meshMgr->CreateTube(rotHandleMeshName, 0.95f, 1.07f, 0.1f, 1, 64, + IGN_PI); + } VisualPtr rotVis = this->Scene()->CreateVisual(); diff --git a/include/ignition/rendering/base/BaseLidarVisual.hh b/include/ignition/rendering/base/BaseLidarVisual.hh index 39a427795..c2cf9a1df 100644 --- a/include/ignition/rendering/base/BaseLidarVisual.hh +++ b/include/ignition/rendering/base/BaseLidarVisual.hh @@ -462,7 +462,7 @@ namespace ignition mtl->SetCastShadows(false); mtl->SetReceiveShadows(false); mtl->SetLightingEnabled(false); - mtl->SetMetalness(0.0); + mtl->SetMetalness(0.0f); mtl->SetReflectivity(0.0); } @@ -476,7 +476,7 @@ namespace ignition mtl->SetCastShadows(false); mtl->SetReceiveShadows(false); mtl->SetLightingEnabled(false); - mtl->SetMetalness(0.0); + mtl->SetMetalness(0.0f); mtl->SetReflectivity(0.0); } @@ -490,7 +490,7 @@ namespace ignition mtl->SetCastShadows(false); mtl->SetReceiveShadows(false); mtl->SetLightingEnabled(false); - mtl->SetMetalness(0.5); + mtl->SetMetalness(0.5f); mtl->SetReflectivity(0.2); } @@ -505,7 +505,7 @@ namespace ignition mtl->SetCastShadows(false); mtl->SetReceiveShadows(false); mtl->SetLightingEnabled(false); - mtl->SetMetalness(0.1); + mtl->SetMetalness(0.1f); mtl->SetReflectivity(0.2); } return; diff --git a/include/ignition/rendering/base/BaseMarker.hh b/include/ignition/rendering/base/BaseMarker.hh index 183b5c6ba..7f5f83d2a 100644 --- a/include/ignition/rendering/base/BaseMarker.hh +++ b/include/ignition/rendering/base/BaseMarker.hh @@ -17,6 +17,8 @@ #ifndef IGNITION_RENDERING_BASEMARKER_HH_ #define IGNITION_RENDERING_BASEMARKER_HH_ +#include + #include "ignition/rendering/Marker.hh" #include "ignition/rendering/base/BaseObject.hh" #include "ignition/rendering/base/BaseRenderTypes.hh" @@ -81,8 +83,10 @@ namespace ignition const ignition::math::Vector3d &_value) override; /// \brief Life time of a marker + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING protected: std::chrono::steady_clock::duration lifetime = std::chrono::steady_clock::duration::zero(); + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING /// \brief Layer at which the marker will reside protected: int32_t layer = 0; diff --git a/include/ignition/rendering/base/BaseObject.hh b/include/ignition/rendering/base/BaseObject.hh index 57d22fc6e..73f670ddf 100644 --- a/include/ignition/rendering/base/BaseObject.hh +++ b/include/ignition/rendering/base/BaseObject.hh @@ -19,6 +19,7 @@ #include #include +#include #include "ignition/rendering/Object.hh" namespace ignition @@ -28,7 +29,9 @@ namespace ignition inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { // class IGNITION_RENDERING_VISIBLE BaseObject : + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING public virtual std::enable_shared_from_this, + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING public virtual Object { protected: BaseObject(); @@ -56,7 +59,9 @@ namespace ignition protected: unsigned int id; + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING protected: std::string name; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/include/ignition/rendering/base/BaseRenderEngine.hh b/include/ignition/rendering/base/BaseRenderEngine.hh index cac190a25..c41fb03a5 100644 --- a/include/ignition/rendering/base/BaseRenderEngine.hh +++ b/include/ignition/rendering/base/BaseRenderEngine.hh @@ -20,6 +20,7 @@ #include #include #include +#include #include "ignition/rendering/RenderEngine.hh" #include "ignition/rendering/Storage.hh" @@ -112,12 +113,14 @@ namespace ignition protected: unsigned int nextSceneId; + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief a list of paths that render engines use to locate their /// resources protected: std::vector resourcePaths; /// \brief Render pass system for this render engine. protected: RenderPassSystemPtr renderPassSystem; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/include/ignition/rendering/base/BaseScene.hh b/include/ignition/rendering/base/BaseScene.hh index d77e8671f..cd4d7e5c2 100644 --- a/include/ignition/rendering/base/BaseScene.hh +++ b/include/ignition/rendering/base/BaseScene.hh @@ -22,6 +22,7 @@ #include #include +#include #include "ignition/rendering/RenderEngine.hh" #include "ignition/rendering/Scene.hh" @@ -34,7 +35,9 @@ namespace ignition inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { // class IGNITION_RENDERING_VISIBLE BaseScene : + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING public std::enable_shared_from_this, + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING public virtual Scene { protected: BaseScene(unsigned int _id, const std::string &_name); @@ -628,7 +631,9 @@ namespace ignition protected: unsigned int id; + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING protected: std::string name; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING protected: common::Time IGN_DEPRECATED(4) simTime; @@ -659,7 +664,9 @@ namespace ignition private: unsigned int nextObjectId; + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING private: NodeStorePtr nodes; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/include/ignition/rendering/base/BaseThermalCamera.hh b/include/ignition/rendering/base/BaseThermalCamera.hh index fbfc957de..a061a371b 100644 --- a/include/ignition/rendering/base/BaseThermalCamera.hh +++ b/include/ignition/rendering/base/BaseThermalCamera.hh @@ -83,10 +83,10 @@ namespace ignition unsigned int, const std::string &)> _subscriber) override; /// \brief Ambient temperature of the environment - protected: float ambient = 0.0; + protected: float ambient = 0.0f; /// \brief Ambient temperature range - protected: float ambientRange = 0.0; + protected: float ambientRange = 0.0f; /// \brief Minimum temperature protected: float minTemp = -ignition::math::INF_F; @@ -95,10 +95,10 @@ namespace ignition protected: float maxTemp = ignition::math::INF_F; /// \brief Linear resolution. Defaults to 10mK. - protected: float resolution = 0.01; + protected: float resolution = 0.01f; /// \brief Range of heat source temperature variation - protected: float heatSourceTempRange = 0.0; + protected: float heatSourceTempRange = 0.0f; }; ////////////////////////////////////////////////// diff --git a/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh b/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh index 753535bc4..93c5ddee3 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGaussianNoisePass.hh @@ -19,6 +19,8 @@ #include +#include + #include "ignition/rendering/base/BaseGaussianNoisePass.hh" #include "ignition/rendering/ogre/OgreIncludes.hh" #include "ignition/rendering/ogre/OgreRenderPass.hh" @@ -59,8 +61,10 @@ namespace ignition public: Ogre::CompositorInstance *gaussianNoiseInstance = nullptr; /// \brief Gaussian noise compositor listener + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING public: std::shared_ptr gaussianNoiseCompositorListener; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/ogre/include/ignition/rendering/ogre/OgreGeometry.hh b/ogre/include/ignition/rendering/ogre/OgreGeometry.hh index 8afb92749..2700d3c97 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGeometry.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGeometry.hh @@ -17,6 +17,8 @@ #ifndef IGNITION_RENDERING_OGRE_OGREGEOMETRY_HH_ #define IGNITION_RENDERING_OGRE_OGREGEOMETRY_HH_ +#include + #include "ignition/rendering/base/BaseGeometry.hh" #include "ignition/rendering/ogre/OgreObject.hh" @@ -46,7 +48,9 @@ namespace ignition protected: virtual void SetParent(OgreVisualPtr _parent); + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING protected: OgreVisualPtr parent; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING private: friend class OgreVisual; }; diff --git a/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh b/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh index 5413c357e..fa39bee88 100644 --- a/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh +++ b/ogre/include/ignition/rendering/ogre/OgreGpuRays.hh @@ -23,6 +23,8 @@ #include #include +#include + #include "ignition/rendering/RenderTypes.hh" #include "ignition/rendering/base/BaseGpuRays.hh" #include "ignition/rendering/ogre/OgreConversions.hh" @@ -183,7 +185,9 @@ namespace ignition /// \internal /// \brief Pointer to private data. + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING private: std::unique_ptr dataPtr; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING private: friend class OgreScene; }; diff --git a/ogre/include/ignition/rendering/ogre/OgreIncludes.hh b/ogre/include/ignition/rendering/ogre/OgreIncludes.hh index 89fadd73e..d858b8204 100644 --- a/ogre/include/ignition/rendering/ogre/OgreIncludes.hh +++ b/ogre/include/ignition/rendering/ogre/OgreIncludes.hh @@ -18,7 +18,11 @@ #define IGNITION_RENDERING_OGRE_OGREINCLUDES_HH_ // This disables warning messages for OGRE -#pragma GCC system_header +#ifndef _MSC_VER + #pragma GCC system_header +#else + #pragma warning(push, 0) +#endif // This prevents some deprecation #warning messages on OSX 10.9 #pragma clang diagnostic ignored "-W#warnings" @@ -80,4 +84,8 @@ #include #endif +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #endif diff --git a/ogre/include/ignition/rendering/ogre/OgreMaterial.hh b/ogre/include/ignition/rendering/ogre/OgreMaterial.hh index 77c41a2e3..2677edafa 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMaterial.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMaterial.hh @@ -19,6 +19,8 @@ #include +#include + #include "ignition/rendering/base/BaseMaterial.hh" #include "ignition/rendering/ogre/OgreObject.hh" #include "ignition/rendering/ogre/OgreIncludes.hh" @@ -199,6 +201,7 @@ namespace ignition protected: virtual void Init() override; + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING protected: Ogre::MaterialPtr ogreMaterial; protected: Ogre::Technique *ogreTechnique = nullptr; @@ -229,6 +232,7 @@ namespace ignition /// \brief Parameters to be bound to the fragment shader protected: ShaderParamsPtr fragmentShaderParams; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING private: friend class OgreScene; }; diff --git a/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh b/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh index b1e86835f..cf799f4fd 100644 --- a/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh +++ b/ogre/include/ignition/rendering/ogre/OgreMaterialSwitcher.hh @@ -21,6 +21,7 @@ #include #include +#include #include #include "ignition/rendering/config.hh" #include "ignition/rendering/ogre/Export.hh" @@ -38,7 +39,17 @@ namespace ignition /// \brief Helper class to assign unique colors to renderables class IGNITION_RENDERING_OGRE_VISIBLE OgreMaterialSwitcher : - public Ogre::MaterialManager::Listener, Ogre::RenderTargetListener +// Ogre::MaterialManager::Listener isn't a dll-interface class, this may cause +// issues +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4275) +#endif + public Ogre::MaterialManager::Listener, +#ifdef _MSC_VER + #pragma warning(pop) +#endif + Ogre::RenderTargetListener { /// \brief Constructor public: OgreMaterialSwitcher(); @@ -92,7 +103,9 @@ namespace ignition /// \brief Color dictionary that maps the unique color value to /// renderable name + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING private: std::map colorDict; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING /// \brief Increment unique color value that will be assigned to the /// next renderable diff --git a/ogre/include/ignition/rendering/ogre/OgreNode.hh b/ogre/include/ignition/rendering/ogre/OgreNode.hh index 363ed561a..a68e5a12f 100644 --- a/ogre/include/ignition/rendering/ogre/OgreNode.hh +++ b/ogre/include/ignition/rendering/ogre/OgreNode.hh @@ -17,6 +17,8 @@ #ifndef IGNITION_RENDERING_OGRE_OGRENODE_HH_ #define IGNITION_RENDERING_OGRE_OGRENODE_HH_ +#include + #include "ignition/rendering/base/BaseNode.hh" #include "ignition/rendering/ogre/OgreRenderTypes.hh" #include "ignition/rendering/ogre/OgreObject.hh" @@ -87,7 +89,9 @@ namespace ignition protected: virtual void Init() override; + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING protected: OgreNodePtr parent; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING protected: Ogre::SceneNode *ogreNode = nullptr; diff --git a/ogre/include/ignition/rendering/ogre/OgreObject.hh b/ogre/include/ignition/rendering/ogre/OgreObject.hh index 0c84bf991..e8d691516 100644 --- a/ogre/include/ignition/rendering/ogre/OgreObject.hh +++ b/ogre/include/ignition/rendering/ogre/OgreObject.hh @@ -17,6 +17,8 @@ #ifndef IGNITION_RENDERING_OGRE_OGREOBJECT_HH_ #define IGNITION_RENDERING_OGRE_OGREOBJECT_HH_ +#include + #include "ignition/rendering/base/BaseObject.hh" #include "ignition/rendering/ogre/OgreRenderTypes.hh" #include "ignition/rendering/ogre/Export.hh" @@ -36,7 +38,9 @@ namespace ignition public: virtual ScenePtr Scene() const; + IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING protected: OgreScenePtr scene; + IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING private: friend class OgreScene; }; diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh b/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh index 5f13f32f2..26b94d083 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh @@ -167,7 +167,7 @@ namespace ignition /// \brief Paths to ogre plugins private: std::vector ogrePaths; -#if not (__APPLE__ || _WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) private: void *dummyDisplay = nullptr; private: void *dummyContext = nullptr; diff --git a/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh b/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh index 9dcb48646..cee3a3add 100644 --- a/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh +++ b/ogre/include/ignition/rendering/ogre/OgreRenderTargetMaterial.hh @@ -24,6 +24,13 @@ #include "ignition/rendering/ogre/OgreRenderTypes.hh" #include "ignition/rendering/ogre/Export.hh" +// Ogre::MaterialManager::Listener isn't a dll-interface class, this may cause +// issues +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4275) +#endif + namespace ignition { namespace rendering @@ -99,4 +106,8 @@ namespace ignition } } +#ifdef _MSC_VER + #pragma warning(pop) +#endif + #endif diff --git a/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh b/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh index 17edbdc07..ac244a93f 100644 --- a/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh +++ b/ogre/include/ignition/rendering/ogre/OgreSelectionBuffer.hh @@ -37,7 +37,7 @@ namespace ignition inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { // // forward declaration - struct OgreSelectionBufferPrivate; + class OgreSelectionBufferPrivate; /// \brief Generates a selection buffer object for a given camera. /// The selection buffer is used of entity selection. On setup, a unique diff --git a/ogre/src/CMakeLists.txt b/ogre/src/CMakeLists.txt index 9ef018b6b..92a403a6c 100644 --- a/ogre/src/CMakeLists.txt +++ b/ogre/src/CMakeLists.txt @@ -2,6 +2,15 @@ # "gtest_sources" variable. ign_get_libsources_and_unittests(sources gtest_sources) +if (MSVC) + # Warning #4251 is the "dll-interface" warning that tells you when types used + # by a class are not being exported. These generated source files have private + # members that don't get exported, so they trigger this warning. However, the + # warning is not important since those members do not need to be interfaced + # with. + set_source_files_properties(${sources} ${gtest_sources} COMPILE_FLAGS "/wd4251") +endif() + set(engine_name "ogre") ign_add_component(${engine_name} SOURCES ${sources} GET_TARGET_NAME ogre_target) @@ -28,10 +37,10 @@ set_property( target_link_libraries(${ogre_target} PUBLIC ${ignition-common${IGN_COMMON_VER}_LIBRARIES} + IgnOGRE::IgnOGRE PRIVATE ignition-plugin${IGN_PLUGIN_VER}::register ${OPENGL_LIBRARIES} - IgnOGRE::IgnOGRE ) # Build the unit tests @@ -54,7 +63,7 @@ if (WIN32) # disable MSVC inherit via dominance warning set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250") INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy - ${IGNITION_RENDERING_ENGINE_INSTALL_DIR}\/${versioned} + ${IGNITION_RENDERING_ENGINE_INSTALL_DIR}\/${versioned} ${IGNITION_RENDERING_ENGINE_INSTALL_DIR}\/${unversioned})") else() EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${versioned} ${unversioned}) diff --git a/ogre/src/OgreDepthCamera.cc b/ogre/src/OgreDepthCamera.cc index e1e1d3213..a3363be7c 100644 --- a/ogre/src/OgreDepthCamera.cc +++ b/ogre/src/OgreDepthCamera.cc @@ -17,7 +17,9 @@ #if (_WIN32) /* Needed for std::min */ - #define NOMINMAX + #ifndef NOMINMAX + #define NOMINMAX + #endif #include #endif #include @@ -313,7 +315,7 @@ void OgreDepthCamera::UpdateRenderTarget(OgreRenderTexturePtr _target, // Which normally equates to infinite distance. We don't want this. So // we have to set the distance every time. this->ogreCamera->setFarClipDistance(this->FarClipPlane()); - this->ogreCamera->setNearClipDistance(1e-4); + this->ogreCamera->setNearClipDistance(1e-4f); Ogre::AutoParamDataSource autoParamDataSource; @@ -383,10 +385,10 @@ void OgreDepthCamera::PostRender() // color data unsigned int colorChannelCount = 3; - int bgColorR = this->scene->BackgroundColor().R() * 255; - int bgColorG = this->scene->BackgroundColor().G() * 255; - int bgColorB = this->scene->BackgroundColor().B() * 255; - int bgColorA = this->scene->BackgroundColor().A() * 255; + int bgColorR = static_cast(this->scene->BackgroundColor().R() * 255); + int bgColorG = static_cast(this->scene->BackgroundColor().G() * 255); + int bgColorB = static_cast(this->scene->BackgroundColor().B() * 255); + int bgColorA = static_cast(this->scene->BackgroundColor().A() * 255); if (this->dataPtr->outputPoints) { PixelFormat colorFormat = this->dataPtr->colorTexture->Format(); diff --git a/ogre/src/OgreGpuRays.cc b/ogre/src/OgreGpuRays.cc index a4997e58a..2dba203b6 100644 --- a/ogre/src/OgreGpuRays.cc +++ b/ogre/src/OgreGpuRays.cc @@ -344,13 +344,13 @@ void OgreGpuRays::ConfigureCameras() if ((horzRangeCountPerCamera / this->rangeCountRatio) > vertRangeCountPerCamera) { - vertRangeCountPerCamera = - std::round(horzRangeCountPerCamera / this->rangeCountRatio); + vertRangeCountPerCamera = static_cast( + std::round(horzRangeCountPerCamera / this->rangeCountRatio)); } else { - horzRangeCountPerCamera = - round(vertRangeCountPerCamera * this->rangeCountRatio); + horzRangeCountPerCamera = static_cast(std::round( + vertRangeCountPerCamera * this->rangeCountRatio)); } } else @@ -468,7 +468,7 @@ void OgreGpuRays::CreateGpuRaysTextures() Ogre::Matrix4 p = this->BuildScaledOrthoMatrix( 0, static_cast(this->dataPtr->w2nd / 10.0), 0, static_cast(this->dataPtr->h2nd / 10.0), - 0.01, 0.02); + 0.01f, 0.02f); this->dataPtr->orthoCam->setCustomProjectionMatrix(true, p); @@ -724,9 +724,9 @@ void OgreGpuRays::CreateOrthoCam() if (this->dataPtr->orthoCam) { - this->dataPtr->orthoCam->setNearClipDistance(0.01); - this->dataPtr->orthoCam->setFarClipDistance(0.02); - this->dataPtr->orthoCam->setRenderingDistance(0.02); + this->dataPtr->orthoCam->setNearClipDistance(0.01f); + this->dataPtr->orthoCam->setFarClipDistance(0.02f); + this->dataPtr->orthoCam->setRenderingDistance(0.02f); this->dataPtr->orthoCam->setProjectionType(Ogre::PT_ORTHOGRAPHIC); } @@ -837,7 +837,8 @@ void OgreGpuRays::CreateMesh() double delta = hstep * i; // index of texture that contains the depth value - unsigned int texture = delta / this->CosHorzFOV(); + unsigned int texture = static_cast( + delta / this->CosHorzFOV()); // cap texture index and horizontal angle if (texture > this->dataPtr->textureCount-1) diff --git a/ogre/src/OgreMaterialSwitcher.cc b/ogre/src/OgreMaterialSwitcher.cc index 2a560d8f3..dc1b024c3 100644 --- a/ogre/src/OgreMaterialSwitcher.cc +++ b/ogre/src/OgreMaterialSwitcher.cc @@ -28,7 +28,7 @@ using namespace rendering; OgreMaterialSwitcher::OgreMaterialSwitcher() : lastTechnique(nullptr) { - this->currentColor = ignition::math::Color(0.0, 0.0, 0.1); + this->currentColor = ignition::math::Color(0.0f, 0.0f, 0.1f); } ///////////////////////////////////////////////// diff --git a/ogre/src/OgreMeshFactory.cc b/ogre/src/OgreMeshFactory.cc index 66b927570..55b31f669 100644 --- a/ogre/src/OgreMeshFactory.cc +++ b/ogre/src/OgreMeshFactory.cc @@ -18,7 +18,6 @@ #include - #include #include #include diff --git a/ogre/src/OgreRenderEngine.cc b/ogre/src/OgreRenderEngine.cc index 0d894e8f7..1b42b87fb 100644 --- a/ogre/src/OgreRenderEngine.cc +++ b/ogre/src/OgreRenderEngine.cc @@ -16,7 +16,7 @@ */ // Not Apple or Windows -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) # include # include # include @@ -46,7 +46,7 @@ class ignition::rendering::OgreRenderEnginePrivate { -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) public: XVisualInfo *dummyVisual = nullptr; #endif @@ -123,7 +123,7 @@ void OgreRenderEngine::Destroy() delete this->ogreLogManager; this->ogreLogManager = nullptr; -#if not (__APPLE__ || _WIN32) +#if (!defined(__APPLE__) && !defined(_WIN32)) if (this->dummyDisplay) { Display *x11Display = static_cast(this->dummyDisplay); @@ -341,7 +341,7 @@ void OgreRenderEngine::CreateLogger() ////////////////////////////////////////////////// void OgreRenderEngine::CreateContext() { -#if not (__APPLE__ || _WIN32) +#if (!defined(__APPLE__) && !defined(_WIN32)) // create X11 display this->dummyDisplay = XOpenDisplay(0); Display *x11Display = static_cast(this->dummyDisplay); @@ -613,7 +613,12 @@ void OgreRenderEngine::CreateResources() void OgreRenderEngine::CreateRenderWindow() { // create dummy window - this->CreateRenderWindow(std::to_string(this->dummyWindowId), 1, 1, 1, 0); + auto res = this->CreateRenderWindow(std::to_string(this->dummyWindowId), 1, 1, + 1, 0); + if (res.empty()) + { + ignerr << "Failed to create dummy render window." << std::endl; + } } ////////////////////////////////////////////////// @@ -667,20 +672,22 @@ std::string OgreRenderEngine::CreateRenderWindow(const std::string &_handle, window = this->ogreRoot->createRenderWindow( stream.str(), _width, _height, false, ¶ms); } - catch(...) + catch(Ogre::Exception &_e) { - ignerr << " Unable to create the rendering window\n"; + ignerr << "Unable to create the rendering window. Attempt [" << attempts + << "]. Exception [" << _e.what() << "]" << std::endl; window = nullptr; } } if (attempts >= 10) { - ignerr << "Unable to create the rendering window\n" << std::endl; + ignerr << "Unable to create the rendering window after [" << attempts + << "] attempts." << std::endl; return std::string(); } - if (window) + if (nullptr != window) { window->setActive(true); window->setVisible(true); @@ -695,11 +702,23 @@ std::string OgreRenderEngine::CreateRenderWindow(const std::string &_handle, ////////////////////////////////////////////////// void OgreRenderEngine::CheckCapabilities() { + if (nullptr == this->ogreRoot ||nullptr == this->ogreRoot->getRenderSystem()) + { + ignerr << "No ogreRoot or render system" << std::endl; + return; + } + const Ogre::RenderSystemCapabilities *capabilities; Ogre::RenderSystemCapabilities::ShaderProfiles profiles; Ogre::RenderSystemCapabilities::ShaderProfiles::const_iterator iter; capabilities = this->ogreRoot->getRenderSystem()->getCapabilities(); + if (nullptr == capabilities) + { + ignerr << "Failed to get capabilities" << std::endl; + return; + } + profiles = capabilities->getSupportedShaderProfiles(); bool hasFragmentPrograms = @@ -721,17 +740,23 @@ void OgreRenderEngine::CheckCapabilities() std::find(profiles.begin(), profiles.end(), "glsl") != profiles.end(); if (!hasFragmentPrograms || !hasVertexPrograms) + { ignwarn << "Vertex and fragment shaders are missing. " << "Fixed function rendering will be used.\n"; + } if (!hasGLSL) + { ignwarn << "GLSL is missing." << "Fixed function rendering will be used.\n"; + } // cppcheck-suppress knownConditionTrueFalse if (!hasFBO) + { ignwarn << "Frame Buffer Objects (FBO) is missing. " << "Rendering will be disabled.\n"; + } this->renderPathType = OgreRenderEngine::NONE; diff --git a/ogre/src/OgreRenderTarget.cc b/ogre/src/OgreRenderTarget.cc index 081410a63..217c28a03 100644 --- a/ogre/src/OgreRenderTarget.cc +++ b/ogre/src/OgreRenderTarget.cc @@ -18,12 +18,16 @@ #ifndef _WIN32 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wunused-parameter" +#else +# pragma warning(push, 0) #endif // leave this out of OgreIncludes as it conflicts with other files requiring // gl.h #include #ifndef _WIN32 # pragma GCC diagnostic pop +#else +# pragma warning(pop) #endif @@ -64,6 +68,9 @@ OgreRenderTarget::~OgreRenderTarget() ////////////////////////////////////////////////// void OgreRenderTarget::Copy(Image &_image) const { + if (nullptr == this->RenderTarget()) + return; + // TODO(anyone): handle Bayer conversions // TODO(anyone): handle ogre version differences @@ -206,7 +213,7 @@ void OgreRenderTarget::SetMaterial(MaterialPtr _material) ////////////////////////////////////////////////// void OgreRenderTarget::RebuildMaterial() { - if (this->material) + if (this->material && this->RenderTarget()) { OgreMaterial *ogreMaterial = dynamic_cast( this->material.get()); @@ -238,6 +245,13 @@ void OgreRenderTarget::UpdateRenderPassChain() Ogre::Viewport *OgreRenderTarget::Viewport(const int _viewportId) const { Ogre::RenderTarget *ogreRenderTarget = this->RenderTarget(); + + if (nullptr == ogreRenderTarget) + { + ignerr << "Failed to get viewport: null render target" << std::endl; + return nullptr; + } + return ogreRenderTarget->getViewport(_viewportId); } @@ -245,6 +259,13 @@ Ogre::Viewport *OgreRenderTarget::Viewport(const int _viewportId) const Ogre::Viewport *OgreRenderTarget::AddViewport(Ogre::Camera *_camera) { Ogre::RenderTarget *ogreRenderTarget = this->RenderTarget(); + + if (nullptr == ogreRenderTarget) + { + ignerr << "Failed to add viewport: null render target" << std::endl; + return nullptr; + } + return ogreRenderTarget->addViewport(_camera); } @@ -252,6 +273,13 @@ Ogre::Viewport *OgreRenderTarget::AddViewport(Ogre::Camera *_camera) void OgreRenderTarget::SetAutoUpdated(const bool _value) { Ogre::RenderTarget *ogreRenderTarget = this->RenderTarget(); + + if (nullptr == ogreRenderTarget) + { + ignerr << "Failed to set auto update: null render target" << std::endl; + return; + } + ogreRenderTarget->setAutoUpdated(_value); } @@ -259,6 +287,13 @@ void OgreRenderTarget::SetAutoUpdated(const bool _value) void OgreRenderTarget::SetUpdate(const bool _value) { Ogre::RenderTarget *ogreRenderTarget = this->RenderTarget(); + + if (nullptr == ogreRenderTarget) + { + ignerr << "Failed to set update: null render target" << std::endl; + return; + } + ogreRenderTarget->update(_value); } @@ -378,6 +413,13 @@ void OgreRenderTexture::PostRender() void OgreRenderTexture::Buffer(float *_buffer) { Ogre::RenderTarget *ogreRenderTarget = this->RenderTarget(); + + if (nullptr == ogreRenderTarget) + { + ignerr << "Failed to set buffer: null render target" << std::endl; + return; + } + ogreRenderTarget->swapBuffers(); Ogre::HardwarePixelBufferSharedPtr pcdPixelBuffer; @@ -428,6 +470,13 @@ void OgreRenderWindow::RebuildTarget() Ogre::RenderWindow *window = dynamic_cast(this->ogreRenderWindow); + + if (nullptr == window) + { + ignerr << "Failed to cast render window." << std::endl; + return; + } + window->resize(this->width, this->height); window->windowMovedOrResized(); } @@ -442,6 +491,13 @@ void OgreRenderWindow::BuildTarget() this->height, this->ratio, this->antiAliasing); + + if (renderTargetName.empty()) + { + ignerr << "Failed to build target." << std::endl; + return; + } + this->ogreRenderWindow = engine->OgreRoot()->getRenderTarget(renderTargetName); } diff --git a/ogre/src/OgreSelectionBuffer.cc b/ogre/src/OgreSelectionBuffer.cc index 07ba26c66..0bfc8c0f2 100644 --- a/ogre/src/OgreSelectionBuffer.cc +++ b/ogre/src/OgreSelectionBuffer.cc @@ -201,8 +201,8 @@ Ogre::Entity *OgreSelectionBuffer::OnSelectionClick(const int _x, const int _y) // 1x1 selection buffer, adapted from rviz // http://docs.ros.org/indigo/api/rviz/html/c++/selection__manager_8cpp.html - unsigned int width = 1; - unsigned int height = 1; + float width = 1.0f; + float height = 1.0f; float x1 = static_cast(_x) / static_cast(targetWidth - 1) - 0.5f; float y1 = static_cast(_y) / diff --git a/ogre/src/OgreText.cc b/ogre/src/OgreText.cc index 4154055be..7b0d4a238 100644 --- a/ogre/src/OgreText.cc +++ b/ogre/src/OgreText.cc @@ -380,7 +380,7 @@ void OgreMovableText::SetFontNameImpl(const std::string &_newFontName) #if OGRE_VERSION_LT_1_10_1 this->ogreMaterial.setNull(); #else - this->ogreMaterial == nullptr; + this->ogreMaterial = nullptr; #endif } diff --git a/ogre/src/OgreThermalCamera.cc b/ogre/src/OgreThermalCamera.cc index 34c3db608..cf8b7a7ac 100644 --- a/ogre/src/OgreThermalCamera.cc +++ b/ogre/src/OgreThermalCamera.cc @@ -17,7 +17,9 @@ #if (_WIN32) /* Needed for std::min */ - #define NOMINMAX + #ifndef NOMINMAX + #define NOMINMAX + #endif #include #endif @@ -228,13 +230,13 @@ Ogre::Technique *OgreThermalCameraMaterialSwitcher::handleSchemeNotFound( { try { - temp = std::get(tempAny); + temp = static_cast(std::get(tempAny)); } catch(...) { try { - temp = std::get(tempAny); + temp = static_cast(std::get(tempAny)); } catch(std::bad_variant_access &e) { @@ -410,7 +412,7 @@ void OgreThermalCamera::CreateThermalTexture() // without being clipped. double nearPlane = this->NearClipPlane(); double farPlane = this->FarClipPlane(); - this->ogreCamera->setNearClipDistance(1e-4); + this->ogreCamera->setNearClipDistance(1e-4f); this->ogreCamera->setFarClipDistance(farPlane); // create thermal material diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh index 9b5e54eb3..d25bf7fda 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh @@ -18,7 +18,11 @@ #define IGNITION_RENDERING_OGRE2_OGRE2INCLUDES_HH_ // This disables warning messages for OGRE -#pragma GCC system_header +#ifndef _MSC_VER + #pragma GCC system_header +#else + #pragma warning(push, 0) +#endif // This prevents some deprecation #warning messages on OSX 10.9 #pragma clang diagnostic ignored "-W#warnings" @@ -99,4 +103,8 @@ // #include // #include +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #endif diff --git a/ogre2/src/CMakeLists.txt b/ogre2/src/CMakeLists.txt index 420a071df..44b8b5a52 100644 --- a/ogre2/src/CMakeLists.txt +++ b/ogre2/src/CMakeLists.txt @@ -2,6 +2,15 @@ # "gtest_sources" variable. ign_get_libsources_and_unittests(sources gtest_sources) +if (MSVC) + # Warning #4251 is the "dll-interface" warning that tells you when types used + # by a class are not being exported. These generated source files have private + # members that don't get exported, so they trigger this warning. However, the + # warning is not important since those members do not need to be interfaced + # with. + set_source_files_properties(${sources} ${gtest_sources} COMPILE_FLAGS "/wd4251") +endif() + set(engine_name "ogre2") ign_add_component(${engine_name} SOURCES ${sources} GET_TARGET_NAME ogre2_target) @@ -34,7 +43,7 @@ if (WIN32) # disable MSVC inherit via dominance warning set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250") INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy - ${IGNITION_RENDERING_ENGINE_INSTALL_DIR}\/${versioned} + ${IGNITION_RENDERING_ENGINE_INSTALL_DIR}\/${versioned} ${IGNITION_RENDERING_ENGINE_INSTALL_DIR}\/${unversioned})") else() EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${versioned} ${unversioned}) diff --git a/ogre2/src/Ogre2DepthCamera.cc b/ogre2/src/Ogre2DepthCamera.cc index 6075ba573..3b019225f 100644 --- a/ogre2/src/Ogre2DepthCamera.cc +++ b/ogre2/src/Ogre2DepthCamera.cc @@ -17,7 +17,9 @@ #if (_WIN32) /* Needed for std::min */ - #define NOMINMAX + #ifndef NOMINMAX + #define NOMINMAX + #endif #include #endif diff --git a/ogre2/src/Ogre2DynamicRenderable.cc b/ogre2/src/Ogre2DynamicRenderable.cc index 40e28001b..f6590e13d 100644 --- a/ogre2/src/Ogre2DynamicRenderable.cc +++ b/ogre2/src/Ogre2DynamicRenderable.cc @@ -17,7 +17,13 @@ // Note this include is placed in the src file because // otherwise ogre produces compile errors +#ifdef _MSC_VER +#pragma warning(push, 0) +#endif #include +#ifdef _MSC_VER +#pragma warning(pop) +#endif #include "ignition/common/Console.hh" #include "ignition/rendering/ogre2/Ogre2Conversions.hh" diff --git a/ogre2/src/Ogre2Material.cc b/ogre2/src/Ogre2Material.cc index deb0a2f28..e0bd1eac7 100644 --- a/ogre2/src/Ogre2Material.cc +++ b/ogre2/src/Ogre2Material.cc @@ -17,8 +17,14 @@ // Note this include is placed in the src file because // otherwise ogre produces compile errors +#ifdef _MSC_VER +#pragma warning(push, 0) +#endif #include #include +#ifdef _MSC_VER +#pragma warning(pop) +#endif #include #include diff --git a/ogre2/src/Ogre2Mesh.cc b/ogre2/src/Ogre2Mesh.cc index 2377c5ee7..eaf7e8e7b 100644 --- a/ogre2/src/Ogre2Mesh.cc +++ b/ogre2/src/Ogre2Mesh.cc @@ -17,7 +17,13 @@ // Note this include is placed in the src file because // otherwise ogre produces compile errors +#ifdef _MSC_VER +#pragma warning(push, 0) +#endif #include +#ifdef _MSC_VER +#pragma warning(pop) +#endif #include diff --git a/ogre2/src/Ogre2ParticleEmitter.cc b/ogre2/src/Ogre2ParticleEmitter.cc index 36f28691c..7e0e36f08 100644 --- a/ogre2/src/Ogre2ParticleEmitter.cc +++ b/ogre2/src/Ogre2ParticleEmitter.cc @@ -17,8 +17,14 @@ // Note this include is placed in the src file because // otherwise ogre produces compile errors +#ifdef _MSC_VER +#pragma warning(push, 0) +#endif #include #include +#ifdef _MSC_VER +#pragma warning(pop) +#endif #include "ignition/rendering/ogre2/Ogre2Conversions.hh" #include "ignition/rendering/ogre2/Ogre2Includes.hh" diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index 49bcb72df..392770a58 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -16,7 +16,7 @@ */ // Not Apple or Windows -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) # include # include # include @@ -43,7 +43,7 @@ class ignition::rendering::Ogre2RenderEnginePrivate { -#if not defined(__APPLE__) && not defined(_WIN32) +#if !defined(__APPLE__) && !defined(_WIN32) public: XVisualInfo *dummyVisual = nullptr; #endif diff --git a/ogre2/src/Ogre2RenderTarget.cc b/ogre2/src/Ogre2RenderTarget.cc index 74ec0acf7..91c1247bb 100644 --- a/ogre2/src/Ogre2RenderTarget.cc +++ b/ogre2/src/Ogre2RenderTarget.cc @@ -17,7 +17,13 @@ // leave this out of OgreIncludes as it conflicts with other files requiring // gl.h +#ifdef _MSC_VER +#pragma warning(push, 0) +#endif #include +#ifdef _MSC_VER +#pragma warning(pop) +#endif #include diff --git a/ogre2/src/Ogre2ThermalCamera.cc b/ogre2/src/Ogre2ThermalCamera.cc index 012e0f235..d31299bcb 100644 --- a/ogre2/src/Ogre2ThermalCamera.cc +++ b/ogre2/src/Ogre2ThermalCamera.cc @@ -17,7 +17,9 @@ #if (_WIN32) /* Needed for std::min */ - #define NOMINMAX + #ifndef NOMINMAX + #define NOMINMAX + #endif #include #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6d79f6f6..be1ea5d97 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,15 @@ set_property( # "gtest_sources" variable. ign_get_libsources_and_unittests(sources gtest_sources) +if (MSVC) + # Warning #4251 is the "dll-interface" warning that tells you when types used + # by a class are not being exported. These generated source files have private + # members that don't get exported, so they trigger this warning. However, the + # warning is not important since those members do not need to be interfaced + # with. + set_source_files_properties(${sources} ${gtest_sources} COMPILE_FLAGS "/wd4251") +endif() + add_subdirectory(base) # Create the library target. diff --git a/src/Camera_TEST.cc b/src/Camera_TEST.cc index 60250a1c9..73c07d77c 100644 --- a/src/Camera_TEST.cc +++ b/src/Camera_TEST.cc @@ -76,7 +76,7 @@ void CameraTest::ViewProjectionMatrix(const std::string &_renderEngine) EXPECT_GT(camera->AspectRatio(), 0); camera->SetAspectRatio(1.7777); - EXPECT_FLOAT_EQ(1.7777, camera->AspectRatio()); + EXPECT_NEAR(1.7777, camera->AspectRatio(), 1e-6); camera->SetAntiAliasing(1u); EXPECT_EQ(1u, camera->AntiAliasing()); diff --git a/src/Grid_TEST.cc b/src/Grid_TEST.cc index 7da4cfd35..12448f4ba 100644 --- a/src/Grid_TEST.cc +++ b/src/Grid_TEST.cc @@ -1,4 +1,5 @@ -/* * Copyright (C) 2017 Open Source Robotics Foundation +/* + * Copyright (C) 2017 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. @@ -78,9 +79,9 @@ void GridTest::Grid(const std::string &_renderEngine) grid->SetMaterial(mat); MaterialPtr gridMat = grid->Material(); ASSERT_NE(nullptr, gridMat); - EXPECT_EQ(math::Color(0.6, 0.7, 0.8), gridMat->Ambient()); - EXPECT_EQ(math::Color(0.3, 0.8, 0.2), gridMat->Diffuse()); - EXPECT_EQ(math::Color(0.4, 0.9, 1.0), gridMat->Specular()); + EXPECT_EQ(math::Color(0.6f, 0.7f, 0.8f), gridMat->Ambient()); + EXPECT_EQ(math::Color(0.3f, 0.8f, 0.2f), gridMat->Diffuse()); + EXPECT_EQ(math::Color(0.4f, 0.9f, 1.0f), gridMat->Specular()); // Clean up engine->DestroyScene(scene); diff --git a/src/Light_TEST.cc b/src/Light_TEST.cc index bd0f01521..ea8c289ee 100644 --- a/src/Light_TEST.cc +++ b/src/Light_TEST.cc @@ -75,12 +75,13 @@ void LightTest::Light(const std::string &_renderEngine) EXPECT_FALSE(light->CastShadows()); // attenuation + // Checking near because Ogre stores it as float light->SetAttenuationConstant(0.6); - EXPECT_FLOAT_EQ(0.6, light->AttenuationConstant()); + EXPECT_NEAR(0.6, light->AttenuationConstant(), 1e-6); light->SetAttenuationLinear(0.2); - EXPECT_FLOAT_EQ(0.2, light->AttenuationLinear()); + EXPECT_NEAR(0.2, light->AttenuationLinear(), 1e-6); light->SetAttenuationQuadratic(0.01); - EXPECT_FLOAT_EQ(0.01, light->AttenuationQuadratic()); + EXPECT_NEAR(0.01, light->AttenuationQuadratic(), 1e-6); light->SetAttenuationRange(10); EXPECT_DOUBLE_EQ(10, light->AttenuationRange()); @@ -122,7 +123,7 @@ void LightTest::Light(const std::string &_renderEngine) spotLight->SetOuterAngle(math::Angle(0.2)); EXPECT_EQ(math::Angle(0.2), spotLight->OuterAngle()); spotLight->SetFalloff(0.2); - EXPECT_FLOAT_EQ(0.2, spotLight->Falloff()); + EXPECT_NEAR(0.2, spotLight->Falloff(), 1e-6); // remove lights scene->DestroyLightById(light->Id()); diff --git a/src/Material_TEST.cc b/src/Material_TEST.cc index 204aacd7a..67a7d4b81 100644 --- a/src/Material_TEST.cc +++ b/src/Material_TEST.cc @@ -74,38 +74,38 @@ void MaterialTest::MaterialProperties(const std::string &_renderEngine) EXPECT_TRUE(scene->MaterialRegistered("unique")); // ambient - math::Color ambient(0.5, 0.2, 0.4, 1.0); + math::Color ambient(0.5f, 0.2f, 0.4f, 1.0f); material->SetAmbient(ambient); EXPECT_EQ(ambient, material->Ambient()); - ambient.Set(0.55, 0.22, 0.44, 1.0); + ambient.Set(0.55f, 0.22f, 0.44f, 1.0f); material->SetAmbient(ambient.R(), ambient.G(), ambient.B(), ambient.A()); EXPECT_EQ(ambient, material->Ambient()); // diffuse - math::Color diffuse(0.1, 0.9, 0.3, 1.0); + math::Color diffuse(0.1f, 0.9f, 0.3f, 1.0f); material->SetDiffuse(diffuse); EXPECT_EQ(diffuse, material->Diffuse()); - diffuse.Set(0.11, 0.99, 0.33, 1.0); + diffuse.Set(0.11f, 0.99f, 0.33f, 1.0f); material->SetDiffuse(diffuse.R(), diffuse.G(), diffuse.B(), diffuse.A()); EXPECT_EQ(diffuse, material->Diffuse()); // specular - math::Color specular(0.8, 0.7, 0.0, 1.0); + math::Color specular(0.8f, 0.7f, 0.0f, 1.0f); material->SetSpecular(specular); EXPECT_EQ(specular, material->Specular()); - specular.Set(0.88, 0.77, 0.66, 1.0); + specular.Set(0.88f, 0.77f, 0.66f, 1.0f); material->SetSpecular(specular.R(), specular.G(), specular.B(), specular.A()); EXPECT_EQ(specular, material->Specular()); // emissive - math::Color emissive(0.6, 0.4, 0.2, 1.0); + math::Color emissive(0.6f, 0.4f, 0.2f, 1.0f); material->SetEmissive(emissive); EXPECT_EQ(emissive, material->Emissive()); - emissive.Set(0.66, 0.44, 0.22, 1.0); + emissive.Set(0.66f, 0.44f, 0.22f, 1.0f); material->SetEmissive(emissive.R(), emissive.G(), emissive.B(), emissive.A()); EXPECT_EQ(emissive, material->Emissive()); @@ -267,12 +267,12 @@ void MaterialTest::MaterialProperties(const std::string &_renderEngine) EXPECT_TRUE(material->HasLightMap()); // roughness - float roughness = 0.3; + float roughness = 0.3f; material->SetRoughness(roughness); EXPECT_FLOAT_EQ(roughness, material->Roughness()); // metalness - float metalness = 0.9; + float metalness = 0.9f; material->SetMetalness(metalness); EXPECT_FLOAT_EQ(metalness, material->Metalness()); } @@ -303,10 +303,10 @@ void MaterialTest::Copy(const std::string &_renderEngine) MaterialPtr material = scene->CreateMaterial(); ASSERT_TRUE(material != nullptr); - math::Color ambient(0.5, 0.2, 0.4, 1.0); - math::Color diffuse(0.1, 0.9, 0.3, 1.0); - math::Color specular(0.8, 0.7, 0.0, 1.0); - math::Color emissive(0.6, 0.4, 0.2, 1.0); + math::Color ambient(0.5f, 0.2f, 0.4f, 1.0f); + math::Color diffuse(0.1f, 0.9f, 0.3f, 1.0f); + math::Color specular(0.8f, 0.7f, 0.0f, 1.0f); + math::Color emissive(0.6f, 0.4f, 0.2f, 1.0f); double shininess = 0.8; double transparency = 0.3; bool alphaFromTexture = true; @@ -319,8 +319,8 @@ void MaterialTest::Copy(const std::string &_renderEngine) bool lightingEnabled = false; bool depthCheckEnabled = false; bool depthWriteEnabled = false; - float roughness = 0.5; - float metalness = 0.1; + float roughness = 0.5f; + float metalness = 0.1f; std::string textureName = common::joinPaths(TEST_MEDIA_PATH, "texture.png"); diff --git a/src/OrbitViewController.cc b/src/OrbitViewController.cc index 338e5ec2d..33c44a8fb 100644 --- a/src/OrbitViewController.cc +++ b/src/OrbitViewController.cc @@ -41,8 +41,8 @@ class ignition::rendering::OrbitViewControllerPrivate using namespace ignition; using namespace rendering; -static const float PITCH_LIMIT_LOW = -IGN_PI*0.5 + 0.001; -static const float PITCH_LIMIT_HIGH = IGN_PI*0.5 - 0.001; +static const float PITCH_LIMIT_LOW = -static_cast(IGN_PI)*0.5f + 0.001f; +static const float PITCH_LIMIT_HIGH = static_cast(IGN_PI)*0.5f - 0.001f; ////////////////////////////////////////////////// OrbitViewController::OrbitViewController() diff --git a/src/Text_TEST.cc b/src/Text_TEST.cc index 0f916fdfc..f09ed59bf 100644 --- a/src/Text_TEST.cc +++ b/src/Text_TEST.cc @@ -74,14 +74,14 @@ void TextTest::Text(const std::string &_renderEngine) text->SetTextString("abc def"); EXPECT_EQ("abc def", text->TextString()); - text->SetCharHeight(1.8); - EXPECT_FLOAT_EQ(1.8, text->CharHeight()); + text->SetCharHeight(1.8f); + EXPECT_FLOAT_EQ(1.8f, text->CharHeight()); - text->SetSpaceWidth(1.5); - EXPECT_FLOAT_EQ(1.5, text->SpaceWidth()); + text->SetSpaceWidth(1.5f); + EXPECT_FLOAT_EQ(1.5f, text->SpaceWidth()); - text->SetBaseline(0.5); - EXPECT_FLOAT_EQ(0.5, text->Baseline()); + text->SetBaseline(0.5f); + EXPECT_FLOAT_EQ(0.5f, text->Baseline()); text->SetTextAlignment(TextHorizontalAlign::CENTER, TextVerticalAlign::TOP); EXPECT_EQ(TextHorizontalAlign::CENTER, text->HorizontalAlignment()); @@ -90,24 +90,24 @@ void TextTest::Text(const std::string &_renderEngine) text->SetShowOnTop(true); EXPECT_TRUE(text->ShowOnTop()); - text->SetColor(math::Color(1, 0.2, 0.3, 1.0)); - EXPECT_EQ(math::Color(1, 0.2, 0.3, 1.0), text->Color()); + text->SetColor(math::Color(1.0f, 0.2f, 0.3f, 1.0f)); + EXPECT_EQ(math::Color(1.0f, 0.2f, 0.3f, 1.0f), text->Color()); // create material MaterialPtr mat = scene->CreateMaterial(); - mat->SetAmbient(0.6, 0.7, 0.8); - mat->SetDiffuse(0.3, 0.8, 0.2); - mat->SetSpecular(0.4, 0.9, 1.0); + mat->SetAmbient(0.6f, 0.7f, 0.8f); + mat->SetDiffuse(0.3f, 0.8f, 0.2f); + mat->SetSpecular(0.4f, 0.9f, 1.0f); text->SetMaterial(mat); MaterialPtr textMat = text->Material(); ASSERT_NE(nullptr, textMat); - EXPECT_EQ(math::Color(0.6, 0.7, 0.8), textMat->Ambient()); - EXPECT_EQ(math::Color(0.3, 0.8, 0.2), textMat->Diffuse()); - EXPECT_EQ(math::Color(0.4, 0.9, 1.0), textMat->Specular()); + EXPECT_EQ(math::Color(0.6f, 0.7f, 0.8f), textMat->Ambient()); + EXPECT_EQ(math::Color(0.3f, 0.8f, 0.2f), textMat->Diffuse()); + EXPECT_EQ(math::Color(0.4f, 0.9f, 1.0f), textMat->Specular()); // color is affected by material but currently only by the diffuse component - EXPECT_EQ(math::Color(0.3, 0.8, 0.2, 1.0), text->Color()); + EXPECT_EQ(math::Color(0.3f, 0.8f, 0.2f, 1.0f), text->Color()); // Clean up engine->DestroyScene(scene); diff --git a/src/ThermalCamera_TEST.cc b/src/ThermalCamera_TEST.cc index 5dbab485f..86aa41c19 100644 --- a/src/ThermalCamera_TEST.cc +++ b/src/ThermalCamera_TEST.cc @@ -56,19 +56,19 @@ void ThermalCameraTest::ThermalCamera(const std::string &_renderEngine) camera->SetAmbientTemperature(ambient); EXPECT_FLOAT_EQ(ambient, camera->AmbientTemperature()); - float range = 3.35; + float range = 3.35f; camera->SetAmbientTemperatureRange(range); EXPECT_FLOAT_EQ(range, camera->AmbientTemperatureRange()); - float minTemp = 250.05; + float minTemp = 250.05f; camera->SetMinTemperature(minTemp); EXPECT_FLOAT_EQ(minTemp, camera->MinTemperature()); - float maxTemp = 380.06; + float maxTemp = 380.06f; camera->SetMaxTemperature(maxTemp); EXPECT_FLOAT_EQ(maxTemp, camera->MaxTemperature()); - float resolution = 0.04; + float resolution = 0.04f; camera->SetLinearResolution(resolution); EXPECT_FLOAT_EQ(resolution, camera->LinearResolution()); diff --git a/src/Utils.cc b/src/Utils.cc index 821547e9d..9896ea17f 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -34,8 +34,15 @@ float screenScalingFactor() // todo(anyone) set device pixel ratio for high dpi displays on Windows float ratio = 1.0; #ifdef __linux__ - Display *disp = XOpenDisplay(nullptr); - char *resourceString = XResourceManagerString(disp); + auto closeDisplay = [](Display * display) + { + if (display) + XCloseDisplay(display); + }; + auto display = + std::unique_ptr( + XOpenDisplay(nullptr), closeDisplay); + char *resourceString = XResourceManagerString(display.get()); if (resourceString) { @@ -68,8 +75,8 @@ float screenScalingFactor() // We can use either the width or height in the following line. The zero // values in DisplayHeight and DisplayHeightMM is the screen number. A // value of zero uses the default screen. - float yDpiRes = (DisplayHeight(disp, 0) * 25.4) / - DisplayHeightMM(disp, 0); + float yDpiRes = (DisplayHeight(display.get(), 0) * 25.4) / + DisplayHeightMM(display.get(), 0); if (!math::equal(dpiDesktop, 0.0f) && !math::equal(yDpiRes, 0.0f)) ratio = dpiDesktop / yDpiRes; diff --git a/src/Visual_TEST.cc b/src/Visual_TEST.cc index 45e76cf91..e18961a5c 100644 --- a/src/Visual_TEST.cc +++ b/src/Visual_TEST.cc @@ -78,9 +78,9 @@ void VisualTest::Material(const std::string &_renderEngine) EXPECT_EQ(nullptr, visual->Material()); // create material - math::Color ambient(0.5, 0.2, 0.4, 1.0); - math::Color diffuse(0.1, 0.9, 0.3, 1.0); - math::Color specular(0.8, 0.7, 0.0, 1.0); + math::Color ambient(0.5f, 0.2f, 0.4f, 1.0f); + math::Color diffuse(0.1f, 0.9f, 0.3f, 1.0f); + math::Color specular(0.8f, 0.7f, 0.0f, 1.0f); double transparency = 0.3; MaterialPtr material = scene->CreateMaterial("unique"); ASSERT_NE(nullptr, material); @@ -108,9 +108,9 @@ void VisualTest::Material(const std::string &_renderEngine) EXPECT_DOUBLE_EQ(transparency, cloneMat->Transparency()); // create another material - math::Color ambient2(0.0, 0.0, 1.0, 1.0); - math::Color diffuse2(1.0, 0.0, 1.0, 1.0); - math::Color specular2(0.0, 1.0, 0.0, 1.0); + math::Color ambient2(0.0f, 0.0f, 1.0f, 1.0f); + math::Color diffuse2(1.0f, 0.0f, 1.0f, 1.0f); + math::Color specular2(0.0f, 1.0f, 0.0f, 1.0f); double transparency2 = 0; MaterialPtr material2 = scene->CreateMaterial("unique2"); ASSERT_NE(nullptr, material2); @@ -348,7 +348,11 @@ void VisualTest::UserData(const std::string &_renderEngine) EXPECT_EQ(stringValue, std::get(value)); // test invalid access - EXPECT_THROW(std::get(value), std::bad_variant_access); + EXPECT_THROW( + { + auto res = std::get(value); + igndbg << res << std::endl; + }, std::bad_variant_access); // Clean up engine->DestroyScene(scene); diff --git a/src/WireBox_TEST.cc b/src/WireBox_TEST.cc index c672dcfda..5a053c14d 100644 --- a/src/WireBox_TEST.cc +++ b/src/WireBox_TEST.cc @@ -73,9 +73,9 @@ void WireBoxTest::WireBox(const std::string &_renderEngine) wireBox->SetMaterial(mat); MaterialPtr wireBoxMat = wireBox->Material(); ASSERT_NE(nullptr, wireBoxMat); - EXPECT_EQ(math::Color(0.6, 0.7, 0.8), wireBoxMat->Ambient()); - EXPECT_EQ(math::Color(0.3, 0.8, 0.2), wireBoxMat->Diffuse()); - EXPECT_EQ(math::Color(0.4, 0.9, 1.0), wireBoxMat->Specular()); + EXPECT_EQ(math::Color(0.6f, 0.7f, 0.8f), wireBoxMat->Ambient()); + EXPECT_EQ(math::Color(0.3f, 0.8f, 0.2f), wireBoxMat->Diffuse()); + EXPECT_EQ(math::Color(0.4f, 0.9f, 1.0f), wireBoxMat->Specular()); // Clean up engine->DestroyScene(scene); diff --git a/test/integration/depth_camera.cc b/test/integration/depth_camera.cc index 056d494b0..b67c7d9af 100644 --- a/test/integration/depth_camera.cc +++ b/test/integration/depth_camera.cc @@ -174,8 +174,8 @@ void DepthCameraTest::DepthCameraBoxes( // from depth and point cloud image // depth image indices - int midWidth = depthCamera->ImageWidth() * 0.5; - int midHeight = depthCamera->ImageHeight() * 0.5; + int midWidth = static_cast(depthCamera->ImageWidth() * 0.5); + int midHeight = static_cast(depthCamera->ImageHeight() * 0.5); int mid = midHeight * depthCamera->ImageWidth() + midWidth -1; double expectedRangeAtMidPoint = boxPosition.X() - unitBoxSize * 0.5; int left = midHeight * depthCamera->ImageWidth(); diff --git a/test/integration/render_pass.cc b/test/integration/render_pass.cc index d45d6e91a..17659a3e3 100644 --- a/test/integration/render_pass.cc +++ b/test/integration/render_pass.cc @@ -297,8 +297,8 @@ void RenderPassTest::DepthGaussianNoise(const std::string &_renderEngine) // from point cloud image // point cloud image indices - int midWidth = depthCamera->ImageWidth() * 0.5; - int midHeight = depthCamera->ImageHeight() * 0.5; + int midWidth = static_cast(depthCamera->ImageWidth() * 0.5); + int midHeight = static_cast(depthCamera->ImageHeight() * 0.5); double expectedRangeAtMidPoint = boxPosition.X() - unitBoxSize * 0.5; int pcMid = midHeight * depthCamera->ImageWidth() * pointCloudChannelCount diff --git a/test/integration/scene.cc b/test/integration/scene.cc index c3f1c26cf..7fbb78e64 100644 --- a/test/integration/scene.cc +++ b/test/integration/scene.cc @@ -71,9 +71,9 @@ void SceneTest::AddRemoveVisuals(const std::string &_renderEngine) root->AddChild(camera); // create material assigned to all geoms - math::Color ambient(0.5, 0.2, 0.4, 1.0); - math::Color diffuse(0.1, 0.9, 0.3, 1.0); - math::Color specular(0.8, 0.7, 0.0, 1.0); + math::Color ambient(0.5f, 0.2f, 0.4f, 1.0f); + math::Color diffuse(0.1f, 0.9f, 0.3f, 1.0f); + math::Color specular(0.8f, 0.7f, 0.0f, 1.0f); double transparency = 0.3; MaterialPtr material = scene->CreateMaterial("mat"); ASSERT_NE(nullptr, material); diff --git a/test/integration/thermal_camera.cc b/test/integration/thermal_camera.cc index a24bebf35..1ce399c9a 100644 --- a/test/integration/thermal_camera.cc +++ b/test/integration/thermal_camera.cc @@ -145,9 +145,9 @@ void ThermalCameraTest::ThermalCameraBoxes( // thermal-specific params // set room temperature: 294 ~ 298 Kelvin - float ambientTemp = 296.0; - float ambientTempRange = 4.0; - float linearResolution = 0.01; + float ambientTemp = 296.0f; + float ambientTempRange = 4.0f; + float linearResolution = 0.01f; thermalCamera->SetAmbientTemperature(ambientTemp); EXPECT_FLOAT_EQ(ambientTemp, thermalCamera->AmbientTemperature()); thermalCamera->SetAmbientTemperatureRange(ambientTempRange); @@ -171,8 +171,8 @@ void ThermalCameraTest::ThermalCameraBoxes( thermalCamera->Update(); // thermal image indices - int midWidth = thermalCamera->ImageWidth() * 0.5; - int midHeight = thermalCamera->ImageHeight() * 0.5; + int midWidth = static_cast(thermalCamera->ImageWidth() * 0.5); + int midHeight = static_cast(thermalCamera->ImageHeight() * 0.5); int mid = midHeight * thermalCamera->ImageWidth() + midWidth -1; int left = midHeight * thermalCamera->ImageWidth(); int right = (midHeight+1) * thermalCamera->ImageWidth() - 1; diff --git a/tutorials.md.in b/tutorials.md.in index 6b248afcb..87bd3a259 100644 --- a/tutorials.md.in +++ b/tutorials.md.in @@ -23,6 +23,7 @@ Ignition @IGN_DESIGNATION_CAP@ library and how to use the library effectively. 9. \subpage text_geom "Text geom" 10. \subpage particles "Particles" 11. \subpage render_order "Render Order" +12. \subpage transform_fbx_to_dae "Transform FBX to Collada in Blender" ## License diff --git a/tutorials/02_install.md b/tutorials/02_install.md index d7d7720d5..fec7243e7 100644 --- a/tutorials/02_install.md +++ b/tutorials/02_install.md @@ -1,108 +1,110 @@ \page installation Installation -[Install](#install) +These instructions are for installing only Ignition Rendering. +If you're interested in using all the Ignition libraries, check out this [Ignition installation](https://ignitionrobotics.org/docs/latest/install). -* [Binary Install](#binary-install) +We recommend following the Binary Install instructions to get up and running as quickly and painlessly as possible. -* [Source Install](#source-install) +The Source Install instructions should be used if you need the very latest software improvements, you need to modify the code, or you plan to make a contribution. - * [Prerequisites](#prerequisites) +# Ubuntu - * [Building from Source](#building-from-source) +## Binary Installation -We recommend following the [Binary Install](#binary-install) instructions to get up and running as quickly and painlessly as possible. - -The [Source Install](#source-install) instructions should be used if you need the very latest software improvements, you need to modify the code, or you plan to make a contribution. - -## Binary Install - -### Ubuntu +Install dependencies: +``` +sudo apt-get update +sudo apt-get -y install wget lsb-release gnupg +``` -Setup your computer to accept software from packages.osrfoundation.org: +Setup your computer to accept software from +[packages.osrfoundation.org](http://packages.osrfoundation.org): +``` +sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' +``` - sudo apt -y install wget lsb-release gnupg - sudo 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 - | sudo apt-key add - - sudo apt update +Setup keys: +``` +wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - +``` -Install Ignition Rendering: +Install: +``` +sudo apt-get update +sudo apt-get install libignition-rendering<#>-dev +``` - # This installs ign-rendering3. Change the number after libignition-rendering to the version you want - sudo apt install libignition-rendering3-dev +Be sure to replace `<#>` with a number value, such as `1` or `2`, depending on which version you need. -## Source Install +## Source Installation ### Prerequisites -#### Ubuntu Bionic 18.04 or above +Ubuntu Bionic 18.04 or above: Install dependencies: - - sudo apt -y install wget lsb-release gnupg - sudo 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 - | sudo apt-key add - - sudo apt update - sudo apt install -y \ - g++-8 \ - cmake \ - pkg-config \ - git \ - libglew-dev \ - libfreeimage-dev \ - freeglut3-dev \ - libxmu-dev \ - libxi-dev \ - libignition-cmake2-dev \ - libignition-math6-dev \ - libignition-common3-dev \ - libignition-plugin-dev - sudo 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 - -Clone source code - - # This checks out the `master` branch. You can append `-b ign-rendering#` (replace # with a number) to checkout a specific version - git clone http://github.com/ignitionrobotics/ign-rendering - -#### Supported Rendering Engines +``` +sudo apt -y install wget lsb-release gnupg +sudo 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 - | sudo apt-key add - +sudo apt update +sudo apt install -y \ + g++-8 \ + cmake \ + pkg-config \ + git \ + libglew-dev \ + libfreeimage-dev \ + freeglut3-dev \ + libxmu-dev \ + libxi-dev \ + libignition-cmake2-dev \ + libignition-math6-dev \ + libignition-common3-dev \ + libignition-plugin-dev +sudo 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 +``` + +### Supported Rendering Engines Ignition Rendering will look for rendering libraries installed in the system and build the relevant plugins if dependencies are found. **OGRE 1.x** - - # this installs ogre 1.9. Alternatively, you can install 1.8 - sudo apt-get install libogre-1.9-dev +``` +# this installs ogre 1.9. Alternatively, you can install 1.8 +sudo apt-get install libogre-1.9-dev +``` **OGRE 2.x (supported in Versions >= ign-rendering1)** Add OSRF packages if you have not done so already: - - sudo apt -y install wget lsb-release gnupg - sudo 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 - | sudo apt-key add - - sudo apt update +``` +sudo apt -y install wget lsb-release gnupg +sudo 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 - | sudo apt-key add - +sudo apt update +``` Install OGRE 2.1 debs - - sudo apt install libogre-2.1-dev +``` +sudo apt install libogre-2.1-dev +``` **OptiX (experimental)** Download and install by following instructions on NVIDIA website -CUDA: - -http://docs.nvidia.com/cuda +CUDA: http://docs.nvidia.com/cuda -OptiX: - -https://developer.nvidia.com/optix +OptiX: https://developer.nvidia.com/optix Update `LD_LIBRARY_PATH` and add an `OPTIX_INSTALL_DIR` environment variables so that ign-rendering can find Optix, e.g. if you installed version 4.0.2 in HOME/optix: - - export LD_LIBRARY_PATH=${HOME}/optix/NVIDIA-OptiX-SDK-4.0.2-linux64/lib64:${LD_LIBRARY_PATH} - export OPTIX_INSTALL_DIR=${HOME}/optix/NVIDIA-OptiX-SDK-4.0.2-linux64 +``` +export LD_LIBRARY_PATH=${HOME}/optix/NVIDIA-OptiX-SDK-4.0.2-linux64/lib64:${LD_LIBRARY_PATH} +export OPTIX_INSTALL_DIR=${HOME}/optix/NVIDIA-OptiX-SDK-4.0.2-linux64 +``` Note: If you encounter errors about different exception specifiers in optix math when building Ign Rendering OptiX plugin, edit @@ -110,16 +112,118 @@ when building Ign Rendering OptiX plugin, edit out the section that defines `fminf`, fmaxf, and `copysignf` (for optix sdk 4.0.2, comment out lines 167-206). +### Build from Source + +1. Clone the repository + ``` + # Optionally, append `-b ign-rendering#` (replace # with a number) to check out a specific version + git clone http://github.com/ignitionrobotics/ign-rendering + ``` + +2. Configure and build + ``` + cd ign-rendering + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install/dir + make + ``` + Replace `/path/to/install/dir` to whatever directory you want to install this package to + +3. Optionally, install + ``` + make install + ``` + +# Windows + +On Windows, only OGRE 1 is currently supported. + +## Prerequisites + +First, follow the [ign-cmake](https://github.com/ignitionrobotics/ign-cmake) tutorial for installing Conda, Visual Studio, CMake, and other prerequisites, and also for creating a Conda environment. + +Navigate to ``condabin`` if necessary to use the ``conda`` command (i.e., if Conda is not in your `PATH` environment variable. You can find the location of ``condabin`` in Anaconda Prompt, ``where conda``). + +Create if necessary, and activate a Conda environment: +``` +conda create -n ign-ws +conda activate ign-ws +``` + +## Binary Installation + +`libignition-rendering<#>` Conda feedstock is not yet available, pending [conda-forge/staged-recipes#13551](https://github.com/conda-forge/staged-recipes/issues/13551). + +## Source Installation + +This assumes you have created and activated a Conda environment while installing the Prerequisites. + +1. Install dependencies: + ``` + conda install ogre --channel conda-forge + ``` + +2. Install Ignition dependencies: + + You can view available versions and their dependencies: + ``` + conda search libignition-rendering* --channel conda-forge --info + ``` + + Install dependencies, replacing `<#>` with the desired versions: + ``` + conda install libignition-cmake<#> libignition-common<#> libignition-math<#> libignition-plugin<#> --channel conda-forge + ``` + +3. Navigate to where you would like to build the library, and clone the repository. + ``` + # Optionally, append `-b ign-rendering#` (replace # with a number) to check out a specific version + git clone https://github.com/ignitionrobotics/ign-rendering.git + ``` + +4. Configure and build + ``` + cd ign-rendering + mkdir build + cd build + cmake .. -DBUILD_TESTING=OFF # Optionally, -DCMAKE_INSTALL_PREFIX=path\to\install + cmake --build . --config Release + ``` + +5. Optionally, install + ``` + cmake --install . --config Release + ``` + +# Documentation + +API documentation can be generated using Doxygen + ``` + sudo apt install -y doxygen + ``` + +Build documentation + ``` + cd build + make doc + ``` -### Building from source +View documentation + ``` + firefox doxygen/html/index.html + ``` -Build and install as follows: +# Testing + +Tests can be run by building the `test` target: + ``` + cd build + make test + ``` - cd ign-rendering - mkdir build - cd build - cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install/dir - make -j4 - make install +To run tests specific to a render engine, set the `RENDER_ENGINE_VALUES` environment variable, e.g. + ``` + RENDER_ENGINE_VALUES=ogre2 make test + ``` -Replace `/path/to/install/dir` to whatever directory you want to install this package to diff --git a/tutorials/21_transform_fbx_to_dae.md b/tutorials/21_transform_fbx_to_dae.md new file mode 100644 index 000000000..5f7d59382 --- /dev/null +++ b/tutorials/21_transform_fbx_to_dae.md @@ -0,0 +1,40 @@ +\page transform_fbx_to_dae Transform FBX to Collada in Blender + +This tutorial shows how to transform a mesh in fbx format to collada with Blender and change its origin. + +You can download Blender +2.81 from [this web site](https://www.blender.org/download/). + +# Importing the FBX file + +Remove all the elements in the scene. You can select the elements pushing `Ctrl + Shift + left mouse button` +from the list of elements that you can see in the right top corner of the Blender window. + +@image html img/transform_fbx_to_dae/remove_elemets.gif + +Then import your FBX model. `File -> Import -> Fbx (.fbx).` + +@image html img/transform_fbx_to_dae/import_model.gif + +# Modify properties of the model + +Now we can edit some of the properties of the object. + +## Change the origin of the model (Optional) + +Sometimes a mesh may have an origin at an offset from the desired location. For example, +you may want to move the origin of a robot arm to the base or move the origin of a wheel to its center. + +Select the object by pushing the letter `a` and enter to `Edit mode` by pushing `Tab`. +Select the part of the object at which you’d like to place the origin point (vertex, edge or face). +When we are ready push `Shift + s` to bring up the *snap menu* and select `Cursor to active` to locate +the Blender cursor (red/white circle thing) in the selected new place. +Switch back to `Object Mode` and see the Blender cursor where your future origin is going to be. +In the `Options` menu select `Origins` and then select in the object menu `Object -> Set Origin -> Origin to 3D Cursor`. +Now your origin is at the desired place. We can move this origin to another place by editing the +transform dialog. + +@image html img/transform_fbx_to_dae/edit_origin.gif + +# Exporting to Collada + +Finally export your model to collada `File -> Export -> Collada (default)(.dae).` diff --git a/tutorials/img/transform_fbx_to_dae/edit_origin.gif b/tutorials/img/transform_fbx_to_dae/edit_origin.gif new file mode 100644 index 000000000..e0b6bf061 Binary files /dev/null and b/tutorials/img/transform_fbx_to_dae/edit_origin.gif differ diff --git a/tutorials/img/transform_fbx_to_dae/import_model.gif b/tutorials/img/transform_fbx_to_dae/import_model.gif new file mode 100644 index 000000000..20d640254 Binary files /dev/null and b/tutorials/img/transform_fbx_to_dae/import_model.gif differ diff --git a/tutorials/img/transform_fbx_to_dae/remove_elemets.gif b/tutorials/img/transform_fbx_to_dae/remove_elemets.gif new file mode 100644 index 000000000..1200b450b Binary files /dev/null and b/tutorials/img/transform_fbx_to_dae/remove_elemets.gif differ