Skip to content

Commit

Permalink
remove unused code, update migration guide, use numeric limits
Browse files Browse the repository at this point in the history
  • Loading branch information
iche033 committed Nov 5, 2019
1 parent 89a926b commit 05572c9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
8 changes: 8 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Deprecated code produces compile-time warnings. These warning serve as
notification to users that their code should be upgraded. The next major
release will remove the deprecated code.


## Ignition Rendering 2.X to 3.X

### Deletions

1. **Ogre2DepthCamera.hh**
+ Removed unused member variables `captureData` and `newData`

## Ignition Rendering 1.X to 2.X

### Modifications
Expand Down
3 changes: 3 additions & 0 deletions ogre/src/OgreMaterialSwitcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Ogre::Technique *OgreMaterialSwitcher::handleSchemeNotFound(
Ogre::Material *_originalMaterial, uint16_t /*_lodIndex*/,
const Ogre::Renderable *_rend)
{
// selection buffer: check scheme name against the one specified in
// OgreSelectionBuffer::CreateRTTBuffer. Only proceed if this is a callback
// from the selection camera.
if (_schemeName != "selection")
return nullptr;

Expand Down
14 changes: 7 additions & 7 deletions ogre/src/OgreThermalCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#define NOMINMAX
#include <windows.h>
#endif

#include <limits>

#include <ignition/math/Helpers.hh>
#include "ignition/rendering/ShaderParams.hh"
#include "ignition/rendering/ogre/OgreThermalCamera.hh"
Expand Down Expand Up @@ -83,7 +86,6 @@ class OgreThermalCameraMaterialSwitcher : public Ogre::RenderTargetListener,
class ignition::rendering::OgreThermalCameraPrivate
{
/// \brief The thermal material
// public: Ogre::Material *thermalMaterial = nullptr;
public: MaterialPtr thermalMaterial = nullptr;

/// \brief thermal camera texture
Expand All @@ -105,7 +107,7 @@ class ignition::rendering::OgreThermalCameraPrivate
public: uint16_t *thermalImage = nullptr;

/// \brief maximum value used for data outside sensor range
public: uint16_t dataMaxVal = 65535u;
public: uint16_t dataMaxVal = std::numeric_limits<uint16_t>::max();

/// \brief minimum value used for data outside sensor range
public: uint16_t dataMinVal = 0u;
Expand Down Expand Up @@ -229,14 +231,13 @@ Ogre::Technique *OgreThermalCameraMaterialSwitcher::handleSchemeNotFound(
if (temp >= 0.0)
{
// normalize temperature value
float color = temp * 100.0 / 65535.0;
float color = temp * 100.0 / static_cast<float>(
std::numeric_limits<uint16_t>::max());
const_cast<Ogre::SubEntity *>(subEntity)->setCustomParameter(
this->customParamIdx,
// Ogre::Vector4(color, color, color, 1.0));
Ogre::Vector4(color, 0.0, 0.0, 1.0));

return this->heatSourceMaterial->getSupportedTechnique(0);
// return this->heatSourceMaterial->getTechnique(0);
}
}

Expand Down Expand Up @@ -309,7 +310,6 @@ void OgreThermalCamera::Init()
{
BaseThermalCamera::Init();
this->CreateCamera();
// this->CreateThermalTexture();
this->CreateRenderTexture();
this->Reset();
}
Expand Down Expand Up @@ -532,7 +532,7 @@ void OgreThermalCamera::UpdateRenderTarget(Ogre::RenderTarget *_target,
float d = farPlane / (farPlane - nearPlane);
float temp = this->ambient - this->ambientRange * 0.5 + (1.0 - d)
* this->ambientRange;
temp /= 655.35;
temp /= (this->dataPtr->dataMaxVal * 0.01);
vp->setBackgroundColour(Ogre::ColourValue(temp, 0, 0));

Ogre::CompositorManager::getSingleton().setCompositorEnabled(
Expand Down
1 change: 0 additions & 1 deletion ogre/src/media/materials/programs/thermal_camera_fs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void main()

// check for heat source
float heat = texture2D(heatTexture, gl_TexCoord[0].xy).x;
// float heat = 0.2;
if (heat > 0.0)
{
// heat is normalized so convert back to work in kelvin
Expand Down
7 changes: 5 additions & 2 deletions ogre2/src/Ogre2ThermalCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#endif

#include <math.h>
#include <limits>

#include <ignition/common/Console.hh>
#include <ignition/math/Helpers.hh>

Expand Down Expand Up @@ -92,7 +94,7 @@ class ignition::rendering::Ogre2ThermalCameraPrivate
public: uint16_t *thermalImage = nullptr;

/// \brief maximum value used for data outside sensor range
public: uint16_t dataMaxVal = 65535u;
public: uint16_t dataMaxVal = std::numeric_limits<uint16_t>::max();

/// \brief minimum value used for data outside sensor range
public: uint16_t dataMinVal = 0u;
Expand Down Expand Up @@ -214,7 +216,8 @@ void Ogre2ThermalCameraMaterialSwitcher::preRenderTargetUpdate(
if (!subItem->hasCustomParameter(this->customParamIdx))
{
// normalize temperature value
float color = temp * 100.0 / 65535.0;
float color = temp * 100.0 /
static_cast<float>(std::numeric_limits<uint16_t>::max());
subItem->setCustomParameter(this->customParamIdx,
Ogre::Vector4(color, color, color, 1.0));
}
Expand Down

0 comments on commit 05572c9

Please sign in to comment.