@@ -90,12 +90,12 @@ class Ogre2ThermalCameraMaterialSwitcher : public Ogre::Camera::Listener
90
90
// / \param[in] _resolution Temperature linear resolution
91
91
public: void SetLinearResolution (double _resolution);
92
92
93
- // / \brief Callback when a camara is about to be rendered
93
+ // / \brief Callback when a camera is about to be rendered
94
94
// / \param[in] _cam Ogre camera pointer which is about to render
95
95
private: virtual void cameraPreRenderScene (
96
96
Ogre::Camera * _cam) override ;
97
97
98
- // / \brief Callback when a camera is finisned being rendered
98
+ // / \brief Callback when a camera is finished being rendered
99
99
// / \param[in] _cam Ogre camera pointer which has already render
100
100
private: virtual void cameraPostRenderScene (
101
101
Ogre::Camera * _cam) override ;
@@ -250,7 +250,7 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPreRenderScene(
250
250
const Ogre::HlmsBlendblock *noBlend =
251
251
hlmsManager->getBlendblock (Ogre::HlmsBlendblock ());
252
252
253
- const std::string tempKey = " temperature" ;
253
+ static const std::string tempKey = " temperature" ;
254
254
255
255
auto itor = this ->scene ->OgreSceneManager ()->getMovableObjectIterator (
256
256
Ogre::ItemFactory::FACTORY_TYPE_NAME);
@@ -279,38 +279,32 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPreRenderScene(
279
279
Variant tempAny = ogreVisual->UserData (tempKey);
280
280
if (tempAny.index () != 0 && !std::holds_alternative<std::string>(tempAny))
281
281
{
282
- float temp = -1.0 ;
282
+ float temp = -1 .0f ;
283
283
bool foundTemp = true ;
284
- try
284
+ if (std::holds_alternative< float >(tempAny))
285
285
{
286
286
temp = std::get<float >(tempAny);
287
287
}
288
- catch (... )
288
+ else if (std::holds_alternative< double >(tempAny) )
289
289
{
290
- try
291
- {
292
- temp = static_cast <float >(std::get<double >(tempAny));
293
- }
294
- catch (...)
295
- {
296
- try
297
- {
298
- temp = static_cast <float >(std::get<int >(tempAny));
299
- }
300
- catch (std::bad_variant_access &e)
301
- {
302
- gzerr << " Error casting user data: " << e.what () << " \n " ;
303
- temp = -1.0 ;
304
- foundTemp = false ;
305
- }
306
- }
290
+ temp = static_cast <float >(std::get<double >(tempAny));
291
+ }
292
+ else if (std::holds_alternative<int >(tempAny))
293
+ {
294
+ temp = static_cast <float >(std::get<int >(tempAny));
295
+ }
296
+ else
297
+ {
298
+ gzerr << " Error casting user data: temperature\n " ;
299
+ temp = -1 .0f ;
300
+ foundTemp = false ;
307
301
}
308
302
309
303
// if a non-positive temperature was given, clamp it to 0
310
304
if (foundTemp && temp < 0.0 )
311
305
{
312
306
temp = 0.0 ;
313
- gzwarn << " Unable to set negatve temperature for: "
307
+ gzwarn << " Unable to set negative temperature for: "
314
308
<< ogreVisual->Name () << " . Value cannot be lower than absolute "
315
309
<< " zero. Clamping temperature to 0 degrees Kelvin."
316
310
<< std::endl;
@@ -560,36 +554,30 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPreRenderScene(
560
554
{
561
555
float temp = -1.0 ;
562
556
bool foundTemp = true ;
563
- try
557
+ if (std::holds_alternative< float >(tempAny))
564
558
{
565
559
temp = std::get<float >(tempAny);
566
560
}
567
- catch (... )
561
+ else if (std::holds_alternative< double >(tempAny) )
568
562
{
569
- try
570
- {
571
- temp = static_cast <float >(std::get<double >(tempAny));
572
- }
573
- catch (...)
574
- {
575
- try
576
- {
577
- temp = static_cast <float >(std::get<int >(tempAny));
578
- }
579
- catch (std::bad_variant_access &e)
580
- {
581
- gzerr << " Error casting user data: " << e.what () << " \n " ;
582
- temp = -1.0 ;
583
- foundTemp = false ;
584
- }
585
- }
563
+ temp = static_cast <float >(std::get<double >(tempAny));
564
+ }
565
+ else if (std::holds_alternative<int >(tempAny))
566
+ {
567
+ temp = static_cast <float >(std::get<int >(tempAny));
568
+ }
569
+ else
570
+ {
571
+ gzerr << " Error casting user data: temperature\n " ;
572
+ temp = -1 .0f ;
573
+ foundTemp = false ;
586
574
}
587
575
588
576
// if a non-positive temperature was given, clamp it to 0
589
577
if (foundTemp && temp < 0.0 )
590
578
{
591
579
temp = 0.0 ;
592
- gzwarn << " Unable to set negatve temperature for: " << visual->Name ()
580
+ gzwarn << " Unable to set negative temperature for: " << visual->Name ()
593
581
<< " . Value cannot be lower than absolute "
594
582
<< " zero. Clamping temperature to 0 degrees Kelvin."
595
583
<< std::endl;
@@ -1068,7 +1056,7 @@ void Ogre2ThermalCamera::CreateThermalTexture()
1068
1056
this ->dataPtr ->ogreThermalTexture ->scheduleTransitionTo (
1069
1057
Ogre::GpuResidency::Resident);
1070
1058
1071
- // create compositor worksspace
1059
+ // create compositor workspace
1072
1060
this ->dataPtr ->ogreCompositorWorkspace =
1073
1061
ogreCompMgr->addWorkspace (
1074
1062
this ->scene ->OgreSceneManager (),
@@ -1078,7 +1066,7 @@ void Ogre2ThermalCamera::CreateThermalTexture()
1078
1066
false );
1079
1067
1080
1068
// add thermal material switcher to render target listener
1081
- // so we can switch to use heat material when the camera is being udpated
1069
+ // so we can switch to use heat material when the camera is being updated
1082
1070
Ogre::CompositorNode *node =
1083
1071
this ->dataPtr ->ogreCompositorWorkspace ->getNodeSequence ()[0 ];
1084
1072
auto channels = node->getLocalTextures ();
0 commit comments