mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-18 21:10:05 +00:00
Optimize rayTest with btScaledBvhTriangleMeshShape
This commit is contained in:
parent
723c206d0f
commit
2cc9ff2176
@ -21,6 +21,7 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
|
||||
#include "BulletCollision/CollisionShapes/btSphereShape.h" //for raycasting
|
||||
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" //for raycasting
|
||||
#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h" //for raycasting
|
||||
#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
|
||||
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
|
||||
@ -407,6 +408,21 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans,con
|
||||
rcb.m_hitFraction = resultCallback.m_closestHitFraction;
|
||||
triangleMesh->performRaycast(&rcb,rayFromLocal,rayToLocal);
|
||||
}
|
||||
else if (collisionShape->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
{
|
||||
///optimized version for btScaledBvhTriangleMeshShape
|
||||
btScaledBvhTriangleMeshShape* scaledTriangleMesh = (btScaledBvhTriangleMeshShape*)collisionShape;
|
||||
btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)scaledTriangleMesh->getChildShape();
|
||||
|
||||
//scale the ray positions
|
||||
btVector3 scale = scaledTriangleMesh->getLocalScaling();
|
||||
btVector3 rayFromLocalScaled = rayFromLocal / scale;
|
||||
btVector3 rayToLocalScaled = rayToLocal / scale;
|
||||
|
||||
BridgeTriangleRaycastCallback rcb(rayFromLocalScaled, rayToLocalScaled, &resultCallback, collisionObjectWrap->getCollisionObject(), triangleMesh, colObjWorldTransform);
|
||||
rcb.m_hitFraction = resultCallback.m_closestHitFraction;
|
||||
triangleMesh->performRaycast(&rcb, rayFromLocalScaled, rayToLocalScaled);
|
||||
}
|
||||
else
|
||||
{
|
||||
//generic (slower) case
|
||||
|
Loading…
Reference in New Issue
Block a user