Skip to content

Commit

Permalink
Pimpl'ize ogre2 classes (#137)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Sep 14, 2020
1 parent 46bf318 commit df19d14
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 16 deletions.
6 changes: 6 additions & 0 deletions ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef IGNITION_RENDERING_OGRE2_OGRE2CAMERA_HH_
#define IGNITION_RENDERING_OGRE2_OGRE2CAMERA_HH_

#include <memory>

#include "ignition/rendering/base/BaseCamera.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh"
#include "ignition/rendering/ogre2/Ogre2Sensor.hh"
Expand All @@ -33,6 +35,7 @@ namespace ignition
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
// forward declaration
class Ogre2CameraPrivate;
class Ogre2SelectionBuffer;

/// \brief Ogre2.x implementation of the camera class
Expand Down Expand Up @@ -130,6 +133,9 @@ namespace ignition
/// \brief Color of background
protected: math::Color backgroundColor;

/// \brief Pointer to private data class
private: std::unique_ptr<Ogre2CameraPrivate> dataPtr;

/// \brief Make scene our friend so it can create a camera
private: friend class Ogre2Scene;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef IGNITION_RENDERING_OGRE2_OGRE2GAUSSIANNOISEPASS_HH_
#define IGNITION_RENDERING_OGRE2_OGRE2GAUSSIANNOISEPASS_HH_

#include <memory>

#include "ignition/rendering/base/BaseGaussianNoisePass.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2RenderPass.hh"
Expand All @@ -28,6 +30,9 @@ namespace ignition
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
// forward declaration
class Ogre2GaussianNoisePassPrivate;

/* \class Ogre2GaussianNoisePass Ogre2GaussianNoisePass.hh \
* ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh
*/
Expand All @@ -47,8 +52,8 @@ namespace ignition
// Documentation inherited
public: void CreateRenderPass() override;

/// brief Pointer to the Gaussian noise ogre material
private: Ogre::Material *gaussianNoiseMat = nullptr;
/// \brief Pointer to private data class
private: std::unique_ptr<Ogre2GaussianNoisePassPrivate> dataPtr;
};
}
}
Expand Down
8 changes: 8 additions & 0 deletions ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef IGNITION_RENDERING_OGRE2_OGRE2LIGHT_HH_
#define IGNITION_RENDERING_OGRE2_OGRE2LIGHT_HH_

#include <memory>

#include "ignition/rendering/base/BaseLight.hh"
#include "ignition/rendering/ogre2/Ogre2Node.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
Expand All @@ -32,6 +34,9 @@ namespace ignition
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
// forward declaration
class Ogre2LightPrivate;

/// \brief Ogre 2.x implementation of the light class
class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Light :
public BaseLight<Ogre2Node>
Expand Down Expand Up @@ -116,6 +121,9 @@ namespace ignition

/// \brief Light type
protected: Ogre::Light::LightTypes ogreLightType;

/// \brief Pointer to private data class
private: std::unique_ptr<Ogre2LightPrivate> dataPtr;
};

/// \brief Ogre 2.x implementation of the directional light class
Expand Down
7 changes: 7 additions & 0 deletions ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IGNITION_RENDERING_OGRE2_OGRE2MATERIAL_HH_
#define IGNITION_RENDERING_OGRE2_OGRE2MATERIAL_HH_

#include <memory>
#include <string>

#include "ignition/rendering/base/BaseMaterial.hh"
Expand All @@ -29,6 +30,9 @@ namespace ignition
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
// forward declaration
class Ogre2MaterialPrivate;

/// \brief Ogre 2.x implementation of the material class
class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Material :
public BaseMaterial<Ogre2Object>
Expand Down Expand Up @@ -246,6 +250,9 @@ namespace ignition
/// \brief Unique id assigned to ogre hlms datablock
protected: std::string ogreDatablockId;

/// \brief Pointer to private data class
private: std::unique_ptr<Ogre2MaterialPrivate> dataPtr;

/// \brief Only an ogre scene can create an ogre material
private: friend class Ogre2Scene;
};
Expand Down
11 changes: 11 additions & 0 deletions ogre2/include/ignition/rendering/ogre2/Ogre2MeshFactory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IGNITION_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_
#define IGNITION_RENDERING_OGRE2_OGRE2MESHFACTORY_HH_

#include <memory>
#include <string>
#include <vector>

Expand All @@ -37,6 +38,10 @@ namespace ignition
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
// forward declaration
class Ogre2MeshFactoryPrivate;
class Ogre2SubMeshStoreFactoryPrivate;

/// \brief Ogre2.x implementation of the mesh factory class
class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2MeshFactory
{
Expand Down Expand Up @@ -88,6 +93,9 @@ namespace ignition

/// \brief Pointer to the scene object
protected: Ogre2ScenePtr scene;

/// \brief Pointer to private data class
private: std::unique_ptr<Ogre2MeshFactoryPrivate> dataPtr;
};

/// \brief Ogre2.x implementation of a submesh store factory class
Expand Down Expand Up @@ -129,6 +137,9 @@ namespace ignition

/// \brief A list of names associated with each ogre subitem / submesh
protected: std::vector<std::string> names;

/// \brief Pointer to private data class
private: std::unique_ptr<Ogre2SubMeshStoreFactoryPrivate> dataPtr;
};
}
}
Expand Down
7 changes: 7 additions & 0 deletions ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IGNITION_RENDERING_OGRE2_OGRE2RENDERPASS_HH_
#define IGNITION_RENDERING_OGRE2_OGRE2RENDERPASS_HH_

#include <memory>
#include <string>

#include "ignition/rendering/base/BaseRenderPass.hh"
Expand All @@ -30,6 +31,9 @@ namespace ignition
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
// forward declaration
class Ogre2RenderPassPrivate;

/* \class Ogre2RenderPass Ogre2RenderPass.hh \
* ignition/rendering/ogre2/Ogre2RenderPass.hh
*/
Expand Down Expand Up @@ -67,6 +71,9 @@ namespace ignition

/// \brief Name of the ogre compositor node definition
protected: std::string ogreCompositorNodeDefName;

/// \brief Pointer to private data class
private: std::unique_ptr<Ogre2RenderPassPrivate> dataPtr;
};
}
}
Expand Down
7 changes: 7 additions & 0 deletions ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IGNITION_RENDERING_OGRE2_OGRE2SCENE_HH_
#define IGNITION_RENDERING_OGRE2_OGRE2SCENE_HH_

#include <memory>
#include <string>

#include "ignition/rendering/Storage.hh"
Expand All @@ -37,6 +38,9 @@ namespace ignition
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
// forward declaration
class Ogre2ScenePrivate;
//
/// \brief Ogre2.x implementation of the scene class
class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Scene :
public BaseScene
Expand Down Expand Up @@ -267,6 +271,9 @@ namespace ignition
/// \brief Pointer to the ogre scene manager
protected: Ogre::SceneManager *ogreSceneManager = nullptr;

/// \brief Pointer to private data class
private: std::unique_ptr<Ogre2ScenePrivate> dataPtr;

/// \brief Make the render engine our friend
private: friend class Ogre2RenderEngine;
};
Expand Down
7 changes: 7 additions & 0 deletions ogre2/include/ignition/rendering/ogre2/Ogre2Visual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IGNITION_RENDERING_OGRE2_OGRE2VISUAL_HH_
#define IGNITION_RENDERING_OGRE2_OGRE2VISUAL_HH_

#include <memory>
#include <vector>

#include "ignition/rendering/base/BaseVisual.hh"
Expand All @@ -29,6 +30,9 @@ namespace ignition
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
// forward declaration
class Ogre2VisualPrivate;

/// \brief Ogre2.x implementation of the visual class
class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Visual :
public BaseVisual<Ogre2Node>
Expand Down Expand Up @@ -90,6 +94,9 @@ namespace ignition
/// \brief Pointer to the attached geometries
protected: Ogre2GeometryStorePtr geometries;

/// \brief Pointer to private data class
private: std::unique_ptr<Ogre2VisualPrivate> dataPtr;

/// \brief Make scene our friend so it can create ogre2 visuals
private: friend class Ogre2Scene;
};
Expand Down
6 changes: 6 additions & 0 deletions ogre2/src/Ogre2Camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@
#include "ignition/rendering/ogre2/Ogre2SelectionBuffer.hh"
#include "ignition/rendering/Utils.hh"

/// \brief Private data for the Ogre2Camera class
class ignition::rendering::Ogre2CameraPrivate
{
};

using namespace ignition;
using namespace rendering;

//////////////////////////////////////////////////
Ogre2Camera::Ogre2Camera()
: dataPtr(std::make_unique<Ogre2CameraPrivate>())
{
}

Expand Down
19 changes: 14 additions & 5 deletions ogre2/src/Ogre2GaussianNoisePass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@
#include "ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh"
#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh"

/// \brief Private data for the Ogre2GaussianNoisePass class
class ignition::rendering::Ogre2GaussianNoisePassPrivate
{
/// brief Pointer to the Gaussian noise ogre material
public: Ogre::Material *gaussianNoiseMat = nullptr;
};

using namespace ignition;
using namespace rendering;

//////////////////////////////////////////////////
Ogre2GaussianNoisePass::Ogre2GaussianNoisePass()
: dataPtr(std::make_unique<Ogre2GaussianNoisePassPrivate>())
{
}

Expand All @@ -39,7 +47,7 @@ Ogre2GaussianNoisePass::~Ogre2GaussianNoisePass()
//////////////////////////////////////////////////
void Ogre2GaussianNoisePass::PreRender()
{
if (!this->gaussianNoiseMat)
if (!this->dataPtr->gaussianNoiseMat)
return;

if (!this->enabled)
Expand All @@ -58,7 +66,8 @@ void Ogre2GaussianNoisePass::PreRender()
// 1. media/materials/scripts/gaussian_noise.material, in
// fragment_program GaussianNoiseFS
// 2. media/materials/scripts/gaussian_noise_fs.glsl
Ogre::Pass *pass = this->gaussianNoiseMat->getTechnique(0)->getPass(0);
Ogre::Pass *pass =
this->dataPtr->gaussianNoiseMat->getTechnique(0)->getPass(0);
Ogre::GpuProgramParametersSharedPtr psParams =
pass->getFragmentProgramParameters();
psParams->setNamedConstant("offsets", offsets);
Expand Down Expand Up @@ -87,9 +96,9 @@ void Ogre2GaussianNoisePass::CreateRenderPass()
<< std::endl;
return;
}
this->gaussianNoiseMat = ogreMat.get();
if (!this->gaussianNoiseMat->isLoaded())
this->gaussianNoiseMat->load();
this->dataPtr->gaussianNoiseMat = ogreMat.get();
if (!this->dataPtr->gaussianNoiseMat->isLoaded())
this->dataPtr->gaussianNoiseMat->load();

// check the compositor node exists
auto engine = Ogre2RenderEngine::Instance();
Expand Down
8 changes: 7 additions & 1 deletion ogre2/src/Ogre2Light.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2Scene.hh"

/// \brief Private data for the Ogre2Light class
class ignition::rendering::Ogre2LightPrivate
{
};

using namespace ignition;
using namespace rendering;

//////////////////////////////////////////////////
// Ogre2Light
//////////////////////////////////////////////////
Ogre2Light::Ogre2Light() :
ogreLightType(Ogre::Light::LT_POINT)
ogreLightType(Ogre::Light::LT_POINT),
dataPtr(std::make_unique<Ogre2LightPrivate>())
{
}

Expand Down
6 changes: 6 additions & 0 deletions ogre2/src/Ogre2Material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@
#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh"
#include "ignition/rendering/ogre2/Ogre2Scene.hh"

/// \brief Private data for the Ogre2Material class
class ignition::rendering::Ogre2MaterialPrivate
{
};

using namespace ignition;
using namespace rendering;

//////////////////////////////////////////////////
Ogre2Material::Ogre2Material()
: dataPtr(std::make_unique<Ogre2MaterialPrivate>())
{
}

Expand Down
15 changes: 13 additions & 2 deletions ogre2/src/Ogre2MeshFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,22 @@
#include "ignition/rendering/ogre2/Ogre2Scene.hh"
#include "ignition/rendering/ogre2/Ogre2Storage.hh"

/// \brief Private data for the Ogre2MeshFactory class
class ignition::rendering::Ogre2MeshFactoryPrivate
{
};

/// \brief Private data for the Ogre2SubMeshStoreFactory class
class ignition::rendering::Ogre2SubMeshStoreFactoryPrivate
{
};

using namespace ignition;
using namespace rendering;

//////////////////////////////////////////////////
Ogre2MeshFactory::Ogre2MeshFactory(Ogre2ScenePtr _scene) :
scene(_scene)
scene(_scene), dataPtr(std::make_unique<Ogre2MeshFactoryPrivate>())
{
}

Expand Down Expand Up @@ -500,7 +510,8 @@ bool Ogre2MeshFactory::Validate(const MeshDescriptor &_desc)
Ogre2SubMeshStoreFactory::Ogre2SubMeshStoreFactory(Ogre2ScenePtr _scene,
Ogre::Item *_item) :
scene(_scene),
ogreItem(_item)
ogreItem(_item),
dataPtr(new Ogre2SubMeshStoreFactoryPrivate)
{
this->CreateNameList();
}
Expand Down
5 changes: 5 additions & 0 deletions ogre2/src/Ogre2RenderPass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@
*/
#include "ignition/rendering/ogre2/Ogre2RenderPass.hh"

/// \brief Private data for the Ogre2RenderPass class
class ignition::rendering::Ogre2RenderPassPrivate
{
};

using namespace ignition;
using namespace rendering;

//////////////////////////////////////////////////
Ogre2RenderPass::Ogre2RenderPass()
: dataPtr(std::make_unique<Ogre2RenderPassPrivate>())
{
}

Expand Down
Loading

0 comments on commit df19d14

Please sign in to comment.