Skip to content

Commit

Permalink
Finale: Tick-tock IgnOgreRenderingMode
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon committed Jul 15, 2022
1 parent 3258608 commit ca9e852
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 67 deletions.
3 changes: 3 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ release will remove the deprecated code.
3. `IGN_VISIBILITY_SELECTION`
4. `IGN_VISIBILITY_GUI`
5. `IGN_VISIBILITY_SELECTABLE`
7. The `IgnRenderingMode` enum is deprecated and will be removed in future versions. Use `GzRenderingMode` instead.
1. Similarly, the `IORM_` prefixed enum values are deprecated. Use the `GORM_` prefix instead.
2. Also, `Ogre2RenderEngine->SetIgnOgreRenderingMode` is deprecated and will be removed. Use `Ogre2RenderEngine->SetGzOgreRenderingMode` instead.

### Breaking Changes

Expand Down
19 changes: 12 additions & 7 deletions ogre2/include/gz/rendering/ogre2/Ogre2GzOgreRenderingMode.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,32 @@ namespace gz
/// \brief Rendering modes so that GzHlms implementations
/// follow alternate code paths or extra customizations
/// when they're enabled
enum IgnOgreRenderingMode
enum GzOgreRenderingMode
{
/// \brief Normal rendering
IORM_NORMAL,
GORM_NORMAL = 0,
IORM_NORMAL = 0, // TODO(CH3): Deprecated. Remove on tock.

/// \brief Render a solid color explicit per object.
/// Used by e.g. Segmentation camera mode
IORM_SOLID_COLOR,
GORM_SOLID_COLOR = 1,
IORM_SOLID_COLOR = 1, // TODO(CH3): Deprecated. Remove on tock.

/// \brief Like IORM_SOLID_COLOR, but if CustomParameter 2u
/// \brief Like GORM_SOLID_COLOR, but if CustomParameter 2u
/// is present, raw diffuse texture will be multiplied against
/// the solid colour.
///
/// Also Unlit will behave as if IORM_NORMAL
/// Also Unlit will behave as if GORM_NORMAL
///
/// Used by thermal camera
IORM_SOLID_THERMAL_COLOR_TEXTURED,
GORM_SOLID_THERMAL_COLOR_TEXTURED = 2,
IORM_SOLID_THERMAL_COLOR_TEXTURED = 2, // TODO(CH3): Deprecated. Remove on tock.

/// \brief Total number of rendering modes
IORM_COUNT,
GORM_COUNT = 3,
IORM_COUNT = 3, // TODO(CH3): Deprecated. Remove on tock.
};
using IgnOgreRenderingMode GZ_DEPRECATED(7) = GzOgreRenderingMode; // TODO(CH3): Deprecated. Remove on tock.
} // namespace GZ_RENDERING_VERSION_NAMESPACE
} // namespace rendering
} // namespace gz
Expand Down
9 changes: 7 additions & 2 deletions ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,15 @@ namespace gz
public: Ogre::v1::OverlaySystem *OverlaySystem() const;

/// \internal
/// \brief Sets the current rendering mode. See IgnOgreRenderingMode
/// \brief Sets the current rendering mode. See GzOgreRenderingMode
/// and see Ogre::GzHlmsPbs
/// \param[in] renderingMode
public: void SetIgnOgreRenderingMode(IgnOgreRenderingMode renderingMode);
public: void SetGzOgreRenderingMode(GzOgreRenderingMode renderingMode);
// TODO(CH3): Deprecated. Remove on tock.
public:
inline void GZ_DEPRECATED(7) SetIgnOgreRenderingMode(GzOgreRenderingMode renderingMode){
return SetGzOgreRenderingMode(renderingMode);
}

/// \internal
/// \brief Get a pointer to the Pbs listener that adds terra shadows.
Expand Down
8 changes: 4 additions & 4 deletions ogre2/src/Ogre2GpuRays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void Ogre2LaserRetroMaterialSwitcher::passPreExecute(
return;

auto engine = Ogre2RenderEngine::Instance();
engine->SetIgnOgreRenderingMode(IORM_SOLID_COLOR);
engine->SetGzOgreRenderingMode(GORM_SOLID_COLOR);

this->materialMap.clear();
this->datablockMap.clear();
Expand Down Expand Up @@ -452,7 +452,7 @@ void Ogre2LaserRetroMaterialSwitcher::passPosExecute(
this->datablockMap.clear();

// Remove the custom parameter. Why? If there are multiple cameras that
// use IORM_SOLID_COLOR (or any other mode), we want them to throw if
// use GORM_SOLID_COLOR (or any other mode), we want them to throw if
// that code forgot to call setCustomParameter. We may miss those errors
// if that code forgets to call but it was already carrying the value
// we set here.
Expand Down Expand Up @@ -490,7 +490,7 @@ void Ogre2LaserRetroMaterialSwitcher::passPosExecute(
heightmap->Terra()->UnsetSolidColors();
}

engine->SetIgnOgreRenderingMode(IORM_NORMAL);
engine->SetGzOgreRenderingMode(GORM_NORMAL);
}

//////////////////////////////////////////////////
Expand Down Expand Up @@ -1186,7 +1186,7 @@ void Ogre2GpuRays::Setup1stPass()
false);

// add laser retro material switcher to workspace listener
// so we can switch to use IORM_SOLID_COLOR
// so we can switch to use GORM_SOLID_COLOR
this->dataPtr->laserRetroMaterialSwitcher[i].reset(
new Ogre2LaserRetroMaterialSwitcher(this->scene));
this->dataPtr->ogreCompositorWorkspace1st[i]->addListener(
Expand Down
26 changes: 13 additions & 13 deletions ogre2/src/Ogre2GzHlmsPbsPrivate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ namespace Ogre
Hlms *_hlms)
{
if (!_casterPass &&
(this->gzOgreRenderingMode == IORM_SOLID_COLOR ||
this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED))
(this->gzOgreRenderingMode == GORM_SOLID_COLOR ||
this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED))
{
_hlms->_setProperty("gz_render_solid_color", 1);

if (this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED)
if (this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED)
_hlms->_setProperty("gz_render_solid_color_textured", 1);
}

Expand Down Expand Up @@ -146,8 +146,8 @@ namespace Ogre
}

if (_casterPass ||
(this->gzOgreRenderingMode != IORM_SOLID_COLOR &&
this->gzOgreRenderingMode != IORM_SOLID_THERMAL_COLOR_TEXTURED))
(this->gzOgreRenderingMode != GORM_SOLID_COLOR &&
this->gzOgreRenderingMode != GORM_SOLID_THERMAL_COLOR_TEXTURED))
{
return;
}
Expand All @@ -163,8 +163,8 @@ namespace Ogre
const uint32 instanceIdx = HlmsPbs::fillBuffersForV1(
_cache, _queuedRenderable, _casterPass, _lastCacheHash, _commandBuffer);

if ((this->gzOgreRenderingMode == IORM_SOLID_COLOR ||
this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED) &&
if ((this->gzOgreRenderingMode == GORM_SOLID_COLOR ||
this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED) &&
!_casterPass)
{
Vector4 customParam =
Expand All @@ -177,12 +177,12 @@ namespace Ogre
dataPtr[1] = customParam.y;
dataPtr[2] = customParam.z;

if (this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED &&
if (this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED &&
_queuedRenderable.renderable->hasCustomParameter(2u))
{
GZ_ASSERT(customParam.w >= 0.0f,
"customParam.w can't be negative for "
"IORM_SOLID_THERMAL_COLOR_TEXTURED");
"GORM_SOLID_THERMAL_COLOR_TEXTURED");

// Negate customParam.w to tell the shader we wish to multiply
// against the diffuse texture. We substract 0.5f to avoid -0.0 = 0.0
Expand All @@ -205,8 +205,8 @@ namespace Ogre
const uint32 instanceIdx = HlmsPbs::fillBuffersForV2(
_cache, _queuedRenderable, _casterPass, _lastCacheHash, _commandBuffer);

if ((this->gzOgreRenderingMode == IORM_SOLID_COLOR ||
this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED) &&
if ((this->gzOgreRenderingMode == GORM_SOLID_COLOR ||
this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED) &&
!_casterPass)
{
Vector4 customParam;
Expand Down Expand Up @@ -236,12 +236,12 @@ namespace Ogre
dataPtr[2] = customParam.z;
dataPtr[3] = customParam.w;

if (this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED &&
if (this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED &&
_queuedRenderable.renderable->hasCustomParameter(2u))
{
GZ_ASSERT(customParam.w >= 0.0f,
"customParam.w can't be negative for "
"IORM_SOLID_THERMAL_COLOR_TEXTURED");
"GORM_SOLID_THERMAL_COLOR_TEXTURED");

// Negate customParam.w to tell the shader we wish to multiply
// against the diffuse texture. We substract 0.5f to avoid -0.0 = 0.0
Expand Down
2 changes: 1 addition & 1 deletion ogre2/src/Ogre2GzHlmsPbsPrivate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace Ogre
public: virtual void notifyPropertiesMergedPreGenerationStep() override;

/// \brief Override HlmsListener::hlmsTypeChanged so we can
/// bind buffers which carry per-object data when in IORM_SOLID_COLOR
/// bind buffers which carry per-object data when in GORM_SOLID_COLOR
/// \param[in] _casterPass true if this is a caster pass
/// \param[in] _commandBuffer command buffer so we can add commands
/// \param[in] _datablock material of the object that caused
Expand Down
6 changes: 3 additions & 3 deletions ogre2/src/Ogre2GzHlmsSharedPrivate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace gz
{
inline namespace GZ_RENDERING_VERSION_NAMESPACE
{
typedef gz::rendering::IgnOgreRenderingMode IgnOgreRenderingMode;
typedef gz::rendering::GzOgreRenderingMode GzOgreRenderingMode;
typedef Ogre::vector<Ogre::ConstBufferPacked*>::type ConstBufferPackedVec;

/// \brief Implements code shared across all or most of our Hlms
Expand Down Expand Up @@ -106,9 +106,9 @@ namespace gz
/// \internal
protected: float *currPerObjectDataPtr = nullptr;

/// \brief See IgnOgreRenderingMode. Public variable.
/// \brief See GzOgreRenderingMode. Public variable.
/// Modifying it takes change on the next render
public: IgnOgreRenderingMode gzOgreRenderingMode = IORM_NORMAL;
public: GzOgreRenderingMode gzOgreRenderingMode = GORM_NORMAL;
};
}
}
Expand Down
26 changes: 13 additions & 13 deletions ogre2/src/Ogre2GzHlmsTerraPrivate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ namespace Ogre
bool _dualParaboloid, SceneManager *_sceneManager, Hlms *_hlms)
{
if (!_casterPass &&
(this->gzOgreRenderingMode == IORM_SOLID_COLOR ||
this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED))
(this->gzOgreRenderingMode == GORM_SOLID_COLOR ||
this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED))
{
_hlms->_setProperty("gz_render_solid_color", 1);

if (this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED)
if (this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED)
_hlms->_setProperty("gz_render_solid_color_textured", 1);
}

Expand Down Expand Up @@ -143,8 +143,8 @@ namespace Ogre
}

if (_casterPass ||
(this->gzOgreRenderingMode != IORM_SOLID_COLOR &&
this->gzOgreRenderingMode != IORM_SOLID_THERMAL_COLOR_TEXTURED))
(this->gzOgreRenderingMode != GORM_SOLID_COLOR &&
this->gzOgreRenderingMode != GORM_SOLID_THERMAL_COLOR_TEXTURED))
{
return;
}
Expand All @@ -160,8 +160,8 @@ namespace Ogre
const uint32 instanceIdx = HlmsTerra::fillBuffersForV1(
_cache, _queuedRenderable, _casterPass, _lastCacheHash, _commandBuffer);

if ((this->gzOgreRenderingMode == IORM_SOLID_COLOR ||
this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED) &&
if ((this->gzOgreRenderingMode == GORM_SOLID_COLOR ||
this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED) &&
!_casterPass)
{
const Ogre::Terra *terra =
Expand Down Expand Up @@ -193,12 +193,12 @@ namespace Ogre
dataPtr[1] = customParam.y;
dataPtr[2] = customParam.z;

if (this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED &&
if (this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED &&
terra->HasSolidColor(2u))
{
GZ_ASSERT(customParam.w >= 0.0f,
"customParam.w can't be negative for "
"IORM_SOLID_THERMAL_COLOR_TEXTURED");
"GORM_SOLID_THERMAL_COLOR_TEXTURED");

// Negate customParam.w to tell the shader we wish to multiply
// against the diffuse texture. We substract 0.5f to avoid -0.0 = 0.0
Expand All @@ -221,8 +221,8 @@ namespace Ogre
const uint32 instanceIdx = HlmsTerra::fillBuffersForV2(
_cache, _queuedRenderable, _casterPass, _lastCacheHash, _commandBuffer);

if ((this->gzOgreRenderingMode == IORM_SOLID_COLOR ||
this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED) &&
if ((this->gzOgreRenderingMode == GORM_SOLID_COLOR ||
this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED) &&
!_casterPass)
{
const Ogre::Terra *terra =
Expand Down Expand Up @@ -255,12 +255,12 @@ namespace Ogre
dataPtr[2] = customParam.z;
dataPtr[3] = customParam.w;

if (this->gzOgreRenderingMode == IORM_SOLID_THERMAL_COLOR_TEXTURED &&
if (this->gzOgreRenderingMode == GORM_SOLID_THERMAL_COLOR_TEXTURED &&
terra->HasSolidColor(2u))
{
GZ_ASSERT(customParam.w >= 0.0f,
"customParam.w can't be negative for "
"IORM_SOLID_THERMAL_COLOR_TEXTURED");
"GORM_SOLID_THERMAL_COLOR_TEXTURED");

// Negate customParam.w to tell the shader we wish to multiply
// against the diffuse texture. We substract 0.5f to avoid -0.0 = 0.0
Expand Down
2 changes: 1 addition & 1 deletion ogre2/src/Ogre2GzHlmsTerraPrivate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ namespace Ogre
public: virtual void notifyPropertiesMergedPreGenerationStep() override;

/// \brief Override HlmsListener::hlmsTypeChanged so we can
/// bind buffers which carry per-object data when in IORM_SOLID_COLOR
/// bind buffers which carry per-object data when in GORM_SOLID_COLOR
/// \param[in] _casterPass true if this is a caster pass
/// \param[in] _commandBuffer command buffer so we can add commands
/// \param[in] _datablock material of the object that caused
Expand Down
8 changes: 4 additions & 4 deletions ogre2/src/Ogre2GzHlmsUnlitPrivate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace Ogre
const CompositorShadowNode *_shadowNode, bool _casterPass,
bool _dualParaboloid, SceneManager *_sceneManager, Hlms *_hlms)
{
if (!_casterPass && this->gzOgreRenderingMode == IORM_SOLID_COLOR)
if (!_casterPass && this->gzOgreRenderingMode == GORM_SOLID_COLOR)
{
_hlms->_setProperty("gz_render_solid_color", 1);
}
Expand Down Expand Up @@ -135,7 +135,7 @@ namespace Ogre
listener->hlmsTypeChanged(_casterPass, _commandBuffer, _datablock);
}

if (_casterPass || this->gzOgreRenderingMode != IORM_SOLID_COLOR)
if (_casterPass || this->gzOgreRenderingMode != GORM_SOLID_COLOR)
{
return;
}
Expand All @@ -151,7 +151,7 @@ namespace Ogre
const uint32 instanceIdx = HlmsUnlit::fillBuffersForV1(
_cache, _queuedRenderable, _casterPass, _lastCacheHash, _commandBuffer);

if (this->gzOgreRenderingMode == IORM_SOLID_COLOR && !_casterPass)
if (this->gzOgreRenderingMode == GORM_SOLID_COLOR && !_casterPass)
{
Vector4 customParam;
try
Expand Down Expand Up @@ -192,7 +192,7 @@ namespace Ogre
const uint32 instanceIdx = HlmsUnlit::fillBuffersForV2(
_cache, _queuedRenderable, _casterPass, _lastCacheHash, _commandBuffer);

if (this->gzOgreRenderingMode == IORM_SOLID_COLOR && !_casterPass)
if (this->gzOgreRenderingMode == GORM_SOLID_COLOR && !_casterPass)
{
Vector4 customParam =
_queuedRenderable.renderable->getCustomParameter(1u);
Expand Down
2 changes: 1 addition & 1 deletion ogre2/src/Ogre2GzHlmsUnlitPrivate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ namespace Ogre
public: virtual void notifyPropertiesMergedPreGenerationStep() override;

/// \brief Override HlmsListener::hlmsTypeChanged so we can
/// bind buffers which carry per-object data when in IORM_SOLID_COLOR
/// bind buffers which carry per-object data when in GORM_SOLID_COLOR
/// \param[in] _casterPass true if this is a caster pass
/// \param[in] _commandBuffer command buffer so we can add commands
/// \param[in] _datablock material of the object that caused
Expand Down
6 changes: 3 additions & 3 deletions ogre2/src/Ogre2MaterialSwitcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void Ogre2MaterialSwitcher::cameraPreRenderScene(
Ogre::Camera * /*_evt*/)
{
auto engine = Ogre2RenderEngine::Instance();
engine->SetIgnOgreRenderingMode(IORM_SOLID_COLOR);
engine->SetGzOgreRenderingMode(GORM_SOLID_COLOR);

this->materialMap.clear();
this->datablockMap.clear();
Expand Down Expand Up @@ -196,7 +196,7 @@ void Ogre2MaterialSwitcher::cameraPostRenderScene(
this->datablockMap.clear();

// Remove the custom parameter. Why? If there are multiple cameras that
// use IORM_SOLID_COLOR (or any other mode), we want them to throw if
// use GORM_SOLID_COLOR (or any other mode), we want them to throw if
// that code forgot to call setCustomParameter. We may miss those errors
// if that code forgets to call but it was already carrying the value
// we set here.
Expand Down Expand Up @@ -234,7 +234,7 @@ void Ogre2MaterialSwitcher::cameraPostRenderScene(
heightmap->Terra()->UnsetSolidColors();
}

engine->SetIgnOgreRenderingMode(IORM_NORMAL);
engine->SetGzOgreRenderingMode(GORM_NORMAL);
}

/////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions ogre2/src/Ogre2RenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,8 @@ Ogre::v1::OverlaySystem *Ogre2RenderEngine::OverlaySystem() const
}

/////////////////////////////////////////////////
void Ogre2RenderEngine::SetIgnOgreRenderingMode(
IgnOgreRenderingMode renderingMode)
void Ogre2RenderEngine::SetGzOgreRenderingMode(
GzOgreRenderingMode renderingMode)
{
this->dataPtr->gzHlmsPbs->gzOgreRenderingMode = renderingMode;
this->dataPtr->gzHlmsUnlit->gzOgreRenderingMode = renderingMode;
Expand Down
Loading

0 comments on commit ca9e852

Please sign in to comment.