mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-26 22:40:25 +00:00
Share the bvh of btBvhTriangleMeshShape's when possible
Results in decent cell-loading speed up. (only affects bullet versions < 2.83, since we use btScaledBvhTriangleMeshShape for >=2.83)
This commit is contained in:
parent
d2290a8183
commit
e49bce7b40
2 changed files with 12 additions and 3 deletions
|
@ -62,7 +62,16 @@ btCollisionShape* BulletShape::duplicateCollisionShape(btCollisionShape *shape)
|
||||||
// work around btScaledBvhTriangleMeshShape bug ( https://code.google.com/p/bullet/issues/detail?id=371 ) in older bullet versions
|
// work around btScaledBvhTriangleMeshShape bug ( https://code.google.com/p/bullet/issues/detail?id=371 ) in older bullet versions
|
||||||
btTriangleMesh* oldMesh = static_cast<btTriangleMesh*>(trishape->getMeshInterface());
|
btTriangleMesh* oldMesh = static_cast<btTriangleMesh*>(trishape->getMeshInterface());
|
||||||
btTriangleMesh* newMesh = new btTriangleMesh(*oldMesh);
|
btTriangleMesh* newMesh = new btTriangleMesh(*oldMesh);
|
||||||
TriangleMeshShape* newShape = new TriangleMeshShape(newMesh, true);
|
|
||||||
|
// Do not build a new bvh (not needed, since it's the same as the original shape's bvh)
|
||||||
|
bool buildBvh = true;
|
||||||
|
if (trishape->getOptimizedBvh())
|
||||||
|
buildBvh = false;
|
||||||
|
TriangleMeshShape* newShape = new TriangleMeshShape(newMesh, true, buildBvh);
|
||||||
|
// Set original shape's bvh via pointer
|
||||||
|
// The pointer is safe because the BulletShapeInstance keeps a ref_ptr to the original BulletShape
|
||||||
|
if (!buildBvh)
|
||||||
|
newShape->setOptimizedBvh(trishape->getOptimizedBvh());
|
||||||
#endif
|
#endif
|
||||||
return newShape;
|
return newShape;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,8 @@ namespace Resource
|
||||||
// Subclass btBhvTriangleMeshShape to auto-delete the meshInterface
|
// Subclass btBhvTriangleMeshShape to auto-delete the meshInterface
|
||||||
struct TriangleMeshShape : public btBvhTriangleMeshShape
|
struct TriangleMeshShape : public btBvhTriangleMeshShape
|
||||||
{
|
{
|
||||||
TriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression)
|
TriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true)
|
||||||
: btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression)
|
: btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue