Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows regresion on OgreLightVisual #228

Merged
merged 6 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ignition/rendering/base/BaseLightVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ namespace ignition
}
else if (this->type == LightVisualType::LVT_POINT)
{
float s = 0.1;
float s = 0.1f;
positions.emplace_back(ignition::math::Vector3d(-s, -s, 0));
positions.emplace_back(ignition::math::Vector3d(-s, s, 0));

Expand Down
22 changes: 12 additions & 10 deletions ogre/include/ignition/rendering/ogre/OgreHeightmap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
#include "ignition/rendering/ogre/OgreGeometry.hh"
#include "ignition/rendering/ogre/OgreIncludes.hh"

// Ignoring warning: "non dll-interface class
// 'ignition::rendering::v5::Heightmap' used as base for dll-interface class"
// because `Heightmap` and `BaseHeightmap` are header-only
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4275)
#endif

namespace ignition
{
namespace rendering
Expand All @@ -37,17 +45,7 @@ namespace ignition

/// \brief Ogre implementation of a heightmap geometry.
class IGNITION_RENDERING_OGRE_VISIBLE OgreHeightmap
// Ignoring warning: "non dll-interface class
// 'ignition::rendering::v5::Heightmap' used as base for dll-interface class"
// because `Heightmap` and `BaseHeightmap` are header-only
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4275)
#endif
: public BaseHeightmap<OgreGeometry>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
{
/// \brief Constructor
protected: explicit OgreHeightmap(const HeightmapDescriptor &_desc);
Expand Down Expand Up @@ -133,4 +131,8 @@ namespace ignition
}
}
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif
3 changes: 2 additions & 1 deletion ogre/include/ignition/rendering/ogre/OgreLightVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ namespace ignition
public: virtual MaterialPtr Material() const;

// Documentation inherited.
public: virtual void SetMaterial(MaterialPtr _material, bool _unique);
public: virtual void SetMaterial(
MaterialPtr _material, bool _unique) override;

/// \brief Set material to grid geometry.
/// \param[in] _material Ogre material.
Expand Down
105 changes: 56 additions & 49 deletions ogre/include/ignition/rendering/ogre/OgreScene.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,152 +43,159 @@ namespace ignition

public: virtual ~OgreScene();

public: virtual void Fini();
public: virtual void Fini() override;

public: virtual RenderEngine *Engine() const;
public: virtual RenderEngine *Engine() const override;

public: virtual VisualPtr RootVisual() const;
public: virtual VisualPtr RootVisual() const override;

public: virtual math::Color AmbientLight() const;
public: virtual math::Color AmbientLight() const override;

public: virtual void SetAmbientLight(const math::Color &_color);
public: virtual void SetAmbientLight(const math::Color &_color) override;

public: virtual void SetBackgroundColor(const math::Color &_color);
public: virtual void SetBackgroundColor(
const math::Color &_color) override;

// Documentation inherited.
public: virtual void SetGradientBackgroundColor(
const std::array<math::Color, 4> &_colors);
const std::array<math::Color, 4> &_colors) override;

// Documentation inherited.
public: virtual void RemoveGradientBackgroundColor();
public: virtual void RemoveGradientBackgroundColor() override;

public: virtual void PreRender();
public: virtual void PreRender() override;

public: virtual void Clear();
public: virtual void Clear() override;

public: virtual void Destroy();
public: virtual void Destroy() override;

public: virtual Ogre::SceneManager *OgreSceneManager() const;

protected: virtual bool LoadImpl();
protected: virtual bool LoadImpl() override;

protected: virtual bool InitImpl();
protected: virtual bool InitImpl() override;

protected: virtual DirectionalLightPtr CreateDirectionalLightImpl(
unsigned int _id, const std::string &_name);
unsigned int _id, const std::string &_name) override;

// Documentation inherited
protected: virtual LightVisualPtr CreateLightVisualImpl(unsigned int _id,
const std::string &_name) override;

protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual CameraPtr CreateCameraImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

// Documentation inherited
protected: virtual DepthCameraPtr CreateDepthCameraImpl(
const unsigned int _id,
const std::string &_name);
const std::string &_name) override;

// Documentation inherited
protected: virtual ThermalCameraPtr CreateThermalCameraImpl(
const unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual GpuRaysPtr CreateGpuRaysImpl(
const unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual VisualPtr CreateVisualImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

// Documentation inherited
protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual GeometryPtr CreateConeImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual MeshPtr CreateMeshImpl(unsigned int _id,
const std::string &_name, const std::string &_meshName);

protected: virtual MeshPtr CreateMeshImpl(unsigned int _id,
const std::string &_name, const MeshDescriptor &_desc);
protected: virtual MeshPtr CreateMeshImpl(
unsigned int _id,
const std::string &_name,
const MeshDescriptor &_desc) override;

// Documentation inherited
protected: virtual HeightmapPtr CreateHeightmapImpl(unsigned int _id,
const std::string &_name, const HeightmapDescriptor &_desc);
protected: virtual HeightmapPtr CreateHeightmapImpl(
unsigned int _id,
const std::string &_name,
const HeightmapDescriptor &_desc) override;

// Documentation inherited
protected: virtual GridPtr CreateGridImpl(unsigned int _id,
const std::string &_name);
protected: virtual GridPtr CreateGridImpl(
unsigned int _id,
const std::string &_name) override;

// Documentation inherited
protected: virtual MarkerPtr CreateMarkerImpl(unsigned int _id,
const std::string &_name);
protected: virtual MarkerPtr CreateMarkerImpl(
unsigned int _id,
const std::string &_name) override;

// Documentation inherited
protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

// Documentation inherited
protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

// Documentation inherited
protected: virtual TextPtr CreateTextImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id,
const std::string &_name);
const std::string &_name) override;

protected: virtual RenderTexturePtr CreateRenderTextureImpl(
unsigned int _id, const std::string &_name);
unsigned int _id, const std::string &_name) override;

// Documentation inherited.
protected: virtual RenderWindowPtr CreateRenderWindowImpl(
unsigned int _id, const std::string &_name);
unsigned int _id, const std::string &_name) override;

protected: virtual RayQueryPtr CreateRayQueryImpl(
unsigned int _id, const std::string &_name);
unsigned int _id, const std::string &_name) override;

// Documentation inherited
protected: virtual ParticleEmitterPtr CreateParticleEmitterImpl(
unsigned int _id, const std::string &_name);
unsigned int _id, const std::string &_name) override;

protected: virtual bool InitObject(OgreObjectPtr _object,
unsigned int _id, const std::string &_name);

protected: virtual LightStorePtr Lights() const;
protected: virtual LightStorePtr Lights() const override;

protected: virtual SensorStorePtr Sensors() const;
protected: virtual SensorStorePtr Sensors() const override;

protected: virtual VisualStorePtr Visuals() const;
protected: virtual VisualStorePtr Visuals() const override;

protected: virtual MaterialMapPtr Materials() const;
protected: virtual MaterialMapPtr Materials() const override;

private: void CreateContext();

Expand Down
9 changes: 8 additions & 1 deletion ogre/src/OgreLightVisual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ void OgreLightVisual::CreateVisual()
this->dataPtr->line = std::shared_ptr<OgreDynamicLines>(
new OgreDynamicLines(MT_LINE_LIST));
this->ogreNode->attachObject(this->OgreObject());
this->dataPtr->line->setMaterial("Default/TransGreen");
MaterialPtr lightVisualMaterial =
this->Scene()->Material("Default/TransGreen");
this->SetMaterial(lightVisualMaterial, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed? since we're not modifying the material, we don't need a copy right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed e8ea4e7

}
std::vector<ignition::math::Vector3d> positions = this->CreateVisualLines();

Expand Down Expand Up @@ -111,7 +113,12 @@ void OgreLightVisual::SetMaterialImpl(OgreMaterialPtr _material)
{
std::string materialName = _material->Name();
Ogre::MaterialPtr ogreMaterial = _material->Material();

#if (OGRE_VERSION <= ((1 << 16) | (10 << 8) | 7))
this->dataPtr->line->setMaterial(materialName);
#else
this->dataPtr->line->setMaterial(ogreMaterial);
#endif
this->dataPtr->material = _material;

this->dataPtr->material->SetReceiveShadows(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ namespace ignition
public: virtual MaterialPtr Material() const;

// Documentation inherited.
public: virtual void SetMaterial(MaterialPtr _material, bool _unique);
public: virtual void SetMaterial(
MaterialPtr _material, bool _unique) override;

/// \brief Set material to grid geometry.
/// \param[in] _material Ogre material.
Expand Down