Rename the List class into Array

This commit is contained in:
Daniel Chappuis 2020-09-05 15:06:51 +02:00
parent 0d203d9490
commit cd4bc7573f
63 changed files with 893 additions and 891 deletions

View File

@ -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

View File

@ -27,7 +27,7 @@
#define REACTPHYSICS3D_COLLISION_CALLBACK_H
// Libraries
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/collision/ContactPair.h>
#include <reactphysics3d/constraint/ContactPoint.h>
@ -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<reactphysics3d::ContactPoint>* mContactPoints;
Array<reactphysics3d::ContactPoint>* mContactPoints;
/// Reference to the physics world
PhysicsWorld& mWorld;
@ -152,7 +152,7 @@ class CollisionCallback {
// -------------------- Methods -------------------- //
/// Constructor
ContactPair(const reactphysics3d::ContactPair& contactPair, List<reactphysics3d::ContactPoint>* contactPoints,
ContactPair(const reactphysics3d::ContactPair& contactPair, Array<reactphysics3d::ContactPoint>* 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<reactphysics3d::ContactPair>* mContactPairs;
/// Pointer to the array of contact pairs (contains contacts and triggers events)
Array<reactphysics3d::ContactPair>* mContactPairs;
/// Pointer to the list of contact manifolds
List<ContactManifold>* mContactManifolds;
/// Pointer to the array of contact manifolds
Array<ContactManifold>* mContactManifolds;
/// Pointer to the contact points
List<reactphysics3d::ContactPoint>* mContactPoints;
Array<reactphysics3d::ContactPoint>* mContactPoints;
/// Pointer to the list of lost contact pairs (contains contacts and triggers events)
List<reactphysics3d::ContactPair>& mLostContactPairs;
/// Pointer to the array of lost contact pairs (contains contacts and triggers events)
Array<reactphysics3d::ContactPair>& mLostContactPairs;
/// List of indices of the mContactPairs list that are contact events (not overlap/triggers)
List<uint> mContactPairsIndices;
/// Array of indices in the mContactPairs array that are contact events (not overlap/triggers)
Array<uint> mContactPairsIndices;
/// List of indices of the mLostContactPairs list that are contact events (not overlap/triggers)
List<uint> mLostContactPairsIndices;
/// Array of indices in the mLostContactPairs array that are contact events (not overlap/triggers)
Array<uint> mLostContactPairsIndices;
/// Reference to the physics world
PhysicsWorld& mWorld;
@ -250,8 +250,8 @@ class CollisionCallback {
// -------------------- Methods -------------------- //
/// Constructor
CallbackData(List<reactphysics3d::ContactPair>* contactPairs, List<ContactManifold>* manifolds,
List<reactphysics3d::ContactPoint>* contactPoints, List<reactphysics3d::ContactPair>& lostContactPairs,
CallbackData(Array<reactphysics3d::ContactPair>* contactPairs, Array<ContactManifold>* manifolds,
Array<reactphysics3d::ContactPoint>* contactPoints, Array<reactphysics3d::ContactPair>& lostContactPairs,
PhysicsWorld& world);
/// Deleted copy constructor

View File

@ -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

View File

@ -54,13 +54,13 @@ class HalfEdgeStructure {
/// Face
struct Face {
uint edgeIndex; // Index of an half-edge of the face
List<uint> faceVertices; // Index of the vertices of the face
Array<uint> faceVertices; // Index of the vertices of the face
/// Constructor
Face(MemoryAllocator& allocator) : faceVertices(allocator) {}
/// Constructor
Face(List<uint> vertices) : faceVertices(vertices) {}
Face(Array<uint> vertices) : faceVertices(vertices) {}
};
/// Vertex
@ -78,13 +78,13 @@ class HalfEdgeStructure {
MemoryAllocator& mAllocator;
/// All the faces
List<Face> mFaces;
Array<Face> mFaces;
/// All the vertices
List<Vertex> mVertices;
Array<Vertex> mVertices;
/// All the half-edges
List<Edge> mEdges;
Array<Edge> mEdges;
public:
@ -103,7 +103,7 @@ class HalfEdgeStructure {
uint addVertex(uint vertexPointIndex);
/// Add a face
void addFace(List<uint> faceVertices);
void addFace(Array<uint> 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<uint> faceVertices) {
RP3D_FORCE_INLINE void HalfEdgeStructure::addFace(Array<uint> faceVertices) {
// Create a new face
Face face(faceVertices);

View File

@ -27,7 +27,7 @@
#define REACTPHYSICS3D_OVERLAP_CALLBACK_H
// Libraries
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/collision/ContactPair.h>
/// ReactPhysics3D namespace
@ -131,17 +131,17 @@ class OverlapCallback {
// -------------------- Attributes -------------------- //
/// Reference to the list of contact pairs (contains contacts and triggers events)
List<ContactPair>& mContactPairs;
/// Reference to the array of contact pairs (contains contacts and triggers events)
Array<ContactPair>& mContactPairs;
/// Reference to the list of lost contact pairs (contains contacts and triggers events)
List<ContactPair>& mLostContactPairs;
/// Reference to the array of lost contact pairs (contains contacts and triggers events)
Array<ContactPair>& mLostContactPairs;
/// List of indices of the mContactPairs list that are overlap/triggers events (not contact events)
List<uint> mContactPairsIndices;
/// Array of indices of the mContactPairs array that are overlap/triggers events (not contact events)
Array<uint> mContactPairsIndices;
/// List of indices of the mLostContactPairs list that are overlap/triggers events (not contact events)
List<uint> mLostContactPairsIndices;
/// Array of indices of the mLostContactPairs array that are overlap/triggers events (not contact events)
Array<uint> mLostContactPairsIndices;
/// Reference to the physics world
PhysicsWorld& mWorld;
@ -149,7 +149,7 @@ class OverlapCallback {
// -------------------- Methods -------------------- //
/// Constructor
CallbackData(List<ContactPair>& contactPairs, List<ContactPair>& lostContactPairs, bool onlyReportTriggers, PhysicsWorld& world);
CallbackData(Array<ContactPair>& contactPairs, Array<ContactPair>& lostContactPairs, bool onlyReportTriggers, PhysicsWorld& world);
/// Deleted copy constructor
CallbackData(const CallbackData& callbackData) = delete;

View File

@ -28,7 +28,7 @@
// Libraries
#include <cassert>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/memory/MemoryAllocator.h>
namespace reactphysics3d {
@ -49,7 +49,7 @@ class TriangleMesh {
protected:
/// All the triangle arrays of the mesh (one triangle array per part)
List<TriangleVertexArray*> mTriangleArrays;
Array<TriangleVertexArray*> mTriangleArrays;
/// Constructor
TriangleMesh(reactphysics3d::MemoryAllocator& allocator);

View File

@ -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<int32>& nodesToTest, size_t startIndex,
size_t endIndex, List<Pair<int32, int32>>& outOverlappingNodes) const;
void reportAllShapesOverlappingWithShapes(const Array<int32>& nodesToTest, size_t startIndex,
size_t endIndex, Array<Pair<int32, int32>>& outOverlappingNodes) const;
/// Report all shapes overlapping with the AABB given in parameter.
void reportAllShapesOverlappingWithAABB(const AABB& aabb, List<int>& overlappingNodes) const;
void reportAllShapesOverlappingWithAABB(const AABB& aabb, Array<int>& overlappingNodes) const;
/// Ray casting method
void raycast(const Ray& ray, DynamicAABBTreeRaycastCallback& callback) const;

View File

@ -39,7 +39,7 @@ struct NarrowPhaseInfoBatch;
class ConvexShape;
class Profiler;
class VoronoiSimplex;
template<typename T> class List;
template<typename T> 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<GJKResult>& gjkResults);
uint batchNbItems, Array<GJKResult>& gjkResults);
#ifdef IS_RP3D_PROFILING_ENABLED

View File

@ -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<NarrowPhaseInfo> narrowPhaseInfos;
Array<NarrowPhaseInfo> narrowPhaseInfos;
/// Constructor
NarrowPhaseInfoBatch(OverlappingPairs& overlappingPairs, MemoryAllocator& allocator);

View File

@ -27,7 +27,7 @@
#define REACTPHYSICS3D_NARROW_PHASE_INPUT_H
// Libraries
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h>
#include <reactphysics3d/collision/narrowphase/CollisionDispatch.h>

View File

@ -30,7 +30,7 @@
#include <cassert>
#include <reactphysics3d/configuration.h>
#include <reactphysics3d/utils/Profiler.h>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
/// 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<Collider*> mColliders;
/// Array of the colliders associated with this shape
Array<Collider*> mColliders;
#ifdef IS_RP3D_PROFILING_ENABLED

View File

@ -29,7 +29,7 @@
// Libraries
#include <reactphysics3d/collision/shapes/ConcaveShape.h>
#include <reactphysics3d/collision/broadphase/DynamicAABBTree.h>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
namespace reactphysics3d {
@ -72,7 +72,7 @@ class ConcaveMeshRaycastCallback : public DynamicAABBTreeRaycastCallback {
private :
List<int32> mHitAABBNodes;
Array<int32> 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<Vector3>& triangleVertices,
List<Vector3> &triangleVerticesNormals, List<uint>& shapeIds,
virtual void computeOverlappingTriangles(const AABB& localAABB, Array<Vector3>& triangleVertices,
Array<Vector3> &triangleVerticesNormals, Array<uint>& shapeIds,
MemoryAllocator& allocator) const override;
/// Destructor

View File

@ -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<Vector3>& triangleVertices,
List<Vector3>& triangleVerticesNormals, List<uint>& shapeIds,
virtual void computeOverlappingTriangles(const AABB& localAABB, Array<Vector3>& triangleVertices,
Array<Vector3>& triangleVerticesNormals, Array<uint>& shapeIds,
MemoryAllocator& allocator) const=0;
/// Compute and return the volume of the collision shape

View File

@ -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<Vector3>& triangleVertices,
List<Vector3>& triangleVerticesNormals, List<uint>& shapeIds,
virtual void computeOverlappingTriangles(const AABB& localAABB, Array<Vector3>& triangleVertices,
Array<Vector3>& triangleVerticesNormals, Array<uint>& shapeIds,
MemoryAllocator& allocator) const override;
/// Return the string representation of the shape

View File

@ -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<uint64>* mOverlappingPairs;
/// Array with the involved overlapping pairs for each collider
Array<uint64>* 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<uint64>& getOverlappingPairs(Entity colliderEntity);
/// Return a reference to the array of overlapping pairs for a given collider
Array<uint64>& 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<uint64>& ColliderComponents::getOverlappingPairs(Entity colliderEntity) {
// Return a reference to the array of overlapping pairs for a given collider
RP3D_FORCE_INLINE Array<uint64>& ColliderComponents::getOverlappingPairs(Entity colliderEntity) {
assert(mMapEntityToComponentIndex.containsKey(colliderEntity));

View File

@ -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<Entity>* mColliders;
/// Array with the colliders of each body
Array<Entity>* 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<Entity>& getColliders(Entity bodyEntity) const;
/// Return the array of colliders of a body
const Array<Entity>& 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<Entity>& CollisionBodyComponents::getColliders(Entity bodyEntity) const {
// Return the array of colliders of a body
RP3D_FORCE_INLINE const Array<Entity>& CollisionBodyComponents::getColliders(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));

View File

@ -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<Entity>* mJoints;
/// For each body, the array of joints entities the body is part of
Array<Entity>* mJoints;
/// For each body, the list of the indices of contact pairs in which the body is involved
List<uint>* mContactPairs;
/// For each body, the array of the indices of contact pairs in which the body is involved
Array<uint>* 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<Entity>& getJoints(Entity bodyEntity) const;
/// Return the array of joints of a body
const Array<Entity>& 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<Entity>& RigidBodyComponents::getJoints(Entity bodyEntity) const {
// Return the array of joints of a body
RP3D_FORCE_INLINE const Array<Entity>& RigidBodyComponents::getJoints(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
return mJoints[mMapEntityToComponentIndex[bodyEntity]];

View File

@ -23,8 +23,8 @@
* *
********************************************************************************/
#ifndef REACTPHYSICS3D_LIST_H
#define REACTPHYSICS3D_LIST_H
#ifndef REACTPHYSICS3D_ARRAY_H
#define REACTPHYSICS3D_ARRAY_H
// Libraries
#include <reactphysics3d/configuration.h>
@ -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<typename T>
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<T>& list) : mBuffer(nullptr), mSize(0), mCapacity(0), mAllocator(list.mAllocator) {
Array(const Array<T>& 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<typename...Ts>
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<T>& 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<T>& 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<list.size(); i++) {
// Add the elements of the array to the current one
for(uint32 i=0; i<array.size(); i++) {
new (reinterpret_cast<void*>(mBuffer + mSize)) T(list[i]);
new (reinterpret_cast<void*>(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<T>& list) const {
bool operator==(const Array<T>& 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<T>& list) const {
bool operator!=(const Array<T>& array) const {
return !((*this) == list);
return !((*this) == array);
}
/// Overloaded assignment operator
List<T>& operator=(const List<T>& list) {
Array<T>& operator=(const Array<T>& 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;

View File

@ -478,16 +478,16 @@ class Set {
return end();
}
/// Return a list with all the values of the set
List<V> toList(MemoryAllocator& listAllocator) const {
/// Return an array with all the values of the set
Array<V> toArray(MemoryAllocator& arrayAllocator) const {
List<V> list(listAllocator);
Array<V> array(arrayAllocator);
for (auto it = begin(); it != end(); ++it) {
list.add(*it);
array.add(*it);
}
return list;
return array;
}
/// Clear the set

View File

@ -28,7 +28,7 @@
// Libraries
#include <reactphysics3d/configuration.h>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/containers/Deque.h>
#include <reactphysics3d/engine/Entity.h>
@ -45,8 +45,8 @@ class EntityManager {
// -------------------- Attributes -------------------- //
/// List storing the generations of the created entities
List<uint8> mGenerations;
/// Array storing the generations of the created entities
Array<uint8> mGenerations;
/// Deque with the indices of destroyed entities that can be reused
Deque<uint32> mFreeIndices;

View File

@ -28,7 +28,7 @@
// Libraries
#include <reactphysics3d/configuration.h>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/engine/Entity.h>
#include <reactphysics3d/constraint/Joint.h>
@ -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<uint> contactManifoldsIndices;
Array<uint> contactManifoldsIndices;
/// For each island, number of contact manifolds in the island
List<uint> nbContactManifolds;
Array<uint> nbContactManifolds;
/// List of all the entities of the bodies in the islands (stored sequentially)
List<Entity> bodyEntities;
/// Array of all the entities of the bodies in the islands (stored sequentially)
Array<Entity> bodyEntities;
/// For each island we store the starting index of the bodies of that island in the "bodyEntities" array
List<uint32> startBodyEntitiesIndex;
Array<uint32> startBodyEntitiesIndex;
/// For each island, total number of bodies in the island
List<uint32> nbBodiesInIsland;
Array<uint32> nbBodiesInIsland;
// -------------------- Methods -------------------- //

View File

@ -283,11 +283,11 @@ class OverlappingPairs {
/// Heap memory allocator
MemoryAllocator& mHeapAllocator;
/// List of convex vs convex overlapping pairs
List<ConvexOverlappingPair> mConvexPairs;
/// Array of convex vs convex overlapping pairs
Array<ConvexOverlappingPair> mConvexPairs;
/// List of convex vs concave overlapping pairs
List<ConcaveOverlappingPair> mConcavePairs;
/// Array of convex vs concave overlapping pairs
Array<ConcaveOverlappingPair> mConcavePairs;
/// Map a pair id to the internal array index
Map<uint64, uint64> mMapConvexPairIdToPairIndex;

View File

@ -28,7 +28,7 @@
// Libraries
#include <reactphysics3d/mathematics/mathematics.h>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/constraint/Joint.h>
#include <reactphysics3d/memory/MemoryManager.h>
#include <reactphysics3d/engine/EntityManager.h>
@ -210,7 +210,7 @@ class PhysicsWorld {
CollisionDetectionSystem mCollisionDetection;
/// All the collision bodies of the world
List<CollisionBody*> mCollisionBodies;
Array<CollisionBody*> 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<uint32> mProcessContactPairsOrderIslands;
Array<uint32> mProcessContactPairsOrderIslands;
/// Contact solver system
ContactSolverSystem mContactSolverSystem;
@ -254,7 +254,7 @@ class PhysicsWorld {
bool mIsSleepingEnabled;
/// All the rigid bodies of the physics world
List<RigidBody*> mRigidBodies;
Array<RigidBody*> 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

View File

@ -32,7 +32,7 @@
#include <algorithm>
#include <cassert>
#include <cmath>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
/// 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<Vector3> clipSegmentWithPlanes(const Vector3& segA, const Vector3& segB,
const List<Vector3>& planesPoints,
const List<Vector3>& planesNormals,
Array<Vector3> clipSegmentWithPlanes(const Vector3& segA, const Vector3& segB,
const Array<Vector3>& planesPoints,
const Array<Vector3>& planesNormals,
MemoryAllocator& allocator);
/// Clip a polygon against multiple planes and return the clipped polygon vertices
List<Vector3> clipPolygonWithPlanes(const List<Vector3>& polygonVertices, const List<Vector3>& planesPoints,
const List<Vector3>& planesNormals, MemoryAllocator& allocator);
Array<Vector3> clipPolygonWithPlanes(const Array<Vector3>& polygonVertices, const Array<Vector3>& planesPoints,
const Array<Vector3>& 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);

View File

@ -64,7 +64,7 @@
#include <reactphysics3d/constraint/SliderJoint.h>
#include <reactphysics3d/constraint/HingeJoint.h>
#include <reactphysics3d/constraint/FixedJoint.h>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
/// Alias to the ReactPhysics3D namespace
namespace rp3d = reactphysics3d;

View File

@ -51,10 +51,10 @@ class AABBOverlapCallback : public DynamicAABBTreeOverlapCallback {
public:
List<int>& mOverlappingNodes;
Array<int>& mOverlappingNodes;
// Constructor
AABBOverlapCallback(List<int>& overlappingNodes) : mOverlappingNodes(overlappingNodes) {
AABBOverlapCallback(Array<int>& 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<Pair<int32, int32>>& overlappingNodes);
void computeOverlappingPairs(MemoryManager& memoryManager, Array<Pair<int32, int32>>& overlappingNodes);
/// Return the collider corresponding to the broad-phase node id in parameter
Collider* getColliderForBroadPhaseId(int broadPhaseId) const;

View File

@ -99,7 +99,7 @@ class CollisionDetectionSystem {
OverlappingPairs mOverlappingPairs;
/// Overlapping nodes during broad-phase computation
List<Pair<int32, int32>> mBroadPhaseOverlappingNodes;
Array<Pair<int32, int32>> 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<ContactPointInfo> mPotentialContactPoints;
/// Array of the potential contact points
Array<ContactPointInfo> mPotentialContactPoints;
/// List of the potential contact manifolds
List<ContactManifoldInfo> mPotentialContactManifolds;
/// Array of the potential contact manifolds
Array<ContactManifoldInfo> mPotentialContactManifolds;
/// First list of narrow-phase pair contacts
List<ContactPair> mContactPairs1;
/// First array of narrow-phase pair contacts
Array<ContactPair> mContactPairs1;
/// Second list of narrow-phase pair contacts
List<ContactPair> mContactPairs2;
/// Second array of narrow-phase pair contacts
Array<ContactPair> mContactPairs2;
/// Pointer to the list of contact pairs of the previous frame (either mContactPairs1 or mContactPairs2)
List<ContactPair>* mPreviousContactPairs;
/// Pointer to the array of contact pairs of the previous frame (either mContactPairs1 or mContactPairs2)
Array<ContactPair>* mPreviousContactPairs;
/// Pointer to the list of contact pairs of the current frame (either mContactPairs1 or mContactPairs2)
List<ContactPair>* mCurrentContactPairs;
/// Pointer to the array of contact pairs of the current frame (either mContactPairs1 or mContactPairs2)
Array<ContactPair>* mCurrentContactPairs;
/// List of lost contact pairs (contact pairs in contact in previous frame but not in the current one)
List<ContactPair> mLostContactPairs;
/// Array of lost contact pairs (contact pairs in contact in previous frame but not in the current one)
Array<ContactPair> mLostContactPairs;
/// Pointer to the map of overlappingPairId to the index of contact pair of the previous frame
/// (either mMapPairIdToContactPairIndex1 or mMapPairIdToContactPairIndex2)
Map<uint64, uint> mPreviousMapPairIdToContactPairIndex;
/// First list with the contact manifolds
List<ContactManifold> mContactManifolds1;
/// First array with the contact manifolds
Array<ContactManifold> mContactManifolds1;
/// Second list with the contact manifolds
List<ContactManifold> mContactManifolds2;
/// Second array with the contact manifolds
Array<ContactManifold> mContactManifolds2;
/// Pointer to the list of contact manifolds from the previous frame (either mContactManifolds1 or mContactManifolds2)
List<ContactManifold>* mPreviousContactManifolds;
/// Pointer to the array of contact manifolds from the previous frame (either mContactManifolds1 or mContactManifolds2)
Array<ContactManifold>* mPreviousContactManifolds;
/// Pointer to the list of contact manifolds from the current frame (either mContactManifolds1 or mContactManifolds2)
List<ContactManifold>* mCurrentContactManifolds;
/// Pointer to the array of contact manifolds from the current frame (either mContactManifolds1 or mContactManifolds2)
Array<ContactManifold>* mCurrentContactManifolds;
/// Second list of contact points (contact points from either the current frame of the previous frame)
List<ContactPoint> mContactPoints1;
/// Second array of contact points (contact points from either the current frame of the previous frame)
Array<ContactPoint> mContactPoints1;
/// Second list of contact points (contact points from either the current frame of the previous frame)
List<ContactPoint> mContactPoints2;
/// Second array of contact points (contact points from either the current frame of the previous frame)
Array<ContactPoint> mContactPoints2;
/// Pointer to the contact points of the previous frame (either mContactPoints1 or mContactPoints2)
List<ContactPoint>* mPreviousContactPoints;
Array<ContactPoint>* mPreviousContactPoints;
/// Pointer to the contact points of the current frame (either mContactPoints1 or mContactPoints2)
List<ContactPoint>* mCurrentContactPoints;
Array<ContactPoint>* mCurrentContactPoints;
/// Array with the indices of all the contact pairs that have at least one CollisionBody
List<uint32> mCollisionBodyContactPairsIndices;
Array<uint32> 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<uint64>& convexPairs, List<uint64>& concavePairs, NarrowPhaseInput& narrowPhaseInput,
void computeMiddlePhaseCollisionSnapshot(Array<uint64>& convexPairs, Array<uint64>& 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<ContactPair>& contactPairs) const;
void computeOverlapSnapshotContactPairs(NarrowPhaseInput& narrowPhaseInput, Array<ContactPair>& contactPairs) const;
/// Convert the potential contact into actual contacts
void computeOverlapSnapshotContactPairs(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, List<ContactPair>& contactPairs,
void computeOverlapSnapshotContactPairs(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, Array<ContactPair>& contactPairs,
Set<uint64>& setOverlapContactPairId) const;
/// Take a list of overlapping nodes in the broad-phase and create new overlapping pairs if necessary
void updateOverlappingPairs(const List<Pair<int32, int32> >& overlappingNodes);
/// Take an array of overlapping nodes in the broad-phase and create new overlapping pairs if necessary
void updateOverlappingPairs(const Array<Pair<int32, int32> >& 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<ContactPointInfo>& potentialContactPoints,
List<ContactManifoldInfo>& potentialContactManifolds,
Map<uint64, uint>& mapPairIdToContactPairIndex, List<ContactPair>* contactPairs);
bool updateLastFrameInfo, Array<ContactPointInfo>& potentialContactPoints,
Array<ContactManifoldInfo>& potentialContactManifolds,
Map<uint64, uint>& mapPairIdToContactPairIndex, Array<ContactPair>* contactPairs);
/// Process the potential contacts after narrow-phase collision detection
void processAllPotentialContacts(NarrowPhaseInput& narrowPhaseInput, bool updateLastFrameInfo, List<ContactPointInfo>& potentialContactPoints,
List<ContactManifoldInfo>& potentialContactManifolds, List<ContactPair>* contactPairs);
void processAllPotentialContacts(NarrowPhaseInput& narrowPhaseInput, bool updateLastFrameInfo, Array<ContactPointInfo>& potentialContactPoints,
Array<ContactManifoldInfo>& potentialContactManifolds, Array<ContactPair>* contactPairs);
/// Reduce the potential contact manifolds and contact points of the overlapping pair contacts
void reducePotentialContactManifolds(List<ContactPair>* contactPairs, List<ContactManifoldInfo>& potentialContactManifolds,
const List<ContactPointInfo>& potentialContactPoints) const;
void reducePotentialContactManifolds(Array<ContactPair>* contactPairs, Array<ContactManifoldInfo>& potentialContactManifolds,
const Array<ContactPointInfo>& 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<ContactPair>& contactPairs, List<ContactManifold> &contactManifolds,
List<ContactPoint>& contactPoints,
List<ContactManifoldInfo>& potentialContactManifolds,
List<ContactPointInfo>& potentialContactPoints);
void createSnapshotContacts(Array<ContactPair>& contactPairs, Array<ContactManifold> &contactManifolds,
Array<ContactPoint>& contactPoints,
Array<ContactManifoldInfo>& potentialContactManifolds,
Array<ContactPointInfo>& 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<ContactPointInfo>& potentialContactPoints) const;
const Array<ContactPointInfo>& potentialContactPoints) const;
/// Report contacts
void reportContacts(CollisionCallback& callback, List<ContactPair>* contactPairs,
List<ContactManifold>* manifolds, List<ContactPoint>* contactPoints, List<ContactPair>& lostContactPairs);
void reportContacts(CollisionCallback& callback, Array<ContactPair>* contactPairs,
Array<ContactManifold>* manifolds, Array<ContactPoint>* contactPoints, Array<ContactPair>& lostContactPairs);
/// Report all triggers
void reportTriggers(EventListener& eventListener, List<ContactPair>* contactPairs, List<ContactPair>& lostContactPairs);
void reportTriggers(EventListener& eventListener, Array<ContactPair>* contactPairs, Array<ContactPair>& lostContactPairs);
/// Report all contacts for debug rendering
void reportDebugRenderingContacts(List<ContactPair>* contactPairs, List<ContactManifold>* manifolds, List<ContactPoint>* contactPoints, List<ContactPair>& lostContactPairs);
void reportDebugRenderingContacts(Array<ContactPair>* contactPairs, Array<ContactManifold>* manifolds, Array<ContactPoint>* contactPoints, Array<ContactPair>& lostContactPairs);
/// Return the largest depth of all the contact points of a potential manifold
decimal computePotentialManifoldLargestContactDepth(const ContactManifoldInfo& manifold,
const List<ContactPointInfo>& potentialContactPoints) const;
const Array<ContactPointInfo>& 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<uint64>& convexPairs, List<uint64>& concavePairs) const;
void filterOverlappingPairs(Entity bodyEntity, Array<uint64>& convexPairs, Array<uint64>& concavePairs) const;
/// Filter the overlapping pairs to keep only the pairs where two given bodies are involved
void filterOverlappingPairs(Entity body1Entity, Entity body2Entity, List<uint64>& convexPairs, List<uint64>& concavePairs) const;
void filterOverlappingPairs(Entity body1Entity, Entity body2Entity, Array<uint64>& convexPairs, Array<uint64>& 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) {

View File

@ -302,11 +302,11 @@ class ContactSolverSystem {
/// Reference to the islands
Islands& mIslands;
/// Pointer to the list of contact manifolds from narrow-phase
List<ContactManifold>* mAllContactManifolds;
/// Pointer to the array of contact manifolds from narrow-phase
Array<ContactManifold>* mAllContactManifolds;
/// Pointer to the list of contact points from narrow-phase
List<ContactPoint>* mAllContactPoints;
/// Pointer to the array of contact points from narrow-phase
Array<ContactPoint>* mAllContactPoints;
/// Reference to the body components
CollisionBodyComponents& mBodyComponents;
@ -356,7 +356,7 @@ class ContactSolverSystem {
~ContactSolverSystem() = default;
/// Initialize the contact constraints
void init(List<ContactManifold>* contactManifolds, List<ContactPoint>* contactPoints, decimal timeStep);
void init(Array<ContactManifold>* contactManifolds, Array<ContactPoint>* contactPoints, decimal timeStep);
/// Initialize the constraint solver for a given island
void initializeForIsland(uint islandIndex);

View File

@ -27,7 +27,7 @@
#define REACTPHYSICS3D_DEBUG_RENDERER_H
// Libraries
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/containers/Map.h>
#include <reactphysics3d/mathematics/mathematics.h>
#include <reactphysics3d/engine/EventListener.h>
@ -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<DebugLine> mLines;
/// Array with all the debug lines
Array<DebugLine> mLines;
/// List with all the debug triangles
List<DebugTriangle> mTriangles;
/// Array with all the debug triangles
Array<DebugTriangle> 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<DebugLine>& getLines() const;
/// Return a reference to the array of lines
const Array<DebugLine>& 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<DebugTriangle>& getTriangles() const;
/// Return a reference to the array of triangles
const Array<DebugTriangle>& 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::DebugLine>& DebugRenderer::getLines() const {
RP3D_FORCE_INLINE const Array<DebugRenderer::DebugLine>& 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::DebugTriangle>& DebugRenderer::getTriangles() const {
RP3D_FORCE_INLINE const Array<DebugRenderer::DebugTriangle>& DebugRenderer::getTriangles() const {
return mTriangles;
}

View File

@ -28,7 +28,7 @@
// Libraries
#include <reactphysics3d/utils/Logger.h>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/containers/Map.h>
#include <string>
#include <iostream>
@ -445,7 +445,7 @@ class DefaultLogger : public Logger {
MemoryAllocator& mAllocator;
/// All the log destinations
List<Destination*> mDestinations;
Array<Destination*> mDestinations;
/// Map a log format to the given formatter object
Map<Format, Formatter*> mFormatters;

View File

@ -27,7 +27,7 @@
#define REACTPHYSICS3D_LOGGER_H
// Libraries
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/containers/Map.h>
#include <string>
#include <iostream>

View File

@ -34,7 +34,7 @@
#include <reactphysics3d/configuration.h>
#include <reactphysics3d/engine/Timer.h>
#include <fstream>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
/// ReactPhysics3D namespace
namespace reactphysics3d {

View File

@ -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<Entity> 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<Entity> 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
if (colliderEntities.size() == 0) return bodyAABB;
const Transform& transform = mWorld.mTransformComponents.getTransform(mEntity);

View File

@ -324,7 +324,7 @@ Vector3 RigidBody::computeCenterOfMass() const {
Vector3 centerOfMassLocal(0, 0, 0);
// Compute the local center of mass
const List<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
for (uint32 i=0; i < colliderEntities.size(); i++) {
// Get the currently overlapping pairs for this collider
List<uint64> overlappingPairs = mWorld.mCollidersComponents.getOverlappingPairs(colliderEntities[i]);
Array<uint64> 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<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
const Array<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
for (uint32 i=0; i < colliderEntities.size(); i++) {
Collider* collider = mWorld.mCollidersComponents.getCollider(colliderEntities[i]);

View File

@ -39,7 +39,7 @@ CollisionCallback::ContactPoint::ContactPoint(const reactphysics3d::ContactPoint
// Contact Pair Constructor
CollisionCallback::ContactPair::ContactPair(const reactphysics3d::ContactPair& contactPair,
List<reactphysics3d::ContactPoint>* contactPoints, PhysicsWorld& world, bool isLostContactPair)
Array<reactphysics3d::ContactPoint>* 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<reactphysics3d::ContactPair>* contactPairs, List<ContactManifold>* manifolds,
List<reactphysics3d::ContactPoint>* contactPoints, List<reactphysics3d::ContactPair>& lostContactPairs, PhysicsWorld& world)
CollisionCallback::CallbackData::CallbackData(Array<reactphysics3d::ContactPair>* contactPairs, Array<ContactManifold>* manifolds,
Array<reactphysics3d::ContactPoint>* contactPoints, Array<reactphysics3d::ContactPair>& 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) {

View File

@ -41,7 +41,7 @@ void HalfEdgeStructure::init() {
Map<uint32, VerticesPair> mapEdgeIndexToKey(mAllocator);
Map<uint32, VerticesPair> mapFaceIndexToEdgeKey(mAllocator);
List<VerticesPair> currentFaceEdges(mAllocator, mFaces[0].faceVertices.size());
Array<VerticesPair> currentFaceEdges(mAllocator, mFaces[0].faceVertices.size());
// For each face
for (uint32 f=0; f<mFaces.size(); f++) {

View File

@ -67,7 +67,7 @@ OverlapCallback::OverlapPair::EventType OverlapCallback::OverlapPair::getEventTy
}
// CollisionCallbackData Constructor
OverlapCallback::CallbackData::CallbackData(List<ContactPair>& contactPairs, List<ContactPair>& lostContactPairs, bool onlyReportTriggers, PhysicsWorld& world)
OverlapCallback::CallbackData::CallbackData(Array<ContactPair>& contactPairs, Array<ContactPair>& lostContactPairs, bool onlyReportTriggers, PhysicsWorld& world)
:mContactPairs(contactPairs), mLostContactPairs(lostContactPairs),
mContactPairsIndices(world.mMemoryManager.getHeapAllocator()), mLostContactPairsIndices(world.mMemoryManager.getHeapAllocator()), mWorld(world) {

View File

@ -75,7 +75,7 @@ void PolyhedronMesh::createHalfEdgeStructure() {
// Get the polygon face
PolygonVertexArray::PolygonFace* face = mPolygonVertexArray->getPolygonFace(f);
List<uint> faceVertices(mMemoryAllocator, face->nbVertices);
Array<uint> faceVertices(mMemoryAllocator, face->nbVertices);
// For each vertex of the face
for (uint v=0; v < face->nbVertices; v++) {

View File

@ -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<int32>& nodesToTest, size_t startIndex,
size_t endIndex, List<Pair<int32, int32>>& 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<int32>& nodesToTest, size_t startIndex,
size_t endIndex, Array<Pair<int32, int32>>& outOverlappingNodes) const {
RP3D_PROFILE("DynamicAABBTree::reportAllShapesOverlappingWithAABB()", mProfiler);
@ -609,7 +609,7 @@ void DynamicAABBTree::reportAllShapesOverlappingWithShapes(const List<int32>& 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<int32, int32>(nodesToTest[i], nodeIDToVisit));
}
else { // If the node is not a leaf
@ -626,7 +626,7 @@ void DynamicAABBTree::reportAllShapesOverlappingWithShapes(const List<int32>& no
}
// Report all shapes overlapping with the AABB given in parameter.
void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& aabb, List<int32>& overlappingNodes) const {
void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& aabb, Array<int32>& overlappingNodes) const {
RP3D_PROFILE("DynamicAABBTree::reportAllShapesOverlappingWithAABB()", mProfiler);

View File

@ -59,7 +59,7 @@ bool CapsuleVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& nar
#endif
// Run the GJK algorithm
List<GJKAlgorithm::GJKResult> gjkResults(memoryAllocator);
Array<GJKAlgorithm::GJKResult> gjkResults(memoryAllocator);
gjkAlgorithm.testCollision(narrowPhaseInfoBatch, batchStartIndex, batchNbItems, gjkResults);
assert(gjkResults.size() == batchNbItems);

View File

@ -30,7 +30,7 @@
#include <reactphysics3d/collision/shapes/TriangleShape.h>
#include <reactphysics3d/configuration.h>
#include <reactphysics3d/utils/Profiler.h>
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h>
#include <reactphysics3d/collision/narrowphase/GJK/VoronoiSimplex.h>
#include <cassert>
@ -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<GJKResult>& gjkResults) {
uint batchNbItems, Array<GJKResult>& gjkResults) {
RP3D_PROFILE("GJKAlgorithm::testCollision()", mProfiler);

View File

@ -395,8 +395,8 @@ bool SATAlgorithm::computeCapsulePolyhedronFaceContactPoints(uint referenceFaceI
uint firstEdgeIndex = face.edgeIndex;
uint edgeIndex = firstEdgeIndex;
List<Vector3> planesPoints(mMemoryAllocator, 2);
List<Vector3> planesNormals(mMemoryAllocator, 2);
Array<Vector3> planesPoints(mMemoryAllocator, 2);
Array<Vector3> 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<Vector3> clipSegment = clipSegmentWithPlanes(capsuleSegAPolyhedronSpace, capsuleSegBPolyhedronSpace, planesPoints, planesNormals, mMemoryAllocator);
Array<Vector3> 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<Vector3> polygonVertices(mMemoryAllocator, nbIncidentFaceVertices); // Vertices to clip of the incident face
List<Vector3> planesNormals(mMemoryAllocator, nbIncidentFaceVertices); // Normals of the clipping planes
List<Vector3> planesPoints(mMemoryAllocator, nbIncidentFaceVertices); // Points on the clipping planes
Array<Vector3> polygonVertices(mMemoryAllocator, nbIncidentFaceVertices); // Vertices to clip of the incident face
Array<Vector3> planesNormals(mMemoryAllocator, nbIncidentFaceVertices); // Normals of the clipping planes
Array<Vector3> 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<Vector3> clipPolygonVertices = clipPolygonWithPlanes(polygonVertices, planesPoints, planesNormals, mMemoryAllocator);
Array<Vector3> 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);

View File

@ -50,7 +50,7 @@ bool SphereVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narr
#endif
List<GJKAlgorithm::GJKResult> gjkResults(memoryAllocator, batchNbItems);
Array<GJKAlgorithm::GJKResult> gjkResults(memoryAllocator, batchNbItems);
gjkAlgorithm.testCollision(narrowPhaseInfoBatch, batchStartIndex, batchNbItems, gjkResults);
assert(gjkResults.size() == batchNbItems);

View File

@ -56,17 +56,17 @@ BoxShape::BoxShape(const Vector3& halfExtents, MemoryAllocator& allocator)
mHalfEdgeStructure.addVertex(7);
// Faces
List<uint> face0(allocator, 4);
Array<uint> face0(allocator, 4);
face0.add(0); face0.add(1); face0.add(2); face0.add(3);
List<uint> face1(allocator, 4);
Array<uint> face1(allocator, 4);
face1.add(1); face1.add(5); face1.add(6); face1.add(2);
List<uint> face2(allocator, 4);
Array<uint> face2(allocator, 4);
face2.add(4); face2.add(7); face2.add(6); face2.add(5);
List<uint> face3(allocator, 4);
Array<uint> face3(allocator, 4);
face3.add(4); face3.add(0); face3.add(3); face3.add(7);
List<uint> face4(allocator, 4);
Array<uint> face4(allocator, 4);
face4.add(4); face4.add(5); face4.add(1); face4.add(0);
List<uint> face5(allocator, 4);
Array<uint> face5(allocator, 4);
face5.add(2); face5.add(6); face5.add(7); face5.add(3);
mHalfEdgeStructure.addFace(face0);

View File

@ -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<Vector3>& triangleVertices,
List<Vector3>& triangleVerticesNormals, List<uint>& shapeIds,
void ConcaveMeshShape::computeOverlappingTriangles(const AABB& localAABB, Array<Vector3>& triangleVertices,
Array<Vector3>& triangleVerticesNormals, Array<uint>& shapeIds,
MemoryAllocator& allocator) const {
RP3D_PROFILE("ConcaveMeshShape::computeOverlappingTriangles()", mProfiler);
@ -139,12 +139,12 @@ void ConcaveMeshShape::computeOverlappingTriangles(const AABB& localAABB, List<V
aabb.applyScale(Vector3(decimal(1.0) / mScale.x, decimal(1.0) / mScale.y, decimal(1.0) / mScale.z));
// Compute the nodes of the internal AABB tree that are overlapping with the AABB
List<int> overlappingNodes(allocator, 64);
Array<int> 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<int>::Iterator it;
Array<int>::Iterator it;
decimal smallestHitFraction = mRay.maxFraction;
for (it = mHitAABBNodes.begin(); it != mHitAABBNodes.end(); ++it) {

View File

@ -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

View File

@ -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<Vector3>& triangleVertices,
List<Vector3>& triangleVerticesNormals, List<uint>& shapeIds,
void HeightFieldShape::computeOverlappingTriangles(const AABB& localAABB, Array<Vector3>& triangleVertices,
Array<Vector3>& triangleVerticesNormals, Array<uint>& 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<Vector3> triangleVertices(allocator, 64);
List<Vector3> triangleVerticesNormals(allocator, 64);
List<uint> shapeIds(allocator, 64);
Array<Vector3> triangleVertices(allocator, 64);
Array<Vector3> triangleVerticesNormals(allocator, 64);
Array<uint> shapeIds(allocator, 64);
computeOverlappingTriangles(rayAABB, triangleVertices, triangleVerticesNormals, shapeIds, allocator);
assert(triangleVertices.size() == triangleVerticesNormals.size());

View File

@ -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<uint64>) + sizeof(bool) +
sizeof(unsigned short) + sizeof(Transform) + sizeof(Array<uint64>) + 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<unsigned short*>(newCollisionShapes + nbComponentsToAllocate);
unsigned short* newCollideWithMaskBits = reinterpret_cast<unsigned short*>(newCollisionCategoryBits + nbComponentsToAllocate);
Transform* newLocalToWorldTransforms = reinterpret_cast<Transform*>(newCollideWithMaskBits + nbComponentsToAllocate);
List<uint64>* newOverlappingPairs = reinterpret_cast<List<uint64>*>(newLocalToWorldTransforms + nbComponentsToAllocate);
Array<uint64>* newOverlappingPairs = reinterpret_cast<Array<uint64>*>(newLocalToWorldTransforms + nbComponentsToAllocate);
bool* hasCollisionShapeChangedSize = reinterpret_cast<bool*>(newOverlappingPairs + nbComponentsToAllocate);
bool* isTrigger = reinterpret_cast<bool*>(hasCollisionShapeChangedSize + nbComponentsToAllocate);
Material* materials = reinterpret_cast<Material*>(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<uint64>));
memcpy(newOverlappingPairs, mOverlappingPairs, mNbComponents * sizeof(Array<uint64>));
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<uint64>(mMemoryAllocator);
new (mOverlappingPairs + index) Array<uint64>(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<uint64>(mOverlappingPairs[srcIndex]);
new (mOverlappingPairs + destIndex) Array<uint64>(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<uint64> overlappingPairs = mOverlappingPairs[index1];
Array<uint64> 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<uint64>(overlappingPairs);
new (mOverlappingPairs + index2) Array<uint64>(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<uint64>();
mOverlappingPairs[index].~Array<uint64>();
mMaterials[index].~Material();
}

View File

@ -34,7 +34,7 @@ using namespace reactphysics3d;
// Constructor
CollisionBodyComponents::CollisionBodyComponents(MemoryAllocator& allocator)
:Components(allocator, sizeof(Entity) + sizeof(CollisionBody*) + sizeof(List<Entity>) +
:Components(allocator, sizeof(Entity) + sizeof(CollisionBody*) + sizeof(Array<Entity>) +
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<Entity*>(newBuffer);
CollisionBody** newBodies = reinterpret_cast<CollisionBody**>(newBodiesEntities + nbComponentsToAllocate);
List<Entity>* newColliders = reinterpret_cast<List<Entity>*>(newBodies + nbComponentsToAllocate);
Array<Entity>* newColliders = reinterpret_cast<Array<Entity>*>(newBodies + nbComponentsToAllocate);
bool* newIsActive = reinterpret_cast<bool*>(newColliders + nbComponentsToAllocate);
void** newUserData = reinterpret_cast<void**>(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<Entity>));
memcpy(newColliders, mColliders, mNbComponents * sizeof(Array<Entity>));
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<Entity>(mMemoryAllocator);
new (mColliders + index) Array<Entity>(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<Entity>(mColliders[srcIndex]);
new (mColliders + destIndex) Array<Entity>(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<Entity> colliders1(mColliders[index1]);
Array<Entity> 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<Entity>(colliders1);
new (mColliders + index2) Array<Entity>(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<Entity>();
mColliders[index].~Array<Entity>();
mUserData[index] = nullptr;
}

View File

@ -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<Entity>) + sizeof(List<uint>)) {
sizeof(bool) + sizeof(bool) + sizeof(Array<Entity>) + sizeof(Array<uint>)) {
// Allocate memory for the components data
allocate(INIT_NB_ALLOCATED_COMPONENTS);
@ -89,8 +89,8 @@ void RigidBodyComponents::allocate(uint32 nbComponentsToAllocate) {
Vector3* newCentersOfMassWorld = reinterpret_cast<Vector3*>(newCentersOfMassLocal + nbComponentsToAllocate);
bool* newIsGravityEnabled = reinterpret_cast<bool*>(newCentersOfMassWorld + nbComponentsToAllocate);
bool* newIsAlreadyInIsland = reinterpret_cast<bool*>(newIsGravityEnabled + nbComponentsToAllocate);
List<Entity>* newJoints = reinterpret_cast<List<Entity>*>(newIsAlreadyInIsland + nbComponentsToAllocate);
List<uint>* newContactPairs = reinterpret_cast<List<uint>*>(newJoints + nbComponentsToAllocate);
Array<Entity>* newJoints = reinterpret_cast<Array<Entity>*>(newIsAlreadyInIsland + nbComponentsToAllocate);
Array<uint>* newContactPairs = reinterpret_cast<Array<uint>*>(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<Entity>));
memcpy(newContactPairs, mContactPairs, mNbComponents * sizeof(List<uint>));
memcpy(newJoints, mJoints, mNbComponents * sizeof(Array<Entity>));
memcpy(newContactPairs, mContactPairs, mNbComponents * sizeof(Array<uint>));
// 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<Entity>(mMemoryAllocator);
new (mContactPairs + index) List<uint>(mMemoryAllocator);
new (mJoints + index) Array<Entity>(mMemoryAllocator);
new (mContactPairs + index) Array<uint>(mMemoryAllocator);
// Map the entity with the new component lookup index
mMapEntityToComponentIndex.add(Pair<Entity, uint32>(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<Entity>(mJoints[srcIndex]);
new (mContactPairs + destIndex) List<uint>(mContactPairs[srcIndex]);
new (mJoints + destIndex) Array<Entity>(mJoints[srcIndex]);
new (mContactPairs + destIndex) Array<uint>(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<Entity> joints1 = mJoints[index1];
List<uint> contactPairs1 = mContactPairs[index1];
Array<Entity> joints1 = mJoints[index1];
Array<uint> 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<Entity>(joints1);
new (mContactPairs + index2) List<uint>(contactPairs1);
new (mJoints + index2) Array<Entity>(joints1);
new (mContactPairs + index2) Array<uint>(contactPairs1);
// Update the entity to component index mapping
mMapEntityToComponentIndex.add(Pair<Entity, uint32>(entity1, index2));
@ -361,6 +361,6 @@ void RigidBodyComponents::destroyComponent(uint32 index) {
mConstrainedOrientations[index].~Quaternion();
mCentersOfMassLocal[index].~Vector3();
mCentersOfMassWorld[index].~Vector3();
mJoints[index].~List<Entity>();
mContactPairs[index].~List<uint>();
mJoints[index].~Array<Entity>();
mContactPairs[index].~Array<uint>();
}

View File

@ -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<Entity>& collidersEntities = mCollisionBodyComponents.getColliders(bodyEntity);
const Array<Entity>& 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<Entity>& joints = mRigidBodyComponents.getJoints(bodyEntity);
const Array<Entity>& 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<Entity>& joints = mRigidBodyComponents.getJoints(rigidBody->getEntity());
const Array<Entity>& 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<Entity> bodyEntitiesToVisit(mMemoryManager.getSingleFrameAllocator(), mIslands.getNbMaxBodiesInIslandPreviousFrame());
// List of static bodies added to the current island (used to reset the isAlreadyInIsland variable of static bodies)
List<Entity> staticBodiesAddedToIsland(mMemoryManager.getSingleFrameAllocator(), 16);
// Array of static bodies added to the current island (used to reset the isAlreadyInIsland variable of static bodies)
Array<Entity> 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<Entity>& joints = mRigidBodyComponents.getJoints(rigidBodyToVisit->getEntity());
const Array<Entity>& 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<RigidBody*>::Iterator it;
Array<RigidBody*>::Iterator it;
for (it = mRigidBodies.begin(); it != mRigidBodies.end(); ++it) {
// Wake up the rigid body

View File

@ -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 SutherlandHodgman clipping algorithm
List<Vector3> reactphysics3d::clipSegmentWithPlanes(const Vector3& segA, const Vector3& segB,
const List<Vector3>& planesPoints,
const List<Vector3>& planesNormals,
Array<Vector3> reactphysics3d::clipSegmentWithPlanes(const Vector3& segA, const Vector3& segB,
const Array<Vector3>& planesPoints,
const Array<Vector3>& planesNormals,
MemoryAllocator& allocator) {
assert(planesPoints.size() == planesNormals.size());
List<Vector3> inputVertices(allocator, 2);
List<Vector3> outputVertices(allocator, 2);
Array<Vector3> inputVertices(allocator, 2);
Array<Vector3> outputVertices(allocator, 2);
inputVertices.add(segA);
inputVertices.add(segB);
@ -296,14 +296,14 @@ List<Vector3> reactphysics3d::clipSegmentWithPlanes(const Vector3& segA, const V
// Clip a polygon against multiple planes and return the clipped polygon vertices
// This method implements the SutherlandHodgman clipping algorithm
List<Vector3> reactphysics3d::clipPolygonWithPlanes(const List<Vector3>& polygonVertices, const List<Vector3>& planesPoints,
const List<Vector3>& planesNormals, MemoryAllocator& allocator) {
Array<Vector3> reactphysics3d::clipPolygonWithPlanes(const Array<Vector3>& polygonVertices, const Array<Vector3>& planesPoints,
const Array<Vector3>& planesNormals, MemoryAllocator& allocator) {
assert(planesPoints.size() == planesNormals.size());
uint32 nbMaxElements = polygonVertices.size() + planesPoints.size();
List<Vector3> inputVertices(allocator, nbMaxElements);
List<Vector3> outputVertices(allocator, nbMaxElements);
Array<Vector3> inputVertices(allocator, nbMaxElements);
Array<Vector3> outputVertices(allocator, nbMaxElements);
inputVertices.addRange(polygonVertices);

View File

@ -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<Pair<int32, int32>>& overlappingNodes) {
void BroadPhaseSystem::computeOverlappingPairs(MemoryManager& memoryManager, Array<Pair<int32, int32>>& overlappingNodes) {
RP3D_PROFILE("BroadPhaseSystem::computeOverlappingPairs()", mProfiler);
// Get the list of the colliders that have moved or have been created in the last frame
List<int> shapesToTest = mMovedShapes.toList(memoryManager.getHeapAllocator());
// Get the array of the colliders that have moved or have been created in the last frame
Array<int> 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);

View File

@ -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<Pair<int32, int32>>& overlappingNodes) {
// Take an array of overlapping nodes in the broad-phase and create new overlapping pairs if necessary
void CollisionDetectionSystem::updateOverlappingPairs(const Array<Pair<int32, int32>>& 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<uint64>& convexPairs, List<uint64>& concavePairs,
void CollisionDetectionSystem::computeMiddlePhaseCollisionSnapshot(Array<uint64>& convexPairs, Array<uint64>& 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<Vector3> triangleVertices(allocator, 64);
List<Vector3> triangleVerticesNormals(allocator, 64);
List<uint> shapeIds(allocator, 64);
Array<Vector3> triangleVertices(allocator, 64);
Array<Vector3> triangleVerticesNormals(allocator, 64);
Array<uint> 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<ContactPointInfo>& potentialContactPoints,
List<ContactManifoldInfo>& potentialContactManifolds,
List<ContactPair>* contactPairs) {
Array<ContactPointInfo>& potentialContactPoints,
Array<ContactManifoldInfo>& potentialContactManifolds,
Array<ContactPair>* 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<ContactPair> contactPairs(allocator);
List<ContactPair> lostContactPairs(allocator); // Always empty in this case (snapshot)
Array<ContactPair> contactPairs(allocator);
Array<ContactPair> 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<ContactPair>& contactPairs) const {
void CollisionDetectionSystem::computeOverlapSnapshotContactPairs(NarrowPhaseInput& narrowPhaseInput, Array<ContactPair>& contactPairs) const {
Set<uint64> 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<uint64>& overlappingPairs = mCollidersComponents.getOverlappingPairs(collider->getEntity());
Array<uint64>& 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<ContactPair>& contactPairs,
void CollisionDetectionSystem::computeOverlapSnapshotContactPairs(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, Array<ContactPair>& contactPairs,
Set<uint64>& 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<ContactPointInfo> potentialContactPoints(allocator);
List<ContactManifoldInfo> potentialContactManifolds(allocator);
List<ContactPair> contactPairs(allocator);
List<ContactPair> lostContactPairs(allocator); // Not used during collision snapshots
List<ContactManifold> contactManifolds(allocator);
List<ContactPoint> contactPoints(allocator);
Array<ContactPointInfo> potentialContactPoints(allocator);
Array<ContactManifoldInfo> potentialContactManifolds(allocator);
Array<ContactPair> contactPairs(allocator);
Array<ContactPair> lostContactPairs(allocator); // Not used during collision snapshots
Array<ContactManifold> contactManifolds(allocator);
Array<ContactPoint> 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<ContactPair>& contactPairs,
List<ContactManifold>& contactManifolds,
List<ContactPoint>& contactPoints,
List<ContactManifoldInfo>& potentialContactManifolds,
List<ContactPointInfo>& potentialContactPoints) {
void CollisionDetectionSystem::createSnapshotContacts(Array<ContactPair>& contactPairs,
Array<ContactManifold>& contactManifolds,
Array<ContactPoint>& contactPoints,
Array<ContactManifoldInfo>& potentialContactManifolds,
Array<ContactPointInfo>& 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<uint64>& overlappingPairs = mCollidersComponents.getOverlappingPairs(collider->getEntity());
Array<uint64>& 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<ContactPointInfo>& potentialContactPoints,
List<ContactManifoldInfo>& potentialContactManifolds,
Array<ContactPointInfo>& potentialContactPoints,
Array<ContactManifoldInfo>& potentialContactManifolds,
Map<uint64, uint>& mapPairIdToContactPairIndex,
List<ContactPair>* contactPairs) {
Array<ContactPair>* 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<ContactPair>* contactPairs,
List<ContactManifoldInfo>& potentialContactManifolds,
const List<ContactPointInfo>& potentialContactPoints) const {
void CollisionDetectionSystem::reducePotentialContactManifolds(Array<ContactPair>* contactPairs,
Array<ContactManifoldInfo>& potentialContactManifolds,
const Array<ContactPointInfo>& potentialContactPoints) const {
RP3D_PROFILE("CollisionDetectionSystem::reducePotentialContactManifolds()", mProfiler);
@ -1357,7 +1357,7 @@ void CollisionDetectionSystem::reducePotentialContactManifolds(List<ContactPair>
// Return the largest depth of all the contact points of a potential manifold
decimal CollisionDetectionSystem::computePotentialManifoldLargestContactDepth(const ContactManifoldInfo& manifold,
const List<ContactPointInfo>& potentialContactPoints) const {
const Array<ContactPointInfo>& 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<ContactPointInfo>& potentialContactPoints) const {
const Array<ContactPointInfo>& 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<ContactPair>* contactPairs,
List<ContactManifold>* manifolds, List<ContactPoint>* contactPoints, List<ContactPair>& lostContactPairs) {
void CollisionDetectionSystem::reportContacts(CollisionCallback& callback, Array<ContactPair>* contactPairs,
Array<ContactManifold>* manifolds, Array<ContactPoint>* contactPoints, Array<ContactPair>& 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<ContactPair>* contactPairs, List<ContactPair>& lostContactPairs) {
void CollisionDetectionSystem::reportTriggers(EventListener& eventListener, Array<ContactPair>* contactPairs, Array<ContactPair>& 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<ContactPair>* contactPairs, List<ContactManifold>* manifolds, List<ContactPoint>* contactPoints, List<ContactPair>& lostContactPairs) {
void CollisionDetectionSystem::reportDebugRenderingContacts(Array<ContactPair>* contactPairs, Array<ContactManifold>* manifolds, Array<ContactPoint>* contactPoints, Array<ContactPair>& 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<uint64> convexPairs(mMemoryManager.getPoolAllocator());
List<uint64> concavePairs(mMemoryManager.getPoolAllocator());
Array<uint64> convexPairs(mMemoryManager.getPoolAllocator());
Array<uint64> 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<uint64> convexPairs(mMemoryManager.getPoolAllocator());
List<uint64> concavePairs(mMemoryManager.getPoolAllocator());
Array<uint64> convexPairs(mMemoryManager.getPoolAllocator());
Array<uint64> 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<uint64> convexPairs(mMemoryManager.getPoolAllocator());
List<uint64> concavePairs(mMemoryManager.getPoolAllocator());
Array<uint64> convexPairs(mMemoryManager.getPoolAllocator());
Array<uint64> 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<uint64> convexPairs(mMemoryManager.getPoolAllocator());
List<uint64> concavePairs(mMemoryManager.getPoolAllocator());
Array<uint64> convexPairs(mMemoryManager.getPoolAllocator());
Array<uint64> 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<uint64>& convexPairs, List<uint64>& concavePairs) const {
void CollisionDetectionSystem::filterOverlappingPairs(Entity bodyEntity, Array<uint64>& convexPairs, Array<uint64>& concavePairs) const {
// For each convex pairs
const uint32 nbConvexPairs = mOverlappingPairs.mConvexPairs.size();
@ -1785,7 +1785,7 @@ void CollisionDetectionSystem::filterOverlappingPairs(Entity bodyEntity, List<ui
}
// Filter the overlapping pairs to keep only the pairs where two given bodies are involved
void CollisionDetectionSystem::filterOverlappingPairs(Entity body1Entity, Entity body2Entity, List<uint64>& convexPairs, List<uint64>& concavePairs) const {
void CollisionDetectionSystem::filterOverlappingPairs(Entity body1Entity, Entity body2Entity, Array<uint64>& convexPairs, Array<uint64>& concavePairs) const {
// For each convex pair
const uint32 nbConvexPairs = mOverlappingPairs.mConvexPairs.size();

View File

@ -62,7 +62,7 @@ ContactSolverSystem::ContactSolverSystem(MemoryManager& memoryManager, PhysicsWo
}
// Initialize the contact constraints
void ContactSolverSystem::init(List<ContactManifold>* contactManifolds, List<ContactPoint>* contactPoints, decimal timeStep) {
void ContactSolverSystem::init(Array<ContactManifold>* contactManifolds, Array<ContactPoint>* contactPoints, decimal timeStep) {
mAllContactManifolds = contactManifolds;
mAllContactPoints = contactPoints;

View File

@ -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"

View File

@ -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"));

View File

@ -126,7 +126,7 @@ class TestDynamicAABBTree : public Test {
}
bool isOverlapping(int nodeId, const List<int>& overlappingNodes) const {
bool isOverlapping(int nodeId, const Array<int>& overlappingNodes) const {
return std::find(overlappingNodes.begin(), overlappingNodes.end(), nodeId) != overlappingNodes.end();
}
@ -223,7 +223,7 @@ class TestDynamicAABBTree : public Test {
// ---------- Tests ---------- //
List<int> overlappingNodes(mAllocator);
Array<int> overlappingNodes(mAllocator);
// AABB overlapping nothing
overlappingNodes.clear();

View File

@ -71,17 +71,17 @@ class TestHalfEdgeStructure : public Test {
cubeStructure.addVertex(7);
// Faces
List<uint> face0(mAllocator, 4);
Array<uint> face0(mAllocator, 4);
face0.add(0); face0.add(1); face0.add(2); face0.add(3);
List<uint> face1(mAllocator, 4);
Array<uint> face1(mAllocator, 4);
face1.add(1); face1.add(5); face1.add(6); face1.add(2);
List<uint> face2(mAllocator, 4);
Array<uint> face2(mAllocator, 4);
face2.add(5); face2.add(4); face2.add(7); face2.add(6);
List<uint> face3(mAllocator, 4);
Array<uint> face3(mAllocator, 4);
face3.add(4); face3.add(0); face3.add(3); face3.add(7);
List<uint> face4(mAllocator, 4);
Array<uint> face4(mAllocator, 4);
face4.add(0); face4.add(4); face4.add(5); face4.add(1);
List<uint> face5(mAllocator, 4);
Array<uint> 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<uint> face0(mAllocator, 3);
Array<uint> face0(mAllocator, 3);
face0.add(0); face0.add(1); face0.add(2);
List<uint> face1(mAllocator, 3);
Array<uint> face1(mAllocator, 3);
face1.add(0); face1.add(3); face1.add(1);
List<uint> face2(mAllocator, 3);
Array<uint> face2(mAllocator, 3);
face2.add(1); face2.add(3); face2.add(2);
List<uint> face3(mAllocator, 3);
Array<uint> face3(mAllocator, 3);
face3.add(0); face3.add(2); face3.add(3);
tetrahedron.addFace(face0);

View File

@ -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 <reactphysics3d/containers/Array.h>
#include <reactphysics3d/memory/DefaultAllocator.h>
/// 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<int> array1(mAllocator);
rp3d_test(array1.capacity() == 0);
rp3d_test(array1.size() == 0);
Array<int> array2(mAllocator, 100);
rp3d_test(array2.capacity() == 100);
rp3d_test(array2.size() == 0);
Array<int> array3(mAllocator);
array3.add(1);
array3.add(2);
array3.add(3);
rp3d_test(array3.capacity() == 4);
rp3d_test(array3.size() == 3);
// ----- Copy Constructors ----- //
Array<int> array4(array1);
rp3d_test(array4.capacity() == 0);
rp3d_test(array4.size() == 0);
Array<int> array5(array3);
rp3d_test(array5.capacity() == array3.capacity());
rp3d_test(array5.size() == array3.size());
for (uint i=0; i<array3.size(); i++) {
rp3d_test(array5[i] == array3[i]);
}
// ----- Test capacity grow ----- //
Array<std::string> 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<int> 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<int> array2(mAllocator);
for (uint i=0; i<arraySize; i++) {
array2.add(arrayTest[i]);
}
rp3d_test(array2.size() == arraySize);
for (uint i=0; i<arraySize; i++) {
rp3d_test(array2[i] == arrayTest[i]);
}
// ----- Test remove() ----- //
Array<int> 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<int> array4(mAllocator);
array4.add(1);
array4.add(2);
array4.add(3);
Array<int> array5(mAllocator);
array5.add(4);
array5.add(5);
Array<int> 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<std::string> 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<int> 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<int> array1(mAllocator);
array1.add(1);
array1.add(2);
array1.add(3);
Array<int> array2(mAllocator);
array2.add(5);
array2.add(6);
Array<int> array3(mAllocator);
Array<int> array4(mAllocator);
array4.add(1);
array4.add(2);
Array<int> 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<int> 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<int> 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<int> array1(mAllocator);
array1.add(1);
array1.add(2);
array1.add(3);
Array<int> array2(mAllocator);
array2.add(1);
array2.add(2);
Array<int> array3(mAllocator);
array3.add(1);
array3.add(2);
array3.add(3);
Array<int> 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<int> 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<int> array1(mAllocator);
rp3d_test(array1.begin() == array1.end());
array1.add(5);
array1.add(6);
array1.add(8);
array1.add(-1);
Array<int>::Iterator itBegin = array1.begin();
Array<int>::Iterator itEnd = array1.end();
Array<int>::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<int> 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

View File

@ -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 <reactphysics3d/containers/List.h>
#include <reactphysics3d/memory/DefaultAllocator.h>
/// 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<int> list1(mAllocator);
rp3d_test(list1.capacity() == 0);
rp3d_test(list1.size() == 0);
List<int> list2(mAllocator, 100);
rp3d_test(list2.capacity() == 100);
rp3d_test(list2.size() == 0);
List<int> list3(mAllocator);
list3.add(1);
list3.add(2);
list3.add(3);
rp3d_test(list3.capacity() == 4);
rp3d_test(list3.size() == 3);
// ----- Copy Constructors ----- //
List<int> list4(list1);
rp3d_test(list4.capacity() == 0);
rp3d_test(list4.size() == 0);
List<int> list5(list3);
rp3d_test(list5.capacity() == list3.capacity());
rp3d_test(list5.size() == list3.size());
for (uint i=0; i<list3.size(); i++) {
rp3d_test(list5[i] == list3[i]);
}
// ----- Test capacity grow ----- //
List<std::string> 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<int> 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<int> list2(mAllocator);
for (uint i=0; i<arraySize; i++) {
list2.add(arrayTest[i]);
}
rp3d_test(list2.size() == arraySize);
for (uint i=0; i<arraySize; i++) {
rp3d_test(list2[i] == arrayTest[i]);
}
// ----- Test remove() ----- //
List<int> 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<int> list4(mAllocator);
list4.add(1);
list4.add(2);
list4.add(3);
List<int> list5(mAllocator);
list5.add(4);
list5.add(5);
List<int> 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<std::string> 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<int> 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<int> list1(mAllocator);
list1.add(1);
list1.add(2);
list1.add(3);
List<int> list2(mAllocator);
list2.add(5);
list2.add(6);
List<int> list3(mAllocator);
List<int> list4(mAllocator);
list4.add(1);
list4.add(2);
List<int> 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<int> 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<int> 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<int> list1(mAllocator);
list1.add(1);
list1.add(2);
list1.add(3);
List<int> list2(mAllocator);
list2.add(1);
list2.add(2);
List<int> list3(mAllocator);
list3.add(1);
list3.add(2);
list3.add(3);
List<int> 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<int> 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<int> list1(mAllocator);
rp3d_test(list1.begin() == list1.end());
list1.add(5);
list1.add(6);
list1.add(8);
list1.add(-1);
List<int>::Iterator itBegin = list1.begin();
List<int>::Iterator itEnd = list1.end();
List<int>::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<int> 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

View File

@ -432,18 +432,18 @@ class TestSet : public Test {
set1.add(3);
set1.add(4);
List<int> 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<int> 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<int> set2(mAllocator);
List<int> list2 = set2.toList(mAllocator);
rp3d_test(list2.size() == 0);
Array<int> array2 = set2.toArray(mAllocator);
rp3d_test(array2.size() == 0);
}
};

View File

@ -27,7 +27,7 @@
#define TEST_MATHEMATICS_FUNCTIONS_H
// Libraries
#include <reactphysics3d/containers/List.h>
#include <reactphysics3d/containers/Array.h>
#include <reactphysics3d/memory/DefaultAllocator.h>
#include <reactphysics3d/mathematics/mathematics.h>
@ -187,12 +187,12 @@ class TestMathematicsFunctions : public Test {
segmentVertices.push_back(Vector3(-6, 3, 0));
segmentVertices.push_back(Vector3(8, 3, 0));
List<Vector3> planesNormals(mAllocator, 2);
List<Vector3> planesPoints(mAllocator, 2);
Array<Vector3> planesNormals(mAllocator, 2);
Array<Vector3> planesPoints(mAllocator, 2);
planesNormals.add(Vector3(-1, 0, 0));
planesPoints.add(Vector3(4, 0, 0));
List<Vector3> clipSegmentVertices = clipSegmentWithPlanes(segmentVertices[0], segmentVertices[1],
Array<Vector3> 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<Vector3> polygonVertices(mAllocator);
Array<Vector3> 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<Vector3> polygonPlanesNormals(mAllocator);
List<Vector3> polygonPlanesPoints(mAllocator);
Array<Vector3> polygonPlanesNormals(mAllocator);
Array<Vector3> 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<Vector3> clipPolygonVertices = clipPolygonWithPlanes(polygonVertices, polygonPlanesPoints, polygonPlanesNormals, mAllocator);
Array<Vector3> 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));