mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-19 06:41:36 +00:00
Make empty collision shape for objects without any triangles.
This commit is contained in:
parent
954e5884c3
commit
0a1af644af
1 changed files with 14 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <osg/Transform>
|
#include <osg/Transform>
|
||||||
#include <osg/TriangleFunctor>
|
#include <osg/TriangleFunctor>
|
||||||
|
|
||||||
|
#include <BulletCollision/CollisionShapes/btEmptyShape.h>
|
||||||
#include <BulletCollision/CollisionShapes/btTriangleMesh.h>
|
#include <BulletCollision/CollisionShapes/btTriangleMesh.h>
|
||||||
|
|
||||||
#include <components/misc/osguservalues.hpp>
|
#include <components/misc/osguservalues.hpp>
|
||||||
|
@ -77,6 +78,19 @@ namespace Resource
|
||||||
if (!mTriangleMesh)
|
if (!mTriangleMesh)
|
||||||
return osg::ref_ptr<BulletShape>();
|
return osg::ref_ptr<BulletShape>();
|
||||||
|
|
||||||
|
if (mTriangleMesh->getNumTriangles() == 0)
|
||||||
|
{
|
||||||
|
osg::ref_ptr<BulletShape> shape(new BulletShape);
|
||||||
|
mTriangleMesh.reset(nullptr);
|
||||||
|
auto emptyShape = std::make_unique<btEmptyShape>();
|
||||||
|
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<BulletShape> shape(new BulletShape);
|
osg::ref_ptr<BulletShape> shape(new BulletShape);
|
||||||
|
|
||||||
auto triangleMeshShape = std::make_unique<TriangleMeshShape>(mTriangleMesh.release(), true);
|
auto triangleMeshShape = std::make_unique<TriangleMeshShape>(mTriangleMesh.release(), true);
|
||||||
|
|
Loading…
Reference in a new issue