From cd4bc7573fca64c26675567a771e02559274d796 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Sat, 5 Sep 2020 15:06:51 +0200 Subject: [PATCH] Rename the List class into Array --- CHANGELOG.md | 3 +- .../collision/CollisionCallback.h | 34 +- .../collision/ContactManifold.h | 2 +- .../collision/HalfEdgeStructure.h | 16 +- .../collision/OverlapCallback.h | 20 +- .../reactphysics3d/collision/TriangleMesh.h | 4 +- .../collision/broadphase/DynamicAABBTree.h | 10 +- .../collision/narrowphase/GJK/GJKAlgorithm.h | 4 +- .../narrowphase/NarrowPhaseInfoBatch.h | 4 +- .../collision/narrowphase/NarrowPhaseInput.h | 2 +- .../collision/shapes/CollisionShape.h | 6 +- .../collision/shapes/ConcaveMeshShape.h | 10 +- .../collision/shapes/ConcaveShape.h | 4 +- .../collision/shapes/HeightFieldShape.h | 4 +- .../components/ColliderComponents.h | 12 +- .../components/CollisionBodyComponents.h | 12 +- .../components/RigidBodyComponents.h | 16 +- .../containers/{List.h => Array.h} | 95 ++-- include/reactphysics3d/containers/Set.h | 10 +- include/reactphysics3d/engine/EntityManager.h | 6 +- include/reactphysics3d/engine/Islands.h | 14 +- .../reactphysics3d/engine/OverlappingPairs.h | 8 +- include/reactphysics3d/engine/PhysicsWorld.h | 10 +- .../mathematics/mathematics_functions.h | 12 +- include/reactphysics3d/reactphysics3d.h | 2 +- .../reactphysics3d/systems/BroadPhaseSystem.h | 6 +- .../systems/CollisionDetectionSystem.h | 112 ++--- .../systems/ContactSolverSystem.h | 10 +- include/reactphysics3d/utils/DebugRenderer.h | 32 +- include/reactphysics3d/utils/DefaultLogger.h | 4 +- include/reactphysics3d/utils/Logger.h | 2 +- include/reactphysics3d/utils/Profiler.h | 2 +- src/body/CollisionBody.cpp | 18 +- src/body/RigidBody.cpp | 12 +- src/collision/CollisionCallback.cpp | 6 +- src/collision/HalfEdgeStructure.cpp | 2 +- src/collision/OverlapCallback.cpp | 2 +- src/collision/PolyhedronMesh.cpp | 2 +- src/collision/broadphase/DynamicAABBTree.cpp | 10 +- .../CapsuleVsConvexPolyhedronAlgorithm.cpp | 2 +- .../narrowphase/GJK/GJKAlgorithm.cpp | 4 +- .../narrowphase/SAT/SATAlgorithm.cpp | 14 +- .../SphereVsConvexPolyhedronAlgorithm.cpp | 2 +- src/collision/shapes/BoxShape.cpp | 12 +- src/collision/shapes/ConcaveMeshShape.cpp | 10 +- src/collision/shapes/ConvexMeshShape.cpp | 2 +- src/collision/shapes/HeightFieldShape.cpp | 10 +- src/components/ColliderComponents.cpp | 16 +- src/components/CollisionBodyComponents.cpp | 16 +- src/components/RigidBodyComponents.cpp | 30 +- src/engine/PhysicsWorld.cpp | 26 +- src/mathematics/mathematics_functions.cpp | 18 +- src/systems/BroadPhaseSystem.cpp | 6 +- src/systems/CollisionDetectionSystem.cpp | 110 ++--- src/systems/ContactSolverSystem.cpp | 2 +- test/CMakeLists.txt | 2 +- test/main.cpp | 4 +- test/tests/collision/TestDynamicAABBTree.h | 4 +- test/tests/collision/TestHalfEdgeStructure.h | 20 +- test/tests/containers/TestArray.h | 449 ++++++++++++++++++ test/tests/containers/TestList.h | 449 ------------------ test/tests/containers/TestSet.h | 20 +- .../mathematics/TestMathematicsFunctions.h | 16 +- 63 files changed, 893 insertions(+), 891 deletions(-) rename include/reactphysics3d/containers/{List.h => Array.h} (84%) create mode 100644 test/tests/containers/TestArray.h delete mode 100644 test/tests/containers/TestList.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 89988769..fcb86105 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ do not hesitate to take a look at the user manual. ### Changed - - Rolling resistance constraint is not solved anymore in the solver. Angular damping needs to be used instead to simulate this. + - Rolling resistance constraint is not solved anymore in the solver. Angular damping needs to be used instead to simulate this + - The List class has been renamed to Array ### Removed diff --git a/include/reactphysics3d/collision/CollisionCallback.h b/include/reactphysics3d/collision/CollisionCallback.h index e1210fad..a398a3c9 100644 --- a/include/reactphysics3d/collision/CollisionCallback.h +++ b/include/reactphysics3d/collision/CollisionCallback.h @@ -27,7 +27,7 @@ #define REACTPHYSICS3D_COLLISION_CALLBACK_H // Libraries -#include +#include #include #include @@ -114,7 +114,7 @@ class CollisionCallback { // Class ContactPair /** * This class represents the contact between two colliders of the physics world. - * A contact pair contains a list of contact points. + * A contact pair contains an array of contact points. */ class ContactPair { @@ -141,7 +141,7 @@ class CollisionCallback { const reactphysics3d::ContactPair& mContactPair; /// Pointer to the contact points - List* mContactPoints; + Array* mContactPoints; /// Reference to the physics world PhysicsWorld& mWorld; @@ -152,7 +152,7 @@ class CollisionCallback { // -------------------- Methods -------------------- // /// Constructor - ContactPair(const reactphysics3d::ContactPair& contactPair, List* contactPoints, + ContactPair(const reactphysics3d::ContactPair& contactPair, Array* contactPoints, PhysicsWorld& world, bool mIsLostContactPair); public: @@ -226,23 +226,23 @@ class CollisionCallback { // -------------------- Attributes -------------------- // - /// Pointer to the list of contact pairs (contains contacts and triggers events) - List* mContactPairs; + /// Pointer to the array of contact pairs (contains contacts and triggers events) + Array* mContactPairs; - /// Pointer to the list of contact manifolds - List* mContactManifolds; + /// Pointer to the array of contact manifolds + Array* mContactManifolds; /// Pointer to the contact points - List* mContactPoints; + Array* mContactPoints; - /// Pointer to the list of lost contact pairs (contains contacts and triggers events) - List& mLostContactPairs; + /// Pointer to the array of lost contact pairs (contains contacts and triggers events) + Array& mLostContactPairs; - /// List of indices of the mContactPairs list that are contact events (not overlap/triggers) - List mContactPairsIndices; + /// Array of indices in the mContactPairs array that are contact events (not overlap/triggers) + Array mContactPairsIndices; - /// List of indices of the mLostContactPairs list that are contact events (not overlap/triggers) - List mLostContactPairsIndices; + /// Array of indices in the mLostContactPairs array that are contact events (not overlap/triggers) + Array mLostContactPairsIndices; /// Reference to the physics world PhysicsWorld& mWorld; @@ -250,8 +250,8 @@ class CollisionCallback { // -------------------- Methods -------------------- // /// Constructor - CallbackData(List* contactPairs, List* manifolds, - List* contactPoints, List& lostContactPairs, + CallbackData(Array* contactPairs, Array* manifolds, + Array* contactPoints, Array& lostContactPairs, PhysicsWorld& world); /// Deleted copy constructor diff --git a/include/reactphysics3d/collision/ContactManifold.h b/include/reactphysics3d/collision/ContactManifold.h index b76906da..738e1565 100644 --- a/include/reactphysics3d/collision/ContactManifold.h +++ b/include/reactphysics3d/collision/ContactManifold.h @@ -62,7 +62,7 @@ class ContactManifold { // -------------------- Attributes -------------------- // - /// Index of the first contact point of the manifold in the list of contact points + /// Index of the first contact point of the manifold in the array of contact points uint contactPointsIndex; /// Entity of the first body in contact diff --git a/include/reactphysics3d/collision/HalfEdgeStructure.h b/include/reactphysics3d/collision/HalfEdgeStructure.h index a8d5ac2e..8b9f8e4a 100644 --- a/include/reactphysics3d/collision/HalfEdgeStructure.h +++ b/include/reactphysics3d/collision/HalfEdgeStructure.h @@ -54,13 +54,13 @@ class HalfEdgeStructure { /// Face struct Face { uint edgeIndex; // Index of an half-edge of the face - List faceVertices; // Index of the vertices of the face + Array faceVertices; // Index of the vertices of the face /// Constructor Face(MemoryAllocator& allocator) : faceVertices(allocator) {} /// Constructor - Face(List vertices) : faceVertices(vertices) {} + Face(Array vertices) : faceVertices(vertices) {} }; /// Vertex @@ -78,13 +78,13 @@ class HalfEdgeStructure { MemoryAllocator& mAllocator; /// All the faces - List mFaces; + Array mFaces; /// All the vertices - List mVertices; + Array mVertices; /// All the half-edges - List mEdges; + Array mEdges; public: @@ -103,7 +103,7 @@ class HalfEdgeStructure { uint addVertex(uint vertexPointIndex); /// Add a face - void addFace(List faceVertices); + void addFace(Array faceVertices); /// Return the number of faces uint getNbFaces() const; @@ -137,10 +137,10 @@ RP3D_FORCE_INLINE uint32 HalfEdgeStructure::addVertex(uint32 vertexPointIndex) { // Add a face /** - * @param faceVertices List of the vertices in a face (ordered in CCW order as seen from outside + * @param faceVertices Array of the vertices in a face (ordered in CCW order as seen from outside * the polyhedron */ -RP3D_FORCE_INLINE void HalfEdgeStructure::addFace(List faceVertices) { +RP3D_FORCE_INLINE void HalfEdgeStructure::addFace(Array faceVertices) { // Create a new face Face face(faceVertices); diff --git a/include/reactphysics3d/collision/OverlapCallback.h b/include/reactphysics3d/collision/OverlapCallback.h index e0126132..aa0b55de 100644 --- a/include/reactphysics3d/collision/OverlapCallback.h +++ b/include/reactphysics3d/collision/OverlapCallback.h @@ -27,7 +27,7 @@ #define REACTPHYSICS3D_OVERLAP_CALLBACK_H // Libraries -#include +#include #include /// ReactPhysics3D namespace @@ -131,17 +131,17 @@ class OverlapCallback { // -------------------- Attributes -------------------- // - /// Reference to the list of contact pairs (contains contacts and triggers events) - List& mContactPairs; + /// Reference to the array of contact pairs (contains contacts and triggers events) + Array& mContactPairs; - /// Reference to the list of lost contact pairs (contains contacts and triggers events) - List& mLostContactPairs; + /// Reference to the array of lost contact pairs (contains contacts and triggers events) + Array& mLostContactPairs; - /// List of indices of the mContactPairs list that are overlap/triggers events (not contact events) - List mContactPairsIndices; + /// Array of indices of the mContactPairs array that are overlap/triggers events (not contact events) + Array mContactPairsIndices; - /// List of indices of the mLostContactPairs list that are overlap/triggers events (not contact events) - List mLostContactPairsIndices; + /// Array of indices of the mLostContactPairs array that are overlap/triggers events (not contact events) + Array mLostContactPairsIndices; /// Reference to the physics world PhysicsWorld& mWorld; @@ -149,7 +149,7 @@ class OverlapCallback { // -------------------- Methods -------------------- // /// Constructor - CallbackData(List& contactPairs, List& lostContactPairs, bool onlyReportTriggers, PhysicsWorld& world); + CallbackData(Array& contactPairs, Array& lostContactPairs, bool onlyReportTriggers, PhysicsWorld& world); /// Deleted copy constructor CallbackData(const CallbackData& callbackData) = delete; diff --git a/include/reactphysics3d/collision/TriangleMesh.h b/include/reactphysics3d/collision/TriangleMesh.h index 87163407..2088a312 100644 --- a/include/reactphysics3d/collision/TriangleMesh.h +++ b/include/reactphysics3d/collision/TriangleMesh.h @@ -28,7 +28,7 @@ // Libraries #include -#include +#include #include namespace reactphysics3d { @@ -49,7 +49,7 @@ class TriangleMesh { protected: /// All the triangle arrays of the mesh (one triangle array per part) - List mTriangleArrays; + Array mTriangleArrays; /// Constructor TriangleMesh(reactphysics3d::MemoryAllocator& allocator); diff --git a/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h b/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h index 1ff0aa67..a354de7c 100644 --- a/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h +++ b/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h @@ -58,7 +58,7 @@ struct TreeNode { // -------------------- Attributes -------------------- // - // A node is either in the tree (has a parent) or in the free nodes list + // A node is either in the tree (has a parent) or in the free nodes array // (has a next node) union { @@ -149,7 +149,7 @@ class DynamicAABBTree { /// ID of the root node of the tree int32 mRootNodeID; - /// ID of the first node of the list of free (allocated) nodes in the tree that we can use + /// ID of the first node of the array of free (allocated) nodes in the tree that we can use int32 mFreeNodeID; /// Number of allocated nodes in the tree @@ -236,11 +236,11 @@ class DynamicAABBTree { void* getNodeDataPointer(int32 nodeID) const; /// Report all shapes overlapping with all the shapes in the map in parameter - void reportAllShapesOverlappingWithShapes(const List& nodesToTest, size_t startIndex, - size_t endIndex, List>& outOverlappingNodes) const; + void reportAllShapesOverlappingWithShapes(const Array& nodesToTest, size_t startIndex, + size_t endIndex, Array>& outOverlappingNodes) const; /// Report all shapes overlapping with the AABB given in parameter. - void reportAllShapesOverlappingWithAABB(const AABB& aabb, List& overlappingNodes) const; + void reportAllShapesOverlappingWithAABB(const AABB& aabb, Array& overlappingNodes) const; /// Ray casting method void raycast(const Ray& ray, DynamicAABBTreeRaycastCallback& callback) const; diff --git a/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h b/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h index 2aba4e73..2383be1f 100644 --- a/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h @@ -39,7 +39,7 @@ struct NarrowPhaseInfoBatch; class ConvexShape; class Profiler; class VoronoiSimplex; -template class List; +template class Array; // Constants constexpr decimal REL_ERROR = decimal(1.0e-3); @@ -98,7 +98,7 @@ class GJKAlgorithm { /// Compute a contact info if the two bounding volumes collide. void testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, - uint batchNbItems, List& gjkResults); + uint batchNbItems, Array& gjkResults); #ifdef IS_RP3D_PROFILING_ENABLED diff --git a/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h b/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h index f4f94d38..fd296536 100644 --- a/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h +++ b/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h @@ -85,7 +85,7 @@ struct NarrowPhaseInfoBatch { /// Number of contact points uint8 nbContactPoints; - /// List of contact points created during the narrow-phase + /// Array of contact points created during the narrow-phase ContactPointInfo contactPoints[NB_MAX_CONTACT_POINTS_IN_NARROWPHASE_INFO]; /// Constructor @@ -114,7 +114,7 @@ struct NarrowPhaseInfoBatch { public: /// For each collision test, we keep some meta data - List narrowPhaseInfos; + Array narrowPhaseInfos; /// Constructor NarrowPhaseInfoBatch(OverlappingPairs& overlappingPairs, MemoryAllocator& allocator); diff --git a/include/reactphysics3d/collision/narrowphase/NarrowPhaseInput.h b/include/reactphysics3d/collision/narrowphase/NarrowPhaseInput.h index 9f64574a..b3770176 100644 --- a/include/reactphysics3d/collision/narrowphase/NarrowPhaseInput.h +++ b/include/reactphysics3d/collision/narrowphase/NarrowPhaseInput.h @@ -27,7 +27,7 @@ #define REACTPHYSICS3D_NARROW_PHASE_INPUT_H // Libraries -#include +#include #include #include diff --git a/include/reactphysics3d/collision/shapes/CollisionShape.h b/include/reactphysics3d/collision/shapes/CollisionShape.h index beca8bcb..4c8c5561 100644 --- a/include/reactphysics3d/collision/shapes/CollisionShape.h +++ b/include/reactphysics3d/collision/shapes/CollisionShape.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include /// ReactPhysics3D namespace namespace reactphysics3d { @@ -76,8 +76,8 @@ class CollisionShape { /// Unique identifier of the shape inside an overlapping pair uint32 mId; - /// List of the colliders associated with this shape - List mColliders; + /// Array of the colliders associated with this shape + Array mColliders; #ifdef IS_RP3D_PROFILING_ENABLED diff --git a/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h b/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h index dab3b9dd..106f0844 100644 --- a/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h +++ b/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h @@ -29,7 +29,7 @@ // Libraries #include #include -#include +#include namespace reactphysics3d { @@ -72,7 +72,7 @@ class ConcaveMeshRaycastCallback : public DynamicAABBTreeRaycastCallback { private : - List mHitAABBNodes; + Array mHitAABBNodes; const DynamicAABBTree& mDynamicAABBTree; const ConcaveMeshShape& mConcaveMeshShape; Collider* mCollider; @@ -156,7 +156,7 @@ class ConcaveMeshShape : public ConcaveShape { /// Insert all the triangles into the dynamic AABB tree void initBVHTree(); - /// Return the three vertices coordinates (in the list outTriangleVertices) of a triangle + /// Return the three vertices coordinates (in the array outTriangleVertices) of a triangle void getTriangleVertices(uint subPart, uint triangleIndex, Vector3* outTriangleVertices) const; /// Return the three vertex normals (in the array outVerticesNormals) of a triangle @@ -166,8 +166,8 @@ class ConcaveMeshShape : public ConcaveShape { uint computeTriangleShapeId(uint subPart, uint triangleIndex) const; /// Compute all the triangles of the mesh that are overlapping with the AABB in parameter - virtual void computeOverlappingTriangles(const AABB& localAABB, List& triangleVertices, - List &triangleVerticesNormals, List& shapeIds, + virtual void computeOverlappingTriangles(const AABB& localAABB, Array& triangleVertices, + Array &triangleVerticesNormals, Array& shapeIds, MemoryAllocator& allocator) const override; /// Destructor diff --git a/include/reactphysics3d/collision/shapes/ConcaveShape.h b/include/reactphysics3d/collision/shapes/ConcaveShape.h index 3ee13b42..b49f2e27 100644 --- a/include/reactphysics3d/collision/shapes/ConcaveShape.h +++ b/include/reactphysics3d/collision/shapes/ConcaveShape.h @@ -111,8 +111,8 @@ class ConcaveShape : public CollisionShape { virtual bool isPolyhedron() const override; /// Use a callback method on all triangles of the concave shape inside a given AABB - virtual void computeOverlappingTriangles(const AABB& localAABB, List& triangleVertices, - List& triangleVerticesNormals, List& shapeIds, + virtual void computeOverlappingTriangles(const AABB& localAABB, Array& triangleVertices, + Array& triangleVerticesNormals, Array& shapeIds, MemoryAllocator& allocator) const=0; /// Compute and return the volume of the collision shape diff --git a/include/reactphysics3d/collision/shapes/HeightFieldShape.h b/include/reactphysics3d/collision/shapes/HeightFieldShape.h index a6405334..c991de12 100644 --- a/include/reactphysics3d/collision/shapes/HeightFieldShape.h +++ b/include/reactphysics3d/collision/shapes/HeightFieldShape.h @@ -152,8 +152,8 @@ class HeightFieldShape : public ConcaveShape { virtual void getLocalBounds(Vector3& min, Vector3& max) const override; /// Use a callback method on all triangles of the concave shape inside a given AABB - virtual void computeOverlappingTriangles(const AABB& localAABB, List& triangleVertices, - List& triangleVerticesNormals, List& shapeIds, + virtual void computeOverlappingTriangles(const AABB& localAABB, Array& triangleVertices, + Array& triangleVerticesNormals, Array& shapeIds, MemoryAllocator& allocator) const override; /// Return the string representation of the shape diff --git a/include/reactphysics3d/components/ColliderComponents.h b/include/reactphysics3d/components/ColliderComponents.h index 8207309c..e6c4eb20 100644 --- a/include/reactphysics3d/components/ColliderComponents.h +++ b/include/reactphysics3d/components/ColliderComponents.h @@ -90,8 +90,8 @@ class ColliderComponents : public Components { /// Array with the local-to-world transforms of the colliders Transform* mLocalToWorldTransforms; - /// Array with the list of involved overlapping pairs for each collider - List* mOverlappingPairs; + /// Array with the involved overlapping pairs for each collider + Array* mOverlappingPairs; /// True if the size of the collision shape associated with the collider /// has been changed by the user @@ -194,8 +194,8 @@ class ColliderComponents : public Components { /// Set the local-to-world transform of a collider void setLocalToWorldTransform(Entity colliderEntity, const Transform& transform); - /// Return a reference to the list of overlapping pairs for a given collider - List& getOverlappingPairs(Entity colliderEntity); + /// Return a reference to the array of overlapping pairs for a given collider + Array& getOverlappingPairs(Entity colliderEntity); /// Return true if the size of collision shape of the collider has been changed by the user bool getHasCollisionShapeChangedSize(Entity colliderEntity) const; @@ -329,8 +329,8 @@ RP3D_FORCE_INLINE void ColliderComponents::setLocalToWorldTransform(Entity colli mLocalToWorldTransforms[mMapEntityToComponentIndex[colliderEntity]] = transform; } -// Return a reference to the list of overlapping pairs for a given collider -RP3D_FORCE_INLINE List& ColliderComponents::getOverlappingPairs(Entity colliderEntity) { +// Return a reference to the array of overlapping pairs for a given collider +RP3D_FORCE_INLINE Array& ColliderComponents::getOverlappingPairs(Entity colliderEntity) { assert(mMapEntityToComponentIndex.containsKey(colliderEntity)); diff --git a/include/reactphysics3d/components/CollisionBodyComponents.h b/include/reactphysics3d/components/CollisionBodyComponents.h index 08141341..a9ddd003 100644 --- a/include/reactphysics3d/components/CollisionBodyComponents.h +++ b/include/reactphysics3d/components/CollisionBodyComponents.h @@ -57,8 +57,8 @@ class CollisionBodyComponents : public Components { /// Array of pointers to the corresponding bodies CollisionBody** mBodies; - /// Array with the list of colliders of each body - List* mColliders; + /// Array with the colliders of each body + Array* mColliders; /// Array of boolean values to know if the body is active. bool* mIsActive; @@ -113,8 +113,8 @@ class CollisionBodyComponents : public Components { /// Return a pointer to a body CollisionBody* getBody(Entity bodyEntity); - /// Return the list of colliders of a body - const List& getColliders(Entity bodyEntity) const; + /// Return the array of colliders of a body + const Array& getColliders(Entity bodyEntity) const; /// Return true if the body is active bool getIsActive(Entity bodyEntity) const; @@ -153,8 +153,8 @@ RP3D_FORCE_INLINE CollisionBody *CollisionBodyComponents::getBody(Entity bodyEnt return mBodies[mMapEntityToComponentIndex[bodyEntity]]; } -// Return the list of colliders of a body -RP3D_FORCE_INLINE const List& CollisionBodyComponents::getColliders(Entity bodyEntity) const { +// Return the array of colliders of a body +RP3D_FORCE_INLINE const Array& CollisionBodyComponents::getColliders(Entity bodyEntity) const { assert(mMapEntityToComponentIndex.containsKey(bodyEntity)); diff --git a/include/reactphysics3d/components/RigidBodyComponents.h b/include/reactphysics3d/components/RigidBodyComponents.h index 45d986e8..69266262 100644 --- a/include/reactphysics3d/components/RigidBodyComponents.h +++ b/include/reactphysics3d/components/RigidBodyComponents.h @@ -145,11 +145,11 @@ class RigidBodyComponents : public Components { /// Array with the boolean value to know if the body has already been added into an island bool* mIsAlreadyInIsland; - /// For each body, the list of joints entities the body is part of - List* mJoints; + /// For each body, the array of joints entities the body is part of + Array* mJoints; - /// For each body, the list of the indices of contact pairs in which the body is involved - List* mContactPairs; + /// For each body, the array of the indices of contact pairs in which the body is involved + Array* mContactPairs; // -------------------- Methods -------------------- // @@ -342,8 +342,8 @@ class RigidBodyComponents : public Components { /// Set the value to know if the entity is already in an island void setIsAlreadyInIsland(Entity bodyEntity, bool isAlreadyInIsland); - /// Return the list of joints of a body - const List& getJoints(Entity bodyEntity) const; + /// Return the array of joints of a body + const Array& getJoints(Entity bodyEntity) const; /// Add a joint to a body component void addJointToBody(Entity bodyEntity, Entity jointEntity); @@ -769,8 +769,8 @@ RP3D_FORCE_INLINE void RigidBodyComponents::setIsAlreadyInIsland(Entity bodyEnti mIsAlreadyInIsland[mMapEntityToComponentIndex[bodyEntity]] = isAlreadyInIsland; } -// Return the list of joints of a body -RP3D_FORCE_INLINE const List& RigidBodyComponents::getJoints(Entity bodyEntity) const { +// Return the array of joints of a body +RP3D_FORCE_INLINE const Array& RigidBodyComponents::getJoints(Entity bodyEntity) const { assert(mMapEntityToComponentIndex.containsKey(bodyEntity)); return mJoints[mMapEntityToComponentIndex[bodyEntity]]; diff --git a/include/reactphysics3d/containers/List.h b/include/reactphysics3d/containers/Array.h similarity index 84% rename from include/reactphysics3d/containers/List.h rename to include/reactphysics3d/containers/Array.h index 651a2961..b48c8717 100755 --- a/include/reactphysics3d/containers/List.h +++ b/include/reactphysics3d/containers/Array.h @@ -23,8 +23,8 @@ * * ********************************************************************************/ -#ifndef REACTPHYSICS3D_LIST_H -#define REACTPHYSICS3D_LIST_H +#ifndef REACTPHYSICS3D_ARRAY_H +#define REACTPHYSICS3D_ARRAY_H // Libraries #include @@ -36,24 +36,24 @@ namespace reactphysics3d { -// Class List +// Class Array /** - * This class represents a simple generic list with custom memory allocator. + * This class represents a simple dynamic array with custom memory allocator. */ template -class List { +class Array { private: // -------------------- Attributes -------------------- // - /// Buffer for the list elements + /// Buffer for the array elements T* mBuffer; - /// Number of elements in the list + /// Number of elements in the array uint32 mSize; - /// Number of allocated elements in the list + /// Number of allocated elements in the array uint32 mCapacity; /// Memory allocator @@ -63,7 +63,7 @@ class List { /// Class Iterator /** - * This class represents an iterator for the List + * This class represents an iterator for the array */ class Iterator { @@ -198,7 +198,7 @@ class List { bool operator==(const Iterator& iterator) const { assert(mCurrentIndex >= 0 && mCurrentIndex <= mSize); - // If both iterators points to the end of the list + // If both iterators points to the end of the array if (mCurrentIndex == mSize && iterator.mCurrentIndex == iterator.mSize) { return true; } @@ -212,14 +212,14 @@ class List { } /// Frienship - friend class List; + friend class Array; }; // -------------------- Methods -------------------- // /// Constructor - List(MemoryAllocator& allocator, uint32 capacity = 0) + Array(MemoryAllocator& allocator, uint32 capacity = 0) : mBuffer(nullptr), mSize(0), mCapacity(0), mAllocator(allocator) { if (capacity > 0) { @@ -230,24 +230,24 @@ class List { } /// Copy constructor - List(const List& list) : mBuffer(nullptr), mSize(0), mCapacity(0), mAllocator(list.mAllocator) { + Array(const Array& array) : mBuffer(nullptr), mSize(0), mCapacity(0), mAllocator(array.mAllocator) { // If we need to allocate more memory - if (list.mCapacity > 0) { - reserve(list.mCapacity); + if (array.mCapacity > 0) { + reserve(array.mCapacity); } - // All all the elements of the list to the current one - addRange(list); + // All all the elements of the array to the current one + addRange(array); } /// Destructor - ~List() { + ~Array() { // If elements have been allocated if (mCapacity > 0) { - // Clear the list + // Clear the array clear(true); } } @@ -284,7 +284,7 @@ class List { mCapacity = capacity; } - /// Add an element into the list + /// Add an element into the array void add(const T& element) { // If we need to allocate more memory @@ -298,7 +298,7 @@ class List { mSize++; } - /// Add an element into the list by constructing it directly into the list (in order to avoid a copy) + /// Add an element into the array by constructing it directly into the array (in order to avoid a copy) template void emplace(Ts&&... args) { @@ -313,7 +313,7 @@ class List { mSize++; } - /// Add a given numbers of elements at the end of the list but do not init them + /// Add a given numbers of elements at the end of the array but do not init them void addWithoutInit(uint32 nbElements) { // If we need to allocate more memory @@ -324,8 +324,8 @@ class List { mSize += nbElements; } - /// Try to find a given item of the list and return an iterator - /// pointing to that element if it exists in the list. Otherwise, + /// Try to find a given item of the array and return an iterator + /// pointing to that element if it exists in the array. Otherwise, /// this method returns the end() iterator Iterator find(const T& element) { @@ -338,19 +338,19 @@ class List { return end(); } - /// Look for an element in the list and remove it + /// Look for an element in the array and remove it Iterator remove(const T& element) { return remove(find(element)); } - /// Remove an element from the list and return a iterator + /// Remove an element from the array and return a iterator /// pointing to the element after the removed one (or end() if none) Iterator remove(const Iterator& it) { assert(it.mBuffer == mBuffer); return removeAt(it.mCurrentIndex); } - /// Remove an element from the list at a given index (all the following items will be moved) + /// Remove an element from the array at a given index (all the following items will be moved) Iterator removeAt(uint32 index) { assert(index < mSize); @@ -379,31 +379,32 @@ class List { mBuffer[index] = mBuffer[mSize - 1]; - // Call the destructor of the last element + // Call the destructor of the last element mBuffer[mSize - 1].~T(); mSize--; } - /// Append another list at the end of the current one - void addRange(const List& list) { + /// Remove an element from the array at a given index and replace it by the last one of the array (if any) + /// Append another array at the end of the current one + void addRange(const Array& array) { // If we need to allocate more memory - if (mSize + list.size() > mCapacity) { + if (mSize + array.size() > mCapacity) { // Allocate memory - reserve(mSize + list.size()); + reserve(mSize + array.size()); } - // Add the elements of the list to the current one - for(uint32 i=0; i(mBuffer + mSize)) T(list[i]); + new (reinterpret_cast(mBuffer + mSize)) T(array[i]); mSize++; } } - /// Clear the list + /// Clear the array void clear(bool releaseMemory = false) { // Call the destructor of each element @@ -424,12 +425,12 @@ class List { } } - /// Return the number of elements in the list + /// Return the number of elements in the array uint32 size() const { return mSize; } - /// Return the capacity of the list + /// Return the capacity of the array uint32 capacity() const { return mCapacity; } @@ -447,12 +448,12 @@ class List { } /// Overloaded equality operator - bool operator==(const List& list) const { + bool operator==(const Array& array) const { - if (mSize != list.mSize) return false; + if (mSize != array.mSize) return false; for (uint32 i=0; i < mSize; i++) { - if (mBuffer[i] != list[i]) { + if (mBuffer[i] != array[i]) { return false; } } @@ -461,21 +462,21 @@ class List { } /// Overloaded not equal operator - bool operator!=(const List& list) const { + bool operator!=(const Array& array) const { - return !((*this) == list); + return !((*this) == array); } /// Overloaded assignment operator - List& operator=(const List& list) { + Array& operator=(const Array& array) { - if (this != &list) { + if (this != &array) { // Clear all the elements clear(); - // Add all the elements of the list to the current one - addRange(list); + // Add all the elements of the array to the current one + addRange(array); } return *this; diff --git a/include/reactphysics3d/containers/Set.h b/include/reactphysics3d/containers/Set.h index f54c7a69..3be397b8 100755 --- a/include/reactphysics3d/containers/Set.h +++ b/include/reactphysics3d/containers/Set.h @@ -478,16 +478,16 @@ class Set { return end(); } - /// Return a list with all the values of the set - List toList(MemoryAllocator& listAllocator) const { + /// Return an array with all the values of the set + Array toArray(MemoryAllocator& arrayAllocator) const { - List list(listAllocator); + Array array(arrayAllocator); for (auto it = begin(); it != end(); ++it) { - list.add(*it); + array.add(*it); } - return list; + return array; } /// Clear the set diff --git a/include/reactphysics3d/engine/EntityManager.h b/include/reactphysics3d/engine/EntityManager.h index 383e509b..f2a92bb1 100644 --- a/include/reactphysics3d/engine/EntityManager.h +++ b/include/reactphysics3d/engine/EntityManager.h @@ -28,7 +28,7 @@ // Libraries #include -#include +#include #include #include @@ -45,8 +45,8 @@ class EntityManager { // -------------------- Attributes -------------------- // - /// List storing the generations of the created entities - List mGenerations; + /// Array storing the generations of the created entities + Array mGenerations; /// Deque with the indices of destroyed entities that can be reused Deque mFreeIndices; diff --git a/include/reactphysics3d/engine/Islands.h b/include/reactphysics3d/engine/Islands.h index cc3d42b9..b2931222 100644 --- a/include/reactphysics3d/engine/Islands.h +++ b/include/reactphysics3d/engine/Islands.h @@ -28,7 +28,7 @@ // Libraries #include -#include +#include #include #include @@ -64,19 +64,19 @@ struct Islands { /// For each island, index of the first contact manifold of the island in the array of contact manifolds - List contactManifoldsIndices; + Array contactManifoldsIndices; /// For each island, number of contact manifolds in the island - List nbContactManifolds; + Array nbContactManifolds; - /// List of all the entities of the bodies in the islands (stored sequentially) - List bodyEntities; + /// Array of all the entities of the bodies in the islands (stored sequentially) + Array bodyEntities; /// For each island we store the starting index of the bodies of that island in the "bodyEntities" array - List startBodyEntitiesIndex; + Array startBodyEntitiesIndex; /// For each island, total number of bodies in the island - List nbBodiesInIsland; + Array nbBodiesInIsland; // -------------------- Methods -------------------- // diff --git a/include/reactphysics3d/engine/OverlappingPairs.h b/include/reactphysics3d/engine/OverlappingPairs.h index cdde8865..21583ef0 100644 --- a/include/reactphysics3d/engine/OverlappingPairs.h +++ b/include/reactphysics3d/engine/OverlappingPairs.h @@ -283,11 +283,11 @@ class OverlappingPairs { /// Heap memory allocator MemoryAllocator& mHeapAllocator; - /// List of convex vs convex overlapping pairs - List mConvexPairs; + /// Array of convex vs convex overlapping pairs + Array mConvexPairs; - /// List of convex vs concave overlapping pairs - List mConcavePairs; + /// Array of convex vs concave overlapping pairs + Array mConcavePairs; /// Map a pair id to the internal array index Map mMapConvexPairIdToPairIndex; diff --git a/include/reactphysics3d/engine/PhysicsWorld.h b/include/reactphysics3d/engine/PhysicsWorld.h index f25253bd..fa603517 100644 --- a/include/reactphysics3d/engine/PhysicsWorld.h +++ b/include/reactphysics3d/engine/PhysicsWorld.h @@ -28,7 +28,7 @@ // Libraries #include -#include +#include #include #include #include @@ -210,7 +210,7 @@ class PhysicsWorld { CollisionDetectionSystem mCollisionDetection; /// All the collision bodies of the world - List mCollisionBodies; + Array mCollisionBodies; /// Pointer to an event listener object EventListener* mEventListener; @@ -233,7 +233,7 @@ class PhysicsWorld { /// Order in which to process the ContactPairs for contact creation such that /// all the contact manifolds and contact points of a given island are packed together /// This array contains the indices of the ContactPairs. - List mProcessContactPairsOrderIslands; + Array mProcessContactPairsOrderIslands; /// Contact solver system ContactSolverSystem mContactSolverSystem; @@ -254,7 +254,7 @@ class PhysicsWorld { bool mIsSleepingEnabled; /// All the rigid bodies of the physics world - List mRigidBodies; + Array mRigidBodies; /// True if the gravity force is on bool mIsGravityEnabled; @@ -298,7 +298,7 @@ class PhysicsWorld { /// Put bodies to sleep if needed. void updateSleepingBodies(decimal timeStep); - /// Add the joint to the list of joints of the two bodies involved in the joint + /// Add the joint to the array of joints of the two bodies involved in the joint void addJointToBodies(Entity body1, Entity body2, Entity joint); /// Update the world inverse inertia tensors of rigid bodies diff --git a/include/reactphysics3d/mathematics/mathematics_functions.h b/include/reactphysics3d/mathematics/mathematics_functions.h index cf0f6880..2f1aa0d5 100755 --- a/include/reactphysics3d/mathematics/mathematics_functions.h +++ b/include/reactphysics3d/mathematics/mathematics_functions.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include /// ReactPhysics3D namespace namespace reactphysics3d { @@ -111,14 +111,14 @@ decimal computePlaneSegmentIntersection(const Vector3& segA, const Vector3& segB decimal computePointToLineDistance(const Vector3& linePointA, const Vector3& linePointB, const Vector3& point); /// Clip a segment against multiple planes and return the clipped segment vertices -List clipSegmentWithPlanes(const Vector3& segA, const Vector3& segB, - const List& planesPoints, - const List& planesNormals, +Array clipSegmentWithPlanes(const Vector3& segA, const Vector3& segB, + const Array& planesPoints, + const Array& planesNormals, MemoryAllocator& allocator); /// Clip a polygon against multiple planes and return the clipped polygon vertices -List clipPolygonWithPlanes(const List& polygonVertices, const List& planesPoints, - const List& planesNormals, MemoryAllocator& allocator); +Array clipPolygonWithPlanes(const Array& polygonVertices, const Array& planesPoints, + const Array& planesNormals, MemoryAllocator& allocator); /// Project a point onto a plane that is given by a point and its unit length normal Vector3 projectPointOntoPlane(const Vector3& point, const Vector3& planeNormal, const Vector3& planePoint); diff --git a/include/reactphysics3d/reactphysics3d.h b/include/reactphysics3d/reactphysics3d.h index 2b32999c..918deb73 100644 --- a/include/reactphysics3d/reactphysics3d.h +++ b/include/reactphysics3d/reactphysics3d.h @@ -64,7 +64,7 @@ #include #include #include -#include +#include /// Alias to the ReactPhysics3D namespace namespace rp3d = reactphysics3d; diff --git a/include/reactphysics3d/systems/BroadPhaseSystem.h b/include/reactphysics3d/systems/BroadPhaseSystem.h index 9b4baf8a..3cbaa4ec 100644 --- a/include/reactphysics3d/systems/BroadPhaseSystem.h +++ b/include/reactphysics3d/systems/BroadPhaseSystem.h @@ -51,10 +51,10 @@ class AABBOverlapCallback : public DynamicAABBTreeOverlapCallback { public: - List& mOverlappingNodes; + Array& mOverlappingNodes; // Constructor - AABBOverlapCallback(List& overlappingNodes) : mOverlappingNodes(overlappingNodes) { + AABBOverlapCallback(Array& overlappingNodes) : mOverlappingNodes(overlappingNodes) { } @@ -184,7 +184,7 @@ class BroadPhaseSystem { void removeMovedCollider(int broadPhaseID); /// Compute all the overlapping pairs of collision shapes - void computeOverlappingPairs(MemoryManager& memoryManager, List>& overlappingNodes); + void computeOverlappingPairs(MemoryManager& memoryManager, Array>& overlappingNodes); /// Return the collider corresponding to the broad-phase node id in parameter Collider* getColliderForBroadPhaseId(int broadPhaseId) const; diff --git a/include/reactphysics3d/systems/CollisionDetectionSystem.h b/include/reactphysics3d/systems/CollisionDetectionSystem.h index 89ed2f32..9431279b 100644 --- a/include/reactphysics3d/systems/CollisionDetectionSystem.h +++ b/include/reactphysics3d/systems/CollisionDetectionSystem.h @@ -99,7 +99,7 @@ class CollisionDetectionSystem { OverlappingPairs mOverlappingPairs; /// Overlapping nodes during broad-phase computation - List> mBroadPhaseOverlappingNodes; + Array> mBroadPhaseOverlappingNodes; /// Broad-phase system BroadPhaseSystem mBroadPhaseSystem; @@ -110,57 +110,57 @@ class CollisionDetectionSystem { /// Narrow-phase collision detection input NarrowPhaseInput mNarrowPhaseInput; - /// List of the potential contact points - List mPotentialContactPoints; + /// Array of the potential contact points + Array mPotentialContactPoints; - /// List of the potential contact manifolds - List mPotentialContactManifolds; + /// Array of the potential contact manifolds + Array mPotentialContactManifolds; - /// First list of narrow-phase pair contacts - List mContactPairs1; + /// First array of narrow-phase pair contacts + Array mContactPairs1; - /// Second list of narrow-phase pair contacts - List mContactPairs2; + /// Second array of narrow-phase pair contacts + Array mContactPairs2; - /// Pointer to the list of contact pairs of the previous frame (either mContactPairs1 or mContactPairs2) - List* mPreviousContactPairs; + /// Pointer to the array of contact pairs of the previous frame (either mContactPairs1 or mContactPairs2) + Array* mPreviousContactPairs; - /// Pointer to the list of contact pairs of the current frame (either mContactPairs1 or mContactPairs2) - List* mCurrentContactPairs; + /// Pointer to the array of contact pairs of the current frame (either mContactPairs1 or mContactPairs2) + Array* mCurrentContactPairs; - /// List of lost contact pairs (contact pairs in contact in previous frame but not in the current one) - List mLostContactPairs; + /// Array of lost contact pairs (contact pairs in contact in previous frame but not in the current one) + Array mLostContactPairs; /// Pointer to the map of overlappingPairId to the index of contact pair of the previous frame /// (either mMapPairIdToContactPairIndex1 or mMapPairIdToContactPairIndex2) Map mPreviousMapPairIdToContactPairIndex; - /// First list with the contact manifolds - List mContactManifolds1; + /// First array with the contact manifolds + Array mContactManifolds1; - /// Second list with the contact manifolds - List mContactManifolds2; + /// Second array with the contact manifolds + Array mContactManifolds2; - /// Pointer to the list of contact manifolds from the previous frame (either mContactManifolds1 or mContactManifolds2) - List* mPreviousContactManifolds; + /// Pointer to the array of contact manifolds from the previous frame (either mContactManifolds1 or mContactManifolds2) + Array* mPreviousContactManifolds; - /// Pointer to the list of contact manifolds from the current frame (either mContactManifolds1 or mContactManifolds2) - List* mCurrentContactManifolds; + /// Pointer to the array of contact manifolds from the current frame (either mContactManifolds1 or mContactManifolds2) + Array* mCurrentContactManifolds; - /// Second list of contact points (contact points from either the current frame of the previous frame) - List mContactPoints1; + /// Second array of contact points (contact points from either the current frame of the previous frame) + Array mContactPoints1; - /// Second list of contact points (contact points from either the current frame of the previous frame) - List mContactPoints2; + /// Second array of contact points (contact points from either the current frame of the previous frame) + Array mContactPoints2; /// Pointer to the contact points of the previous frame (either mContactPoints1 or mContactPoints2) - List* mPreviousContactPoints; + Array* mPreviousContactPoints; /// Pointer to the contact points of the current frame (either mContactPoints1 or mContactPoints2) - List* mCurrentContactPoints; + Array* mCurrentContactPoints; /// Array with the indices of all the contact pairs that have at least one CollisionBody - List mCollisionBodyContactPairsIndices; + Array mCollisionBodyContactPairsIndices; #ifdef IS_RP3D_PROFILING_ENABLED @@ -178,7 +178,7 @@ class CollisionDetectionSystem { void computeMiddlePhase(NarrowPhaseInput& narrowPhaseInput, bool needToReportContacts); // Compute the middle-phase collision detection - void computeMiddlePhaseCollisionSnapshot(List& convexPairs, List& concavePairs, NarrowPhaseInput& narrowPhaseInput, + void computeMiddlePhaseCollisionSnapshot(Array& convexPairs, Array& concavePairs, NarrowPhaseInput& narrowPhaseInput, bool reportContacts); /// Compute the narrow-phase collision detection @@ -191,14 +191,14 @@ class CollisionDetectionSystem { bool computeNarrowPhaseCollisionSnapshot(NarrowPhaseInput& narrowPhaseInput, CollisionCallback& callback); /// Process the potential contacts after narrow-phase collision detection - void computeOverlapSnapshotContactPairs(NarrowPhaseInput& narrowPhaseInput, List& contactPairs) const; + void computeOverlapSnapshotContactPairs(NarrowPhaseInput& narrowPhaseInput, Array& contactPairs) const; /// Convert the potential contact into actual contacts - void computeOverlapSnapshotContactPairs(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, List& contactPairs, + void computeOverlapSnapshotContactPairs(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, Array& contactPairs, Set& setOverlapContactPairId) const; - /// Take a list of overlapping nodes in the broad-phase and create new overlapping pairs if necessary - void updateOverlappingPairs(const List >& overlappingNodes); + /// Take an array of overlapping nodes in the broad-phase and create new overlapping pairs if necessary + void updateOverlappingPairs(const Array >& overlappingNodes); /// Remove pairs that are not overlapping anymore void removeNonOverlappingPairs(); @@ -213,22 +213,22 @@ class CollisionDetectionSystem { void computeConvexVsConcaveMiddlePhase(OverlappingPairs::ConcaveOverlappingPair& overlappingPair, MemoryAllocator& allocator, NarrowPhaseInput& narrowPhaseInput); - /// Swap the previous and current contacts lists + /// Swap the previous and current contacts arrays void swapPreviousAndCurrentContacts(); /// Convert the potential contact into actual contacts void processPotentialContacts(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, - bool updateLastFrameInfo, List& potentialContactPoints, - List& potentialContactManifolds, - Map& mapPairIdToContactPairIndex, List* contactPairs); + bool updateLastFrameInfo, Array& potentialContactPoints, + Array& potentialContactManifolds, + Map& mapPairIdToContactPairIndex, Array* contactPairs); /// Process the potential contacts after narrow-phase collision detection - void processAllPotentialContacts(NarrowPhaseInput& narrowPhaseInput, bool updateLastFrameInfo, List& potentialContactPoints, - List& potentialContactManifolds, List* contactPairs); + void processAllPotentialContacts(NarrowPhaseInput& narrowPhaseInput, bool updateLastFrameInfo, Array& potentialContactPoints, + Array& potentialContactManifolds, Array* contactPairs); /// Reduce the potential contact manifolds and contact points of the overlapping pair contacts - void reducePotentialContactManifolds(List* contactPairs, List& potentialContactManifolds, - const List& potentialContactPoints) const; + void reducePotentialContactManifolds(Array* contactPairs, Array& potentialContactManifolds, + const Array& potentialContactPoints) const; /// Create the actual contact manifolds and contacts points (from potential contacts) for a given contact pair void createContacts(); @@ -243,40 +243,40 @@ class CollisionDetectionSystem { void computeLostContactPairs(); /// Create the actual contact manifolds and contacts points for testCollision() methods - void createSnapshotContacts(List& contactPairs, List &contactManifolds, - List& contactPoints, - List& potentialContactManifolds, - List& potentialContactPoints); + void createSnapshotContacts(Array& contactPairs, Array &contactManifolds, + Array& contactPoints, + Array& potentialContactManifolds, + Array& potentialContactPoints); /// Initialize the current contacts with the contacts from the previous frame (for warmstarting) void initContactsWithPreviousOnes(); /// Reduce the number of contact points of a potential contact manifold void reduceContactPoints(ContactManifoldInfo& manifold, const Transform& shape1ToWorldTransform, - const List& potentialContactPoints) const; + const Array& potentialContactPoints) const; /// Report contacts - void reportContacts(CollisionCallback& callback, List* contactPairs, - List* manifolds, List* contactPoints, List& lostContactPairs); + void reportContacts(CollisionCallback& callback, Array* contactPairs, + Array* manifolds, Array* contactPoints, Array& lostContactPairs); /// Report all triggers - void reportTriggers(EventListener& eventListener, List* contactPairs, List& lostContactPairs); + void reportTriggers(EventListener& eventListener, Array* contactPairs, Array& lostContactPairs); /// Report all contacts for debug rendering - void reportDebugRenderingContacts(List* contactPairs, List* manifolds, List* contactPoints, List& lostContactPairs); + void reportDebugRenderingContacts(Array* contactPairs, Array* manifolds, Array* contactPoints, Array& lostContactPairs); /// Return the largest depth of all the contact points of a potential manifold decimal computePotentialManifoldLargestContactDepth(const ContactManifoldInfo& manifold, - const List& potentialContactPoints) const; + const Array& potentialContactPoints) const; /// Process the potential contacts where one collion is a concave shape void processSmoothMeshContacts(OverlappingPair* pair); /// Filter the overlapping pairs to keep only the pairs where a given body is involved - void filterOverlappingPairs(Entity bodyEntity, List& convexPairs, List& concavePairs) const; + void filterOverlappingPairs(Entity bodyEntity, Array& convexPairs, Array& concavePairs) const; /// Filter the overlapping pairs to keep only the pairs where two given bodies are involved - void filterOverlappingPairs(Entity body1Entity, Entity body2Entity, List& convexPairs, List& concavePairs) const; + void filterOverlappingPairs(Entity body1Entity, Entity body2Entity, Array& convexPairs, Array& concavePairs) const; /// Remove an element in an array (and replace it by the last one in the array) void removeItemAtInArray(uint array[], uint8 index, uint8& arraySize) const; @@ -411,7 +411,7 @@ RP3D_FORCE_INLINE void CollisionDetectionSystem::removeNoCollisionPair(Entity bo } // Ask for a collision shape to be tested again during broad-phase. -/// We simply put the shape in the list of collision shape that have moved in the +/// We simply put the shape in the array of collision shape that have moved in the /// previous frame so that it is tested for collision again in the broad-phase. RP3D_FORCE_INLINE void CollisionDetectionSystem::askForBroadPhaseCollisionCheck(Collider* collider) { diff --git a/include/reactphysics3d/systems/ContactSolverSystem.h b/include/reactphysics3d/systems/ContactSolverSystem.h index 8c484328..9c5a87db 100644 --- a/include/reactphysics3d/systems/ContactSolverSystem.h +++ b/include/reactphysics3d/systems/ContactSolverSystem.h @@ -302,11 +302,11 @@ class ContactSolverSystem { /// Reference to the islands Islands& mIslands; - /// Pointer to the list of contact manifolds from narrow-phase - List* mAllContactManifolds; + /// Pointer to the array of contact manifolds from narrow-phase + Array* mAllContactManifolds; - /// Pointer to the list of contact points from narrow-phase - List* mAllContactPoints; + /// Pointer to the array of contact points from narrow-phase + Array* mAllContactPoints; /// Reference to the body components CollisionBodyComponents& mBodyComponents; @@ -356,7 +356,7 @@ class ContactSolverSystem { ~ContactSolverSystem() = default; /// Initialize the contact constraints - void init(List* contactManifolds, List* contactPoints, decimal timeStep); + void init(Array* contactManifolds, Array* contactPoints, decimal timeStep); /// Initialize the constraint solver for a given island void initializeForIsland(uint islandIndex); diff --git a/include/reactphysics3d/utils/DebugRenderer.h b/include/reactphysics3d/utils/DebugRenderer.h index e8e31473..c5321f8e 100644 --- a/include/reactphysics3d/utils/DebugRenderer.h +++ b/include/reactphysics3d/utils/DebugRenderer.h @@ -27,7 +27,7 @@ #define REACTPHYSICS3D_DEBUG_RENDERER_H // Libraries -#include +#include #include #include #include @@ -47,7 +47,7 @@ class PhysicsWorld; /** * This class is used to display physics debug information directly into the user application view. * For instance, it is possible to display AABBs of colliders, colliders or contact points. This class - * can be used to get the debug information as lists of basic primitives (points, linges, triangles, ...). + * can be used to get the debug information as arrays of basic primitives (points, linges, triangles, ...). * You can use this to render physics debug information in your simulation on top of your object. Note that * you should use this only for debugging purpose and you should disable it when you compile the final release * version of your application because computing/rendering phyiscs debug information can be expensive. @@ -159,11 +159,11 @@ class DebugRenderer : public EventListener { /// Memory allocator MemoryAllocator& mAllocator; - /// List with all the debug lines - List mLines; + /// Array with all the debug lines + Array mLines; - /// List with all the debug triangles - List mTriangles; + /// Array with all the debug triangles + Array mTriangles; /// 32-bits integer that contains all the flags of debug items to display uint32 mDisplayedDebugItems; @@ -216,8 +216,8 @@ class DebugRenderer : public EventListener { /// Return the number of lines uint32 getNbLines() const; - /// Return a reference to the list of lines - const List& getLines() const; + /// Return a reference to the array of lines + const Array& getLines() const; /// Return a pointer to the array of lines const DebugLine* getLinesArray() const; @@ -225,8 +225,8 @@ class DebugRenderer : public EventListener { /// Return the number of triangles uint32 getNbTriangles() const; - /// Return a reference to the list of triangles - const List& getTriangles() const; + /// Return a reference to the array of triangles + const Array& getTriangles() const; /// Return a pointer to the array of triangles const DebugTriangle* getTrianglesArray() const; @@ -267,11 +267,11 @@ RP3D_FORCE_INLINE uint32 DebugRenderer::getNbLines() const { return mLines.size(); } -// Return a reference to the list of lines +// Return a reference to the array of lines /** - * @return The list of lines to draw + * @return The array of lines to draw */ -RP3D_FORCE_INLINE const List& DebugRenderer::getLines() const { +RP3D_FORCE_INLINE const Array& DebugRenderer::getLines() const { return mLines; } @@ -291,11 +291,11 @@ RP3D_FORCE_INLINE uint32 DebugRenderer::getNbTriangles() const { return mTriangles.size(); } -// Return a reference to the list of triangles +// Return a reference to the array of triangles /** - * @return The list of triangles to draw + * @return The array of triangles to draw */ -RP3D_FORCE_INLINE const List& DebugRenderer::getTriangles() const { +RP3D_FORCE_INLINE const Array& DebugRenderer::getTriangles() const { return mTriangles; } diff --git a/include/reactphysics3d/utils/DefaultLogger.h b/include/reactphysics3d/utils/DefaultLogger.h index bcc2f450..5f6733ee 100644 --- a/include/reactphysics3d/utils/DefaultLogger.h +++ b/include/reactphysics3d/utils/DefaultLogger.h @@ -28,7 +28,7 @@ // Libraries #include -#include +#include #include #include #include @@ -445,7 +445,7 @@ class DefaultLogger : public Logger { MemoryAllocator& mAllocator; /// All the log destinations - List mDestinations; + Array mDestinations; /// Map a log format to the given formatter object Map mFormatters; diff --git a/include/reactphysics3d/utils/Logger.h b/include/reactphysics3d/utils/Logger.h index ba0144e2..c54ae10e 100644 --- a/include/reactphysics3d/utils/Logger.h +++ b/include/reactphysics3d/utils/Logger.h @@ -27,7 +27,7 @@ #define REACTPHYSICS3D_LOGGER_H // Libraries -#include +#include #include #include #include diff --git a/include/reactphysics3d/utils/Profiler.h b/include/reactphysics3d/utils/Profiler.h index 43f4ae0f..8c46e7ca 100644 --- a/include/reactphysics3d/utils/Profiler.h +++ b/include/reactphysics3d/utils/Profiler.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include /// ReactPhysics3D namespace namespace reactphysics3d { diff --git a/src/body/CollisionBody.cpp b/src/body/CollisionBody.cpp index dbfada79..ba89b3a7 100644 --- a/src/body/CollisionBody.cpp +++ b/src/body/CollisionBody.cpp @@ -200,8 +200,8 @@ void CollisionBody::removeCollider(Collider* collider) { void CollisionBody::removeAllColliders() { // Look for the collider that contains the collision shape in parameter. - // Note that we need to copy the list of collider entities because we are deleting them in a loop. - const List collidersEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + // Note that we need to copy the array of collider entities because we are deleting them in a loop. + const Array collidersEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < collidersEntities.size(); i++) { removeCollider(mWorld.mCollidersComponents.getCollider(collidersEntities[i])); @@ -222,7 +222,7 @@ const Transform& CollisionBody::getTransform() const { void CollisionBody::updateBroadPhaseState(decimal timeStep) const { // For all the colliders of the body - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); const uint32 nbColliderEntities = colliderEntities.size(); for (uint32 i=0; i < nbColliderEntities; i++) { @@ -253,7 +253,7 @@ void CollisionBody::setIsActive(bool isActive) { const Transform& transform = mWorld.mTransformComponents.getTransform(mEntity); // For each collider of the body - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < colliderEntities.size(); i++) { Collider* collider = mWorld.mCollidersComponents.getCollider(colliderEntities[i]); @@ -269,7 +269,7 @@ void CollisionBody::setIsActive(bool isActive) { else { // If we have to deactivate the body // For each collider of the body - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < colliderEntities.size(); i++) { Collider* collider = mWorld.mCollidersComponents.getCollider(colliderEntities[i]); @@ -292,7 +292,7 @@ void CollisionBody::setIsActive(bool isActive) { void CollisionBody::askForBroadPhaseCollisionCheck() const { // For all the colliders of the body - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < colliderEntities.size(); i++) { Collider* collider = mWorld.mCollidersComponents.getCollider(colliderEntities[i]); @@ -310,7 +310,7 @@ void CollisionBody::askForBroadPhaseCollisionCheck() const { bool CollisionBody::testPointInside(const Vector3& worldPoint) const { // For each collider of the body - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < colliderEntities.size(); i++) { Collider* collider = mWorld.mCollidersComponents.getCollider(colliderEntities[i]); @@ -339,7 +339,7 @@ bool CollisionBody::raycast(const Ray& ray, RaycastInfo& raycastInfo) { Ray rayTemp(ray); // For each collider of the body - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < colliderEntities.size(); i++) { Collider* collider = mWorld.mCollidersComponents.getCollider(colliderEntities[i]); @@ -362,7 +362,7 @@ AABB CollisionBody::getAABB() const { AABB bodyAABB; - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); if (colliderEntities.size() == 0) return bodyAABB; const Transform& transform = mWorld.mTransformComponents.getTransform(mEntity); diff --git a/src/body/RigidBody.cpp b/src/body/RigidBody.cpp index 74cdf8ed..bd5586a1 100644 --- a/src/body/RigidBody.cpp +++ b/src/body/RigidBody.cpp @@ -324,7 +324,7 @@ Vector3 RigidBody::computeCenterOfMass() const { Vector3 centerOfMassLocal(0, 0, 0); // Compute the local center of mass - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < colliderEntities.size(); i++) { const uint colliderIndex = mWorld.mCollidersComponents.getEntityIndex(colliderEntities[i]); @@ -356,7 +356,7 @@ void RigidBody::computeMassAndInertiaTensorLocal(Vector3& inertiaTensorLocal, de const Vector3 centerOfMassLocal = mWorld.mRigidBodyComponents.getCenterOfMassLocal(mEntity); // Compute the inertia tensor using all the colliders - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < colliderEntities.size(); i++) { const uint colliderIndex = mWorld.mCollidersComponents.getEntityIndex(colliderEntities[i]); @@ -431,7 +431,7 @@ void RigidBody::updateMassFromColliders() { decimal totalMass = decimal(0.0); // Compute the total mass of the body - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < colliderEntities.size(); i++) { const uint colliderIndex = mWorld.mCollidersComponents.getEntityIndex(colliderEntities[i]); @@ -871,11 +871,11 @@ void RigidBody::setIsSleeping(bool isSleeping) { void RigidBody::resetOverlappingPairs() { // For each collider of the body - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < colliderEntities.size(); i++) { // Get the currently overlapping pairs for this collider - List overlappingPairs = mWorld.mCollidersComponents.getOverlappingPairs(colliderEntities[i]); + Array overlappingPairs = mWorld.mCollidersComponents.getOverlappingPairs(colliderEntities[i]); for (uint32 j=0; j < overlappingPairs.size(); j++) { @@ -951,7 +951,7 @@ void RigidBody::setProfiler(Profiler* profiler) { CollisionBody::setProfiler(profiler); // Set the profiler for each collider - const List& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); + const Array& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity); for (uint32 i=0; i < colliderEntities.size(); i++) { Collider* collider = mWorld.mCollidersComponents.getCollider(colliderEntities[i]); diff --git a/src/collision/CollisionCallback.cpp b/src/collision/CollisionCallback.cpp index 34d40f51..f537bdb9 100644 --- a/src/collision/CollisionCallback.cpp +++ b/src/collision/CollisionCallback.cpp @@ -39,7 +39,7 @@ CollisionCallback::ContactPoint::ContactPoint(const reactphysics3d::ContactPoint // Contact Pair Constructor CollisionCallback::ContactPair::ContactPair(const reactphysics3d::ContactPair& contactPair, - List* contactPoints, PhysicsWorld& world, bool isLostContactPair) + Array* contactPoints, PhysicsWorld& world, bool isLostContactPair) :mContactPair(contactPair), mContactPoints(contactPoints), mWorld(world), mIsLostContactPair(isLostContactPair) { @@ -76,8 +76,8 @@ CollisionCallback::ContactPair::EventType CollisionCallback::ContactPair::getEve } // Constructor -CollisionCallback::CallbackData::CallbackData(List* contactPairs, List* manifolds, - List* contactPoints, List& lostContactPairs, PhysicsWorld& world) +CollisionCallback::CallbackData::CallbackData(Array* contactPairs, Array* manifolds, + Array* contactPoints, Array& lostContactPairs, PhysicsWorld& world) :mContactPairs(contactPairs), mContactManifolds(manifolds), mContactPoints(contactPoints), mLostContactPairs(lostContactPairs), mContactPairsIndices(world.mMemoryManager.getHeapAllocator(), contactPairs->size()), mLostContactPairsIndices(world.mMemoryManager.getHeapAllocator(), lostContactPairs.size()), mWorld(world) { diff --git a/src/collision/HalfEdgeStructure.cpp b/src/collision/HalfEdgeStructure.cpp index 0892b77c..574062c3 100644 --- a/src/collision/HalfEdgeStructure.cpp +++ b/src/collision/HalfEdgeStructure.cpp @@ -41,7 +41,7 @@ void HalfEdgeStructure::init() { Map mapEdgeIndexToKey(mAllocator); Map mapFaceIndexToEdgeKey(mAllocator); - List currentFaceEdges(mAllocator, mFaces[0].faceVertices.size()); + Array currentFaceEdges(mAllocator, mFaces[0].faceVertices.size()); // For each face for (uint32 f=0; f& contactPairs, List& lostContactPairs, bool onlyReportTriggers, PhysicsWorld& world) +OverlapCallback::CallbackData::CallbackData(Array& contactPairs, Array& lostContactPairs, bool onlyReportTriggers, PhysicsWorld& world) :mContactPairs(contactPairs), mLostContactPairs(lostContactPairs), mContactPairsIndices(world.mMemoryManager.getHeapAllocator()), mLostContactPairsIndices(world.mMemoryManager.getHeapAllocator()), mWorld(world) { diff --git a/src/collision/PolyhedronMesh.cpp b/src/collision/PolyhedronMesh.cpp index 653fde1a..e413bce0 100644 --- a/src/collision/PolyhedronMesh.cpp +++ b/src/collision/PolyhedronMesh.cpp @@ -75,7 +75,7 @@ void PolyhedronMesh::createHalfEdgeStructure() { // Get the polygon face PolygonVertexArray::PolygonFace* face = mPolygonVertexArray->getPolygonFace(f); - List faceVertices(mMemoryAllocator, face->nbVertices); + Array faceVertices(mMemoryAllocator, face->nbVertices); // For each vertex of the face for (uint v=0; v < face->nbVertices; v++) { diff --git a/src/collision/broadphase/DynamicAABBTree.cpp b/src/collision/broadphase/DynamicAABBTree.cpp index 655e3a1e..651def8a 100644 --- a/src/collision/broadphase/DynamicAABBTree.cpp +++ b/src/collision/broadphase/DynamicAABBTree.cpp @@ -573,9 +573,9 @@ int32 DynamicAABBTree::balanceSubTreeAtNode(int32 nodeID) { return nodeID; } -/// Take a list of shapes to be tested for broad-phase overlap and return a list of pair of overlapping shapes -void DynamicAABBTree::reportAllShapesOverlappingWithShapes(const List& nodesToTest, size_t startIndex, - size_t endIndex, List>& outOverlappingNodes) const { +/// Take an array of shapes to be tested for broad-phase overlap and return an array of pair of overlapping shapes +void DynamicAABBTree::reportAllShapesOverlappingWithShapes(const Array& nodesToTest, size_t startIndex, + size_t endIndex, Array>& outOverlappingNodes) const { RP3D_PROFILE("DynamicAABBTree::reportAllShapesOverlappingWithAABB()", mProfiler); @@ -609,7 +609,7 @@ void DynamicAABBTree::reportAllShapesOverlappingWithShapes(const List& no // If the node is a leaf if (nodeToVisit->isLeaf()) { - // Add the node in the list of overlapping nodes + // Add the node in the array of overlapping nodes outOverlappingNodes.add(Pair(nodesToTest[i], nodeIDToVisit)); } else { // If the node is not a leaf @@ -626,7 +626,7 @@ void DynamicAABBTree::reportAllShapesOverlappingWithShapes(const List& no } // Report all shapes overlapping with the AABB given in parameter. -void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& aabb, List& overlappingNodes) const { +void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& aabb, Array& overlappingNodes) const { RP3D_PROFILE("DynamicAABBTree::reportAllShapesOverlappingWithAABB()", mProfiler); diff --git a/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp b/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp index 49dcbc0b..b09df90f 100644 --- a/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp +++ b/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp @@ -59,7 +59,7 @@ bool CapsuleVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& nar #endif // Run the GJK algorithm - List gjkResults(memoryAllocator); + Array gjkResults(memoryAllocator); gjkAlgorithm.testCollision(narrowPhaseInfoBatch, batchStartIndex, batchNbItems, gjkResults); assert(gjkResults.size() == batchNbItems); diff --git a/src/collision/narrowphase/GJK/GJKAlgorithm.cpp b/src/collision/narrowphase/GJK/GJKAlgorithm.cpp index 74a0dbaa..d35fd6e0 100644 --- a/src/collision/narrowphase/GJK/GJKAlgorithm.cpp +++ b/src/collision/narrowphase/GJK/GJKAlgorithm.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -48,7 +48,7 @@ using namespace reactphysics3d; /// origin, they we give that simplex polytope to the EPA algorithm which will compute /// the correct penetration depth and contact points between the enlarged objects. void GJKAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, - uint batchNbItems, List& gjkResults) { + uint batchNbItems, Array& gjkResults) { RP3D_PROFILE("GJKAlgorithm::testCollision()", mProfiler); diff --git a/src/collision/narrowphase/SAT/SATAlgorithm.cpp b/src/collision/narrowphase/SAT/SATAlgorithm.cpp index b67c94a2..0d0eccfe 100644 --- a/src/collision/narrowphase/SAT/SATAlgorithm.cpp +++ b/src/collision/narrowphase/SAT/SATAlgorithm.cpp @@ -395,8 +395,8 @@ bool SATAlgorithm::computeCapsulePolyhedronFaceContactPoints(uint referenceFaceI uint firstEdgeIndex = face.edgeIndex; uint edgeIndex = firstEdgeIndex; - List planesPoints(mMemoryAllocator, 2); - List planesNormals(mMemoryAllocator, 2); + Array planesPoints(mMemoryAllocator, 2); + Array planesNormals(mMemoryAllocator, 2); // For each adjacent edge of the separating face of the polyhedron do { @@ -422,7 +422,7 @@ bool SATAlgorithm::computeCapsulePolyhedronFaceContactPoints(uint referenceFaceI } while(edgeIndex != firstEdgeIndex); // First we clip the inner segment of the capsule with the four planes of the adjacent faces - List clipSegment = clipSegmentWithPlanes(capsuleSegAPolyhedronSpace, capsuleSegBPolyhedronSpace, planesPoints, planesNormals, mMemoryAllocator); + Array clipSegment = clipSegmentWithPlanes(capsuleSegAPolyhedronSpace, capsuleSegBPolyhedronSpace, planesPoints, planesNormals, mMemoryAllocator); // Project the two clipped points into the polyhedron face const Vector3 delta = faceNormal * (penetrationDepth - capsuleRadius); @@ -916,9 +916,9 @@ bool SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints(bool isMinPene const HalfEdgeStructure::Face& incidentFace = incidentPolyhedron->getFace(incidentFaceIndex); uint32 nbIncidentFaceVertices = incidentFace.faceVertices.size(); - List polygonVertices(mMemoryAllocator, nbIncidentFaceVertices); // Vertices to clip of the incident face - List planesNormals(mMemoryAllocator, nbIncidentFaceVertices); // Normals of the clipping planes - List planesPoints(mMemoryAllocator, nbIncidentFaceVertices); // Points on the clipping planes + Array polygonVertices(mMemoryAllocator, nbIncidentFaceVertices); // Vertices to clip of the incident face + Array planesNormals(mMemoryAllocator, nbIncidentFaceVertices); // Normals of the clipping planes + Array planesPoints(mMemoryAllocator, nbIncidentFaceVertices); // Points on the clipping planes // Get all the vertices of the incident face (in the reference local-space) for (uint32 i=0; i < incidentFace.faceVertices.size(); i++) { @@ -958,7 +958,7 @@ bool SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints(bool isMinPene assert(planesNormals.size() == planesPoints.size()); // Clip the reference faces with the adjacent planes of the reference face - List clipPolygonVertices = clipPolygonWithPlanes(polygonVertices, planesPoints, planesNormals, mMemoryAllocator); + Array clipPolygonVertices = clipPolygonWithPlanes(polygonVertices, planesPoints, planesNormals, mMemoryAllocator); // We only keep the clipped points that are below the reference face const Vector3 referenceFaceVertex = referencePolyhedron->getVertexPosition(referencePolyhedron->getHalfEdge(firstEdgeIndex).vertexIndex); diff --git a/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp b/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp index f0c199d5..039aa9bb 100644 --- a/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp +++ b/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp @@ -50,7 +50,7 @@ bool SphereVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narr #endif - List gjkResults(memoryAllocator, batchNbItems); + Array gjkResults(memoryAllocator, batchNbItems); gjkAlgorithm.testCollision(narrowPhaseInfoBatch, batchStartIndex, batchNbItems, gjkResults); assert(gjkResults.size() == batchNbItems); diff --git a/src/collision/shapes/BoxShape.cpp b/src/collision/shapes/BoxShape.cpp index 60f5a2b2..35448295 100644 --- a/src/collision/shapes/BoxShape.cpp +++ b/src/collision/shapes/BoxShape.cpp @@ -56,17 +56,17 @@ BoxShape::BoxShape(const Vector3& halfExtents, MemoryAllocator& allocator) mHalfEdgeStructure.addVertex(7); // Faces - List face0(allocator, 4); + Array face0(allocator, 4); face0.add(0); face0.add(1); face0.add(2); face0.add(3); - List face1(allocator, 4); + Array face1(allocator, 4); face1.add(1); face1.add(5); face1.add(6); face1.add(2); - List face2(allocator, 4); + Array face2(allocator, 4); face2.add(4); face2.add(7); face2.add(6); face2.add(5); - List face3(allocator, 4); + Array face3(allocator, 4); face3.add(4); face3.add(0); face3.add(3); face3.add(7); - List face4(allocator, 4); + Array face4(allocator, 4); face4.add(4); face4.add(5); face4.add(1); face4.add(0); - List face5(allocator, 4); + Array face5(allocator, 4); face5.add(2); face5.add(6); face5.add(7); face5.add(3); mHalfEdgeStructure.addFace(face0); diff --git a/src/collision/shapes/ConcaveMeshShape.cpp b/src/collision/shapes/ConcaveMeshShape.cpp index 766d6d7f..cedb55f2 100644 --- a/src/collision/shapes/ConcaveMeshShape.cpp +++ b/src/collision/shapes/ConcaveMeshShape.cpp @@ -127,8 +127,8 @@ uint ConcaveMeshShape::getNbTriangles(uint subPart) const } // Compute all the triangles of the mesh that are overlapping with the AABB in parameter -void ConcaveMeshShape::computeOverlappingTriangles(const AABB& localAABB, List& triangleVertices, - List& triangleVerticesNormals, List& shapeIds, +void ConcaveMeshShape::computeOverlappingTriangles(const AABB& localAABB, Array& triangleVertices, + Array& triangleVerticesNormals, Array& shapeIds, MemoryAllocator& allocator) const { RP3D_PROFILE("ConcaveMeshShape::computeOverlappingTriangles()", mProfiler); @@ -139,12 +139,12 @@ void ConcaveMeshShape::computeOverlappingTriangles(const AABB& localAABB, List overlappingNodes(allocator, 64); + Array overlappingNodes(allocator, 64); mDynamicAABBTree.reportAllShapesOverlappingWithAABB(aabb, overlappingNodes); const uint32 nbOverlappingNodes = overlappingNodes.size(); - // Add space in the list of triangles vertices/normals for the new triangles + // Add space in the array of triangles vertices/normals for the new triangles triangleVertices.addWithoutInit(nbOverlappingNodes * 3); triangleVerticesNormals.addWithoutInit(nbOverlappingNodes * 3); @@ -230,7 +230,7 @@ decimal ConcaveMeshRaycastCallback::raycastBroadPhaseShape(int32 nodeId, const R // Raycast all collision shapes that have been collected void ConcaveMeshRaycastCallback::raycastTriangles() { - List::Iterator it; + Array::Iterator it; decimal smallestHitFraction = mRay.maxFraction; for (it = mHitAABBNodes.begin(); it != mHitAABBNodes.end(); ++it) { diff --git a/src/collision/shapes/ConvexMeshShape.cpp b/src/collision/shapes/ConvexMeshShape.cpp index 06589d4e..a8912ee2 100644 --- a/src/collision/shapes/ConvexMeshShape.cpp +++ b/src/collision/shapes/ConvexMeshShape.cpp @@ -49,7 +49,7 @@ ConvexMeshShape::ConvexMeshShape(PolyhedronMesh* polyhedronMesh, MemoryAllocator // Return a local support point in a given direction without the object margin. /// If the edges information is not used for collision detection, this method will go through -/// the whole vertices list and pick up the vertex with the largest dot product in the support +/// the whole vertices array and pick up the vertex with the largest dot product in the support /// direction. This is an O(n) process with "n" being the number of vertices in the mesh. /// However, if the edges information is used, we can cache the previous support vertex and use /// it as a start in a hill-climbing (local search) process to find the new support vertex which diff --git a/src/collision/shapes/HeightFieldShape.cpp b/src/collision/shapes/HeightFieldShape.cpp index e6c3f7bb..ff5419a9 100644 --- a/src/collision/shapes/HeightFieldShape.cpp +++ b/src/collision/shapes/HeightFieldShape.cpp @@ -91,8 +91,8 @@ void HeightFieldShape::getLocalBounds(Vector3& min, Vector3& max) const { // of the body when need to test and see against which triangles of the height-field we need // to test for collision. We compute the sub-grid points that are inside the other body's AABB // and then for each rectangle in the sub-grid we generate two triangles that we use to test collision. -void HeightFieldShape::computeOverlappingTriangles(const AABB& localAABB, List& triangleVertices, - List& triangleVerticesNormals, List& shapeIds, +void HeightFieldShape::computeOverlappingTriangles(const AABB& localAABB, Array& triangleVertices, + Array& triangleVerticesNormals, Array& shapeIds, MemoryAllocator& allocator) const { RP3D_PROFILE("HeightFieldShape::computeOverlappingTriangles()", mProfiler); @@ -236,9 +236,9 @@ bool HeightFieldShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collide const AABB rayAABB(Vector3::min(ray.point1, rayEnd), Vector3::max(ray.point1, rayEnd)); // Compute the triangles overlapping with the ray AABB - List triangleVertices(allocator, 64); - List triangleVerticesNormals(allocator, 64); - List shapeIds(allocator, 64); + Array triangleVertices(allocator, 64); + Array triangleVerticesNormals(allocator, 64); + Array shapeIds(allocator, 64); computeOverlappingTriangles(rayAABB, triangleVertices, triangleVerticesNormals, shapeIds, allocator); assert(triangleVertices.size() == triangleVerticesNormals.size()); diff --git a/src/components/ColliderComponents.cpp b/src/components/ColliderComponents.cpp index 550acd2f..03cdd37e 100644 --- a/src/components/ColliderComponents.cpp +++ b/src/components/ColliderComponents.cpp @@ -37,7 +37,7 @@ using namespace reactphysics3d; ColliderComponents::ColliderComponents(MemoryAllocator& allocator) :Components(allocator, sizeof(Entity) + sizeof(Entity) + sizeof(Collider*) + sizeof(int32) + sizeof(Transform) + sizeof(CollisionShape*) + sizeof(unsigned short) + - sizeof(unsigned short) + sizeof(Transform) + sizeof(List) + sizeof(bool) + + sizeof(unsigned short) + sizeof(Transform) + sizeof(Array) + sizeof(bool) + sizeof(bool) + sizeof(Material)) { // Allocate memory for the components data @@ -66,7 +66,7 @@ void ColliderComponents::allocate(uint32 nbComponentsToAllocate) { unsigned short* newCollisionCategoryBits = reinterpret_cast(newCollisionShapes + nbComponentsToAllocate); unsigned short* newCollideWithMaskBits = reinterpret_cast(newCollisionCategoryBits + nbComponentsToAllocate); Transform* newLocalToWorldTransforms = reinterpret_cast(newCollideWithMaskBits + nbComponentsToAllocate); - List* newOverlappingPairs = reinterpret_cast*>(newLocalToWorldTransforms + nbComponentsToAllocate); + Array* newOverlappingPairs = reinterpret_cast*>(newLocalToWorldTransforms + nbComponentsToAllocate); bool* hasCollisionShapeChangedSize = reinterpret_cast(newOverlappingPairs + nbComponentsToAllocate); bool* isTrigger = reinterpret_cast(hasCollisionShapeChangedSize + nbComponentsToAllocate); Material* materials = reinterpret_cast(isTrigger + nbComponentsToAllocate); @@ -84,7 +84,7 @@ void ColliderComponents::allocate(uint32 nbComponentsToAllocate) { memcpy(newCollisionCategoryBits, mCollisionCategoryBits, mNbComponents * sizeof(unsigned short)); memcpy(newCollideWithMaskBits, mCollideWithMaskBits, mNbComponents * sizeof(unsigned short)); memcpy(newLocalToWorldTransforms, mLocalToWorldTransforms, mNbComponents * sizeof(Transform)); - memcpy(newOverlappingPairs, mOverlappingPairs, mNbComponents * sizeof(List)); + memcpy(newOverlappingPairs, mOverlappingPairs, mNbComponents * sizeof(Array)); memcpy(hasCollisionShapeChangedSize, mHasCollisionShapeChangedSize, mNbComponents * sizeof(bool)); memcpy(isTrigger, mIsTrigger, mNbComponents * sizeof(bool)); memcpy(materials, mMaterials, mNbComponents * sizeof(Material)); @@ -128,7 +128,7 @@ void ColliderComponents::addComponent(Entity colliderEntity, bool isSleeping, co new (mCollisionCategoryBits + index) unsigned short(component.collisionCategoryBits); new (mCollideWithMaskBits + index) unsigned short(component.collideWithMaskBits); new (mLocalToWorldTransforms + index) Transform(component.localToWorldTransform); - new (mOverlappingPairs + index) List(mMemoryAllocator); + new (mOverlappingPairs + index) Array(mMemoryAllocator); mHasCollisionShapeChangedSize[index] = false; mIsTrigger[index] = false; mMaterials[index] = component.material; @@ -157,7 +157,7 @@ void ColliderComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) new (mCollisionCategoryBits + destIndex) unsigned short(mCollisionCategoryBits[srcIndex]); new (mCollideWithMaskBits + destIndex) unsigned short(mCollideWithMaskBits[srcIndex]); new (mLocalToWorldTransforms + destIndex) Transform(mLocalToWorldTransforms[srcIndex]); - new (mOverlappingPairs + destIndex) List(mOverlappingPairs[srcIndex]); + new (mOverlappingPairs + destIndex) Array(mOverlappingPairs[srcIndex]); mHasCollisionShapeChangedSize[destIndex] = mHasCollisionShapeChangedSize[srcIndex]; mIsTrigger[destIndex] = mIsTrigger[srcIndex]; mMaterials[destIndex] = mMaterials[srcIndex]; @@ -186,7 +186,7 @@ void ColliderComponents::swapComponents(uint32 index1, uint32 index2) { unsigned short collisionCategoryBits1 = mCollisionCategoryBits[index1]; unsigned short collideWithMaskBits1 = mCollideWithMaskBits[index1]; Transform localToWorldTransform1 = mLocalToWorldTransforms[index1]; - List overlappingPairs = mOverlappingPairs[index1]; + Array overlappingPairs = mOverlappingPairs[index1]; bool hasCollisionShapeChangedSize = mHasCollisionShapeChangedSize[index1]; bool isTrigger = mIsTrigger[index1]; Material material = mMaterials[index1]; @@ -206,7 +206,7 @@ void ColliderComponents::swapComponents(uint32 index1, uint32 index2) { new (mCollisionCategoryBits + index2) unsigned short(collisionCategoryBits1); new (mCollideWithMaskBits + index2) unsigned short(collideWithMaskBits1); new (mLocalToWorldTransforms + index2) Transform(localToWorldTransform1); - new (mOverlappingPairs + index2) List(overlappingPairs); + new (mOverlappingPairs + index2) Array(overlappingPairs); mHasCollisionShapeChangedSize[index2] = hasCollisionShapeChangedSize; mIsTrigger[index2] = isTrigger; mMaterials[index2] = material; @@ -234,6 +234,6 @@ void ColliderComponents::destroyComponent(uint32 index) { mLocalToBodyTransforms[index].~Transform(); mCollisionShapes[index] = nullptr; mLocalToWorldTransforms[index].~Transform(); - mOverlappingPairs[index].~List(); + mOverlappingPairs[index].~Array(); mMaterials[index].~Material(); } diff --git a/src/components/CollisionBodyComponents.cpp b/src/components/CollisionBodyComponents.cpp index eeadf088..8aee03db 100644 --- a/src/components/CollisionBodyComponents.cpp +++ b/src/components/CollisionBodyComponents.cpp @@ -34,7 +34,7 @@ using namespace reactphysics3d; // Constructor CollisionBodyComponents::CollisionBodyComponents(MemoryAllocator& allocator) - :Components(allocator, sizeof(Entity) + sizeof(CollisionBody*) + sizeof(List) + + :Components(allocator, sizeof(Entity) + sizeof(CollisionBody*) + sizeof(Array) + sizeof(bool) + sizeof(void*)) { // Allocate memory for the components data @@ -56,7 +56,7 @@ void CollisionBodyComponents::allocate(uint32 nbComponentsToAllocate) { // New pointers to components data Entity* newBodiesEntities = static_cast(newBuffer); CollisionBody** newBodies = reinterpret_cast(newBodiesEntities + nbComponentsToAllocate); - List* newColliders = reinterpret_cast*>(newBodies + nbComponentsToAllocate); + Array* newColliders = reinterpret_cast*>(newBodies + nbComponentsToAllocate); bool* newIsActive = reinterpret_cast(newColliders + nbComponentsToAllocate); void** newUserData = reinterpret_cast(newIsActive + nbComponentsToAllocate); @@ -66,7 +66,7 @@ void CollisionBodyComponents::allocate(uint32 nbComponentsToAllocate) { // Copy component data from the previous buffer to the new one memcpy(newBodiesEntities, mBodiesEntities, mNbComponents * sizeof(Entity)); memcpy(newBodies, mBodies, mNbComponents * sizeof(CollisionBody*)); - memcpy(newColliders, mColliders, mNbComponents * sizeof(List)); + memcpy(newColliders, mColliders, mNbComponents * sizeof(Array)); memcpy(newIsActive, mIsActive, mNbComponents * sizeof(bool)); memcpy(newUserData, mUserData, mNbComponents * sizeof(void*)); @@ -92,7 +92,7 @@ void CollisionBodyComponents::addComponent(Entity bodyEntity, bool isSleeping, c // Insert the new component data new (mBodiesEntities + index) Entity(bodyEntity); mBodies[index] = component.body; - new (mColliders + index) List(mMemoryAllocator); + new (mColliders + index) Array(mMemoryAllocator); mIsActive[index] = true; mUserData[index] = nullptr; @@ -114,7 +114,7 @@ void CollisionBodyComponents::moveComponentToIndex(uint32 srcIndex, uint32 destI // Copy the data of the source component to the destination location new (mBodiesEntities + destIndex) Entity(mBodiesEntities[srcIndex]); mBodies[destIndex] = mBodies[srcIndex]; - new (mColliders + destIndex) List(mColliders[srcIndex]); + new (mColliders + destIndex) Array(mColliders[srcIndex]); mIsActive[destIndex] = mIsActive[srcIndex]; mUserData[destIndex] = mUserData[srcIndex]; @@ -135,7 +135,7 @@ void CollisionBodyComponents::swapComponents(uint32 index1, uint32 index2) { // Copy component 1 data Entity entity1(mBodiesEntities[index1]); CollisionBody* body1 = mBodies[index1]; - List colliders1(mColliders[index1]); + Array colliders1(mColliders[index1]); bool isActive1 = mIsActive[index1]; void* userData1 = mUserData[index1]; @@ -146,7 +146,7 @@ void CollisionBodyComponents::swapComponents(uint32 index1, uint32 index2) { // Reconstruct component 1 at component 2 location new (mBodiesEntities + index2) Entity(entity1); - new (mColliders + index2) List(colliders1); + new (mColliders + index2) Array(colliders1); mBodies[index2] = body1; mIsActive[index2] = isActive1; mUserData[index2] = userData1; @@ -170,6 +170,6 @@ void CollisionBodyComponents::destroyComponent(uint32 index) { mBodiesEntities[index].~Entity(); mBodies[index] = nullptr; - mColliders[index].~List(); + mColliders[index].~Array(); mUserData[index] = nullptr; } diff --git a/src/components/RigidBodyComponents.cpp b/src/components/RigidBodyComponents.cpp index 6d2a389a..ce851b4d 100644 --- a/src/components/RigidBodyComponents.cpp +++ b/src/components/RigidBodyComponents.cpp @@ -43,7 +43,7 @@ RigidBodyComponents::RigidBodyComponents(MemoryAllocator& allocator) sizeof(Vector3) + + sizeof(Matrix3x3) + sizeof(Vector3) + sizeof(Vector3) + sizeof(Vector3) + sizeof(Vector3) + sizeof(Vector3) + sizeof(Quaternion) + sizeof(Vector3) + sizeof(Vector3) + - sizeof(bool) + sizeof(bool) + sizeof(List) + sizeof(List)) { + sizeof(bool) + sizeof(bool) + sizeof(Array) + sizeof(Array)) { // Allocate memory for the components data allocate(INIT_NB_ALLOCATED_COMPONENTS); @@ -89,8 +89,8 @@ void RigidBodyComponents::allocate(uint32 nbComponentsToAllocate) { Vector3* newCentersOfMassWorld = reinterpret_cast(newCentersOfMassLocal + nbComponentsToAllocate); bool* newIsGravityEnabled = reinterpret_cast(newCentersOfMassWorld + nbComponentsToAllocate); bool* newIsAlreadyInIsland = reinterpret_cast(newIsGravityEnabled + nbComponentsToAllocate); - List* newJoints = reinterpret_cast*>(newIsAlreadyInIsland + nbComponentsToAllocate); - List* newContactPairs = reinterpret_cast*>(newJoints + nbComponentsToAllocate); + Array* newJoints = reinterpret_cast*>(newIsAlreadyInIsland + nbComponentsToAllocate); + Array* newContactPairs = reinterpret_cast*>(newJoints + nbComponentsToAllocate); // If there was already components before if (mNbComponents > 0) { @@ -123,8 +123,8 @@ void RigidBodyComponents::allocate(uint32 nbComponentsToAllocate) { memcpy(newCentersOfMassWorld, mCentersOfMassWorld, mNbComponents * sizeof(Vector3)); memcpy(newIsGravityEnabled, mIsGravityEnabled, mNbComponents * sizeof(bool)); memcpy(newIsAlreadyInIsland, mIsAlreadyInIsland, mNbComponents * sizeof(bool)); - memcpy(newJoints, mJoints, mNbComponents * sizeof(List)); - memcpy(newContactPairs, mContactPairs, mNbComponents * sizeof(List)); + memcpy(newJoints, mJoints, mNbComponents * sizeof(Array)); + memcpy(newContactPairs, mContactPairs, mNbComponents * sizeof(Array)); // Deallocate previous memory mMemoryAllocator.release(mBuffer, mNbAllocatedComponents * mComponentDataSize); @@ -197,8 +197,8 @@ void RigidBodyComponents::addComponent(Entity bodyEntity, bool isSleeping, const new (mCentersOfMassWorld + index) Vector3(component.worldPosition); mIsGravityEnabled[index] = true; mIsAlreadyInIsland[index] = false; - new (mJoints + index) List(mMemoryAllocator); - new (mContactPairs + index) List(mMemoryAllocator); + new (mJoints + index) Array(mMemoryAllocator); + new (mContactPairs + index) Array(mMemoryAllocator); // Map the entity with the new component lookup index mMapEntityToComponentIndex.add(Pair(bodyEntity, index)); @@ -243,8 +243,8 @@ void RigidBodyComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex new (mCentersOfMassWorld + destIndex) Vector3(mCentersOfMassWorld[srcIndex]); mIsGravityEnabled[destIndex] = mIsGravityEnabled[srcIndex]; mIsAlreadyInIsland[destIndex] = mIsAlreadyInIsland[srcIndex]; - new (mJoints + destIndex) List(mJoints[srcIndex]); - new (mContactPairs + destIndex) List(mContactPairs[srcIndex]); + new (mJoints + destIndex) Array(mJoints[srcIndex]); + new (mContactPairs + destIndex) Array(mContactPairs[srcIndex]); // Destroy the source component destroyComponent(srcIndex); @@ -288,8 +288,8 @@ void RigidBodyComponents::swapComponents(uint32 index1, uint32 index2) { Vector3 centerOfMassWorld1 = mCentersOfMassWorld[index1]; bool isGravityEnabled1 = mIsGravityEnabled[index1]; bool isAlreadyInIsland1 = mIsAlreadyInIsland[index1]; - List joints1 = mJoints[index1]; - List contactPairs1 = mContactPairs[index1]; + Array joints1 = mJoints[index1]; + Array contactPairs1 = mContactPairs[index1]; // Destroy component 1 destroyComponent(index1); @@ -324,8 +324,8 @@ void RigidBodyComponents::swapComponents(uint32 index1, uint32 index2) { mCentersOfMassWorld[index2] = centerOfMassWorld1; mIsGravityEnabled[index2] = isGravityEnabled1; mIsAlreadyInIsland[index2] = isAlreadyInIsland1; - new (mJoints + index2) List(joints1); - new (mContactPairs + index2) List(contactPairs1); + new (mJoints + index2) Array(joints1); + new (mContactPairs + index2) Array(contactPairs1); // Update the entity to component index mapping mMapEntityToComponentIndex.add(Pair(entity1, index2)); @@ -361,6 +361,6 @@ void RigidBodyComponents::destroyComponent(uint32 index) { mConstrainedOrientations[index].~Quaternion(); mCentersOfMassLocal[index].~Vector3(); mCentersOfMassWorld[index].~Vector3(); - mJoints[index].~List(); - mContactPairs[index].~List(); + mJoints[index].~Array(); + mContactPairs[index].~Array(); } diff --git a/src/engine/PhysicsWorld.cpp b/src/engine/PhysicsWorld.cpp index f7ad6433..c1b6ff1e 100644 --- a/src/engine/PhysicsWorld.cpp +++ b/src/engine/PhysicsWorld.cpp @@ -217,7 +217,7 @@ void PhysicsWorld::destroyCollisionBody(CollisionBody* collisionBody) { // Call the destructor of the collision body collisionBody->~CollisionBody(); - // Remove the collision body from the list of bodies + // Remove the collision body from the array of bodies mCollisionBodies.remove(collisionBody); // Free the object from the memory allocator @@ -238,7 +238,7 @@ void PhysicsWorld::setBodyDisabled(Entity bodyEntity, bool isDisabled) { mRigidBodyComponents.setIsEntityDisabled(bodyEntity, isDisabled); // For each collider of the body - const List& collidersEntities = mCollisionBodyComponents.getColliders(bodyEntity); + const Array& collidersEntities = mCollisionBodyComponents.getColliders(bodyEntity); for (uint32 i=0; i < collidersEntities.size(); i++) { mCollidersComponents.setIsEntityDisabled(collidersEntities[i], isDisabled); @@ -246,7 +246,7 @@ void PhysicsWorld::setBodyDisabled(Entity bodyEntity, bool isDisabled) { // Disable the joints of the body if necessary // For each joint of the body - const List& joints = mRigidBodyComponents.getJoints(bodyEntity); + const Array& joints = mRigidBodyComponents.getJoints(bodyEntity); for(uint32 i=0; i < joints.size(); i++) { const Entity body1Entity = mJointsComponents.getBody1Entity(joints[i]); @@ -518,7 +518,7 @@ void PhysicsWorld::destroyRigidBody(RigidBody* rigidBody) { rigidBody->removeAllColliders(); // Destroy all the joints in which the rigid body to be destroyed is involved - const List& joints = mRigidBodyComponents.getJoints(rigidBody->getEntity()); + const Array& joints = mRigidBodyComponents.getJoints(rigidBody->getEntity()); for (uint32 i=0; i < joints.size(); i++) { destroyJoint(mJointsComponents.getJoint(joints[i])); } @@ -532,7 +532,7 @@ void PhysicsWorld::destroyRigidBody(RigidBody* rigidBody) { // Call the destructor of the rigid body rigidBody->~RigidBody(); - // Remove the rigid body from the list of rigid bodies + // Remove the rigid body from the array of rigid bodies mRigidBodies.remove(rigidBody); // Free the object from the memory allocator @@ -656,7 +656,7 @@ Joint* PhysicsWorld::createJoint(const JointInfo& jointInfo) { RP3D_LOG(mConfig.worldName, Logger::Level::Information, Logger::Category::Joint, "Joint " + std::to_string(newJoint->getEntity().id) + ": " + newJoint->to_string(), __FILE__, __LINE__); - // Add the joint into the joint list of the bodies involved in the joint + // Add the joint into the joint array of the bodies involved in the joint addJointToBodies(jointInfo.body1->getEntity(), jointInfo.body2->getEntity(), entity); // Return the pointer to the created joint @@ -688,7 +688,7 @@ void PhysicsWorld::destroyJoint(Joint* joint) { body1->setIsSleeping(false); body2->setIsSleeping(false); - // Remove the joint from the joint list of the bodies involved in the joint + // Remove the joint from the joint array of the bodies involved in the joint mRigidBodyComponents.removeJointFromBody(body1->getEntity(), joint->getEntity()); mRigidBodyComponents.removeJointFromBody(body2->getEntity(), joint->getEntity()); @@ -732,7 +732,7 @@ void PhysicsWorld::setNbIterationsVelocitySolver(uint nbIterations) { "Physics World: Set nb iterations velocity solver to " + std::to_string(nbIterations), __FILE__, __LINE__); } -// Add the joint to the list of joints of the two bodies involved in the joint +// Add the joint to the array of joints of the two bodies involved in the joint void PhysicsWorld::addJointToBodies(Entity body1, Entity body2, Entity joint) { mRigidBodyComponents.addJointToBody(body1, joint); @@ -777,8 +777,8 @@ void PhysicsWorld::createIslands() { // Create a stack for the bodies to visit during the Depth First Search Stack bodyEntitiesToVisit(mMemoryManager.getSingleFrameAllocator(), mIslands.getNbMaxBodiesInIslandPreviousFrame()); - // List of static bodies added to the current island (used to reset the isAlreadyInIsland variable of static bodies) - List staticBodiesAddedToIsland(mMemoryManager.getSingleFrameAllocator(), 16); + // Array of static bodies added to the current island (used to reset the isAlreadyInIsland variable of static bodies) + Array staticBodiesAddedToIsland(mMemoryManager.getSingleFrameAllocator(), 16); uint nbTotalManifolds = 0; @@ -862,13 +862,13 @@ void PhysicsWorld::createIslands() { } else { - // Add the contact pair index in the list of contact pairs that won't be part of islands + // Add the contact pair index in the array of contact pairs that won't be part of islands pair.isAlreadyInIsland = true; } } // For each joint in which the current body is involved - const List& joints = mRigidBodyComponents.getJoints(rigidBodyToVisit->getEntity()); + const Array& joints = mRigidBodyComponents.getJoints(rigidBodyToVisit->getEntity()); for (uint32 i=0; i < joints.size(); i++) { // Check if the current joint has already been added into an island @@ -981,7 +981,7 @@ void PhysicsWorld::enableSleeping(bool isSleepingEnabled) { if (!mIsSleepingEnabled) { // For each body of the world - List::Iterator it; + Array::Iterator it; for (it = mRigidBodies.begin(); it != mRigidBodies.end(); ++it) { // Wake up the rigid body diff --git a/src/mathematics/mathematics_functions.cpp b/src/mathematics/mathematics_functions.cpp index 4db9367c..a237a6d2 100755 --- a/src/mathematics/mathematics_functions.cpp +++ b/src/mathematics/mathematics_functions.cpp @@ -221,14 +221,14 @@ decimal reactphysics3d::computePointToLineDistance(const Vector3& linePointA, co // Clip a segment against multiple planes and return the clipped segment vertices // This method implements the Sutherland–Hodgman clipping algorithm -List reactphysics3d::clipSegmentWithPlanes(const Vector3& segA, const Vector3& segB, - const List& planesPoints, - const List& planesNormals, +Array reactphysics3d::clipSegmentWithPlanes(const Vector3& segA, const Vector3& segB, + const Array& planesPoints, + const Array& planesNormals, MemoryAllocator& allocator) { assert(planesPoints.size() == planesNormals.size()); - List inputVertices(allocator, 2); - List outputVertices(allocator, 2); + Array inputVertices(allocator, 2); + Array outputVertices(allocator, 2); inputVertices.add(segA); inputVertices.add(segB); @@ -296,14 +296,14 @@ List reactphysics3d::clipSegmentWithPlanes(const Vector3& segA, const V // Clip a polygon against multiple planes and return the clipped polygon vertices // This method implements the Sutherland–Hodgman clipping algorithm -List reactphysics3d::clipPolygonWithPlanes(const List& polygonVertices, const List& planesPoints, - const List& planesNormals, MemoryAllocator& allocator) { +Array reactphysics3d::clipPolygonWithPlanes(const Array& polygonVertices, const Array& planesPoints, + const Array& planesNormals, MemoryAllocator& allocator) { assert(planesPoints.size() == planesNormals.size()); uint32 nbMaxElements = polygonVertices.size() + planesPoints.size(); - List inputVertices(allocator, nbMaxElements); - List outputVertices(allocator, nbMaxElements); + Array inputVertices(allocator, nbMaxElements); + Array outputVertices(allocator, nbMaxElements); inputVertices.addRange(polygonVertices); diff --git a/src/systems/BroadPhaseSystem.cpp b/src/systems/BroadPhaseSystem.cpp index 8c1326a6..a66a760b 100644 --- a/src/systems/BroadPhaseSystem.cpp +++ b/src/systems/BroadPhaseSystem.cpp @@ -206,12 +206,12 @@ void BroadPhaseSystem::addMovedCollider(int broadPhaseID, Collider* collider) { } // Compute all the overlapping pairs of collision shapes -void BroadPhaseSystem::computeOverlappingPairs(MemoryManager& memoryManager, List>& overlappingNodes) { +void BroadPhaseSystem::computeOverlappingPairs(MemoryManager& memoryManager, Array>& overlappingNodes) { RP3D_PROFILE("BroadPhaseSystem::computeOverlappingPairs()", mProfiler); - // Get the list of the colliders that have moved or have been created in the last frame - List shapesToTest = mMovedShapes.toList(memoryManager.getHeapAllocator()); + // Get the array of the colliders that have moved or have been created in the last frame + Array shapesToTest = mMovedShapes.toArray(memoryManager.getHeapAllocator()); // Ask the dynamic AABB tree to report all collision shapes that overlap with the shapes to test mDynamicAABBTree.reportAllShapesOverlappingWithShapes(shapesToTest, 0, shapesToTest.size(), overlappingNodes); diff --git a/src/systems/CollisionDetectionSystem.cpp b/src/systems/CollisionDetectionSystem.cpp index 756acda1..247d8467 100644 --- a/src/systems/CollisionDetectionSystem.cpp +++ b/src/systems/CollisionDetectionSystem.cpp @@ -195,8 +195,8 @@ void CollisionDetectionSystem::addLostContactPair(OverlappingPairs::OverlappingP mLostContactPairs.add(lostContactPair); } -// Take a list of overlapping nodes in the broad-phase and create new overlapping pairs if necessary -void CollisionDetectionSystem::updateOverlappingPairs(const List>& overlappingNodes) { +// Take an array of overlapping nodes in the broad-phase and create new overlapping pairs if necessary +void CollisionDetectionSystem::updateOverlappingPairs(const Array>& overlappingNodes) { RP3D_PROFILE("CollisionDetectionSystem::updateOverlappingPairs()", mProfiler); @@ -356,7 +356,7 @@ void CollisionDetectionSystem::computeMiddlePhase(NarrowPhaseInput& narrowPhaseI } // Compute the middle-phase collision detection -void CollisionDetectionSystem::computeMiddlePhaseCollisionSnapshot(List& convexPairs, List& concavePairs, +void CollisionDetectionSystem::computeMiddlePhaseCollisionSnapshot(Array& convexPairs, Array& concavePairs, NarrowPhaseInput& narrowPhaseInput, bool reportContacts) { RP3D_PROFILE("CollisionDetectionSystem::computeMiddlePhase()", mProfiler); @@ -454,9 +454,9 @@ void CollisionDetectionSystem::computeConvexVsConcaveMiddlePhase(OverlappingPair convexShape->computeAABB(aabb, convexToConcaveTransform); // Compute the concave shape triangles that are overlapping with the convex mesh AABB - List triangleVertices(allocator, 64); - List triangleVerticesNormals(allocator, 64); - List shapeIds(allocator, 64); + Array triangleVertices(allocator, 64); + Array triangleVerticesNormals(allocator, 64); + Array shapeIds(allocator, 64); concaveShape->computeOverlappingTriangles(aabb, triangleVertices, triangleVerticesNormals, shapeIds, allocator); assert(triangleVertices.size() == triangleVerticesNormals.size()); @@ -559,9 +559,9 @@ bool CollisionDetectionSystem::testNarrowPhaseCollision(NarrowPhaseInput& narrow // Process the potential contacts after narrow-phase collision detection void CollisionDetectionSystem::processAllPotentialContacts(NarrowPhaseInput& narrowPhaseInput, bool updateLastFrameInfo, - List& potentialContactPoints, - List& potentialContactManifolds, - List* contactPairs) { + Array& potentialContactPoints, + Array& potentialContactManifolds, + Array* contactPairs) { assert(contactPairs->size() == 0); @@ -592,7 +592,7 @@ void CollisionDetectionSystem::computeNarrowPhase() { MemoryAllocator& allocator = mMemoryManager.getSingleFrameAllocator(); - // Swap the previous and current contacts lists + // Swap the previous and current contacts arrays swapPreviousAndCurrentContacts(); mPotentialContactManifolds.reserve(mPreviousContactManifolds->size()); @@ -665,8 +665,8 @@ bool CollisionDetectionSystem::computeNarrowPhaseOverlapSnapshot(NarrowPhaseInpu if (collisionFound && callback != nullptr) { // Compute the overlapping colliders - List contactPairs(allocator); - List lostContactPairs(allocator); // Always empty in this case (snapshot) + Array contactPairs(allocator); + Array lostContactPairs(allocator); // Always empty in this case (snapshot) computeOverlapSnapshotContactPairs(narrowPhaseInput, contactPairs); // Report overlapping colliders @@ -678,7 +678,7 @@ bool CollisionDetectionSystem::computeNarrowPhaseOverlapSnapshot(NarrowPhaseInpu } // Process the potential overlapping bodies for the testOverlap() methods -void CollisionDetectionSystem::computeOverlapSnapshotContactPairs(NarrowPhaseInput& narrowPhaseInput, List& contactPairs) const { +void CollisionDetectionSystem::computeOverlapSnapshotContactPairs(NarrowPhaseInput& narrowPhaseInput, Array& contactPairs) const { Set setOverlapContactPairId(mMemoryManager.getHeapAllocator()); @@ -703,7 +703,7 @@ void CollisionDetectionSystem::computeOverlapSnapshotContactPairs(NarrowPhaseInp void CollisionDetectionSystem::notifyOverlappingPairsToTestOverlap(Collider* collider) { // Get the overlapping pairs involved with this collider - List& overlappingPairs = mCollidersComponents.getOverlappingPairs(collider->getEntity()); + Array& overlappingPairs = mCollidersComponents.getOverlappingPairs(collider->getEntity()); const uint32 nbPairs = overlappingPairs.size(); for (uint32 i=0; i < nbPairs; i++) { @@ -714,7 +714,7 @@ void CollisionDetectionSystem::notifyOverlappingPairsToTestOverlap(Collider* col } // Convert the potential overlapping bodies for the testOverlap() methods -void CollisionDetectionSystem::computeOverlapSnapshotContactPairs(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, List& contactPairs, +void CollisionDetectionSystem::computeOverlapSnapshotContactPairs(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, Array& contactPairs, Set& setOverlapContactPairId) const { RP3D_PROFILE("CollisionDetectionSystem::computeSnapshotContactPairs()", mProfiler); @@ -765,12 +765,12 @@ bool CollisionDetectionSystem::computeNarrowPhaseCollisionSnapshot(NarrowPhaseIn // If collision has been found, create contacts if (collisionFound) { - List potentialContactPoints(allocator); - List potentialContactManifolds(allocator); - List contactPairs(allocator); - List lostContactPairs(allocator); // Not used during collision snapshots - List contactManifolds(allocator); - List contactPoints(allocator); + Array potentialContactPoints(allocator); + Array potentialContactManifolds(allocator); + Array contactPairs(allocator); + Array lostContactPairs(allocator); // Not used during collision snapshots + Array contactManifolds(allocator); + Array contactPoints(allocator); // Process all the potential contacts after narrow-phase collision processAllPotentialContacts(narrowPhaseInput, true, potentialContactPoints, potentialContactManifolds, &contactPairs); @@ -788,7 +788,7 @@ bool CollisionDetectionSystem::computeNarrowPhaseCollisionSnapshot(NarrowPhaseIn return collisionFound; } -// Swap the previous and current contacts lists +// Swap the previous and current contacts arrays void CollisionDetectionSystem::swapPreviousAndCurrentContacts() { if (mPreviousContactPairs == &mContactPairs1) { @@ -927,11 +927,11 @@ void CollisionDetectionSystem::computeLostContactPairs() { } // Create the actual contact manifolds and contacts points for testCollision() methods -void CollisionDetectionSystem::createSnapshotContacts(List& contactPairs, - List& contactManifolds, - List& contactPoints, - List& potentialContactManifolds, - List& potentialContactPoints) { +void CollisionDetectionSystem::createSnapshotContacts(Array& contactPairs, + Array& contactManifolds, + Array& contactPoints, + Array& potentialContactManifolds, + Array& potentialContactPoints) { RP3D_PROFILE("CollisionDetectionSystem::createSnapshotContacts()", mProfiler); @@ -1078,10 +1078,10 @@ void CollisionDetectionSystem::removeCollider(Collider* collider) { assert(mMapBroadPhaseIdToColliderEntity.containsKey(colliderBroadPhaseId)); // Remove all the overlapping pairs involving this collider - List& overlappingPairs = mCollidersComponents.getOverlappingPairs(collider->getEntity()); + Array& overlappingPairs = mCollidersComponents.getOverlappingPairs(collider->getEntity()); while(overlappingPairs.size() > 0) { - // TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds list of the two bodies involved + // TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds array of the two bodies involved // Remove the overlapping pair mOverlappingPairs.removePair(overlappingPairs[0]); @@ -1109,10 +1109,10 @@ void CollisionDetectionSystem::raycast(RaycastCallback* raycastCallback, // Convert the potential contact into actual contacts void CollisionDetectionSystem::processPotentialContacts(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, bool updateLastFrameInfo, - List& potentialContactPoints, - List& potentialContactManifolds, + Array& potentialContactPoints, + Array& potentialContactManifolds, Map& mapPairIdToContactPairIndex, - List* contactPairs) { + Array* contactPairs) { RP3D_PROFILE("CollisionDetectionSystem::processPotentialContacts()", mProfiler); @@ -1183,7 +1183,7 @@ void CollisionDetectionSystem::processPotentialContacts(NarrowPhaseInfoBatch& na contactManifoldInfo.potentialContactPointsIndices[contactManifoldInfo.nbPotentialContactPoints] = contactPointIndexStart + j; contactManifoldInfo.nbPotentialContactPoints++; - // Add the contact point to the list of potential contact points + // Add the contact point to the array of potential contact points const ContactPointInfo& contactPoint = narrowPhaseInfoBatch.narrowPhaseInfos[i].contactPoints[j]; potentialContactPoints.add(contactPoint); @@ -1230,7 +1230,7 @@ void CollisionDetectionSystem::processPotentialContacts(NarrowPhaseInfoBatch& na const ContactPointInfo& contactPoint = narrowPhaseInfoBatch.narrowPhaseInfos[i].contactPoints[j]; - // Add the contact point to the list of potential contact points + // Add the contact point to the array of potential contact points const uint32 contactPointIndex = potentialContactPoints.size(); potentialContactPoints.add(contactPoint); @@ -1294,9 +1294,9 @@ void CollisionDetectionSystem::processPotentialContacts(NarrowPhaseInfoBatch& na } // Clear the obsolete manifolds and contact points and reduce the number of contacts points of the remaining manifolds -void CollisionDetectionSystem::reducePotentialContactManifolds(List* contactPairs, - List& potentialContactManifolds, - const List& potentialContactPoints) const { +void CollisionDetectionSystem::reducePotentialContactManifolds(Array* contactPairs, + Array& potentialContactManifolds, + const Array& potentialContactPoints) const { RP3D_PROFILE("CollisionDetectionSystem::reducePotentialContactManifolds()", mProfiler); @@ -1357,7 +1357,7 @@ void CollisionDetectionSystem::reducePotentialContactManifolds(List // Return the largest depth of all the contact points of a potential manifold decimal CollisionDetectionSystem::computePotentialManifoldLargestContactDepth(const ContactManifoldInfo& manifold, - const List& potentialContactPoints) const { + const Array& potentialContactPoints) const { decimal largestDepth = 0.0f; @@ -1379,15 +1379,15 @@ decimal CollisionDetectionSystem::computePotentialManifoldLargestContactDepth(co // "Contacts Creation" GDC presentation. This method will reduce the number of // contact points to a maximum of 4 points (but it can be less). void CollisionDetectionSystem::reduceContactPoints(ContactManifoldInfo& manifold, const Transform& shape1ToWorldTransform, - const List& potentialContactPoints) const { + const Array& potentialContactPoints) const { assert(manifold.nbPotentialContactPoints > MAX_CONTACT_POINTS_IN_MANIFOLD); // The following algorithm only works to reduce to a maximum of 4 contact points assert(MAX_CONTACT_POINTS_IN_MANIFOLD == 4); - // List of the candidate contact points indices in the manifold. Every time that we have found a - // point we want to keep, we will remove it from this list + // Array of the candidate contact points indices in the manifold. Every time that we have found a + // point we want to keep, we will remove it from this array uint candidatePointsIndices[NB_MAX_CONTACT_POINTS_IN_POTENTIAL_MANIFOLD]; uint8 nbCandidatePoints = manifold.nbPotentialContactPoints; for (uint8 i=0 ; i < manifold.nbPotentialContactPoints; i++) { @@ -1589,8 +1589,8 @@ void CollisionDetectionSystem::reportContactsAndTriggers() { } // Report all contacts to the user -void CollisionDetectionSystem::reportContacts(CollisionCallback& callback, List* contactPairs, - List* manifolds, List* contactPoints, List& lostContactPairs) { +void CollisionDetectionSystem::reportContacts(CollisionCallback& callback, Array* contactPairs, + Array* manifolds, Array* contactPoints, Array& lostContactPairs) { RP3D_PROFILE("CollisionDetectionSystem::reportContacts()", mProfiler); @@ -1605,7 +1605,7 @@ void CollisionDetectionSystem::reportContacts(CollisionCallback& callback, List< } // Report all triggers to the user -void CollisionDetectionSystem::reportTriggers(EventListener& eventListener, List* contactPairs, List& lostContactPairs) { +void CollisionDetectionSystem::reportTriggers(EventListener& eventListener, Array* contactPairs, Array& lostContactPairs) { RP3D_PROFILE("CollisionDetectionSystem::reportTriggers()", mProfiler); @@ -1620,7 +1620,7 @@ void CollisionDetectionSystem::reportTriggers(EventListener& eventListener, List } // Report all contacts for debug rendering -void CollisionDetectionSystem::reportDebugRenderingContacts(List* contactPairs, List* manifolds, List* contactPoints, List& lostContactPairs) { +void CollisionDetectionSystem::reportDebugRenderingContacts(Array* contactPairs, Array* manifolds, Array* contactPoints, Array& lostContactPairs) { RP3D_PROFILE("CollisionDetectionSystem::reportDebugRenderingContacts()", mProfiler); @@ -1643,8 +1643,8 @@ bool CollisionDetectionSystem::testOverlap(CollisionBody* body1, CollisionBody* computeBroadPhase(); // Filter the overlapping pairs to get only the ones with the selected body involved - List convexPairs(mMemoryManager.getPoolAllocator()); - List concavePairs(mMemoryManager.getPoolAllocator()); + Array convexPairs(mMemoryManager.getPoolAllocator()); + Array concavePairs(mMemoryManager.getPoolAllocator()); filterOverlappingPairs(body1->getEntity(), body2->getEntity(), convexPairs, concavePairs); if (convexPairs.size() > 0 || concavePairs.size() > 0) { @@ -1683,8 +1683,8 @@ void CollisionDetectionSystem::testOverlap(CollisionBody* body, OverlapCallback& computeBroadPhase(); // Filter the overlapping pairs to get only the ones with the selected body involved - List convexPairs(mMemoryManager.getPoolAllocator()); - List concavePairs(mMemoryManager.getPoolAllocator()); + Array convexPairs(mMemoryManager.getPoolAllocator()); + Array concavePairs(mMemoryManager.getPoolAllocator()); filterOverlappingPairs(body->getEntity(), convexPairs, concavePairs); if (convexPairs.size() > 0 || concavePairs.size() > 0) { @@ -1706,8 +1706,8 @@ void CollisionDetectionSystem::testCollision(CollisionBody* body1, CollisionBody computeBroadPhase(); // Filter the overlapping pairs to get only the ones with the selected body involved - List convexPairs(mMemoryManager.getPoolAllocator()); - List concavePairs(mMemoryManager.getPoolAllocator()); + Array convexPairs(mMemoryManager.getPoolAllocator()); + Array concavePairs(mMemoryManager.getPoolAllocator()); filterOverlappingPairs(body1->getEntity(), body2->getEntity(), convexPairs, concavePairs); if (convexPairs.size() > 0 || concavePairs.size() > 0) { @@ -1729,8 +1729,8 @@ void CollisionDetectionSystem::testCollision(CollisionBody* body, CollisionCallb computeBroadPhase(); // Filter the overlapping pairs to get only the ones with the selected body involved - List convexPairs(mMemoryManager.getPoolAllocator()); - List concavePairs(mMemoryManager.getPoolAllocator()); + Array convexPairs(mMemoryManager.getPoolAllocator()); + Array concavePairs(mMemoryManager.getPoolAllocator()); filterOverlappingPairs(body->getEntity(), convexPairs, concavePairs); if (convexPairs.size() > 0 || concavePairs.size() > 0) { @@ -1759,7 +1759,7 @@ void CollisionDetectionSystem::testCollision(CollisionCallback& callback) { } // Filter the overlapping pairs to keep only the pairs where a given body is involved -void CollisionDetectionSystem::filterOverlappingPairs(Entity bodyEntity, List& convexPairs, List& concavePairs) const { +void CollisionDetectionSystem::filterOverlappingPairs(Entity bodyEntity, Array& convexPairs, Array& concavePairs) const { // For each convex pairs const uint32 nbConvexPairs = mOverlappingPairs.mConvexPairs.size(); @@ -1785,7 +1785,7 @@ void CollisionDetectionSystem::filterOverlappingPairs(Entity bodyEntity, List& convexPairs, List& concavePairs) const { +void CollisionDetectionSystem::filterOverlappingPairs(Entity body1Entity, Entity body2Entity, Array& convexPairs, Array& concavePairs) const { // For each convex pair const uint32 nbConvexPairs = mOverlappingPairs.mConvexPairs.size(); diff --git a/src/systems/ContactSolverSystem.cpp b/src/systems/ContactSolverSystem.cpp index 40220359..18139b8f 100644 --- a/src/systems/ContactSolverSystem.cpp +++ b/src/systems/ContactSolverSystem.cpp @@ -62,7 +62,7 @@ ContactSolverSystem::ContactSolverSystem(MemoryManager& memoryManager, PhysicsWo } // Initialize the contact constraints -void ContactSolverSystem::init(List* contactManifolds, List* contactPoints, decimal timeStep) { +void ContactSolverSystem::init(Array* contactManifolds, Array* contactPoints, decimal timeStep) { mAllContactManifolds = contactManifolds; mAllContactPoints = contactPoints; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 804f7cb8..c125f2ac 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,7 +15,7 @@ set (RP3D_TESTS_HEADERS "tests/collision/TestPointInside.h" "tests/collision/TestRaycast.h" "tests/collision/TestTriangleVertexArray.h" - "tests/containers/TestList.h" + "tests/containers/TestArray.h" "tests/containers/TestMap.h" "tests/containers/TestSet.h" "tests/containers/TestStack.h" diff --git a/test/main.cpp b/test/main.cpp index 3d2ba550..0346ee57 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -39,7 +39,7 @@ #include "tests/collision/TestDynamicAABBTree.h" #include "tests/collision/TestHalfEdgeStructure.h" #include "tests/collision/TestTriangleVertexArray.h" -#include "tests/containers/TestList.h" +#include "tests/containers/TestArray.h" #include "tests/containers/TestMap.h" #include "tests/containers/TestSet.h" #include "tests/containers/TestDeque.h" @@ -54,7 +54,7 @@ int main() { // ---------- Containers tests ---------- // testSuite.addTest(new TestSet("Set")); - testSuite.addTest(new TestList("List")); + testSuite.addTest(new TestArray("Array")); testSuite.addTest(new TestMap("Map")); testSuite.addTest(new TestDeque("Deque")); testSuite.addTest(new TestStack("Stack")); diff --git a/test/tests/collision/TestDynamicAABBTree.h b/test/tests/collision/TestDynamicAABBTree.h index 69b876be..22fc4155 100755 --- a/test/tests/collision/TestDynamicAABBTree.h +++ b/test/tests/collision/TestDynamicAABBTree.h @@ -126,7 +126,7 @@ class TestDynamicAABBTree : public Test { } - bool isOverlapping(int nodeId, const List& overlappingNodes) const { + bool isOverlapping(int nodeId, const Array& overlappingNodes) const { return std::find(overlappingNodes.begin(), overlappingNodes.end(), nodeId) != overlappingNodes.end(); } @@ -223,7 +223,7 @@ class TestDynamicAABBTree : public Test { // ---------- Tests ---------- // - List overlappingNodes(mAllocator); + Array overlappingNodes(mAllocator); // AABB overlapping nothing overlappingNodes.clear(); diff --git a/test/tests/collision/TestHalfEdgeStructure.h b/test/tests/collision/TestHalfEdgeStructure.h index 447c1c97..b6f7e834 100644 --- a/test/tests/collision/TestHalfEdgeStructure.h +++ b/test/tests/collision/TestHalfEdgeStructure.h @@ -71,17 +71,17 @@ class TestHalfEdgeStructure : public Test { cubeStructure.addVertex(7); // Faces - List face0(mAllocator, 4); + Array face0(mAllocator, 4); face0.add(0); face0.add(1); face0.add(2); face0.add(3); - List face1(mAllocator, 4); + Array face1(mAllocator, 4); face1.add(1); face1.add(5); face1.add(6); face1.add(2); - List face2(mAllocator, 4); + Array face2(mAllocator, 4); face2.add(5); face2.add(4); face2.add(7); face2.add(6); - List face3(mAllocator, 4); + Array face3(mAllocator, 4); face3.add(4); face3.add(0); face3.add(3); face3.add(7); - List face4(mAllocator, 4); + Array face4(mAllocator, 4); face4.add(0); face4.add(4); face4.add(5); face4.add(1); - List face5(mAllocator, 4); + Array face5(mAllocator, 4); face5.add(2); face5.add(6); face5.add(7); face5.add(3); cubeStructure.addFace(face0); @@ -188,13 +188,13 @@ class TestHalfEdgeStructure : public Test { tetrahedron.addVertex(3); // Faces - List face0(mAllocator, 3); + Array face0(mAllocator, 3); face0.add(0); face0.add(1); face0.add(2); - List face1(mAllocator, 3); + Array face1(mAllocator, 3); face1.add(0); face1.add(3); face1.add(1); - List face2(mAllocator, 3); + Array face2(mAllocator, 3); face2.add(1); face2.add(3); face2.add(2); - List face3(mAllocator, 3); + Array face3(mAllocator, 3); face3.add(0); face3.add(2); face3.add(3); tetrahedron.addFace(face0); diff --git a/test/tests/containers/TestArray.h b/test/tests/containers/TestArray.h new file mode 100644 index 00000000..8faaa8dd --- /dev/null +++ b/test/tests/containers/TestArray.h @@ -0,0 +1,449 @@ +/******************************************************************************** +* ReactPhysics3D physics library, http://www.reactphysics3d.com * +* Copyright (c) 2010-2016 Daniel Chappuis * +********************************************************************************* +* * +* This software is provided 'as-is', without any express or implied warranty. * +* In no event will the authors be held liable for any damages arising from the * +* use of this software. * +* * +* Permission is granted to anyone to use this software for any purpose, * +* including commercial applications, and to alter it and redistribute it * +* freely, subject to the following restrictions: * +* * +* 1. The origin of this software must not be misrepresented; you must not claim * +* that you wrote the original software. If you use this software in a * +* product, an acknowledgment in the product documentation would be * +* appreciated but is not required. * +* * +* 2. Altered source versions must be plainly marked as such, and must not be * +* misrepresented as being the original software. * +* * +* 3. This notice may not be removed or altered from any source distribution. * +* * +********************************************************************************/ + +#ifndef TEST_ARRAY_H +#define TEST_ARRAY_H + +// Libraries +#include "Test.h" +#include +#include + +/// Reactphysics3D namespace +namespace reactphysics3d { + +// Class TestArray +/** + * Unit test for the Array class + */ +class TestArray : public Test { + + private : + + // ---------- Atributes ---------- // + + DefaultAllocator mAllocator; + + public : + + // ---------- Methods ---------- // + + /// Constructor + TestArray(const std::string& name) : Test(name) { + + } + + /// Run the tests + void run() { + + testConstructors(); + testAddRemoveClear(); + testAssignment(); + testIndexing(); + testFind(); + testEquality(); + testReserve(); + testIterators(); + } + + void testConstructors() { + + // ----- Constructors ----- // + + Array array1(mAllocator); + rp3d_test(array1.capacity() == 0); + rp3d_test(array1.size() == 0); + + Array array2(mAllocator, 100); + rp3d_test(array2.capacity() == 100); + rp3d_test(array2.size() == 0); + + Array array3(mAllocator); + array3.add(1); + array3.add(2); + array3.add(3); + rp3d_test(array3.capacity() == 4); + rp3d_test(array3.size() == 3); + + // ----- Copy Constructors ----- // + + Array array4(array1); + rp3d_test(array4.capacity() == 0); + rp3d_test(array4.size() == 0); + + Array array5(array3); + rp3d_test(array5.capacity() == array3.capacity()); + rp3d_test(array5.size() == array3.size()); + for (uint i=0; i arra6(mAllocator, 20); + rp3d_test(arra6.capacity() == 20); + for (uint i=0; i<20; i++) { + arra6.add("test"); + } + rp3d_test(arra6.capacity() == 20); + arra6.add("test"); + rp3d_test(arra6.capacity() == 40); + } + + void testAddRemoveClear() { + + // ----- Test add() ----- // + + Array array1(mAllocator); + array1.add(4); + rp3d_test(array1.size() == 1); + rp3d_test(array1[0] == 4); + array1.add(9); + rp3d_test(array1.size() == 2); + rp3d_test(array1[0] == 4); + rp3d_test(array1[1] == 9); + + const int arraySize = 15; + int arrayTest[arraySize] = {3, 145, -182, 34, 12, 95, -1834, 4143, -111, -111, 4343, 234, 22983, -3432, 753}; + Array array2(mAllocator); + for (uint i=0; i array3(mAllocator); + array3.add(1); + array3.add(2); + array3.add(3); + array3.add(4); + + auto it = array3.removeAt(3); + rp3d_test(array3.size() == 3); + rp3d_test(array3.capacity() == 4); + rp3d_test(it == array3.end()); + rp3d_test(array3[0] == 1); + rp3d_test(array3[1] == 2); + rp3d_test(array3[2] == 3); + + it = array3.removeAt(1); + rp3d_test(array3.size() == 2); + rp3d_test(array3.capacity() == 4); + rp3d_test(array3[0] == 1); + rp3d_test(array3[1] == 3); + rp3d_test(*it == 3); + + array3.removeAt(0); + rp3d_test(array3.size() == 1); + rp3d_test(array3.capacity() == 4); + rp3d_test(array3[0] == 3); + + it = array3.removeAt(0); + rp3d_test(array3.size() == 0); + rp3d_test(array3.capacity() == 4); + rp3d_test(it == array3.end()); + + array3.add(1); + array3.add(2); + array3.add(3); + it = array3.begin(); + array3.remove(it); + rp3d_test(array3.size() == 2); + rp3d_test(array3[0] == 2); + rp3d_test(array3[1] == 3); + it = array3.find(3); + array3.remove(it); + rp3d_test(array3.size() == 1); + rp3d_test(array3[0] == 2); + + array3.add(5); + array3.add(6); + array3.add(7); + it = array3.remove(7); + rp3d_test(it == array3.end()); + rp3d_test(array3.size() == 3); + it = array3.remove(5); + rp3d_test((*it) == 6); + + // ----- Test addRange() ----- // + + Array array4(mAllocator); + array4.add(1); + array4.add(2); + array4.add(3); + + Array array5(mAllocator); + array5.add(4); + array5.add(5); + + Array array6(mAllocator); + array6.addRange(array5); + rp3d_test(array6.size() == array5.size()); + rp3d_test(array6[0] == 4); + rp3d_test(array6[1] == 5); + + array4.addRange(array5); + rp3d_test(array4.size() == 3 + array5.size()); + rp3d_test(array4[0] == 1); + rp3d_test(array4[1] == 2); + rp3d_test(array4[2] == 3); + rp3d_test(array4[3] == 4); + rp3d_test(array4[4] == 5); + + // ----- Test clear() ----- // + + Array array7(mAllocator); + array7.add("test1"); + array7.add("test2"); + array7.add("test3"); + array7.clear(); + rp3d_test(array7.size() == 0); + array7.add("new"); + rp3d_test(array7.size() == 1); + rp3d_test(array7[0] == "new"); + + // ----- Test removeAtAndReplaceByLast() ----- // + + Array array8(mAllocator); + array8.add(1); + array8.add(2); + array8.add(3); + array8.add(4); + array8.removeAtAndReplaceByLast(1); + rp3d_test(array8.size() == 3); + rp3d_test(array8[0] == 1); + rp3d_test(array8[1] == 4); + rp3d_test(array8[2] == 3); + array8.removeAtAndReplaceByLast(2); + rp3d_test(array8.size() == 2); + rp3d_test(array8[0] == 1); + rp3d_test(array8[1] == 4); + array8.removeAtAndReplaceByLast(0); + rp3d_test(array8.size() == 1); + rp3d_test(array8[0] == 4); + array8.removeAtAndReplaceByLast(0); + rp3d_test(array8.size() == 0); + } + + void testAssignment() { + + Array array1(mAllocator); + array1.add(1); + array1.add(2); + array1.add(3); + + Array array2(mAllocator); + array2.add(5); + array2.add(6); + + Array array3(mAllocator); + Array array4(mAllocator); + array4.add(1); + array4.add(2); + + Array array5(mAllocator); + array5.add(1); + array5.add(2); + array5.add(3); + + array3 = array2; + rp3d_test(array2.size() == array3.size()); + rp3d_test(array2[0] == array3[0]); + rp3d_test(array2[1] == array3[1]); + + array4 = array1; + rp3d_test(array4.size() == array1.size()) + rp3d_test(array4[0] == array1[0]); + rp3d_test(array4[1] == array1[1]); + rp3d_test(array4[2] == array1[2]); + + array5 = array2; + rp3d_test(array5.size() == array2.size()); + rp3d_test(array5[0] == array2[0]); + rp3d_test(array5[1] == array2[1]); + } + + void testIndexing() { + + Array array1(mAllocator); + array1.add(1); + array1.add(2); + array1.add(3); + + rp3d_test(array1[0] == 1); + rp3d_test(array1[1] == 2); + rp3d_test(array1[2] == 3); + + array1[0] = 6; + array1[1] = 7; + array1[2] = 8; + + rp3d_test(array1[0] == 6); + rp3d_test(array1[1] == 7); + rp3d_test(array1[2] == 8); + + const int a = array1[0]; + const int b = array1[1]; + rp3d_test(a == 6); + rp3d_test(b == 7); + + array1[0]++; + array1[1]++; + rp3d_test(array1[0] == 7); + rp3d_test(array1[1] == 8); + } + + void testFind() { + + Array array1(mAllocator); + array1.add(1); + array1.add(2); + array1.add(3); + array1.add(4); + array1.add(5); + + rp3d_test(array1.find(1) == array1.begin()); + rp3d_test(*(array1.find(2)) == 2); + rp3d_test(*(array1.find(5)) == 5); + } + + void testEquality() { + + Array array1(mAllocator); + array1.add(1); + array1.add(2); + array1.add(3); + + Array array2(mAllocator); + array2.add(1); + array2.add(2); + + Array array3(mAllocator); + array3.add(1); + array3.add(2); + array3.add(3); + + Array array4(mAllocator); + array4.add(1); + array4.add(5); + array4.add(3); + + rp3d_test(array1 == array1); + rp3d_test(array1 != array2); + rp3d_test(array1 == array3); + rp3d_test(array1 != array4); + rp3d_test(array2 != array4); + } + + void testReserve() { + + Array array1(mAllocator); + array1.reserve(10); + rp3d_test(array1.size() == 0); + rp3d_test(array1.capacity() == 10); + array1.add(1); + array1.add(2); + rp3d_test(array1.capacity() == 10); + rp3d_test(array1.size() == 2); + rp3d_test(array1[0] == 1); + rp3d_test(array1[1] == 2); + + array1.reserve(1); + rp3d_test(array1.capacity() == 10); + + array1.reserve(100); + rp3d_test(array1.capacity() == 100); + rp3d_test(array1[0] == 1); + rp3d_test(array1[1] == 2); + } + + void testIterators() { + + Array array1(mAllocator); + + rp3d_test(array1.begin() == array1.end()); + + array1.add(5); + array1.add(6); + array1.add(8); + array1.add(-1); + + Array::Iterator itBegin = array1.begin(); + Array::Iterator itEnd = array1.end(); + Array::Iterator it = array1.begin(); + + rp3d_test(itBegin < itEnd); + rp3d_test(itBegin <= itEnd); + rp3d_test(itEnd > itBegin); + rp3d_test(itEnd >= itBegin); + + rp3d_test(itBegin == it); + rp3d_test(*it == 5); + rp3d_test(*(it++) == 5); + rp3d_test(*it == 6); + rp3d_test(*(it--) == 6); + rp3d_test(*it == 5); + rp3d_test(*(++it) == 6); + rp3d_test(*it == 6); + rp3d_test(*(--it) == 5); + rp3d_test(*it == 5); + rp3d_test(it == itBegin); + + it = array1.end(); + rp3d_test(it == itEnd); + it--; + rp3d_test(*it == -1); + it++; + rp3d_test(it == itEnd); + + Array array2(mAllocator); + for (auto it = array1.begin(); it != array1.end(); ++it) { + array2.add(*it); + } + + rp3d_test(array1 == array2); + + it = itBegin; + rp3d_test(*(it + 2) == 8); + it += 2; + rp3d_test(*it == 8); + rp3d_test(*(it - 2) == 5); + it -= 2; + rp3d_test(*it == 5); + rp3d_test((itEnd - itBegin) == 4); + + it = itBegin; + *it = 19; + rp3d_test(*it == 19); + } + + }; + +} + +#endif diff --git a/test/tests/containers/TestList.h b/test/tests/containers/TestList.h deleted file mode 100644 index 5e20c32d..00000000 --- a/test/tests/containers/TestList.h +++ /dev/null @@ -1,449 +0,0 @@ -/******************************************************************************** -* ReactPhysics3D physics library, http://www.reactphysics3d.com * -* Copyright (c) 2010-2016 Daniel Chappuis * -********************************************************************************* -* * -* This software is provided 'as-is', without any express or implied warranty. * -* In no event will the authors be held liable for any damages arising from the * -* use of this software. * -* * -* Permission is granted to anyone to use this software for any purpose, * -* including commercial applications, and to alter it and redistribute it * -* freely, subject to the following restrictions: * -* * -* 1. The origin of this software must not be misrepresented; you must not claim * -* that you wrote the original software. If you use this software in a * -* product, an acknowledgment in the product documentation would be * -* appreciated but is not required. * -* * -* 2. Altered source versions must be plainly marked as such, and must not be * -* misrepresented as being the original software. * -* * -* 3. This notice may not be removed or altered from any source distribution. * -* * -********************************************************************************/ - -#ifndef TEST_LIST_H -#define TEST_LIST_H - -// Libraries -#include "Test.h" -#include -#include - -/// Reactphysics3D namespace -namespace reactphysics3d { - -// Class TestList -/** - * Unit test for the List class - */ -class TestList : public Test { - - private : - - // ---------- Atributes ---------- // - - DefaultAllocator mAllocator; - - public : - - // ---------- Methods ---------- // - - /// Constructor - TestList(const std::string& name) : Test(name) { - - } - - /// Run the tests - void run() { - - testConstructors(); - testAddRemoveClear(); - testAssignment(); - testIndexing(); - testFind(); - testEquality(); - testReserve(); - testIterators(); - } - - void testConstructors() { - - // ----- Constructors ----- // - - List list1(mAllocator); - rp3d_test(list1.capacity() == 0); - rp3d_test(list1.size() == 0); - - List list2(mAllocator, 100); - rp3d_test(list2.capacity() == 100); - rp3d_test(list2.size() == 0); - - List list3(mAllocator); - list3.add(1); - list3.add(2); - list3.add(3); - rp3d_test(list3.capacity() == 4); - rp3d_test(list3.size() == 3); - - // ----- Copy Constructors ----- // - - List list4(list1); - rp3d_test(list4.capacity() == 0); - rp3d_test(list4.size() == 0); - - List list5(list3); - rp3d_test(list5.capacity() == list3.capacity()); - rp3d_test(list5.size() == list3.size()); - for (uint i=0; i list6(mAllocator, 20); - rp3d_test(list6.capacity() == 20); - for (uint i=0; i<20; i++) { - list6.add("test"); - } - rp3d_test(list6.capacity() == 20); - list6.add("test"); - rp3d_test(list6.capacity() == 40); - } - - void testAddRemoveClear() { - - // ----- Test add() ----- // - - List list1(mAllocator); - list1.add(4); - rp3d_test(list1.size() == 1); - rp3d_test(list1[0] == 4); - list1.add(9); - rp3d_test(list1.size() == 2); - rp3d_test(list1[0] == 4); - rp3d_test(list1[1] == 9); - - const int arraySize = 15; - int arrayTest[arraySize] = {3, 145, -182, 34, 12, 95, -1834, 4143, -111, -111, 4343, 234, 22983, -3432, 753}; - List list2(mAllocator); - for (uint i=0; i list3(mAllocator); - list3.add(1); - list3.add(2); - list3.add(3); - list3.add(4); - - auto it = list3.removeAt(3); - rp3d_test(list3.size() == 3); - rp3d_test(list3.capacity() == 4); - rp3d_test(it == list3.end()); - rp3d_test(list3[0] == 1); - rp3d_test(list3[1] == 2); - rp3d_test(list3[2] == 3); - - it = list3.removeAt(1); - rp3d_test(list3.size() == 2); - rp3d_test(list3.capacity() == 4); - rp3d_test(list3[0] == 1); - rp3d_test(list3[1] == 3); - rp3d_test(*it == 3); - - list3.removeAt(0); - rp3d_test(list3.size() == 1); - rp3d_test(list3.capacity() == 4); - rp3d_test(list3[0] == 3); - - it = list3.removeAt(0); - rp3d_test(list3.size() == 0); - rp3d_test(list3.capacity() == 4); - rp3d_test(it == list3.end()); - - list3.add(1); - list3.add(2); - list3.add(3); - it = list3.begin(); - list3.remove(it); - rp3d_test(list3.size() == 2); - rp3d_test(list3[0] == 2); - rp3d_test(list3[1] == 3); - it = list3.find(3); - list3.remove(it); - rp3d_test(list3.size() == 1); - rp3d_test(list3[0] == 2); - - list3.add(5); - list3.add(6); - list3.add(7); - it = list3.remove(7); - rp3d_test(it == list3.end()); - rp3d_test(list3.size() == 3); - it = list3.remove(5); - rp3d_test((*it) == 6); - - // ----- Test addRange() ----- // - - List list4(mAllocator); - list4.add(1); - list4.add(2); - list4.add(3); - - List list5(mAllocator); - list5.add(4); - list5.add(5); - - List list6(mAllocator); - list6.addRange(list5); - rp3d_test(list6.size() == list5.size()); - rp3d_test(list6[0] == 4); - rp3d_test(list6[1] == 5); - - list4.addRange(list5); - rp3d_test(list4.size() == 3 + list5.size()); - rp3d_test(list4[0] == 1); - rp3d_test(list4[1] == 2); - rp3d_test(list4[2] == 3); - rp3d_test(list4[3] == 4); - rp3d_test(list4[4] == 5); - - // ----- Test clear() ----- // - - List list7(mAllocator); - list7.add("test1"); - list7.add("test2"); - list7.add("test3"); - list7.clear(); - rp3d_test(list7.size() == 0); - list7.add("new"); - rp3d_test(list7.size() == 1); - rp3d_test(list7[0] == "new"); - - // ----- Test removeAtAndReplaceByLast() ----- // - - List list8(mAllocator); - list8.add(1); - list8.add(2); - list8.add(3); - list8.add(4); - list8.removeAtAndReplaceByLast(1); - rp3d_test(list8.size() == 3); - rp3d_test(list8[0] == 1); - rp3d_test(list8[1] == 4); - rp3d_test(list8[2] == 3); - list8.removeAtAndReplaceByLast(2); - rp3d_test(list8.size() == 2); - rp3d_test(list8[0] == 1); - rp3d_test(list8[1] == 4); - list8.removeAtAndReplaceByLast(0); - rp3d_test(list8.size() == 1); - rp3d_test(list8[0] == 4); - list8.removeAtAndReplaceByLast(0); - rp3d_test(list8.size() == 0); - } - - void testAssignment() { - - List list1(mAllocator); - list1.add(1); - list1.add(2); - list1.add(3); - - List list2(mAllocator); - list2.add(5); - list2.add(6); - - List list3(mAllocator); - List list4(mAllocator); - list4.add(1); - list4.add(2); - - List list5(mAllocator); - list5.add(1); - list5.add(2); - list5.add(3); - - list3 = list2; - rp3d_test(list2.size() == list3.size()); - rp3d_test(list2[0] == list3[0]); - rp3d_test(list2[1] == list3[1]); - - list4 = list1; - rp3d_test(list4.size() == list1.size()) - rp3d_test(list4[0] == list1[0]); - rp3d_test(list4[1] == list1[1]); - rp3d_test(list4[2] == list1[2]); - - list5 = list2; - rp3d_test(list5.size() == list2.size()); - rp3d_test(list5[0] == list2[0]); - rp3d_test(list5[1] == list2[1]); - } - - void testIndexing() { - - List list1(mAllocator); - list1.add(1); - list1.add(2); - list1.add(3); - - rp3d_test(list1[0] == 1); - rp3d_test(list1[1] == 2); - rp3d_test(list1[2] == 3); - - list1[0] = 6; - list1[1] = 7; - list1[2] = 8; - - rp3d_test(list1[0] == 6); - rp3d_test(list1[1] == 7); - rp3d_test(list1[2] == 8); - - const int a = list1[0]; - const int b = list1[1]; - rp3d_test(a == 6); - rp3d_test(b == 7); - - list1[0]++; - list1[1]++; - rp3d_test(list1[0] == 7); - rp3d_test(list1[1] == 8); - } - - void testFind() { - - List list1(mAllocator); - list1.add(1); - list1.add(2); - list1.add(3); - list1.add(4); - list1.add(5); - - rp3d_test(list1.find(1) == list1.begin()); - rp3d_test(*(list1.find(2)) == 2); - rp3d_test(*(list1.find(5)) == 5); - } - - void testEquality() { - - List list1(mAllocator); - list1.add(1); - list1.add(2); - list1.add(3); - - List list2(mAllocator); - list2.add(1); - list2.add(2); - - List list3(mAllocator); - list3.add(1); - list3.add(2); - list3.add(3); - - List list4(mAllocator); - list4.add(1); - list4.add(5); - list4.add(3); - - rp3d_test(list1 == list1); - rp3d_test(list1 != list2); - rp3d_test(list1 == list3); - rp3d_test(list1 != list4); - rp3d_test(list2 != list4); - } - - void testReserve() { - - List list1(mAllocator); - list1.reserve(10); - rp3d_test(list1.size() == 0); - rp3d_test(list1.capacity() == 10); - list1.add(1); - list1.add(2); - rp3d_test(list1.capacity() == 10); - rp3d_test(list1.size() == 2); - rp3d_test(list1[0] == 1); - rp3d_test(list1[1] == 2); - - list1.reserve(1); - rp3d_test(list1.capacity() == 10); - - list1.reserve(100); - rp3d_test(list1.capacity() == 100); - rp3d_test(list1[0] == 1); - rp3d_test(list1[1] == 2); - } - - void testIterators() { - - List list1(mAllocator); - - rp3d_test(list1.begin() == list1.end()); - - list1.add(5); - list1.add(6); - list1.add(8); - list1.add(-1); - - List::Iterator itBegin = list1.begin(); - List::Iterator itEnd = list1.end(); - List::Iterator it = list1.begin(); - - rp3d_test(itBegin < itEnd); - rp3d_test(itBegin <= itEnd); - rp3d_test(itEnd > itBegin); - rp3d_test(itEnd >= itBegin); - - rp3d_test(itBegin == it); - rp3d_test(*it == 5); - rp3d_test(*(it++) == 5); - rp3d_test(*it == 6); - rp3d_test(*(it--) == 6); - rp3d_test(*it == 5); - rp3d_test(*(++it) == 6); - rp3d_test(*it == 6); - rp3d_test(*(--it) == 5); - rp3d_test(*it == 5); - rp3d_test(it == itBegin); - - it = list1.end(); - rp3d_test(it == itEnd); - it--; - rp3d_test(*it == -1); - it++; - rp3d_test(it == itEnd); - - List list2(mAllocator); - for (auto it = list1.begin(); it != list1.end(); ++it) { - list2.add(*it); - } - - rp3d_test(list1 == list2); - - it = itBegin; - rp3d_test(*(it + 2) == 8); - it += 2; - rp3d_test(*it == 8); - rp3d_test(*(it - 2) == 5); - it -= 2; - rp3d_test(*it == 5); - rp3d_test((itEnd - itBegin) == 4); - - it = itBegin; - *it = 19; - rp3d_test(*it == 19); - } - - }; - -} - -#endif diff --git a/test/tests/containers/TestSet.h b/test/tests/containers/TestSet.h index 0d1f4091..6d6c488c 100644 --- a/test/tests/containers/TestSet.h +++ b/test/tests/containers/TestSet.h @@ -432,18 +432,18 @@ class TestSet : public Test { set1.add(3); set1.add(4); - List list1 = set1.toList(mAllocator); - rp3d_test(list1.size() == 4); - rp3d_test(list1.find(1) != list1.end()); - rp3d_test(list1.find(2) != list1.end()); - rp3d_test(list1.find(3) != list1.end()); - rp3d_test(list1.find(4) != list1.end()); - rp3d_test(list1.find(5) == list1.end()); - rp3d_test(list1.find(6) == list1.end()); + Array array1 = set1.toArray(mAllocator); + rp3d_test(array1.size() == 4); + rp3d_test(array1.find(1) != array1.end()); + rp3d_test(array1.find(2) != array1.end()); + rp3d_test(array1.find(3) != array1.end()); + rp3d_test(array1.find(4) != array1.end()); + rp3d_test(array1.find(5) == array1.end()); + rp3d_test(array1.find(6) == array1.end()); Set set2(mAllocator); - List list2 = set2.toList(mAllocator); - rp3d_test(list2.size() == 0); + Array array2 = set2.toArray(mAllocator); + rp3d_test(array2.size() == 0); } }; diff --git a/test/tests/mathematics/TestMathematicsFunctions.h b/test/tests/mathematics/TestMathematicsFunctions.h index 7caab95f..b5c77fe2 100644 --- a/test/tests/mathematics/TestMathematicsFunctions.h +++ b/test/tests/mathematics/TestMathematicsFunctions.h @@ -27,7 +27,7 @@ #define TEST_MATHEMATICS_FUNCTIONS_H // Libraries -#include +#include #include #include @@ -187,12 +187,12 @@ class TestMathematicsFunctions : public Test { segmentVertices.push_back(Vector3(-6, 3, 0)); segmentVertices.push_back(Vector3(8, 3, 0)); - List planesNormals(mAllocator, 2); - List planesPoints(mAllocator, 2); + Array planesNormals(mAllocator, 2); + Array planesPoints(mAllocator, 2); planesNormals.add(Vector3(-1, 0, 0)); planesPoints.add(Vector3(4, 0, 0)); - List clipSegmentVertices = clipSegmentWithPlanes(segmentVertices[0], segmentVertices[1], + Array clipSegmentVertices = clipSegmentWithPlanes(segmentVertices[0], segmentVertices[1], planesPoints, planesNormals, mAllocator); rp3d_test(clipSegmentVertices.size() == 2); rp3d_test(approxEqual(clipSegmentVertices[0].x, -6, 0.000001)); @@ -236,14 +236,14 @@ class TestMathematicsFunctions : public Test { rp3d_test(clipSegmentVertices.size() == 0); // Test clipPolygonWithPlanes() - List polygonVertices(mAllocator); + Array polygonVertices(mAllocator); polygonVertices.add(Vector3(-4, 2, 0)); polygonVertices.add(Vector3(7, 2, 0)); polygonVertices.add(Vector3(7, 4, 0)); polygonVertices.add(Vector3(-4, 4, 0)); - List polygonPlanesNormals(mAllocator); - List polygonPlanesPoints(mAllocator); + Array polygonPlanesNormals(mAllocator); + Array polygonPlanesPoints(mAllocator); polygonPlanesNormals.add(Vector3(1, 0, 0)); polygonPlanesPoints.add(Vector3(0, 0, 0)); polygonPlanesNormals.add(Vector3(0, 1, 0)); @@ -253,7 +253,7 @@ class TestMathematicsFunctions : public Test { polygonPlanesNormals.add(Vector3(0, -1, 0)); polygonPlanesPoints.add(Vector3(10, 5, 0)); - List clipPolygonVertices = clipPolygonWithPlanes(polygonVertices, polygonPlanesPoints, polygonPlanesNormals, mAllocator); + Array clipPolygonVertices = clipPolygonWithPlanes(polygonVertices, polygonPlanesPoints, polygonPlanesNormals, mAllocator); rp3d_test(clipPolygonVertices.size() == 4); rp3d_test(approxEqual(clipPolygonVertices[0].x, 0, 0.000001)); rp3d_test(approxEqual(clipPolygonVertices[0].y, 2, 0.000001));