Skip to content

Commit

Permalink
Protect against more NaNs
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina committed Jun 23, 2022
1 parent 120f3a3 commit f310470
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions ogre2/src/Ogre2RayQuery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,27 @@ void Ogre2RayQuery::SetFromCamera(const CameraPtr &_camera,
Ogre::Ray ray =
camera->ogreCamera->getCameraToViewportRay(screenPos.X(), screenPos.Y());

this->origin = Ogre2Conversions::Convert(ray.getOrigin());
this->direction = Ogre2Conversions::Convert(ray.getDirection());
auto originMath = Ogre2Conversions::Convert(ray.getOrigin());
if (originMath.IsFinite())
{
this->origin = originMath;
}
else
{
ignwarn << "Attempted to set non-finite origin from camera ["
<< camera->Name() << "]" << std::endl;
}

auto directionMath = Ogre2Conversions::Convert(ray.getDirection());
if (directionMath.IsFinite())
{
this->direction = directionMath;
}
else
{
ignwarn << "Attempted to set non-finite direction from camera ["
<< camera->Name() << "]" << std::endl;
}

this->dataPtr->camera = camera;

Expand Down

0 comments on commit f310470

Please sign in to comment.