From d54d604e3f89249f56b21093fdaa95d1ef715833 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Tue, 5 Nov 2024 21:15:05 +0000 Subject: [PATCH] early out, check valid manual obj Signed-off-by: Ian Chen --- ogre/src/OgreWireBox.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ogre/src/OgreWireBox.cc b/ogre/src/OgreWireBox.cc index c365b4fef..c071af58d 100644 --- a/ogre/src/OgreWireBox.cc +++ b/ogre/src/OgreWireBox.cc @@ -84,6 +84,9 @@ void OgreWireBox::Create() this->scene->OgreSceneManager()->createManualObject(this->name); } + if (this->box == math::AxisAlignedBox()) + return; + this->dataPtr->manualObject->clear(); this->dataPtr->manualObject->setCastShadows(false); @@ -93,9 +96,6 @@ void OgreWireBox::Create() this->dataPtr->manualObject->begin(materialName, Ogre::RenderOperation::OT_LINE_LIST); - if (this->box == math::AxisAlignedBox()) - return; - gz::math::Vector3d max = this->box.Max(); gz::math::Vector3d min = this->box.Min(); @@ -172,6 +172,10 @@ void OgreWireBox::SetMaterial(MaterialPtr _material, bool _unique) ////////////////////////////////////////////////// void OgreWireBox::SetMaterialImpl(OgreMaterialPtr _material) { + if (!this->dataPtr->manualObject || + this->dataPtr->manualObject->getNumSections() == 0u) + return; + std::string materialName = _material->Name(); Ogre::MaterialPtr ogreMaterial = _material->Material(); this->dataPtr->manualObject->setMaterialName(0, materialName);