From f8d88ffab6693d38c653194fa3748043f0f438ef Mon Sep 17 00:00:00 2001
From: Andreas Drewke
Date: Thu, 11 Jul 2024 14:28:57 +0200
Subject: [PATCH] ext/reactphysics3d: updated to 0.10.1
---
Makefile | 103 +-
Makefile.nmake | 103 +-
ext/reactphysics3d/CHANGELOG.md | 576 +++++----
ext/reactphysics3d/FUNDING.yml | 3 +
ext/reactphysics3d/LICENSE | 2 +-
ext/reactphysics3d/README.md | 23 +-
ext/reactphysics3d/VERSION | 2 +-
.../body/{CollisionBody.h => Body.h} | 42 +-
.../include/reactphysics3d/body/RigidBody.h | 25 +-
.../reactphysics3d/collision/Collider.h | 28 +-
.../collision/CollisionCallback.h | 8 +-
.../collision/ContactManifold.h | 6 +-
.../collision/ContactManifoldInfo.h | 2 +-
.../reactphysics3d/collision/ContactPair.h | 2 +-
.../collision/ContactPointInfo.h | 4 +-
.../{PolyhedronMesh.h => ConvexMesh.h} | 125 +-
.../collision/HalfEdgeStructure.h | 28 +-
.../reactphysics3d/collision/HeightField.h | 273 +++++
.../collision/OverlapCallback.h | 10 +-
.../collision/PolygonVertexArray.h | 44 +-
.../reactphysics3d/collision/RaycastInfo.h | 11 +-
.../reactphysics3d/collision/TriangleMesh.h | 173 ++-
.../collision/TriangleVertexArray.h | 39 +-
.../reactphysics3d/collision/VertexArray.h | 125 ++
.../collision/broadphase/DynamicAABBTree.h | 21 +-
.../narrowphase/CapsuleVsCapsuleAlgorithm.h | 2 +-
.../CapsuleVsConvexPolyhedronAlgorithm.h | 2 +-
.../collision/narrowphase/CollisionDispatch.h | 12 +-
...vexPolyhedronVsConvexPolyhedronAlgorithm.h | 2 +-
.../collision/narrowphase/GJK/GJKAlgorithm.h | 2 +-
.../narrowphase/GJK/VoronoiSimplex.h | 2 +-
.../narrowphase/NarrowPhaseAlgorithm.h | 2 +-
.../narrowphase/NarrowPhaseInfoBatch.h | 10 +-
.../collision/narrowphase/NarrowPhaseInput.h | 4 +-
.../collision/narrowphase/SAT/SATAlgorithm.h | 2 +-
.../narrowphase/SphereVsCapsuleAlgorithm.h | 2 +-
.../SphereVsConvexPolyhedronAlgorithm.h | 2 +-
.../narrowphase/SphereVsSphereAlgorithm.h | 2 +-
.../reactphysics3d/collision/shapes/AABB.h | 30 +-
.../collision/shapes/BoxShape.h | 26 +-
.../collision/shapes/CapsuleShape.h | 25 +-
.../collision/shapes/CollisionShape.h | 12 +-
.../collision/shapes/ConcaveMeshShape.h | 114 +-
.../collision/shapes/ConcaveShape.h | 4 +-
.../collision/shapes/ConvexMeshShape.h | 106 +-
.../collision/shapes/ConvexPolyhedronShape.h | 2 +-
.../collision/shapes/ConvexShape.h | 2 +-
.../collision/shapes/HeightFieldShape.h | 120 +-
.../collision/shapes/SphereShape.h | 27 +-
.../collision/shapes/TriangleShape.h | 26 +-
.../components/BallAndSocketJointComponents.h | 4 +-
...isionBodyComponents.h => BodyComponents.h} | 69 +-
.../components/ColliderComponents.h | 55 +-
.../reactphysics3d/components/Components.h | 14 +-
.../components/FixedJointComponents.h | 4 +-
.../components/HingeJointComponents.h | 4 +-
.../components/JointComponents.h | 4 +-
.../components/RigidBodyComponents.h | 27 +-
.../components/SliderJointComponents.h | 4 +-
.../components/TransformComponents.h | 4 +-
.../include/reactphysics3d/configuration.h | 28 +-
.../constraint/BallAndSocketJoint.h | 2 +-
.../reactphysics3d/constraint/ContactPoint.h | 4 +-
.../reactphysics3d/constraint/FixedJoint.h | 2 +-
.../reactphysics3d/constraint/HingeJoint.h | 2 +-
.../include/reactphysics3d/constraint/Joint.h | 2 +-
.../reactphysics3d/constraint/SliderJoint.h | 2 +-
.../include/reactphysics3d/containers/Array.h | 21 +-
.../include/reactphysics3d/containers/Deque.h | 292 ++---
.../reactphysics3d/containers/LinkedList.h | 13 +-
.../include/reactphysics3d/containers/Map.h | 19 +-
.../include/reactphysics3d/containers/Pair.h | 6 +-
.../include/reactphysics3d/containers/Set.h | 10 +-
.../include/reactphysics3d/containers/Stack.h | 13 +-
.../containers/containers_common.h | 3 +-
.../include/reactphysics3d/decimal.h | 2 +-
.../include/reactphysics3d/engine/Entity.h | 4 +-
.../reactphysics3d/engine/EntityManager.h | 2 +-
.../reactphysics3d/engine/EventListener.h | 2 +-
.../include/reactphysics3d/engine/Island.h | 2 +-
.../include/reactphysics3d/engine/Islands.h | 2 +-
.../include/reactphysics3d/engine/Material.h | 4 +-
.../reactphysics3d/engine/OverlappingPairs.h | 124 +-
.../reactphysics3d/engine/PhysicsCommon.h | 51 +-
.../reactphysics3d/engine/PhysicsWorld.h | 54 +-
.../reactphysics3d/mathematics/Matrix2x2.h | 2 +-
.../reactphysics3d/mathematics/Matrix3x3.h | 2 +-
.../reactphysics3d/mathematics/Quaternion.h | 2 +-
.../include/reactphysics3d/mathematics/Ray.h | 2 +-
.../reactphysics3d/mathematics/Transform.h | 2 +-
.../reactphysics3d/mathematics/Vector2.h | 2 +-
.../reactphysics3d/mathematics/Vector3.h | 11 +-
.../reactphysics3d/mathematics/mathematics.h | 2 +-
.../mathematics/mathematics_common.h | 2 +-
.../mathematics/mathematics_functions.h | 2 +-
.../reactphysics3d/memory/DefaultAllocator.h | 37 +-
.../reactphysics3d/memory/HeapAllocator.h | 42 +-
.../reactphysics3d/memory/MemoryAllocator.h | 11 +-
.../reactphysics3d/memory/MemoryManager.h | 16 +-
.../reactphysics3d/memory/PoolAllocator.h | 9 +-
.../memory/SingleFrameAllocator.h | 10 +-
.../include/reactphysics3d/reactphysics3d.h | 13 +-
.../reactphysics3d/systems/BroadPhaseSystem.h | 7 +-
.../systems/CollisionDetectionSystem.h | 34 +-
.../systems/ConstraintSolverSystem.h | 2 +-
.../systems/ContactSolverSystem.h | 8 +-
.../reactphysics3d/systems/DynamicsSystem.h | 8 +-
.../systems/SolveBallAndSocketJointSystem.h | 2 +-
.../systems/SolveFixedJointSystem.h | 2 +-
.../systems/SolveHingeJointSystem.h | 2 +-
.../systems/SolveSliderJointSystem.h | 2 +-
.../reactphysics3d/utils/DebugRenderer.h | 33 +-
.../reactphysics3d/utils/DefaultLogger.h | 69 +-
.../include/reactphysics3d/utils/Logger.h | 2 +-
.../include/reactphysics3d/utils/Message.h | 63 +
.../include/reactphysics3d/utils/Profiler.h | 6 +-
.../utils/quickhull/QHHalfEdgeStructure.h | 397 ++++++
.../utils/quickhull/QuickHull.h | 184 +++
.../src/body/{CollisionBody.cpp => Body.cpp} | 185 +--
ext/reactphysics3d/src/body/RigidBody.cpp | 184 ++-
ext/reactphysics3d/src/collision/Collider.cpp | 68 +-
.../src/collision/CollisionCallback.cpp | 10 +-
.../src/collision/ContactManifold.cpp | 2 +-
.../src/collision/ConvexMesh.cpp | 264 ++++
.../src/collision/HalfEdgeStructure.cpp | 72 +-
.../src/collision/HeightField.cpp | 428 +++++++
.../src/collision/OverlapCallback.cpp | 10 +-
.../src/collision/PolygonVertexArray.cpp | 46 +-
.../src/collision/PolyhedronMesh.cpp | 249 ----
.../src/collision/RaycastInfo.cpp | 2 +-
.../src/collision/TriangleMesh.cpp | 316 ++++-
.../src/collision/TriangleVertexArray.cpp | 227 +---
.../src/collision/VertexArray.cpp | 69 ++
.../collision/broadphase/DynamicAABBTree.cpp | 9 +-
.../narrowphase/CapsuleVsCapsuleAlgorithm.cpp | 23 +-
.../CapsuleVsConvexPolyhedronAlgorithm.cpp | 25 +-
.../narrowphase/CollisionDispatch.cpp | 38 +-
...xPolyhedronVsConvexPolyhedronAlgorithm.cpp | 2 +-
.../narrowphase/GJK/GJKAlgorithm.cpp | 3 +-
.../narrowphase/GJK/VoronoiSimplex.cpp | 2 +-
.../narrowphase/NarrowPhaseInfoBatch.cpp | 9 +-
.../narrowphase/NarrowPhaseInput.cpp | 2 +-
.../narrowphase/SAT/SATAlgorithm.cpp | 17 +-
.../narrowphase/SphereVsCapsuleAlgorithm.cpp | 2 +-
.../SphereVsConvexPolyhedronAlgorithm.cpp | 2 +-
.../narrowphase/SphereVsSphereAlgorithm.cpp | 2 +-
.../src/collision/shapes/AABB.cpp | 2 +-
.../src/collision/shapes/BoxShape.cpp | 11 +-
.../src/collision/shapes/CapsuleShape.cpp | 13 +-
.../src/collision/shapes/CollisionShape.cpp | 29 +-
.../src/collision/shapes/ConcaveMeshShape.cpp | 263 ++--
.../src/collision/shapes/ConcaveShape.cpp | 11 +-
.../src/collision/shapes/ConvexMeshShape.cpp | 104 +-
.../shapes/ConvexPolyhedronShape.cpp | 2 +-
.../src/collision/shapes/ConvexShape.cpp | 2 +-
.../src/collision/shapes/HeightFieldShape.cpp | 393 +-----
.../src/collision/shapes/SphereShape.cpp | 16 +-
.../src/collision/shapes/TriangleShape.cpp | 25 +-
.../BallAndSocketJointComponents.cpp | 70 +-
...nBodyComponents.cpp => BodyComponents.cpp} | 56 +-
.../src/components/ColliderComponents.cpp | 70 +-
.../src/components/Components.cpp | 17 +-
.../src/components/FixedJointComponents.cpp | 59 +-
.../src/components/HingeJointComponents.cpp | 119 +-
.../src/components/JointComponents.cpp | 38 +-
.../src/components/RigidBodyComponents.cpp | 107 +-
.../src/components/SliderJointComponents.cpp | 134 +-
.../src/components/TransformComponents.cpp | 23 +-
.../src/constraint/BallAndSocketJoint.cpp | 2 +-
.../src/constraint/ContactPoint.cpp | 6 +-
.../src/constraint/FixedJoint.cpp | 2 +-
.../src/constraint/HingeJoint.cpp | 2 +-
ext/reactphysics3d/src/constraint/Joint.cpp | 2 +-
.../src/constraint/SliderJoint.cpp | 4 +-
ext/reactphysics3d/src/engine/Entity.cpp | 2 +-
.../src/engine/EntityManager.cpp | 2 +-
ext/reactphysics3d/src/engine/Island.cpp | 2 +-
ext/reactphysics3d/src/engine/Material.cpp | 2 +-
.../src/engine/OverlappingPairs.cpp | 353 +++++-
.../src/engine/PhysicsCommon.cpp | 231 +++-
.../src/engine/PhysicsWorld.cpp | 201 +--
.../src/mathematics/Matrix2x2.cpp | 2 +-
.../src/mathematics/Matrix3x3.cpp | 2 +-
.../src/mathematics/Quaternion.cpp | 2 +-
.../src/mathematics/Transform.cpp | 2 +-
.../src/mathematics/Vector2.cpp | 2 +-
.../src/mathematics/Vector3.cpp | 2 +-
.../src/memory/HeapAllocator.cpp | 186 ++-
.../src/memory/MemoryAllocator.cpp | 71 ++
.../src/memory/MemoryManager.cpp | 2 +-
.../src/memory/PoolAllocator.cpp | 26 +-
.../src/memory/SingleFrameAllocator.cpp | 62 +-
.../src/systems/BroadPhaseSystem.cpp | 20 +-
.../src/systems/CollisionDetectionSystem.cpp | 465 ++++---
.../src/systems/ConstraintSolverSystem.cpp | 4 +-
.../src/systems/ContactSolverSystem.cpp | 13 +-
.../src/systems/DynamicsSystem.cpp | 6 +-
.../systems/SolveBallAndSocketJointSystem.cpp | 5 +-
.../src/systems/SolveFixedJointSystem.cpp | 5 +-
.../src/systems/SolveHingeJointSystem.cpp | 5 +-
.../src/systems/SolveSliderJointSystem.cpp | 5 +-
.../src/utils/DebugRenderer.cpp | 192 ++-
.../src/utils/DefaultLogger.cpp | 15 +-
ext/reactphysics3d/src/utils/Profiler.cpp | 2 +-
.../utils/quickhull/QHHalfEdgeStructure.cpp | 419 +++++++
.../src/utils/quickhull/QuickHull.cpp | 1076 +++++++++++++++++
src/tdme/engine/SceneConnector.cpp | 2 -
src/tdme/engine/physics/Body.cpp | 1 +
src/tdme/engine/primitives/BoundingVolume.cpp | 2 +-
src/tdme/engine/primitives/ConvexMesh.cpp | 33 +-
src/tdme/engine/primitives/ConvexMesh.h | 4 +-
src/tdme/engine/primitives/HeightMap.cpp | 42 +-
src/tdme/engine/primitives/HeightMap.h | 9 +-
src/tdme/engine/primitives/TerrainMesh.cpp | 20 +-
214 files changed, 7965 insertions(+), 3543 deletions(-)
create mode 100644 ext/reactphysics3d/FUNDING.yml
rename ext/reactphysics3d/include/reactphysics3d/body/{CollisionBody.h => Body.h} (88%)
rename ext/reactphysics3d/include/reactphysics3d/collision/{PolyhedronMesh.h => ConvexMesh.h} (51%)
create mode 100644 ext/reactphysics3d/include/reactphysics3d/collision/HeightField.h
create mode 100644 ext/reactphysics3d/include/reactphysics3d/collision/VertexArray.h
rename ext/reactphysics3d/include/reactphysics3d/components/{CollisionBodyComponents.h => BodyComponents.h} (72%)
create mode 100644 ext/reactphysics3d/include/reactphysics3d/utils/Message.h
create mode 100644 ext/reactphysics3d/include/reactphysics3d/utils/quickhull/QHHalfEdgeStructure.h
create mode 100644 ext/reactphysics3d/include/reactphysics3d/utils/quickhull/QuickHull.h
rename ext/reactphysics3d/src/body/{CollisionBody.cpp => Body.cpp} (72%)
create mode 100644 ext/reactphysics3d/src/collision/ConvexMesh.cpp
create mode 100644 ext/reactphysics3d/src/collision/HeightField.cpp
delete mode 100644 ext/reactphysics3d/src/collision/PolyhedronMesh.cpp
create mode 100644 ext/reactphysics3d/src/collision/VertexArray.cpp
rename ext/reactphysics3d/src/components/{CollisionBodyComponents.cpp => BodyComponents.cpp} (69%)
create mode 100644 ext/reactphysics3d/src/memory/MemoryAllocator.cpp
create mode 100644 ext/reactphysics3d/src/utils/quickhull/QHHalfEdgeStructure.cpp
create mode 100644 ext/reactphysics3d/src/utils/quickhull/QuickHull.cpp
diff --git a/Makefile b/Makefile
index a109aa78c..84578c547 100644
--- a/Makefile
+++ b/Makefile
@@ -728,88 +728,93 @@ EXT_OGG_SRCS = \
ext/ogg/framing.c
EXT_REACTPHYSICS3D_SRCS = \
- ext/reactphysics3d/src/body/CollisionBody.cpp \
+ ext/reactphysics3d/src/body/Body.cpp \
ext/reactphysics3d/src/body/RigidBody.cpp \
ext/reactphysics3d/src/collision/broadphase/DynamicAABBTree.cpp \
+ ext/reactphysics3d/src/collision/Collider.cpp \
+ ext/reactphysics3d/src/collision/CollisionCallback.cpp \
+ ext/reactphysics3d/src/collision/ContactManifold.cpp \
+ ext/reactphysics3d/src/collision/ConvexMesh.cpp \
+ ext/reactphysics3d/src/collision/HalfEdgeStructure.cpp \
+ ext/reactphysics3d/src/collision/HeightField.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp \
ext/reactphysics3d/src/collision/narrowphase/CollisionDispatch.cpp \
- ext/reactphysics3d/src/collision/narrowphase/GJK/VoronoiSimplex.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp \
ext/reactphysics3d/src/collision/narrowphase/GJK/GJKAlgorithm.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/GJK/VoronoiSimplex.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/NarrowPhaseInput.cpp \
ext/reactphysics3d/src/collision/narrowphase/SAT/SATAlgorithm.cpp \
- ext/reactphysics3d/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp \
- ext/reactphysics3d/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp \
ext/reactphysics3d/src/collision/narrowphase/SphereVsCapsuleAlgorithm.cpp \
ext/reactphysics3d/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp \
- ext/reactphysics3d/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp \
- ext/reactphysics3d/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp \
- ext/reactphysics3d/src/collision/narrowphase/NarrowPhaseInput.cpp \
- ext/reactphysics3d/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp \
+ ext/reactphysics3d/src/collision/OverlapCallback.cpp \
+ ext/reactphysics3d/src/collision/PolygonVertexArray.cpp \
+ ext/reactphysics3d/src/collision/RaycastInfo.cpp \
ext/reactphysics3d/src/collision/shapes/AABB.cpp \
- ext/reactphysics3d/src/collision/shapes/ConvexShape.cpp \
- ext/reactphysics3d/src/collision/shapes/ConvexPolyhedronShape.cpp \
- ext/reactphysics3d/src/collision/shapes/ConcaveShape.cpp \
ext/reactphysics3d/src/collision/shapes/BoxShape.cpp \
ext/reactphysics3d/src/collision/shapes/CapsuleShape.cpp \
ext/reactphysics3d/src/collision/shapes/CollisionShape.cpp \
+ ext/reactphysics3d/src/collision/shapes/ConcaveMeshShape.cpp \
+ ext/reactphysics3d/src/collision/shapes/ConcaveShape.cpp \
ext/reactphysics3d/src/collision/shapes/ConvexMeshShape.cpp \
+ ext/reactphysics3d/src/collision/shapes/ConvexPolyhedronShape.cpp \
+ ext/reactphysics3d/src/collision/shapes/ConvexShape.cpp \
+ ext/reactphysics3d/src/collision/shapes/HeightFieldShape.cpp \
ext/reactphysics3d/src/collision/shapes/SphereShape.cpp \
ext/reactphysics3d/src/collision/shapes/TriangleShape.cpp \
- ext/reactphysics3d/src/collision/shapes/ConcaveMeshShape.cpp \
- ext/reactphysics3d/src/collision/shapes/HeightFieldShape.cpp \
- ext/reactphysics3d/src/collision/RaycastInfo.cpp \
- ext/reactphysics3d/src/collision/Collider.cpp \
- ext/reactphysics3d/src/collision/TriangleVertexArray.cpp \
- ext/reactphysics3d/src/collision/PolygonVertexArray.cpp \
ext/reactphysics3d/src/collision/TriangleMesh.cpp \
- ext/reactphysics3d/src/collision/PolyhedronMesh.cpp \
- ext/reactphysics3d/src/collision/HalfEdgeStructure.cpp \
- ext/reactphysics3d/src/collision/ContactManifold.cpp \
+ ext/reactphysics3d/src/collision/TriangleVertexArray.cpp \
+ ext/reactphysics3d/src/collision/VertexArray.cpp \
+ ext/reactphysics3d/src/components/BallAndSocketJointComponents.cpp \
+ ext/reactphysics3d/src/components/BodyComponents.cpp \
+ ext/reactphysics3d/src/components/ColliderComponents.cpp \
+ ext/reactphysics3d/src/components/Components.cpp \
+ ext/reactphysics3d/src/components/FixedJointComponents.cpp \
+ ext/reactphysics3d/src/components/HingeJointComponents.cpp \
+ ext/reactphysics3d/src/components/JointComponents.cpp \
+ ext/reactphysics3d/src/components/RigidBodyComponents.cpp \
+ ext/reactphysics3d/src/components/SliderJointComponents.cpp \
+ ext/reactphysics3d/src/components/TransformComponents.cpp \
ext/reactphysics3d/src/constraint/BallAndSocketJoint.cpp \
ext/reactphysics3d/src/constraint/ContactPoint.cpp \
ext/reactphysics3d/src/constraint/FixedJoint.cpp \
ext/reactphysics3d/src/constraint/HingeJoint.cpp \
ext/reactphysics3d/src/constraint/Joint.cpp \
ext/reactphysics3d/src/constraint/SliderJoint.cpp \
- ext/reactphysics3d/src/engine/PhysicsCommon.cpp \
- ext/reactphysics3d/src/systems/ConstraintSolverSystem.cpp \
- ext/reactphysics3d/src/systems/ContactSolverSystem.cpp \
- ext/reactphysics3d/src/systems/DynamicsSystem.cpp \
- ext/reactphysics3d/src/systems/CollisionDetectionSystem.cpp \
- ext/reactphysics3d/src/systems/SolveBallAndSocketJointSystem.cpp \
- ext/reactphysics3d/src/systems/SolveFixedJointSystem.cpp \
- ext/reactphysics3d/src/systems/SolveHingeJointSystem.cpp \
- ext/reactphysics3d/src/systems/SolveSliderJointSystem.cpp \
- ext/reactphysics3d/src/engine/PhysicsWorld.cpp \
+ ext/reactphysics3d/src/engine/Entity.cpp \
+ ext/reactphysics3d/src/engine/EntityManager.cpp \
ext/reactphysics3d/src/engine/Island.cpp \
ext/reactphysics3d/src/engine/Material.cpp \
ext/reactphysics3d/src/engine/OverlappingPairs.cpp \
- ext/reactphysics3d/src/engine/Entity.cpp \
- ext/reactphysics3d/src/engine/EntityManager.cpp \
- ext/reactphysics3d/src/systems/BroadPhaseSystem.cpp \
- ext/reactphysics3d/src/components/Components.cpp \
- ext/reactphysics3d/src/components/CollisionBodyComponents.cpp \
- ext/reactphysics3d/src/components/RigidBodyComponents.cpp \
- ext/reactphysics3d/src/components/TransformComponents.cpp \
- ext/reactphysics3d/src/components/ColliderComponents.cpp \
- ext/reactphysics3d/src/components/JointComponents.cpp \
- ext/reactphysics3d/src/components/BallAndSocketJointComponents.cpp \
- ext/reactphysics3d/src/components/FixedJointComponents.cpp \
- ext/reactphysics3d/src/components/HingeJointComponents.cpp \
- ext/reactphysics3d/src/components/SliderJointComponents.cpp \
- ext/reactphysics3d/src/collision/CollisionCallback.cpp \
- ext/reactphysics3d/src/collision/OverlapCallback.cpp \
+ ext/reactphysics3d/src/engine/PhysicsCommon.cpp \
+ ext/reactphysics3d/src/engine/PhysicsWorld.cpp \
ext/reactphysics3d/src/mathematics/Matrix2x2.cpp \
ext/reactphysics3d/src/mathematics/Matrix3x3.cpp \
ext/reactphysics3d/src/mathematics/Quaternion.cpp \
ext/reactphysics3d/src/mathematics/Transform.cpp \
ext/reactphysics3d/src/mathematics/Vector2.cpp \
ext/reactphysics3d/src/mathematics/Vector3.cpp \
- ext/reactphysics3d/src/memory/PoolAllocator.cpp \
- ext/reactphysics3d/src/memory/SingleFrameAllocator.cpp \
ext/reactphysics3d/src/memory/HeapAllocator.cpp \
+ ext/reactphysics3d/src/memory/MemoryAllocator.cpp \
ext/reactphysics3d/src/memory/MemoryManager.cpp \
- ext/reactphysics3d/src/utils/Profiler.cpp \
+ ext/reactphysics3d/src/memory/PoolAllocator.cpp \
+ ext/reactphysics3d/src/memory/SingleFrameAllocator.cpp \
+ ext/reactphysics3d/src/systems/BroadPhaseSystem.cpp \
+ ext/reactphysics3d/src/systems/CollisionDetectionSystem.cpp \
+ ext/reactphysics3d/src/systems/ConstraintSolverSystem.cpp \
+ ext/reactphysics3d/src/systems/ContactSolverSystem.cpp \
+ ext/reactphysics3d/src/systems/DynamicsSystem.cpp \
+ ext/reactphysics3d/src/systems/SolveBallAndSocketJointSystem.cpp \
+ ext/reactphysics3d/src/systems/SolveFixedJointSystem.cpp \
+ ext/reactphysics3d/src/systems/SolveHingeJointSystem.cpp \
+ ext/reactphysics3d/src/systems/SolveSliderJointSystem.cpp \
+ ext/reactphysics3d/src/utils/DebugRenderer.cpp \
ext/reactphysics3d/src/utils/DefaultLogger.cpp \
- ext/reactphysics3d/src/utils/DebugRenderer.cpp
+ ext/reactphysics3d/src/utils/Profiler.cpp \
+ ext/reactphysics3d/src/utils/quickhull/QHHalfEdgeStructure.cpp \
+ ext/reactphysics3d/src/utils/quickhull/QuickHull.cpp
EXT_CPPSPLINE_SRCS = \
ext/cpp-spline/src/Bezier.cpp \
diff --git a/Makefile.nmake b/Makefile.nmake
index 639ac0681..0d65c12ab 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -596,88 +596,93 @@ EXT_OGG_SRCS = \
ext/ogg/framing.c
EXT_REACTPHYSICS3D_SRCS = \
- ext/reactphysics3d/src/body/CollisionBody.cpp \
+ ext/reactphysics3d/src/body/Body.cpp \
ext/reactphysics3d/src/body/RigidBody.cpp \
ext/reactphysics3d/src/collision/broadphase/DynamicAABBTree.cpp \
+ ext/reactphysics3d/src/collision/Collider.cpp \
+ ext/reactphysics3d/src/collision/CollisionCallback.cpp \
+ ext/reactphysics3d/src/collision/ContactManifold.cpp \
+ ext/reactphysics3d/src/collision/ConvexMesh.cpp \
+ ext/reactphysics3d/src/collision/HalfEdgeStructure.cpp \
+ ext/reactphysics3d/src/collision/HeightField.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp \
ext/reactphysics3d/src/collision/narrowphase/CollisionDispatch.cpp \
- ext/reactphysics3d/src/collision/narrowphase/GJK/VoronoiSimplex.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp \
ext/reactphysics3d/src/collision/narrowphase/GJK/GJKAlgorithm.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/GJK/VoronoiSimplex.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/NarrowPhaseInput.cpp \
ext/reactphysics3d/src/collision/narrowphase/SAT/SATAlgorithm.cpp \
- ext/reactphysics3d/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp \
- ext/reactphysics3d/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp \
ext/reactphysics3d/src/collision/narrowphase/SphereVsCapsuleAlgorithm.cpp \
ext/reactphysics3d/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp \
- ext/reactphysics3d/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp \
- ext/reactphysics3d/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp \
- ext/reactphysics3d/src/collision/narrowphase/NarrowPhaseInput.cpp \
- ext/reactphysics3d/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp \
+ ext/reactphysics3d/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp \
+ ext/reactphysics3d/src/collision/OverlapCallback.cpp \
+ ext/reactphysics3d/src/collision/PolygonVertexArray.cpp \
+ ext/reactphysics3d/src/collision/RaycastInfo.cpp \
ext/reactphysics3d/src/collision/shapes/AABB.cpp \
- ext/reactphysics3d/src/collision/shapes/ConvexShape.cpp \
- ext/reactphysics3d/src/collision/shapes/ConvexPolyhedronShape.cpp \
- ext/reactphysics3d/src/collision/shapes/ConcaveShape.cpp \
ext/reactphysics3d/src/collision/shapes/BoxShape.cpp \
ext/reactphysics3d/src/collision/shapes/CapsuleShape.cpp \
ext/reactphysics3d/src/collision/shapes/CollisionShape.cpp \
+ ext/reactphysics3d/src/collision/shapes/ConcaveMeshShape.cpp \
+ ext/reactphysics3d/src/collision/shapes/ConcaveShape.cpp \
ext/reactphysics3d/src/collision/shapes/ConvexMeshShape.cpp \
+ ext/reactphysics3d/src/collision/shapes/ConvexPolyhedronShape.cpp \
+ ext/reactphysics3d/src/collision/shapes/ConvexShape.cpp \
+ ext/reactphysics3d/src/collision/shapes/HeightFieldShape.cpp \
ext/reactphysics3d/src/collision/shapes/SphereShape.cpp \
ext/reactphysics3d/src/collision/shapes/TriangleShape.cpp \
- ext/reactphysics3d/src/collision/shapes/ConcaveMeshShape.cpp \
- ext/reactphysics3d/src/collision/shapes/HeightFieldShape.cpp \
- ext/reactphysics3d/src/collision/RaycastInfo.cpp \
- ext/reactphysics3d/src/collision/Collider.cpp \
- ext/reactphysics3d/src/collision/TriangleVertexArray.cpp \
- ext/reactphysics3d/src/collision/PolygonVertexArray.cpp \
ext/reactphysics3d/src/collision/TriangleMesh.cpp \
- ext/reactphysics3d/src/collision/PolyhedronMesh.cpp \
- ext/reactphysics3d/src/collision/HalfEdgeStructure.cpp \
- ext/reactphysics3d/src/collision/ContactManifold.cpp \
+ ext/reactphysics3d/src/collision/TriangleVertexArray.cpp \
+ ext/reactphysics3d/src/collision/VertexArray.cpp \
+ ext/reactphysics3d/src/components/BallAndSocketJointComponents.cpp \
+ ext/reactphysics3d/src/components/BodyComponents.cpp \
+ ext/reactphysics3d/src/components/ColliderComponents.cpp \
+ ext/reactphysics3d/src/components/Components.cpp \
+ ext/reactphysics3d/src/components/FixedJointComponents.cpp \
+ ext/reactphysics3d/src/components/HingeJointComponents.cpp \
+ ext/reactphysics3d/src/components/JointComponents.cpp \
+ ext/reactphysics3d/src/components/RigidBodyComponents.cpp \
+ ext/reactphysics3d/src/components/SliderJointComponents.cpp \
+ ext/reactphysics3d/src/components/TransformComponents.cpp \
ext/reactphysics3d/src/constraint/BallAndSocketJoint.cpp \
ext/reactphysics3d/src/constraint/ContactPoint.cpp \
ext/reactphysics3d/src/constraint/FixedJoint.cpp \
ext/reactphysics3d/src/constraint/HingeJoint.cpp \
ext/reactphysics3d/src/constraint/Joint.cpp \
ext/reactphysics3d/src/constraint/SliderJoint.cpp \
- ext/reactphysics3d/src/engine/PhysicsCommon.cpp \
- ext/reactphysics3d/src/systems/ConstraintSolverSystem.cpp \
- ext/reactphysics3d/src/systems/ContactSolverSystem.cpp \
- ext/reactphysics3d/src/systems/DynamicsSystem.cpp \
- ext/reactphysics3d/src/systems/CollisionDetectionSystem.cpp \
- ext/reactphysics3d/src/systems/SolveBallAndSocketJointSystem.cpp \
- ext/reactphysics3d/src/systems/SolveFixedJointSystem.cpp \
- ext/reactphysics3d/src/systems/SolveHingeJointSystem.cpp \
- ext/reactphysics3d/src/systems/SolveSliderJointSystem.cpp \
- ext/reactphysics3d/src/engine/PhysicsWorld.cpp \
+ ext/reactphysics3d/src/engine/Entity.cpp \
+ ext/reactphysics3d/src/engine/EntityManager.cpp \
ext/reactphysics3d/src/engine/Island.cpp \
ext/reactphysics3d/src/engine/Material.cpp \
ext/reactphysics3d/src/engine/OverlappingPairs.cpp \
- ext/reactphysics3d/src/engine/Entity.cpp \
- ext/reactphysics3d/src/engine/EntityManager.cpp \
- ext/reactphysics3d/src/systems/BroadPhaseSystem.cpp \
- ext/reactphysics3d/src/components/Components.cpp \
- ext/reactphysics3d/src/components/CollisionBodyComponents.cpp \
- ext/reactphysics3d/src/components/RigidBodyComponents.cpp \
- ext/reactphysics3d/src/components/TransformComponents.cpp \
- ext/reactphysics3d/src/components/ColliderComponents.cpp \
- ext/reactphysics3d/src/components/JointComponents.cpp \
- ext/reactphysics3d/src/components/BallAndSocketJointComponents.cpp \
- ext/reactphysics3d/src/components/FixedJointComponents.cpp \
- ext/reactphysics3d/src/components/HingeJointComponents.cpp \
- ext/reactphysics3d/src/components/SliderJointComponents.cpp \
- ext/reactphysics3d/src/collision/CollisionCallback.cpp \
- ext/reactphysics3d/src/collision/OverlapCallback.cpp \
+ ext/reactphysics3d/src/engine/PhysicsCommon.cpp \
+ ext/reactphysics3d/src/engine/PhysicsWorld.cpp \
ext/reactphysics3d/src/mathematics/Matrix2x2.cpp \
ext/reactphysics3d/src/mathematics/Matrix3x3.cpp \
ext/reactphysics3d/src/mathematics/Quaternion.cpp \
ext/reactphysics3d/src/mathematics/Transform.cpp \
ext/reactphysics3d/src/mathematics/Vector2.cpp \
ext/reactphysics3d/src/mathematics/Vector3.cpp \
- ext/reactphysics3d/src/memory/PoolAllocator.cpp \
- ext/reactphysics3d/src/memory/SingleFrameAllocator.cpp \
ext/reactphysics3d/src/memory/HeapAllocator.cpp \
+ ext/reactphysics3d/src/memory/MemoryAllocator.cpp \
ext/reactphysics3d/src/memory/MemoryManager.cpp \
- ext/reactphysics3d/src/utils/Profiler.cpp \
+ ext/reactphysics3d/src/memory/PoolAllocator.cpp \
+ ext/reactphysics3d/src/memory/SingleFrameAllocator.cpp \
+ ext/reactphysics3d/src/systems/BroadPhaseSystem.cpp \
+ ext/reactphysics3d/src/systems/CollisionDetectionSystem.cpp \
+ ext/reactphysics3d/src/systems/ConstraintSolverSystem.cpp \
+ ext/reactphysics3d/src/systems/ContactSolverSystem.cpp \
+ ext/reactphysics3d/src/systems/DynamicsSystem.cpp \
+ ext/reactphysics3d/src/systems/SolveBallAndSocketJointSystem.cpp \
+ ext/reactphysics3d/src/systems/SolveFixedJointSystem.cpp \
+ ext/reactphysics3d/src/systems/SolveHingeJointSystem.cpp \
+ ext/reactphysics3d/src/systems/SolveSliderJointSystem.cpp \
+ ext/reactphysics3d/src/utils/DebugRenderer.cpp \
ext/reactphysics3d/src/utils/DefaultLogger.cpp \
- ext/reactphysics3d/src/utils/DebugRenderer.cpp
+ ext/reactphysics3d/src/utils/Profiler.cpp \
+ ext/reactphysics3d/src/utils/quickhull/QHHalfEdgeStructure.cpp \
+ ext/reactphysics3d/src/utils/quickhull/QuickHull.cpp
EXT_CPPSPLINE_SRCS = \
ext/cpp-spline/src/Bezier.cpp \
diff --git a/ext/reactphysics3d/CHANGELOG.md b/ext/reactphysics3d/CHANGELOG.md
index 2c915cfc2..3a955c843 100644
--- a/ext/reactphysics3d/CHANGELOG.md
+++ b/ext/reactphysics3d/CHANGELOG.md
@@ -1,49 +1,132 @@
# Changelog
-## Version 0.9.0 (January 4, 2022)
+## [0.10.1] - 2024-06-25
+
+### Fixed
+
+- Issue [#377](https://github.com/DanielChappuis/reactphysics3d/issues/377) Assert when destroying an empty PhysicsWorld
+- Issue [#378](https://github.com/DanielChappuis/reactphysics3d/issues/378) Wrong raycasting result against the HeightFieldShape
+- Issue [#381](https://github.com/DanielChappuis/reactphysics3d/issues/381) Fix robustness issue with CapsuleShape vs CapsuleShape collision
+- Issue [#387](https://github.com/DanielChappuis/reactphysics3d/issues/387) Fix memory allocation issue when destroying a ConvexMesh
+- Issue [#388](https://github.com/DanielChappuis/reactphysics3d/issues/388) Fix bodies without simulation collider not taken into account during islands creation
+- Fix crash within testbed application in raycasting scene
+
+## [0.10.0] - 2024-03-10
+
+### Changed
+
+- The library must now be compiled with a C++ 17 compiler
+- The internal allocators now allocates memory that is 16-bytes aligned
+- If the user sets its own custom allocator, the return allocated memory must now be 16 bytes aligned
+- The PolyhedronMesh class has been renamed to ConvexMesh
+- The PhysicsCommon::createPolyhedronMesh() method has been renamed to PhysicsCommon::createConvexMesh()
+- The PhysicsCommon::destroyPolyhedronMesh() method has been renamed to PhysicsCommon::destroyConvexMesh()
+- The PhysicsCommon::createConvexMesh() nows outputs a list of errors that might have happened during the mesh creation
+- The PhysicsCommon::createConvexMesh() method now takes a reference to PolygonVertexArray
+- When creating a ConvexMesh with PhysicsCommon::createConvexMesh(), the user data (vertices, faces) is now copied into the ConvexMesh and not shared anymore
+- The PhysicsCommon::createTriangleMesh() method now directly takes a TriangleVertexArray
+- The PhysicsCommon::createTriangleMesh() nows outputs a list of errors that might have happened during the mesh creation
+- When creating a TriangleMesh with PhysicsCommon::createTriangleMesh(), the user data (vertices, faces) is now copied into the TriangleMesh and not shared anymore
+- The PhysicsCommon::createHeightField() must be used to create a HeightField object
+- The PhysicsCommon::createHeightFieldShape() method now takes a HeightField object
+- It is not necessary anymore to specify the min/max height when creating a HeightFieldShape
+- It is not possible anymore to specify the up axis when creating a HeightFieldShape
+- When creating a HeightField with PhysicsCommon::createHeightField(), the user data (heights values) is now copied into the HeightField and not shared anymore
+- The signature of the TriangleVertexArray::getTriangleVerticesIndices() method has changed
+- The signature of the TriangleVertexArray::getNormal() method has changed
+- The getLocalBounds() methods of the collision shapes now returns an AABB
+- It is now necessary to enable debug rendering for each body that you want to debug using the Body::setIsDebugEnabled() method
### Added
- - The performance of the collision detection and rigid bodies simulation (PhysicsWorld::update() method) has been improved significantly (1.7x speedup on average measured in [PEEL](https://github.com/Pierre-Terdiman/PEEL) scenes)
- - Method RigidBody::resetForce() to reset the accumulated external force on a rigid body has been added
- - Method RigidBody::resetTorque() to reset the accumulated external torque on a rigid body has been added
- - Constructors with local-space anchor/axis have been added to BallAndSocketJointInfo, HingeJointInfo, FixedJointInfo and SliderJointInfo classes
- - Method HingeJoint::getAngle() to get the current angle of the hinge joint has been added
- - Method Joint::getReactionForce() has been added to retrieve the current reaction force of a joint
- - Method Joint::getReactionTorque() has been added to retrieve the current reaction torque of a joint
- - Method RigidBody::setLinearLockAxisFactor() to lock the translational movement of a body along the world-space x, y and z axes
- - Method RigidBody::setAngularLockAxisFactor() to lock the rotational movement of a body around the world-space x, y and z axes
- - Method RigidBody::applyLocalForceAtWorldPosition() to manually apply a force to a rigid body
- - Method RigidBody::applyLocalForceAtLocalPosition() to manually apply a force to a rigid body
- - Method RigidBody::applyLocalForceToCenterOfMass() to manually apply a force to a rigid body
- - Method RigidBody::applyLocalTorque() to apply a local-space torque to a rigid body
- - Method RigidBody::getForce() to get the total manually applied force on a rigid body
- - Method RigidBody::getTorque() to get the total manually applied torque on a rigid body
- - Method RigidBody::setIsSleeping() is now public in order to wake up or put to sleep a rigid body
- - A cone limit can now be set to the ball-and-socket joint (this is useful for ragdolls)
- - New scenes have been added to the testbed application (Box Tower, Ragdoll, Rope, Ball And Socket Joint, Bridge, Hinge Joint, Hinge Joint chain, Ball and
- Socket Joint chain, Ball and Socket Joint net, ...)
- - It is now possible to move bodies using the mouse (CTRL + click and drag) in the testbed application
+- The library will now return errors found in input data during the creation of ConvexMesh, TriangularMesh and HeighField
+- It is now possible to create a ConvexMeshShape by specifying only a list of vertices (automatic computation of convex hull using internal
+QuickHull algorithm)
+- The performance of static bodies has been improved
+- The reporting of contact state is now correct even if the body goes to sleep
+- The DebugRenderer can now display the normals of the collider faces for debugging purpose
+- It is now possible to select for which bodies the debug information from the DebugRenderer is displayed
+
+### Removed
+
+- The TriangleMesh does not support adding multiple parts of a mesh anymore.
+- The TriangleMesh::addSubpart() method has been removed. The PhysicsCommon::createTriangleMesh() method should be used instead
+- The TriangleMesh::getSubpart() method has been removed.
+- The TriangleMesh::getNbSubparts() method has been removed.
+- When creating a HeightField, it is not possible to specify the up axis anymore (changing the Transform of the Collider must be used instead)
+- No need to specify the min/max height when creating a HeightField anymore (this is now automatically computed)
+- The HeightFiedShape::getNbColumns() method has been removed (HeightFieldShape::getHeightField()->getNbColumns() must be used instead)
+- The HeightFiedShape::getNbRows() method has been removed (HeightFieldShape::getHeightField()->getNbRows() must be used instead)
+- The HeightFiedShape::getHeightAt() method has been removed (HeightFieldShape::getHeightField()->getHeightAt() must be used instead)
+- The CollisionBody class has been removed (RigidBody class must be used instead with a Collider where isSimulationCollider is disabled)
+- The PhysicsWorld::createCollisionBody() method has been removed
+- The PhysicsWorld::destroyCollisionBody() method has been removed
+- The PhysicsWorld::getCollisionBody() method has been removed
+- The PhysicsWorld::getNbCollisionBodies() method has been removed
+
+### Fixed
+
+- Issue [#206](https://github.com/DanielChappuis/reactphysics3d/issues/206) Collision issue and scaling of collider normals
+- Issue [#235](https://github.com/DanielChappuis/reactphysics3d/issues/235) Removing a body should wake up its neighbors
+- Issue [#237](https://github.com/DanielChappuis/reactphysics3d/issues/237) Wrong assert has been removed
+- Issue [#239](https://github.com/DanielChappuis/reactphysics3d/issues/239) Memory allocation alignment
+- Issue [#240](https://github.com/DanielChappuis/reactphysics3d/issues/240) Uninitialized variable
+- Issue [#347](https://github.com/DanielChappuis/reactphysics3d/issues/347) Missing collision between capsule and triangle edge in some case
+- Issue [#362](https://github.com/DanielChappuis/reactphysics3d/issues/362) Bug in Collider::setLocalToBodyTransform()
+- Issue [#275](https://github.com/DanielChappuis/reactphysics3d/issues/275) Compilation warning
+- Issue [#286](https://github.com/DanielChappuis/reactphysics3d/issues/286) Compilation error on Android
+- Issue [#323](https://github.com/DanielChappuis/reactphysics3d/issues/323) Avoid conflict with X11 library
+- Issue [#362](https://github.com/DanielChappuis/reactphysics3d/issues/362) Crash
+- Issue [#364](https://github.com/DanielChappuis/reactphysics3d/issues/364) Assert in createContacts() method
+- Issue [#366](https://github.com/DanielChappuis/reactphysics3d/issues/366) Crash when creating islands
+- Issue [#370](https://github.com/DanielChappuis/reactphysics3d/issues/370) Compilation error on recent compiler
+- Issue with edge vs edge collision detection for BoxShape, ConvexMeshShape, ConcaveMeshShape and HeightFieldShape (SAT algorithm)
+- Compilation error on Clang 19
+
+## [0.9.0] - 2022-01-04
### Changed
- - The PhysicsWorld::setGravity() method now takes a const parameter
- - Rolling resistance constraint is not solved anymore in the solver. Angular damping needs to be used instead to simulate it.
- - The List class has been renamed to Array
- - The default number of iterations for the velocity solver is now 6 instead of 10
- - The default number of iterations for the position solver is now 3 instead of 5
- - Rename method RigidBody::applyForceAtWorldPosition() into RigidBody::applyWorldForceAtWorldPosition()
- - Rename method RigidBody::applyForceAtLocalPosition() into RigidBody::applyWorldForceAtLocalPosition()
- - Rename method RigidBody::applyForceToCenterOfMass() into RigidBody::applyWorldForceAtCenterOfMass()
- - Rename method RigidBody::applyTorque() into RigidBody::applyWorldTorque()
- - The raycasting broad-phase performance has been improved
- - The raycasting performance against HeighFieldShape has been improved (better middle-phase algorithm)
- - Robustness of polyhedron vs polyhedron collision detection has been improved in SAT algorithm (face contacts are favored over edge-edge contacts for better stability)
+- The PhysicsWorld::setGravity() method now takes a const parameter
+- Rolling resistance constraint is not solved anymore in the solver. Angular damping needs to be used instead to simulate it.
+- The List class has been renamed to Array
+- The default number of iterations for the velocity solver is now 6 instead of 10
+- The default number of iterations for the position solver is now 3 instead of 5
+- Rename method RigidBody::applyForceAtWorldPosition() into RigidBody::applyWorldForceAtWorldPosition()
+- Rename method RigidBody::applyForceAtLocalPosition() into RigidBody::applyWorldForceAtLocalPosition()
+- Rename method RigidBody::applyForceToCenterOfMass() into RigidBody::applyWorldForceAtCenterOfMass()
+- Rename method RigidBody::applyTorque() into RigidBody::applyWorldTorque()
+- The raycasting broad-phase performance has been improved
+- The raycasting performance against HeighFieldShape has been improved (better middle-phase algorithm)
+- Robustness of polyhedron vs polyhedron collision detection has been improved in SAT algorithm (face contacts are favored over edge-edge contacts for better stability)
+
+### Added
+
+- The performance of the collision detection and rigid bodies simulation (PhysicsWorld::update() method) has been improved significantly (1.7x speedup on average measured in [PEEL](https://github.com/Pierre-Terdiman/PEEL) scenes)
+- Method RigidBody::resetForce() to reset the accumulated external force on a rigid body has been added
+- Method RigidBody::resetTorque() to reset the accumulated external torque on a rigid body has been added
+- Constructors with local-space anchor/axis have been added to BallAndSocketJointInfo, HingeJointInfo, FixedJointInfo and SliderJointInfo classes
+- Method HingeJoint::getAngle() to get the current angle of the hinge joint has been added
+- Method Joint::getReactionForce() has been added to retrieve the current reaction force of a joint
+- Method Joint::getReactionTorque() has been added to retrieve the current reaction torque of a joint
+- Method RigidBody::setLinearLockAxisFactor() to lock the translational movement of a body along the world-space x, y and z axes
+- Method RigidBody::setAngularLockAxisFactor() to lock the rotational movement of a body around the world-space x, y and z axes
+- Method RigidBody::applyLocalForceAtWorldPosition() to manually apply a force to a rigid body
+- Method RigidBody::applyLocalForceAtLocalPosition() to manually apply a force to a rigid body
+- Method RigidBody::applyLocalForceToCenterOfMass() to manually apply a force to a rigid body
+- Method RigidBody::applyLocalTorque() to apply a local-space torque to a rigid body
+- Method RigidBody::getForce() to get the total manually applied force on a rigid body
+- Method RigidBody::getTorque() to get the total manually applied torque on a rigid body
+- Method RigidBody::setIsSleeping() is now public in order to wake up or put to sleep a rigid body
+- A cone limit can now be set to the ball-and-socket joint (this is useful for ragdolls)
+- New scenes have been added to the testbed application (Box Tower, Ragdoll, Rope, Ball And Socket Joint, Bridge, Hinge Joint, Hinge Joint chain, Ball and
+Socket Joint chain, Ball and Socket Joint net, ...)
+- It is now possible to move bodies using the mouse (CTRL + click and drag) in the testbed application
### Removed
- - Method Material::getRollingResistance() has been removed (angular damping has to be used instead of rolling resistance)
- - Method Material::setRollingResistance() has been removed (angular damping has to be used instead of rolling resistance)
+- Method Material::getRollingResistance() has been removed (angular damping has to be used instead of rolling resistance)
+- Method Material::setRollingResistance() has been removed (angular damping has to be used instead of rolling resistance)
### Fixed
@@ -59,7 +142,7 @@
- Issue [#157](https://github.com/DanielChappuis/reactphysics3d/issues/157) with matrix to quaternion conversion has been fixed
- Issue [#184](https://github.com/DanielChappuis/reactphysics3d/issues/184) with update of mass/inertia properties of static bodies
- Issue with the computation of the two friction vectors in the contact solver
-- Issue with the rendering of the capsule collision shape in the Debug Renderer (missing triangle faces)
+- Issue with the rendering of the capsule collision shape in the Debug Renderer (missing triangle faces)
- Issue with wrong linear velocity update computed in RigidBody::setLocalCenterOfMass() method
- Issue with wrong linear velocity update computed in RigidBody::updateLocalCenterOfMassFromColliders() method
- Issue with wrong linear velocity update computed in RigidBody::updateMassPropertiesFromColliders() method
@@ -68,284 +151,293 @@
- The default warning level is not set anymore in CMakeLists.txt file (Issue [#220](https://github.com/DanielChappuis/reactphysics3d/issues/220))
- Issue [#225](https://github.com/DanielChappuis/reactphysics3d/issues/225) with collision not working when setting a body to be static before calling updateMassPropertiesFromColliders()
-## Version 0.8.0 (May 31, 2020)
+## [0.8.0] - 2020-05-31
-Note that this release contains some public API changes. Please read carefully the following changes before upgrading to this new version and
+Note that this release contains some public API changes. Please read carefully the following changes before upgrading to this new version and
do not hesitate to take a look at the user manual.
-### Added
+### Changed
- - It is now possible to change the size of a BoxShape using the BoxShape::setHalfExtents() method
- - It is now possible to change the radius of a SphereShape using the SphereShape::setRadius() method
- - It is now possible to change the height and radius of a CapsuleShape using the CapsuleShape::setHeight() and CapsuleShape::setRadius() methods
- - It is now possible to change the scale of a ConvexMeshShape using the ConvexMeshShape::setScale() method
- - It is now possible to change the scale of a ConcaveMeshShape using the ConcaveMeshShape::setScale() method
- - It is now possible to change the scale of a HeightFieldShape using the HeightFieldShape::setScale() method
- - A method PhysicsWorld::getCollisionBody(uint index) has been added on a physics world to retrieve a given CollisionBody
- - A method PhysicsWorld::getRigidBody(uint index) has been added on a physics world to retrieve a given RigidBody
- - A RigidBody::getLocalCenterOfMass() method has been added to retrieve the current local-space center of mass of a rigid body
- - Add PhysicsCommon class that needs to be instanciated at the beginning and is used as a factory for other objects of the library (see the user manual)
- - The RigidBody::updateLocalCenterOfMassFromColliders() method has been added to compute and set the center of mass of a body using its colliders
- - The RigidBody::updateLocalInertiaTensorFromColliders() method has been added to compute and set the local inertia tensor of a body using its colliders
- - The RigidBody::getLocalInertiaTensor() method has been added to retrieve the local-space inertia tensor of a rigid body
- - The RigidBody::updateMassFromColliders() method has been added to compute and set the mass of a body using its colliders
- - A Material nows has a mass density parameter that can be set using the Material::setMassDensity() method. The mass density is used to compute the mass of a collider when computing the mass of a rigid body
- - A Collider can now be a trigger. This collider will be used to only report collisions with another collider but no collision response will be applied. You can use the Collider::setIsTrigger() method for this.
- - The EventListener class now has a onTrigger() method that is called when a trigger collider is colling with another collider
- - In the EventListener, the onContact() and onTrigger() method now reports the type of event (start, stay, exit) for each contact. This way the user can know whether it's a new contact or not or when two colliders are not in contact anymore
- - A DebugRenderer class has been added in order to display debug info (colliders, AABBs, contacts, ...) in your simulation using graphics primitives (lines, triangles).
- - A RigidBody::applyForceAtLocalPosition() method has been added to apply a force at a given position of the rigid body in local-space
- - A default logger can be instanciated using the PhysicsCommon::createDefaultLogger() method
- - The CMakeLists.txt file of the library has been refactored to use modern CMake. The targets are now exported when you install the library so that you can import the library with the find_package(ReactPhysics3D) function in your own CMakeLists.txt file
- - A Hello World project has been added to show a very simple project that shows how to compile and use the ReactPhysics3D library
+- The CollisionWorld::testCollision() methods do not have the 'categoryMaskBits' parameter anymore
+- The CollisionWorld::testOverlap() methods do not have the 'categoryMaskBits' parameter anymore
+- Many methods in the EventListener class have changed. Check the user manual for more information
+- The way to retrieve contacts has changed. Check the user manual for more information
+- DynamicsWorld and CollisionWorld classes have been merged into a single class called PhysicsWorld
+- The ProxyShape class has been renamed into Collider
+- The Material is now part of the Collider instead of the RigidBody. Therefore, it is now possible to have a RigidBody with multiple
+colliders and a different material for each Collider
+- The Logger has to be set using the PhysicsCommon::setLogger() method
+- The Box::getExtent() method has been renamed to Box::getHalfExtents()
+- An instance of the BoxShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createBoxShape() method
+- An instance of the SphereShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createSphereShape() method
+- An instance of the CapsuleShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createCapsuleShape() method
+- An instance of the ConvexMeshShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createConvexMeshShape() method
+- An instance of the HeightFieldShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createHeightFieldShape() method
+- An instance of the ConcaveMeshShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createConcaveMeshShape() method
+- An instance of the PolyhedronMesh class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createPolyhedronMesh() method
+- An instance of the TriangleMesh class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createTriangleMesh() method
+- The ProxyShape class has been renamed to Collider. The CollisionBody::addCollider(), RigidBody::addCollider() methods have to be used to create and add a collider to a body. Then methods CollisionBody::removeCollider(), RigidBody::removeCollider() need to be used to remove a collider from a body.
+- The RigidBody::addCollider() method (previously addProxyShape() method) does not take a "mass" parameter anymore
+- The RigidBody::setCenterOfMassLocal() method has been renamed to RigidBody::setLocalCenterOfMass()
+- The RigidBody::setInertiaTensorLocal() method has been renamed to RigidBody::setLocalInertiaTensor()
+- Now, the local inertia tensor of a rigid body has to be set using a Vector3 instead of a Matrix3x3. You only need to provide the three diagonal values of the matrix
+- The RigidBody::recomputeMassInformation() method has been renamed to RigidBody::updateMassPropertiesFromColliders.
+- Now, you need to manually call the RigidBody::updateMassPropertiesFromColliders() method after adding colliders to a rigid body to recompute its inertia tensor, center of mass and mass. There are other methods that you can use form that (see the user manual)
+- The RigidBody::applyForce() method has been renamed to RigidBody::applyForceAtWorldPosition()
+- The linear and angular damping function of the rigid bodies has been changed
+- The rendering in the testbed application has been improved
+- Many of the data inside the library have been refactored for better caching and easier parallelization in the future
+- The old Logger class has been renamed to DefaultLogger
+- The Logger class is now an abstract class that you can inherit from in order to receive log events from the library
+- User manual and API documentation have been updated
-### Fixed
+### Added
- - Issues [#125](https://github.com/DanielChappuis/reactphysics3d/issues/125) and [#106](https://github.com/DanielChappuis/reactphysics3d/issues/106) with CMake install of the library have been fixed
- - Issue [#141](https://github.com/DanielChappuis/reactphysics3d/issues/141) with limits of hinge and slider joints has been fixed
- - Issue [#117](https://github.com/DanielChappuis/reactphysics3d/issues/117) in documentation has been fixed
- - Issue [#131](https://github.com/DanielChappuis/reactphysics3d/issues/131) in documentation has been fixed
- - Issue [#139](https://github.com/DanielChappuis/reactphysics3d/issues/139) in API documentation has been fixed
- - Issue [#122](https://github.com/DanielChappuis/reactphysics3d/issues/122) in logger has been fixed
+- It is now possible to change the size of a BoxShape using the BoxShape::setHalfExtents() method
+- It is now possible to change the radius of a SphereShape using the SphereShape::setRadius() method
+- It is now possible to change the height and radius of a CapsuleShape using the CapsuleShape::setHeight() and CapsuleShape::setRadius() methods
+- It is now possible to change the scale of a ConvexMeshShape using the ConvexMeshShape::setScale() method
+- It is now possible to change the scale of a ConcaveMeshShape using the ConcaveMeshShape::setScale() method
+- It is now possible to change the scale of a HeightFieldShape using the HeightFieldShape::setScale() method
+- A method PhysicsWorld::getCollisionBody(uint index) has been added on a physics world to retrieve a given CollisionBody
+- A method PhysicsWorld::getRigidBody(uint index) has been added on a physics world to retrieve a given RigidBody
+- A RigidBody::getLocalCenterOfMass() method has been added to retrieve the current local-space center of mass of a rigid body
+- Add PhysicsCommon class that needs to be instanciated at the beginning and is used as a factory for other objects of the library (see the user manual)
+- The RigidBody::updateLocalCenterOfMassFromColliders() method has been added to compute and set the center of mass of a body using its colliders
+- The RigidBody::updateLocalInertiaTensorFromColliders() method has been added to compute and set the local inertia tensor of a body using its colliders
+- The RigidBody::getLocalInertiaTensor() method has been added to retrieve the local-space inertia tensor of a rigid body
+- The RigidBody::updateMassFromColliders() method has been added to compute and set the mass of a body using its colliders
+- A Material nows has a mass density parameter that can be set using the Material::setMassDensity() method. The mass density is used to compute the mass of a collider when computing the mass of a rigid body
+- A Collider can now be a trigger. This collider will be used to only report collisions with another collider but no collision response will be applied. You can use the Collider::setIsTrigger() method for this.
+- The EventListener class now has a onTrigger() method that is called when a trigger collider is colling with another collider
+- In the EventListener, the onContact() and onTrigger() method now reports the type of event (start, stay, exit) for each contact. This way the user can know whether it's a new contact or not or when two colliders are not in contact anymore
+- A DebugRenderer class has been added in order to display debug info (colliders, AABBs, contacts, ...) in your simulation using graphics primitives (lines, triangles).
+- A RigidBody::applyForceAtLocalPosition() method has been added to apply a force at a given position of the rigid body in local-space
+- A default logger can be instanciated using the PhysicsCommon::createDefaultLogger() method
+- The CMakeLists.txt file of the library has been refactored to use modern CMake. The targets are now exported when you install the library so that you can import the library with the find_package(ReactPhysics3D) function in your own CMakeLists.txt file
+- A Hello World project has been added to show a very simple project that shows how to compile and use the ReactPhysics3D library
-### Changed
+### Removed
- - The CollisionWorld::testCollision() methods do not have the 'categoryMaskBits' parameter anymore
- - The CollisionWorld::testOverlap() methods do not have the 'categoryMaskBits' parameter anymore
- - Many methods in the EventListener class have changed. Check the user manual for more information
- - The way to retrieve contacts has changed. Check the user manual for more information
- - DynamicsWorld and CollisionWorld classes have been merged into a single class called PhysicsWorld
- - The ProxyShape class has been renamed into Collider
- - The Material is now part of the Collider instead of the RigidBody. Therefore, it is now possible to have a RigidBody with multiple
- colliders and a different material for each Collider
- - The Logger has to be set using the PhysicsCommon::setLogger() method
- - The Box::getExtent() method has been renamed to Box::getHalfExtents()
- - An instance of the BoxShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createBoxShape() method
- - An instance of the SphereShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createSphereShape() method
- - An instance of the CapsuleShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createCapsuleShape() method
- - An instance of the ConvexMeshShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createConvexMeshShape() method
- - An instance of the HeightFieldShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createHeightFieldShape() method
- - An instance of the ConcaveMeshShape class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createConcaveMeshShape() method
- - An instance of the PolyhedronMesh class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createPolyhedronMesh() method
- - An instance of the TriangleMesh class cannot be instanciated directly anymore. You need to use the PhysicsCommon::createTriangleMesh() method
- - The ProxyShape class has been renamed to Collider. The CollisionBody::addCollider(), RigidBody::addCollider() methods have to be used to create and add a collider to a body. Then methods CollisionBody::removeCollider(), RigidBody::removeCollider() need to be used to remove a collider from a body.
- - The RigidBody::addCollider() method (previously addProxyShape() method) does not take a "mass" parameter anymore
- - The RigidBody::setCenterOfMassLocal() method has been renamed to RigidBody::setLocalCenterOfMass()
- - The RigidBody::setInertiaTensorLocal() method has been renamed to RigidBody::setLocalInertiaTensor()
- - Now, the local inertia tensor of a rigid body has to be set using a Vector3 instead of a Matrix3x3. You only need to provide the three diagonal values of the matrix
- - The RigidBody::recomputeMassInformation() method has been renamed to RigidBody::updateMassPropertiesFromColliders.
- - Now, you need to manually call the RigidBody::updateMassPropertiesFromColliders() method after adding colliders to a rigid body to recompute its inertia tensor, center of mass and mass. There are other methods that you can use form that (see the user manual)
- - The RigidBody::applyForce() method has been renamed to RigidBody::applyForceAtWorldPosition()
- - The linear and angular damping function of the rigid bodies has been changed
- - The rendering in the testbed application has been improved
- - Many of the data inside the library have been refactored for better caching and easier parallelization in the future
- - The old Logger class has been renamed to DefaultLogger
- - The Logger class is now an abstract class that you can inherit from in order to receive log events from the library
- - User manual and API documentation have been updated
+- The method DynamicsWorld::getContactsList() has been removed. You need to use the EventListener class to retrieve contacts now (see the user manual).
+- The DynamicsWorld::getNbJoints() method has been removed.
+- The EventListener::beginInternalTick() method has been removed (because internal ticks do not exist anymore).
+- The EventListener::endInternalTick() method has been removed (because internal ticks do not exist anymore).
+- The RigidBody::getJointsList() method has been removed.
+- It is not possible anymore to set custom pool and stack frame allocators. Only the base allocator can be customized when creating a PhysicsCommon instance.
+- The RigidBody::setInverseInertiaTensorLocal() method has been removed. The RigidBody::setInertiaTensorLocal() has to be used instead.
+- The RigidBody::getInverseInertiaTensorWorld() method has been removed.
+- The Collider::getMass() method has been removed.
-### Removed
+### Fixed
- - The method DynamicsWorld::getContactsList() has been removed. You need to use the EventListener class to retrieve contacts now (see the user manual).
- - The DynamicsWorld::getNbJoints() method has been removed.
- - The EventListener::beginInternalTick() method has been removed (because internal ticks do not exist anymore).
- - The EventListener::endInternalTick() method has been removed (because internal ticks do not exist anymore).
- - The RigidBody::getJointsList() method has been removed.
- - It is not possible anymore to set custom pool and stack frame allocators. Only the base allocator can be customized when creating a PhysicsCommon instance.
- - The RigidBody::setInverseInertiaTensorLocal() method has been removed. The RigidBody::setInertiaTensorLocal() has to be used instead.
- - The RigidBody::getInverseInertiaTensorWorld() method has been removed.
- - The Collider::getMass() method has been removed.
+- Issues [#125](https://github.com/DanielChappuis/reactphysics3d/issues/125) and [#106](https://github.com/DanielChappuis/reactphysics3d/issues/106) with CMake install of the library have been fixed
+- Issue [#141](https://github.com/DanielChappuis/reactphysics3d/issues/141) with limits of hinge and slider joints has been fixed
+- Issue [#117](https://github.com/DanielChappuis/reactphysics3d/issues/117) in documentation has been fixed
+- Issue [#131](https://github.com/DanielChappuis/reactphysics3d/issues/131) in documentation has been fixed
+- Issue [#139](https://github.com/DanielChappuis/reactphysics3d/issues/139) in API documentation has been fixed
+- Issue [#122](https://github.com/DanielChappuis/reactphysics3d/issues/122) in logger has been fixed
-## Version 0.7.1 (July 01, 2019)
+## [0.7.1] - 2019-07-01
### Added
- - Make possible for the user to get vertices, normals and triangle indices of a ConcaveMeshShape
- - Make possible for the user to get vertices and height values of the HeightFieldShape
+- Make possible for the user to get vertices, normals and triangle indices of a ConcaveMeshShape
+- Make possible for the user to get vertices and height values of the HeightFieldShape
### Fixed
- - Bug [#45](https://github.com/DanielChappuis/reactphysics3d/issues/45) has been fixed.
- - Bug [#50](https://github.com/DanielChappuis/reactphysics3d/issues/50) has been fixed.
- - Bug [#52](https://github.com/DanielChappuis/reactphysics3d/issues/52) has been fixed.
- - Bug [#53](https://github.com/DanielChappuis/reactphysics3d/issues/53) has been fixed.
- - Bug [#54](https://github.com/DanielChappuis/reactphysics3d/issues/54) has been fixed.
- - Bug [#55](https://github.com/DanielChappuis/reactphysics3d/issues/55) has been fixed.
- - Bug [#51](https://github.com/DanielChappuis/reactphysics3d/issues/51) has been fixed.
- - Bug [#60](https://github.com/DanielChappuis/reactphysics3d/issues/60) has been fixed.
- - Bug [#57](https://github.com/DanielChappuis/reactphysics3d/issues/57) has been fixed.
- - Bug [#37](https://github.com/DanielChappuis/reactphysics3d/issues/37) has been fixed.
- - Bug [#62](https://github.com/DanielChappuis/reactphysics3d/issues/62) has been fixed.
- - Bug [#63](https://github.com/DanielChappuis/reactphysics3d/issues/63) has been fixed.
- - Bug [#82](https://github.com/DanielChappuis/reactphysics3d/issues/82) has been fixed.
- - Bug [#85](https://github.com/DanielChappuis/reactphysics3d/issues/85) has been fixed.
- - Bug [#79](https://github.com/DanielChappuis/reactphysics3d/issues/79) has been fixed.
- - Bug: the free() method was called in PoolAllocator instead of release() method of base allocator.
+- Bug [#45](https://github.com/DanielChappuis/reactphysics3d/issues/45) has been fixed.
+- Bug [#50](https://github.com/DanielChappuis/reactphysics3d/issues/50) has been fixed.
+- Bug [#52](https://github.com/DanielChappuis/reactphysics3d/issues/52) has been fixed.
+- Bug [#53](https://github.com/DanielChappuis/reactphysics3d/issues/53) has been fixed.
+- Bug [#54](https://github.com/DanielChappuis/reactphysics3d/issues/54) has been fixed.
+- Bug [#55](https://github.com/DanielChappuis/reactphysics3d/issues/55) has been fixed.
+- Bug [#51](https://github.com/DanielChappuis/reactphysics3d/issues/51) has been fixed.
+- Bug [#60](https://github.com/DanielChappuis/reactphysics3d/issues/60) has been fixed.
+- Bug [#57](https://github.com/DanielChappuis/reactphysics3d/issues/57) has been fixed.
+- Bug [#37](https://github.com/DanielChappuis/reactphysics3d/issues/37) has been fixed.
+- Bug [#62](https://github.com/DanielChappuis/reactphysics3d/issues/62) has been fixed.
+- Bug [#63](https://github.com/DanielChappuis/reactphysics3d/issues/63) has been fixed.
+- Bug [#82](https://github.com/DanielChappuis/reactphysics3d/issues/82) has been fixed.
+- Bug [#85](https://github.com/DanielChappuis/reactphysics3d/issues/85) has been fixed.
+- Bug [#79](https://github.com/DanielChappuis/reactphysics3d/issues/79) has been fixed.
+- Bug: the free() method was called in PoolAllocator instead of release() method of base allocator.
### Removed
- - The CollisionWorld::setCollisionDispatch() method has been removed. In order to use a custom collision
- algorithm, you must not get the collision dispatch object with the
- CollisionWorld::getCollisionDispatch() method and set a collision algorithm to this object.
- - The methods CollisionBody::getProxyShapesList() has been remove. You can now use the
- CollisionBody::getNbProxyShapes() method to know the number of proxy-shapes of a body and the
- CollisionBody::getProxyShape(uint proxyShapeIndex) method to get a given proxy-shape of the body.
- - The CollisionWorld::testAABBOverlap() methods have been removed.
+- The CollisionWorld::setCollisionDispatch() method has been removed. In order to use a custom collision
+algorithm, you must not get the collision dispatch object with the
+CollisionWorld::getCollisionDispatch() method and set a collision algorithm to this object.
+- The methods CollisionBody::getProxyShapesList() has been remove. You can now use the
+CollisionBody::getNbProxyShapes() method to know the number of proxy-shapes of a body and the
+CollisionBody::getProxyShape(uint proxyShapeIndex) method to get a given proxy-shape of the body.
+- The CollisionWorld::testAABBOverlap() methods have been removed.
-## Version 0.7.0 (May 1, 2018)
+## [0.7.0] - 2018-05-01
### Added
-
- - Dedicated Sphere vs Capsule collision detection algorithm.
- - Dedicated Capsule vs Capsule collision detection algorithm.
- - Allow a Rigid Body to have zero mass (for static bodies for instance).
- - Add single frame memory allocator for faster memory allocation in a frame.
- - Make possible to have a profiler per DynamicsWorld instead of a unique one.
- - Make possible to use your own allocation/deallocation methods instead of default malloc/free
- - Make possible to display the AABB of the bodies in the testbed application.
- - Add RigidBody::setInverseLocalInertiaTensor() method to directly set the inverse inertia tensor of a rigid body.
- - More unit tests have been added
+
+- Dedicated Sphere vs Capsule collision detection algorithm.
+- Dedicated Capsule vs Capsule collision detection algorithm.
+- Allow a Rigid Body to have zero mass (for static bodies for instance).
+- Add single frame memory allocator for faster memory allocation in a frame.
+- Make possible to have a profiler per DynamicsWorld instead of a unique one.
+- Make possible to use your own allocation/deallocation methods instead of default malloc/free
+- Make possible to display the AABB of the bodies in the testbed application.
+- Add RigidBody::setInverseLocalInertiaTensor() method to directly set the inverse inertia tensor of a rigid body.
+- More unit tests have been added
### Changed
- - Use single-shot contact manifold computation instead of incremental across several frames.
- - Replace the EPA narrow-phase collision detection with SAT algorithm.
- - The collision detection is now faster and more robust.
- - Code has been refactored such that we do not use STL containers anymore.
- - The way to create a ConvexMeshShape has changed (see the user manual)
- - The vertex indices stride has changed in the TriangleVertexArray for ConvexMeshShape (see the API documentation)
- - The raycasting of a ConvexMeshShape does not use GJK algorithm anymore.
- - The test do detect if a point is inside of a ConvexMeshShape does not use GJK algorithm anymore.
- - A lot of optimizations have been performed and the library is now faster.
- - Release code is now compiled with -O2 compiler optimization level (instead of none)
- - Documentation has been updated
+- Use single-shot contact manifold computation instead of incremental across several frames.
+- Replace the EPA narrow-phase collision detection with SAT algorithm.
+- The collision detection is now faster and more robust.
+- Code has been refactored such that we do not use STL containers anymore.
+- The way to create a ConvexMeshShape has changed (see the user manual)
+- The vertex indices stride has changed in the TriangleVertexArray for ConvexMeshShape (see the API documentation)
+- The raycasting of a ConvexMeshShape does not use GJK algorithm anymore.
+- The test do detect if a point is inside of a ConvexMeshShape does not use GJK algorithm anymore.
+- A lot of optimizations have been performed and the library is now faster.
+- Release code is now compiled with -O2 compiler optimization level (instead of none)
+- Documentation has been updated
### Removed
-
- - Quaternion constructor with Euler angles has been removed. The Quaternion::fromEulerAngles() method should be used instead.
- - Cylinder and Cone collision shapes have been removed. The ConvexMeshShape collision shape should be used instead.
- - The ProxyShape::setLocalScaling() method has been removed. The ConvexMeshShape, ConcaveMeshShape and HeightFieldShape
- collision shapes can be scaled directly.
+
+- Quaternion constructor with Euler angles has been removed. The Quaternion::fromEulerAngles() method should be used instead.
+- Cylinder and Cone collision shapes have been removed. The ConvexMeshShape collision shape should be used instead.
+- The ProxyShape::setLocalScaling() method has been removed. The ConvexMeshShape, ConcaveMeshShape and HeightFieldShape
+collision shapes can be scaled directly.
### Fixed
- - Issues with checkboxes in testbed application were fixed.
- - Fix issue with wrong AABB computation that can cause missing collision in broad-phase
- - Bug [#26](https://github.com/DanielChappuis/reactphysics3d/issues/26) has been fixed.
- - Bug [#30](https://github.com/DanielChappuis/reactphysics3d/issues/30) has been fixed.
- - Bug [#32](https://github.com/DanielChappuis/reactphysics3d/issues/32) has been fixed.
- - Issue [#31](https://github.com/DanielChappuis/reactphysics3d/issues/31) has been fixed.
- - Issue [#34](https://github.com/DanielChappuis/reactphysics3d/issues/34) has been fixed.
- - Issue [#37](https://github.com/DanielChappuis/reactphysics3d/issues/37) has been fixed.
+- Issues with checkboxes in testbed application were fixed.
+- Fix issue with wrong AABB computation that can cause missing collision in broad-phase
+- Bug [#26](https://github.com/DanielChappuis/reactphysics3d/issues/26) has been fixed.
+- Bug [#30](https://github.com/DanielChappuis/reactphysics3d/issues/30) has been fixed.
+- Bug [#32](https://github.com/DanielChappuis/reactphysics3d/issues/32) has been fixed.
+- Issue [#31](https://github.com/DanielChappuis/reactphysics3d/issues/31) has been fixed.
+- Issue [#34](https://github.com/DanielChappuis/reactphysics3d/issues/34) has been fixed.
+- Issue [#37](https://github.com/DanielChappuis/reactphysics3d/issues/37) has been fixed.
-## Version 0.6.0 (April 15, 2016)
+## [0.6.0] - 2016-04-15
### Added
- - Support for static concave triangular mesh collision shape.
- - Support for height field collision shape.
- - Support for rolling resistance.
- - It is now possible to change the local scaling of a collision shape.
- - Add new constructor of ConvexMeshShape that accepts a triangular mesh.
- - It is now easier to use your own narrow-phase collision detection algorithm.
- - The CollisionWorld and DynamicsWorld now automatically destroys bodies and joints that have not been destroyed at the end.
- - New testbed application with demo scenes.
+- Support for static concave triangular mesh collision shape.
+- Support for height field collision shape.
+- Support for rolling resistance.
+- It is now possible to change the local scaling of a collision shape.
+- Add new constructor of ConvexMeshShape that accepts a triangular mesh.
+- It is now easier to use your own narrow-phase collision detection algorithm.
+- The CollisionWorld and DynamicsWorld now automatically destroys bodies and joints that have not been destroyed at the end.
+- New testbed application with demo scenes.
### Changed
- - The DynamicsWorld::update() method now takes the time step for the next simulation step in parameter.
+- The DynamicsWorld::update() method now takes the time step for the next simulation step in parameter.
-## Version 0.5.0 (March 4, 2015)
+## [0.5.0] - 2015-03-04
### Added
- - It is now possible to use multiple collision shapes per body.
- - Ray casting support.
- - Add methods to check if a point is inside a body or a proxy shape.
- - Add collision filtering using collision categories (with bit masks).
- - It is possible to attach user data to a body or a proxy shape.
- - It is now possible to create a quaternion using Euler angles.
- - It now possible to activate of deactivate a body.
- - Differentiation between dynamic, kinematic and static bodies.
- - Gravity can now be changed after the creation of the world.
- - The center of mass and inertia tensor of a body can be set manually (center of mass can be different from body origin).
- - Add a simulation step callback in the EventListener class that is called at each internal physics tick.
- - Add methods to transform points/vectors from/into local-space/world-space coordinates of a body.
- - Add CollisionWorld::testAABBOverlap() method to test overlap between two bodies or two proxy shapes.
- - Add a ray casting example.
- - Add unit tests for ray casting and collision detection.
+- It is now possible to use multiple collision shapes per body.
+- Ray casting support.
+- Add methods to check if a point is inside a body or a proxy shape.
+- Add collision filtering using collision categories (with bit masks).
+- It is possible to attach user data to a body or a proxy shape.
+- It is now possible to create a quaternion using Euler angles.
+- It now possible to activate of deactivate a body.
+- Differentiation between dynamic, kinematic and static bodies.
+- Gravity can now be changed after the creation of the world.
+- The center of mass and inertia tensor of a body can be set manually (center of mass can be different from body origin).
+- Add a simulation step callback in the EventListener class that is called at each internal physics tick.
+- Add methods to transform points/vectors from/into local-space/world-space coordinates of a body.
+- Add CollisionWorld::testAABBOverlap() method to test overlap between two bodies or two proxy shapes.
+- Add a ray casting example.
+- Add unit tests for ray casting and collision detection.
### Changed
- - Replace the Sweep-And-Prune algorithm by a Dynamic AABB Tree for the broad-phase collision detection.
- - The center of mass of a body is now automatically computed from its collision shapes.
- - Use GLFW instead of GLUT/Freeglut for the examples.
+- Replace the Sweep-And-Prune algorithm by a Dynamic AABB Tree for the broad-phase collision detection.
+- The center of mass of a body is now automatically computed from its collision shapes.
+- Use GLFW instead of GLUT/Freeglut for the examples.
### Fixed
- - Fix two issues in the EPA algorithm.
+- Fix two issues in the EPA algorithm.
-## Version 0.4.0 (October 7, 2013)
+## [0.4.0] - 2013-10-07
### Added
- - Add collision shapes (Capsule, Convex Mesh).
- - Add joints (Ball and Socket, Hinge, Slider, Fixed).
- - Add sleeping technique for inactive bodies.
- - Add velocity damping.
- - It is now easier to apply force and torque to a rigid body.
- - Add the EventListener class to allow the user to be notified when some events occur (contacts, …).
- - Add examples for the joints and collision shapes.
- - Make possible to modify the collision margin of some collision shapes.
- - Add a Material class to keep track of the properties of a rigid body (friction coefficient, bounciness, …).
- - Add a hierarchical real-time profiler.
+- Add collision shapes (Capsule, Convex Mesh).
+- Add joints (Ball and Socket, Hinge, Slider, Fixed).
+- Add sleeping technique for inactive bodies.
+- Add velocity damping.
+- It is now easier to apply force and torque to a rigid body.
+- Add the EventListener class to allow the user to be notified when some events occur (contacts, …).
+- Add examples for the joints and collision shapes.
+- Make possible to modify the collision margin of some collision shapes.
+- Add a Material class to keep track of the properties of a rigid body (friction coefficient, bounciness, …).
+- Add a hierarchical real-time profiler.
### Changed
- - Collision shapes now use the internal memory allocator.
- - New internal memory allocator.
+- Collision shapes now use the internal memory allocator.
+- New internal memory allocator.
### Removed
- - Remove the world gravity force from the external force of rigid bodies and allow the user to disable the gravity on a given body.
- - Reduce the allocated memory of the broad-phase when several bodies are removed from the world.
+- Remove the world gravity force from the external force of rigid bodies and allow the user to disable the gravity on a given body.
+- Reduce the allocated memory of the broad-phase when several bodies are removed from the world.
### Fixed
- - Fix issue in the Sweep-And-Prune broad-phase collision detection (thanks to Aleksi Sapon).
- - Fix issue in the contact solver resulting in less jittering.
-
+- Fix issue in the Sweep-And-Prune broad-phase collision detection (thanks to Aleksi Sapon).
+- Fix issue in the contact solver resulting in less jittering.
-## Version 0.3.0
+## [0.3.0] - 2013-03-20
### Added
- - Implementation of a dedicated collision detection algorithm for spheres against spheres instead of using GJK/EPA algorithm.
- - Make possible to use a unique instance of a collision shape for multiple rigid bodies.
- - Create the API documentation using Doxygen.
- - Add Unit tests
+- Implementation of a dedicated collision detection algorithm for spheres against spheres instead of using GJK/EPA algorithm.
+- Make possible to use a unique instance of a collision shape for multiple rigid bodies.
+- Create the API documentation using Doxygen.
+- Add Unit tests
### Changed
- - The Sweep-and-Prune broad-phase collision detection algorithm has been rewritten according to the technique described by Pierre Terdiman at http://www.codercorner.com/SAP.pdf to be much more efficient than the previous naive implementation.
- - The contact solver has been rewritten to use the Sequential Impulses technique from Erin Catto which is mathematically equivalent to the Projected Gauss Seidel technique that was used before. The Sequential Impulses technique is more intuitive.
- - Make GJK/EPA algorithm more robust for spheres.
- - Change the structure of the code for a better separation between the collision detection and the dynamics simulation code.
+- The Sweep-and-Prune broad-phase collision detection algorithm has been rewritten according to the technique described by Pierre Terdiman at http://www.codercorner.com/SAP.pdf to be much more efficient than the previous naive implementation.
+- The contact solver has been rewritten to use the Sequential Impulses technique from Erin Catto which is mathematically equivalent to the Projected Gauss Seidel technique that was used before. The Sequential Impulses technique is more intuitive.
+- Make GJK/EPA algorithm more robust for spheres.
+- Change the structure of the code for a better separation between the collision detection and the dynamics simulation code.
-## Version 0.2.0
+## [0.2.0] - 2013-01-01
### Added
- - Add the GJK/EPA algorithm for convex shapes collision detection
- - Persistent contacts storing between frames
- - Add Sphere, Cylinder and Cone collision shapes
- - Add the Transform class for better handling of position and orientation of rigid bodies
- - It is now possible to approximate the inertia tensor of rigid bodies using the collision shape inertia tensor.
- - The AABB is now computed automatically using the collision shape
- - Add the MemoryPool class to avoid intense dynamic allocation during the simulation
+- Add the GJK/EPA algorithm for convex shapes collision detection
+- Persistent contacts storing between frames
+- Add Sphere, Cylinder and Cone collision shapes
+- Add the Transform class for better handling of position and orientation of rigid bodies
+- It is now possible to approximate the inertia tensor of rigid bodies using the collision shape inertia tensor.
+- The AABB is now computed automatically using the collision shape
+- Add the MemoryPool class to avoid intense dynamic allocation during the simulation
### Changed
- - Simplification of the mathematics library
- - Optimization of the constraint solver
- - ReactPhysics3D is now under the zlib license
-
+- Simplification of the mathematics library
+- Optimization of the constraint solver
+- ReactPhysics3D is now under the zlib license
+
+[0.10.1]: https://github.com/DanielChappuis/reactphysics3d/compare/v0.10.0...v0.10.1
+[0.10.0]: https://github.com/DanielChappuis/reactphysics3d/compare/v0.9.0...v0.10.0
+[0.9.0]: https://github.com/DanielChappuis/reactphysics3d/compare/v0.8.0...v0.9.0
+[0.8.0]: https://github.com/DanielChappuis/reactphysics3d/compare/v0.7.1...v0.8.0
+[0.7.1]: https://github.com/DanielChappuis/reactphysics3d/compare/v0.7.0...v0.7.1
+[0.7.0]: https://github.com/DanielChappuis/reactphysics3d/compare/v0.6.0...v0.7.0
+[0.6.0]: https://github.com/DanielChappuis/reactphysics3d/compare/v0.5.0...v0.6.0
+[0.5.0]: https://github.com/DanielChappuis/reactphysics3d/compare/v0.4.0...v0.5.0
+[0.4.0]: https://github.com/DanielChappuis/reactphysics3d/compare/v0.3.0...v0.4.0
+[0.3.0]: https://github.com/DanielChappuis/reactphysics3d/releases/tag/v0.3.0
diff --git a/ext/reactphysics3d/FUNDING.yml b/ext/reactphysics3d/FUNDING.yml
new file mode 100644
index 000000000..7ae73106d
--- /dev/null
+++ b/ext/reactphysics3d/FUNDING.yml
@@ -0,0 +1,3 @@
+github: [DanielChappuis]
+custom: ["https://reactphysics3d.com/donate.html"]
+
diff --git a/ext/reactphysics3d/LICENSE b/ext/reactphysics3d/LICENSE
index c2d4eafed..7c2f2a9b8 100644
--- a/ext/reactphysics3d/LICENSE
+++ b/ext/reactphysics3d/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2010-2022 Daniel Chappuis http://www.reactphysics3d.com
+Copyright (c) 2010-2024 Daniel Chappuis http://www.reactphysics3d.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
diff --git a/ext/reactphysics3d/README.md b/ext/reactphysics3d/README.md
index 5a1fdba85..f56ee9a6c 100644
--- a/ext/reactphysics3d/README.md
+++ b/ext/reactphysics3d/README.md
@@ -22,7 +22,7 @@
-## :dart: Features
+## Features
- Rigid body dynamics
- Discrete collision detection
@@ -44,37 +44,42 @@
- Logs
- Unit tests
-## :book: Documentation
+## Documentation
You can find the user manual and the Doxygen API documentation here.
-## :information_source: Branches
+## Branches
The "master" branch always contains the last released version of the library and some possible hot fixes. This is the most stable version. On the other side,
the "develop" branch is used for development. This branch is frequently updated and can be quite unstable. Therefore, if you want to use the library in
your application, it is recommended to checkout the "master" branch.
-## :question: Questions
+## Questions
If you have any questions about the library and how to use it, you should use Github Discussions to read previous questions and answers or to ask new questions. If you want, you can also share your project there if you are using the ReactPhysics3D library.
-## :warning: Issues
+## Questions/Discussions
+
+You can use the Discussions section to ask your questions or answer questions from other users of the library. Please, do not open a new issue to ask a question.
+
+## Issues
If you find any issue with the library, you can report it on the issue tracker here.
+Please, do not open a new issue to ask a question. Use the Discussions section for your questions.
-## :man: Author
+## Author
The ReactPhysics3D library has been created and is maintained by Daniel Chappuis.
-## :copyright: License
+## License
The ReactPhysics3D library is released under the open-source ZLib license.
-## :+1: Sponsorship
+## Sponsorship
If you are using this library and want to support its development, you can sponsor it here.
-## :clap: Credits
+## Credits
Thanks a lot to Erin Catto, Dirk Gregorius, Erwin Coumans, Pierre Terdiman and Christer Ericson for their amazing GDC presentations,
their physics engines, their books or articles and their contributions on many physics engine forums.
diff --git a/ext/reactphysics3d/VERSION b/ext/reactphysics3d/VERSION
index ac39a106c..571215736 100644
--- a/ext/reactphysics3d/VERSION
+++ b/ext/reactphysics3d/VERSION
@@ -1 +1 @@
-0.9.0
+0.10.1
diff --git a/ext/reactphysics3d/include/reactphysics3d/body/CollisionBody.h b/ext/reactphysics3d/include/reactphysics3d/body/Body.h
similarity index 88%
rename from ext/reactphysics3d/include/reactphysics3d/body/CollisionBody.h
rename to ext/reactphysics3d/include/reactphysics3d/body/Body.h
index 5dd6a879d..3f5014204 100644
--- a/ext/reactphysics3d/include/reactphysics3d/body/CollisionBody.h
+++ b/ext/reactphysics3d/include/reactphysics3d/body/Body.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -45,12 +45,11 @@ class DefaultPoolAllocator;
class Profiler;
class Logger;
-// Class CollisionBody
+// Class Body
/**
- * This class represents a body that is able to collide with others
- * bodies.
+ * This class represents a body
*/
-class CollisionBody {
+class Body {
protected :
@@ -62,6 +61,9 @@ class CollisionBody {
/// Reference to the world the body belongs to
PhysicsWorld& mWorld;
+ /// Determines if debug information is computed for this body
+ bool mIsDebugEnabled;
+
#ifdef IS_RP3D_PROFILING_ENABLED
/// Pointer to the profiler
@@ -81,21 +83,24 @@ class CollisionBody {
/// (as if the body has moved).
void askForBroadPhaseCollisionCheck() const;
+ /// Update whether the body has at least one simulation provider
+ void updateHasSimulationCollider();
+
public :
// -------------------- Methods -------------------- //
/// Constructor
- CollisionBody(PhysicsWorld& world, Entity entity);
+ Body(PhysicsWorld& world, Entity entity);
/// Destructor
- virtual ~CollisionBody();
+ virtual ~Body();
/// Deleted copy-constructor
- CollisionBody(const CollisionBody& body) = delete;
+ Body(const Body& body) = delete;
/// Deleted assignment operator
- CollisionBody& operator=(const CollisionBody& body) = delete;
+ Body& operator=(const Body& body) = delete;
/// Return the corresponding entity of the body
Entity getEntity() const;
@@ -157,6 +162,12 @@ class CollisionBody {
/// Return the body local-space coordinates of a vector given in the world-space coordinates
Vector3 getLocalVector(const Vector3& worldVector) const;
+ /// Set whether or not debug lines are computed for this body
+ void setIsDebugEnabled(bool enabled);
+
+ /// Return true if debug lines should be computed for this body
+ bool isDebugEnabled() const;
+
#ifdef IS_RP3D_PROFILING_ENABLED
/// Set the profiler
@@ -178,7 +189,7 @@ class CollisionBody {
* @param worldAABB The AABB (in world-space coordinates) that will be used to test overlap
* @return True if the given AABB overlaps with the AABB of the collision body
*/
-RP3D_FORCE_INLINE bool CollisionBody::testAABBOverlap(const AABB& worldAABB) const {
+RP3D_FORCE_INLINE bool Body::testAABBOverlap(const AABB& worldAABB) const {
return worldAABB.testCollision(getAABB());
}
@@ -186,19 +197,10 @@ RP3D_FORCE_INLINE bool CollisionBody::testAABBOverlap(const AABB& worldAABB) con
/**
* @return The entity of the body
*/
-RP3D_FORCE_INLINE Entity CollisionBody::getEntity() const {
+RP3D_FORCE_INLINE Entity Body::getEntity() const {
return mEntity;
}
-#ifdef IS_RP3D_PROFILING_ENABLED
-
-// Set the profiler
-RP3D_FORCE_INLINE void CollisionBody::setProfiler(Profiler* profiler) {
- mProfiler = profiler;
-}
-
-#endif
-
}
#endif
diff --git a/ext/reactphysics3d/include/reactphysics3d/body/RigidBody.h b/ext/reactphysics3d/include/reactphysics3d/body/RigidBody.h
index 2c3971669..8133af9fa 100644
--- a/ext/reactphysics3d/include/reactphysics3d/body/RigidBody.h
+++ b/ext/reactphysics3d/include/reactphysics3d/body/RigidBody.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -28,7 +28,7 @@
// Libraries
#include
-#include
+#include
#include
/// Namespace reactphysics3d
@@ -45,16 +45,22 @@ enum class BodyType;
* This class represents a rigid body of the physics
* engine. A rigid body is a non-deformable body that
* has a constant mass. This class inherits from the
- * CollisionBody class.
+ * Body class.
*/
-class RigidBody : public CollisionBody {
+class RigidBody : public Body {
protected :
// -------------------- Methods -------------------- //
- /// Update whether the current overlapping pairs where this body is involed are active or not
- void resetOverlappingPairs();
+ /// Awake the disabled neighbor bodies
+ void awakeNeighborDisabledBodies();
+
+ /// Remove the disabled overlapping pairs
+ void enableOverlappingPairs();
+
+ /// Disable the overlapping pairs if both bodies of the pair are disabled (sleeping or static)
+ void checkForDisabledOverlappingPairs();
/// Compute and return the local-space center of mass of the body using its colliders
Vector3 computeCenterOfMass() const;
@@ -219,13 +225,6 @@ class RigidBody : public CollisionBody {
/// Remove a collider from the body
virtual void removeCollider(Collider* collider) override;
-#ifdef IS_RP3D_PROFILING_ENABLED
-
- /// Set the profiler
- void setProfiler(Profiler* profiler) override;
-
-#endif
-
// -------------------- Friendship -------------------- //
friend class PhysicsWorld;
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/Collider.h b/ext/reactphysics3d/include/reactphysics3d/collision/Collider.h
index 425afb078..6543e9e5a 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/Collider.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/Collider.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -27,7 +27,7 @@
#define REACTPHYSICS3D_COLLIDER_H
// Libraries
-#include
+#include
#include
#include
#include
@@ -39,7 +39,7 @@ class MemoryManager;
// Class Collider
/**
- * A collider has a collision shape (box, sphere, capsule, ...) and is attached to a CollisionBody or
+ * A collider has a collision shape (box, sphere, capsule, ...) and is attached to a
* RigidBody. A body can have multiple colliders. The collider also have a mass value and a Material
* with many physics parameters like friction or bounciness. When you create a body, you need to attach
* at least one collider to it if you want that body to be able to collide in the physics world.
@@ -57,7 +57,7 @@ class Collider {
Entity mEntity;
/// Pointer to the parent body
- CollisionBody* mBody;
+ Body* mBody;
/// Pointer to user data
void* mUserData;
@@ -80,7 +80,7 @@ class Collider {
// -------------------- Methods -------------------- //
/// Constructor
- Collider(Entity entity, CollisionBody* body, MemoryManager& memoryManager);
+ Collider(Entity entity, Body* body, MemoryManager& memoryManager);
/// Destructor
virtual ~Collider();
@@ -101,7 +101,7 @@ class Collider {
const CollisionShape* getCollisionShape() const;
/// Return the parent body
- CollisionBody* getBody() const;
+ Body* getBody() const;
/// Return a pointer to the user data attached to this body
void* getUserData() const;
@@ -157,6 +157,18 @@ class Collider {
/// Set whether the collider is a trigger
void setIsTrigger(bool isTrigger) const;
+ /// Return true if the collider can generate contacts for the simulation of the associated body
+ bool getIsSimulationCollider() const;
+
+ /// Set whether the collider can generate contacts for the simulation of the associated body
+ void setIsSimulationCollider(bool isSimulationCollider) const;
+
+ /// Return true if the collider will be part of results of queries on the PhysicsWorld
+ bool getIsWorldQueryCollider() const;
+
+ /// Set whether the collider will be part of results of queries on the PhysicsWorld
+ void setIsWorldQueryCollider(bool isWorldQueryCollider) const;
+
#ifdef IS_RP3D_PROFILING_ENABLED
/// Set the profiler
@@ -167,7 +179,7 @@ class Collider {
// -------------------- Friendship -------------------- //
friend class OverlappingPair;
- friend class CollisionBody;
+ friend class Body;
friend class RigidBody;
friend class BroadPhaseAlgorithm;
friend class DynamicAABBTree;
@@ -193,7 +205,7 @@ RP3D_FORCE_INLINE Entity Collider::getEntity() const {
/**
* @return Pointer to the parent body
*/
-RP3D_FORCE_INLINE CollisionBody* Collider::getBody() const {
+RP3D_FORCE_INLINE Body* Collider::getBody() const {
return mBody;
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/CollisionCallback.h b/ext/reactphysics3d/include/reactphysics3d/collision/CollisionCallback.h
index 1f9b13c43..14d75cedc 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/CollisionCallback.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/CollisionCallback.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -37,7 +37,7 @@ namespace reactphysics3d {
// Declarations
class OverlappingPair;
class ContactManifold;
-class CollisionBody;
+class Body;
class Collider;
class MemoryManager;
@@ -185,13 +185,13 @@ class CollisionCallback {
/**
* @return A pointer to the first colliding body of the pair
*/
- CollisionBody* getBody1() const;
+ Body* getBody1() const;
/// Return a pointer to the second body in contact
/**
* @return A pointer to the second colliding body of the pair
*/
- CollisionBody* getBody2() const;
+ Body* getBody2() const;
/// Return a pointer to the first collider in contact (in body 1)
/**
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/ContactManifold.h b/ext/reactphysics3d/include/reactphysics3d/collision/ContactManifold.h
index c55c20763..c679eac7e 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/ContactManifold.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/ContactManifold.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -36,7 +36,7 @@ namespace reactphysics3d {
class ContactManifold;
struct ContactManifoldInfo;
struct ContactPointInfo;
-class CollisionBody;
+class Body;
class ContactPoint;
class DefaultPoolAllocator;
@@ -110,7 +110,7 @@ class ContactManifold {
friend class PhysicsWorld;
friend class Island;
- friend class CollisionBody;
+ friend class Body;
friend class ContactManifoldSet;
friend class ContactSolverSystem;
friend class CollisionDetectionSystem;
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/ContactManifoldInfo.h b/ext/reactphysics3d/include/reactphysics3d/collision/ContactManifoldInfo.h
index 5a15b3eca..7acd23b23 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/ContactManifoldInfo.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/ContactManifoldInfo.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/ContactPair.h b/ext/reactphysics3d/include/reactphysics3d/collision/ContactPair.h
index 81cd991e3..2f618f6dd 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/ContactPair.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/ContactPair.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/ContactPointInfo.h b/ext/reactphysics3d/include/reactphysics3d/collision/ContactPointInfo.h
index 779d35fef..23f7a9656 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/ContactPointInfo.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/ContactPointInfo.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -34,7 +34,7 @@
namespace reactphysics3d {
// Declarations
-class CollisionBody;
+class Body;
// Structure ContactPointInfo
/**
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/PolyhedronMesh.h b/ext/reactphysics3d/include/reactphysics3d/collision/ConvexMesh.h
similarity index 51%
rename from ext/reactphysics3d/include/reactphysics3d/collision/PolyhedronMesh.h
rename to ext/reactphysics3d/include/reactphysics3d/collision/ConvexMesh.h
index c06cc2301..7633d4aa8 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/PolyhedronMesh.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/ConvexMesh.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -23,12 +23,13 @@
* *
********************************************************************************/
-#ifndef REACTPHYSICS3D_POLYHEDRON_MESH_H
-#define REACTPHYSICS3D_POLYHEDRON_MESH_H
+#ifndef REACTPHYSICS3D_CONVEX_MESH_H
+#define REACTPHYSICS3D_CONVEX_MESH_H
// Libraries
#include
#include
+#include
#include "HalfEdgeStructure.h"
namespace reactphysics3d {
@@ -36,13 +37,14 @@ namespace reactphysics3d {
// Declarations
class DefaultAllocator;
class PolygonVertexArray;
+struct Message;
-// Class PolyhedronMesh
+// Class ConvexMesh
/**
- * This class describes a polyhedron mesh made of faces and vertices.
- * The faces do not have to be triangles.
+ * This class describes a convex mesh made of faces and vertices.
+ * The faces are made of polygons (not only triangles).
*/
-class PolyhedronMesh {
+class ConvexMesh {
private:
@@ -51,67 +53,78 @@ class PolyhedronMesh {
/// Reference to the memory allocator
MemoryAllocator& mMemoryAllocator;
- /// Pointer the the polygon vertex array with vertices and faces
- /// of the mesh
- PolygonVertexArray* mPolygonVertexArray;
-
/// Half-edge structure of the mesh
HalfEdgeStructure mHalfEdgeStructure;
+ /// All the vertices of the mesh
+ Array mVertices;
+
/// Array with the face normals
- Vector3* mFacesNormals;
+ Array mFacesNormals;
- /// Centroid of the polyhedron
+ /// Centroid of the mesh
Vector3 mCentroid;
+ /// Mesh minimum/maximum bounds in the three local x, y and z directions
+ AABB mBounds;
+
+ /// Volume of the mesh
+ decimal mVolume;
+
// -------------------- Methods -------------------- //
/// Constructor
- PolyhedronMesh(PolygonVertexArray* polygonVertexArray, MemoryAllocator& allocator);
+ ConvexMesh(MemoryAllocator& allocator);
+
+ /// Initialize a mesh and returns errors if any
+ bool init(const PolygonVertexArray& polygonVertexArray, std::vector& errors);
+
+ /// Copy the vertices into the mesh
+ bool copyVertices(const PolygonVertexArray& polygonVertexArray, std::vector& errors);
/// Create the half-edge structure of the mesh
- bool createHalfEdgeStructure();
+ bool createHalfEdgeStructure(const PolygonVertexArray& polygonVertexArray, std::vector& errors);
/// Compute the faces normals
- void computeFacesNormals();
+ bool computeFacesNormals(std::vector& errors);
- /// Compute the centroid of the polyhedron
- void computeCentroid() ;
+ /// Compute and return the face normal (not normalized)
+ Vector3 computeFaceNormal(uint32 faceIndex) const;
- /// Compute and return the area of a face
- decimal getFaceArea(uint32 faceIndex) const;
-
- /// Static factory method to create a polyhedron mesh
- static PolyhedronMesh* create(PolygonVertexArray* polygonVertexArray, MemoryAllocator& polyhedronMeshAllocator, MemoryAllocator& dataAllocator);
+ /// Compute the volume of the mesh
+ void computeVolume();
public:
// -------------------- Methods -------------------- //
- /// Destructor
- ~PolyhedronMesh();
-
/// Return the number of vertices
uint32 getNbVertices() const;
/// Return a vertex
- Vector3 getVertex(uint32 index) const;
+ const Vector3& getVertex(uint32 index) const;
/// Return the number of faces
uint32 getNbFaces() const;
/// Return a face normal
- Vector3 getFaceNormal(uint32 faceIndex) const;
+ const Vector3& getFaceNormal(uint32 faceIndex) const;
/// Return the half-edge structure of the mesh
const HalfEdgeStructure& getHalfEdgeStructure() const;
- /// Return the centroid of the polyhedron
- Vector3 getCentroid() const;
+ /// Return the centroid of the mesh
+ const Vector3& getCentroid() const;
+
+ /// Return the bounds of the mesh in the x,y,z direction
+ const AABB& getBounds() const;
- /// Compute and return the volume of the polyhedron
+ /// Compute and return the volume of the mesh
decimal getVolume() const;
+ /// Return the local inertia tensor of the mesh
+ Vector3 getLocalInertiaTensor(decimal mass, Vector3 scale) const;
+
// ---------- Friendship ---------- //
friend class PhysicsCommon;
@@ -121,15 +134,25 @@ class PolyhedronMesh {
/**
* @return The number of vertices in the mesh
*/
-RP3D_FORCE_INLINE uint32 PolyhedronMesh::getNbVertices() const {
- return mHalfEdgeStructure.getNbVertices();
+RP3D_FORCE_INLINE uint32 ConvexMesh::getNbVertices() const {
+ return mVertices.size();
+}
+
+/// Return a vertex
+/**
+ * @param index Index of a given vertex in the mesh
+ * @return The coordinates of a given vertex in the mesh
+ */
+RP3D_FORCE_INLINE const Vector3& ConvexMesh::getVertex(uint32 index) const {
+ assert(index < mVertices.size());
+ return mVertices[index];
}
// Return the number of faces
/**
* @return The number of faces in the mesh
*/
-RP3D_FORCE_INLINE uint32 PolyhedronMesh::getNbFaces() const {
+RP3D_FORCE_INLINE uint32 ConvexMesh::getNbFaces() const {
return mHalfEdgeStructure.getNbFaces();
}
@@ -138,7 +161,7 @@ RP3D_FORCE_INLINE uint32 PolyhedronMesh::getNbFaces() const {
* @param faceIndex The index of a given face of the mesh
* @return The normal vector of a given face of the mesh
*/
-RP3D_FORCE_INLINE Vector3 PolyhedronMesh::getFaceNormal(uint32 faceIndex) const {
+RP3D_FORCE_INLINE const Vector3& ConvexMesh::getFaceNormal(uint32 faceIndex) const {
assert(faceIndex < mHalfEdgeStructure.getNbFaces());
return mFacesNormals[faceIndex];
}
@@ -147,7 +170,7 @@ RP3D_FORCE_INLINE Vector3 PolyhedronMesh::getFaceNormal(uint32 faceIndex) const
/**
* @return The Half-Edge structure of the mesh
*/
-RP3D_FORCE_INLINE const HalfEdgeStructure& PolyhedronMesh::getHalfEdgeStructure() const {
+RP3D_FORCE_INLINE const HalfEdgeStructure& ConvexMesh::getHalfEdgeStructure() const {
return mHalfEdgeStructure;
}
@@ -155,10 +178,38 @@ RP3D_FORCE_INLINE const HalfEdgeStructure& PolyhedronMesh::getHalfEdgeStructure(
/**
* @return The centroid of the mesh
*/
-RP3D_FORCE_INLINE Vector3 PolyhedronMesh::getCentroid() const {
+RP3D_FORCE_INLINE const Vector3& ConvexMesh::getCentroid() const {
return mCentroid;
}
+// Return the volume of the convex mesh
+/**
+ * @return The volume of the mesh
+ */
+RP3D_FORCE_INLINE decimal ConvexMesh::getVolume() const {
+ return mVolume;
+}
+
+// Return the local inertia tensor of the mesh
+/// The local inertia tensor of the convex mesh is approximated using the inertia tensor
+/// of its bounding box.
+/**
+* @param mass Mass to use to compute the inertia tensor of the collision shape
+* @param scale Scaling factor for the mesh
+*/
+RP3D_FORCE_INLINE Vector3 ConvexMesh::getLocalInertiaTensor(decimal mass, Vector3 scale) const {
+
+ // TODO: We should compute a much better inertia tensor here (not using a box)
+
+ const decimal factor = (decimal(1.0) / decimal(3.0)) * mass;
+ const Vector3 realExtent = decimal(0.5) * scale * (mBounds.getMax() - mBounds.getMin());
+ assert(realExtent.x > 0 && realExtent.y > 0 && realExtent.z > 0);
+ const decimal xSquare = realExtent.x * realExtent.x;
+ const decimal ySquare = realExtent.y * realExtent.y;
+ const decimal zSquare = realExtent.z * realExtent.z;
+ return Vector3(factor * (ySquare + zSquare), factor * (xSquare + zSquare), factor * (xSquare + ySquare));
+}
+
}
#endif
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/HalfEdgeStructure.h b/ext/reactphysics3d/include/reactphysics3d/collision/HalfEdgeStructure.h
index 06f110fe1..9aa8f7d23 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/HalfEdgeStructure.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/HalfEdgeStructure.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -34,8 +34,7 @@ namespace reactphysics3d {
// Class HalfEdgeStructure
/**
* This class describes a polyhedron mesh made of faces and vertices.
- * The faces do not have to be triangle. Note that the half-edge structure
- * is only valid if the mesh is closed (each edge has two adjacent faces).
+ * The faces do not have to be triangle.
*/
class HalfEdgeStructure {
@@ -60,7 +59,7 @@ class HalfEdgeStructure {
Face(MemoryAllocator& allocator) : edgeIndex(0), faceVertices(allocator) {}
/// Constructor
- Face(Array vertices) : edgeIndex(0), faceVertices(vertices) {}
+ Face(const Array& vertices) : edgeIndex(0), faceVertices(vertices) {}
};
/// Vertex
@@ -96,14 +95,14 @@ class HalfEdgeStructure {
/// Destructor
~HalfEdgeStructure() = default;
- /// Initialize the structure (when all vertices and faces have been added)
- void init();
+ /// Compute the half-edges (when all vertices and faces have been added)
+ void computeHalfEdges();
/// Add a vertex
uint32 addVertex(uint32 vertexPointIndex);
/// Add a face
- void addFace(Array faceVertices);
+ void addFace(const Array& faceVertices);
/// Return the number of faces
uint32 getNbFaces() const;
@@ -123,11 +122,17 @@ class HalfEdgeStructure {
/// Return a given vertex
const Vertex& getVertex(uint32 index) const;
+ /// Reserve some memory for vertices, faces and edges
+ void reserve(uint32 facesCapacity, uint32 verticesCapacity, uint32 edgesCapacity);
+
+ /// Return a string representation of the half-edge structure
+ std::string to_string() const;
+
};
// Add a vertex
/**
- * @param vertexPointIndex Index of the vertex in the vertex data array
+ * @param vertexPointIndex Index of the vertex in the external user vertex data array
*/
RP3D_FORCE_INLINE uint32 HalfEdgeStructure::addVertex(uint32 vertexPointIndex) {
Vertex vertex(vertexPointIndex);
@@ -138,13 +143,12 @@ RP3D_FORCE_INLINE uint32 HalfEdgeStructure::addVertex(uint32 vertexPointIndex) {
// Add a face
/**
* @param faceVertices Array of the vertices in a face (ordered in CCW order as seen from outside
- * the polyhedron
+ * the polyhedron). The indices are the internal indices of the vertices inside the HalfEdgeStructure.
*/
-RP3D_FORCE_INLINE void HalfEdgeStructure::addFace(Array faceVertices) {
+RP3D_FORCE_INLINE void HalfEdgeStructure::addFace(const Array& faceVertices) {
// Create a new face
- Face face(faceVertices);
- mFaces.add(face);
+ mFaces.add(Face(faceVertices));
}
// Return the number of faces
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/HeightField.h b/ext/reactphysics3d/include/reactphysics3d/collision/HeightField.h
new file mode 100644
index 000000000..6ba859f0e
--- /dev/null
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/HeightField.h
@@ -0,0 +1,273 @@
+/********************************************************************************
+* ReactPhysics3D physics library, http://www.reactphysics3d.com *
+* Copyright (c) 2010-2024 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 REACTPHYSICS3D_HEIGHT_FIELD_H
+#define REACTPHYSICS3D_HEIGHT_FIELD_H
+
+// Libraries
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace reactphysics3d {
+
+// Declarations
+struct Message;
+
+// Class HeightField
+/**
+ * This class represents a static height field that can be used to represent
+ * a terrain. The height field is made of a grid with rows and columns with a
+ * height value at each grid point. Note that the height values are copied into the shape.
+ * The height values can be of type integer, float or double.
+ * Note that the HeightField will be re-centered based on its AABB. It means
+ * that for instance, if the minimum height value is -200 and the maximum value is 400, the final
+ * minimum height of the field in the simulation will be -300 and the maximum height will be 300.
+ */
+class HeightField {
+
+ public:
+
+ /// Data type for the height data of the height field
+ enum class HeightDataType {HEIGHT_FLOAT_TYPE, HEIGHT_DOUBLE_TYPE, HEIGHT_INT_TYPE};
+
+ protected:
+
+ // -------------------- Attributes -------------------- //
+
+ /// Reference to a memory allocator
+ MemoryAllocator& mAllocator;
+
+ /// Number of columns in the grid of the height field (along the local x direction)
+ uint32 mNbColumns;
+
+ /// Number of rows in the grid of the height field (along the local z direction)
+ uint32 mNbRows;
+
+ /// Height field width
+ decimal mWidth;
+
+ /// Height field length
+ decimal mLength;
+
+ /// Minimum height value of the height field
+ decimal mMinHeight;
+
+ /// Maximum height value of the height field
+ decimal mMaxHeight;
+
+ /// Height origin
+ decimal mHeightOrigin;
+
+ /// Height values scale for height field with integer height values
+ decimal mIntegerHeightScale;
+
+ /// Data type of the height values
+ HeightDataType mHeightDataType;
+
+ /// Array of data with all the height values of the height field
+ Array mHeightFieldData;
+
+ /// Local bounds of the height field
+ AABB mBounds;
+
+ /// Reference to the half-edge structure
+ HalfEdgeStructure& mTriangleHalfEdgeStructure;
+
+#ifdef IS_RP3D_PROFILING_ENABLED
+
+ /// Pointer to the profiler
+ Profiler* mProfiler;
+
+#endif
+
+ // -------------------- Methods -------------------- //
+
+ /// Constructor
+ HeightField(MemoryAllocator& allocator, HalfEdgeStructure& triangleHalfEdgeStructure);
+
+ bool init(int nbGridColumns, int nbGridRows, const void* heightFieldData,
+ HeightDataType dataType, std::vector& messages, decimal integerHeightScale = 1.0f);
+
+ /// Copy the data from the user into the height-field array
+ void copyData(const void* heightFieldData);
+
+ /// Raycast a single triangle of the height-field
+ bool raycastTriangle(const Ray& ray, const Vector3& p1, const Vector3& p2, const Vector3& p3, uint32 shapeId,
+ Collider* collider, RaycastInfo& raycastInfo, decimal& smallestHitFraction,
+ TriangleRaycastSide testSide, MemoryAllocator& allocator) const;
+
+ /// Raycast method with feedback information
+ bool raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, TriangleRaycastSide testSide,
+ MemoryAllocator& allocator) const;
+
+ /// Compute the min/max grid coords corresponding to the intersection of the AABB of the height field and the AABB to collide
+ void computeMinMaxGridCoordinates(uint32* minCoords, uint32* maxCoords, const AABB& aabbToCollide) const;
+
+ /// Compute the shape Id for a given triangle
+ uint32 computeTriangleShapeId(uint32 iIndex, uint32 jIndex, uint32 secondTriangleIncrement) const;
+
+ /// Compute the first grid cell of the heightfield intersected by a ray
+ bool computeEnteringRayGridCoordinates(const Ray& ray, int32& i, int32& j, Vector3& outHitPoint) const;
+
+ /// Use a callback method on all triangles of the concave shape inside a given AABB
+ void computeOverlappingTriangles(const AABB& aabb, Array& triangleVertices,
+ Array& triangleVerticesNormals,
+ Array& shapeIds, const Vector3& scale) const;
+
+ public:
+
+ /// Deleted copy-constructor
+ HeightField(const HeightField& heightField) = delete;
+
+ /// Deleted assignment operator
+ HeightField& operator=(const HeightField& heightField) = delete;
+
+ /// Return the number of rows in the height-field (along the local x direction)
+ uint32 getNbRows() const;
+
+ /// Return the number of columns in the height-field (along the local z direction)
+ uint32 getNbColumns() const;
+
+ /// Return the minimum height value of the height-field
+ decimal getMinHeight() const;
+
+ /// Return the maximum height value of the height-field
+ decimal getMaxHeight() const;
+
+ /// Return the integer height scale
+ decimal getIntegerHeightScale() const;
+
+ /// Return the vertex (local-coordinates) of the height-field at a given (x,y) position
+ Vector3 getVertexAt(uint32 x, uint32 y) const;
+
+ /// Return the height value of a given (x,y) point in the height-field (in local-space)
+ decimal getHeightAt(uint32 x, uint32 y) const;
+
+ /// Return the type of height value in the height-field
+ HeightDataType getHeightDataType() const;
+
+ /// Return the minimum bounds of the height-field in the x,y,z direction
+ const AABB& getBounds() const;
+
+ /// Return the string representation of the shape
+ std::string to_string() const;
+
+#ifdef IS_RP3D_PROFILING_ENABLED
+
+ /// Set the profiler
+ void setProfiler(Profiler* profiler);
+
+#endif
+
+ // ---------- Friendship ----------- //
+
+ friend class ConvexTriangleAABBOverlapCallback;
+ friend class ConcaveMeshRaycastCallback;
+ friend class HeightFieldShape;
+ friend class PhysicsCommon;
+};
+
+// Return the minimum bounds of the height-field in the x,y,z direction
+/**
+ * @return The three mimimum bounds of the height-field in the x,y,z direction
+ */
+RP3D_FORCE_INLINE const AABB& HeightField::getBounds() const {
+ return mBounds;
+}
+
+// Return the number of rows in the height-field (along the local x direction)
+/**
+ * @return The number of rows of the grid (along x direction)
+ */
+RP3D_FORCE_INLINE uint32 HeightField::getNbRows() const {
+ return mNbRows;
+}
+
+// Return the number of columns in the height-field (along the local z direction)
+/**
+ * @return The number of columns of the grid (along z direction)
+ */
+RP3D_FORCE_INLINE uint32 HeightField::getNbColumns() const {
+ return mNbColumns;
+}
+
+// Return the minimum height value of the height-field
+/**
+ * @return The mimimum height value of the height-field
+ */
+RP3D_FORCE_INLINE decimal HeightField::getMinHeight() const {
+ return mMinHeight;
+}
+
+// Return the maximum height value of the height-field
+/**
+ * @return The maximum height value of the height-field
+ */
+RP3D_FORCE_INLINE decimal HeightField::getMaxHeight() const {
+ return mMaxHeight;
+}
+
+// Return the integer height scale
+/**
+ * @return The integer height scale
+ */
+RP3D_FORCE_INLINE decimal HeightField::getIntegerHeightScale() const {
+ return mIntegerHeightScale;
+}
+
+// Return the type of height value in the height-field
+RP3D_FORCE_INLINE HeightField::HeightDataType HeightField::getHeightDataType() const {
+ return mHeightDataType;
+}
+
+// Return the height value of a given (x,y) point in the height-field
+RP3D_FORCE_INLINE decimal HeightField::getHeightAt(uint32 x, uint32 y) const {
+ assert(x < mNbColumns);
+ assert(y < mNbRows);
+ return mHeightFieldData[y * mNbColumns + x];
+}
+
+// Compute the shape Id for a given triangle
+RP3D_FORCE_INLINE uint32 HeightField::computeTriangleShapeId(uint32 iIndex, uint32 jIndex, uint32 secondTriangleIncrement) const {
+ return (jIndex * (mNbColumns - 1) + iIndex) * 2 + secondTriangleIncrement;
+}
+
+#ifdef IS_RP3D_PROFILING_ENABLED
+
+// Set the profiler
+RP3D_FORCE_INLINE void HeightField::setProfiler(Profiler* profiler) {
+ mProfiler = profiler;
+}
+
+#endif
+
+}
+
+#endif
+
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/OverlapCallback.h b/ext/reactphysics3d/include/reactphysics3d/collision/OverlapCallback.h
index 58e628960..4f12816e8 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/OverlapCallback.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/OverlapCallback.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -34,7 +34,7 @@
namespace reactphysics3d {
// Declarations
-class CollisionBody;
+class Body;
class PhysicsWorld;
class Collider;
struct Entity;
@@ -96,7 +96,7 @@ class OverlapCallback {
OverlapPair(const OverlapPair& contactPair) = default;
/// Assignment operator
- OverlapPair& operator=(const OverlapPair& contactPair) = default;
+ OverlapPair& operator=(const OverlapPair& contactPair) = delete;
/// Destructor
~OverlapPair() = default;
@@ -108,10 +108,10 @@ class OverlapCallback {
Collider* getCollider2() const;
/// Return a pointer to the first body in contact
- CollisionBody* getBody1() const;
+ Body* getBody1() const;
/// Return a pointer to the second body in contact
- CollisionBody* getBody2() const;
+ Body* getBody2() const;
/// Return the corresponding type of event for this overlapping pair
EventType getEventType() const;
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/PolygonVertexArray.h b/ext/reactphysics3d/include/reactphysics3d/collision/PolygonVertexArray.h
index fd3faf902..52b21fb84 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/PolygonVertexArray.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/PolygonVertexArray.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -32,16 +32,15 @@
namespace reactphysics3d {
+// Declarations
+struct Vector3;
+
// Class PolygonVertexArray
/**
- * This class is used to describe the vertices and faces of a polyhedron mesh.
+ * This class is used to describe the vertices and faces of a mesh.
* A PolygonVertexArray represents an array of vertices and polygon faces
- * of a polyhedron mesh. When you create a PolygonVertexArray, no data is copied
- * into the array. It only stores pointer to the data. The purpose is to allow
- * the user to share vertices data between the physics engine and the rendering
- * part. Therefore, make sure that the data pointed by a PolygonVertexArray
- * remains valid during the PolygonVertexArray life.
- */
+ * of a mesh. When you create a PolygonVertexArray, no data is copied
+ * into the array. It only stores pointer to the data. */
class PolygonVertexArray {
public:
@@ -52,7 +51,7 @@ class PolygonVertexArray {
/// Data type for the indices in the array
enum class IndexDataType {INDEX_INTEGER_TYPE, INDEX_SHORT_TYPE};
- /// Represent a polygon face of the polyhedron
+ /// Represent a polygon face of the mesh
struct PolygonFace {
/// Number of vertices in the polygon face
@@ -85,7 +84,7 @@ class PolygonVertexArray {
/// Number of polygon faces in the array
uint32 mNbFaces;
- /// Pointer to the first polygon face in the polyhedron
+ /// Pointer to the first polygon face in the mesh
PolygonFace* mPolygonFacesStart;
/// Data type of the vertices in the array
@@ -96,14 +95,20 @@ class PolygonVertexArray {
public:
+ /// Constructor
+ PolygonVertexArray();
+
/// Constructor
PolygonVertexArray(uint32 nbVertices, const void* verticesStart, uint32 verticesStride,
const void* indexesStart, uint32 indexesStride,
uint32 nbFaces, PolygonFace* facesStart,
VertexDataType vertexDataType, IndexDataType indexDataType);
- /// Destructor
- ~PolygonVertexArray() = default;
+ /// Initialize the PolygonVertexArray
+ void init(uint32 nbVertices, const void* verticesStart, uint32 verticesStride,
+ const void* indexesStart, uint32 indexesStride,
+ uint32 nbFaces, PolygonFace* facesStart,
+ VertexDataType vertexDataType, IndexDataType indexDataType);
/// Return the vertex data type
VertexDataType getVertexDataType() const;
@@ -126,7 +131,10 @@ class PolygonVertexArray {
/// Return the vertex index of a given vertex in a face
uint32 getVertexIndexInFace(uint32 faceIndex32, uint32 noVertexInFace) const;
- /// Return a polygon face of the polyhedron
+ /// Return the coordinates of a given vertex
+ Vector3 getVertex(uint32 vertexIndex) const;
+
+ /// Return a polygon face of the mesh
PolygonFace* getPolygonFace(uint32 faceIndex) const;
/// Return the pointer to the start of the vertices array
@@ -134,6 +142,10 @@ class PolygonVertexArray {
/// Return the pointer to the start of the indices array
const unsigned char* getIndicesStart() const;
+
+ // -------------------- Friendship -------------------- //
+
+ friend class PhysicsCommon;
};
// Return the vertex data type
@@ -184,7 +196,7 @@ RP3D_FORCE_INLINE uint32 PolygonVertexArray::getIndicesStride() const {
return mIndicesStride;
}
-// Return a polygon face of the polyhedron
+// Return a polygon face of the mesh
/**
* @param faceIndex Index of a given face
* @return A polygon face
@@ -196,7 +208,7 @@ RP3D_FORCE_INLINE PolygonVertexArray::PolygonFace* PolygonVertexArray::getPolygo
// Return the pointer to the start of the vertices array
/**
- * @return A pointer to the start of the vertex array of the polyhedron
+ * @return A pointer to the start of the vertex array of the mesh
*/
RP3D_FORCE_INLINE const unsigned char* PolygonVertexArray::getVerticesStart() const {
return mVerticesStart;
@@ -204,7 +216,7 @@ RP3D_FORCE_INLINE const unsigned char* PolygonVertexArray::getVerticesStart() co
// Return the pointer to the start of the indices array
/**
- * @return A pointer to the start of the face indices array of the polyhedron
+ * @return A pointer to the start of the face indices array of the mesh
*/
RP3D_FORCE_INLINE const unsigned char* PolygonVertexArray::getIndicesStart() const {
return mIndicesStart;
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/RaycastInfo.h b/ext/reactphysics3d/include/reactphysics3d/collision/RaycastInfo.h
index 50c418c06..c637af2a3 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/RaycastInfo.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/RaycastInfo.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -33,7 +33,7 @@
namespace reactphysics3d {
// Declarations
-class CollisionBody;
+class Body;
class Collider;
class CollisionShape;
struct Ray;
@@ -60,14 +60,11 @@ struct RaycastInfo {
/// The hit point "p" is such that p = point1 + hitFraction * (point2 - point1)
decimal hitFraction;
- /// Mesh subpart index that has been hit (only used for triangles mesh and -1 otherwise)
- int meshSubpart;
-
/// Hit triangle index (only used for triangles mesh and -1 otherwise)
int triangleIndex;
/// Pointer to the hit collision body
- CollisionBody* body;
+ Body* body;
/// Pointer to the hit collider
Collider* collider;
@@ -75,7 +72,7 @@ struct RaycastInfo {
// -------------------- Methods -------------------- //
/// Constructor
- RaycastInfo() : meshSubpart(-1), triangleIndex(-1), body(nullptr), collider(nullptr) {
+ RaycastInfo() : hitFraction(-1), triangleIndex(-1), body(nullptr), collider(nullptr) {
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/TriangleMesh.h b/ext/reactphysics3d/include/reactphysics3d/collision/TriangleMesh.h
index 0728b5678..1d3703633 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/TriangleMesh.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/TriangleMesh.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -30,76 +30,177 @@
#include
#include
#include
+#include
+#include
namespace reactphysics3d {
// Declarations
class TriangleVertexArray;
+struct Message;
// Class TriangleMesh
/**
- * This class represents a mesh made of triangles. A TriangleMesh contains
- * one or several parts. Each part is a set of triangles represented in a
- * TriangleVertexArray object describing all the triangles vertices of the part.
- * A TriangleMesh object can be used to create a ConcaveMeshShape from a triangle
- * mesh for instance.
+ * This class represents a mesh made of triangles.
+ * A single TriangleMesh object can be used to create one or many ConcaveMeshShape (with
+ * different scaling for instance).
*/
class TriangleMesh {
protected:
- /// All the triangle arrays of the mesh (one triangle array per part)
- Array mTriangleArrays;
+ /// Reference to the memory allocator
+ MemoryAllocator& mAllocator;
+
+ /// All the vertices of the mesh
+ Array mVertices;
+
+ /// The three vertices indices for each triangle face of the mesh
+ Array mTriangles;
+
+ /// The normal vector at each vertex of the mesh
+ Array mVerticesNormals;
+
+ /// Dynamic AABB tree to accelerate collision with the triangles
+ DynamicAABBTree mDynamicAABBTree;
+
+ /// Epsilon value for this mesh
+ decimal mEpsilon;
/// Constructor
TriangleMesh(reactphysics3d::MemoryAllocator& allocator);
+ /// Copy the vertices into the mesh
+ bool copyVertices(const TriangleVertexArray& triangleVertexArray, std::vector& messages);
+
+ /// Copy or compute the vertices normals
+ void computeVerticesNormals();
+
+ /// Compute the epsilon value for this mesh
+ void computeEpsilon(const TriangleVertexArray& triangleVertexArray);
+
+ /// Copy the triangles into the mesh
+ bool copyData(const TriangleVertexArray& triangleVertexArray, std::vector& errors);
+
+ /// Insert all the triangles into the dynamic AABB tree
+ void initBVHTree();
+
+ /// Initialize the mesh using a TriangleVertexArray
+ bool init(const TriangleVertexArray& triangleVertexArray, std::vector& messages);
+
+ /// Report all shapes overlapping with the AABB given in parameter.
+ void reportAllShapesOverlappingWithAABB(const AABB& aabb, Array& overlappingNodes);
+
+ /// Remove the ununsed vertices (because they are not used in any triangles or are part of discarded triangles)
+ void removeUnusedVertices(Array& areUsedVertices);
+
+ /// Return the integer data of leaf node of the dynamic AABB tree
+ int32 getDynamicAABBTreeNodeDataInt(int32 nodeID) const;
+
+ /// Ray casting method
+ void raycast(const Ray& ray, DynamicAABBTreeRaycastCallback& callback) const;
+
public:
- /// Destructor
- ~TriangleMesh();
+ /// Return the number of vertices in the mesh
+ uint32 getNbVertices() const;
+
+ /// Return the number of triangles faces of the mesh
+ uint32 getNbTriangles() const;
+
+ /// Return the bounds of the mesh in the x,y,z direction
+ const AABB& getBounds() const;
- /// Add a subpart of the mesh
- void addSubpart(TriangleVertexArray* triangleVertexArray);
+ /// Return the three vertex indices of a given triangle face
+ void getTriangleVerticesIndices(uint32 triangleIndex, uint32& outV1Index, uint32& outV2Index,
+ uint32& outV3Index) const;
- /// Return a pointer to a given subpart (triangle vertex array) of the mesh
- TriangleVertexArray* getSubpart(uint32 indexSubpart) const;
+ /// Return the coordinates of the three vertices of a given triangle face
+ void getTriangleVertices(uint32 triangleIndex, Vector3& outV1, Vector3& outV2, Vector3& outV3) const;
- /// Return the number of subparts of the mesh
- uint32 getNbSubparts() const;
+ /// Return the normals of the three vertices of a given triangle face
+ void getTriangleVerticesNormals(uint32 triangleIndex, Vector3& outN1,
+ Vector3& outN2, Vector3& outN3) const;
+ /// Return the coordinates of a given vertex
+ const Vector3& getVertex(uint32 vertexIndex) const;
+
+ /// Return the normal of a given vertex
+ const Vector3& getVertexNormal(uint32 vertexIndex) const;
+
+#ifdef IS_RP3D_PROFILING_ENABLED
+
+ /// Set the profiler
+ void setProfiler(Profiler* profiler);
+
+#endif
// ---------- Friendship ---------- //
friend class PhysicsCommon;
+ friend class ConcaveMeshShape;
};
-// Add a subpart of the mesh
-/**
- * @param triangleVertexArray Pointer to the TriangleVertexArray to add into the mesh
- */
-RP3D_FORCE_INLINE void TriangleMesh::addSubpart(TriangleVertexArray* triangleVertexArray) {
- mTriangleArrays.add(triangleVertexArray );
+// Return the number of vertices in the mesh
+RP3D_FORCE_INLINE uint32 TriangleMesh::getNbVertices() const {
+ return mVertices.size();
}
-// Return a pointer to a given subpart (triangle vertex array) of the mesh
-/**
- * @param indexSubpart The index of the sub-part of the mesh
- * @return A pointer to the triangle vertex array of a given sub-part of the mesh
- */
-RP3D_FORCE_INLINE TriangleVertexArray* TriangleMesh::getSubpart(uint32 indexSubpart) const {
- assert(indexSubpart < mTriangleArrays.size());
- return mTriangleArrays[indexSubpart];
+// Return the number of triangles faces of the mesh
+RP3D_FORCE_INLINE uint32 TriangleMesh::getNbTriangles() const {
+ return mTriangles.size() / 3;
}
-// Return the number of sub-parts of the mesh
-/**
- * @return The number of sub-parts of the mesh
- */
-RP3D_FORCE_INLINE uint32 TriangleMesh::getNbSubparts() const {
- return static_cast(mTriangleArrays.size());
+// Return the three vertex indices of a given triangle face
+RP3D_FORCE_INLINE void TriangleMesh::getTriangleVerticesIndices(uint32 triangleIndex, uint32& outV1Index,
+ uint32& outV2Index, uint32& outV3Index) const {
+ assert(triangleIndex < mTriangles.size() / 3);
+
+ outV1Index = mTriangles[triangleIndex * 3];
+ outV2Index = mTriangles[triangleIndex * 3 + 1];
+ outV3Index = mTriangles[triangleIndex * 3 + 2];
}
+// Return the coordinates of the three vertices of a given triangle face
+RP3D_FORCE_INLINE void TriangleMesh::getTriangleVertices(uint32 triangleIndex, Vector3& outV1, Vector3& outV2,
+ Vector3& outV3) const {
+ assert(triangleIndex < mTriangles.size() / 3);
+
+ outV1 = mVertices[mTriangles[triangleIndex * 3]];
+ outV2 = mVertices[mTriangles[triangleIndex * 3 + 1]];
+ outV3 = mVertices[mTriangles[triangleIndex * 3 + 2]];
+}
+
+// Return the normals of the three vertices of a given triangle face
+RP3D_FORCE_INLINE void TriangleMesh::getTriangleVerticesNormals(uint32 triangleIndex, Vector3& outN1,
+ Vector3& outN2, Vector3& outN3) const {
+ assert(triangleIndex < mTriangles.size() / 3);
+
+ outN1 = mVerticesNormals[mTriangles[triangleIndex * 3]];
+ outN2 = mVerticesNormals[mTriangles[triangleIndex * 3 + 1]];
+ outN3 = mVerticesNormals[mTriangles[triangleIndex * 3 + 2]];
+}
+
+// Return the coordinates of a given vertex
+RP3D_FORCE_INLINE const Vector3& TriangleMesh::getVertex(uint32 vertexIndex) const {
+ assert(vertexIndex < mVertices.size());
+ return mVertices[vertexIndex];
+}
+
+// Return the normal of a given vertex
+RP3D_FORCE_INLINE const Vector3& TriangleMesh::getVertexNormal(uint32 vertexIndex) const {
+ assert(vertexIndex < mVertices.size());
+ return mVerticesNormals[vertexIndex];
+}
+
+#ifdef IS_RP3D_PROFILING_ENABLED
+
+// Set the profiler
+RP3D_FORCE_INLINE void TriangleMesh::setProfiler(Profiler* profiler) {
+ mDynamicAABBTree.setProfiler(profiler);
+}
+
+#endif
}
#endif
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/TriangleVertexArray.h b/ext/reactphysics3d/include/reactphysics3d/collision/TriangleVertexArray.h
index 046698bb3..e82908876 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/TriangleVertexArray.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/TriangleVertexArray.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -39,8 +39,7 @@ struct Vector3;
* This class is used to describe the vertices and faces of a triangular mesh.
* A TriangleVertexArray represents a continuous array of vertices and indexes
* of a triangular mesh. When you create a TriangleVertexArray, no data is copied
- * into the array. It only stores pointer to the data. The purpose is to allow
- * the user to share vertices data between the physics engine and the rendering
+ * into the array. It only stores pointer to the data.
* part. Therefore, make sure that the data pointed by a TriangleVertexArray
* remains valid during the TriangleVertexArray life.
*/
@@ -97,13 +96,10 @@ class TriangleVertexArray {
IndexDataType mIndexDataType;
/// True if the vertices normals are provided by the user
- bool mAreVerticesNormalsProvidedByUser;
+ bool mHasNormals;
// -------------------- Methods -------------------- //
- /// Compute the vertices normals when they are not provided by the user
- void computeVerticesNormals();
-
public:
// -------------------- Methods -------------------- //
@@ -120,9 +116,6 @@ class TriangleVertexArray {
VertexDataType vertexDataType, NormalDataType normalDataType,
IndexDataType indexDataType);
- /// Destructor
- ~TriangleVertexArray();
-
/// Deleted assignment operator
TriangleVertexArray& operator=(const TriangleVertexArray& triangleVertexArray) = delete;
@@ -135,6 +128,9 @@ class TriangleVertexArray {
/// Return the vertex normal data type
NormalDataType getVertexNormalDataType() const;
+ /// Return true if the vertices normal have been provided by the user
+ bool getHasNormals() const;
+
/// Return the index data type
IndexDataType getIndexDataType() const;
@@ -162,20 +158,15 @@ class TriangleVertexArray {
/// Return the pointer to the start of the indices array
const void* getIndicesStart() const;
- /// Return the vertices coordinates of a triangle
- void getTriangleVertices(uint32 triangleIndex, Vector3* outTriangleVertices) const;
-
- /// Return the three vertices normals of a triangle
- void getTriangleVerticesNormals(uint32 triangleIndex, Vector3* outTriangleVerticesNormals) const;
-
- /// Return the indices of the three vertices of a given triangle in the array
- void getTriangleVerticesIndices(uint32 triangleIndex, uint32* outVerticesIndices) const;
+ /// Return the three vertex indices of a given triangle face
+ void getTriangleVerticesIndices(uint32 triangleIndex, uint32& outV1Index, uint32& outV2Index,
+ uint32& outV3Index) const;
/// Return a vertex of the array
- void getVertex(uint32 vertexIndex, Vector3* outVertex);
+ Vector3 getVertex(uint32 vertexIndex) const;
/// Return a vertex normal of the array
- void getNormal(uint32 vertexIndex, Vector3* outNormal);
+ Vector3 getVertexNormal(uint32 vertexIndex) const;
};
// Return the vertex data type
@@ -266,6 +257,14 @@ RP3D_FORCE_INLINE const void* TriangleVertexArray::getIndicesStart() const {
return mIndicesStart;
}
+// Return true if the vertices normals have been provided by the user
+/**
+ * @return True if the vertices normals have been provided by the user
+ */
+RP3D_FORCE_INLINE bool TriangleVertexArray::getHasNormals() const {
+ return mHasNormals;
+}
+
}
#endif
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/VertexArray.h b/ext/reactphysics3d/include/reactphysics3d/collision/VertexArray.h
new file mode 100644
index 000000000..75129f0aa
--- /dev/null
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/VertexArray.h
@@ -0,0 +1,125 @@
+/********************************************************************************
+* ReactPhysics3D physics library, http://www.reactphysics3d.com *
+* Copyright (c) 2010-2024 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 REACTPHYSICS3D_VERTEX_ARRAY_H
+#define REACTPHYSICS3D_VERTEX_ARRAY_H
+
+// Libraries
+#include
+#include
+
+namespace reactphysics3d {
+
+// Declarations
+struct Vector3;
+
+// Class VertexArray
+/**
+ * This class is used to describe an array of vertices.
+ */
+class VertexArray {
+
+ public:
+
+ /// Data type for the vertices in the array
+ enum class DataType {VERTEX_FLOAT_TYPE, VERTEX_DOUBLE_TYPE};
+
+ protected:
+
+ /// Number of vertices in the array
+ uint32 mNbVertices;
+
+ /// Pointer to the first vertex value in the array
+ const unsigned char* mStart;
+
+ /// Stride (number of bytes) between the beginning of two vertices values in the array
+ uint32 mStride;
+
+ /// Data type of the vertices in the array
+ DataType mDataType;
+
+ public:
+
+ /// Constructor
+ VertexArray(const void* start, uint32 stride, uint32 nbVertices, DataType dataType);
+
+ // TODO : Add constructor with a reference to a vector of Vector3
+
+ /// Return the vertex data type
+ DataType getDataType() const;
+
+ /// Return the number of vertices
+ uint32 getNbVertices() const;
+
+ /// Return the vertices stride (number of bytes)
+ uint32 getStride() const;
+
+ /// Return the coordinates of a given vertex
+ Vector3 getVertex(uint32 index) const;
+
+ /// Return the pointer to the start of the vertices array
+ const unsigned char* getStart() const;
+
+ // -------------------- Friendship -------------------- //
+
+ friend class PhysicsCommon;
+};
+
+// Return the vertex data type
+/**
+ * @return The data type of the vertices in the array
+ */
+RP3D_FORCE_INLINE VertexArray::DataType VertexArray::getDataType() const {
+ return mDataType;
+}
+
+// Return the number of vertices
+/**
+ * @return The number of vertices in the array
+ */
+RP3D_FORCE_INLINE uint32 VertexArray::getNbVertices() const {
+ return mNbVertices;
+}
+
+// Return the vertices stride (number of bytes)
+/**
+ * @return The number of bytes between two vertices
+ */
+RP3D_FORCE_INLINE uint32 VertexArray::getStride() const {
+ return mStride;
+}
+
+// Return the pointer to the start of the vertices array
+/**
+ * @return A pointer to the start of the vertex array of the mesh
+ */
+RP3D_FORCE_INLINE const unsigned char* VertexArray::getStart() const {
+ return mStart;
+}
+
+}
+
+#endif
+
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h b/ext/reactphysics3d/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h
index ac80cfe96..6ed6df55e 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -38,7 +38,7 @@ namespace reactphysics3d {
class BroadPhaseSystem;
class BroadPhaseRaycastTestCallback;
class DynamicAABBTreeOverlapCallback;
-class CollisionBody;
+class Body;
struct RaycastTest;
class AABB;
class Profiler;
@@ -77,7 +77,7 @@ struct TreeNode {
/// Two pieces of data stored at that node (in case the node is a leaf)
union {
- int32 dataInt[2];
+ uint32 dataInt;
void* dataPointer;
};
};
@@ -220,7 +220,7 @@ class DynamicAABBTree {
~DynamicAABBTree();
/// Add an object into the tree (where node data are two integers)
- int32 addObject(const AABB& aabb, int32 data1, int32 data2);
+ int32 addObject(const AABB& aabb, uint32 data);
/// Add an object into the tree (where node data is a pointer)
int32 addObject(const AABB& aabb, void* data);
@@ -235,7 +235,7 @@ class DynamicAABBTree {
const AABB& getFatAABB(int32 nodeID) const;
/// Return the pointer to the data array of a given leaf node of the tree
- int32* getNodeDataInt(int32 nodeID) const;
+ int32 getNodeDataInt(int32 nodeID) const;
/// Return the data pointer of a given leaf node of the tree
void* getNodeDataPointer(int32 nodeID) const;
@@ -254,7 +254,7 @@ class DynamicAABBTree {
int computeHeight();
/// Return the root AABB of the tree
- AABB getRootAABB() const;
+ const AABB& getRootAABB() const;
/// Clear all the nodes and reset the tree
void reset();
@@ -280,7 +280,7 @@ RP3D_FORCE_INLINE const AABB& DynamicAABBTree::getFatAABB(int32 nodeID) const {
}
// Return the pointer to the data array of a given leaf node of the tree
-RP3D_FORCE_INLINE int32* DynamicAABBTree::getNodeDataInt(int32 nodeID) const {
+RP3D_FORCE_INLINE int32 DynamicAABBTree::getNodeDataInt(int32 nodeID) const {
assert(nodeID >= 0 && nodeID < mNbAllocatedNodes);
assert(mNodes[nodeID].isLeaf());
return mNodes[nodeID].dataInt;
@@ -294,18 +294,17 @@ RP3D_FORCE_INLINE void* DynamicAABBTree::getNodeDataPointer(int32 nodeID) const
}
// Return the root AABB of the tree
-RP3D_FORCE_INLINE AABB DynamicAABBTree::getRootAABB() const {
+RP3D_FORCE_INLINE const AABB& DynamicAABBTree::getRootAABB() const {
return getFatAABB(mRootNodeID);
}
// Add an object into the tree. This method creates a new leaf node in the tree and
// returns the ID of the corresponding node.
-RP3D_FORCE_INLINE int32 DynamicAABBTree::addObject(const AABB& aabb, int32 data1, int32 data2) {
+RP3D_FORCE_INLINE int32 DynamicAABBTree::addObject(const AABB& aabb, uint32 data) {
int32 nodeId = addObjectInternal(aabb);
- mNodes[nodeId].dataInt[0] = data1;
- mNodes[nodeId].dataInt[1] = data2;
+ mNodes[nodeId].dataInt = data;
return nodeId;
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CapsuleVsCapsuleAlgorithm.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CapsuleVsCapsuleAlgorithm.h
index 35a7cca52..a96a59d5e 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CapsuleVsCapsuleAlgorithm.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CapsuleVsCapsuleAlgorithm.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.h
index de3b108a7..b170f50b0 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CollisionDispatch.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CollisionDispatch.h
index cf09f961a..375ea015c 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CollisionDispatch.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/CollisionDispatch.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -40,7 +40,7 @@ namespace reactphysics3d {
/// Enumeration for the type of narrow-phase
/// collision detection algorithm
enum class NarrowPhaseAlgorithmType {
- None,
+ NoCollisionTest,
SphereVsSphere,
SphereVsCapsule,
CapsuleVsCapsule,
@@ -62,6 +62,14 @@ class CollisionDispatch {
/// Memory allocator
MemoryAllocator& mAllocator;
+ /// Allocation sizes
+ size_t mSphereVsSphereAllocatedSize;
+ size_t mSphereVsCapsuleAllocatedSize;
+ size_t mCapsuleVsCapsuleAllocatedSize;
+ size_t mSphereVsConvexPolyAllocatedSize;
+ size_t mCapsuleVsConvexPolyAllocatedSize;
+ size_t mConvexPolyVsConvexPolyAllocatedSize;
+
/// True if the sphere vs sphere algorithm is the default one
bool mIsSphereVsSphereDefault = true;
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.h
index 42daf1592..2c6d5abe4 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h
index b98e7914c..23799a8f3 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/VoronoiSimplex.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/VoronoiSimplex.h
index a4943687c..b3c21f9e8 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/VoronoiSimplex.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/VoronoiSimplex.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseAlgorithm.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseAlgorithm.h
index 6b74e55aa..a21ed41cb 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseAlgorithm.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseAlgorithm.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h
index 126d92022..505182c03 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -47,6 +47,11 @@ struct ContactPointInfo;
*/
struct NarrowPhaseInfoBatch {
+ // Struct NarrowPhaseInfo
+ /**
+ * A potential collision between two colliders from the middle-phase algorithm
+ * that have to be tested during narrow-phase collision detection.
+ */
struct NarrowPhaseInfo {
/// Broadphase overlapping pairs ids
@@ -111,6 +116,9 @@ struct NarrowPhaseInfoBatch {
/// Cached capacity
uint32 mCachedCapacity = 0;
+ /// TriangleShape allocated size
+ static const size_t mTriangleShapeAllocatedSize;
+
public:
/// For each collision test, we keep some meta data
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseInput.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseInput.h
index 4ac07eab4..097020817 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseInput.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/NarrowPhaseInput.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -152,7 +152,7 @@ RP3D_FORCE_INLINE void NarrowPhaseInput::addNarrowPhaseTest(uint64 pairId, Entit
case NarrowPhaseAlgorithmType::ConvexPolyhedronVsConvexPolyhedron:
mConvexPolyhedronVsConvexPolyhedronBatch.addNarrowPhaseInfo(pairId, collider1, collider2, shape1, shape2, shape1Transform, shape2Transform, reportContacts, lastFrameInfo, shapeAllocator);
break;
- case NarrowPhaseAlgorithmType::None:
+ case NarrowPhaseAlgorithmType::NoCollisionTest:
// Must never happen
assert(false);
break;
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h
index 36ffa25b1..74e3bf2a2 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsCapsuleAlgorithm.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsCapsuleAlgorithm.h
index 86f58036b..29f259984 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsCapsuleAlgorithm.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsCapsuleAlgorithm.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.h
index d113862cc..ec968bc9b 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsSphereAlgorithm.h b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsSphereAlgorithm.h
index 78b5f5cfc..41ec1789c 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsSphereAlgorithm.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/narrowphase/SphereVsSphereAlgorithm.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/AABB.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/AABB.h
index 1cfebf129..e18070618 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/AABB.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/AABB.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -28,6 +28,7 @@
// Libraries
#include
+#include
/// ReactPhysics3D namespace
namespace reactphysics3d {
@@ -82,6 +83,9 @@ class AABB {
/// Inflate each side of the AABB by a given size
void inflate(decimal dx, decimal dy, decimal dz);
+ /// Inflate (if necessary) to make sure that a given point fit inside it
+ void inflateWithPoint(const Vector3& point);
+
/// Return true if the current AABB is overlapping with the AABB in argument
bool testCollision(const AABB& aabb) const;
@@ -98,7 +102,7 @@ class AABB {
bool contains(const AABB& aabb) const;
/// Return true if a point is inside the AABB
- bool contains(const Vector3& point) const;
+ bool contains(const Vector3& point, decimal epsilon = MACHINE_EPSILON) const;
/// Return true if the AABB of a triangle intersects the AABB
bool testCollisionTriangleAABB(const Vector3* trianglePoints) const;
@@ -156,6 +160,20 @@ RP3D_FORCE_INLINE void AABB::inflate(decimal dx, decimal dy, decimal dz) {
mMinCoordinates -= Vector3(dx, dy, dz);
}
+// Inflate (if necessary) to make sure that a given point fit inside it
+RP3D_FORCE_INLINE void AABB::inflateWithPoint(const Vector3& point) {
+
+ // Compute mesh bounds
+ if (point.x > mMaxCoordinates.x) mMaxCoordinates.x = point.x;
+ if (point.x < mMinCoordinates.x) mMinCoordinates.x = point.x;
+
+ if (point.y > mMaxCoordinates.y) mMaxCoordinates.y = point.y;
+ if (point.y < mMinCoordinates.y) mMinCoordinates.y = point.y;
+
+ if (point.z > mMaxCoordinates.z) mMaxCoordinates.z = point.z;
+ if (point.z < mMinCoordinates.z) mMinCoordinates.z = point.z;
+}
+
// Return true if the current AABB is overlapping with the AABB in argument.
/// Two AABBs overlap if they overlap in the three x, y and z axis at the same time
RP3D_FORCE_INLINE bool AABB::testCollision(const AABB& aabb) const {
@@ -189,11 +207,11 @@ RP3D_FORCE_INLINE bool AABB::testCollisionTriangleAABB(const Vector3* trianglePo
}
// Return true if a point is inside the AABB
-RP3D_FORCE_INLINE bool AABB::contains(const Vector3& point) const {
+RP3D_FORCE_INLINE bool AABB::contains(const Vector3& point, decimal epsilon) const {
- return (point.x >= mMinCoordinates.x - MACHINE_EPSILON && point.x <= mMaxCoordinates.x + MACHINE_EPSILON &&
- point.y >= mMinCoordinates.y - MACHINE_EPSILON && point.y <= mMaxCoordinates.y + MACHINE_EPSILON &&
- point.z >= mMinCoordinates.z - MACHINE_EPSILON && point.z <= mMaxCoordinates.z + MACHINE_EPSILON);
+ return (point.x >= mMinCoordinates.x - epsilon && point.x <= mMaxCoordinates.x + epsilon &&
+ point.y >= mMinCoordinates.y - epsilon && point.y <= mMaxCoordinates.y + epsilon &&
+ point.z >= mMinCoordinates.z - epsilon && point.z <= mMaxCoordinates.z + epsilon);
}
// Apply a scale factor to the AABB
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/BoxShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/BoxShape.h
index 0c8e503e1..cdc5ee4ce 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/BoxShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/BoxShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -34,9 +34,10 @@
namespace reactphysics3d {
// Declarations
-class CollisionBody;
+class Body;
class DefaultAllocator;
class PhysicsCommon;
+class AABB;
// Class BoxShape
/**
@@ -88,13 +89,13 @@ class BoxShape : public ConvexPolyhedronShape {
BoxShape& operator=(const BoxShape& shape) = delete;
/// Return the half-extents of the box
- Vector3 getHalfExtents() const;
+ const Vector3& getHalfExtents() const;
/// Set the half-extents of the box
void setHalfExtents(const Vector3& halfExtents);
/// Return the local bounds of the shape in x, y and z directions
- virtual void getLocalBounds(Vector3& min, Vector3& max) const override;
+ virtual AABB getLocalBounds() const override;
/// Return the local inertia tensor of the collision shape
virtual Vector3 getLocalInertiaTensor(decimal mass) const override;
@@ -141,7 +142,7 @@ class BoxShape : public ConvexPolyhedronShape {
/**
* @return The vector with the three half-extents of the box shape
*/
-RP3D_FORCE_INLINE Vector3 BoxShape::getHalfExtents() const {
+RP3D_FORCE_INLINE const Vector3& BoxShape::getHalfExtents() const {
return mHalfExtents;
}
@@ -157,21 +158,6 @@ RP3D_FORCE_INLINE void BoxShape::setHalfExtents(const Vector3& halfExtents) {
notifyColliderAboutChangedSize();
}
-// Return the local bounds of the shape in x, y and z directions
-/// This method is used to compute the AABB of the box
-/**
- * @param min The minimum bounds of the shape in local-space coordinates
- * @param max The maximum bounds of the shape in local-space coordinates
- */
-RP3D_FORCE_INLINE void BoxShape::getLocalBounds(Vector3& min, Vector3& max) const {
-
- // Maximum bounds
- max = mHalfExtents;
-
- // Minimum bounds
- min = -max;
-}
-
// Return the number of bytes used by the collision shape
RP3D_FORCE_INLINE size_t BoxShape::getSizeInBytes() const {
return sizeof(BoxShape);
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/CapsuleShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/CapsuleShape.h
index b4976d97d..592967748 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/CapsuleShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/CapsuleShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -34,7 +34,7 @@
namespace reactphysics3d {
// Declarations
-class CollisionBody;
+class Body;
// Class CapsuleShape
/**
@@ -103,7 +103,7 @@ class CapsuleShape : public ConvexShape {
void setHeight(decimal height);
/// Return the local bounds of the shape in x, y and z directions
- virtual void getLocalBounds(Vector3& min, Vector3& max) const override;
+ virtual AABB getLocalBounds() const override;
/// Compute and return the volume of the collision shape
virtual decimal getVolume() const override;
@@ -171,25 +171,6 @@ RP3D_FORCE_INLINE size_t CapsuleShape::getSizeInBytes() const {
return sizeof(CapsuleShape);
}
-// Return the local bounds of the shape in x, y and z directions
-// This method is used to compute the AABB of the box
-/**
- * @param min The minimum bounds of the shape in local-space coordinates
- * @param max The maximum bounds of the shape in local-space coordinates
- */
-RP3D_FORCE_INLINE void CapsuleShape::getLocalBounds(Vector3& min, Vector3& max) const {
-
- // Maximum bounds
- max.x = mMargin;
- max.y = mHalfHeight + mMargin;
- max.z = mMargin;
-
- // Minimum bounds
- min.x = -mMargin;
- min.y = -max.y;
- min.z = min.x;
-}
-
// Compute and return the volume of the collision shape
RP3D_FORCE_INLINE decimal CapsuleShape::getVolume() const {
return reactphysics3d::PI_RP3D * mMargin * mMargin * (decimal(4.0) * mMargin / decimal(3.0) + decimal(2.0) * mHalfHeight);
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/CollisionShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/CollisionShape.h
index 3d061c0d6..bc8abec4c 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/CollisionShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/CollisionShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -54,7 +54,7 @@ enum class CollisionShapeName { TRIANGLE, SPHERE, CAPSULE, BOX, CONVEX_MESH, TRI
// Declarations
class Collider;
-class CollisionBody;
+class Body;
// Class CollisionShape
/**
@@ -135,7 +135,7 @@ class CollisionShape {
virtual bool isPolyhedron() const=0;
/// Return the local bounds of the shape in x, y and z directions
- virtual void getLocalBounds(Vector3& min, Vector3& max) const=0;
+ virtual AABB getLocalBounds() const=0;
/// Return the id of the shape
uint32 getId() const;
@@ -146,8 +146,8 @@ class CollisionShape {
/// Compute and return the volume of the collision shape
virtual decimal getVolume() const=0;
- /// Compute the world-space AABB of the collision shape given a transform
- virtual void computeAABB(AABB& aabb, const Transform& transform) const;
+ /// Compute the transformed AABB of the collision shape given a transform
+ virtual AABB computeTransformedAABB(const Transform& transform) const;
/// Return the string representation of the shape
virtual std::string to_string() const=0;
@@ -162,7 +162,7 @@ class CollisionShape {
// -------------------- Friendship -------------------- //
friend class Collider;
- friend class CollisionBody;
+ friend class Body;
friend class RigidBody;
friend class PhysicsWorld;
friend class BroadPhaseSystem;
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h
index f794d9bea..2f9ac10e4 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -40,6 +40,9 @@ class TriangleShape;
class TriangleMesh;
// class ConvexTriangleAABBOverlapCallback
+/**
+ * This class represents a callback when an overlap occurs
+ */
class ConvexTriangleAABBOverlapCallback : public DynamicAABBTreeOverlapCallback {
private:
@@ -49,15 +52,11 @@ class ConvexTriangleAABBOverlapCallback : public DynamicAABBTreeOverlapCallback
// Reference to the concave mesh shape
const ConcaveMeshShape& mConcaveMeshShape;
- // Reference to the Dynamic AABB tree
- const DynamicAABBTree& mDynamicAABBTree;
-
public:
// Constructor
- ConvexTriangleAABBOverlapCallback(TriangleCallback& triangleCallback, const ConcaveMeshShape& concaveShape,
- const DynamicAABBTree& dynamicAABBTree)
- : mTriangleTestCallback(triangleCallback), mConcaveMeshShape(concaveShape), mDynamicAABBTree(dynamicAABBTree) {
+ ConvexTriangleAABBOverlapCallback(TriangleCallback& triangleCallback, const ConcaveMeshShape& concaveShape)
+ : mTriangleTestCallback(triangleCallback), mConcaveMeshShape(concaveShape) {
}
@@ -73,14 +72,12 @@ class ConcaveMeshRaycastCallback : public DynamicAABBTreeRaycastCallback {
private :
Array mHitAABBNodes;
- const DynamicAABBTree& mDynamicAABBTree;
const ConcaveMeshShape& mConcaveMeshShape;
Collider* mCollider;
RaycastInfo& mRaycastInfo;
const Ray& mRay;
bool mIsHit;
MemoryAllocator& mAllocator;
- const Vector3& mMeshScale;
#ifdef IS_RP3D_PROFILING_ENABLED
@@ -92,10 +89,10 @@ class ConcaveMeshRaycastCallback : public DynamicAABBTreeRaycastCallback {
public:
// Constructor
- ConcaveMeshRaycastCallback(const DynamicAABBTree& dynamicAABBTree, const ConcaveMeshShape& concaveMeshShape,
- Collider* collider, RaycastInfo& raycastInfo, const Ray& ray, const Vector3& meshScale, MemoryAllocator& allocator)
- : mHitAABBNodes(allocator), mDynamicAABBTree(dynamicAABBTree), mConcaveMeshShape(concaveMeshShape), mCollider(collider),
- mRaycastInfo(raycastInfo), mRay(ray), mIsHit(false), mAllocator(allocator), mMeshScale(meshScale) {
+ ConcaveMeshRaycastCallback(const ConcaveMeshShape& concaveMeshShape,
+ Collider* collider, RaycastInfo& raycastInfo, const Ray& ray, MemoryAllocator& allocator)
+ : mHitAABBNodes(allocator), mConcaveMeshShape(concaveMeshShape), mCollider(collider),
+ mRaycastInfo(raycastInfo), mRay(ray), mIsHit(false), mAllocator(allocator) {
}
@@ -135,16 +132,12 @@ class ConcaveMeshShape : public ConcaveShape {
/// Pointer to the triangle mesh
TriangleMesh* mTriangleMesh;
- /// Dynamic AABB tree to accelerate collision with the triangles
- DynamicAABBTree mDynamicAABBTree;
-
- /// Array with computed vertices normals for each TriangleVertexArray of the triangle mesh (only
- /// if the user did not provide its own vertices normals)
- Vector3** mComputedVerticesNormals;
-
/// Reference to the triangle half-edge structure
HalfEdgeStructure& mTriangleHalfEdgeStructure;
+ /// Array with the scaled face normals
+ Array mScaledVerticesNormals;
+
// -------------------- Methods -------------------- //
/// Constructor
@@ -159,14 +152,8 @@ class ConcaveMeshShape : public ConcaveShape {
/// Insert all the triangles into the dynamic AABB tree
void initBVHTree();
- /// Return the three vertices coordinates (in the array outTriangleVertices) of a triangle
- void getTriangleVertices(uint32 subPart, uint32 triangleIndex, Vector3* outTriangleVertices) const;
-
- /// Return the three vertex normals (in the array outVerticesNormals) of a triangle
- void getTriangleVerticesNormals(uint32 subPart, uint32 triangleIndex, Vector3* outVerticesNormals) const;
-
/// Compute the shape Id for a given triangle of the mesh
- uint32 computeTriangleShapeId(uint32 subPart, uint32 triangleIndex) const;
+ uint32 computeTriangleShapeId(uint32 triangleIndex) const;
/// Compute all the triangles of the mesh that are overlapping with the AABB in parameter
virtual void computeOverlappingTriangles(const AABB& localAABB, Array& triangleVertices,
@@ -176,6 +163,12 @@ class ConcaveMeshShape : public ConcaveShape {
/// Destructor
virtual ~ConcaveMeshShape() override = default;
+ // Return the integer data of leaf node of the dynamic AABB tree
+ int32 getDynamicAABBTreeNodeDataInt(int32 nodeID) const;
+
+ /// Compute the scaled faces normals
+ void computeScaledVerticesNormals();
+
public:
/// Deleted copy-constructor
@@ -184,17 +177,34 @@ class ConcaveMeshShape : public ConcaveShape {
/// Deleted assignment operator
ConcaveMeshShape& operator=(const ConcaveMeshShape& shape) = delete;
- /// Return the number of sub parts contained in this mesh
- uint32 getNbSubparts() const;
-
- /// Return the number of triangles in a sub part of the mesh
- uint32 getNbTriangles(uint32 subPart) const;
+ /// Set the scale of the shape
+ virtual void setScale(const Vector3& scale) override;
+
+ /// Return the number of vertices in the mesh
+ uint32 getNbVertices() const;
+
+ /// Return the number of triangles of the mesh
+ uint32 getNbTriangles() const;
/// Return the indices of the three vertices of a given triangle in the array
- void getTriangleVerticesIndices(uint32 subPart, uint32 triangleIndex, uint32* outVerticesIndices) const;
+ void getTriangleVerticesIndices(uint32 triangleIndex, uint32& outV1Index, uint32& outV2Index,
+ uint32& outV3Index) const;
+
+ /// Return the coordinates of the three vertices of a given triangle face
+ void getTriangleVertices(uint32 triangleIndex, Vector3& outV1, Vector3& outV2, Vector3& outV3) const;
+
+ /// Return the normals of the three vertices of a given triangle face
+ void getTriangleVerticesNormals(uint32 triangleIndex, Vector3& outN1,
+ Vector3& outN2, Vector3& outN3) const;
+
+ /// Return the coordinates of a given vertex
+ const Vector3 getVertex(uint32 vertexIndex) const;
+
+ /// Return the normal of a given vertex
+ const Vector3& getVertexNormal(uint32 vertexIndex) const;
/// Return the local bounds of the shape in x, y and z directions.
- virtual void getLocalBounds(Vector3& min, Vector3& max) const override;
+ virtual AABB getLocalBounds() const override;
/// Return the string representation of the shape
virtual std::string to_string() const override;
@@ -219,53 +229,33 @@ RP3D_FORCE_INLINE size_t ConcaveMeshShape::getSizeInBytes() const {
return sizeof(ConcaveMeshShape);
}
-// Return the local bounds of the shape in x, y and z directions.
-// This method is used to compute the AABB of the box
-/**
- * @param min The minimum bounds of the shape in local-space coordinates
- * @param max The maximum bounds of the shape in local-space coordinates
- */
-RP3D_FORCE_INLINE void ConcaveMeshShape::getLocalBounds(Vector3& min, Vector3& max) const {
-
- // Get the AABB of the whole tree
- AABB treeAABB = mDynamicAABBTree.getRootAABB();
-
- min = treeAABB.getMin();
- max = treeAABB.getMax();
-}
-
// Called when a overlapping node has been found during the call to
// DynamicAABBTree:reportAllShapesOverlappingWithAABB()
RP3D_FORCE_INLINE void ConvexTriangleAABBOverlapCallback::notifyOverlappingNode(int nodeId) {
// Get the node data (triangle index and mesh subpart index)
- int32* data = mDynamicAABBTree.getNodeDataInt(nodeId);
+ int32 data = mConcaveMeshShape.getDynamicAABBTreeNodeDataInt(nodeId);
// Get the triangle vertices for this node from the concave mesh shape
Vector3 trianglePoints[3];
- mConcaveMeshShape.getTriangleVertices(data[0], data[1], trianglePoints);
+ mConcaveMeshShape.getTriangleVertices(data, trianglePoints[0], trianglePoints[1], trianglePoints[2]);
// Get the vertices normals of the triangle
Vector3 verticesNormals[3];
- mConcaveMeshShape.getTriangleVerticesNormals(data[0], data[1], verticesNormals);
+ mConcaveMeshShape.getTriangleVerticesNormals(data, verticesNormals[0], verticesNormals[1], verticesNormals[2]);
// Call the callback to test narrow-phase collision with this triangle
- mTriangleTestCallback.testTriangle(trianglePoints, verticesNormals, mConcaveMeshShape.computeTriangleShapeId(data[0], data[1]));
+ mTriangleTestCallback.testTriangle(trianglePoints, verticesNormals, mConcaveMeshShape.computeTriangleShapeId(data));
}
-#ifdef IS_RP3D_PROFILING_ENABLED
-
-// Set the profiler
-RP3D_FORCE_INLINE void ConcaveMeshShape::setProfiler(Profiler* profiler) {
+// Compute the shape Id for a given triangle of the mesh
+RP3D_FORCE_INLINE uint32 ConcaveMeshShape::computeTriangleShapeId(uint32 triangleIndex) const {
- CollisionShape::setProfiler(profiler);
+ RP3D_PROFILE("ConcaveMeshShape::computeTriangleShapeId()", mProfiler);
- mDynamicAABBTree.setProfiler(profiler);
+ return getNbTriangles() + triangleIndex;
}
-
-#endif
-
}
#endif
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConcaveShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConcaveShape.h
index 0f9837dbc..5ff2c5b11 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConcaveShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConcaveShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -99,7 +99,7 @@ class ConcaveShape : public CollisionShape {
const Vector3& getScale() const;
/// Set the scale of the shape
- void setScale(const Vector3& scale);
+ virtual void setScale(const Vector3& scale);
/// Return the local inertia tensor of the collision shape
virtual Vector3 getLocalInertiaTensor(decimal mass) const override;
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexMeshShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexMeshShape.h
index ab09099ed..d0aa148e0 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexMeshShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexMeshShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -29,7 +29,7 @@
// Libraries
#include
#include
-#include
+#include
/// ReactPhysics3D namespace
namespace reactphysics3d {
@@ -51,25 +51,19 @@ class ConvexMeshShape : public ConvexPolyhedronShape {
// -------------------- Attributes -------------------- //
- /// Polyhedron structure of the mesh
- PolyhedronMesh* mPolyhedronMesh;
+ /// Convex mesh
+ ConvexMesh* mConvexMesh;
- /// Mesh minimum bounds in the three local x, y and z directions
- Vector3 mMinBounds;
-
- /// Mesh maximum bounds in the three local x, y and z directions
- Vector3 mMaxBounds;
-
- /// Scale of the mesh
+ /// Scale to apply to the mesh
Vector3 mScale;
+ /// Array with the scaled face normals
+ Array mScaledFacesNormals;
+
// -------------------- Methods -------------------- //
/// Constructor
- ConvexMeshShape(PolyhedronMesh* polyhedronMesh, MemoryAllocator& allocator, const Vector3& scale = Vector3(1,1,1));
-
- /// Recompute the bounds of the mesh
- void recalculateBounds();
+ ConvexMeshShape(ConvexMesh* convexMesh, MemoryAllocator& allocator, const Vector3& scale = Vector3(1,1,1));
/// Return a local support point in a given direction without the object margin.
virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction) const override;
@@ -83,6 +77,9 @@ class ConvexMeshShape : public ConvexPolyhedronShape {
/// Return the number of bytes used by the collision shape
virtual size_t getSizeInBytes() const override;
+ // Compute the scaled faces normals
+ void computeScaledFacesNormals();
+
/// Destructor
virtual ~ConvexMeshShape() override = default;
@@ -103,36 +100,36 @@ class ConvexMeshShape : public ConvexPolyhedronShape {
void setScale(const Vector3& scale);
/// Return the local bounds of the shape in x, y and z directions
- virtual void getLocalBounds(Vector3& min, Vector3& max) const override;
+ virtual AABB getLocalBounds() const override;
/// Return the local inertia tensor of the collision shape.
virtual Vector3 getLocalInertiaTensor(decimal mass) const override;
- /// Return the number of faces of the polyhedron
+ /// Return the number of faces of the mesh
virtual uint32 getNbFaces() const override;
- /// Return a given face of the polyhedron
+ /// Return a given face of the mesh
virtual const HalfEdgeStructure::Face& getFace(uint32 faceIndex) const override;
- /// Return the number of vertices of the polyhedron
+ /// Return the number of vertices of the mesh
virtual uint32 getNbVertices() const override;
- /// Return a given vertex of the polyhedron
+ /// Return a given vertex of the mesh
virtual const HalfEdgeStructure::Vertex& getVertex(uint32 vertexIndex) const override;
- /// Return the number of half-edges of the polyhedron
+ /// Return the number of half-edges of the mesh
virtual uint32 getNbHalfEdges() const override;
- /// Return a given half-edge of the polyhedron
+ /// Return a given half-edge of the mesh
virtual const HalfEdgeStructure::Edge& getHalfEdge(uint32 edgeIndex) const override;
/// Return the position of a given vertex
virtual Vector3 getVertexPosition(uint32 vertexIndex) const override;
- /// Return the normal vector of a given face of the polyhedron
+ /// Return the normal vector of a given face of the mesh
virtual Vector3 getFaceNormal(uint32 faceIndex) const override;
- /// Return the centroid of the polyhedron
+ /// Return the centroid of the mesh
virtual Vector3 getCentroid() const override;
/// Compute and return the volume of the collision shape
@@ -160,19 +157,13 @@ RP3D_FORCE_INLINE const Vector3& ConvexMeshShape::getScale() const {
/// Note that you might want to recompute the inertia tensor and center of mass of the body
/// after changing the scale of a collision shape
RP3D_FORCE_INLINE void ConvexMeshShape::setScale(const Vector3& scale) {
+
mScale = scale;
- recalculateBounds();
- notifyColliderAboutChangedSize();
-}
-// Return the local bounds of the shape in x, y and z directions
-/**
- * @param min The minimum bounds of the shape in local-space coordinates
- * @param max The maximum bounds of the shape in local-space coordinates
- */
-RP3D_FORCE_INLINE void ConvexMeshShape::getLocalBounds(Vector3& min, Vector3& max) const {
- min = mMinBounds;
- max = mMaxBounds;
+ // Recompute the scaled face normals
+ computeScaledFacesNormals();
+
+ notifyColliderAboutChangedSize();
}
// Return the local inertia tensor of the collision shape.
@@ -182,69 +173,62 @@ RP3D_FORCE_INLINE void ConvexMeshShape::getLocalBounds(Vector3& min, Vector3& ma
* @param mass Mass to use to compute the inertia tensor of the collision shape
*/
RP3D_FORCE_INLINE Vector3 ConvexMeshShape::getLocalInertiaTensor(decimal mass) const {
- const decimal factor = (decimal(1.0) / decimal(3.0)) * mass;
- const Vector3 realExtent = decimal(0.5) * (mMaxBounds - mMinBounds);
- assert(realExtent.x > 0 && realExtent.y > 0 && realExtent.z > 0);
- const decimal xSquare = realExtent.x * realExtent.x;
- const decimal ySquare = realExtent.y * realExtent.y;
- const decimal zSquare = realExtent.z * realExtent.z;
- return Vector3(factor * (ySquare + zSquare), factor * (xSquare + zSquare), factor * (xSquare + ySquare));
+ return mConvexMesh->getLocalInertiaTensor(mass, mScale);
}
-// Return the number of faces of the polyhedron
+// Return the number of faces of the mesh
RP3D_FORCE_INLINE uint32 ConvexMeshShape::getNbFaces() const {
- return mPolyhedronMesh->getHalfEdgeStructure().getNbFaces();
+ return mConvexMesh->getHalfEdgeStructure().getNbFaces();
}
-// Return a given face of the polyhedron
+// Return a given face of the mesh
RP3D_FORCE_INLINE const HalfEdgeStructure::Face& ConvexMeshShape::getFace(uint32 faceIndex) const {
assert(faceIndex < getNbFaces());
- return mPolyhedronMesh->getHalfEdgeStructure().getFace(faceIndex);
+ return mConvexMesh->getHalfEdgeStructure().getFace(faceIndex);
}
-// Return the number of vertices of the polyhedron
+// Return the number of vertices of the mesh
RP3D_FORCE_INLINE uint32 ConvexMeshShape::getNbVertices() const {
- return mPolyhedronMesh->getHalfEdgeStructure().getNbVertices();
+ return mConvexMesh->getHalfEdgeStructure().getNbVertices();
}
-// Return a given vertex of the polyhedron
+// Return a given vertex of the mesh
RP3D_FORCE_INLINE const HalfEdgeStructure::Vertex& ConvexMeshShape::getVertex(uint32 vertexIndex) const {
assert(vertexIndex < getNbVertices());
- return mPolyhedronMesh->getHalfEdgeStructure().getVertex(vertexIndex);
+ return mConvexMesh->getHalfEdgeStructure().getVertex(vertexIndex);
}
-// Return the number of half-edges of the polyhedron
+// Return the number of half-edges of the mesh
RP3D_FORCE_INLINE uint32 ConvexMeshShape::getNbHalfEdges() const {
- return mPolyhedronMesh->getHalfEdgeStructure().getNbHalfEdges();
+ return mConvexMesh->getHalfEdgeStructure().getNbHalfEdges();
}
-// Return a given half-edge of the polyhedron
+// Return a given half-edge of the mesh
RP3D_FORCE_INLINE const HalfEdgeStructure::Edge& ConvexMeshShape::getHalfEdge(uint32 edgeIndex) const {
assert(edgeIndex < getNbHalfEdges());
- return mPolyhedronMesh->getHalfEdgeStructure().getHalfEdge(edgeIndex);
+ return mConvexMesh->getHalfEdgeStructure().getHalfEdge(edgeIndex);
}
// Return the position of a given vertex
RP3D_FORCE_INLINE Vector3 ConvexMeshShape::getVertexPosition(uint32 vertexIndex) const {
assert(vertexIndex < getNbVertices());
- return mPolyhedronMesh->getVertex(vertexIndex) * mScale;
+ return mConvexMesh->getVertex(vertexIndex) * mScale;
}
-// Return the normal vector of a given face of the polyhedron
+// Return the normal vector of a given face of the mesh
RP3D_FORCE_INLINE Vector3 ConvexMeshShape::getFaceNormal(uint32 faceIndex) const {
assert(faceIndex < getNbFaces());
- return mPolyhedronMesh->getFaceNormal(faceIndex);
+ return mScaledFacesNormals[faceIndex];
}
-// Return the centroid of the polyhedron
+// Return the centroid of the mesh
RP3D_FORCE_INLINE Vector3 ConvexMeshShape::getCentroid() const {
- return mPolyhedronMesh->getCentroid() * mScale;
+ return mConvexMesh->getCentroid() * mScale;
}
-
// Compute and return the volume of the collision shape
RP3D_FORCE_INLINE decimal ConvexMeshShape::getVolume() const {
- return mPolyhedronMesh->getVolume();
+ return mConvexMesh->getVolume() * mScale.x * mScale.y * mScale.z;
}
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexPolyhedronShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexPolyhedronShape.h
index 43953c4c6..3c89130ae 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexPolyhedronShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexPolyhedronShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexShape.h
index 21dc377b8..3aff4fa6c 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/ConvexShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/HeightFieldShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/HeightFieldShape.h
index c13964e89..e6972b4c3 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/HeightFieldShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/HeightFieldShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -28,6 +28,7 @@
// Libraries
#include
+#include
#include
namespace reactphysics3d {
@@ -51,60 +52,17 @@ class HeightFieldShape : public ConcaveShape {
public:
- /// Data type for the height data of the height field
- enum class HeightDataType {HEIGHT_FLOAT_TYPE, HEIGHT_DOUBLE_TYPE, HEIGHT_INT_TYPE};
-
protected:
// -------------------- Attributes -------------------- //
- /// Number of columns in the grid of the height field
- int mNbColumns;
-
- /// Number of rows in the grid of the height field
- int mNbRows;
-
- /// Height field width
- decimal mWidth;
-
- /// Height field length
- decimal mLength;
-
- /// Minimum height of the height field
- decimal mMinHeight;
-
- /// Maximum height of the height field
- decimal mMaxHeight;
-
- /// Up axis direction (0 => x, 1 => y, 2 => z)
- int mUpAxis;
-
- /// Height values scale for height field with integer height values
- decimal mIntegerHeightScale;
-
- /// Data type of the height values
- HeightDataType mHeightDataType;
-
- /// Array of data with all the height values of the height field
- const void* mHeightFieldData;
-
- /// Local AABB of the height field (without scaling)
- AABB mAABB;
-
- /// Reference to the half-edge structure
- HalfEdgeStructure& mTriangleHalfEdgeStructure;
+ /// Height-field
+ HeightField* mHeightField;
// -------------------- Methods -------------------- //
/// Constructor
- HeightFieldShape(int nbGridColumns, int nbGridRows, decimal minHeight, decimal maxHeight,
- const void* heightFieldData, HeightDataType dataType, MemoryAllocator& allocator,
- HalfEdgeStructure& triangleHalfEdgeStructure, int upAxis = 1, decimal integerHeightScale = 1.0f,
- const Vector3& scaling = Vector3(1,1,1));
-
- /// Raycast a single triangle of the height-field
- bool raycastTriangle(const Ray& ray, const Vector3& p1, const Vector3& p2, const Vector3& p3, uint32 shapeId,
- Collider *collider, RaycastInfo& raycastInfo, decimal &smallestHitFraction, MemoryAllocator& allocator) const;
+ HeightFieldShape(HeightField* heightfield, MemoryAllocator& allocator, const Vector3& scaling = Vector3(1,1,1));
/// Raycast method with feedback information
virtual bool raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& allocator) const override;
@@ -112,20 +70,6 @@ class HeightFieldShape : public ConcaveShape {
/// Return the number of bytes used by the collision shape
virtual size_t getSizeInBytes() const override;
- /// Return the three vertices coordinates (in the array outTriangleVertices) of a triangle
- /// given the start vertex index pointer of the triangle.
- void getTriangleVerticesWithIndexPointer(int32 subPart, int32 triangleIndex,
- Vector3* outTriangleVertices) const;
-
- /// Compute the min/max grid coords corresponding to the intersection of the AABB of the height field and the AABB to collide
- void computeMinMaxGridCoordinates(int* minCoords, int* maxCoords, const AABB& aabbToCollide) const;
-
- /// Compute the shape Id for a given triangle
- uint32 computeTriangleShapeId(uint32 iIndex, uint32 jIndex, uint32 secondTriangleIncrement) const;
-
- /// Compute the first grid cell of the heightfield intersected by a ray
- bool computeEnteringRayGridCoordinates(const Ray& ray, int& i, int& j, Vector3& outHitPoint) const;
-
/// Destructor
virtual ~HeightFieldShape() override = default;
@@ -137,23 +81,14 @@ class HeightFieldShape : public ConcaveShape {
/// Deleted assignment operator
HeightFieldShape& operator=(const HeightFieldShape& shape) = delete;
- /// Return the number of rows in the height field
- int getNbRows() const;
+ /// Return a pointer to the internal height-field
+ HeightField* getHeightField() const;
- /// Return the number of columns in the height field
- int getNbColumns() const;
-
/// Return the vertex (local-coordinates) of the height field at a given (x,y) position
- Vector3 getVertexAt(int x, int y) const;
-
- /// Return the height of a given (x,y) point in the height field
- decimal getHeightAt(int x, int y) const;
-
- /// Return the type of height value in the height field
- HeightDataType getHeightDataType() const;
+ Vector3 getVertexAt(uint32 x, uint32 y) const;
/// Return the local bounds of the shape in x, y and z directions.
- virtual void getLocalBounds(Vector3& min, Vector3& max) const override;
+ virtual AABB getLocalBounds() const override;
/// Use a callback method on all triangles of the concave shape inside a given AABB
virtual void computeOverlappingTriangles(const AABB& localAABB, Array& triangleVertices,
@@ -170,19 +105,9 @@ class HeightFieldShape : public ConcaveShape {
friend class PhysicsCommon;
};
-// Return the number of rows in the height field
-RP3D_FORCE_INLINE int HeightFieldShape::getNbRows() const {
- return mNbRows;
-}
-
-// Return the number of columns in the height field
-RP3D_FORCE_INLINE int HeightFieldShape::getNbColumns() const {
- return mNbColumns;
-}
-
-// Return the type of height value in the height field
-RP3D_FORCE_INLINE HeightFieldShape::HeightDataType HeightFieldShape::getHeightDataType() const {
- return mHeightDataType;
+// Return a pointer to the internal height-field
+RP3D_FORCE_INLINE HeightField* HeightFieldShape::getHeightField() const {
+ return mHeightField;
}
// Return the number of bytes used by the collision shape
@@ -190,24 +115,9 @@ RP3D_FORCE_INLINE size_t HeightFieldShape::getSizeInBytes() const {
return sizeof(HeightFieldShape);
}
-// Return the height of a given (x,y) point in the height field
-RP3D_FORCE_INLINE decimal HeightFieldShape::getHeightAt(int x, int y) const {
-
- assert(x >= 0 && x < mNbColumns);
- assert(y >= 0 && y < mNbRows);
-
- switch(mHeightDataType) {
- case HeightDataType::HEIGHT_FLOAT_TYPE : return decimal(((float*)mHeightFieldData)[y * mNbColumns + x]);
- case HeightDataType::HEIGHT_DOUBLE_TYPE : return decimal(((double*)mHeightFieldData)[y * mNbColumns + x]);
- case HeightDataType::HEIGHT_INT_TYPE : return decimal(((int*)mHeightFieldData)[y * mNbColumns + x] * mIntegerHeightScale);
- default: assert(false); return 0;
- }
-}
-
-// Compute the shape Id for a given triangle
-RP3D_FORCE_INLINE uint32 HeightFieldShape::computeTriangleShapeId(uint32 iIndex, uint32 jIndex, uint32 secondTriangleIncrement) const {
-
- return (jIndex * (mNbColumns - 1) + iIndex) * 2 + secondTriangleIncrement;
+// Return the vertex (local-coordinates) of the height field at a given (x,y) position
+RP3D_FORCE_INLINE Vector3 HeightFieldShape::getVertexAt(uint32 x, uint32 y) const {
+ return mHeightField->getVertexAt(x, y) * mScale;
}
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/SphereShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/SphereShape.h
index f06166d9c..f7382669d 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/SphereShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/SphereShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -29,12 +29,13 @@
// Libraries
#include
#include
+#include
// ReactPhysics3D namespace
namespace reactphysics3d {
// Declarations
-class CollisionBody;
+class Body;
// Class SphereShape
/**
@@ -88,7 +89,7 @@ class SphereShape : public ConvexShape {
virtual bool isPolyhedron() const override;
/// Return the local bounds of the shape in x, y and z directions.
- virtual void getLocalBounds(Vector3& min, Vector3& max) const override;
+ virtual AABB getLocalBounds() const override;
/// Return the local inertia tensor of the collision shape
virtual Vector3 getLocalInertiaTensor(decimal mass) const override;
@@ -96,8 +97,8 @@ class SphereShape : public ConvexShape {
/// Compute and return the volume of the collision shape
virtual decimal getVolume() const override;
- /// Update the AABB of a body using its collision shape
- virtual void computeAABB(AABB& aabb, const Transform& transform) const override;
+ /// Compute the transformed AABB
+ virtual AABB computeTransformedAABB(const Transform& transform) const override;
/// Return the string representation of the shape
virtual std::string to_string() const override;
@@ -154,20 +155,12 @@ RP3D_FORCE_INLINE Vector3 SphereShape::getLocalSupportPointWithoutMargin(const V
// Return the local bounds of the shape in x, y and z directions.
// This method is used to compute the AABB of the box
/**
- * @param min The minimum bounds of the shape in local-space coordinates
- * @param max The maximum bounds of the shape in local-space coordinates
+ * @return The AABB with the min/max bounds of the shape
*/
-RP3D_FORCE_INLINE void SphereShape::getLocalBounds(Vector3& min, Vector3& max) const {
+RP3D_FORCE_INLINE AABB SphereShape::getLocalBounds() const {
- // Maximum bounds
- max.x = mMargin;
- max.y = mMargin;
- max.z = mMargin;
-
- // Minimum bounds
- min.x = -mMargin;
- min.y = min.x;
- min.z = min.x;
+ return AABB(Vector3(-mMargin, -mMargin, -mMargin),
+ Vector3(mMargin, mMargin, mMargin));
}
// Return the local inertia tensor of the sphere
diff --git a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/TriangleShape.h b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/TriangleShape.h
index 3767b7aff..584eb4bee 100644
--- a/ext/reactphysics3d/include/reactphysics3d/collision/shapes/TriangleShape.h
+++ b/ext/reactphysics3d/include/reactphysics3d/collision/shapes/TriangleShape.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -28,6 +28,7 @@
// Libraries
#include
+#include
#include
/// ReactPhysics3D namespace
@@ -127,13 +128,13 @@ class TriangleShape : public ConvexPolyhedronShape {
TriangleShape& operator=(const TriangleShape& shape) = delete;
/// Return the local bounds of the shape in x, y and z directions.
- virtual void getLocalBounds(Vector3& min, Vector3& max) const override;
+ virtual AABB getLocalBounds() const override;
/// Return the local inertia tensor of the collision shape
virtual Vector3 getLocalInertiaTensor(decimal mass) const override;
- /// Update the AABB of a body using its collision shape
- virtual void computeAABB(AABB& aabb, const Transform& transform) const override;
+ /// Compute the transformed AABB of the collision shape given a transform
+ virtual AABB computeTransformedAABB(const Transform& transform) const override;
/// Return the raycast test type (front, back, front-back)
TriangleRaycastSide getRaycastTestType() const;
@@ -185,7 +186,7 @@ class TriangleShape : public ConvexPolyhedronShape {
friend class ConcaveMeshRaycastCallback;
friend class TriangleOverlapCallback;
friend class MiddlePhaseTriangleCallback;
- friend class HeightFieldShape;
+ friend class HeightField;
friend class CollisionDetectionSystem;
};
@@ -201,28 +202,27 @@ RP3D_FORCE_INLINE Vector3 TriangleShape::getLocalSupportPointWithoutMargin(const
}
// Return the local bounds of the shape in x, y and z directions.
-// This method is used to compute the AABB of the box
/**
- * @param min The minimum bounds of the shape in local-space coordinates
- * @param max The maximum bounds of the shape in local-space coordinates
+ * @return The AABB with the min/max bounds of the shape
*/
-RP3D_FORCE_INLINE void TriangleShape::getLocalBounds(Vector3& min, Vector3& max) const {
+RP3D_FORCE_INLINE AABB TriangleShape::getLocalBounds() const {
const Vector3 xAxis(mPoints[0].x, mPoints[1].x, mPoints[2].x);
const Vector3 yAxis(mPoints[0].y, mPoints[1].y, mPoints[2].y);
const Vector3 zAxis(mPoints[0].z, mPoints[1].z, mPoints[2].z);
- min.setAllValues(xAxis.getMinValue(), yAxis.getMinValue(), zAxis.getMinValue());
- max.setAllValues(xAxis.getMaxValue(), yAxis.getMaxValue(), zAxis.getMaxValue());
+ Vector3 min(xAxis.getMinValue(), yAxis.getMinValue(), zAxis.getMinValue());
+ Vector3 max(xAxis.getMaxValue(), yAxis.getMaxValue(), zAxis.getMaxValue());
min -= Vector3(mMargin, mMargin, mMargin);
max += Vector3(mMargin, mMargin, mMargin);
+
+ return AABB(min, max);
}
// Return the local inertia tensor of the triangle shape
/**
- * @param[out] tensor The 3x3 inertia tensor matrix of the shape in local-space
- * coordinates
* @param mass Mass to use to compute the inertia tensor of the collision shape
+ * @return A vector with the three diagonal values of the local inertia tensor
*/
RP3D_FORCE_INLINE Vector3 TriangleShape::getLocalInertiaTensor(decimal /*mass*/) const {
return Vector3(0, 0, 0);
diff --git a/ext/reactphysics3d/include/reactphysics3d/components/BallAndSocketJointComponents.h b/ext/reactphysics3d/include/reactphysics3d/components/BallAndSocketJointComponents.h
index dc6954746..654662f77 100644
--- a/ext/reactphysics3d/include/reactphysics3d/components/BallAndSocketJointComponents.h
+++ b/ext/reactphysics3d/include/reactphysics3d/components/BallAndSocketJointComponents.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -144,7 +144,7 @@ class BallAndSocketJointComponents : public Components {
virtual ~BallAndSocketJointComponents() override = default;
/// Add a component
- void addComponent(Entity jointEntity, bool isSleeping, const BallAndSocketJointComponent& component);
+ void addComponent(Entity jointEntity, bool isDisabled, const BallAndSocketJointComponent& component);
/// Return a pointer to a given joint
BallAndSocketJoint* getJoint(Entity jointEntity) const;
diff --git a/ext/reactphysics3d/include/reactphysics3d/components/CollisionBodyComponents.h b/ext/reactphysics3d/include/reactphysics3d/components/BodyComponents.h
similarity index 72%
rename from ext/reactphysics3d/include/reactphysics3d/components/CollisionBodyComponents.h
rename to ext/reactphysics3d/include/reactphysics3d/components/BodyComponents.h
index 282558c7e..3d59b8351 100644
--- a/ext/reactphysics3d/include/reactphysics3d/components/CollisionBodyComponents.h
+++ b/ext/reactphysics3d/include/reactphysics3d/components/BodyComponents.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -38,14 +38,14 @@ namespace reactphysics3d {
// Class declarations
class MemoryAllocator;
class EntityManager;
-class CollisionBody;
+class Body;
-// Class CollisionBodyComponents
+// Class BodyComponents
/**
- * This class represent the component of the ECS that contains data about a collision body.
+ * This class represent the component of the ECS that contains data about a body.
* The components of the sleeping entities (bodies) are always stored at the end of the array.
*/
-class CollisionBodyComponents : public Components {
+class BodyComponents : public Components {
private:
@@ -55,7 +55,7 @@ class CollisionBodyComponents : public Components {
Entity* mBodiesEntities;
/// Array of pointers to the corresponding bodies
- CollisionBody** mBodies;
+ Body** mBodies;
/// Array with the colliders of each body
Array* mColliders;
@@ -66,6 +66,9 @@ class CollisionBodyComponents : public Components {
/// Array of pointers that can be used to attach user data to the body
void** mUserData;
+ /// For each body, true if it has a least one simulation collider
+ bool* mHasSimulationCollider;
+
// -------------------- Methods -------------------- //
/// Allocate memory for a given number of components
@@ -83,12 +86,12 @@ class CollisionBodyComponents : public Components {
public:
/// Structure for the data of a collision body component
- struct CollisionBodyComponent {
+ struct BodyComponent {
- CollisionBody* body;
+ Body* body;
/// Constructor
- CollisionBodyComponent(CollisionBody* body) : body(body) {
+ BodyComponent(Body* body) : body(body) {
}
};
@@ -96,13 +99,13 @@ class CollisionBodyComponents : public Components {
// -------------------- Methods -------------------- //
/// Constructor
- CollisionBodyComponents(MemoryAllocator& allocator);
+ BodyComponents(MemoryAllocator& allocator);
/// Destructor
- virtual ~CollisionBodyComponents() override = default;
+ virtual ~BodyComponents() override = default;
/// Add a component
- void addComponent(Entity bodyEntity, bool isSleeping, const CollisionBodyComponent& component);
+ void addComponent(Entity bodyEntity, bool isDisabled, const BodyComponent& component);
/// Add a collider to a body component
void addColliderToBody(Entity bodyEntity, Entity colliderEntity);
@@ -111,7 +114,7 @@ class CollisionBodyComponents : public Components {
void removeColliderFromBody(Entity bodyEntity, Entity colliderEntity);
/// Return a pointer to a body
- CollisionBody* getBody(Entity bodyEntity);
+ Body* getBody(Entity bodyEntity);
/// Return the array of colliders of a body
const Array& getColliders(Entity bodyEntity) const;
@@ -127,10 +130,20 @@ class CollisionBodyComponents : public Components {
/// Set the user data associated with the body
void setUserData(Entity bodyEntity, void* userData) const;
+
+ /// Return true if the body has at least one simulation collider
+ bool getHasSimulationCollider(Entity bodyEntity) const;
+
+ /// Set whether the body has at least one simulation collider
+ void setHasSimulationCollider(Entity bodyEntity, bool hasSimulationCollider) const;
+
+ // -------------------- Friendship -------------------- //
+
+ friend class Body;
};
// Add a collider to a body component
-RP3D_FORCE_INLINE void CollisionBodyComponents::addColliderToBody(Entity bodyEntity, Entity colliderEntity) {
+RP3D_FORCE_INLINE void BodyComponents::addColliderToBody(Entity bodyEntity, Entity colliderEntity) {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@@ -138,7 +151,7 @@ RP3D_FORCE_INLINE void CollisionBodyComponents::addColliderToBody(Entity bodyEnt
}
// Remove a collider from a body component
-RP3D_FORCE_INLINE void CollisionBodyComponents::removeColliderFromBody(Entity bodyEntity, Entity colliderEntity) {
+RP3D_FORCE_INLINE void BodyComponents::removeColliderFromBody(Entity bodyEntity, Entity colliderEntity) {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@@ -146,7 +159,7 @@ RP3D_FORCE_INLINE void CollisionBodyComponents::removeColliderFromBody(Entity bo
}
// Return a pointer to a body
-RP3D_FORCE_INLINE CollisionBody *CollisionBodyComponents::getBody(Entity bodyEntity) {
+RP3D_FORCE_INLINE Body* BodyComponents::getBody(Entity bodyEntity) {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@@ -154,7 +167,7 @@ RP3D_FORCE_INLINE CollisionBody *CollisionBodyComponents::getBody(Entity bodyEnt
}
// Return the array of colliders of a body
-RP3D_FORCE_INLINE const Array& CollisionBodyComponents::getColliders(Entity bodyEntity) const {
+RP3D_FORCE_INLINE const Array& BodyComponents::getColliders(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@@ -162,7 +175,7 @@ RP3D_FORCE_INLINE const Array& CollisionBodyComponents::getColliders(Ent
}
// Return true if the body is active
-RP3D_FORCE_INLINE bool CollisionBodyComponents::getIsActive(Entity bodyEntity) const {
+RP3D_FORCE_INLINE bool BodyComponents::getIsActive(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@@ -170,7 +183,7 @@ RP3D_FORCE_INLINE bool CollisionBodyComponents::getIsActive(Entity bodyEntity) c
}
// Set the value to know if the body is active
-RP3D_FORCE_INLINE void CollisionBodyComponents::setIsActive(Entity bodyEntity, bool isActive) const {
+RP3D_FORCE_INLINE void BodyComponents::setIsActive(Entity bodyEntity, bool isActive) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@@ -178,7 +191,7 @@ RP3D_FORCE_INLINE void CollisionBodyComponents::setIsActive(Entity bodyEntity, b
}
// Return the user data associated with the body
-RP3D_FORCE_INLINE void* CollisionBodyComponents::getUserData(Entity bodyEntity) const {
+RP3D_FORCE_INLINE void* BodyComponents::getUserData(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@@ -186,13 +199,27 @@ RP3D_FORCE_INLINE void* CollisionBodyComponents::getUserData(Entity bodyEntity)
}
// Set the user data associated with the body
-RP3D_FORCE_INLINE void CollisionBodyComponents::setUserData(Entity bodyEntity, void* userData) const {
+RP3D_FORCE_INLINE void BodyComponents::setUserData(Entity bodyEntity, void* userData) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
mUserData[mMapEntityToComponentIndex[bodyEntity]] = userData;
}
+// Return true if the body has at least one simulation collider
+RP3D_FORCE_INLINE bool BodyComponents::getHasSimulationCollider(Entity bodyEntity) const {
+
+ assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
+ return mHasSimulationCollider[mMapEntityToComponentIndex[bodyEntity]];
+}
+
+// Set whether the body has at least one simulation collider
+RP3D_FORCE_INLINE void BodyComponents::setHasSimulationCollider(Entity bodyEntity, bool hasSimulationCollider) const {
+
+ assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
+ mHasSimulationCollider[mMapEntityToComponentIndex[bodyEntity]] = hasSimulationCollider;
+}
+
}
#endif
diff --git a/ext/reactphysics3d/include/reactphysics3d/components/ColliderComponents.h b/ext/reactphysics3d/include/reactphysics3d/components/ColliderComponents.h
index 32c013f87..6c793dcd7 100644
--- a/ext/reactphysics3d/include/reactphysics3d/components/ColliderComponents.h
+++ b/ext/reactphysics3d/include/reactphysics3d/components/ColliderComponents.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -100,10 +100,15 @@ class ColliderComponents : public Components {
/// True if the collider is a trigger
bool* mIsTrigger;
+ /// True if the collider is simulation collider
+ bool* mIsSimulationCollider;
+
+ /// True if the collider is a world query collider
+ bool* mIsWorldQueryCollider;
+
/// Array with the material of each collider
Material* mMaterials;
-
// -------------------- Methods -------------------- //
/// Allocate memory for a given number of components
@@ -153,7 +158,7 @@ class ColliderComponents : public Components {
virtual ~ColliderComponents() override = default;
/// Add a component
- void addComponent(Entity colliderEntity, bool isSleeping, const ColliderComponent& component);
+ void addComponent(Entity colliderEntity, bool isDisabled, const ColliderComponent& component);
/// Return the body entity of a given collider
Entity getBody(Entity colliderEntity) const;
@@ -209,6 +214,18 @@ class ColliderComponents : public Components {
/// Set whether a collider is a trigger
void setIsTrigger(Entity colliderEntity, bool isTrigger);
+ /// Return true if a collider is a simulation collider
+ bool getIsSimulationCollider(Entity colliderEntity) const;
+
+ /// Set whether a collider is a simulation collider
+ void setIsSimulationCollider(Entity colliderEntity, bool isSimulationCollider);
+
+ /// Return true if a collider is a world query collider
+ bool getIsWorldQueryCollider(Entity colliderEntity) const;
+
+ /// Set whether a collider is a world query collider
+ void setIsWorldQueryCollider(Entity colliderEntity, bool isWorldQueryCollider);
+
/// Return a reference to the material of a collider
Material& getMaterial(Entity colliderEntity);
@@ -370,6 +387,38 @@ RP3D_FORCE_INLINE void ColliderComponents::setIsTrigger(Entity colliderEntity, b
mIsTrigger[mMapEntityToComponentIndex[colliderEntity]] = isTrigger;
}
+// Return true if a collider is a simulation collider
+RP3D_FORCE_INLINE bool ColliderComponents::getIsSimulationCollider(Entity colliderEntity) const {
+
+ assert(mMapEntityToComponentIndex.containsKey(colliderEntity));
+
+ return mIsSimulationCollider[mMapEntityToComponentIndex[colliderEntity]];
+}
+
+// Set whether a collider is a simulation collider
+RP3D_FORCE_INLINE void ColliderComponents::setIsSimulationCollider(Entity colliderEntity, bool isSimulationCollider) {
+
+ assert(mMapEntityToComponentIndex.containsKey(colliderEntity));
+
+ mIsSimulationCollider[mMapEntityToComponentIndex[colliderEntity]] = isSimulationCollider;
+}
+
+// Return true if a collider is a world query collider
+RP3D_FORCE_INLINE bool ColliderComponents::getIsWorldQueryCollider(Entity colliderEntity) const {
+
+ assert(mMapEntityToComponentIndex.containsKey(colliderEntity));
+
+ return mIsWorldQueryCollider[mMapEntityToComponentIndex[colliderEntity]];
+}
+
+// Set whether a collider is a world query collider
+RP3D_FORCE_INLINE void ColliderComponents::setIsWorldQueryCollider(Entity colliderEntity, bool isWorldQueryCollider) {
+
+ assert(mMapEntityToComponentIndex.containsKey(colliderEntity));
+
+ mIsWorldQueryCollider[mMapEntityToComponentIndex[colliderEntity]] = isWorldQueryCollider;
+}
+
// Return a reference to the material of a collider
RP3D_FORCE_INLINE Material& ColliderComponents::getMaterial(Entity colliderEntity) {
diff --git a/ext/reactphysics3d/include/reactphysics3d/components/Components.h b/ext/reactphysics3d/include/reactphysics3d/components/Components.h
index 34cdd4dcc..1e41be5e8 100644
--- a/ext/reactphysics3d/include/reactphysics3d/components/Components.h
+++ b/ext/reactphysics3d/include/reactphysics3d/components/Components.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -63,6 +63,9 @@ class Components {
/// Size (in bytes) of a single component
size_t mComponentDataSize;
+ /// Size (in bytes) to allocate to make sure we can offset the components array to keep alignment
+ size_t mAlignmentMarginSize;
+
/// Number of allocated components
uint32 mNbAllocatedComponents;
@@ -77,7 +80,7 @@ class Components {
uint32 mDisabledStartIndex;
/// Compute the index where we need to insert the new component
- uint32 prepareAddComponent(bool isSleeping);
+ uint32 prepareAddComponent(bool isDisabled);
/// Allocate memory for a given number of components
virtual void allocate(uint32 nbComponentsToAllocate)=0;
@@ -96,11 +99,14 @@ class Components {
// -------------------- Methods -------------------- //
/// Constructor
- Components(MemoryAllocator& allocator, size_t componentDataSize);
+ Components(MemoryAllocator& allocator, size_t componentDataSize, size_t alignmentMarginSize);
/// Destructor
virtual ~Components();
+ /// Initialize the components:
+ void init();
+
/// Remove a component
void removeComponent(Entity entity);
@@ -137,7 +143,7 @@ RP3D_FORCE_INLINE bool Components::hasComponent(Entity entity) const {
return mMapEntityToComponentIndex.containsKey(entity);
}
-// Return true if there is a component for a given entiy and if so set the entity index
+// Return true if there is a component for a given entity and if so set the entity index
RP3D_FORCE_INLINE bool Components::hasComponentGetIndex(Entity entity, uint32& entityIndex) const {
auto it = mMapEntityToComponentIndex.find(entity);
diff --git a/ext/reactphysics3d/include/reactphysics3d/components/FixedJointComponents.h b/ext/reactphysics3d/include/reactphysics3d/components/FixedJointComponents.h
index eedbeda2a..f7236dcff 100644
--- a/ext/reactphysics3d/include/reactphysics3d/components/FixedJointComponents.h
+++ b/ext/reactphysics3d/include/reactphysics3d/components/FixedJointComponents.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -131,7 +131,7 @@ class FixedJointComponents : public Components {
virtual ~FixedJointComponents() override = default;
/// Add a component
- void addComponent(Entity jointEntity, bool isSleeping, const FixedJointComponent& component);
+ void addComponent(Entity jointEntity, bool isDisabled, const FixedJointComponent& component);
/// Return a pointer to a given joint
FixedJoint* getJoint(Entity jointEntity) const;
diff --git a/ext/reactphysics3d/include/reactphysics3d/components/HingeJointComponents.h b/ext/reactphysics3d/include/reactphysics3d/components/HingeJointComponents.h
index b4ecbedbb..f8177e12a 100644
--- a/ext/reactphysics3d/include/reactphysics3d/components/HingeJointComponents.h
+++ b/ext/reactphysics3d/include/reactphysics3d/components/HingeJointComponents.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -202,7 +202,7 @@ class HingeJointComponents : public Components {
virtual ~HingeJointComponents() override = default;
/// Add a component
- void addComponent(Entity jointEntity, bool isSleeping, const HingeJointComponent& component);
+ void addComponent(Entity jointEntity, bool isDisabled, const HingeJointComponent& component);
/// Return a pointer to a given joint
HingeJoint* getJoint(Entity jointEntity) const;
diff --git a/ext/reactphysics3d/include/reactphysics3d/components/JointComponents.h b/ext/reactphysics3d/include/reactphysics3d/components/JointComponents.h
index f593d2701..a79a254b9 100644
--- a/ext/reactphysics3d/include/reactphysics3d/components/JointComponents.h
+++ b/ext/reactphysics3d/include/reactphysics3d/components/JointComponents.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -120,7 +120,7 @@ class JointComponents : public Components {
virtual ~JointComponents() override = default;
/// Add a component
- void addComponent(Entity jointEntity, bool isSleeping, const JointComponent& component);
+ void addComponent(Entity jointEntity, bool isDisabled, const JointComponent& component);
/// Return the entity of the first body of a joint
Entity getBody1Entity(Entity jointEntity) const;
diff --git a/ext/reactphysics3d/include/reactphysics3d/components/RigidBodyComponents.h b/ext/reactphysics3d/include/reactphysics3d/components/RigidBodyComponents.h
index afe114b63..2443c832e 100644
--- a/ext/reactphysics3d/include/reactphysics3d/components/RigidBodyComponents.h
+++ b/ext/reactphysics3d/include/reactphysics3d/components/RigidBodyComponents.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -32,6 +32,8 @@
#include
#include
#include
+#include
+#include
// ReactPhysics3D namespace
namespace reactphysics3d {
@@ -196,7 +198,7 @@ class RigidBodyComponents : public Components {
virtual ~RigidBodyComponents() override = default;
/// Add a component
- void addComponent(Entity bodyEntity, bool isSleeping, const RigidBodyComponent& component);
+ void addComponent(Entity bodyEntity, bool isDisabled, const RigidBodyComponent& component);
/// Return a pointer to a rigid body
RigidBody* getRigidBody(Entity bodyEntity);
@@ -273,6 +275,9 @@ class RigidBodyComponents : public Components {
/// Return the inverse world inertia tensor of an entity
const Matrix3x3& getInertiaTensorWorldInverse(Entity bodyEntity);
+ /// Set the inverse world inertia tensor of an entity
+ void setInertiaTensorWorldInverse(Entity bodyEntity, const Matrix3x3& inertiaTensor);
+
/// Set the external force of an entity
void setExternalForce(Entity bodyEntity, const Vector3& externalForce);
@@ -372,6 +377,9 @@ class RigidBodyComponents : public Components {
/// A an associated contact pairs into the contact pairs array of the body
void addContacPair(Entity bodyEntity, uint32 contactPairIndex);
+ /// Remove all the contact pairs of a body
+ void removeAllContacPairs(Entity bodyEntity);
+
// -------------------- Friendship -------------------- //
friend class PhysicsWorld;
@@ -556,6 +564,14 @@ RP3D_FORCE_INLINE const Matrix3x3& RigidBodyComponents::getInertiaTensorWorldInv
return mInverseInertiaTensorsWorld[mMapEntityToComponentIndex[bodyEntity]];
}
+// Set the inverse world inertia tensor of an entity
+RP3D_FORCE_INLINE void RigidBodyComponents::setInertiaTensorWorldInverse(Entity bodyEntity, const Matrix3x3& inertiaTensor) {
+
+ assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
+
+ mInverseInertiaTensorsWorld[mMapEntityToComponentIndex[bodyEntity]] = inertiaTensor;
+}
+
// Set the external force of an entity
RP3D_FORCE_INLINE void RigidBodyComponents::setExternalForce(Entity bodyEntity, const Vector3& externalForce) {
@@ -846,6 +862,13 @@ RP3D_FORCE_INLINE void RigidBodyComponents::addContacPair(Entity bodyEntity, uin
mContactPairs[mMapEntityToComponentIndex[bodyEntity]].add(contactPairIndex);
}
+// Remove all the contact pairs of a body
+RP3D_FORCE_INLINE void RigidBodyComponents::removeAllContacPairs(Entity bodyEntity) {
+
+ assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
+ mContactPairs[mMapEntityToComponentIndex[bodyEntity]].clear();
+}
+
}
#endif
diff --git a/ext/reactphysics3d/include/reactphysics3d/components/SliderJointComponents.h b/ext/reactphysics3d/include/reactphysics3d/components/SliderJointComponents.h
index ff6842600..fecbed1b3 100644
--- a/ext/reactphysics3d/include/reactphysics3d/components/SliderJointComponents.h
+++ b/ext/reactphysics3d/include/reactphysics3d/components/SliderJointComponents.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -217,7 +217,7 @@ class SliderJointComponents : public Components {
virtual ~SliderJointComponents() override = default;
/// Add a component
- void addComponent(Entity jointEntity, bool isSleeping, const SliderJointComponent& component);
+ void addComponent(Entity jointEntity, bool isDisabled, const SliderJointComponent& component);
/// Return a pointer to a given joint
SliderJoint* getJoint(Entity jointEntity) const;
diff --git a/ext/reactphysics3d/include/reactphysics3d/components/TransformComponents.h b/ext/reactphysics3d/include/reactphysics3d/components/TransformComponents.h
index d4dc576b2..d9a1e7d37 100644
--- a/ext/reactphysics3d/include/reactphysics3d/components/TransformComponents.h
+++ b/ext/reactphysics3d/include/reactphysics3d/components/TransformComponents.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -93,7 +93,7 @@ class TransformComponents : public Components {
virtual ~TransformComponents() override = default;
/// Add a component
- void addComponent(Entity bodyEntity, bool isSleeping, const TransformComponent& component);
+ void addComponent(Entity bodyEntity, bool isDisabled, const TransformComponent& component);
/// Return the transform of an entity
Transform& getTransform(Entity bodyEntity) const;
diff --git a/ext/reactphysics3d/include/reactphysics3d/configuration.h b/ext/reactphysics3d/include/reactphysics3d/configuration.h
index 6281c93cc..1481c8497 100644
--- a/ext/reactphysics3d/include/reactphysics3d/configuration.h
+++ b/ext/reactphysics3d/include/reactphysics3d/configuration.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -33,9 +33,23 @@
#include
#include
#include
+#include
#include
#include
+// OS
+#if defined(_WIN32) || defined(_WIN64)
+ #define RP3D_PLATFORM_WINDOWS
+#elif defined(__APPLE__)
+ #define RP3D_PLATFORM_APPLE
+#elif defined(__ANDROID__)
+ #define RP3D_PLATFORM_ANDROID
+#elif defined(__linux__)
+ #define RP3D_PLATFORM_LINUX
+#else
+ #define RP3D_PLATFORM_UNKNOWN
+#endif
+
// Compilers
#if defined(_MSC_VER)
#define RP3D_COMPILER_VISUAL_STUDIO
@@ -76,6 +90,7 @@ using int64 = std::int64_t;
using uint64 = std::uint64_t;
struct Entity;
+
using bodypair = Pair;
// ------------------- Enumerations ------------------- //
@@ -119,19 +134,22 @@ constexpr decimal DYNAMIC_TREE_FAT_AABB_INFLATE_PERCENTAGE = decimal(0.08);
constexpr uint8 NB_MAX_CONTACT_POINTS_IN_NARROWPHASE_INFO = 16;
/// Maximum number of contact manifolds in an overlapping pair
-constexpr uint8 NB_MAX_CONTACT_MANIFOLDS = 3;
+constexpr uint8 NB_MAX_CONTACT_MANIFOLDS = 4;
/// Maximum number of potential contact manifolds in an overlapping pair
-constexpr uint8 NB_MAX_POTENTIAL_CONTACT_MANIFOLDS = 4 * NB_MAX_CONTACT_MANIFOLDS;
+constexpr uint8 NB_MAX_POTENTIAL_CONTACT_MANIFOLDS = 64;
/// Maximum number of contact points in potential contact manifold
-constexpr uint16 NB_MAX_CONTACT_POINTS_IN_POTENTIAL_MANIFOLD = 256;
+constexpr uint8 NB_MAX_CONTACT_POINTS_IN_POTENTIAL_MANIFOLD = 255;
/// Distance threshold to consider that two contact points in a manifold are the same
constexpr decimal SAME_CONTACT_POINT_DISTANCE_THRESHOLD = decimal(0.01);
+/// Global alignment (in bytes) that all allocators must enforce
+constexpr uint8 GLOBAL_ALIGNMENT = 16;
+
/// Current version of ReactPhysics3D
-const std::string RP3D_VERSION = std::string("0.9.0");
+const std::string RP3D_VERSION = std::string("0.10.1");
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/constraint/BallAndSocketJoint.h b/ext/reactphysics3d/include/reactphysics3d/constraint/BallAndSocketJoint.h
index 9f37ef3e6..915b1124f 100644
--- a/ext/reactphysics3d/include/reactphysics3d/constraint/BallAndSocketJoint.h
+++ b/ext/reactphysics3d/include/reactphysics3d/constraint/BallAndSocketJoint.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/constraint/ContactPoint.h b/ext/reactphysics3d/include/reactphysics3d/constraint/ContactPoint.h
index fcbcb1583..281ebb19e 100644
--- a/ext/reactphysics3d/include/reactphysics3d/constraint/ContactPoint.h
+++ b/ext/reactphysics3d/include/reactphysics3d/constraint/ContactPoint.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -35,7 +35,7 @@
namespace reactphysics3d {
// Declarations
-class CollisionBody;
+class Body;
// Class ContactPoint
/**
diff --git a/ext/reactphysics3d/include/reactphysics3d/constraint/FixedJoint.h b/ext/reactphysics3d/include/reactphysics3d/constraint/FixedJoint.h
index b020230e2..a3b2543af 100644
--- a/ext/reactphysics3d/include/reactphysics3d/constraint/FixedJoint.h
+++ b/ext/reactphysics3d/include/reactphysics3d/constraint/FixedJoint.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/constraint/HingeJoint.h b/ext/reactphysics3d/include/reactphysics3d/constraint/HingeJoint.h
index 8c1e8c452..71b4b249b 100644
--- a/ext/reactphysics3d/include/reactphysics3d/constraint/HingeJoint.h
+++ b/ext/reactphysics3d/include/reactphysics3d/constraint/HingeJoint.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/constraint/Joint.h b/ext/reactphysics3d/include/reactphysics3d/constraint/Joint.h
index 0e2c62f10..77e5a7481 100644
--- a/ext/reactphysics3d/include/reactphysics3d/constraint/Joint.h
+++ b/ext/reactphysics3d/include/reactphysics3d/constraint/Joint.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/constraint/SliderJoint.h b/ext/reactphysics3d/include/reactphysics3d/constraint/SliderJoint.h
index a0eb557bf..142eeaa36 100644
--- a/ext/reactphysics3d/include/reactphysics3d/constraint/SliderJoint.h
+++ b/ext/reactphysics3d/include/reactphysics3d/constraint/SliderJoint.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/containers/Array.h b/ext/reactphysics3d/include/reactphysics3d/containers/Array.h
index 89801ca13..b7f064558 100755
--- a/ext/reactphysics3d/include/reactphysics3d/containers/Array.h
+++ b/ext/reactphysics3d/include/reactphysics3d/containers/Array.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -95,19 +95,19 @@ class Array {
/// Deferencable
reference operator*() {
- assert(mCurrentIndex >= 0 && mCurrentIndex < mSize);
+ assert(mCurrentIndex < mSize);
return mBuffer[mCurrentIndex];
}
/// Const Deferencable
const_reference operator*() const {
- assert(mCurrentIndex >= 0 && mCurrentIndex < mSize);
+ assert(mCurrentIndex < mSize);
return mBuffer[mCurrentIndex];
}
/// Deferencable
const_pointer operator->() const {
- assert(mCurrentIndex >= 0 && mCurrentIndex < mSize);
+ assert(mCurrentIndex < mSize);
return &(mBuffer[mCurrentIndex]);
}
@@ -190,7 +190,7 @@ class Array {
/// Equality operator (it == end())
bool operator==(const Iterator& iterator) const {
- assert(mCurrentIndex >= 0 && mCurrentIndex <= mSize);
+ assert(mCurrentIndex <= mSize);
// If both iterators points to the end of the array
if (mCurrentIndex == mSize && iterator.mCurrentIndex == iterator.mSize) {
@@ -251,6 +251,9 @@ class Array {
if (capacity <= mCapacity) return;
+ // Make sure capacity is an integral multiple of alignment
+ capacity = std::ceil(capacity / float(GLOBAL_ALIGNMENT)) * GLOBAL_ALIGNMENT;
+
// Allocate memory for the new array
void* newMemory = mAllocator.allocate(capacity * sizeof(T));
T* destination = static_cast(newMemory);
@@ -283,7 +286,7 @@ class Array {
// If we need to allocate more memory
if (mSize == mCapacity) {
- reserve(mCapacity == 0 ? 1 : mCapacity * 2);
+ reserve(mCapacity == 0 ? GLOBAL_ALIGNMENT : mCapacity * 2);
}
// Use the constructor to construct the element
@@ -298,7 +301,7 @@ class Array {
// If we need to allocate more memory
if (mSize == mCapacity) {
- reserve(mCapacity == 0 ? 1 : mCapacity * 2);
+ reserve(mCapacity == 0 ? GLOBAL_ALIGNMENT : mCapacity * 2);
}
// Construct the element directly at its location in the array
@@ -433,13 +436,13 @@ class Array {
/// Overloaded index operator
T& operator[](const uint64 index) {
- assert(index >= 0 && index < mSize);
+ assert(index < mSize);
return mBuffer[index];
}
/// Overloaded const index operator
const T& operator[](const uint64 index) const {
- assert(index >= 0 && index < mSize);
+ assert(index < mSize);
return mBuffer[index];
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/containers/Deque.h b/ext/reactphysics3d/include/reactphysics3d/containers/Deque.h
index 8c4f55e2c..2a7977b14 100644
--- a/ext/reactphysics3d/include/reactphysics3d/containers/Deque.h
+++ b/ext/reactphysics3d/include/reactphysics3d/containers/Deque.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -52,36 +52,19 @@ class Deque {
private:
- // -------------------- Constants -------------------- //
-
- /// Number of items in a chunk
- const uint8 CHUNK_NB_ITEMS = 17;
-
- /// First item index in a chunk
- const uint8 CHUNK_FIRST_ITEM_INDEX = CHUNK_NB_ITEMS / 2;
-
// -------------------- Attributes -------------------- //
- /// Array of chunks
- T** mChunks;
+ /// Buffer of elements
+ T* mBuffer;
/// Number of current elements in the deque
uint64 mSize;
- /// Number of chunks
- uint64 mNbChunks;
-
- /// Index of the chunk with the first element of the deque
- uint64 mFirstChunkIndex;
+ /// Capacity
+ uint64 mCapacity;
- /// Index of the chunk with the last element of the deque
- uint64 mLastChunkIndex;
-
- /// Index of the first element in the first chunk
- uint8 mFirstItemIndex;
-
- /// Index of the last element in the last chunk
- uint8 mLastItemIndex;
+ /// Index in the buffer of the first item of the deque
+ uint64 mFirstItemIndex;
/// Memory allocator
MemoryAllocator& mAllocator;
@@ -89,87 +72,52 @@ class Deque {
// -------------------- Methods -------------------- //
/// Return a reference to an item at the given virtual index in range [0; mSize-1]
- T& getItem(uint64 virtualIndex) const {
-
- // If the virtual index is valid
- if (virtualIndex < mSize) {
+ T& getItem(uint64 index) const {
- uint64 chunkIndex = mFirstChunkIndex;
- uint64 itemIndex = mFirstItemIndex;
+ // Ensure the virtual index is valid
+ assert(index < mSize);
- const uint64 nbItemsFirstChunk = CHUNK_NB_ITEMS - mFirstItemIndex;
- if (virtualIndex < nbItemsFirstChunk) {
- itemIndex += virtualIndex;
- }
- else {
-
- virtualIndex -= nbItemsFirstChunk;
- chunkIndex++;
-
- chunkIndex += virtualIndex / CHUNK_NB_ITEMS;
- itemIndex = virtualIndex % CHUNK_NB_ITEMS;
- }
-
- return mChunks[chunkIndex][itemIndex];
- }
- else {
- assert(false);
- }
+ return mBuffer[mFirstItemIndex + index];
}
/// Add more chunks
- void expandChunks(uint64 atLeastNbChunks = 0) {
+ void reserve(uint64 capacity) {
- // If it is not necessary to expand the chunks
- if (atLeastNbChunks > 0 && atLeastNbChunks <= mNbChunks) {
- return;
- }
+ if (capacity <= mCapacity) return;
- uint64 newNbChunks = mNbChunks == 0 ? 3 : 2 * mNbChunks - 1;
- if (atLeastNbChunks > 0 && newNbChunks < atLeastNbChunks) {
- newNbChunks = uint64(atLeastNbChunks / 2) * 2 + 1;
- }
- const uint64 halfNbChunksToAdd = mNbChunks == 0 ? 1 : (mNbChunks - 1) / 2;
+ // Make sure capacity is an integral multiple of alignment
+ capacity = std::ceil(capacity / float(GLOBAL_ALIGNMENT)) * GLOBAL_ALIGNMENT;
- // Allocate memory for the new array of pointers to chunk
- void* newMemory = mAllocator.allocate(newNbChunks * sizeof(T*));
- assert(newMemory != nullptr);
- T** newChunks = static_cast(newMemory);
+ // Allocate memory for the new array
+ void* newMemory = mAllocator.allocate(capacity * sizeof(T));
+ T* destination = static_cast(newMemory);
- // If chunks have already been allocated
- if (mNbChunks > 0) {
+ const uint64 newStartIndex = capacity / 2 - 1;
- // Copy the pointers to the previous chunks to the new allocated memory location
- std::uninitialized_copy(mChunks, mChunks + mNbChunks, newChunks + halfNbChunksToAdd);
+ if (mBuffer != nullptr) {
- // Release the previously allocated memory
- mAllocator.release(mChunks, mNbChunks * sizeof(T*));
- }
+ if (mSize > 0) {
- mChunks = newChunks;
+ // Copy the elements to the new allocated memory location
+ std::uninitialized_copy(mBuffer + mFirstItemIndex, mBuffer + mFirstItemIndex + mSize, destination + newStartIndex);
- // If we need to allocate the first chunk (in the middle of the chunks array)
- if (mNbChunks == 0) {
- mChunks[newNbChunks / 2] = static_cast(mAllocator.allocate(sizeof(T) * CHUNK_NB_ITEMS));
- assert(mChunks[newNbChunks / 2] != nullptr);
- }
-
- mNbChunks = newNbChunks;
+ // Destruct the previous items
+ for (uint64 i=0; i < mSize; i++) {
+ mBuffer[mFirstItemIndex + i].~T();
+ }
+ }
- // Allocate memory for each new chunk
- for (uint64 i=0; i < halfNbChunksToAdd; i++) {
+ // Release the previously allocated memory
+ mAllocator.release(mBuffer, mCapacity * sizeof(T));
+ }
- // Allocate memory for the new chunk
- mChunks[i] = static_cast(mAllocator.allocate(sizeof(T) * CHUNK_NB_ITEMS));
- assert(mChunks[i] != nullptr);
+ mBuffer = destination;
+ assert(mBuffer != nullptr);
- mChunks[mNbChunks - 1 - i] = static_cast(mAllocator.allocate(sizeof(T) * CHUNK_NB_ITEMS));
- assert(mChunks[mNbChunks - 1 -i] != nullptr);
- }
+ mCapacity = capacity;
// Update the first and last chunk index
- mFirstChunkIndex += halfNbChunksToAdd;
- mLastChunkIndex += halfNbChunksToAdd;
+ mFirstItemIndex = newStartIndex;
}
public:
@@ -197,7 +145,7 @@ class Deque {
using iterator_category = std::random_access_iterator_tag;
/// Constructor
- Iterator(const Deque* deque, uint64 virtualIndex) : mVirtualIndex(virtualIndex), mDeque(deque) {
+ Iterator(const Deque* deque, uint64 index) : mVirtualIndex(index), mDeque(deque) {
}
@@ -318,35 +266,28 @@ class Deque {
/// Constructor
Deque(MemoryAllocator& allocator)
- : mChunks(nullptr), mSize(0), mNbChunks(0), mFirstChunkIndex(1),
- mLastChunkIndex(1), mFirstItemIndex(CHUNK_FIRST_ITEM_INDEX),
- mLastItemIndex(CHUNK_FIRST_ITEM_INDEX), mAllocator(allocator) {
+ : mBuffer(nullptr), mSize(0), mCapacity(0), mFirstItemIndex(0), mAllocator(allocator) {
- // Allocate memory for the chunks array
- expandChunks();
}
/// Copy constructor
Deque(const Deque& deque)
- : mSize(0), mNbChunks(0), mFirstChunkIndex(1),
- mLastChunkIndex(1), mFirstItemIndex(CHUNK_FIRST_ITEM_INDEX),
- mLastItemIndex(CHUNK_FIRST_ITEM_INDEX), mAllocator(deque.mAllocator) {
+ : mBuffer(nullptr), mSize(0), mCapacity(0), mFirstItemIndex(deque.mFirstItemIndex),
+ mAllocator(deque.mAllocator) {
- // Allocate memory for the array of chunks
- expandChunks(deque.mNbChunks);
+ // Allocate memory
+ reserve(deque.mCapacity);
if (deque.mSize > 0) {
- const uint64 dequeHalfSize1 = std::ceil(deque.mSize / 2.0f);
- const uint64 dequeHalfSize2 = deque.mSize - dequeHalfSize1;
-
// Add the items into the deque
- for(uint64 i=0; i < dequeHalfSize1; i++) {
- addFront(deque[dequeHalfSize1 - 1 - i]);
- }
- for(uint64 i=0; i < dequeHalfSize2; i++) {
- addBack(deque[dequeHalfSize1 + i]);
+ for(uint64 i=0; i < deque.mSize; i++) {
+
+ // Construct the element at its location in the buffer
+ new (static_cast(&(mBuffer[deque.mFirstItemIndex + i]))) T(deque.mBuffer[deque.mFirstItemIndex + i]);
}
+
+ mSize = deque.mSize;
}
}
@@ -355,76 +296,58 @@ class Deque {
clear();
- // Release each chunk
- for (uint64 i=0; i < mNbChunks; i++) {
+ if (mCapacity > 0) {
- mAllocator.release(mChunks[i], sizeof(T) * CHUNK_NB_ITEMS);
+ assert(mBuffer != nullptr);
+
+ // Release the chunks array
+ mAllocator.release(mBuffer, sizeof(T) * mCapacity);
}
- // Release the chunks array
- mAllocator.release(mChunks, sizeof(T*) * mNbChunks);
+ mCapacity = 0;
+ mBuffer = nullptr;
}
/// Add an element at the end of the deque
void addBack(const T& element) {
// If we need to add the item in a another chunk
- if (mLastItemIndex == CHUNK_NB_ITEMS - 1) {
-
- // If we need to add more chunks
- if (mLastChunkIndex == mNbChunks - 1) {
+ if (mFirstItemIndex + mSize >= mCapacity) {
- // Add more chunks
- expandChunks();
- }
-
- mLastItemIndex = 0;
- mLastChunkIndex++;
- }
- else if (mSize != 0) {
- mLastItemIndex++;
+ reserve(mCapacity == 0 ? GLOBAL_ALIGNMENT : mCapacity * 2);
}
+ assert(mFirstItemIndex + mSize < mCapacity);
+
// Construct the element at its location in the chunk
- new (static_cast(&(mChunks[mLastChunkIndex][mLastItemIndex]))) T(element);
+ new (static_cast(&(mBuffer[mFirstItemIndex + mSize]))) T(element);
mSize++;
- assert(mFirstChunkIndex >= 0 && mLastChunkIndex < mNbChunks);
- assert(mFirstItemIndex >= 0 && mFirstItemIndex < CHUNK_NB_ITEMS);
- assert(mLastItemIndex >= 0 && mLastItemIndex < CHUNK_NB_ITEMS);
- assert(mFirstChunkIndex <= mLastChunkIndex);
+ assert(mFirstItemIndex + mSize <= mCapacity);
+ assert(mSize <= mCapacity);
}
/// Add an element at the front of the deque
void addFront(const T& element) {
- // If we need to add the item in another chunk
+ // If we need to add the item in a another chunk
if (mFirstItemIndex == 0) {
- // If we need to add more chunks
- if (mFirstChunkIndex == 0) {
+ reserve(mCapacity == 0 ? GLOBAL_ALIGNMENT : mCapacity * 2);
+ }
- // Add more chunks
- expandChunks();
- }
+ assert(mFirstItemIndex > 0);
- mFirstItemIndex = CHUNK_NB_ITEMS - 1;
- mFirstChunkIndex--;
- }
- else if (mSize != 0) {
- mFirstItemIndex--;
- }
+ mFirstItemIndex--;
// Construct the element at its location in the chunk
- new (static_cast(&(mChunks[mFirstChunkIndex][mFirstItemIndex]))) T(element);
+ new (static_cast(&(mBuffer[mFirstItemIndex]))) T(element);
mSize++;
- assert(mFirstChunkIndex >= 0 && mLastChunkIndex < mNbChunks);
- assert(mFirstItemIndex >= 0 && mFirstItemIndex < CHUNK_NB_ITEMS);
- assert(mLastItemIndex >= 0 && mLastItemIndex < CHUNK_NB_ITEMS);
- assert(mFirstChunkIndex <= mLastChunkIndex);
+ assert(mFirstItemIndex + mSize <= mCapacity);
+ assert(mSize <= mCapacity);
}
/// Remove the first element of the deque
@@ -433,28 +356,17 @@ class Deque {
if (mSize > 0) {
// Call the destructor of the first element
- mChunks[mFirstChunkIndex][mFirstItemIndex].~T();
+ mBuffer[mFirstItemIndex].~T();
mSize--;
+ mFirstItemIndex++;
if (mSize == 0) {
- mFirstChunkIndex = mNbChunks / 2;
- mFirstItemIndex = CHUNK_FIRST_ITEM_INDEX;
- mLastChunkIndex = mFirstChunkIndex;
- mLastItemIndex = CHUNK_FIRST_ITEM_INDEX;
- }
- else if (mFirstItemIndex == CHUNK_NB_ITEMS - 1){
- mFirstChunkIndex++;
- mFirstItemIndex = 0;
- }
- else {
- mFirstItemIndex++;
+ mFirstItemIndex = mCapacity / 2 - 1;
}
- assert(mFirstChunkIndex >= 0 && mLastChunkIndex < mNbChunks);
- assert(mFirstItemIndex >= 0 && mFirstItemIndex < CHUNK_NB_ITEMS);
- assert(mLastItemIndex >= 0 && mLastItemIndex < CHUNK_NB_ITEMS);
- assert(mFirstChunkIndex <= mLastChunkIndex);
+ assert(mFirstItemIndex + mSize <= mCapacity);
+ assert(mSize <= mCapacity);
}
}
@@ -464,41 +376,29 @@ class Deque {
if (mSize > 0) {
// Call the destructor of the last element
- mChunks[mLastChunkIndex][mLastItemIndex].~T();
+ mBuffer[mFirstItemIndex + mSize - 1].~T();
mSize--;
if (mSize == 0) {
- mFirstChunkIndex = mNbChunks / 2;
- mFirstItemIndex = CHUNK_FIRST_ITEM_INDEX;
- mLastChunkIndex = mFirstChunkIndex;
- mLastItemIndex = CHUNK_FIRST_ITEM_INDEX;
- }
- else if (mLastItemIndex == 0){
- mLastChunkIndex--;
- mLastItemIndex = CHUNK_NB_ITEMS - 1;
- }
- else {
- mLastItemIndex--;
+ mFirstItemIndex = mCapacity / 2 - 1;
}
- assert(mFirstChunkIndex >= 0 && mLastChunkIndex < mNbChunks);
- assert(mFirstItemIndex >= 0 && mFirstItemIndex < CHUNK_NB_ITEMS);
- assert(mLastItemIndex >= 0 && mLastItemIndex < CHUNK_NB_ITEMS);
- assert(mFirstChunkIndex <= mLastChunkIndex);
+ assert(mFirstItemIndex + mSize <= mCapacity);
+ assert(mSize <= mCapacity);
}
}
/// Return a reference to the first item of the deque
const T& getFront() const {
assert(mSize > 0);
- return mChunks[mFirstChunkIndex][mFirstItemIndex];
+ return mBuffer[mFirstItemIndex];
}
/// Return a reference to the last item of the deque
const T& getBack() const {
assert(mSize > 0);
- return mChunks[mLastChunkIndex][mLastItemIndex];
+ return mBuffer[mFirstItemIndex + mSize - 1];
}
/// Clear the elements of the deque
@@ -512,11 +412,7 @@ class Deque {
}
mSize = 0;
-
- mFirstChunkIndex = mNbChunks / 2;
- mLastChunkIndex = mFirstChunkIndex;
- mFirstItemIndex = CHUNK_FIRST_ITEM_INDEX;
- mLastItemIndex = CHUNK_FIRST_ITEM_INDEX;
+ mFirstItemIndex = mCapacity / 2 - 1;
}
}
@@ -565,27 +461,25 @@ class Deque {
// Clear all the elements
clear();
- if (deque.mSize > 0) {
-
- // Number of used chunks
- const uint64 nbUsedChunks = deque.mLastChunkIndex - deque.mFirstChunkIndex + 1;
-
- // Expand the chunk if necessary
- expandChunks(nbUsedChunks);
+ reserve(deque.mCapacity);
- const uint64 dequeHalfSize1 = std::ceil(deque.mSize / 2.0f);
- const uint64 dequeHalfSize2 = deque.mSize - dequeHalfSize1;
+ if (deque.mSize > 0) {
// Add the items into the deque
- for(uint64 i=0; i < dequeHalfSize1; i++) {
- addFront(deque[dequeHalfSize1 - 1 - i]);
- }
- for(uint64 i=0; i < dequeHalfSize2; i++) {
- addBack(deque[dequeHalfSize1 + i]);
+ for(uint64 i=0; i < deque.mSize; i++) {
+
+ // Construct the element at its location in the buffer
+ new (static_cast(&(mBuffer[mFirstItemIndex + i]))) T(deque.mBuffer[deque.mFirstItemIndex + i]);
}
+
}
+
+ mSize = deque.mSize;
}
+ assert(mFirstItemIndex + mSize <= mCapacity);
+ assert(mSize <= mCapacity);
+
return *this;
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/containers/LinkedList.h b/ext/reactphysics3d/include/reactphysics3d/containers/LinkedList.h
index bf6a3066a..391073819 100644
--- a/ext/reactphysics3d/include/reactphysics3d/containers/LinkedList.h
+++ b/ext/reactphysics3d/include/reactphysics3d/containers/LinkedList.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -66,6 +66,9 @@ class LinkedList {
/// Memory allocator used to allocate the list elements
MemoryAllocator& mAllocator;
+ /// Size to allocate for a single element
+ size_t mElementAllocationSize;
+
public:
// -------------------- Methods -------------------- //
@@ -73,6 +76,8 @@ class LinkedList {
/// Constructor
LinkedList(MemoryAllocator& allocator) : mListHead(nullptr), mAllocator(allocator) {
+ // Make sure capacity is an integral multiple of alignment
+ mElementAllocationSize = std::ceil(sizeof(ListElement) / float(GLOBAL_ALIGNMENT)) * GLOBAL_ALIGNMENT;
}
/// Destructor
@@ -88,7 +93,6 @@ class LinkedList {
/// Remove all the elements of the list
void reset();
-
};
// Return the first element of the list
@@ -100,7 +104,8 @@ RP3D_FORCE_INLINE typename LinkedList::ListElement* LinkedList::getListHea
// Insert an element at the beginning of the linked list
template
RP3D_FORCE_INLINE void LinkedList::insert(const T& data) {
- ListElement* element = new (mAllocator.allocate(sizeof(ListElement))) ListElement(data, mListHead);
+
+ ListElement* element = new (mAllocator.allocate(mElementAllocationSize)) ListElement(data, mListHead);
mListHead = element;
}
@@ -112,7 +117,7 @@ RP3D_FORCE_INLINE void LinkedList::reset() {
ListElement* element = mListHead;
while (element != nullptr) {
ListElement* nextElement = element->next;
- mAllocator.release(element, sizeof(ListElement));
+ mAllocator.release(element, mElementAllocationSize);
element = nextElement;
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/containers/Map.h b/ext/reactphysics3d/include/reactphysics3d/containers/Map.h
index aadf9fa6e..4aaee4b09 100755
--- a/ext/reactphysics3d/include/reactphysics3d/containers/Map.h
+++ b/ext/reactphysics3d/include/reactphysics3d/containers/Map.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -276,8 +276,12 @@ class Map {
uint64* newBuckets = static_cast(mAllocator.allocate(capacity * sizeof(uint64)));
// Allocate memory for the entries
- const uint64 nbAllocatedEntries = static_cast(capacity * double(DEFAULT_LOAD_FACTOR));
+ uint64 nbAllocatedEntries = static_cast(capacity * double(DEFAULT_LOAD_FACTOR));
assert(nbAllocatedEntries > 0);
+
+ // Make sure capacity is an integral multiple of alignment
+ nbAllocatedEntries = std::ceil(nbAllocatedEntries / float(GLOBAL_ALIGNMENT)) * GLOBAL_ALIGNMENT;
+
Pair* newEntries = static_cast*>(mAllocator.allocate(nbAllocatedEntries * sizeof(Pair)));
uint64* newNextEntries = static_cast(mAllocator.allocate(nbAllocatedEntries * sizeof(uint64)));
@@ -383,7 +387,6 @@ class Map {
}
else {
assert(false);
- throw std::runtime_error("The key and value pair already exists in the map");
}
}
}
@@ -567,10 +570,7 @@ class Map {
const uint64 entry = findEntry(key);
- if (entry == INVALID_INDEX) {
- assert(false);
- throw std::runtime_error("No item with given key has been found in the map");
- }
+ assert(entry != INVALID_INDEX);
return mEntries[entry].second;
}
@@ -580,10 +580,7 @@ class Map {
const uint64 entry = findEntry(key);
- if (entry == INVALID_INDEX) {
- assert(false);
- throw std::runtime_error("No item with given key has been found in the map");
- }
+ assert(entry != INVALID_INDEX);
return mEntries[entry].second;
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/containers/Pair.h b/ext/reactphysics3d/include/reactphysics3d/containers/Pair.h
index b69f465d9..ee26b1a5a 100644
--- a/ext/reactphysics3d/include/reactphysics3d/containers/Pair.h
+++ b/ext/reactphysics3d/include/reactphysics3d/containers/Pair.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -27,8 +27,6 @@
#define REACTPHYSICS3D_PAIR_H
// Libraries
-#include
-#include
#include
#include
#include
@@ -72,9 +70,9 @@ class Pair {
}
-// Hash function for a reactphysics3d Pair
namespace std {
+ // Hash function for a reactphysics3d Pair
template struct hash> {
size_t operator()(const reactphysics3d::Pair& pair) const {
diff --git a/ext/reactphysics3d/include/reactphysics3d/containers/Set.h b/ext/reactphysics3d/include/reactphysics3d/containers/Set.h
index 34129ffb5..ea894ab67 100755
--- a/ext/reactphysics3d/include/reactphysics3d/containers/Set.h
+++ b/ext/reactphysics3d/include/reactphysics3d/containers/Set.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -275,8 +275,12 @@ class Set {
uint64* newBuckets = static_cast(mAllocator.allocate(capacity * sizeof(uint64)));
// Allocate memory for the entries
- const uint64 nbAllocatedEntries = static_cast(capacity * double(DEFAULT_LOAD_FACTOR));
+ uint64 nbAllocatedEntries = static_cast(capacity * double(DEFAULT_LOAD_FACTOR));
assert(nbAllocatedEntries > 0);
+
+ // Make sure capacity is an integral multiple of alignment
+ nbAllocatedEntries = std::ceil(nbAllocatedEntries / float(GLOBAL_ALIGNMENT)) * GLOBAL_ALIGNMENT;
+
V* newEntries = static_cast(mAllocator.allocate(nbAllocatedEntries * sizeof(V)));
uint64* newNextEntries = static_cast(mAllocator.allocate(nbAllocatedEntries * sizeof(uint64)));
@@ -470,7 +474,7 @@ class Set {
/// Return an array with all the values of the set
Array toArray(MemoryAllocator& arrayAllocator) const {
- Array array(arrayAllocator);
+ Array array(arrayAllocator, size());
for (auto it = begin(); it != end(); ++it) {
array.add(*it);
diff --git a/ext/reactphysics3d/include/reactphysics3d/containers/Stack.h b/ext/reactphysics3d/include/reactphysics3d/containers/Stack.h
index 2919a7b0e..cdbe26ffa 100644
--- a/ext/reactphysics3d/include/reactphysics3d/containers/Stack.h
+++ b/ext/reactphysics3d/include/reactphysics3d/containers/Stack.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -61,6 +61,9 @@ class Stack {
/// Allocate more memory
void allocate(uint64 capacity) {
+ // Make sure capacity is an integral multiple of alignment
+ capacity = std::ceil(capacity / float(GLOBAL_ALIGNMENT)) * GLOBAL_ALIGNMENT;
+
T* newArray = static_cast(mAllocator.allocate(capacity * sizeof(T)));
assert(newArray != nullptr);
@@ -168,6 +171,14 @@ class Stack {
return item;
}
+ /// Return the top element of the stack
+ T& top() {
+
+ assert(mNbElements > 0);
+
+ return mArray[mNbElements-1];
+ }
+
/// Return the number of items in the stack
uint64 size() const {
return mNbElements;
diff --git a/ext/reactphysics3d/include/reactphysics3d/containers/containers_common.h b/ext/reactphysics3d/include/reactphysics3d/containers/containers_common.h
index 74da7cf12..e8ae38b40 100644
--- a/ext/reactphysics3d/include/reactphysics3d/containers/containers_common.h
+++ b/ext/reactphysics3d/include/reactphysics3d/containers/containers_common.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -29,7 +29,6 @@
// Libraries
#include
#include
-#include
namespace reactphysics3d {
diff --git a/ext/reactphysics3d/include/reactphysics3d/decimal.h b/ext/reactphysics3d/include/reactphysics3d/decimal.h
index c501fc3fb..ef15a5ab6 100644
--- a/ext/reactphysics3d/include/reactphysics3d/decimal.h
+++ b/ext/reactphysics3d/include/reactphysics3d/decimal.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/engine/Entity.h b/ext/reactphysics3d/include/reactphysics3d/engine/Entity.h
index 9b4181c4e..cf4535606 100644
--- a/ext/reactphysics3d/include/reactphysics3d/engine/Entity.h
+++ b/ext/reactphysics3d/include/reactphysics3d/engine/Entity.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -125,9 +125,9 @@ RP3D_FORCE_INLINE bool Entity::operator!=(const Entity& entity) const {
}
-// Hash function for a reactphysics3d Entity
namespace std {
+ // Hash function for a reactphysics3d Entity
template <> struct hash {
size_t operator()(const reactphysics3d::Entity& entity) const {
diff --git a/ext/reactphysics3d/include/reactphysics3d/engine/EntityManager.h b/ext/reactphysics3d/include/reactphysics3d/engine/EntityManager.h
index 35a13fcd2..1dc21d622 100644
--- a/ext/reactphysics3d/include/reactphysics3d/engine/EntityManager.h
+++ b/ext/reactphysics3d/include/reactphysics3d/engine/EntityManager.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/engine/EventListener.h b/ext/reactphysics3d/include/reactphysics3d/engine/EventListener.h
index 7802e892b..f4a758a88 100644
--- a/ext/reactphysics3d/include/reactphysics3d/engine/EventListener.h
+++ b/ext/reactphysics3d/include/reactphysics3d/engine/EventListener.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/engine/Island.h b/ext/reactphysics3d/include/reactphysics3d/engine/Island.h
index dd145f93e..efcb08977 100644
--- a/ext/reactphysics3d/include/reactphysics3d/engine/Island.h
+++ b/ext/reactphysics3d/include/reactphysics3d/engine/Island.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/engine/Islands.h b/ext/reactphysics3d/include/reactphysics3d/engine/Islands.h
index 560e90aec..e70a29969 100644
--- a/ext/reactphysics3d/include/reactphysics3d/engine/Islands.h
+++ b/ext/reactphysics3d/include/reactphysics3d/engine/Islands.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/engine/Material.h b/ext/reactphysics3d/include/reactphysics3d/engine/Material.h
index 5a2a998f3..3445e182e 100644
--- a/ext/reactphysics3d/include/reactphysics3d/engine/Material.h
+++ b/ext/reactphysics3d/include/reactphysics3d/engine/Material.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -90,7 +90,7 @@ class Material {
// ---------- Friendship ---------- //
friend class Collider;
- friend class CollisionBody;
+ friend class Body;
friend class RigidBody;
};
diff --git a/ext/reactphysics3d/include/reactphysics3d/engine/OverlappingPairs.h b/ext/reactphysics3d/include/reactphysics3d/engine/OverlappingPairs.h
index 03b728403..b1c0ed39b 100644
--- a/ext/reactphysics3d/include/reactphysics3d/engine/OverlappingPairs.h
+++ b/ext/reactphysics3d/include/reactphysics3d/engine/OverlappingPairs.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -34,7 +34,7 @@
#include
#include
#include
-#include
+#include
#include
#include
@@ -85,7 +85,7 @@ struct LastFrameCollisionInfo {
/// Constructor
LastFrameCollisionInfo()
- :isValid(false), isObsolete(false), wasColliding(false), wasUsingGJK(false), gjkSeparatingAxis(Vector3(0, 1, 0)),
+ :isValid(false), isObsolete(false), wasColliding(false), wasUsingGJK(false), wasUsingSAT(false), gjkSeparatingAxis(Vector3(0, 1, 0)),
satIsAxisFacePolyhedron1(false), satIsAxisFacePolyhedron2(false), satMinAxisFaceIndex(0),
satMinEdge1Index(0), satMinEdge2Index(0) {
@@ -99,11 +99,20 @@ struct LastFrameCollisionInfo {
* the two colliders start to overlap and is destroyed when they do not
* overlap anymore. Each contains a contact manifold that
* store all the contact points between the two bodies.
+ *
+ * Once the two bodies of an overlapping pair are disabled (sleeping or static),
+ * we put the overlapping pair to the array of disabled pairs. We keep it so that
+ * we can awake the other body if one body is destroyed and we can also correclty
+ * track the lost contacts between bodies even after they go to sleep.
*/
class OverlappingPairs {
public:
+ // Struct OverlappingPair
+ /**
+ * A base overlapping pair
+ */
struct OverlappingPair {
/// Ids of the convex vs convex pairs
@@ -135,12 +144,15 @@ class OverlappingPairs {
/// True if the colliders of the overlapping pair are colliding in the current frame
bool collidingInCurrentFrame;
+ /// True if at least one body of the pair is awake or not static
+ bool isEnabled;
+
/// Constructor
OverlappingPair(uint64 pairId, int32 broadPhaseId1, int32 broadPhaseId2, Entity collider1, Entity collider2,
- NarrowPhaseAlgorithmType narrowPhaseAlgorithmType)
+ NarrowPhaseAlgorithmType narrowPhaseAlgorithmType, bool isEnabled)
: pairID(pairId), broadPhaseId1(broadPhaseId1), broadPhaseId2(broadPhaseId2), collider1(collider1) , collider2(collider2),
needToTestOverlap(false), narrowPhaseAlgorithmType(narrowPhaseAlgorithmType), collidingInPreviousFrame(false),
- collidingInCurrentFrame(false) {
+ collidingInCurrentFrame(false), isEnabled(isEnabled) {
}
@@ -148,7 +160,10 @@ class OverlappingPairs {
virtual ~OverlappingPair() = default;
};
- // Overlapping pair between two convex colliders
+ // Struct ConvexOverlappingPair
+ /**
+ * An overlapping pair between two convex colliders
+ */
struct ConvexOverlappingPair : public OverlappingPair {
/// Temporal coherence collision data for each overlapping collision shapes of this pair.
@@ -159,13 +174,16 @@ class OverlappingPairs {
/// Constructor
ConvexOverlappingPair(uint64 pairId, int32 broadPhaseId1, int32 broadPhaseId2, Entity collider1, Entity collider2,
- NarrowPhaseAlgorithmType narrowPhaseAlgorithmType)
- : OverlappingPair(pairId, broadPhaseId1, broadPhaseId2, collider1, collider2, narrowPhaseAlgorithmType) {
+ NarrowPhaseAlgorithmType narrowPhaseAlgorithmType, bool isEnabled)
+ : OverlappingPair(pairId, broadPhaseId1, broadPhaseId2, collider1, collider2, narrowPhaseAlgorithmType, isEnabled) {
}
};
- // Overlapping pair between two a convex collider and a concave collider
+ // Struct ConvexOverlappingPair
+ /**
+ * An overlapping pair between a convex collider and a concave collider
+ */
struct ConcaveOverlappingPair : public OverlappingPair {
private:
@@ -187,9 +205,10 @@ class OverlappingPairs {
/// Constructor
ConcaveOverlappingPair(uint64 pairId, int32 broadPhaseId1, int32 broadPhaseId2, Entity collider1, Entity collider2,
NarrowPhaseAlgorithmType narrowPhaseAlgorithmType,
- bool isShape1Convex, MemoryAllocator& poolAllocator, MemoryAllocator& heapAllocator)
- : OverlappingPair(pairId, broadPhaseId1, broadPhaseId2, collider1, collider2, narrowPhaseAlgorithmType), mPoolAllocator(&poolAllocator),
- isShape1Convex(isShape1Convex), lastFrameCollisionInfos(heapAllocator, 16) {
+ bool isShape1Convex, MemoryAllocator& poolAllocator, MemoryAllocator& heapAllocator, bool isEnabled,
+ bool allocateLastFrameCollisionInfos = true)
+ : OverlappingPair(pairId, broadPhaseId1, broadPhaseId2, collider1, collider2, narrowPhaseAlgorithmType, isEnabled), mPoolAllocator(&poolAllocator),
+ isShape1Convex(isShape1Convex), lastFrameCollisionInfos(heapAllocator, allocateLastFrameCollisionInfos ? 16 : 0) {
}
@@ -225,7 +244,10 @@ class OverlappingPairs {
auto it = lastFrameCollisionInfos.find(shapesId);
if (it == lastFrameCollisionInfos.end()) {
- LastFrameCollisionInfo* lastFrameInfo = new (mPoolAllocator->allocate(sizeof(LastFrameCollisionInfo))) LastFrameCollisionInfo();
+ // Make sure capacity is an integral multiple of alignment
+ const size_t allocatedMemory = std::ceil(sizeof(LastFrameCollisionInfo) / float(GLOBAL_ALIGNMENT)) * GLOBAL_ALIGNMENT;
+
+ LastFrameCollisionInfo* lastFrameInfo = new (mPoolAllocator->allocate(allocatedMemory)) LastFrameCollisionInfo();
// Add it into the map of collision infos
lastFrameCollisionInfos.add(Pair(shapesId, lastFrameInfo));
@@ -253,8 +275,11 @@ class OverlappingPairs {
// Call the destructor
it->second->LastFrameCollisionInfo::~LastFrameCollisionInfo();
+ // Make sure capacity is an integral multiple of alignment
+ const size_t allocatedMemory = std::ceil(sizeof(LastFrameCollisionInfo) / float(GLOBAL_ALIGNMENT)) * GLOBAL_ALIGNMENT;
+
// Release memory
- mPoolAllocator->release(it->second, sizeof(LastFrameCollisionInfo));
+ mPoolAllocator->release(it->second, allocatedMemory);
it = lastFrameCollisionInfos.remove(it);
}
@@ -285,17 +310,29 @@ class OverlappingPairs {
/// Array of convex vs concave overlapping pairs
Array mConcavePairs;
- /// Map a pair id to the internal array index
+ /// Array of disabled convex overlapping pairs (pairs with both bodies disabled)
+ Array mDisabledConvexPairs;
+
+ /// Array of disabled concave overlapping pairs (pairs with both bodies disabled)
+ Array mDisabledConcavePairs;
+
+ /// Map a convex pair id to the internal array index
Map mMapConvexPairIdToPairIndex;
- /// Map a pair id to the internal array index
+ /// Map a concave pair id to the internal array index
Map mMapConcavePairIdToPairIndex;
+ /// Map a disabled convex pair id to the internal array index
+ Map mMapDisabledConvexPairIdToPairIndex;
+
+ /// Map a disable concave pair id to the internal array index
+ Map mMapDisabledConcavePairIdToPairIndex;
+
/// Reference to the colliders components
ColliderComponents& mColliderComponents;
- /// Reference to the collision body components
- CollisionBodyComponents& mCollisionBodyComponents;
+ /// Reference to the body components
+ BodyComponents& mBodyComponents;
/// Reference to the rigid bodies components
RigidBodyComponents& mRigidBodyComponents;
@@ -321,13 +358,19 @@ class OverlappingPairs {
/// Swap two pairs in the array
void swapPairs(uint64 index1, uint64 index2);
+ /// Remove a disabled convex overlapping pair
+ void removeDisabledConvexPairWithIndex(uint64 pairIndex, bool removeFromColliders);
+
+ /// Remove a disabled concave overlapping pair
+ void removeDisabledConcavePairWithIndex(uint64 pairIndex, bool removeFromColliders);
+
public:
// -------------------- Methods -------------------- //
/// Constructor
OverlappingPairs(MemoryManager& memoryManager, ColliderComponents& colliderComponents,
- CollisionBodyComponents& collisionBodyComponents,
+ BodyComponents& bodyComponents,
RigidBodyComponents& rigidBodyComponents, Set& noCollisionPairs,
CollisionDispatch& collisionDispatch);
@@ -340,14 +383,38 @@ class OverlappingPairs {
/// Deleted assignment operator
OverlappingPairs& operator=(const OverlappingPairs& pair) = delete;
+ /// Enable an overlapping pair (because at least one body of the pair is awaken or not static anymore)
+ void enablePair(uint64 pairId);
+
+ /// Disable an overlapping pair (because both bodies of the pair are disabled)
+ void disablePair(uint64 pairId);
+
+ /// Enable a convex overlapping pair
+ void enableConvexPairWithIndex(uint64 pairIndex);
+
+ /// Disable a convex overlapping pair (because both bodies of the pair are disabled)
+ void disableConvexPairWithIndex(uint64 pairIndex);
+
+ /// Enable a concave overlapping pair
+ void enableConcavePairWithIndex(uint64 pairIndex);
+
+ /// Disable a concave overlapping pair (because both bodies of the pair are disabled)
+ void disableConcavePairWithIndex(uint64 pairIndex);
+
+ /// Return true if a given pair is disabled (both bodies of the pair are disabled)
+ bool isPairDisabled(uint64 pairId) const;
+
/// Add an overlapping pair
uint64 addPair(uint32 collider1Index, uint32 collider2Index, bool isConvexVsConvex);
- /// Remove a component at a given index
+ /// Remove an overlapping pair
void removePair(uint64 pairId);
- /// Remove a pair
- void removePair(uint64 pairIndex, bool isConvexVsConvex);
+ /// Remove a convex pair at a given index
+ void removeConvexPairWithIndex(uint64 pairIndex, bool removeFromColliders = true);
+
+ // Remove a concave pair at a given index
+ void removeConcavePairWithIndex(uint64 pairIndex, bool removeFromColliders = true);
/// Delete all the obsolete last frame collision info
void clearObsoleteLastFrameCollisionInfos();
@@ -413,10 +480,23 @@ RP3D_FORCE_INLINE OverlappingPairs::OverlappingPair* OverlappingPairs::getOverla
if (it != mMapConcavePairIdToPairIndex.end()) {
return &(mConcavePairs[static_cast(it->second)]);
}
+ it = mMapDisabledConvexPairIdToPairIndex.find(pairId);
+ if (it != mMapDisabledConvexPairIdToPairIndex.end()) {
+ return &(mDisabledConvexPairs[static_cast(it->second)]);
+ }
+ it = mMapDisabledConcavePairIdToPairIndex.find(pairId);
+ if (it != mMapDisabledConcavePairIdToPairIndex.end()) {
+ return &(mDisabledConcavePairs[static_cast(it->second)]);
+ }
return nullptr;
}
+// Return true if a given pair is disabled (both bodies of the pair are disabled)
+RP3D_FORCE_INLINE bool OverlappingPairs::isPairDisabled(uint64 pairId) const {
+ return mMapDisabledConvexPairIdToPairIndex.containsKey(pairId) || mMapDisabledConcavePairIdToPairIndex.containsKey(pairId);
+}
+
#ifdef IS_RP3D_PROFILING_ENABLED
// Set the profiler
diff --git a/ext/reactphysics3d/include/reactphysics3d/engine/PhysicsCommon.h b/ext/reactphysics3d/include/reactphysics3d/engine/PhysicsCommon.h
index 2505fb7d0..2c10f7723 100644
--- a/ext/reactphysics3d/include/reactphysics3d/engine/PhysicsCommon.h
+++ b/ext/reactphysics3d/include/reactphysics3d/engine/PhysicsCommon.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -36,11 +36,17 @@
#include
#include
#include
+#include
+#include
#include
+#include
+#include
/// ReactPhysics3D namespace
namespace reactphysics3d {
+class VertexArray;
+
// Class PhysicsCommon
/**
* This class is a singleton that needs to be instanciated once at the beginning.
@@ -77,12 +83,15 @@ class PhysicsCommon {
/// Set of height field shapes
Set mHeightFieldShapes;
- /// Set of polyhedron meshes
- Set mPolyhedronMeshes;
+ /// Set of convex meshes
+ Set mConvexMeshes;
/// Set of triangle meshes
Set mTriangleMeshes;
+ /// Set of height-fields
+ Set mHeightFields;
+
/// Pointer to the current logger
static Logger* mLogger;
@@ -127,12 +136,15 @@ class PhysicsCommon {
/// Delete a concave mesh shape
void deleteConcaveMeshShape(ConcaveMeshShape* concaveMeshShape);
- /// Delete a polyhedron mesh
- void deletePolyhedronMesh(PolyhedronMesh* polyhedronMesh);
+ /// Delete a convex mesh
+ void deleteConvexMesh(ConvexMesh* convexMesh);
/// Delete a triangle mesh
void deleteTriangleMesh(TriangleMesh* triangleMesh);
+ /// Delete a height-field
+ void deleteHeightField(HeightField* heightField);
+
/// Delete a default logger
void deleteDefaultLogger(DefaultLogger* logger);
@@ -191,16 +203,19 @@ class PhysicsCommon {
void destroyCapsuleShape(CapsuleShape* capsuleShape);
/// Create and return a convex mesh shape
- ConvexMeshShape* createConvexMeshShape(PolyhedronMesh* polyhedronMesh, const Vector3& scaling = Vector3(1,1,1));
+ ConvexMeshShape* createConvexMeshShape(ConvexMesh* convexMesh, const Vector3& scaling = Vector3(1,1,1));
/// Destroy a convex mesh shape
void destroyConvexMeshShape(ConvexMeshShape* convexMeshShape);
+ /// Create and return a height-field
+ HeightField* createHeightField(int nbGridColumns, int nbGridRows, const void* heightFieldData,
+ HeightField::HeightDataType dataType, std::vector& messages,
+ decimal integerHeightScale = 1.0f);
+
/// Create and return a height-field shape
- HeightFieldShape* createHeightFieldShape(int nbGridColumns, int nbGridRows, decimal minHeight, decimal maxHeight,
- const void* heightFieldData, HeightFieldShape::HeightDataType dataType,
- int upAxis = 1, decimal integerHeightScale = 1.0f,
- const Vector3& scaling = Vector3(1,1,1));
+ HeightFieldShape* createHeightFieldShape(HeightField* heightField,
+ const Vector3& scaling = Vector3(1,1,1));
/// Destroy a height-field shape
void destroyHeightFieldShape(HeightFieldShape* heightFieldShape);
@@ -211,18 +226,24 @@ class PhysicsCommon {
/// Destroy a concave mesh shape
void destroyConcaveMeshShape(ConcaveMeshShape* concaveMeshShape);
- /// Create a polyhedron mesh
- PolyhedronMesh* createPolyhedronMesh(PolygonVertexArray* polygonVertexArray);
+ /// Create a convex mesh from a PolygonVertexArray describing vertices and faces
+ ConvexMesh* createConvexMesh(const PolygonVertexArray& polygonVertexArray, std::vector& messages);
+
+ /// Create a convex mesh from an array of vertices (automatically computing the convex hull using QuickHull)
+ ConvexMesh* createConvexMesh(const VertexArray& vertexArray, std::vector& messages);
- /// Destroy a polyhedron mesh
- void destroyPolyhedronMesh(PolyhedronMesh* polyhedronMesh);
+ /// Destroy a convex mesh
+ void destroyConvexMesh(ConvexMesh* convexMesh);
/// Create a triangle mesh
- TriangleMesh* createTriangleMesh();
+ TriangleMesh* createTriangleMesh(const TriangleVertexArray& triangleVertexArray, std::vector& messages);
/// Destroy a triangle mesh
void destroyTriangleMesh(TriangleMesh* triangleMesh);
+ /// Destroy a height-field
+ void destroyHeightField(HeightField* heightField);
+
/// Create and return a new default logger
DefaultLogger* createDefaultLogger();
diff --git a/ext/reactphysics3d/include/reactphysics3d/engine/PhysicsWorld.h b/ext/reactphysics3d/include/reactphysics3d/engine/PhysicsWorld.h
index 3462506d9..b1a3baea4 100644
--- a/ext/reactphysics3d/include/reactphysics3d/engine/PhysicsWorld.h
+++ b/ext/reactphysics3d/include/reactphysics3d/engine/PhysicsWorld.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -32,7 +32,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -180,8 +180,11 @@ class PhysicsWorld {
/// True if debug rendering is enabled
bool mIsDebugRenderingEnabled;
+ /// True if the gravity force is on
+ bool mIsGravityEnabled;
+
/// Collision Body Components
- CollisionBodyComponents mCollisionBodyComponents;
+ BodyComponents mBodyComponents;
/// Rigid Body Components
RigidBodyComponents mRigidBodyComponents;
@@ -211,7 +214,7 @@ class PhysicsWorld {
CollisionDetectionSystem mCollisionDetection;
/// All the collision bodies of the world
- Array mCollisionBodies;
+ Array mCollisionBodies;
/// Pointer to an event listener object
EventListener* mEventListener;
@@ -257,9 +260,6 @@ class PhysicsWorld {
/// All the rigid bodies of the physics world
Array mRigidBodies;
- /// True if the gravity force is on
- bool mIsGravityEnabled;
-
/// Sleep linear velocity threshold
decimal mSleepLinearVelocity;
@@ -309,12 +309,6 @@ class PhysicsWorld {
// -------------------- Methods -------------------- //
- /// Create a collision body
- CollisionBody* createCollisionBody(const Transform& transform);
-
- /// Destroy a collision body
- void destroyCollisionBody(CollisionBody* collisionBody);
-
/// Get the collision dispatch configuration
CollisionDispatch& getCollisionDispatch();
@@ -322,19 +316,19 @@ class PhysicsWorld {
void raycast(const Ray& ray, RaycastCallback* raycastCallback, unsigned short raycastWithCategoryMaskBits = 0xFFFF) const;
/// Return true if two bodies overlap (collide)
- bool testOverlap(CollisionBody* body1, CollisionBody* body2);
+ bool testOverlap(Body* body1, Body* body2);
/// Report all the bodies that overlap (collide) with the body in parameter
- void testOverlap(CollisionBody* body, OverlapCallback& overlapCallback);
+ void testOverlap(Body* body, OverlapCallback& overlapCallback);
/// Report all the bodies that overlap (collide) in the world
void testOverlap(OverlapCallback& overlapCallback);
/// Test collision and report contacts between two bodies.
- void testCollision(CollisionBody* body1, CollisionBody* body2, CollisionCallback& callback);
+ void testCollision(Body* body1, Body* body2, CollisionCallback& callback);
/// Test collision and report all the contacts involving the body in parameter
- void testCollision(CollisionBody* body, CollisionCallback& callback);
+ void testCollision(Body* body, CollisionCallback& callback);
/// Test collision and report contacts between each colliding bodies in the world
void testCollision(CollisionCallback& callback);
@@ -426,15 +420,6 @@ class PhysicsWorld {
/// Set an event listener object to receive events callbacks.
void setEventListener(EventListener* eventListener);
- /// Return the number of CollisionBody in the physics world
- uint32 getNbCollisionBodies() const;
-
- /// Return a constant pointer to a given CollisionBody of the world
- const CollisionBody* getCollisionBody(uint32 index) const;
-
- /// Return a pointer to a given CollisionBody of the world
- CollisionBody* getCollisionBody(uint32 index) ;
-
/// Return the number of RigidBody in the physics world
uint32 getNbRigidBodies() const;
@@ -463,7 +448,7 @@ class PhysicsWorld {
// -------------------- Friendship -------------------- //
friend class CollisionDetectionSystem;
- friend class CollisionBody;
+ friend class Body;
friend class Collider;
friend class ConvexMeshShape;
friend class CollisionCallback::ContactPair;
@@ -514,7 +499,7 @@ RP3D_FORCE_INLINE void PhysicsWorld::raycast(const Ray& ray,
* @param body2 Pointer to the second body to test
* @param callback Pointer to the object with the callback method
*/
-RP3D_FORCE_INLINE void PhysicsWorld::testCollision(CollisionBody* body1, CollisionBody* body2, CollisionCallback& callback) {
+RP3D_FORCE_INLINE void PhysicsWorld::testCollision(Body* body1, Body* body2, CollisionCallback& callback) {
mCollisionDetection.testCollision(body1, body2, callback);
}
@@ -527,7 +512,7 @@ RP3D_FORCE_INLINE void PhysicsWorld::testCollision(CollisionBody* body1, Collisi
* @param body Pointer to the body against which we need to test collision
* @param callback Pointer to the object with the callback method to report contacts
*/
-RP3D_FORCE_INLINE void PhysicsWorld::testCollision(CollisionBody* body, CollisionCallback& callback) {
+RP3D_FORCE_INLINE void PhysicsWorld::testCollision(Body* body, CollisionCallback& callback) {
mCollisionDetection.testCollision(body, callback);
}
@@ -551,7 +536,7 @@ RP3D_FORCE_INLINE void PhysicsWorld::testCollision(CollisionCallback& callback)
* @param body Pointer to the collision body to test overlap with
* @param overlapCallback Pointer to the callback class to report overlap
*/
-RP3D_FORCE_INLINE void PhysicsWorld::testOverlap(CollisionBody* body, OverlapCallback& overlapCallback) {
+RP3D_FORCE_INLINE void PhysicsWorld::testOverlap(Body* body, OverlapCallback& overlapCallback) {
mCollisionDetection.testOverlap(body, overlapCallback);
}
@@ -679,15 +664,6 @@ RP3D_FORCE_INLINE void PhysicsWorld::setEventListener(EventListener* eventListen
mEventListener = eventListener;
}
-// Return the number of CollisionBody in the physics world
-/// Note that even if a RigidBody is also a collision body, this method does not return the rigid bodies
-/**
- * @return The number of collision bodies in the physics world
- */
-RP3D_FORCE_INLINE uint32 PhysicsWorld::getNbCollisionBodies() const {
- return static_cast(mCollisionBodies.size());
-}
-
// Return the number of RigidBody in the physics world
/**
* @return The number of rigid bodies in the physics world
diff --git a/ext/reactphysics3d/include/reactphysics3d/mathematics/Matrix2x2.h b/ext/reactphysics3d/include/reactphysics3d/mathematics/Matrix2x2.h
index a736d2a1c..641001279 100644
--- a/ext/reactphysics3d/include/reactphysics3d/mathematics/Matrix2x2.h
+++ b/ext/reactphysics3d/include/reactphysics3d/mathematics/Matrix2x2.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/mathematics/Matrix3x3.h b/ext/reactphysics3d/include/reactphysics3d/mathematics/Matrix3x3.h
index 607bd996d..9ea7b803f 100644
--- a/ext/reactphysics3d/include/reactphysics3d/mathematics/Matrix3x3.h
+++ b/ext/reactphysics3d/include/reactphysics3d/mathematics/Matrix3x3.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/mathematics/Quaternion.h b/ext/reactphysics3d/include/reactphysics3d/mathematics/Quaternion.h
index 5526d1680..0a6d178f8 100644
--- a/ext/reactphysics3d/include/reactphysics3d/mathematics/Quaternion.h
+++ b/ext/reactphysics3d/include/reactphysics3d/mathematics/Quaternion.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/mathematics/Ray.h b/ext/reactphysics3d/include/reactphysics3d/mathematics/Ray.h
index 262fd3644..fcef0a5cd 100644
--- a/ext/reactphysics3d/include/reactphysics3d/mathematics/Ray.h
+++ b/ext/reactphysics3d/include/reactphysics3d/mathematics/Ray.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/mathematics/Transform.h b/ext/reactphysics3d/include/reactphysics3d/mathematics/Transform.h
index 78fcbfc53..b2885b036 100644
--- a/ext/reactphysics3d/include/reactphysics3d/mathematics/Transform.h
+++ b/ext/reactphysics3d/include/reactphysics3d/mathematics/Transform.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/mathematics/Vector2.h b/ext/reactphysics3d/include/reactphysics3d/mathematics/Vector2.h
index 93fb00feb..27cbd13aa 100644
--- a/ext/reactphysics3d/include/reactphysics3d/mathematics/Vector2.h
+++ b/ext/reactphysics3d/include/reactphysics3d/mathematics/Vector2.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/mathematics/Vector3.h b/ext/reactphysics3d/include/reactphysics3d/mathematics/Vector3.h
index 61ed30cd7..80a472725 100644
--- a/ext/reactphysics3d/include/reactphysics3d/mathematics/Vector3.h
+++ b/ext/reactphysics3d/include/reactphysics3d/mathematics/Vector3.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -154,6 +154,9 @@ struct Vector3 {
/// Return the zero vector
static Vector3 zero();
+ /// Function to test if two vectors are (almost) equal
+ static bool approxEqual(const Vector3& vec1, const Vector3& vec2, decimal epsilon = MACHINE_EPSILON);
+
// -------------------- Friends -------------------- //
friend Vector3 operator+(const Vector3& vector1, const Vector3& vector2);
@@ -390,9 +393,9 @@ RP3D_FORCE_INLINE Vector3 Vector3::zero() {
}
// Function to test if two vectors are (almost) equal
-RP3D_FORCE_INLINE bool approxEqual(const Vector3& vec1, const Vector3& vec2, decimal epsilon = MACHINE_EPSILON) {
- return approxEqual(vec1.x, vec2.x, epsilon) && approxEqual(vec1.y, vec2.y, epsilon) &&
- approxEqual(vec1.z, vec2.z, epsilon);
+RP3D_FORCE_INLINE bool Vector3::approxEqual(const Vector3& vec1, const Vector3& vec2, decimal epsilon) {
+ return reactphysics3d::approxEqual(vec1.x, vec2.x, epsilon) && reactphysics3d::approxEqual(vec1.y, vec2.y, epsilon) &&
+ reactphysics3d::approxEqual(vec1.z, vec2.z, epsilon);
}
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics.h b/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics.h
index 289e91ef4..93d44463c 100644
--- a/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics.h
+++ b/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics_common.h b/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics_common.h
index 8f7419f06..b956af87b 100644
--- a/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics_common.h
+++ b/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics_common.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics_functions.h b/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics_functions.h
index d6f73c3cd..1c1aca7ae 100755
--- a/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics_functions.h
+++ b/ext/reactphysics3d/include/reactphysics3d/mathematics/mathematics_functions.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/memory/DefaultAllocator.h b/ext/reactphysics3d/include/reactphysics3d/memory/DefaultAllocator.h
index ec2ef0aef..d4b1b9d22 100644
--- a/ext/reactphysics3d/include/reactphysics3d/memory/DefaultAllocator.h
+++ b/ext/reactphysics3d/include/reactphysics3d/memory/DefaultAllocator.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -28,15 +28,20 @@
// Libraries
#include
+#include
#include
+#include
#include
+#include
/// ReactPhysics3D namespace
namespace reactphysics3d {
// Class DefaultAllocator
/**
- * This class represents a default memory allocator that uses default malloc/free methods
+ * This class represents a default memory allocator that uses standard C++ functions
+ * to allocated 16-bytes aligned memory.
+ *
*/
class DefaultAllocator : public MemoryAllocator {
@@ -49,15 +54,37 @@ class DefaultAllocator : public MemoryAllocator {
DefaultAllocator& operator=(DefaultAllocator& allocator) = default;
/// Allocate memory of a given size (in bytes) and return a pointer to the
- /// allocated memory.
+ /// allocated memory. The returned allocated memory must be 16 bytes aligned.
virtual void* allocate(size_t size) override {
- return std::malloc(size);
+ assert(size % GLOBAL_ALIGNMENT == 0);
+
+// If compiler is Visual Studio
+#ifdef RP3D_PLATFORM_WINDOWS
+
+ // Visual Studio doesn't not support standard std:aligned_alloc() method from C++ 17
+ return _aligned_malloc(size, GLOBAL_ALIGNMENT);
+#else
+
+ // Return 16-bytes aligned memory
+ void* address = nullptr;
+ posix_memalign(&address, GLOBAL_ALIGNMENT, size);
+ return address;
+#endif
}
/// Release previously allocated memory.
virtual void release(void* pointer, size_t /*size*/) override {
- std::free(pointer);
+
+ // If compiler is Visual Studio
+#ifdef RP3D_COMPILER_VISUAL_STUDIO
+
+ // Visual Studio doesn't not support standard std:aligned_alloc() method from c++ 17
+ return _aligned_free(pointer);
+#else
+
+ return std::free(pointer);
+#endif
}
};
diff --git a/ext/reactphysics3d/include/reactphysics3d/memory/HeapAllocator.h b/ext/reactphysics3d/include/reactphysics3d/memory/HeapAllocator.h
index 940853fdb..3e504fa76 100644
--- a/ext/reactphysics3d/include/reactphysics3d/memory/HeapAllocator.h
+++ b/ext/reactphysics3d/include/reactphysics3d/memory/HeapAllocator.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -57,26 +57,33 @@ class HeapAllocator : public MemoryAllocator {
// -------------------- Attributes -------------------- //
- /// Size in bytes of the allocated memory unit
- size_t size;
-
- /// True if the memory unit is currently allocated
- bool isAllocated;
-
/// Pointer to the previous memory unit
MemoryUnitHeader* previousUnit;
/// Pointer to the next memory unit
MemoryUnitHeader* nextUnit;
+ /// Pointer to the previous free (not allocated) memory unit
+ MemoryUnitHeader* previousFreeUnit;
+
+ /// Pointer to the next free (not allocated) memory unit
+ MemoryUnitHeader* nextFreeUnit;
+
+ /// Size in bytes of the allocated memory unit
+ size_t size;
+
/// True if the next memory unit has been allocated with the same call to malloc()
bool isNextContiguousMemory;
+ /// True if the memory unit is currently allocated
+ bool isAllocated = false;
+
// -------------------- Methods -------------------- //
- MemoryUnitHeader(size_t size, MemoryUnitHeader* previousUnit, MemoryUnitHeader* nextUnit, bool isNextContiguousMemory)
- : size(size), isAllocated(false), previousUnit(previousUnit),
- nextUnit(nextUnit), isNextContiguousMemory(isNextContiguousMemory) {
+ MemoryUnitHeader(size_t size, MemoryUnitHeader* previousUnit, MemoryUnitHeader* nextUnit,
+ MemoryUnitHeader* previousFreeUnit, MemoryUnitHeader* nextFreeUnit, bool isNextContiguousMemory)
+ : previousUnit(previousUnit), nextUnit(nextUnit), previousFreeUnit(previousFreeUnit), nextFreeUnit(nextFreeUnit), size(size),
+ isNextContiguousMemory(isNextContiguousMemory) {
assert(size > 0);
}
@@ -101,8 +108,8 @@ class HeapAllocator : public MemoryAllocator {
/// Pointer to the first memory unit of the linked-list
MemoryUnitHeader* mMemoryUnits;
- /// Pointer to a cached free memory unit
- MemoryUnitHeader* mCachedFreeUnit;
+ /// Pointer to the first item of the linked-list of free units
+ MemoryUnitHeader* mFreeUnits;
#ifndef NDEBUG
/// This variable is incremented by one when the allocate() method has been
@@ -118,12 +125,21 @@ class HeapAllocator : public MemoryAllocator {
/// left over space. The second unit is put into the free memory units
void splitMemoryUnit(MemoryUnitHeader* unit, size_t size);
- // Merge two contiguous memory units that are not allocated.
+ /// Add the unit from the linked-list of free units
+ void addToFreeUnits(MemoryUnitHeader* unit);
+
+ /// Remove the unit from the linked-list of free units
+ void removeFromFreeUnits(MemoryUnitHeader* unit);
+
+ /// Merge two contiguous memory units that are not allocated.
void mergeUnits(MemoryUnitHeader* unit1, MemoryUnitHeader* unit2);
/// Reserve more memory for the allocator
void reserve(size_t sizeToAllocate);
+ /// Return the next aligned memory address
+ void* computeAlignedAddress(void* unalignedAddress);
+
public :
// -------------------- Methods -------------------- //
diff --git a/ext/reactphysics3d/include/reactphysics3d/memory/MemoryAllocator.h b/ext/reactphysics3d/include/reactphysics3d/memory/MemoryAllocator.h
index 9111f3d7e..27ae26322 100644
--- a/ext/reactphysics3d/include/reactphysics3d/memory/MemoryAllocator.h
+++ b/ext/reactphysics3d/include/reactphysics3d/memory/MemoryAllocator.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -28,6 +28,7 @@
// Libraries
#include
+#include
/// ReactPhysics3D namespace
namespace reactphysics3d {
@@ -50,11 +51,17 @@ class MemoryAllocator {
MemoryAllocator& operator=(MemoryAllocator& allocator) = default;
/// Allocate memory of a given size (in bytes) and return a pointer to the
- /// allocated memory.
+ /// allocated memory. The return allocated memory must be 16 bytes aligned.
virtual void* allocate(size_t size)=0;
/// Release previously allocated memory.
virtual void release(void* pointer, size_t size)=0;
+
+ /// Given a pointer to memory, this method returns the next aligned address
+ static void* alignAddress(void* pointer, uint8 alignment);
+
+ /// Given a pointer to memory, this method returns the next aligned address and also output the alignment offset
+ static void* alignAddress(void* pointer, uint8 alignment, ptrdiff_t& alignmentOffset);
};
}
diff --git a/ext/reactphysics3d/include/reactphysics3d/memory/MemoryManager.h b/ext/reactphysics3d/include/reactphysics3d/memory/MemoryManager.h
index cf6505bbb..b53460772 100644
--- a/ext/reactphysics3d/include/reactphysics3d/memory/MemoryManager.h
+++ b/ext/reactphysics3d/include/reactphysics3d/memory/MemoryManager.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -104,14 +104,18 @@ class MemoryManager {
// Allocate memory of a given type
RP3D_FORCE_INLINE void* MemoryManager::allocate(AllocationType allocationType, size_t size) {
+ void* allocatedMemory = nullptr;
+
switch (allocationType) {
- case AllocationType::Base: return mBaseAllocator->allocate(size);
- case AllocationType::Pool: return mPoolAllocator.allocate(size);
- case AllocationType::Heap: return mHeapAllocator.allocate(size);
- case AllocationType::Frame: return mSingleFrameAllocator.allocate(size);
+ case AllocationType::Base: allocatedMemory = mBaseAllocator->allocate(size); break;
+ case AllocationType::Pool: allocatedMemory = mPoolAllocator.allocate(size); break;
+ case AllocationType::Heap: allocatedMemory = mHeapAllocator.allocate(size); break;
+ case AllocationType::Frame: allocatedMemory = mSingleFrameAllocator.allocate(size); break;
}
- return nullptr;
+ assert(allocatedMemory == nullptr || reinterpret_cast(allocatedMemory) % 16 == 0);
+
+ return allocatedMemory;
}
// Release previously allocated memory.
diff --git a/ext/reactphysics3d/include/reactphysics3d/memory/PoolAllocator.h b/ext/reactphysics3d/include/reactphysics3d/memory/PoolAllocator.h
index 95f56a1fd..7898545a0 100644
--- a/ext/reactphysics3d/include/reactphysics3d/memory/PoolAllocator.h
+++ b/ext/reactphysics3d/include/reactphysics3d/memory/PoolAllocator.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -81,13 +81,16 @@ class PoolAllocator : public MemoryAllocator {
/// Number of heaps
static const int NB_HEAPS = 128;
+ /// Minimum unit size
+ static const size_t MIN_UNIT_SIZE = GLOBAL_ALIGNMENT;
+
/// Maximum memory unit size. An allocation request of a size smaller or equal to
/// this size will be handled using the small block allocator. However, for an
/// allocation request larger than the maximum block size, the standard malloc()
/// will be used.
- static const size_t MAX_UNIT_SIZE = 1024;
+ static const size_t MAX_UNIT_SIZE = NB_HEAPS * MIN_UNIT_SIZE;
- /// Size a memory chunk
+ /// Size of a memory chunk
static const size_t BLOCK_SIZE = 16 * MAX_UNIT_SIZE;
// -------------------- Attributes -------------------- //
diff --git a/ext/reactphysics3d/include/reactphysics3d/memory/SingleFrameAllocator.h b/ext/reactphysics3d/include/reactphysics3d/memory/SingleFrameAllocator.h
index b53b8a4a0..9455bb36c 100644
--- a/ext/reactphysics3d/include/reactphysics3d/memory/SingleFrameAllocator.h
+++ b/ext/reactphysics3d/include/reactphysics3d/memory/SingleFrameAllocator.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -45,10 +45,6 @@ class SingleFrameAllocator : public MemoryAllocator {
// -------------------- Constants -------------------- //
- /// Number of frames to wait before shrinking the allocated
- /// memory if too much is allocated
- static const int NB_FRAMES_UNTIL_SHRINK = 120;
-
/// Initial size (in bytes) of the single frame allocator
size_t INIT_SINGLE_FRAME_ALLOCATOR_NB_BYTES = 1048576; // 1Mb
@@ -69,10 +65,6 @@ class SingleFrameAllocator : public MemoryAllocator {
/// Pointer to the next available memory location in the buffer
size_t mCurrentOffset;
- /// Current number of frames since we detected too much memory
- /// is allocated
- size_t mNbFramesTooMuchAllocated;
-
/// True if we need to allocate more memory in the next reset() call
bool mNeedToAllocatedMore;
diff --git a/ext/reactphysics3d/include/reactphysics3d/reactphysics3d.h b/ext/reactphysics3d/include/reactphysics3d/reactphysics3d.h
index 3fe4a8fa8..e429a88af 100644
--- a/ext/reactphysics3d/include/reactphysics3d/reactphysics3d.h
+++ b/ext/reactphysics3d/include/reactphysics3d/reactphysics3d.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -26,7 +26,7 @@
/********************************************************************************
* ReactPhysics3D *
-* Version 0.9.0 *
+* Version 0.10.1 *
* http://www.reactphysics3d.com *
* Daniel Chappuis *
********************************************************************************/
@@ -37,7 +37,7 @@
// Libraries
#include
#include
-#include
+#include
#include
#include
#include
@@ -50,14 +50,16 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
#include
-#include
+#include
+#include
#include
#include
+#include
#include
#include
#include
@@ -65,6 +67,7 @@
#include
#include
#include
+#include
/// Alias to the ReactPhysics3D namespace
namespace rp3d = reactphysics3d;
diff --git a/ext/reactphysics3d/include/reactphysics3d/systems/BroadPhaseSystem.h b/ext/reactphysics3d/include/reactphysics3d/systems/BroadPhaseSystem.h
index d06b5cb3b..4311b3082 100644
--- a/ext/reactphysics3d/include/reactphysics3d/systems/BroadPhaseSystem.h
+++ b/ext/reactphysics3d/include/reactphysics3d/systems/BroadPhaseSystem.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -41,12 +41,15 @@ namespace reactphysics3d {
// Declarations
class CollisionDetectionSystem;
class BroadPhaseSystem;
-class CollisionBody;
+class Body;
class Collider;
class MemoryManager;
class Profiler;
// class AABBOverlapCallback
+/**
+ * This class represents a callback when two AABB overlap
+ */
class AABBOverlapCallback : public DynamicAABBTreeOverlapCallback {
public:
diff --git a/ext/reactphysics3d/include/reactphysics3d/systems/CollisionDetectionSystem.h b/ext/reactphysics3d/include/reactphysics3d/systems/CollisionDetectionSystem.h
index 7e17e28b2..ed91dc9f1 100644
--- a/ext/reactphysics3d/include/reactphysics3d/systems/CollisionDetectionSystem.h
+++ b/ext/reactphysics3d/include/reactphysics3d/systems/CollisionDetectionSystem.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -27,7 +27,7 @@
#define REACTPHYSICS3D_COLLISION_DETECTION_SYSTEM_H
// Libraries
-#include
+#include
#include
#include
#include
@@ -160,9 +160,6 @@ class CollisionDetectionSystem {
/// Pointer to the contact points of the current frame (either mContactPoints1 or mContactPoints2)
Array* mCurrentContactPoints;
- /// Array with the indices of all the contact pairs that have at least one CollisionBody
- Array mCollisionBodyContactPairsIndices;
-
/// Number of potential contact manifolds in the previous frame
uint32 mNbPreviousPotentialContactManifolds;
@@ -172,6 +169,9 @@ class CollisionDetectionSystem {
/// Reference to the half-edge structure of the triangle polyhedron
HalfEdgeStructure& mTriangleHalfEdgeStructure;
+ /// Allocated size for a triangle shape
+ static const size_t mTriangleShapeAllocatedSize;
+
#ifdef IS_RP3D_PROFILING_ENABLED
/// Pointer to the profiler
@@ -185,7 +185,7 @@ class CollisionDetectionSystem {
void computeBroadPhase();
/// Compute the middle-phase collision detection
- void computeMiddlePhase(NarrowPhaseInput& narrowPhaseInput, bool needToReportContacts);
+ void computeMiddlePhase(NarrowPhaseInput& narrowPhaseInput, bool needToReportContacts, bool isWorldQuery);
// Compute the middle-phase collision detection
void computeMiddlePhaseCollisionSnapshot(Array& convexPairs, Array& concavePairs, NarrowPhaseInput& narrowPhaseInput,
@@ -213,6 +213,18 @@ class CollisionDetectionSystem {
/// Remove pairs that are not overlapping anymore
void removeNonOverlappingPairs();
+ /// Disable an overlapping pair (because both bodies of the pair are disabled)
+ void disableOverlappingPair(uint64 pairId);
+
+ /// Remove an overlapping pair
+ void removeOverlappingPair(uint64 pairId, bool notifyLostContact);
+
+ /// Remove a convex overlapping pair at a given index
+ void removeConvexOverlappingPairWithIndex(uint64 pairIndex);
+
+ /// Remove a concave overlapping pair at a given index
+ void removeConcaveOverlappingPairWithIndex(uint64 pairIndex);
+
/// Add a lost contact pair (pair of colliders that are not in contact anymore)
void addLostContactPair(OverlappingPairs::OverlappingPair& overlappingPair);
@@ -300,7 +312,7 @@ class CollisionDetectionSystem {
/// Constructor
CollisionDetectionSystem(PhysicsWorld* world, ColliderComponents& collidersComponents,
- TransformComponents& transformComponents, CollisionBodyComponents& collisionBodyComponents, RigidBodyComponents& rigidBodyComponents,
+ TransformComponents& transformComponents, BodyComponents& bodyComponents, RigidBodyComponents& rigidBodyComponents,
MemoryManager& memoryManager, HalfEdgeStructure& triangleHalfEdgeStructure);
/// Destructor
@@ -350,19 +362,19 @@ class CollisionDetectionSystem {
unsigned short raycastWithCategoryMaskBits) const;
/// Return true if two bodies (collide) overlap
- bool testOverlap(CollisionBody* body1, CollisionBody* body2);
+ bool testOverlap(Body* body1, Body* body2);
/// Report all the bodies that overlap (collide) with the body in parameter
- void testOverlap(CollisionBody* body, OverlapCallback& callback);
+ void testOverlap(Body* body, OverlapCallback& callback);
/// Report all the bodies that overlap (collide) in the world
void testOverlap(OverlapCallback& overlapCallback);
/// Test collision and report contacts between two bodies.
- void testCollision(CollisionBody* body1, CollisionBody* body2, CollisionCallback& callback);
+ void testCollision(Body* body1, Body* body2, CollisionCallback& callback);
/// Test collision and report all the contacts involving the body in parameter
- void testCollision(CollisionBody* body, CollisionCallback& callback);
+ void testCollision(Body* body, CollisionCallback& callback);
/// Test collision and report contacts between each colliding bodies in the world
void testCollision(CollisionCallback& callback);
diff --git a/ext/reactphysics3d/include/reactphysics3d/systems/ConstraintSolverSystem.h b/ext/reactphysics3d/include/reactphysics3d/systems/ConstraintSolverSystem.h
index 11b6cbc74..ab3201ddf 100644
--- a/ext/reactphysics3d/include/reactphysics3d/systems/ConstraintSolverSystem.h
+++ b/ext/reactphysics3d/include/reactphysics3d/systems/ConstraintSolverSystem.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/systems/ContactSolverSystem.h b/ext/reactphysics3d/include/reactphysics3d/systems/ContactSolverSystem.h
index 46b1f22d4..20caafc5e 100644
--- a/ext/reactphysics3d/include/reactphysics3d/systems/ContactSolverSystem.h
+++ b/ext/reactphysics3d/include/reactphysics3d/systems/ContactSolverSystem.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -47,7 +47,7 @@ struct Islands;
class RigidBody;
class Collider;
class PhysicsWorld;
-class CollisionBodyComponents;
+class BodyComponents;
class DynamicsComponents;
class RigidBodyComponents;
class ColliderComponents;
@@ -322,7 +322,7 @@ class ContactSolverSystem {
Array* mAllContactPoints;
/// Reference to the body components
- CollisionBodyComponents& mBodyComponents;
+ BodyComponents& mBodyComponents;
/// Reference to the dynamics components
RigidBodyComponents& mRigidBodyComponents;
@@ -362,7 +362,7 @@ class ContactSolverSystem {
// -------------------- Methods -------------------- //
/// Constructor
- ContactSolverSystem(MemoryManager& memoryManager, PhysicsWorld& world, Islands& islands, CollisionBodyComponents& bodyComponents,
+ ContactSolverSystem(MemoryManager& memoryManager, PhysicsWorld& world, Islands& islands, BodyComponents& bodyComponents,
RigidBodyComponents& rigidBodyComponents, ColliderComponents& colliderComponents, decimal& restitutionVelocityThreshold);
/// Destructor
diff --git a/ext/reactphysics3d/include/reactphysics3d/systems/DynamicsSystem.h b/ext/reactphysics3d/include/reactphysics3d/systems/DynamicsSystem.h
index f82c51204..921ffe8d7 100644
--- a/ext/reactphysics3d/include/reactphysics3d/systems/DynamicsSystem.h
+++ b/ext/reactphysics3d/include/reactphysics3d/systems/DynamicsSystem.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -28,7 +28,7 @@
// Libraries
#include
-#include
+#include
#include
#include
#include
@@ -52,7 +52,7 @@ class DynamicsSystem {
PhysicsWorld& mWorld;
/// Reference to the collision body components
- CollisionBodyComponents& mCollisionBodyComponents;
+ BodyComponents& mBodyComponents;
/// Reference to the rigid body components
RigidBodyComponents& mRigidBodyComponents;
@@ -80,7 +80,7 @@ class DynamicsSystem {
// -------------------- Methods -------------------- //
/// Constructor
- DynamicsSystem(PhysicsWorld& world, CollisionBodyComponents& collisionBodyComponents,
+ DynamicsSystem(PhysicsWorld& world, BodyComponents& bodyComponents,
RigidBodyComponents& rigidBodyComponents, TransformComponents& transformComponents,
ColliderComponents& colliderComponents, bool& isGravityEnabled, Vector3& gravity);
diff --git a/ext/reactphysics3d/include/reactphysics3d/systems/SolveBallAndSocketJointSystem.h b/ext/reactphysics3d/include/reactphysics3d/systems/SolveBallAndSocketJointSystem.h
index aa1bf9b98..84441fd61 100644
--- a/ext/reactphysics3d/include/reactphysics3d/systems/SolveBallAndSocketJointSystem.h
+++ b/ext/reactphysics3d/include/reactphysics3d/systems/SolveBallAndSocketJointSystem.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/systems/SolveFixedJointSystem.h b/ext/reactphysics3d/include/reactphysics3d/systems/SolveFixedJointSystem.h
index b897404ff..278809d9c 100644
--- a/ext/reactphysics3d/include/reactphysics3d/systems/SolveFixedJointSystem.h
+++ b/ext/reactphysics3d/include/reactphysics3d/systems/SolveFixedJointSystem.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/systems/SolveHingeJointSystem.h b/ext/reactphysics3d/include/reactphysics3d/systems/SolveHingeJointSystem.h
index 6fcb84b15..dc7083c9f 100644
--- a/ext/reactphysics3d/include/reactphysics3d/systems/SolveHingeJointSystem.h
+++ b/ext/reactphysics3d/include/reactphysics3d/systems/SolveHingeJointSystem.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/systems/SolveSliderJointSystem.h b/ext/reactphysics3d/include/reactphysics3d/systems/SolveSliderJointSystem.h
index a08b65e2b..ebe64ffcb 100644
--- a/ext/reactphysics3d/include/reactphysics3d/systems/SolveSliderJointSystem.h
+++ b/ext/reactphysics3d/include/reactphysics3d/systems/SolveSliderJointSystem.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/utils/DebugRenderer.h b/ext/reactphysics3d/include/reactphysics3d/utils/DebugRenderer.h
index 2d22dba3d..779c7472d 100644
--- a/ext/reactphysics3d/include/reactphysics3d/utils/DebugRenderer.h
+++ b/ext/reactphysics3d/include/reactphysics3d/utils/DebugRenderer.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -31,7 +31,6 @@
#include
#include
#include
-#include
/// ReactPhysics3D namespace
namespace reactphysics3d {
@@ -40,6 +39,7 @@ namespace reactphysics3d {
class ConcaveMeshShape;
class ConvexMeshShape;
class HeightFieldShape;
+class BoxShape;
class Collider;
class PhysicsWorld;
@@ -86,6 +86,9 @@ class DebugRenderer : public EventListener {
/// Display the contact normals
CONTACT_NORMAL = 1 << 4,
+
+ /// Display the face normals of the collision shapes
+ COLLISION_SHAPE_NORMAL = 1 << 5,
};
/// Struture that represents a line of the DebugRenderer
@@ -151,10 +154,13 @@ class DebugRenderer : public EventListener {
/// Default radius of the sphere displayed to represent contact points
static constexpr decimal DEFAULT_CONTACT_POINT_SPHERE_RADIUS = decimal(0.1);
- /// Default radius of the sphere displayed to represent contact points
+ /// Default length for the displayed contacts normals
static constexpr decimal DEFAULT_CONTACT_NORMAL_LENGTH = decimal(1.0);
- // -------------------- Attributes -------------------- //
+ /// Default length for the displayed faces normals of the collision shapes
+ static constexpr decimal DEFAULT_COLLISION_SHAPE_NORMAL_LENGTH = decimal(1.0);
+
+ // -------------------- Attributes -------------------- //
/// Memory allocator
MemoryAllocator& mAllocator;
@@ -174,16 +180,19 @@ class DebugRenderer : public EventListener {
/// Radius of the sphere displayed to represent contact points
decimal mContactPointSphereRadius;
- /// Lenght of contact normal
+ /// Length of contact normal
decimal mContactNormalLength;
+ /// Length of collision shape face normal
+ decimal mCollisionShapeNormalLength;
+
// -------------------- Methods -------------------- //
/// Draw an AABB
void drawAABB(const AABB& aabb, uint32 color);
/// Draw a box
- void drawBox(const Transform& transform, const Vector3& extents, uint32 color);
+ void drawBox(const Transform& transform, const BoxShape* boxShape, uint32 colorShape, uint32 colorShapeNormals);
/// Draw a sphere
void drawSphere(const Vector3& position, decimal radius, uint32 color);
@@ -192,16 +201,18 @@ class DebugRenderer : public EventListener {
void drawCapsule(const Transform& transform, decimal radius, decimal height, uint32 color);
/// Draw a convex mesh
- void drawConvexMesh(const Transform& transform, const ConvexMeshShape* convexMesh, uint32 color);
+ void drawConvexMesh(const Transform& transform, const ConvexMeshShape* convexMesh, uint32 colorShape, uint32 colorShapeNormals);
/// Draw a concave mesh shape
- void drawConcaveMeshShape(const Transform& transform, const ConcaveMeshShape* concaveMeshShape, uint32 color);
+ void drawConcaveMeshShape(const Transform& transform, const ConcaveMeshShape* concaveMeshShape,
+ uint32 colorShape, uint32 colorShapeNormals);
/// Draw a height field shape
- void drawHeightFieldShape(const Transform& transform, const HeightFieldShape* heightFieldShape, uint32 color);
+ void drawHeightFieldShape(const Transform& transform, const HeightFieldShape* heightFieldShape,
+ uint32 colorShape, uint32 colorShapeNormals);
/// Draw the collision shape of a collider
- void drawCollisionShapeOfCollider(const Collider* collider, uint32 color);
+ void drawCollisionShapeOfCollider(const Collider* collider);
public :
@@ -366,9 +377,9 @@ RP3D_FORCE_INLINE void DebugRenderer::setContactNormalLength(decimal contactNorm
}
-// Hash function for a DebugItem
namespace std {
+ // Hash function for a DebugItem
template <> struct hash {
size_t operator()(const reactphysics3d::DebugRenderer::DebugItem& debugItem) const {
diff --git a/ext/reactphysics3d/include/reactphysics3d/utils/DefaultLogger.h b/ext/reactphysics3d/include/reactphysics3d/utils/DefaultLogger.h
index f4d2e927e..1088d1e92 100644
--- a/ext/reactphysics3d/include/reactphysics3d/utils/DefaultLogger.h
+++ b/ext/reactphysics3d/include/reactphysics3d/utils/DefaultLogger.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -36,6 +36,7 @@
#include
#include
#include
+#include
/// ReactPhysics3D namespace
namespace reactphysics3d {
@@ -80,8 +81,33 @@ class DefaultLogger : public Logger {
/// Format a log message
virtual std::string format(const time_t& time, const std::string& physicsWorldName, const std::string& message, Level level, Category category,
const char* filename, int lineNumber) = 0;
+
+ /// Return the current date and time
+ std::tm getLocalTime(const std::time_t& time) const {
+
+ std::tm bt = std::tm();
+
+ // This is because std::localtime is not thread-safe
+
+#if defined(__unix__)
+ localtime_r(&time, &bt);
+#elif defined(_MSC_VER)
+ localtime_s(&bt, &time);
+#else
+ static std::mutex mtx;
+ std::lock_guard lock(mtx);
+ bt = *std::localtime(&time);
+#endif
+
+ return bt;
+ }
+
};
+ // Class TextFormatter
+ /**
+ * Format the logs with simple text
+ */
class TextFormatter : public Formatter {
public:
@@ -101,12 +127,14 @@ class DefaultLogger : public Logger {
// Get current date
auto now = std::chrono::system_clock::now();
- auto time = std::chrono::system_clock::to_time_t(now);
+ std::time_t time = std::chrono::system_clock::to_time_t(now);
+
+ auto localTime = getLocalTime(time);
std::stringstream ss;
ss << "ReactPhysics3D Logs" << std::endl;
ss << "ReactPhysics3D Version: " << RP3D_VERSION << std::endl;
- ss << "Date: " << std::put_time(std::localtime(&time), "%Y-%m-%d") << std::endl;
+ ss << "Date: " << std::put_time(&localTime, "%Y-%m-%d") << std::endl;
ss << "---------------------------------------------------------" << std::endl;
return ss.str();
@@ -117,8 +145,10 @@ class DefaultLogger : public Logger {
Level level, Category category, const char* filename, int lineNumber) override {
std::stringstream ss;
+ auto localTime = getLocalTime(time);
+
// Time
- ss << std::put_time(std::localtime(&time), "%X") << " ";
+ ss << std::put_time(&localTime, "%X") << " ";
// World
ss << "World:" << physicsWorldName << std::endl;
@@ -142,6 +172,10 @@ class DefaultLogger : public Logger {
}
};
+ // Class HtmlFormatter
+ /**
+ * Format the logs with HTML
+ */
class HtmlFormatter : public Formatter {
private:
@@ -152,6 +186,7 @@ class DefaultLogger : public Logger {
// Get current date
auto now = std::chrono::system_clock::now();
auto time = std::chrono::system_clock::to_time_t(now);
+ auto localTime = getLocalTime(time);
std::stringstream ss;
ss << "" << std::endl;
@@ -164,7 +199,7 @@ class DefaultLogger : public Logger {
ss << "ReactPhysics3D Logs
" << std::endl;
ss << "" << std::endl;
ss << "
ReactPhysics3D version: " << RP3D_VERSION << "
" << std::endl;
- ss << "
Date: " << std::put_time(std::localtime(&time), "%Y-%m-%d") << "
" << std::endl;
+ ss << "
Date: " << std::put_time(&localTime, "%Y-%m-%d") << "
" << std::endl;
ss << "
" << std::endl;
ss << "
";
@@ -275,11 +310,13 @@ class DefaultLogger : public Logger {
std::stringstream ss;
+ auto localTime = getLocalTime(time);
+
ss << "";
// Time
ss << "
";
- ss << std::put_time(std::localtime(&time), "%X");
+ ss << std::put_time(&localTime, "%X");
ss << "
";
// Message
@@ -315,7 +352,10 @@ class DefaultLogger : public Logger {
};
- /// Log destination
+ // Class Destination
+ /**
+ * destination for the logs
+ */
class Destination {
public:
@@ -344,6 +384,10 @@ class DefaultLogger : public Logger {
virtual size_t getSizeBytes() const=0;
};
+ // Class FileDestination
+ /**
+ * File destination for the logs
+ */
class FileDestination : public Destination {
private:
@@ -360,9 +404,7 @@ class DefaultLogger : public Logger {
:Destination(maxLevelFlag, formatter), mFilePath(filePath),
mFileStream(filePath, std::ios::binary) {
- if(!mFileStream.is_open()) {
- throw(std::runtime_error("ReactPhysics3D Logger: Unable to open an output stream to file " + mFilePath));
- }
+ assert(mFileStream.is_open());
// Write the header
mFileStream << formatter->getHeader() << std::endl;
@@ -396,7 +438,10 @@ class DefaultLogger : public Logger {
}
};
- /// Stream destination to output the logs into a stream
+ // Class TextFormatter
+ /**
+ * Stream destination for the logs
+ */
class StreamDestination : public Destination {
private:
@@ -487,9 +532,9 @@ class DefaultLogger : public Logger {
}
-// Hash function for struct VerticesPair
namespace std {
+ // Hash function for struct VerticesPair
template<> struct hash
{
size_t operator()(const reactphysics3d::DefaultLogger::Format format) const {
diff --git a/ext/reactphysics3d/include/reactphysics3d/utils/Logger.h b/ext/reactphysics3d/include/reactphysics3d/utils/Logger.h
index bf6a0d422..38cd5152a 100644
--- a/ext/reactphysics3d/include/reactphysics3d/utils/Logger.h
+++ b/ext/reactphysics3d/include/reactphysics3d/utils/Logger.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
diff --git a/ext/reactphysics3d/include/reactphysics3d/utils/Message.h b/ext/reactphysics3d/include/reactphysics3d/utils/Message.h
new file mode 100644
index 000000000..be39494c4
--- /dev/null
+++ b/ext/reactphysics3d/include/reactphysics3d/utils/Message.h
@@ -0,0 +1,63 @@
+/********************************************************************************
+* ReactPhysics3D physics library, http://www.reactphysics3d.com *
+* Copyright (c) 2010-2024 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 REACTPHYSICS3D_MESSAGE_H
+#define REACTPHYSICS3D_MESSAGE_H
+
+// Libraries
+#include
+
+/// ReactPhysics3D namespace
+namespace reactphysics3d {
+
+// Structure Message
+/**
+ * This structure represent a message that can be returned to the user
+ */
+struct Message {
+
+ public:
+
+ /// Type of message
+ enum class Type {Error = 1, Warning = 2, Information = 4};
+
+ /// Message text
+ std::string text;
+
+ // Type (error, warning, information)
+ Type type;
+
+ // -------------------- Methods -------------------- //
+
+ /// Constructor
+ Message(std::string text, Type type = Type::Error) : text(text), type(type) {
+
+ }
+};
+
+}
+
+#endif
+
diff --git a/ext/reactphysics3d/include/reactphysics3d/utils/Profiler.h b/ext/reactphysics3d/include/reactphysics3d/utils/Profiler.h
index b65a19d66..8aad066ee 100644
--- a/ext/reactphysics3d/include/reactphysics3d/utils/Profiler.h
+++ b/ext/reactphysics3d/include/reactphysics3d/utils/Profiler.h
@@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
-* Copyright (c) 2010-2022 Daniel Chappuis *
+* Copyright (c) 2010-2024 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@@ -229,9 +229,7 @@ class Profiler {
:Destination(format), mFilePath(filePath),
mFileStream(filePath, std::ios::binary) {
- if(!mFileStream.is_open()) {
- throw(std::runtime_error("ReactPhysics3D Logger: Unable to open an output stream to file " + mFilePath));
- }
+ assert(mFileStream.is_open());
}
/// Destructor
diff --git a/ext/reactphysics3d/include/reactphysics3d/utils/quickhull/QHHalfEdgeStructure.h b/ext/reactphysics3d/include/reactphysics3d/utils/quickhull/QHHalfEdgeStructure.h
new file mode 100644
index 000000000..a7a86b0cd
--- /dev/null
+++ b/ext/reactphysics3d/include/reactphysics3d/utils/quickhull/QHHalfEdgeStructure.h
@@ -0,0 +1,397 @@
+/********************************************************************************
+* ReactPhysics3D physics library, http://www.reactphysics3d.com *
+* Copyright (c) 2010-2024 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 REACTPHYSICS3D_QH_HALF_EDGE_STRUCTURE_MESH_H
+#define REACTPHYSICS3D_QH_HALF_EDGE_STRUCTURE_MESH_H
+
+// Libraries
+#include
+#include
+#include