Remove method to get last frame info from NarrowPhaseInfoBatch class
This commit is contained in:
parent
b62c0cf100
commit
f0fe97a41b
|
@ -248,7 +248,7 @@ void CollisionDetection::computeNarrowPhase() {
|
|||
// If there is no collision algorithm between those two kinds of shapes, skip it
|
||||
if (narrowPhaseAlgorithm != nullptr) {
|
||||
|
||||
LastFrameCollisionInfo* lastCollisionFrameInfo = mNarrowPhaseInfoBatch.getLastFrameCollisionInfo(batchIndex);
|
||||
LastFrameCollisionInfo* lastCollisionFrameInfo = mNarrowPhaseInfoBatch.lastFrameCollisionInfos[batchIndex];
|
||||
|
||||
// Use the narrow-phase collision detection algorithm to check
|
||||
// if there really is a collision. If a collision occurs, the
|
||||
|
|
|
@ -35,7 +35,7 @@ using namespace reactphysics3d;
|
|||
NarrowPhaseInfoBatch::NarrowPhaseInfoBatch(MemoryAllocator& allocator)
|
||||
: mMemoryAllocator(allocator), overlappingPairs(allocator), collisionShapes1(allocator), collisionShapes2(allocator),
|
||||
shape1ToWorldTransforms(allocator), shape2ToWorldTransforms(allocator),
|
||||
isColliding(allocator), contactPoints(allocator), collisionShapeAllocators(allocator) {
|
||||
isColliding(allocator), contactPoints(allocator), collisionShapeAllocators(allocator), lastFrameCollisionInfos(allocator) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,8 @@ void NarrowPhaseInfoBatch::addNarrowPhaseInfo(OverlappingPair* pair, CollisionSh
|
|||
|
||||
// Add a collision info for the two collision shapes into the overlapping pair (if not present yet)
|
||||
pair->addLastFrameInfoIfNecessary(shape1->getId(), shape2->getId());
|
||||
|
||||
lastFrameCollisionInfos.add(pair->getLastFrameCollisionInfo(shape1->getId(), shape2->getId()));
|
||||
}
|
||||
|
||||
// Add a new contact point
|
||||
|
@ -125,6 +127,7 @@ void NarrowPhaseInfoBatch::clear() {
|
|||
shape1ToWorldTransforms.clear();
|
||||
shape2ToWorldTransforms.clear();
|
||||
collisionShapeAllocators.clear();
|
||||
lastFrameCollisionInfos.clear();
|
||||
isColliding.clear();
|
||||
contactPoints.clear();
|
||||
}
|
||||
|
|
|
@ -78,6 +78,9 @@ struct NarrowPhaseInfoBatch {
|
|||
/// Memory allocators for the collision shape (Used to release TriangleShape memory in destructor)
|
||||
List<MemoryAllocator*> collisionShapeAllocators;
|
||||
|
||||
/// Collision infos of the previous frame
|
||||
List<LastFrameCollisionInfo*> lastFrameCollisionInfos;
|
||||
|
||||
/// Constructor
|
||||
NarrowPhaseInfoBatch(MemoryAllocator& allocator);
|
||||
|
||||
|
@ -101,9 +104,6 @@ struct NarrowPhaseInfoBatch {
|
|||
|
||||
/// Clear all the objects in the batch
|
||||
void clear();
|
||||
|
||||
/// Get the last collision frame info for temporal coherence
|
||||
LastFrameCollisionInfo* getLastFrameCollisionInfo(uint index) const;
|
||||
};
|
||||
|
||||
/// Return the number of objects in the batch
|
||||
|
@ -111,11 +111,6 @@ inline uint NarrowPhaseInfoBatch::getNbObjects() const {
|
|||
return overlappingPairs.size();
|
||||
}
|
||||
|
||||
// Get the last collision frame info for temporal coherence
|
||||
inline LastFrameCollisionInfo* NarrowPhaseInfoBatch::getLastFrameCollisionInfo(uint index) const {
|
||||
return overlappingPairs[index]->getLastFrameCollisionInfo(collisionShapes1[index]->getId(), collisionShapes2[index]->getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -64,7 +64,7 @@ void CapsuleVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& nar
|
|||
for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) {
|
||||
|
||||
// Get the last frame collision info
|
||||
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.getLastFrameCollisionInfo(batchIndex);
|
||||
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.lastFrameCollisionInfos[batchIndex];
|
||||
|
||||
lastFrameCollisionInfo->wasUsingGJK = true;
|
||||
lastFrameCollisionInfo->wasUsingSAT = false;
|
||||
|
|
|
@ -54,7 +54,7 @@ void ConvexPolyhedronVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoB
|
|||
for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) {
|
||||
|
||||
// Get the last frame collision info
|
||||
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.getLastFrameCollisionInfo(batchIndex);
|
||||
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.lastFrameCollisionInfos[batchIndex];
|
||||
|
||||
lastFrameCollisionInfo->wasUsingSAT = true;
|
||||
lastFrameCollisionInfo->wasUsingGJK = false;
|
||||
|
|
|
@ -92,7 +92,7 @@ void GJKAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uin
|
|||
VoronoiSimplex simplex;
|
||||
|
||||
// Get the last collision frame info
|
||||
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.getLastFrameCollisionInfo(batchIndex);
|
||||
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.lastFrameCollisionInfos[batchIndex];
|
||||
|
||||
// Get the previous point V (last cached separating axis)
|
||||
Vector3 v;
|
||||
|
|
|
@ -494,7 +494,7 @@ void SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseIn
|
|||
Vector3 minEdgeVsEdgeSeparatingAxisPolyhedron2Space;
|
||||
bool isShape1Triangle = polyhedron1->getName() == CollisionShapeName::TRIANGLE;
|
||||
|
||||
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.getLastFrameCollisionInfo(batchIndex);
|
||||
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.lastFrameCollisionInfos[batchIndex];
|
||||
|
||||
// If the last frame collision info is valid and was also using SAT algorithm
|
||||
if (lastFrameCollisionInfo->isValid && lastFrameCollisionInfo->wasUsingSAT) {
|
||||
|
|
|
@ -62,7 +62,7 @@ void SphereVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narr
|
|||
narrowPhaseInfoBatch.collisionShapes2[batchIndex]->getType() == CollisionShapeType::SPHERE);
|
||||
|
||||
// Get the last frame collision info
|
||||
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.getLastFrameCollisionInfo(batchIndex);
|
||||
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.lastFrameCollisionInfos[batchIndex];
|
||||
|
||||
lastFrameCollisionInfo->wasUsingGJK = true;
|
||||
lastFrameCollisionInfo->wasUsingSAT = false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user