From 0a1af644af214597956e414b00c872671ba6738a Mon Sep 17 00:00:00 2001 From: unelsson Date: Tue, 28 Mar 2023 16:12:23 +0300 Subject: [PATCH] Make empty collision shape for objects without any triangles. --- components/resource/bulletshapemanager.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/resource/bulletshapemanager.cpp b/components/resource/bulletshapemanager.cpp index 004c772e42..da0354104f 100644 --- a/components/resource/bulletshapemanager.cpp +++ b/components/resource/bulletshapemanager.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -77,6 +78,19 @@ namespace Resource if (!mTriangleMesh) return osg::ref_ptr(); + if (mTriangleMesh->getNumTriangles() == 0) + { + osg::ref_ptr shape(new BulletShape); + mTriangleMesh.reset(nullptr); + auto emptyShape = std::make_unique(); + shape->mCollisionBox.mExtents[0] = 0.0f; + shape->mCollisionBox.mExtents[1] = 0.0f; + shape->mCollisionBox.mExtents[2] = 0.0f; + shape->mCollisionBox.mCenter = osg::Vec3f(0, 0, 0); + shape->mCollisionShape.reset(emptyShape.release()); + return shape; + } + osg::ref_ptr shape(new BulletShape); auto triangleMeshShape = std::make_unique(mTriangleMesh.release(), true);