Optimizations
This commit is contained in:
parent
46d19bf550
commit
58df6cdaff
|
@ -127,8 +127,14 @@ void ConcaveMeshShape::computeOverlappingTriangles(const AABB& localAABB, List<V
|
||||||
List<int> overlappingNodes(allocator);
|
List<int> overlappingNodes(allocator);
|
||||||
mDynamicAABBTree.reportAllShapesOverlappingWithAABB(localAABB, overlappingNodes);
|
mDynamicAABBTree.reportAllShapesOverlappingWithAABB(localAABB, overlappingNodes);
|
||||||
|
|
||||||
|
const uint nbOverlappingNodes = overlappingNodes.size();
|
||||||
|
|
||||||
|
// Add space in the list of triangles vertices/normals for the new triangles
|
||||||
|
triangleVertices.addWithoutInit(nbOverlappingNodes * 3);
|
||||||
|
triangleVerticesNormals.addWithoutInit(nbOverlappingNodes * 3);
|
||||||
|
|
||||||
// For each overlapping node
|
// For each overlapping node
|
||||||
for (uint i=0; i < overlappingNodes.size(); i++) {
|
for (uint i=0; i < nbOverlappingNodes; i++) {
|
||||||
|
|
||||||
int nodeId = overlappingNodes[i];
|
int nodeId = overlappingNodes[i];
|
||||||
|
|
||||||
|
@ -136,18 +142,10 @@ void ConcaveMeshShape::computeOverlappingTriangles(const AABB& localAABB, List<V
|
||||||
int32* data = mDynamicAABBTree.getNodeDataInt(nodeId);
|
int32* data = mDynamicAABBTree.getNodeDataInt(nodeId);
|
||||||
|
|
||||||
// Get the triangle vertices for this node from the concave mesh shape
|
// Get the triangle vertices for this node from the concave mesh shape
|
||||||
Vector3 trianglePoints[3];
|
getTriangleVertices(data[0], data[1], &(triangleVertices[i * 3]));
|
||||||
getTriangleVertices(data[0], data[1], trianglePoints);
|
|
||||||
triangleVertices.add(trianglePoints[0]);
|
|
||||||
triangleVertices.add(trianglePoints[1]);
|
|
||||||
triangleVertices.add(trianglePoints[2]);
|
|
||||||
|
|
||||||
// Get the vertices normals of the triangle
|
// Get the vertices normals of the triangle
|
||||||
Vector3 verticesNormals[3];
|
getTriangleVerticesNormals(data[0], data[1], &(triangleVerticesNormals[i * 3]));
|
||||||
getTriangleVerticesNormals(data[0], data[1], verticesNormals);
|
|
||||||
triangleVerticesNormals.add(verticesNormals[0]);
|
|
||||||
triangleVerticesNormals.add(verticesNormals[1]);
|
|
||||||
triangleVerticesNormals.add(verticesNormals[2]);
|
|
||||||
|
|
||||||
// Compute the triangle shape ID
|
// Compute the triangle shape ID
|
||||||
shapeIds.add(computeTriangleShapeId(data[0], data[1]));
|
shapeIds.add(computeTriangleShapeId(data[0], data[1]));
|
||||||
|
|
|
@ -294,6 +294,17 @@ class List {
|
||||||
mSize++;
|
mSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a given numbers of elements at the end of the list but do not init them
|
||||||
|
void addWithoutInit(uint nbElements) {
|
||||||
|
|
||||||
|
// If we need to allocate more memory
|
||||||
|
if (mSize == mCapacity) {
|
||||||
|
reserve(mCapacity == 0 ? nbElements : (mCapacity + nbElements) * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
mSize += nbElements;
|
||||||
|
}
|
||||||
|
|
||||||
/// Try to find a given item of the list and return an iterator
|
/// Try to find a given item of the list and return an iterator
|
||||||
/// pointing to that element if it exists in the list. Otherwise,
|
/// pointing to that element if it exists in the list. Otherwise,
|
||||||
/// this method returns the end() iterator
|
/// this method returns the end() iterator
|
||||||
|
|
|
@ -433,8 +433,15 @@ LastFrameCollisionInfo* OverlappingPairs::addLastFrameInfoIfNecessary(uint64 pai
|
||||||
|
|
||||||
assert(pairIndex < mNbPairs);
|
assert(pairIndex < mNbPairs);
|
||||||
|
|
||||||
|
uint32 maxShapeId = shapeId1;
|
||||||
|
uint32 minShapeId = shapeId2;
|
||||||
|
if (shapeId1 < shapeId2) {
|
||||||
|
maxShapeId = shapeId2;
|
||||||
|
minShapeId = shapeId1;
|
||||||
|
}
|
||||||
|
|
||||||
// Try to get the corresponding last frame collision info
|
// Try to get the corresponding last frame collision info
|
||||||
const uint64 shapesId = pairNumbers(std::max(shapeId1, shapeId2), std::min(shapeId1, shapeId2));
|
const uint64 shapesId = pairNumbers(maxShapeId, minShapeId);
|
||||||
|
|
||||||
// If there is no collision info for those two shapes already
|
// If there is no collision info for those two shapes already
|
||||||
auto it = mLastFrameCollisionInfos[pairIndex].find(shapesId);
|
auto it = mLastFrameCollisionInfos[pairIndex].find(shapesId);
|
||||||
|
|
|
@ -222,7 +222,6 @@ void CollisionDetectionSystem::computeMiddlePhase(NarrowPhaseInput& narrowPhaseI
|
||||||
assert(mProxyShapesComponents.getBroadPhaseId(mOverlappingPairs.mProxyShapes1[i]) != mProxyShapesComponents.getBroadPhaseId(mOverlappingPairs.mProxyShapes2[i]));
|
assert(mProxyShapesComponents.getBroadPhaseId(mOverlappingPairs.mProxyShapes1[i]) != mProxyShapesComponents.getBroadPhaseId(mOverlappingPairs.mProxyShapes2[i]));
|
||||||
|
|
||||||
// Check that at least one body is enabled (active and awake) and not static
|
// Check that at least one body is enabled (active and awake) and not static
|
||||||
// TODO : Do not test this every frame
|
|
||||||
if (mOverlappingPairs.mIsActive[i]) {
|
if (mOverlappingPairs.mIsActive[i]) {
|
||||||
|
|
||||||
const Entity proxyShape1Entity = mOverlappingPairs.mProxyShapes1[i];
|
const Entity proxyShape1Entity = mOverlappingPairs.mProxyShapes1[i];
|
||||||
|
|
|
@ -320,7 +320,6 @@ class ContactSolverSystem {
|
||||||
RigidBodyComponents& mRigidBodyComponents;
|
RigidBodyComponents& mRigidBodyComponents;
|
||||||
|
|
||||||
/// Reference to the proxy-shapes components
|
/// Reference to the proxy-shapes components
|
||||||
// TODO : Do we really need to use this ?
|
|
||||||
ProxyShapeComponents& mProxyShapeComponents;
|
ProxyShapeComponents& mProxyShapeComponents;
|
||||||
|
|
||||||
/// True if the split impulse position correction is active
|
/// True if the split impulse position correction is active
|
||||||
|
|
Loading…
Reference in New Issue
Block a user