fixed memoryleak,
added RayTestSingle to CollisionWorld prepared to add VehicleDemo
This commit is contained in:
@@ -101,6 +101,7 @@ void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,Broadphase
|
||||
///this FindPair becomes really slow. Either sort the list to speedup the query, or
|
||||
///use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed.
|
||||
///we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address)
|
||||
///Also we can use a 2D bitmap, which can be useful for a future GPU implementation
|
||||
BroadphasePair* OverlappingPairCache::FindPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1)
|
||||
{
|
||||
BroadphasePair* foundPair = 0;
|
||||
|
||||
@@ -103,6 +103,8 @@ void CollisionWorld::PerformDiscreteCollisionDetection()
|
||||
m_pairCache->SetAabb(m_collisionObjects[i]->m_broadphaseHandle,aabbMin,aabbMax);
|
||||
}
|
||||
|
||||
m_pairCache->RefreshOverlappingPairs();
|
||||
|
||||
Dispatcher* dispatcher = GetDispatcher();
|
||||
if (dispatcher)
|
||||
dispatcher->DispatchAllCollisionPairs(&m_pairCache->GetOverlappingPair(0),m_pairCache->GetNumOverlappingPairs(),dispatchInfo);
|
||||
@@ -140,11 +142,11 @@ void CollisionWorld::RemoveCollisionObject(CollisionObject* collisionObject)
|
||||
}
|
||||
}
|
||||
|
||||
void RayTestSingle(const SimdTransform& rayFromTrans,const SimdTransform& rayToTrans,
|
||||
void CollisionWorld::RayTestSingle(const SimdTransform& rayFromTrans,const SimdTransform& rayToTrans,
|
||||
CollisionObject* collisionObject,
|
||||
const CollisionShape* collisionShape,
|
||||
const SimdTransform& colObjWorldTransform,
|
||||
CollisionWorld::RayResultCallback& resultCallback)
|
||||
RayResultCallback& resultCallback)
|
||||
{
|
||||
|
||||
SphereShape pointShape(0.0f);
|
||||
|
||||
@@ -204,8 +204,18 @@ public:
|
||||
return m_collisionObjects.size();
|
||||
}
|
||||
|
||||
/// RayTest performs a raycast on all objects in the CollisionWorld, and calls the resultCallback
|
||||
/// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback.
|
||||
void RayTest(const SimdVector3& rayFromWorld, const SimdVector3& rayToWorld, RayResultCallback& resultCallback);
|
||||
|
||||
/// RayTestSingle performs a raycast call and calls the resultCallback. It is used internally by RayTest.
|
||||
/// In a future implementation, we consider moving the ray test as a virtual method in CollisionShape.
|
||||
/// This allows more customization.
|
||||
void RayTestSingle(const SimdTransform& rayFromTrans,const SimdTransform& rayToTrans,
|
||||
CollisionObject* collisionObject,
|
||||
const CollisionShape* collisionShape,
|
||||
const SimdTransform& colObjWorldTransform,
|
||||
RayResultCallback& resultCallback);
|
||||
|
||||
void AddCollisionObject(CollisionObject* collisionObject,short int collisionFilterGroup=1,short int collisionFilterMask=1);
|
||||
|
||||
|
||||
@@ -85,6 +85,11 @@ void OptimizedBvh::Build(StridingMeshInterface* triangles)
|
||||
// OptimizedBvhNode* leafNodes = new OptimizedBvhNode;
|
||||
}
|
||||
|
||||
OptimizedBvh::~OptimizedBvh()
|
||||
{
|
||||
if (m_contiguousNodes)
|
||||
delete m_contiguousNodes;
|
||||
}
|
||||
|
||||
OptimizedBvhNode* OptimizedBvh::BuildTree (NodeArray& leafNodes,int startIndex,int endIndex)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ class OptimizedBvh
|
||||
|
||||
public:
|
||||
OptimizedBvh() :m_rootNode1(0), m_numNodes(0) { }
|
||||
virtual ~OptimizedBvh() {};
|
||||
virtual ~OptimizedBvh();
|
||||
|
||||
void Build(StridingMeshInterface* triangles);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user