diff --git a/ogre/src/OgreNode.cc b/ogre/src/OgreNode.cc index d955c991b..a4c7beac5 100644 --- a/ogre/src/OgreNode.cc +++ b/ogre/src/OgreNode.cc @@ -17,6 +17,7 @@ #include +#include "gz/rendering/ogre/OgreCamera.hh" #include "gz/rendering/ogre/OgreNode.hh" #include "gz/rendering/ogre/OgreConversions.hh" #include "gz/rendering/ogre/OgreIncludes.hh" @@ -99,6 +100,16 @@ void OgreNode::SetRawLocalPosition(const math::Vector3d &_position) if (nullptr == this->ogreNode) return; + // ogre crashes in the shadow (PSSM) render pass with an + // Ogre::AxisAlignedBox::setExtents assertion error when the camera scene node + // position has large values. Added a workaround that places a max limit on + // the length of the position vector. + if (dynamic_cast(this) && _position.Length() > 1e8) + { + ignerr << "Unable to set camera node position to a distance larger than " + << "1e8 from origin" << std::endl; + return; + } this->ogreNode->setPosition(OgreConversions::Convert(_position)); } diff --git a/ogre2/src/Ogre2Node.cc b/ogre2/src/Ogre2Node.cc index 33900568b..47662f984 100644 --- a/ogre2/src/Ogre2Node.cc +++ b/ogre2/src/Ogre2Node.cc @@ -17,6 +17,7 @@ #include +#include "gz/rendering/ogre2/Ogre2Camera.hh" #include "gz/rendering/ogre2/Ogre2Node.hh" #include "gz/rendering/ogre2/Ogre2Conversions.hh" #include "gz/rendering/ogre2/Ogre2Scene.hh" @@ -109,6 +110,16 @@ void Ogre2Node::SetRawLocalPosition(const math::Vector3d &_position) if (nullptr == this->ogreNode) return; + // ogre crashes in the compositor shadow pass with an + // Ogre::AxisAlignedBox::setExtents assertion error when the camera scene node + // position has large values. Added a workaround that places a max limit on + // the length of the position vector. + if (dynamic_cast(this) && _position.Length() > 1e10) + { + ignerr << "Unable to set camera node position to a distance larger than " + << "1e10 from origin" << std::endl; + return; + } this->ogreNode->setPosition(Ogre2Conversions::Convert(_position)); }