From 58df6cdaff4b90fd7c97c0df023a05c380393683 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Fri, 22 Nov 2019 21:31:51 +0100 Subject: [PATCH] Optimizations --- src/collision/shapes/ConcaveMeshShape.cpp | 20 +++++++++----------- src/containers/List.h | 11 +++++++++++ src/engine/OverlappingPairs.cpp | 9 ++++++++- src/systems/CollisionDetectionSystem.cpp | 1 - src/systems/ContactSolverSystem.h | 1 - 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/collision/shapes/ConcaveMeshShape.cpp b/src/collision/shapes/ConcaveMeshShape.cpp index 90e26078..240defd8 100644 --- a/src/collision/shapes/ConcaveMeshShape.cpp +++ b/src/collision/shapes/ConcaveMeshShape.cpp @@ -127,8 +127,14 @@ void ConcaveMeshShape::computeOverlappingTriangles(const AABB& localAABB, List overlappingNodes(allocator); 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 (uint i=0; i < overlappingNodes.size(); i++) { + for (uint i=0; i < nbOverlappingNodes; i++) { int nodeId = overlappingNodes[i]; @@ -136,18 +142,10 @@ void ConcaveMeshShape::computeOverlappingTriangles(const AABB& localAABB, List