Refactor profiler and start working on logger

This commit is contained in:
Daniel Chappuis 2018-03-14 07:33:28 +01:00
parent 62bd3bc115
commit 393bb0ed88
57 changed files with 1059 additions and 343 deletions

View File

@ -21,6 +21,7 @@ ENABLE_TESTING()
OPTION(COMPILE_TESTBED "Select this if you want to build the testbed application" OFF) OPTION(COMPILE_TESTBED "Select this if you want to build the testbed application" OFF)
OPTION(COMPILE_TESTS "Select this if you want to build the tests" OFF) OPTION(COMPILE_TESTS "Select this if you want to build the tests" OFF)
OPTION(PROFILING_ENABLED "Select this if you want to compile with enabled profiling" OFF) OPTION(PROFILING_ENABLED "Select this if you want to compile with enabled profiling" OFF)
OPTION(LOGS_ENABLED "Select this if you want to compile with logs enabled during execution" OFF)
OPTION(DOUBLE_PRECISION_ENABLED "Select this if you want to compile using double precision floating OPTION(DOUBLE_PRECISION_ENABLED "Select this if you want to compile using double precision floating
values" OFF) values" OFF)
@ -45,6 +46,10 @@ IF(PROFILING_ENABLED)
ADD_DEFINITIONS(-DIS_PROFILING_ACTIVE) ADD_DEFINITIONS(-DIS_PROFILING_ACTIVE)
ENDIF(PROFILING_ENABLED) ENDIF(PROFILING_ENABLED)
IF(LOGS_ENABLED)
ADD_DEFINITIONS(-DIS_LOGGING_ACTIVE)
ENDIF(LOGS_ENABLED)
IF(DOUBLE_PRECISION_ENABLED) IF(DOUBLE_PRECISION_ENABLED)
ADD_DEFINITIONS(-DIS_DOUBLE_PRECISION_ENABLED) ADD_DEFINITIONS(-DIS_DOUBLE_PRECISION_ENABLED)
ENDIF(DOUBLE_PRECISION_ENABLED) ENDIF(DOUBLE_PRECISION_ENABLED)
@ -164,8 +169,6 @@ SET (REACTPHYSICS3D_SOURCES
"src/engine/Material.cpp" "src/engine/Material.cpp"
"src/engine/OverlappingPair.h" "src/engine/OverlappingPair.h"
"src/engine/OverlappingPair.cpp" "src/engine/OverlappingPair.cpp"
"src/engine/Profiler.h"
"src/engine/Profiler.cpp"
"src/engine/Timer.h" "src/engine/Timer.h"
"src/engine/Timer.cpp" "src/engine/Timer.cpp"
"src/collision/CollisionCallback.h" "src/collision/CollisionCallback.h"
@ -201,6 +204,10 @@ SET (REACTPHYSICS3D_SOURCES
"src/containers/Map.h" "src/containers/Map.h"
"src/containers/Set.h" "src/containers/Set.h"
"src/containers/Pair.h" "src/containers/Pair.h"
"src/utils/Profiler.h"
"src/utils/Profiler.cpp"
"src/utils/Logger.h"
"src/utils/Logger.cpp"
) )
# Create the library # Create the library

View File

@ -92,7 +92,7 @@ class Body {
virtual ~Body() = default; virtual ~Body() = default;
/// Return the ID of the body /// Return the ID of the body
bodyindex getID() const; bodyindex getId() const;
/// Return whether or not the body is allowed to sleep /// Return whether or not the body is allowed to sleep
bool isAllowedToSleep() const; bool isAllowedToSleep() const;
@ -137,9 +137,9 @@ class Body {
// Return the id of the body // Return the id of the body
/** /**
* @return The ID of the body * @return The id of the body
*/ */
inline bodyindex Body::getID() const { inline bodyindex Body::getId() const {
return mID; return mID;
} }

View File

@ -36,7 +36,7 @@
#include "collision/RaycastInfo.h" #include "collision/RaycastInfo.h"
#include "memory/PoolAllocator.h" #include "memory/PoolAllocator.h"
#include "configuration.h" #include "configuration.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
/// Namespace reactphysics3d /// Namespace reactphysics3d
namespace reactphysics3d { namespace reactphysics3d {

View File

@ -459,7 +459,7 @@ void RigidBody::recomputeMassInformation() {
// Update the broad-phase state for this body (because it has moved for instance) // Update the broad-phase state for this body (because it has moved for instance)
void RigidBody::updateBroadPhaseState() const { void RigidBody::updateBroadPhaseState() const {
PROFILE("RigidBody::updateBroadPhaseState()", mProfiler); RP3D_PROFILE("RigidBody::updateBroadPhaseState()", mProfiler);
DynamicsWorld& world = static_cast<DynamicsWorld&>(mWorld); DynamicsWorld& world = static_cast<DynamicsWorld&>(mWorld);
const Vector3 displacement = world.mTimeStep * mLinearVelocity; const Vector3 displacement = world.mTimeStep * mLinearVelocity;

View File

@ -68,7 +68,7 @@ CollisionDetection::CollisionDetection(CollisionWorld* world, MemoryManager& mem
// Compute the collision detection // Compute the collision detection
void CollisionDetection::computeCollisionDetection() { void CollisionDetection::computeCollisionDetection() {
PROFILE("CollisionDetection::computeCollisionDetection()", mProfiler); RP3D_PROFILE("CollisionDetection::computeCollisionDetection()", mProfiler);
// Compute the broad-phase collision detection // Compute the broad-phase collision detection
computeBroadPhase(); computeBroadPhase();
@ -86,7 +86,7 @@ void CollisionDetection::computeCollisionDetection() {
// Compute the broad-phase collision detection // Compute the broad-phase collision detection
void CollisionDetection::computeBroadPhase() { void CollisionDetection::computeBroadPhase() {
PROFILE("CollisionDetection::computeBroadPhase()", mProfiler); RP3D_PROFILE("CollisionDetection::computeBroadPhase()", mProfiler);
// If new collision shapes have been added to bodies // If new collision shapes have been added to bodies
if (mIsCollisionShapesAdded) { if (mIsCollisionShapesAdded) {
@ -101,7 +101,7 @@ void CollisionDetection::computeBroadPhase() {
// Compute the middle-phase collision detection // Compute the middle-phase collision detection
void CollisionDetection::computeMiddlePhase() { void CollisionDetection::computeMiddlePhase() {
PROFILE("CollisionDetection::computeMiddlePhase()", mProfiler); RP3D_PROFILE("CollisionDetection::computeMiddlePhase()", mProfiler);
// For each possible collision pair of bodies // For each possible collision pair of bodies
Map<Pair<uint, uint>, OverlappingPair*>::Iterator it; Map<Pair<uint, uint>, OverlappingPair*>::Iterator it;
@ -251,7 +251,7 @@ void CollisionDetection::computeConvexVsConcaveMiddlePhase(OverlappingPair* pair
// Compute the narrow-phase collision detection // Compute the narrow-phase collision detection
void CollisionDetection::computeNarrowPhase() { void CollisionDetection::computeNarrowPhase() {
PROFILE("CollisionDetection::computeNarrowPhase()", mProfiler); RP3D_PROFILE("CollisionDetection::computeNarrowPhase()", mProfiler);
NarrowPhaseInfo* currentNarrowPhaseInfo = mNarrowPhaseInfoList; NarrowPhaseInfo* currentNarrowPhaseInfo = mNarrowPhaseInfoList;
while (currentNarrowPhaseInfo != nullptr) { while (currentNarrowPhaseInfo != nullptr) {
@ -364,7 +364,7 @@ void CollisionDetection::removeProxyCollisionShape(ProxyShape* proxyShape) {
void CollisionDetection::addAllContactManifoldsToBodies() { void CollisionDetection::addAllContactManifoldsToBodies() {
PROFILE("CollisionDetection::addAllContactManifoldsToBodies()", mProfiler); RP3D_PROFILE("CollisionDetection::addAllContactManifoldsToBodies()", mProfiler);
// For each overlapping pairs in contact during the narrow-phase // For each overlapping pairs in contact during the narrow-phase
Map<Pair<uint, uint>, OverlappingPair*>::Iterator it; Map<Pair<uint, uint>, OverlappingPair*>::Iterator it;
@ -415,7 +415,7 @@ void CollisionDetection::addContactManifoldToBody(OverlappingPair* pair) {
/// Convert the potential contact into actual contacts /// Convert the potential contact into actual contacts
void CollisionDetection::processAllPotentialContacts() { void CollisionDetection::processAllPotentialContacts() {
PROFILE("CollisionDetection::processAllPotentialContacts()", mProfiler); RP3D_PROFILE("CollisionDetection::processAllPotentialContacts()", mProfiler);
// For each overlapping pairs in contact during the narrow-phase // For each overlapping pairs in contact during the narrow-phase
Map<Pair<uint, uint>, OverlappingPair*>::Iterator it; Map<Pair<uint, uint>, OverlappingPair*>::Iterator it;
@ -454,7 +454,7 @@ void CollisionDetection::processPotentialContacts(OverlappingPair* pair) {
// Report contacts for all the colliding overlapping pairs // Report contacts for all the colliding overlapping pairs
void CollisionDetection::reportAllContacts() { void CollisionDetection::reportAllContacts() {
PROFILE("CollisionDetection::reportAllContacts()", mProfiler); RP3D_PROFILE("CollisionDetection::reportAllContacts()", mProfiler);
// For each overlapping pairs in contact during the narrow-phase // For each overlapping pairs in contact during the narrow-phase
Map<Pair<uint, uint>, OverlappingPair*>::Iterator it; Map<Pair<uint, uint>, OverlappingPair*>::Iterator it;
@ -532,13 +532,13 @@ void CollisionDetection::testAABBOverlap(const AABB& aabb, OverlapCallback* over
CollisionBody* overlapBody = proxyShape->getBody(); CollisionBody* overlapBody = proxyShape->getBody();
// If the proxy shape is from a body that we have not already reported collision // If the proxy shape is from a body that we have not already reported collision
if (reportedBodies.find(overlapBody->getID()) == reportedBodies.end()) { if (reportedBodies.find(overlapBody->getId()) == reportedBodies.end()) {
// Check if the collision filtering allows collision between the two shapes // Check if the collision filtering allows collision between the two shapes
if ((proxyShape->getCollisionCategoryBits() & categoryMaskBits) != 0) { if ((proxyShape->getCollisionCategoryBits() & categoryMaskBits) != 0) {
// Add the body into the set of reported bodies // Add the body into the set of reported bodies
reportedBodies.add(overlapBody->getID()); reportedBodies.add(overlapBody->getId());
// Notify the overlap to the user // Notify the overlap to the user
overlapCallback->notifyOverlap(overlapBody); overlapCallback->notifyOverlap(overlapBody);
@ -646,7 +646,7 @@ void CollisionDetection::testOverlap(CollisionBody* body, OverlapCallback* overl
LinkedList<int> overlappingNodes(mMemoryManager.getPoolAllocator()); LinkedList<int> overlappingNodes(mMemoryManager.getPoolAllocator());
mBroadPhaseAlgorithm.reportAllShapesOverlappingWithAABB(shapeAABB, overlappingNodes); mBroadPhaseAlgorithm.reportAllShapesOverlappingWithAABB(shapeAABB, overlappingNodes);
const bodyindex bodyId = body->getID(); const bodyindex bodyId = body->getId();
// For each overlaping proxy shape // For each overlaping proxy shape
LinkedList<int>::ListElement* element = overlappingNodes.getListHead(); LinkedList<int>::ListElement* element = overlappingNodes.getListHead();
@ -658,8 +658,8 @@ void CollisionDetection::testOverlap(CollisionBody* body, OverlapCallback* overl
// If the proxy shape is from a body that we have not already reported collision and the // If the proxy shape is from a body that we have not already reported collision and the
// two proxy collision shapes are not from the same body // two proxy collision shapes are not from the same body
if (reportedBodies.find(proxyShape->getBody()->getID()) == reportedBodies.end() && if (reportedBodies.find(proxyShape->getBody()->getId()) == reportedBodies.end() &&
proxyShape->getBody()->getID() != bodyId) { proxyShape->getBody()->getId() != bodyId) {
// Check if the collision filtering allows collision between the two shapes // Check if the collision filtering allows collision between the two shapes
if ((proxyShape->getCollisionCategoryBits() & categoryMaskBits) != 0) { if ((proxyShape->getCollisionCategoryBits() & categoryMaskBits) != 0) {
@ -711,7 +711,7 @@ void CollisionDetection::testOverlap(CollisionBody* body, OverlapCallback* overl
CollisionBody* overlapBody = proxyShape->getBody(); CollisionBody* overlapBody = proxyShape->getBody();
// Add the body into the set of reported bodies // Add the body into the set of reported bodies
reportedBodies.add(overlapBody->getID()); reportedBodies.add(overlapBody->getId());
// Notify the overlap to the user // Notify the overlap to the user
overlapCallback->notifyOverlap(overlapBody); overlapCallback->notifyOverlap(overlapBody);
@ -826,7 +826,7 @@ void CollisionDetection::testCollision(CollisionBody* body, CollisionCallback* c
LinkedList<int> overlappingNodes(mMemoryManager.getPoolAllocator()); LinkedList<int> overlappingNodes(mMemoryManager.getPoolAllocator());
mBroadPhaseAlgorithm.reportAllShapesOverlappingWithAABB(shapeAABB, overlappingNodes); mBroadPhaseAlgorithm.reportAllShapesOverlappingWithAABB(shapeAABB, overlappingNodes);
const bodyindex bodyId = body->getID(); const bodyindex bodyId = body->getId();
// For each overlaping proxy shape // For each overlaping proxy shape
LinkedList<int>::ListElement* element = overlappingNodes.getListHead(); LinkedList<int>::ListElement* element = overlappingNodes.getListHead();
@ -837,7 +837,7 @@ void CollisionDetection::testCollision(CollisionBody* body, CollisionCallback* c
ProxyShape* proxyShape = mBroadPhaseAlgorithm.getProxyShapeForBroadPhaseId(broadPhaseId); ProxyShape* proxyShape = mBroadPhaseAlgorithm.getProxyShapeForBroadPhaseId(broadPhaseId);
// If the two proxy collision shapes are not from the same body // If the two proxy collision shapes are not from the same body
if (proxyShape->getBody()->getID() != bodyId) { if (proxyShape->getBody()->getId() != bodyId) {
// Check if the collision filtering allows collision between the two shapes // Check if the collision filtering allows collision between the two shapes
if ((proxyShape->getCollisionCategoryBits() & categoryMaskBits) != 0) { if ((proxyShape->getCollisionCategoryBits() & categoryMaskBits) != 0) {

View File

@ -314,7 +314,7 @@ inline void CollisionDetection::raycast(RaycastCallback* raycastCallback,
const Ray& ray, const Ray& ray,
unsigned short raycastWithCategoryMaskBits) const { unsigned short raycastWithCategoryMaskBits) const {
PROFILE("CollisionDetection::raycast()", mProfiler); RP3D_PROFILE("CollisionDetection::raycast()", mProfiler);
RaycastTest rayCastTest(raycastCallback); RaycastTest rayCastTest(raycastCallback);

View File

@ -26,7 +26,7 @@
// Libraries // Libraries
#include "BroadPhaseAlgorithm.h" #include "BroadPhaseAlgorithm.h"
#include "collision/CollisionDetection.h" #include "collision/CollisionDetection.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
// We want to use the ReactPhysics3D namespace // We want to use the ReactPhysics3D namespace
using namespace reactphysics3d; using namespace reactphysics3d;
@ -257,7 +257,7 @@ void BroadPhaseAlgorithm::computeOverlappingPairs(MemoryManager& memoryManager)
ProxyShape* shape2 = static_cast<ProxyShape*>(mDynamicAABBTree.getNodeDataPointer(pair->collisionShape2ID)); ProxyShape* shape2 = static_cast<ProxyShape*>(mDynamicAABBTree.getNodeDataPointer(pair->collisionShape2ID));
// If the two proxy collision shapes are from the same body, skip it // If the two proxy collision shapes are from the same body, skip it
if (shape1->getBody()->getID() != shape2->getBody()->getID()) { if (shape1->getBody()->getId() != shape2->getBody()->getId()) {
// Notify the collision detection about the overlapping pair // Notify the collision detection about the overlapping pair
mCollisionDetection.broadPhaseNotifyOverlappingPair(shape1, shape2); mCollisionDetection.broadPhaseNotifyOverlappingPair(shape1, shape2);

View File

@ -30,7 +30,7 @@
#include "body/CollisionBody.h" #include "body/CollisionBody.h"
#include "collision/ProxyShape.h" #include "collision/ProxyShape.h"
#include "DynamicAABBTree.h" #include "DynamicAABBTree.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
#include "containers/LinkedList.h" #include "containers/LinkedList.h"
/// Namespace ReactPhysics3D /// Namespace ReactPhysics3D
@ -265,7 +265,7 @@ inline const AABB& BroadPhaseAlgorithm::getFatAABB(int broadPhaseId) const {
inline void BroadPhaseAlgorithm::raycast(const Ray& ray, RaycastTest& raycastTest, inline void BroadPhaseAlgorithm::raycast(const Ray& ray, RaycastTest& raycastTest,
unsigned short raycastWithCategoryMaskBits) const { unsigned short raycastWithCategoryMaskBits) const {
PROFILE("BroadPhaseAlgorithm::raycast()", mProfiler); RP3D_PROFILE("BroadPhaseAlgorithm::raycast()", mProfiler);
BroadPhaseRaycastCallback broadPhaseRaycastCallback(mDynamicAABBTree, raycastWithCategoryMaskBits, raycastTest); BroadPhaseRaycastCallback broadPhaseRaycastCallback(mDynamicAABBTree, raycastWithCategoryMaskBits, raycastTest);

View File

@ -27,7 +27,7 @@
#include "DynamicAABBTree.h" #include "DynamicAABBTree.h"
#include "BroadPhaseAlgorithm.h" #include "BroadPhaseAlgorithm.h"
#include "containers/Stack.h" #include "containers/Stack.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
using namespace reactphysics3d; using namespace reactphysics3d;
@ -173,7 +173,7 @@ void DynamicAABBTree::removeObject(int nodeID) {
/// (this can be useful if the shape AABB has become much smaller than the previous one for instance). /// (this can be useful if the shape AABB has become much smaller than the previous one for instance).
bool DynamicAABBTree::updateObject(int nodeID, const AABB& newAABB, const Vector3& displacement, bool forceReinsert) { bool DynamicAABBTree::updateObject(int nodeID, const AABB& newAABB, const Vector3& displacement, bool forceReinsert) {
PROFILE("DynamicAABBTree::updateObject()", mProfiler); RP3D_PROFILE("DynamicAABBTree::updateObject()", mProfiler);
assert(nodeID >= 0 && nodeID < mNbAllocatedNodes); assert(nodeID >= 0 && nodeID < mNbAllocatedNodes);
assert(mNodes[nodeID].isLeaf()); assert(mNodes[nodeID].isLeaf());
@ -635,7 +635,7 @@ void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& aabb,
// Ray casting method // Ray casting method
void DynamicAABBTree::raycast(const Ray& ray, DynamicAABBTreeRaycastCallback &callback) const { void DynamicAABBTree::raycast(const Ray& ray, DynamicAABBTreeRaycastCallback &callback) const {
PROFILE("DynamicAABBTree::raycast()", mProfiler); RP3D_PROFILE("DynamicAABBTree::raycast()", mProfiler);
decimal maxFraction = ray.maxFraction; decimal maxFraction = ray.maxFraction;

View File

@ -29,7 +29,7 @@
#include "engine/OverlappingPair.h" #include "engine/OverlappingPair.h"
#include "collision/shapes/TriangleShape.h" #include "collision/shapes/TriangleShape.h"
#include "configuration.h" #include "configuration.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <cfloat> #include <cfloat>
@ -49,7 +49,7 @@ using namespace reactphysics3d;
/// the correct penetration depth and contact points between the enlarged objects. /// the correct penetration depth and contact points between the enlarged objects.
GJKAlgorithm::GJKResult GJKAlgorithm::testCollision(NarrowPhaseInfo* narrowPhaseInfo, bool reportContacts) { GJKAlgorithm::GJKResult GJKAlgorithm::testCollision(NarrowPhaseInfo* narrowPhaseInfo, bool reportContacts) {
PROFILE("GJKAlgorithm::testCollision()", mProfiler); RP3D_PROFILE("GJKAlgorithm::testCollision()", mProfiler);
Vector3 suppA; // Support point of object A Vector3 suppA; // Support point of object A
Vector3 suppB; // Support point of object B Vector3 suppB; // Support point of object B

View File

@ -32,7 +32,7 @@
#include "engine/OverlappingPair.h" #include "engine/OverlappingPair.h"
#include "collision/shapes/TriangleShape.h" #include "collision/shapes/TriangleShape.h"
#include "configuration.h" #include "configuration.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <cfloat> #include <cfloat>
@ -52,7 +52,7 @@ SATAlgorithm::SATAlgorithm(MemoryAllocator& memoryAllocator) : mMemoryAllocator(
// Test collision between a sphere and a convex mesh // Test collision between a sphere and a convex mesh
bool SATAlgorithm::testCollisionSphereVsConvexPolyhedron(NarrowPhaseInfo* narrowPhaseInfo, bool reportContacts) const { bool SATAlgorithm::testCollisionSphereVsConvexPolyhedron(NarrowPhaseInfo* narrowPhaseInfo, bool reportContacts) const {
PROFILE("SATAlgorithm::testCollisionSphereVsConvexPolyhedron()", mProfiler); RP3D_PROFILE("SATAlgorithm::testCollisionSphereVsConvexPolyhedron()", mProfiler);
bool isSphereShape1 = narrowPhaseInfo->collisionShape1->getType() == CollisionShapeType::SPHERE; bool isSphereShape1 = narrowPhaseInfo->collisionShape1->getType() == CollisionShapeType::SPHERE;
@ -127,7 +127,7 @@ bool SATAlgorithm::testCollisionSphereVsConvexPolyhedron(NarrowPhaseInfo* narrow
decimal SATAlgorithm::computePolyhedronFaceVsSpherePenetrationDepth(uint faceIndex, const ConvexPolyhedronShape* polyhedron, decimal SATAlgorithm::computePolyhedronFaceVsSpherePenetrationDepth(uint faceIndex, const ConvexPolyhedronShape* polyhedron,
const SphereShape* sphere, const Vector3& sphereCenter) const { const SphereShape* sphere, const Vector3& sphereCenter) const {
PROFILE("SATAlgorithm::computePolyhedronFaceVsSpherePenetrationDepth)", mProfiler); RP3D_PROFILE("SATAlgorithm::computePolyhedronFaceVsSpherePenetrationDepth)", mProfiler);
// Get the face // Get the face
const HalfEdgeStructure::Face& face = polyhedron->getFace(faceIndex); const HalfEdgeStructure::Face& face = polyhedron->getFace(faceIndex);
@ -144,7 +144,7 @@ decimal SATAlgorithm::computePolyhedronFaceVsSpherePenetrationDepth(uint faceInd
// Test collision between a capsule and a convex mesh // Test collision between a capsule and a convex mesh
bool SATAlgorithm::testCollisionCapsuleVsConvexPolyhedron(NarrowPhaseInfo* narrowPhaseInfo, bool reportContacts) const { bool SATAlgorithm::testCollisionCapsuleVsConvexPolyhedron(NarrowPhaseInfo* narrowPhaseInfo, bool reportContacts) const {
PROFILE("SATAlgorithm::testCollisionCapsuleVsConvexPolyhedron()", mProfiler); RP3D_PROFILE("SATAlgorithm::testCollisionCapsuleVsConvexPolyhedron()", mProfiler);
bool isCapsuleShape1 = narrowPhaseInfo->collisionShape1->getType() == CollisionShapeType::CAPSULE; bool isCapsuleShape1 = narrowPhaseInfo->collisionShape1->getType() == CollisionShapeType::CAPSULE;
@ -304,7 +304,7 @@ decimal SATAlgorithm::computeEdgeVsCapsuleInnerSegmentPenetrationDepth(const Con
const Vector3& edgeDirectionCapsuleSpace, const Vector3& edgeDirectionCapsuleSpace,
const Transform& polyhedronToCapsuleTransform, Vector3& outAxis) const { const Transform& polyhedronToCapsuleTransform, Vector3& outAxis) const {
PROFILE("SATAlgorithm::computeEdgeVsCapsuleInnerSegmentPenetrationDepth)", mProfiler); RP3D_PROFILE("SATAlgorithm::computeEdgeVsCapsuleInnerSegmentPenetrationDepth)", mProfiler);
decimal penetrationDepth = DECIMAL_LARGEST; decimal penetrationDepth = DECIMAL_LARGEST;
@ -338,7 +338,7 @@ decimal SATAlgorithm::computePolyhedronFaceVsCapsulePenetrationDepth(uint polyhe
const CapsuleShape* capsule, const Transform& polyhedronToCapsuleTransform, const CapsuleShape* capsule, const Transform& polyhedronToCapsuleTransform,
Vector3& outFaceNormalCapsuleSpace) const { Vector3& outFaceNormalCapsuleSpace) const {
PROFILE("SATAlgorithm::computePolyhedronFaceVsCapsulePenetrationDepth", mProfiler); RP3D_PROFILE("SATAlgorithm::computePolyhedronFaceVsCapsulePenetrationDepth", mProfiler);
// Get the face // Get the face
const HalfEdgeStructure::Face& face = polyhedron->getFace(polyhedronFaceIndex); const HalfEdgeStructure::Face& face = polyhedron->getFace(polyhedronFaceIndex);
@ -364,7 +364,7 @@ bool SATAlgorithm::computeCapsulePolyhedronFaceContactPoints(uint referenceFaceI
const Vector3& capsuleSegAPolyhedronSpace, const Vector3& capsuleSegBPolyhedronSpace, const Vector3& capsuleSegAPolyhedronSpace, const Vector3& capsuleSegBPolyhedronSpace,
NarrowPhaseInfo* narrowPhaseInfo, bool isCapsuleShape1) const { NarrowPhaseInfo* narrowPhaseInfo, bool isCapsuleShape1) const {
PROFILE("SATAlgorithm::computeCapsulePolyhedronFaceContactPoints", mProfiler); RP3D_PROFILE("SATAlgorithm::computeCapsulePolyhedronFaceContactPoints", mProfiler);
const HalfEdgeStructure::Face& face = polyhedron->getFace(referenceFaceIndex); const HalfEdgeStructure::Face& face = polyhedron->getFace(referenceFaceIndex);
@ -459,7 +459,7 @@ bool SATAlgorithm::isMinkowskiFaceCapsuleVsEdge(const Vector3& capsuleSegment, c
// Test collision between two convex polyhedrons // Test collision between two convex polyhedrons
bool SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseInfo* narrowPhaseInfo, bool reportContacts) const { bool SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseInfo* narrowPhaseInfo, bool reportContacts) const {
PROFILE("SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron()", mProfiler); RP3D_PROFILE("SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron()", mProfiler);
assert(narrowPhaseInfo->collisionShape1->getType() == CollisionShapeType::CONVEX_POLYHEDRON); assert(narrowPhaseInfo->collisionShape1->getType() == CollisionShapeType::CONVEX_POLYHEDRON);
assert(narrowPhaseInfo->collisionShape2->getType() == CollisionShapeType::CONVEX_POLYHEDRON); assert(narrowPhaseInfo->collisionShape2->getType() == CollisionShapeType::CONVEX_POLYHEDRON);
@ -804,7 +804,7 @@ bool SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints(bool isMinPene
const Transform& polyhedron1ToPolyhedron2, const Transform& polyhedron2ToPolyhedron1, const Transform& polyhedron1ToPolyhedron2, const Transform& polyhedron2ToPolyhedron1,
uint minFaceIndex, NarrowPhaseInfo* narrowPhaseInfo, decimal minPenetrationDepth) const { uint minFaceIndex, NarrowPhaseInfo* narrowPhaseInfo, decimal minPenetrationDepth) const {
PROFILE("SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints", mProfiler); RP3D_PROFILE("SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints", mProfiler);
const ConvexPolyhedronShape* referencePolyhedron = isMinPenetrationFaceNormalPolyhedron1 ? polyhedron1 : polyhedron2; const ConvexPolyhedronShape* referencePolyhedron = isMinPenetrationFaceNormalPolyhedron1 ? polyhedron1 : polyhedron2;
const ConvexPolyhedronShape* incidentPolyhedron = isMinPenetrationFaceNormalPolyhedron1 ? polyhedron2 : polyhedron1; const ConvexPolyhedronShape* incidentPolyhedron = isMinPenetrationFaceNormalPolyhedron1 ? polyhedron2 : polyhedron1;
@ -919,7 +919,7 @@ decimal SATAlgorithm::computeDistanceBetweenEdges(const Vector3& edge1A, const V
const Vector3& edge1Direction, const Vector3& edge2Direction, const Vector3& edge1Direction, const Vector3& edge2Direction,
Vector3& outSeparatingAxisPolyhedron2Space) const { Vector3& outSeparatingAxisPolyhedron2Space) const {
PROFILE("SATAlgorithm::computeDistanceBetweenEdges", mProfiler); RP3D_PROFILE("SATAlgorithm::computeDistanceBetweenEdges", mProfiler);
// If the two edges are parallel // If the two edges are parallel
if (areParallelVectors(edge1Direction, edge2Direction)) { if (areParallelVectors(edge1Direction, edge2Direction)) {
@ -948,7 +948,7 @@ decimal SATAlgorithm::testSingleFaceDirectionPolyhedronVsPolyhedron(const Convex
const Transform& polyhedron1ToPolyhedron2, const Transform& polyhedron1ToPolyhedron2,
uint faceIndex) const { uint faceIndex) const {
PROFILE("SATAlgorithm::testSingleFaceDirectionPolyhedronVsPolyhedron", mProfiler); RP3D_PROFILE("SATAlgorithm::testSingleFaceDirectionPolyhedronVsPolyhedron", mProfiler);
const HalfEdgeStructure::Face& face = polyhedron1->getFace(faceIndex); const HalfEdgeStructure::Face& face = polyhedron1->getFace(faceIndex);
@ -974,7 +974,7 @@ decimal SATAlgorithm::testFacesDirectionPolyhedronVsPolyhedron(const ConvexPolyh
const Transform& polyhedron1ToPolyhedron2, const Transform& polyhedron1ToPolyhedron2,
uint& minFaceIndex) const { uint& minFaceIndex) const {
PROFILE("SATAlgorithm::testFacesDirectionPolyhedronVsPolyhedron", mProfiler); RP3D_PROFILE("SATAlgorithm::testFacesDirectionPolyhedronVsPolyhedron", mProfiler);
decimal minPenetrationDepth = DECIMAL_LARGEST; decimal minPenetrationDepth = DECIMAL_LARGEST;
@ -1006,7 +1006,7 @@ bool SATAlgorithm::testEdgesBuildMinkowskiFace(const ConvexPolyhedronShape* poly
const ConvexPolyhedronShape* polyhedron2, const HalfEdgeStructure::Edge& edge2, const ConvexPolyhedronShape* polyhedron2, const HalfEdgeStructure::Edge& edge2,
const Transform& polyhedron1ToPolyhedron2) const { const Transform& polyhedron1ToPolyhedron2) const {
PROFILE("SATAlgorithm::testEdgesBuildMinkowskiFace", mProfiler); RP3D_PROFILE("SATAlgorithm::testEdgesBuildMinkowskiFace", mProfiler);
const Vector3 a = polyhedron1ToPolyhedron2.getOrientation() * polyhedron1->getFaceNormal(edge1.faceIndex); const Vector3 a = polyhedron1ToPolyhedron2.getOrientation() * polyhedron1->getFaceNormal(edge1.faceIndex);
const Vector3 b = polyhedron1ToPolyhedron2.getOrientation() * polyhedron1->getFaceNormal(polyhedron1->getHalfEdge(edge1.twinEdgeIndex).faceIndex); const Vector3 b = polyhedron1ToPolyhedron2.getOrientation() * polyhedron1->getFaceNormal(polyhedron1->getHalfEdge(edge1.twinEdgeIndex).faceIndex);
@ -1039,7 +1039,7 @@ bool SATAlgorithm::testEdgesBuildMinkowskiFace(const ConvexPolyhedronShape* poly
bool SATAlgorithm::testGaussMapArcsIntersect(const Vector3& a, const Vector3& b, const Vector3& c, const Vector3& d, bool SATAlgorithm::testGaussMapArcsIntersect(const Vector3& a, const Vector3& b, const Vector3& c, const Vector3& d,
const Vector3& bCrossA, const Vector3& dCrossC) const { const Vector3& bCrossA, const Vector3& dCrossC) const {
PROFILE("SATAlgorithm::testGaussMapArcsIntersect", mProfiler); RP3D_PROFILE("SATAlgorithm::testGaussMapArcsIntersect", mProfiler);
const decimal cba = c.dot(bCrossA); const decimal cba = c.dot(bCrossA);
const decimal dba = d.dot(bCrossA); const decimal dba = d.dot(bCrossA);

View File

@ -25,7 +25,7 @@
// Libraries // Libraries
#include "CollisionShape.h" #include "CollisionShape.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
#include "body/CollisionBody.h" #include "body/CollisionBody.h"
// We want to use the ReactPhysics3D namespace // We want to use the ReactPhysics3D namespace
@ -48,7 +48,7 @@ CollisionShape::CollisionShape(CollisionShapeName name, CollisionShapeType type)
*/ */
void CollisionShape::computeAABB(AABB& aabb, const Transform& transform) const { void CollisionShape::computeAABB(AABB& aabb, const Transform& transform) const {
PROFILE("CollisionShape::computeAABB()", mProfiler); RP3D_PROFILE("CollisionShape::computeAABB()", mProfiler);
// Get the local bounds in x,y and z direction // Get the local bounds in x,y and z direction
Vector3 minBounds; Vector3 minBounds;

View File

@ -35,7 +35,7 @@
#include "AABB.h" #include "AABB.h"
#include "collision/RaycastInfo.h" #include "collision/RaycastInfo.h"
#include "memory/PoolAllocator.h" #include "memory/PoolAllocator.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
/// ReactPhysics3D namespace /// ReactPhysics3D namespace
namespace reactphysics3d { namespace reactphysics3d {

View File

@ -114,7 +114,7 @@ void ConcaveMeshShape::testAllTriangles(TriangleCallback& callback, const AABB&
/// the ray hits many triangles. /// the ray hits many triangles.
bool ConcaveMeshShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape, MemoryAllocator& allocator) const { bool ConcaveMeshShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape, MemoryAllocator& allocator) const {
PROFILE("ConcaveMeshShape::raycast()", mProfiler); RP3D_PROFILE("ConcaveMeshShape::raycast()", mProfiler);
// Create the callback object that will compute ray casting against triangles // Create the callback object that will compute ray casting against triangles
ConcaveMeshRaycastCallback raycastCallback(mDynamicAABBTree, *this, proxyShape, raycastInfo, ray, allocator); ConcaveMeshRaycastCallback raycastCallback(mDynamicAABBTree, *this, proxyShape, raycastInfo, ray, allocator);

View File

@ -32,7 +32,7 @@
#include "collision/TriangleMesh.h" #include "collision/TriangleMesh.h"
#include "collision/shapes/TriangleShape.h" #include "collision/shapes/TriangleShape.h"
#include "containers/List.h" #include "containers/List.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
namespace reactphysics3d { namespace reactphysics3d {

View File

@ -217,7 +217,7 @@ bool HeightFieldShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxySh
// TODO : Implement raycasting without using an AABB for the ray // TODO : Implement raycasting without using an AABB for the ray
// but using a dynamic AABB tree or octree instead // but using a dynamic AABB tree or octree instead
PROFILE("HeightFieldShape::raycast()", mProfiler); RP3D_PROFILE("HeightFieldShape::raycast()", mProfiler);
TriangleOverlapCallback triangleCallback(ray, proxyShape, raycastInfo, *this, allocator); TriangleOverlapCallback triangleCallback(ray, proxyShape, raycastInfo, *this, allocator);

View File

@ -29,7 +29,7 @@
// Libraries // Libraries
#include "ConcaveShape.h" #include "ConcaveShape.h"
#include "collision/shapes/TriangleShape.h" #include "collision/shapes/TriangleShape.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
namespace reactphysics3d { namespace reactphysics3d {

View File

@ -27,7 +27,7 @@
#include "TriangleShape.h" #include "TriangleShape.h"
#include "collision/ProxyShape.h" #include "collision/ProxyShape.h"
#include "mathematics/mathematics_functions.h" #include "mathematics/mathematics_functions.h"
#include "engine/Profiler.h" #include "utils/Profiler.h"
#include "configuration.h" #include "configuration.h"
#include <cassert> #include <cassert>
@ -213,7 +213,7 @@ Vector3 TriangleShape::computeSmoothLocalContactNormalForTriangle(const Vector3&
/// Real-time Collision Detection by Christer Ericson. /// Real-time Collision Detection by Christer Ericson.
bool TriangleShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape, MemoryAllocator& allocator) const { bool TriangleShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape, MemoryAllocator& allocator) const {
PROFILE("TriangleShape::raycast()", mProfiler); RP3D_PROFILE("TriangleShape::raycast()", mProfiler);
const Vector3 pq = ray.point2 - ray.point1; const Vector3 pq = ray.point2 - ray.point1;
const Vector3 pa = mPoints[0] - ray.point1; const Vector3 pa = mPoints[0] - ray.point1;

View File

@ -33,8 +33,8 @@ using namespace reactphysics3d;
const decimal BallAndSocketJoint::BETA = decimal(0.2); const decimal BallAndSocketJoint::BETA = decimal(0.2);
// Constructor // Constructor
BallAndSocketJoint::BallAndSocketJoint(const BallAndSocketJointInfo& jointInfo) BallAndSocketJoint::BallAndSocketJoint(uint id, const BallAndSocketJointInfo& jointInfo)
: Joint(jointInfo), mImpulse(Vector3(0, 0, 0)) { : Joint(id, jointInfo), mImpulse(Vector3(0, 0, 0)) {
// Compute the local-space anchor point for each body // Compute the local-space anchor point for each body
mLocalAnchorPointBody1 = mBody1->getTransform().getInverse() * jointInfo.anchorPointWorldSpace; mLocalAnchorPointBody1 = mBody1->getTransform().getInverse() * jointInfo.anchorPointWorldSpace;

View File

@ -125,7 +125,7 @@ class BallAndSocketJoint : public Joint {
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Constructor /// Constructor
BallAndSocketJoint(const BallAndSocketJointInfo& jointInfo); BallAndSocketJoint(uint id, const BallAndSocketJointInfo& jointInfo);
/// Destructor /// Destructor
virtual ~BallAndSocketJoint() override = default; virtual ~BallAndSocketJoint() override = default;

View File

@ -33,8 +33,8 @@ using namespace reactphysics3d;
const decimal FixedJoint::BETA = decimal(0.2); const decimal FixedJoint::BETA = decimal(0.2);
// Constructor // Constructor
FixedJoint::FixedJoint(const FixedJointInfo& jointInfo) FixedJoint::FixedJoint(uint id, const FixedJointInfo& jointInfo)
: Joint(jointInfo), mImpulseTranslation(0, 0, 0), mImpulseRotation(0, 0, 0) { : Joint(id, jointInfo), mImpulseTranslation(0, 0, 0), mImpulseRotation(0, 0, 0) {
// Compute the local-space anchor point for each body // Compute the local-space anchor point for each body
const Transform& transform1 = mBody1->getTransform(); const Transform& transform1 = mBody1->getTransform();

View File

@ -136,7 +136,7 @@ class FixedJoint : public Joint {
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Constructor /// Constructor
FixedJoint(const FixedJointInfo& jointInfo); FixedJoint(uint id, const FixedJointInfo& jointInfo);
/// Destructor /// Destructor
virtual ~FixedJoint() override = default; virtual ~FixedJoint() override = default;

View File

@ -34,8 +34,8 @@ using namespace reactphysics3d;
const decimal HingeJoint::BETA = decimal(0.2); const decimal HingeJoint::BETA = decimal(0.2);
// Constructor // Constructor
HingeJoint::HingeJoint(const HingeJointInfo& jointInfo) HingeJoint::HingeJoint(uint id, const HingeJointInfo& jointInfo)
: Joint(jointInfo), mImpulseTranslation(0, 0, 0), mImpulseRotation(0, 0), : Joint(id, jointInfo), mImpulseTranslation(0, 0, 0), mImpulseRotation(0, 0),
mImpulseLowerLimit(0), mImpulseUpperLimit(0), mImpulseMotor(0), mImpulseLowerLimit(0), mImpulseUpperLimit(0), mImpulseMotor(0),
mIsLimitEnabled(jointInfo.isLimitEnabled), mIsMotorEnabled(jointInfo.isMotorEnabled), mIsLimitEnabled(jointInfo.isLimitEnabled), mIsMotorEnabled(jointInfo.isMotorEnabled),
mLowerLimit(jointInfo.minAngleLimit), mUpperLimit(jointInfo.maxAngleLimit), mLowerLimit(jointInfo.minAngleLimit), mUpperLimit(jointInfo.maxAngleLimit),

View File

@ -287,7 +287,7 @@ class HingeJoint : public Joint {
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Constructor /// Constructor
HingeJoint(const HingeJointInfo& jointInfo); HingeJoint(uint id, const HingeJointInfo& jointInfo);
/// Destructor /// Destructor
virtual ~HingeJoint() override = default; virtual ~HingeJoint() override = default;

View File

@ -29,8 +29,8 @@
using namespace reactphysics3d; using namespace reactphysics3d;
// Constructor // Constructor
Joint::Joint(const JointInfo& jointInfo) Joint::Joint(uint id, const JointInfo& jointInfo)
:mBody1(jointInfo.body1), mBody2(jointInfo.body2), mType(jointInfo.type), :mId(id), mBody1(jointInfo.body1), mBody2(jointInfo.body2), mType(jointInfo.type),
mPositionCorrectionTechnique(jointInfo.positionCorrectionTechnique), mPositionCorrectionTechnique(jointInfo.positionCorrectionTechnique),
mIsCollisionEnabled(jointInfo.isCollisionEnabled), mIsAlreadyInIsland(false) { mIsCollisionEnabled(jointInfo.isCollisionEnabled), mIsAlreadyInIsland(false) {

View File

@ -120,6 +120,9 @@ class Joint {
// -------------------- Attributes -------------------- // // -------------------- Attributes -------------------- //
/// Id of the joint
uint mId;
/// Pointer to the first body of the joint /// Pointer to the first body of the joint
RigidBody* const mBody1; RigidBody* const mBody1;
@ -144,6 +147,9 @@ class Joint {
/// True if the joint has already been added into an island /// True if the joint has already been added into an island
bool mIsAlreadyInIsland; bool mIsAlreadyInIsland;
/// Total number of joints
static uint mNbTotalNbJoints;
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Return true if the joint has already been added into an island /// Return true if the joint has already been added into an island
@ -169,7 +175,7 @@ class Joint {
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Constructor /// Constructor
Joint(const JointInfo& jointInfo); Joint(uint id, const JointInfo& jointInfo);
/// Destructor /// Destructor
virtual ~Joint() = default; virtual ~Joint() = default;
@ -195,6 +201,9 @@ class Joint {
/// Return true if the collision between the two bodies of the joint is enabled /// Return true if the collision between the two bodies of the joint is enabled
bool isCollisionEnabled() const; bool isCollisionEnabled() const;
/// Return the id of the joint
uint getId() const;
// -------------------- Friendship -------------------- // // -------------------- Friendship -------------------- //
friend class DynamicsWorld; friend class DynamicsWorld;
@ -243,6 +252,14 @@ inline bool Joint::isCollisionEnabled() const {
return mIsCollisionEnabled; return mIsCollisionEnabled;
} }
// Return the id of the joint
/**
* @return The id of the joint
*/
inline uint Joint::getId() const {
return mId;
}
// Return true if the joint has already been added into an island // Return true if the joint has already been added into an island
inline bool Joint::isAlreadyInIsland() const { inline bool Joint::isAlreadyInIsland() const {
return mIsAlreadyInIsland; return mIsAlreadyInIsland;

View File

@ -32,8 +32,8 @@ using namespace reactphysics3d;
const decimal SliderJoint::BETA = decimal(0.2); const decimal SliderJoint::BETA = decimal(0.2);
// Constructor // Constructor
SliderJoint::SliderJoint(const SliderJointInfo& jointInfo) SliderJoint::SliderJoint(uint id, const SliderJointInfo& jointInfo)
: Joint(jointInfo), mImpulseTranslation(0, 0), mImpulseRotation(0, 0, 0), : Joint(id, jointInfo), mImpulseTranslation(0, 0), mImpulseRotation(0, 0, 0),
mImpulseLowerLimit(0), mImpulseUpperLimit(0), mImpulseMotor(0), mImpulseLowerLimit(0), mImpulseUpperLimit(0), mImpulseMotor(0),
mIsLimitEnabled(jointInfo.isLimitEnabled), mIsMotorEnabled(jointInfo.isMotorEnabled), mIsLimitEnabled(jointInfo.isLimitEnabled), mIsMotorEnabled(jointInfo.isMotorEnabled),
mLowerLimit(jointInfo.minTranslationLimit), mLowerLimit(jointInfo.minTranslationLimit),

View File

@ -285,7 +285,7 @@ class SliderJoint : public Joint {
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Constructor /// Constructor
SliderJoint(const SliderJointInfo& jointInfo); SliderJoint(uint id, const SliderJointInfo& jointInfo);
/// Destructor /// Destructor
virtual ~SliderJoint() override = default; virtual ~SliderJoint() override = default;

View File

@ -29,6 +29,7 @@
// Libraries // Libraries
#include "configuration.h" #include "configuration.h"
#include "memory/MemoryAllocator.h" #include "memory/MemoryAllocator.h"
#include <cassert>
#include <cstring> #include <cstring>
#include <iterator> #include <iterator>

View File

@ -86,7 +86,7 @@ class Pair {
} }
// Hash function for struct VerticesPair // Hash function for a reactphysics3d Pair
namespace std { namespace std {
template <typename T1, typename T2> struct hash<reactphysics3d::Pair<T1, T2>> { template <typename T1, typename T2> struct hash<reactphysics3d::Pair<T1, T2>> {

View File

@ -26,28 +26,64 @@
// Libraries // Libraries
#include "CollisionWorld.h" #include "CollisionWorld.h"
#include <algorithm> #include <algorithm>
#include <sstream>
// Namespaces // Namespaces
using namespace reactphysics3d; using namespace reactphysics3d;
using namespace std; using namespace std;
// Initialization of static fields
uint CollisionWorld::mNbWorlds = 0;
// Constructor // Constructor
CollisionWorld::CollisionWorld(const WorldSettings& worldSettings) CollisionWorld::CollisionWorld(const string& name, const WorldSettings& worldSettings)
: mConfig(worldSettings), mCollisionDetection(this, mMemoryManager), mBodies(mMemoryManager.getPoolAllocator()), mCurrentBodyID(0), : mConfig(worldSettings), mCollisionDetection(this, mMemoryManager), mBodies(mMemoryManager.getPoolAllocator()), mCurrentBodyId(0),
mFreeBodiesIDs(mMemoryManager.getPoolAllocator()), mEventListener(nullptr) { mFreeBodiesIds(mMemoryManager.getPoolAllocator()), mEventListener(nullptr), mName(name) {
// Automatically generate a name for the world
if (mName == "") {
std::stringstream ss;
ss << "world";
if (mNbWorlds > 0) {
ss << mNbWorlds;
}
mName = ss.str();
}
#ifdef IS_PROFILING_ACTIVE #ifdef IS_PROFILING_ACTIVE
// Set the profiler // Add a destination file for the profiling data
mCollisionDetection.setProfiler(&mProfiler); mProfiler.addFileDestination("rp3d_profiling_" + mName + ".txt", Profiler::Format::Text);
// Set the profiler
mCollisionDetection.setProfiler(&mProfiler);
#endif #endif
#ifdef IS_LOGGING_ACTIVE
// Add a log destination file
uint logLevel = static_cast<uint>(Logger::Level::Info) | static_cast<uint>(Logger::Level::Warning) |
static_cast<uint>(Logger::Level::Error);
mLogger.addFileDestination("rp3d_log_" + mName + ".html", logLevel, Logger::Format::HTML);
#endif
mNbWorlds++;
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Collision World: Collision world " + mName + " has been created");
} }
// Destructor // Destructor
CollisionWorld::~CollisionWorld() { CollisionWorld::~CollisionWorld() {
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Collision World: Collision world " + mName + " has been destroyed");
// Destroy all the collision bodies that have not been removed // Destroy all the collision bodies that have not been removed
for (int i=mBodies.size() - 1 ; i >= 0; i--) { for (int i=mBodies.size() - 1 ; i >= 0; i--) {
destroyCollisionBody(mBodies[i]); destroyCollisionBody(mBodies[i]);
@ -64,7 +100,7 @@ CollisionWorld::~CollisionWorld() {
CollisionBody* CollisionWorld::createCollisionBody(const Transform& transform) { CollisionBody* CollisionWorld::createCollisionBody(const Transform& transform) {
// Get the next available body ID // Get the next available body ID
bodyindex bodyID = computeNextAvailableBodyID(); bodyindex bodyID = computeNextAvailableBodyId();
// Largest index cannot be used (it is used for invalid index) // Largest index cannot be used (it is used for invalid index)
assert(bodyID < std::numeric_limits<reactphysics3d::bodyindex>::max()); assert(bodyID < std::numeric_limits<reactphysics3d::bodyindex>::max());
@ -85,6 +121,9 @@ CollisionBody* CollisionWorld::createCollisionBody(const Transform& transform) {
#endif #endif
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::Body,
"Collision Body " + std::to_string(bodyID) + ": New collision body created");
// Return the pointer to the rigid body // Return the pointer to the rigid body
return collisionBody; return collisionBody;
} }
@ -95,11 +134,14 @@ CollisionBody* CollisionWorld::createCollisionBody(const Transform& transform) {
*/ */
void CollisionWorld::destroyCollisionBody(CollisionBody* collisionBody) { void CollisionWorld::destroyCollisionBody(CollisionBody* collisionBody) {
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::Body,
"Collision Body " + std::to_string(collisionBody->getId()) + ": collision body destroyed");
// Remove all the collision shapes of the body // Remove all the collision shapes of the body
collisionBody->removeAllCollisionShapes(); collisionBody->removeAllCollisionShapes();
// Add the body ID to the list of free IDs // Add the body ID to the list of free IDs
mFreeBodiesIDs.add(collisionBody->getID()); mFreeBodiesIds.add(collisionBody->getId());
// Call the destructor of the collision body // Call the destructor of the collision body
collisionBody->~CollisionBody(); collisionBody->~CollisionBody();
@ -112,17 +154,17 @@ void CollisionWorld::destroyCollisionBody(CollisionBody* collisionBody) {
} }
// Return the next available body ID // Return the next available body ID
bodyindex CollisionWorld::computeNextAvailableBodyID() { bodyindex CollisionWorld::computeNextAvailableBodyId() {
// Compute the body ID // Compute the body ID
bodyindex bodyID; bodyindex bodyID;
if (mFreeBodiesIDs.size() != 0) { if (mFreeBodiesIds.size() != 0) {
bodyID = mFreeBodiesIDs[mFreeBodiesIDs.size() - 1]; bodyID = mFreeBodiesIds[mFreeBodiesIds.size() - 1];
mFreeBodiesIDs.removeAt(mFreeBodiesIDs.size() - 1); mFreeBodiesIds.removeAt(mFreeBodiesIds.size() - 1);
} }
else { else {
bodyID = mCurrentBodyID; bodyID = mCurrentBodyId;
mCurrentBodyID++; mCurrentBodyId++;
} }
return bodyID; return bodyID;

View File

@ -30,7 +30,8 @@
#include <algorithm> #include <algorithm>
#include "mathematics/mathematics.h" #include "mathematics/mathematics.h"
#include "containers/List.h" #include "containers/List.h"
#include "Profiler.h" #include "utils/Profiler.h"
#include "utils/Logger.h"
#include "body/CollisionBody.h" #include "body/CollisionBody.h"
#include "collision/RaycastInfo.h" #include "collision/RaycastInfo.h"
#include "OverlappingPair.h" #include "OverlappingPair.h"
@ -71,25 +72,37 @@ class CollisionWorld {
/// All the bodies (rigid and soft) of the world /// All the bodies (rigid and soft) of the world
List<CollisionBody*> mBodies; List<CollisionBody*> mBodies;
/// Current body ID /// Current body id
bodyindex mCurrentBodyID; bodyindex mCurrentBodyId;
/// List of free ID for rigid bodies /// List of free ids for rigid bodies
List<luint> mFreeBodiesIDs; List<luint> mFreeBodiesIds;
/// Pointer to an event listener object /// Pointer to an event listener object
EventListener* mEventListener; EventListener* mEventListener;
/// Name of the collision world
std::string mName;
#ifdef IS_PROFILING_ACTIVE #ifdef IS_PROFILING_ACTIVE
/// Real-time hierarchical profiler /// Real-time hierarchical profiler
Profiler mProfiler; Profiler mProfiler;
#endif #endif
#ifdef IS_LOGGING_ACTIVE
/// Logger
Logger mLogger;
#endif
/// Total number of worlds
static uint mNbWorlds;
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Return the next available body ID /// Return the next available body id
bodyindex computeNextAvailableBodyID(); bodyindex computeNextAvailableBodyId();
/// Reset all the contact manifolds linked list of each body /// Reset all the contact manifolds linked list of each body
void resetContactManifoldListsOfBodies(); void resetContactManifoldListsOfBodies();
@ -99,7 +112,7 @@ class CollisionWorld {
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Constructor /// Constructor
CollisionWorld(const WorldSettings& worldSettings = WorldSettings()); CollisionWorld(const std::string& name = "", const WorldSettings& worldSettings = WorldSettings());
/// Destructor /// Destructor
virtual ~CollisionWorld(); virtual ~CollisionWorld();
@ -147,13 +160,24 @@ class CollisionWorld {
#ifdef IS_PROFILING_ACTIVE #ifdef IS_PROFILING_ACTIVE
/// Set the name of the profiler /// Return a reference to the profiler
void setProfilerName(std::string name); Profiler& getProfiler();
#endif
#ifdef IS_LOGGING_ACTIVE
/// Return a reference to the logger
Logger& getLogger();
#endif #endif
/// Return the current world-space AABB of given proxy shape /// Return the current world-space AABB of given proxy shape
AABB getWorldAABB(const ProxyShape* proxyShape) const; AABB getWorldAABB(const ProxyShape* proxyShape) const;
/// Return the name of the world
const std::string& getName() const;
// -------------------- Friendship -------------------- // // -------------------- Friendship -------------------- //
friend class CollisionDetection; friend class CollisionDetection;
@ -224,11 +248,25 @@ inline void CollisionWorld::testOverlap(CollisionBody* body, OverlapCallback* ov
mCollisionDetection.testOverlap(body, overlapCallback, categoryMaskBits); mCollisionDetection.testOverlap(body, overlapCallback, categoryMaskBits);
} }
// Return the name of the world
inline const std::string& CollisionWorld::getName() const {
return mName;
}
#ifdef IS_PROFILING_ACTIVE #ifdef IS_PROFILING_ACTIVE
// Set the name of the profiler // Return a reference to the profiler
inline void CollisionWorld::setProfilerName(std::string name) { inline Profiler& CollisionWorld::getProfiler() {
mProfiler.setName(name); return mProfiler;
}
#endif
#ifdef IS_LOGGING_ACTIVE
// Return a reference to the logger
inline Logger& CollisionWorld::getLogger() {
return mLogger;
} }
#endif #endif

View File

@ -25,7 +25,7 @@
// Libraries // Libraries
#include "ConstraintSolver.h" #include "ConstraintSolver.h"
#include "Profiler.h" #include "utils/Profiler.h"
using namespace reactphysics3d; using namespace reactphysics3d;
@ -43,7 +43,7 @@ ConstraintSolver::ConstraintSolver() : mIsWarmStartingActive(true) {
// Initialize the constraint solver for a given island // Initialize the constraint solver for a given island
void ConstraintSolver::initializeForIsland(decimal dt, Island* island) { void ConstraintSolver::initializeForIsland(decimal dt, Island* island) {
PROFILE("ConstraintSolver::initializeForIsland()", mProfiler); RP3D_PROFILE("ConstraintSolver::initializeForIsland()", mProfiler);
assert(island != nullptr); assert(island != nullptr);
assert(island->getNbBodies() > 0); assert(island->getNbBodies() > 0);
@ -73,7 +73,7 @@ void ConstraintSolver::initializeForIsland(decimal dt, Island* island) {
// Solve the velocity constraints // Solve the velocity constraints
void ConstraintSolver::solveVelocityConstraints(Island* island) { void ConstraintSolver::solveVelocityConstraints(Island* island) {
PROFILE("ConstraintSolver::solveVelocityConstraints()", mProfiler); RP3D_PROFILE("ConstraintSolver::solveVelocityConstraints()", mProfiler);
assert(island != nullptr); assert(island != nullptr);
assert(island->getNbJoints() > 0); assert(island->getNbJoints() > 0);
@ -90,7 +90,7 @@ void ConstraintSolver::solveVelocityConstraints(Island* island) {
// Solve the position constraints // Solve the position constraints
void ConstraintSolver::solvePositionConstraints(Island* island) { void ConstraintSolver::solvePositionConstraints(Island* island) {
PROFILE("ConstraintSolver::solvePositionConstraints()", mProfiler); RP3D_PROFILE("ConstraintSolver::solvePositionConstraints()", mProfiler);
assert(island != nullptr); assert(island != nullptr);
assert(island->getNbJoints() > 0); assert(island->getNbJoints() > 0);

View File

@ -27,7 +27,7 @@
#include "ContactSolver.h" #include "ContactSolver.h"
#include "DynamicsWorld.h" #include "DynamicsWorld.h"
#include "body/RigidBody.h" #include "body/RigidBody.h"
#include "Profiler.h" #include "utils/Profiler.h"
#include <limits> #include <limits>
using namespace reactphysics3d; using namespace reactphysics3d;
@ -50,7 +50,7 @@ ContactSolver::ContactSolver(MemoryManager& memoryManager, const WorldSettings&
// Initialize the contact constraints // Initialize the contact constraints
void ContactSolver::init(Island** islands, uint nbIslands, decimal timeStep) { void ContactSolver::init(Island** islands, uint nbIslands, decimal timeStep) {
PROFILE("ContactSolver::init()", mProfiler); RP3D_PROFILE("ContactSolver::init()", mProfiler);
mTimeStep = timeStep; mTimeStep = timeStep;
@ -98,7 +98,7 @@ void ContactSolver::init(Island** islands, uint nbIslands, decimal timeStep) {
// Initialize the constraint solver for a given island // Initialize the constraint solver for a given island
void ContactSolver::initializeForIsland(Island* island) { void ContactSolver::initializeForIsland(Island* island) {
PROFILE("ContactSolver::initializeForIsland()", mProfiler); RP3D_PROFILE("ContactSolver::initializeForIsland()", mProfiler);
assert(island != nullptr); assert(island != nullptr);
assert(island->getNbBodies() > 0); assert(island->getNbBodies() > 0);
@ -326,7 +326,7 @@ void ContactSolver::initializeForIsland(Island* island) {
/// the solution of the linear system /// the solution of the linear system
void ContactSolver::warmStart() { void ContactSolver::warmStart() {
PROFILE("ContactSolver::warmStart()", mProfiler); RP3D_PROFILE("ContactSolver::warmStart()", mProfiler);
uint contactPointIndex = 0; uint contactPointIndex = 0;
@ -479,7 +479,7 @@ void ContactSolver::warmStart() {
// Solve the contacts // Solve the contacts
void ContactSolver::solve() { void ContactSolver::solve() {
PROFILE("ContactSolver::solve()", mProfiler); RP3D_PROFILE("ContactSolver::solve()", mProfiler);
decimal deltaLambda; decimal deltaLambda;
decimal lambdaTemp; decimal lambdaTemp;
@ -758,7 +758,7 @@ void ContactSolver::solve() {
// warm start the solver at the next iteration // warm start the solver at the next iteration
void ContactSolver::storeImpulses() { void ContactSolver::storeImpulses() {
PROFILE("ContactSolver::storeImpulses()", mProfiler); RP3D_PROFILE("ContactSolver::storeImpulses()", mProfiler);
uint contactPointIndex = 0; uint contactPointIndex = 0;
@ -786,7 +786,7 @@ void ContactSolver::storeImpulses() {
void ContactSolver::computeFrictionVectors(const Vector3& deltaVelocity, void ContactSolver::computeFrictionVectors(const Vector3& deltaVelocity,
ContactManifoldSolver& contact) const { ContactManifoldSolver& contact) const {
PROFILE("ContactSolver::computeFrictionVectors()", mProfiler); RP3D_PROFILE("ContactSolver::computeFrictionVectors()", mProfiler);
assert(contact.normal.length() > decimal(0.0)); assert(contact.normal.length() > decimal(0.0));

View File

@ -39,8 +39,8 @@ using namespace std;
/** /**
* @param gravity Gravity vector in the world (in meters per second squared) * @param gravity Gravity vector in the world (in meters per second squared)
*/ */
DynamicsWorld::DynamicsWorld(const Vector3 &gravity, const WorldSettings& worldSettings) DynamicsWorld::DynamicsWorld(const Vector3& gravity, const string& name, const WorldSettings& worldSettings)
: CollisionWorld(worldSettings), : CollisionWorld(name, worldSettings),
mContactSolver(mMemoryManager, mConfig), mContactSolver(mMemoryManager, mConfig),
mNbVelocitySolverIterations(mConfig.defaultVelocitySolverNbIterations), mNbVelocitySolverIterations(mConfig.defaultVelocitySolverNbIterations),
mNbPositionSolverIterations(mConfig.defaultPositionSolverNbIterations), mNbPositionSolverIterations(mConfig.defaultPositionSolverNbIterations),
@ -52,7 +52,8 @@ DynamicsWorld::DynamicsWorld(const Vector3 &gravity, const WorldSettings& worldS
mConstrainedOrientations(nullptr), mNbIslands(0), mIslands(nullptr), mConstrainedOrientations(nullptr), mNbIslands(0), mIslands(nullptr),
mSleepLinearVelocity(mConfig.defaultSleepLinearVelocity), mSleepLinearVelocity(mConfig.defaultSleepLinearVelocity),
mSleepAngularVelocity(mConfig.defaultSleepAngularVelocity), mSleepAngularVelocity(mConfig.defaultSleepAngularVelocity),
mTimeBeforeSleep(mConfig.defaultTimeBeforeSleep) { mTimeBeforeSleep(mConfig.defaultTimeBeforeSleep),
mFreeJointsIDs(mMemoryManager.getPoolAllocator()), mCurrentJointId(0) {
#ifdef IS_PROFILING_ACTIVE #ifdef IS_PROFILING_ACTIVE
@ -62,6 +63,9 @@ DynamicsWorld::DynamicsWorld(const Vector3 &gravity, const WorldSettings& worldS
#endif #endif
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Dynamics world " + mName + " has been created");
} }
// Destructor // Destructor
@ -82,13 +86,12 @@ DynamicsWorld::~DynamicsWorld() {
#ifdef IS_PROFILING_ACTIVE #ifdef IS_PROFILING_ACTIVE
// Print the profiling report // Print the profiling report into the destinations
ofstream myfile; mProfiler.printReport();
myfile.open(mProfiler.getName() + ".txt");
mProfiler.printReport(myfile);
myfile.close();
#endif #endif
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Dynamics world " + mName + " has been destroyed");
} }
// Update the physics simulation // Update the physics simulation
@ -102,7 +105,7 @@ void DynamicsWorld::update(decimal timeStep) {
mProfiler.incrementFrameCounter(); mProfiler.incrementFrameCounter();
#endif #endif
PROFILE("DynamicsWorld::update()", &mProfiler); RP3D_PROFILE("DynamicsWorld::update()", &mProfiler);
mTimeStep = timeStep; mTimeStep = timeStep;
@ -150,7 +153,7 @@ void DynamicsWorld::update(decimal timeStep) {
/// the sympletic Euler time stepping scheme. /// the sympletic Euler time stepping scheme.
void DynamicsWorld::integrateRigidBodiesPositions() { void DynamicsWorld::integrateRigidBodiesPositions() {
PROFILE("DynamicsWorld::integrateRigidBodiesPositions()", &mProfiler); RP3D_PROFILE("DynamicsWorld::integrateRigidBodiesPositions()", &mProfiler);
// For each island of the world // For each island of the world
for (uint i=0; i < mNbIslands; i++) { for (uint i=0; i < mNbIslands; i++) {
@ -189,7 +192,7 @@ void DynamicsWorld::integrateRigidBodiesPositions() {
// Update the postion/orientation of the bodies // Update the postion/orientation of the bodies
void DynamicsWorld::updateBodiesState() { void DynamicsWorld::updateBodiesState() {
PROFILE("DynamicsWorld::updateBodiesState()", &mProfiler); RP3D_PROFILE("DynamicsWorld::updateBodiesState()", &mProfiler);
// For each island of the world // For each island of the world
for (uint islandIndex = 0; islandIndex < mNbIslands; islandIndex++) { for (uint islandIndex = 0; islandIndex < mNbIslands; islandIndex++) {
@ -226,7 +229,7 @@ void DynamicsWorld::updateBodiesState() {
// Initialize the bodies velocities arrays for the next simulation step. // Initialize the bodies velocities arrays for the next simulation step.
void DynamicsWorld::initVelocityArrays() { void DynamicsWorld::initVelocityArrays() {
PROFILE("DynamicsWorld::initVelocityArrays()", &mProfiler); RP3D_PROFILE("DynamicsWorld::initVelocityArrays()", &mProfiler);
// Allocate memory for the bodies velocity arrays // Allocate memory for the bodies velocity arrays
uint nbBodies = mRigidBodies.size(); uint nbBodies = mRigidBodies.size();
@ -268,7 +271,7 @@ void DynamicsWorld::initVelocityArrays() {
/// contact solver. /// contact solver.
void DynamicsWorld::integrateRigidBodiesVelocities() { void DynamicsWorld::integrateRigidBodiesVelocities() {
PROFILE("DynamicsWorld::integrateRigidBodiesVelocities()", &mProfiler); RP3D_PROFILE("DynamicsWorld::integrateRigidBodiesVelocities()", &mProfiler);
// Initialize the bodies velocity arrays // Initialize the bodies velocity arrays
initVelocityArrays(); initVelocityArrays();
@ -330,7 +333,7 @@ void DynamicsWorld::integrateRigidBodiesVelocities() {
// Solve the contacts and constraints // Solve the contacts and constraints
void DynamicsWorld::solveContactsAndConstraints() { void DynamicsWorld::solveContactsAndConstraints() {
PROFILE("DynamicsWorld::solveContactsAndConstraints()", &mProfiler); RP3D_PROFILE("DynamicsWorld::solveContactsAndConstraints()", &mProfiler);
// Set the velocities arrays // Set the velocities arrays
mContactSolver.setSplitVelocitiesArrays(mSplitLinearVelocities, mSplitAngularVelocities); mContactSolver.setSplitVelocitiesArrays(mSplitLinearVelocities, mSplitAngularVelocities);
@ -380,7 +383,7 @@ void DynamicsWorld::solveContactsAndConstraints() {
// Solve the position error correction of the constraints // Solve the position error correction of the constraints
void DynamicsWorld::solvePositionCorrection() { void DynamicsWorld::solvePositionCorrection() {
PROFILE("DynamicsWorld::solvePositionCorrection()", &mProfiler); RP3D_PROFILE("DynamicsWorld::solvePositionCorrection()", &mProfiler);
// Do not continue if there is no constraints // Do not continue if there is no constraints
if (mJoints.size() == 0) return; if (mJoints.size() == 0) return;
@ -407,7 +410,7 @@ void DynamicsWorld::solvePositionCorrection() {
RigidBody* DynamicsWorld::createRigidBody(const Transform& transform) { RigidBody* DynamicsWorld::createRigidBody(const Transform& transform) {
// Compute the body ID // Compute the body ID
bodyindex bodyID = computeNextAvailableBodyID(); bodyindex bodyID = computeNextAvailableBodyId();
// Largest index cannot be used (it is used for invalid index) // Largest index cannot be used (it is used for invalid index)
assert(bodyID < std::numeric_limits<reactphysics3d::bodyindex>::max()); assert(bodyID < std::numeric_limits<reactphysics3d::bodyindex>::max());
@ -427,6 +430,9 @@ RigidBody* DynamicsWorld::createRigidBody(const Transform& transform) {
#endif #endif
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::Body,
"Rigid Body " + std::to_string(bodyID) + ": New collision body created");
// Return the pointer to the rigid body // Return the pointer to the rigid body
return rigidBody; return rigidBody;
} }
@ -437,11 +443,14 @@ RigidBody* DynamicsWorld::createRigidBody(const Transform& transform) {
*/ */
void DynamicsWorld::destroyRigidBody(RigidBody* rigidBody) { void DynamicsWorld::destroyRigidBody(RigidBody* rigidBody) {
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::Body,
"Rigid Body " + std::to_string(rigidBody->getId()) + ": rigid body destroyed");
// Remove all the collision shapes of the body // Remove all the collision shapes of the body
rigidBody->removeAllCollisionShapes(); rigidBody->removeAllCollisionShapes();
// Add the body ID to the list of free IDs // Add the body ID to the list of free IDs
mFreeBodiesIDs.add(rigidBody->getID()); mFreeBodiesIds.add(rigidBody->getId());
// Destroy all the joints in which the rigid body to be destroyed is involved // Destroy all the joints in which the rigid body to be destroyed is involved
JointListElement* element; JointListElement* element;
@ -472,6 +481,9 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
Joint* newJoint = nullptr; Joint* newJoint = nullptr;
// Get the next available joint ID
uint jointId = computeNextAvailableJointId();
// Allocate memory to create the new joint // Allocate memory to create the new joint
switch(jointInfo.type) { switch(jointInfo.type) {
@ -482,7 +494,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
sizeof(BallAndSocketJoint)); sizeof(BallAndSocketJoint));
const BallAndSocketJointInfo& info = static_cast<const BallAndSocketJointInfo&>( const BallAndSocketJointInfo& info = static_cast<const BallAndSocketJointInfo&>(
jointInfo); jointInfo);
newJoint = new (allocatedMemory) BallAndSocketJoint(info); newJoint = new (allocatedMemory) BallAndSocketJoint(jointId, info);
break; break;
} }
@ -492,7 +504,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
void* allocatedMemory = mMemoryManager.allocate(MemoryManager::AllocationType::Pool, void* allocatedMemory = mMemoryManager.allocate(MemoryManager::AllocationType::Pool,
sizeof(SliderJoint)); sizeof(SliderJoint));
const SliderJointInfo& info = static_cast<const SliderJointInfo&>(jointInfo); const SliderJointInfo& info = static_cast<const SliderJointInfo&>(jointInfo);
newJoint = new (allocatedMemory) SliderJoint(info); newJoint = new (allocatedMemory) SliderJoint(jointId, info);
break; break;
} }
@ -502,7 +514,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
void* allocatedMemory = mMemoryManager.allocate(MemoryManager::AllocationType::Pool, void* allocatedMemory = mMemoryManager.allocate(MemoryManager::AllocationType::Pool,
sizeof(HingeJoint)); sizeof(HingeJoint));
const HingeJointInfo& info = static_cast<const HingeJointInfo&>(jointInfo); const HingeJointInfo& info = static_cast<const HingeJointInfo&>(jointInfo);
newJoint = new (allocatedMemory) HingeJoint(info); newJoint = new (allocatedMemory) HingeJoint(jointId, info);
break; break;
} }
@ -512,7 +524,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
void* allocatedMemory = mMemoryManager.allocate(MemoryManager::AllocationType::Pool, void* allocatedMemory = mMemoryManager.allocate(MemoryManager::AllocationType::Pool,
sizeof(FixedJoint)); sizeof(FixedJoint));
const FixedJointInfo& info = static_cast<const FixedJointInfo&>(jointInfo); const FixedJointInfo& info = static_cast<const FixedJointInfo&>(jointInfo);
newJoint = new (allocatedMemory) FixedJoint(info); newJoint = new (allocatedMemory) FixedJoint(jointId, info);
break; break;
} }
@ -536,6 +548,9 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
// Add the joint into the joint list of the bodies involved in the joint // Add the joint into the joint list of the bodies involved in the joint
addJointToBody(newJoint); addJointToBody(newJoint);
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::Joint,
"Joint " + std::to_string(newJoint->getId()) + ": New joint created");
// Return the pointer to the created joint // Return the pointer to the created joint
return newJoint; return newJoint;
} }
@ -548,6 +563,9 @@ void DynamicsWorld::destroyJoint(Joint* joint) {
assert(joint != nullptr); assert(joint != nullptr);
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::Joint,
"Joint " + std::to_string(joint->getId()) + ": joint destroyed");
// If the collision between the two bodies of the constraint was disabled // If the collision between the two bodies of the constraint was disabled
if (!joint->isCollisionEnabled()) { if (!joint->isCollisionEnabled()) {
@ -568,9 +586,15 @@ void DynamicsWorld::destroyJoint(Joint* joint) {
size_t nbBytes = joint->getSizeInBytes(); size_t nbBytes = joint->getSizeInBytes();
// Add the joint ID to the list of free IDs
mFreeJointsIDs.add(joint->getId());
// Call the destructor of the joint // Call the destructor of the joint
joint->~Joint(); joint->~Joint();
// Add the joint ID to the list of free IDs
mFreeJointsIDs.add(joint->getId());
// Release the allocated memory // Release the allocated memory
mMemoryManager.release(MemoryManager::AllocationType::Pool, joint, nbBytes); mMemoryManager.release(MemoryManager::AllocationType::Pool, joint, nbBytes);
} }
@ -595,6 +619,23 @@ void DynamicsWorld::addJointToBody(Joint* joint) {
joint->mBody2->mJointsList = jointListElement2; joint->mBody2->mJointsList = jointListElement2;
} }
// Return the next available joint Id
uint DynamicsWorld::computeNextAvailableJointId() {
// Compute the joint ID
uint jointId;
if (mFreeJointsIDs.size() != 0) {
jointId = mFreeJointsIDs[mFreeJointsIDs.size() - 1];
mFreeJointsIDs.removeAt(mFreeJointsIDs.size() - 1);
}
else {
jointId = mCurrentJointId;
mCurrentJointId++;
}
return jointId;
}
// Compute the islands of awake bodies. // Compute the islands of awake bodies.
/// An island is an isolated group of rigid bodies that have constraints (joints or contacts) /// An island is an isolated group of rigid bodies that have constraints (joints or contacts)
/// between each other. This method computes the islands at each time step as follows: For each /// between each other. This method computes the islands at each time step as follows: For each
@ -604,7 +645,7 @@ void DynamicsWorld::addJointToBody(Joint* joint) {
/// it). Then, we create an island with this group of connected bodies. /// it). Then, we create an island with this group of connected bodies.
void DynamicsWorld::computeIslands() { void DynamicsWorld::computeIslands() {
PROFILE("DynamicsWorld::computeIslands()", &mProfiler); RP3D_PROFILE("DynamicsWorld::computeIslands()", &mProfiler);
uint nbBodies = mRigidBodies.size(); uint nbBodies = mRigidBodies.size();
@ -693,7 +734,7 @@ void DynamicsWorld::computeIslands() {
// Get the other body of the contact manifold // Get the other body of the contact manifold
RigidBody* body1 = static_cast<RigidBody*>(contactManifold->getBody1()); RigidBody* body1 = static_cast<RigidBody*>(contactManifold->getBody1());
RigidBody* body2 = static_cast<RigidBody*>(contactManifold->getBody2()); RigidBody* body2 = static_cast<RigidBody*>(contactManifold->getBody2());
RigidBody* otherBody = (body1->getID() == bodyToVisit->getID()) ? body2 : body1; RigidBody* otherBody = (body1->getId() == bodyToVisit->getId()) ? body2 : body1;
// Check if the other body has already been added to the island // Check if the other body has already been added to the island
if (otherBody->mIsAlreadyInIsland) continue; if (otherBody->mIsAlreadyInIsland) continue;
@ -721,7 +762,7 @@ void DynamicsWorld::computeIslands() {
// Get the other body of the contact manifold // Get the other body of the contact manifold
RigidBody* body1 = static_cast<RigidBody*>(joint->getBody1()); RigidBody* body1 = static_cast<RigidBody*>(joint->getBody1());
RigidBody* body2 = static_cast<RigidBody*>(joint->getBody2()); RigidBody* body2 = static_cast<RigidBody*>(joint->getBody2());
RigidBody* otherBody = (body1->getID() == bodyToVisit->getID()) ? body2 : body1; RigidBody* otherBody = (body1->getId() == bodyToVisit->getId()) ? body2 : body1;
// Check if the other body has already been added to the island // Check if the other body has already been added to the island
if (otherBody->mIsAlreadyInIsland) continue; if (otherBody->mIsAlreadyInIsland) continue;
@ -751,7 +792,7 @@ void DynamicsWorld::computeIslands() {
/// time, we put all the bodies of the island to sleep. /// time, we put all the bodies of the island to sleep.
void DynamicsWorld::updateSleepingBodies() { void DynamicsWorld::updateSleepingBodies() {
PROFILE("DynamicsWorld::updateSleepingBodies()", &mProfiler); RP3D_PROFILE("DynamicsWorld::updateSleepingBodies()", &mProfiler);
const decimal sleepLinearVelocitySquare = mSleepLinearVelocity * mSleepLinearVelocity; const decimal sleepLinearVelocitySquare = mSleepLinearVelocity * mSleepLinearVelocity;
const decimal sleepAngularVelocitySquare = mSleepAngularVelocity * mSleepAngularVelocity; const decimal sleepAngularVelocitySquare = mSleepAngularVelocity * mSleepAngularVelocity;
@ -820,6 +861,9 @@ void DynamicsWorld::enableSleeping(bool isSleepingEnabled) {
(*it)->setIsSleeping(false); (*it)->setIsSleeping(false);
} }
} }
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Dynamics World: isSleepingEnabled=" + (isSleepingEnabled ? std::string("true") : std::string("false")) );
} }
/// Return the list of all contacts of the world /// Return the list of all contacts of the world

View File

@ -116,6 +116,12 @@ class DynamicsWorld : public CollisionWorld {
/// becomes smaller than the sleep velocity. /// becomes smaller than the sleep velocity.
decimal mTimeBeforeSleep; decimal mTimeBeforeSleep;
/// List of free ID for joints
List<luint> mFreeJointsIDs;
/// Current joint id
uint mCurrentJointId;
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Integrate the positions and orientations of rigid bodies. /// Integrate the positions and orientations of rigid bodies.
@ -148,12 +154,16 @@ class DynamicsWorld : public CollisionWorld {
/// Add the joint to the list of joints of the two bodies involved in the joint /// Add the joint to the list of joints of the two bodies involved in the joint
void addJointToBody(Joint* joint); void addJointToBody(Joint* joint);
/// Return the next available joint id
uint computeNextAvailableJointId();
public : public :
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Constructor /// Constructor
DynamicsWorld(const Vector3& mGravity, const WorldSettings& worldSettings = WorldSettings()); DynamicsWorld(const Vector3& mGravity, const std::string& name = "",
const WorldSettings& worldSettings = WorldSettings());
/// Destructor /// Destructor
virtual ~DynamicsWorld() override; virtual ~DynamicsWorld() override;
@ -272,6 +282,9 @@ inline uint DynamicsWorld::getNbIterationsVelocitySolver() const {
*/ */
inline void DynamicsWorld::setNbIterationsVelocitySolver(uint nbIterations) { inline void DynamicsWorld::setNbIterationsVelocitySolver(uint nbIterations) {
mNbVelocitySolverIterations = nbIterations; mNbVelocitySolverIterations = nbIterations;
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Dynamics World: Set nb iterations velocity solver to " + std::to_string(nbIterations));
} }
// Get the number of iterations for the position constraint solver // Get the number of iterations for the position constraint solver
@ -285,6 +298,9 @@ inline uint DynamicsWorld::getNbIterationsPositionSolver() const {
*/ */
inline void DynamicsWorld::setNbIterationsPositionSolver(uint nbIterations) { inline void DynamicsWorld::setNbIterationsPositionSolver(uint nbIterations) {
mNbPositionSolverIterations = nbIterations; mNbPositionSolverIterations = nbIterations;
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Dynamics World: Set nb iterations position solver to " + std::to_string(nbIterations));
} }
// Set the position correction technique used for contacts // Set the position correction technique used for contacts
@ -329,6 +345,9 @@ inline Vector3 DynamicsWorld::getGravity() const {
*/ */
inline void DynamicsWorld::setGravity(Vector3& gravity) { inline void DynamicsWorld::setGravity(Vector3& gravity) {
mGravity = gravity; mGravity = gravity;
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Dynamics World: Set gravity vector to " + gravity.to_string());
} }
// Return if the gravity is enaled // Return if the gravity is enaled
@ -346,6 +365,9 @@ inline bool DynamicsWorld::isGravityEnabled() const {
*/ */
inline void DynamicsWorld::setIsGratityEnabled(bool isGravityEnabled) { inline void DynamicsWorld::setIsGratityEnabled(bool isGravityEnabled) {
mIsGravityEnabled = isGravityEnabled; mIsGravityEnabled = isGravityEnabled;
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Dynamics World: isGravityEnabled= " + (isGravityEnabled ? std::string("true") : std::string("false")));
} }
// Return the number of rigid bodies in the world // Return the number of rigid bodies in the world
@ -390,6 +412,9 @@ inline decimal DynamicsWorld::getSleepLinearVelocity() const {
inline void DynamicsWorld::setSleepLinearVelocity(decimal sleepLinearVelocity) { inline void DynamicsWorld::setSleepLinearVelocity(decimal sleepLinearVelocity) {
assert(sleepLinearVelocity >= decimal(0.0)); assert(sleepLinearVelocity >= decimal(0.0));
mSleepLinearVelocity = sleepLinearVelocity; mSleepLinearVelocity = sleepLinearVelocity;
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Dynamics World: sleepLinearVelocity= " + std::to_string(sleepLinearVelocity));
} }
// Return the current sleep angular velocity // Return the current sleep angular velocity
@ -410,6 +435,9 @@ inline decimal DynamicsWorld::getSleepAngularVelocity() const {
inline void DynamicsWorld::setSleepAngularVelocity(decimal sleepAngularVelocity) { inline void DynamicsWorld::setSleepAngularVelocity(decimal sleepAngularVelocity) {
assert(sleepAngularVelocity >= decimal(0.0)); assert(sleepAngularVelocity >= decimal(0.0));
mSleepAngularVelocity = sleepAngularVelocity; mSleepAngularVelocity = sleepAngularVelocity;
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Dynamics World: sleepAngularVelocity= " + std::to_string(sleepAngularVelocity));
} }
// Return the time a body is required to stay still before sleeping // Return the time a body is required to stay still before sleeping
@ -428,6 +456,9 @@ inline decimal DynamicsWorld::getTimeBeforeSleep() const {
inline void DynamicsWorld::setTimeBeforeSleep(decimal timeBeforeSleep) { inline void DynamicsWorld::setTimeBeforeSleep(decimal timeBeforeSleep) {
assert(timeBeforeSleep >= decimal(0.0)); assert(timeBeforeSleep >= decimal(0.0));
mTimeBeforeSleep = timeBeforeSleep; mTimeBeforeSleep = timeBeforeSleep;
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
"Dynamics World: timeBeforeSleep= " + std::to_string(timeBeforeSleep));
} }
// Set an event listener object to receive events callbacks. // Set an event listener object to receive events callbacks.

View File

@ -263,9 +263,9 @@ inline bodyindexpair OverlappingPair::computeBodiesIndexPair(CollisionBody* body
CollisionBody* body2) { CollisionBody* body2) {
// Construct the pair of body index // Construct the pair of body index
bodyindexpair indexPair = body1->getID() < body2->getID() ? bodyindexpair indexPair = body1->getId() < body2->getId() ?
bodyindexpair(body1->getID(), body2->getID()) : bodyindexpair(body1->getId(), body2->getId()) :
bodyindexpair(body2->getID(), body1->getID()); bodyindexpair(body2->getId(), body1->getId());
assert(indexPair.first != indexPair.second); assert(indexPair.first != indexPair.second);
return indexPair; return indexPair;
} }

View File

@ -28,6 +28,7 @@
// Libraries // Libraries
#include <cassert> #include <cassert>
#include <string>
#include "Vector2.h" #include "Vector2.h"
/// ReactPhysics3D namespace /// ReactPhysics3D namespace
@ -145,6 +146,9 @@ class Matrix2x2 {
/// Overloaded operator to read/write element of the matrix. /// Overloaded operator to read/write element of the matrix.
Vector2& operator[](int row); Vector2& operator[](int row);
/// Return the string representation
std::string to_string() const;
}; };
// Constructor of the class Matrix2x2 // Constructor of the class Matrix2x2
@ -340,6 +344,12 @@ inline Vector2& Matrix2x2::operator[](int row) {
return mRows[row]; return mRows[row];
} }
// Get the string representation
inline std::string Matrix2x2::to_string() const {
return "Matrix2x2(" + std::to_string(mRows[0][0]) + "," + std::to_string(mRows[0][1]) + "," +
std::to_string(mRows[1][0]) + "," + std::to_string(mRows[1][1]) + ")";
}
} }
#endif #endif

View File

@ -29,6 +29,7 @@
// Libraries // Libraries
#include <cassert> #include <cassert>
#include <string>
#include "Vector3.h" #include "Vector3.h"
/// ReactPhysics3D namespace /// ReactPhysics3D namespace
@ -153,6 +154,9 @@ class Matrix3x3 {
/// Overloaded operator to read/write element of the matrix. /// Overloaded operator to read/write element of the matrix.
Vector3& operator[](int row); Vector3& operator[](int row);
/// Return the string representation
std::string to_string() const;
}; };
// Constructor of the class Matrix3x3 // Constructor of the class Matrix3x3
@ -392,6 +396,13 @@ inline Vector3& Matrix3x3::operator[](int row) {
return mRows[row]; return mRows[row];
} }
// Get the string representation
inline std::string Matrix3x3::to_string() const {
return "Matrix3x3(" + std::to_string(mRows[0][0]) + "," + std::to_string(mRows[0][1]) + "," + std::to_string(mRows[0][2]) + "," +
std::to_string(mRows[1][0]) + "," + std::to_string(mRows[1][1]) + "," + std::to_string(mRows[1][2]) + "," +
std::to_string(mRows[2][0]) + "," + std::to_string(mRows[2][1]) + "," + std::to_string(mRows[2][2]) + ")";
}
} }
#endif #endif

View File

@ -163,6 +163,9 @@ struct Quaternion {
/// Overloaded operator for equality condition /// Overloaded operator for equality condition
bool operator==(const Quaternion& quaternion) const; bool operator==(const Quaternion& quaternion) const;
/// Return the string representation
std::string to_string() const;
private: private:
/// Initialize the quaternion using Euler angles /// Initialize the quaternion using Euler angles
@ -379,6 +382,12 @@ inline bool Quaternion::operator==(const Quaternion& quaternion) const {
z == quaternion.z && w == quaternion.w); z == quaternion.z && w == quaternion.w);
} }
// Get the string representation
inline std::string Quaternion::to_string() const {
return "Quaternion(" + std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z) + "," +
std::to_string(w) + ")";
}
} }
#endif #endif

View File

@ -116,6 +116,9 @@ class Transform {
/// Assignment operator /// Assignment operator
Transform& operator=(const Transform& transform); Transform& operator=(const Transform& transform);
/// Return the string representation
std::string to_string() const;
}; };
// Constructor // Constructor
@ -268,6 +271,11 @@ inline Transform& Transform::operator=(const Transform& transform) {
return *this; return *this;
} }
// Get the string representation
inline std::string Transform::to_string() const {
return "Transform(" + mPosition.to_string() + "," + mOrientation.to_string() + ")";
}
} }
#endif #endif

View File

@ -29,6 +29,7 @@
// Libraries // Libraries
#include <cmath> #include <cmath>
#include <cassert> #include <cassert>
#include <string>
#include "mathematics_functions.h" #include "mathematics_functions.h"
#include "decimal.h" #include "decimal.h"
@ -135,6 +136,9 @@ struct Vector2 {
/// Overloaded less than operator for ordering to be used inside std::set for instance /// Overloaded less than operator for ordering to be used inside std::set for instance
bool operator<(const Vector2& vector) const; bool operator<(const Vector2& vector) const;
/// Return the string representation
std::string to_string() const;
/// Return a vector taking the minimum components of two vectors /// Return a vector taking the minimum components of two vectors
static Vector2 min(const Vector2& vector1, const Vector2& vector2); static Vector2 min(const Vector2& vector1, const Vector2& vector2);
@ -352,6 +356,11 @@ inline Vector2 Vector2::max(const Vector2& vector1, const Vector2& vector2) {
std::max(vector1.y, vector2.y)); std::max(vector1.y, vector2.y));
} }
// Get the string representation
inline std::string Vector2::to_string() const {
return "Vector2(" + std::to_string(x) + "," + std::to_string(y) + ")";
}
// Return the zero vector // Return the zero vector
inline Vector2 Vector2::zero() { inline Vector2 Vector2::zero() {
return Vector2(0, 0); return Vector2(0, 0);

View File

@ -29,6 +29,7 @@
// Libraries // Libraries
#include <cmath> #include <cmath>
#include <cassert> #include <cassert>
#include <string>
#include "mathematics_functions.h" #include "mathematics_functions.h"
#include "decimal.h" #include "decimal.h"
@ -147,6 +148,9 @@ struct Vector3 {
/// Overloaded less than operator for ordering to be used inside std::set for instance /// Overloaded less than operator for ordering to be used inside std::set for instance
bool operator<(const Vector3& vector) const; bool operator<(const Vector3& vector) const;
/// Get the string representation
std::string to_string() const;
/// Return a vector taking the minimum components of two vectors /// Return a vector taking the minimum components of two vectors
static Vector3 min(const Vector3& vector1, const Vector3& vector2); static Vector3 min(const Vector3& vector1, const Vector3& vector2);
@ -391,6 +395,11 @@ inline decimal Vector3::getMaxValue() const {
return std::max(std::max(x, y), z); return std::max(std::max(x, y), z);
} }
// Get the string representation
inline std::string Vector3::to_string() const {
return "Vector3(" + std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z) + ")";
}
// Return the zero vector // Return the zero vector
inline Vector3 Vector3::zero() { inline Vector3 Vector3::zero() {
return Vector3(0, 0, 0); return Vector3(0, 0, 0);

102
src/utils/Logger.cpp Normal file
View File

@ -0,0 +1,102 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
* In no event will the authors be held liable for any damages arising from the *
* use of this software. *
* *
* Permission is granted to anyone to use this software for any purpose, *
* including commercial applications, and to alter it and redistribute it *
* freely, subject to the following restrictions: *
* *
* 1. The origin of this software must not be misrepresented; you must not claim *
* that you wrote the original software. If you use this software in a *
* product, an acknowledgment in the product documentation would be *
* appreciated but is not required. *
* *
* 2. Altered source versions must be plainly marked as such, and must not be *
* misrepresented as being the original software. *
* *
* 3. This notice may not be removed or altered from any source distribution. *
* *
********************************************************************************/
#ifdef IS_LOGGING_ACTIVE
// Libraries
#include "Logger.h"
#include "memory/MemoryManager.h"
using namespace reactphysics3d;
// Constructor
Logger::Logger()
: mDestinations(MemoryManager::getBaseAllocator()), mFormatters(MemoryManager::getBaseAllocator())
{
// Create the log formatters
mFormatters.add(Pair<Format, Formatter*>(Format::Text, new TextFormatter()));
mFormatters.add(Pair<Format, Formatter*>(Format::HTML, new HtmlFormatter()));
}
// Destructor
Logger::~Logger() {
removeAllDestinations();
// Remove all the loggers
for (auto it = mFormatters.begin(); it != mFormatters.end(); ++it) {
delete it->second;
}
}
// Return the corresponding formatter
Logger::Formatter* Logger::getFormatter(Format format) const {
auto it = mFormatters.find(format);
if (it != mFormatters.end()) {
return it->second;
}
return nullptr;
}
// Add a log file destination to the logger
void Logger::addFileDestination(const std::string& filePath, uint logLevelFlag, Format format) {
FileDestination* destination = new FileDestination(filePath, logLevelFlag, getFormatter(format));
mDestinations.add(destination);
}
/// Add a stream destination to the logger
void Logger::addStreamDestination(std::ostream& outputStream, uint logLevelFlag, Format format) {
StreamDestination* destination = new StreamDestination(outputStream, logLevelFlag, getFormatter(format));
mDestinations.add(destination);
}
// Remove all logs destination previously set
void Logger::removeAllDestinations() {
// Delete all the destinations
for (uint i=0; i<mDestinations.size(); i++) {
delete mDestinations[i];
}
mDestinations.clear();
}
// Log something
void Logger::log(Level level, Category category, const std::string& message) {
// For each destination
for (auto it = mDestinations.begin(); it != mDestinations.end(); ++it) {
(*it)->write(message, level, category);
}
}
#endif

332
src/utils/Logger.h Normal file
View File

@ -0,0 +1,332 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
* In no event will the authors be held liable for any damages arising from the *
* use of this software. *
* *
* Permission is granted to anyone to use this software for any purpose, *
* including commercial applications, and to alter it and redistribute it *
* freely, subject to the following restrictions: *
* *
* 1. The origin of this software must not be misrepresented; you must not claim *
* that you wrote the original software. If you use this software in a *
* product, an acknowledgment in the product documentation would be *
* appreciated but is not required. *
* *
* 2. Altered source versions must be plainly marked as such, and must not be *
* misrepresented as being the original software. *
* *
* 3. This notice may not be removed or altered from any source distribution. *
* *
********************************************************************************/
#ifndef REACTPHYSICS3D_LOGGER_H
#define REACTPHYSICS3D_LOGGER_H
#ifdef IS_LOGGING_ACTIVE
// Libraries
#include "containers/List.h"
#include "containers/Map.h"
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
/// ReactPhysics3D namespace
namespace reactphysics3d {
// Class Logger
/**
* This class is used to log information, warnings or errors during the execution of the
* library code for easier debugging.
*/
class Logger {
public:
/// Log verbosity levels
enum class Level {Error = 1, Warning = 2, Info = 4};
/// Log categories
enum class Category {World, Body, Joint};
/// Log verbosity level
enum class Format {Text, HTML};
/// Log formatter
class Formatter {
public:
/// Constructor
Formatter() {
}
/// Destructor
virtual ~Formatter() {
}
/// Return the header to write at the beginning of the stream
virtual std::string getHeader() const {
return "";
}
/// Return the tail to write at the end of the stream
virtual std::string getTail() const {
return "";
}
/// Format a log message
virtual std::string format(const std::string& message, Level level, Category category) = 0;
};
class TextFormatter : public Formatter {
public:
/// Constructor
TextFormatter() {
}
/// Destructor
virtual ~TextFormatter() {
}
/// Format a log message
virtual std::string format(const std::string& message, Level level,
Category category) override {
return message;
}
};
class HtmlFormatter : public Formatter {
private:
/// Return the header to write at the beginning of the stream
virtual std::string getHeader() const override {
std::stringstream ss;
ss << "<!DOCTYPE HTML>" << std::endl;
ss << "<html>" << std::endl;
ss << "<head>" << std::endl;
ss << "<title>ReactPhysics3D Logs</title>" << std::endl;
ss << "</head>" << std::endl;
ss << "<body>" << std::endl;
return ss.str();
}
/// Return the tail to write at the end of the stream
virtual std::string getTail() const override {
std::stringstream ss;
ss << "</body>" << std::endl;
ss << "</html>" << std::endl;
return ss.str();
}
public:
/// Constructor
HtmlFormatter() {
}
/// Destructor
virtual ~HtmlFormatter() {
}
/// Format a log message
virtual std::string format(const std::string& message, Level level,
Category category) override {
std::stringstream ss;
ss << "<p>";
ss << message;
ss << "</p>";
return ss.str();
}
};
/// Log destination
class Destination {
public:
/// Log level flag for this destination
uint levelFlag;
/// Pointer to the formatter
Formatter* formatter;
/// Constructor
Destination(uint levelFlag, Formatter* logFormatter)
: levelFlag(levelFlag), formatter(logFormatter) {
}
/// Destructor
virtual ~Destination() {
}
/// Write a message into the output stream
virtual void write(const std::string& message, Level level, Category category) = 0;
};
class FileDestination : public Destination {
private:
std::string mFilePath;
/// Output file stream
std::ofstream mFileStream;
public:
/// Constructor
FileDestination(const std::string& filePath, uint levelFlag, Formatter* formatter)
:Destination(levelFlag, 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));
}
// Writer the head
mFileStream << formatter->getHeader() << std::endl;
}
/// Destructor
virtual ~FileDestination() override {
// Writer the tail
mFileStream << formatter->getTail() << std::endl;
if (mFileStream.is_open()) {
// Close the stream
mFileStream.close();
}
}
/// Write a message into the output stream
virtual void write(const std::string& message, Level level, Category category) override {
mFileStream << formatter->format(message, level, category) << std::endl;
}
};
/// Stream destination to output the logs into a stream
class StreamDestination : public Destination {
private:
/// Output stream
std::ostream& mOutputStream;
public:
/// Constructor
StreamDestination(std::ostream& outputStream, uint levelFlag, Formatter* formatter)
:Destination(levelFlag, formatter), mOutputStream(outputStream) {
// Writer the head
mOutputStream << formatter->getHeader() << std::endl;
}
/// Destructor
virtual ~StreamDestination() override {
// Writer the tail
mOutputStream << formatter->getTail() << std::endl;
}
/// Write a message into the output stream
virtual void write(const std::string& message, Level level, Category category) override {
mOutputStream << message << std::endl;
}
};
private:
// -------------------- Attributes -------------------- //
/// All the log destinations
List<Destination*> mDestinations;
/// Map a log format to the given formatter object
Map<Format, Formatter*> mFormatters;
// -------------------- Methods -------------------- //
/// Return the corresponding formatter
Formatter* getFormatter(Format format) const;
public :
// -------------------- Methods -------------------- //
/// Constructor
Logger();
/// Destructor
~Logger();
/// Add a file destination to the logger
void addFileDestination(const std::string& filePath, uint logLevelFlag, Format format);
/// Add a stream destination to the logger
void addStreamDestination(std::ostream& outputStream, uint logLevelFlag, Format format);
/// Remove all logs destination previously set
void removeAllDestinations();
/// Log something
void log(Level level, Category category, const std::string& message);
};
// Use this macro to log something
#define RP3D_LOG(logger, level, category, message) logger.log(level, category, message)
}
#else // If logger is not active
// Empty macro in case logs are not enabled
#define RP3D_LOG(logger, level, message)
#endif
// Hash function for struct VerticesPair
namespace std {
template<> struct hash<reactphysics3d::Logger::Format> {
size_t operator()(const reactphysics3d::Logger::Format format) const {
return static_cast<size_t>(format);
}
};
}
#endif

View File

@ -28,12 +28,10 @@
// Libraries // Libraries
#include "Profiler.h" #include "Profiler.h"
#include <string> #include <string>
#include "memory/MemoryManager.h"
using namespace reactphysics3d; using namespace reactphysics3d;
// Initialization of static variables
int Profiler::mNbProfilers = 0;
// Constructor // Constructor
ProfileNode::ProfileNode(const char* name, ProfileNode* parentNode) ProfileNode::ProfileNode(const char* name, ProfileNode* parentNode)
:mName(name), mNbTotalCalls(0), mStartingTime(0), mTotalTime(0), :mName(name), mNbTotalCalls(0), mStartingTime(0), mTotalTime(0),
@ -79,7 +77,7 @@ void ProfileNode::enterBlockOfCode() {
// Get the current system time to initialize the starting time of // Get the current system time to initialize the starting time of
// the profiling of the current block of code // the profiling of the current block of code
mStartingTime = Timer::getCurrentSystemTime() * 1000.0; mStartingTime = Timer::getCurrentSystemTime() * 1000.0L;
} }
mRecursionCounter++; mRecursionCounter++;
@ -92,7 +90,7 @@ bool ProfileNode::exitBlockOfCode() {
if (mRecursionCounter == 0 && mNbTotalCalls != 0) { if (mRecursionCounter == 0 && mNbTotalCalls != 0) {
// Get the current system time // Get the current system time
long double currentTime = Timer::getCurrentSystemTime() * 1000.0; long double currentTime = Timer::getCurrentSystemTime() * 1000.0L;
// Increase the total elasped time in the current block of code // Increase the total elasped time in the current block of code
mTotalTime += currentTime - mStartingTime; mTotalTime += currentTime - mStartingTime;
@ -105,7 +103,7 @@ bool ProfileNode::exitBlockOfCode() {
// Reset the profiling of the node // Reset the profiling of the node
void ProfileNode::reset() { void ProfileNode::reset() {
mNbTotalCalls = 0; mNbTotalCalls = 0;
mTotalTime = 0.0; mTotalTime = 0.0L;
// Reset the child node // Reset the child node
if (mChildNode != nullptr) { if (mChildNode != nullptr) {
@ -156,27 +154,11 @@ void ProfileNodeIterator::enterParent() {
} }
// Constructor // Constructor
Profiler::Profiler(std::string name) :mRootNode("Root", nullptr) { Profiler::Profiler() :mRootNode("Root", nullptr), mDestinations(MemoryManager::getBaseAllocator()) {
// Set the name of the profiler
if (name == "") {
if (mNbProfilers == 0) {
mName = "profiler";
}
else {
mName = std::string("profiler") + std::to_string(mNbProfilers);
}
}
else {
mName = name;
}
mCurrentNode = &mRootNode; mCurrentNode = &mRootNode;
mProfilingStartTime = Timer::getCurrentSystemTime() * 1000.0; mProfilingStartTime = Timer::getCurrentSystemTime() * 1000.0L;
mFrameCounter = 0; mFrameCounter = 0;
mNbProfilers++;
} }
// Destructor // Destructor
@ -213,18 +195,48 @@ void Profiler::reset() {
mRootNode.reset(); mRootNode.reset();
mRootNode.enterBlockOfCode(); mRootNode.enterBlockOfCode();
mFrameCounter = 0; mFrameCounter = 0;
mProfilingStartTime = Timer::getCurrentSystemTime() * 1000.0; mProfilingStartTime = Timer::getCurrentSystemTime() * 1000.0L;
} }
// Print the report of the profiler in a given output stream // Print the report of the profiler in a given output stream
void Profiler::printReport(std::ostream& outputStream) { void Profiler::printReport() {
ProfileNodeIterator* iterator = Profiler::getIterator();
// Recursively print the report of each node of the profiler tree // For each destination
printRecursiveNodeReport(iterator, 0, outputStream); for (auto it = mDestinations.begin(); it != mDestinations.end(); ++it) {
// Destroy the iterator ProfileNodeIterator* iterator = Profiler::getIterator();
destroyIterator(iterator);
// Recursively print the report of each node of the profiler tree
printRecursiveNodeReport(iterator, 0, (*it)->getOutputStream());
// Destroy the iterator
destroyIterator(iterator);
}
}
// Remove all output profiling destinations previously set
void Profiler::removeAllDestinations() {
// Delete all the destinations
for (size_t i=0; i<mDestinations.size(); i++) {
delete mDestinations[i];
}
mDestinations.clear();
}
// Add a file destination to the profiler
void Profiler::addFileDestination(const std::string& filePath, Format format) {
FileDestination* destination = new FileDestination(filePath, format);
mDestinations.add(destination);
}
// Add a stream destination to the profiler
void Profiler::addStreamDestination(std::ostream& outputStream, Format format) {
StreamDestination* destination = new StreamDestination(outputStream, format);
mDestinations.add(destination);
} }
// Recursively print the report of a given node of the profiler tree // Recursively print the report of a given node of the profiler tree
@ -240,14 +252,14 @@ void Profiler::printRecursiveNodeReport(ProfileNodeIterator* iterator,
long double parentTime = iterator->isRoot() ? getElapsedTimeSinceStart() : long double parentTime = iterator->isRoot() ? getElapsedTimeSinceStart() :
iterator->getCurrentParentTotalTime(); iterator->getCurrentParentTotalTime();
long double accumulatedTime = 0.0; long double accumulatedTime = 0.0L;
uint nbFrames = Profiler::getNbFrames(); uint nbFrames = Profiler::getNbFrames();
for (int i=0; i<spacing; i++) outputStream << " "; for (int i=0; i<spacing; i++) outputStream << " ";
outputStream << "---------------" << std::endl; outputStream << "---------------" << std::endl;
for (int i=0; i<spacing; i++) outputStream << " "; for (int i=0; i<spacing; i++) outputStream << " ";
outputStream << "| Profiling : " << iterator->getCurrentParentName() << outputStream << "| Profiling : " << iterator->getCurrentParentName() <<
" (total running time : " << parentTime << " ms) ---" << std::endl; " (total running time : " << parentTime << " ms) ---" << std::endl;
long double totalTime = 0.0; long double totalTime = 0.0L;
// Recurse over the children of the current node // Recurse over the children of the current node
int nbChildren = 0; int nbChildren = 0;
@ -256,7 +268,7 @@ void Profiler::printRecursiveNodeReport(ProfileNodeIterator* iterator,
long double currentTotalTime = iterator->getCurrentTotalTime(); long double currentTotalTime = iterator->getCurrentTotalTime();
accumulatedTime += currentTotalTime; accumulatedTime += currentTotalTime;
long double fraction = parentTime > std::numeric_limits<long double>::epsilon() ? long double fraction = parentTime > std::numeric_limits<long double>::epsilon() ?
(currentTotalTime / parentTime) * 100.0 : 0.0; (currentTotalTime / parentTime) * 100.0L : 0.0L;
for (int j=0; j<spacing; j++) outputStream << " "; for (int j=0; j<spacing; j++) outputStream << " ";
outputStream << "| " << i << " -- " << iterator->getCurrentName() << " : " << outputStream << "| " << i << " -- " << iterator->getCurrentName() << " : " <<
fraction << " % | " << (currentTotalTime / (long double) (nbFrames)) << fraction << " % | " << (currentTotalTime / (long double) (nbFrames)) <<
@ -270,7 +282,7 @@ void Profiler::printRecursiveNodeReport(ProfileNodeIterator* iterator,
} }
for (int i=0; i<spacing; i++) outputStream << " "; for (int i=0; i<spacing; i++) outputStream << " ";
long double percentage = parentTime > std::numeric_limits<long double>::epsilon() ? long double percentage = parentTime > std::numeric_limits<long double>::epsilon() ?
((parentTime - accumulatedTime) / parentTime) * 100.0 : 0.0; ((parentTime - accumulatedTime) / parentTime) * 100.0L : 0.0L;
long double difference = parentTime - accumulatedTime; long double difference = parentTime - accumulatedTime;
outputStream << "| Unaccounted : " << difference << " ms (" << percentage << " %)" << std::endl; outputStream << "| Unaccounted : " << difference << " ms (" << percentage << " %)" << std::endl;

View File

@ -30,7 +30,9 @@
// Libraries // Libraries
#include "configuration.h" #include "configuration.h"
#include "Timer.h" #include "engine/Timer.h"
#include <fstream>
#include "containers/List.h"
/// ReactPhysics3D namespace /// ReactPhysics3D namespace
namespace reactphysics3d { namespace reactphysics3d {
@ -180,16 +182,102 @@ class ProfileNodeIterator {
*/ */
class Profiler { class Profiler {
public:
/// Format of the profiling data (text, ...)
enum class Format {Text};
/// Profile destination
class Destination {
public:
/// Log format (text, ...)
Format format;
/// Constructor
Destination(Format logFormat) : format(logFormat) {
}
/// Destructor
virtual ~Destination() {
}
/// Return the current output stream
virtual std::ostream& getOutputStream() = 0;
};
/// File destination to output profiling data into a file
class FileDestination : public Destination {
private:
std::string mFilePath;
/// Output file stream
std::ofstream mFileStream;
public:
/// Constructor
FileDestination(const std::string& filePath, Format format)
: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));
}
}
/// Destructor
virtual ~FileDestination() override {
if (mFileStream.is_open()) {
// Close the stream
mFileStream.close();
}
}
/// Return the current output stream
virtual std::ostream& getOutputStream() override {
return mFileStream;
}
};
/// Stream destination to output profiling data into a stream
class StreamDestination : public Destination {
private:
/// Output stream
std::ostream& mOutputStream;
public:
/// Constructor
StreamDestination(std::ostream& outputStream, Format format)
:Destination(format), mOutputStream(outputStream) {
}
/// Destructor
virtual ~StreamDestination() override {
}
/// Return the current output stream
virtual std::ostream& getOutputStream() override {
return mOutputStream;
}
};
private : private :
// -------------------- Attributes -------------------- // // -------------------- Attributes -------------------- //
/// Profiler name
std::string mName;
/// Total number of profilers
static int mNbProfilers;
/// Root node of the profiler tree /// Root node of the profiler tree
ProfileNode mRootNode; ProfileNode mRootNode;
@ -202,8 +290,12 @@ class Profiler {
/// Starting profiling time /// Starting profiling time
long double mProfilingStartTime; long double mProfilingStartTime;
/// All the output destinations
List<Destination*> mDestinations;
/// Recursively print the report of a given node of the profiler tree /// Recursively print the report of a given node of the profiler tree
void printRecursiveNodeReport(ProfileNodeIterator* iterator, int spacing, std::ostream& outputStream); void printRecursiveNodeReport(ProfileNodeIterator* iterator, int spacing,
std::ostream &outputStream);
/// Destroy a previously allocated iterator /// Destroy a previously allocated iterator
void destroyIterator(ProfileNodeIterator* iterator); void destroyIterator(ProfileNodeIterator* iterator);
@ -216,7 +308,7 @@ class Profiler {
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Constructor /// Constructor
Profiler(std::string name = ""); Profiler();
/// Destructor /// Destructor
~Profiler(); ~Profiler();
@ -234,12 +326,6 @@ class Profiler {
/// Return the number of frames /// Return the number of frames
uint getNbFrames(); uint getNbFrames();
/// Get the name of the profiler
std::string getName() const;
/// Set the name of the profiler
void setName(std::string name);
/// Return the elasped time since the start/reset of the profiling /// Return the elasped time since the start/reset of the profiling
long double getElapsedTimeSinceStart(); long double getElapsedTimeSinceStart();
@ -249,8 +335,17 @@ class Profiler {
/// Return an iterator over the profiler tree starting at the root /// Return an iterator over the profiler tree starting at the root
ProfileNodeIterator* getIterator(); ProfileNodeIterator* getIterator();
/// Print the report of the profiler in a given output stream // Add a file destination to the profiler
void printReport(std::ostream& outputStream); void addFileDestination(const std::string& filePath, Format format);
// Add a stream destination to the profiler
void addStreamDestination(std::ostream& outputStream, Format format);
/// Remove all logs destination previously set
void removeAllDestinations();
/// Print the report of the profiler in every output destinations
void printReport();
}; };
// Class ProfileSample // Class ProfileSample
@ -287,7 +382,7 @@ class ProfileSample {
}; };
// Use this macro to start profile a block of code // Use this macro to start profile a block of code
#define PROFILE(name, profiler) ProfileSample profileSample(name, profiler) #define RP3D_PROFILE(name, profiler) ProfileSample profileSample(name, profiler)
// Return true if we are at the root of the profiler tree // Return true if we are at the root of the profiler tree
inline bool ProfileNodeIterator::isRoot() { inline bool ProfileNodeIterator::isRoot() {
@ -374,19 +469,9 @@ inline uint Profiler::getNbFrames() {
return mFrameCounter; return mFrameCounter;
} }
// Get the name of the profiler
inline std::string Profiler::getName() const {
return mName;
}
// Set the name of the profiler
inline void Profiler::setName(std::string name) {
mName = name;
}
// Return the elasped time since the start/reset of the profiling // Return the elasped time since the start/reset of the profiling
inline long double Profiler::getElapsedTimeSinceStart() { inline long double Profiler::getElapsedTimeSinceStart() {
long double currentTime = Timer::getCurrentSystemTime() * 1000.0; long double currentTime = Timer::getCurrentSystemTime() * 1000.0L;
return currentTime - mProfilingStartTime; return currentTime - mProfilingStartTime;
} }
@ -412,10 +497,10 @@ inline void Profiler::destroy() {
} }
#else // In profile is not active #else // If profile is not active
// Empty macro in case profiling is not active // Empty macro in case profiling is not active
#define PROFILE(name, profiler) #define RP3D_PROFILE(name, profiler)
#endif #endif

View File

@ -639,7 +639,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point(3, 0, 0); Vector3 localBody1Point(3, 0, 0);
@ -663,7 +663,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -684,7 +684,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -705,7 +705,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -759,7 +759,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point(3, 0, 0); Vector3 localBody1Point(3, 0, 0);
@ -783,7 +783,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -804,7 +804,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -825,7 +825,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -869,7 +869,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
localBody1Point = std::sqrt(4.5f) * Vector3(1, -1, 0); localBody1Point = std::sqrt(4.5f) * Vector3(1, -1, 0);
@ -893,7 +893,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -914,7 +914,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -935,7 +935,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -979,7 +979,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
localBody1Point = std::sqrt(9.0f / 3.0f) * Vector3(1, -1, -1); localBody1Point = std::sqrt(9.0f / 3.0f) * Vector3(1, -1, -1);
@ -1003,7 +1003,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1024,7 +1024,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1045,7 +1045,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1099,7 +1099,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point(0, -3, 0); Vector3 localBody1Point(0, -3, 0);
@ -1123,7 +1123,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1144,7 +1144,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1165,7 +1165,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1209,7 +1209,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
localBody1Point = Vector3(3, 0, 0); localBody1Point = Vector3(3, 0, 0);
@ -1233,7 +1233,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1254,7 +1254,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1275,7 +1275,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1329,7 +1329,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point(3, 0, 0); Vector3 localBody1Point(3, 0, 0);
@ -1353,7 +1353,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1374,7 +1374,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1395,7 +1395,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1439,7 +1439,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
localBody1Point = std::sqrt(4.5f) * Vector3(1, -1, 0); localBody1Point = std::sqrt(4.5f) * Vector3(1, -1, 0);
@ -1463,7 +1463,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1484,7 +1484,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1505,7 +1505,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1549,7 +1549,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
localBody1Point = std::sqrt(9.0f / 3.0f) * Vector3(1, -1, -1); localBody1Point = std::sqrt(9.0f / 3.0f) * Vector3(1, -1, -1);
@ -1573,7 +1573,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1594,7 +1594,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1615,7 +1615,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1669,7 +1669,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point(0, -3, 0); Vector3 localBody1Point(0, -3, 0);
@ -1693,7 +1693,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1714,7 +1714,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1735,7 +1735,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mSphereBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mSphereBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -1789,7 +1789,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point1(-3, -2, -2); Vector3 localBody1Point1(-3, -2, -2);
@ -1831,7 +1831,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -1860,7 +1860,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -1890,7 +1890,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -1953,7 +1953,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point1(-3, -2, -2); Vector3 localBody1Point1(-3, -2, -2);
@ -1995,7 +1995,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2024,7 +2024,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2054,7 +2054,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2117,7 +2117,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point1(-3, -2, -2); Vector3 localBody1Point1(-3, -2, -2);
@ -2159,7 +2159,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2188,7 +2188,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2218,7 +2218,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2281,7 +2281,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point1(3, 1, 0); Vector3 localBody1Point1(3, 1, 0);
@ -2304,7 +2304,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2325,7 +2325,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2346,7 +2346,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2400,7 +2400,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point1(3, 1, 0); Vector3 localBody1Point1(3, 1, 0);
@ -2423,7 +2423,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2444,7 +2444,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2465,7 +2465,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
@ -2519,7 +2519,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) { for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) {
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f)); test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
@ -2539,7 +2539,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) { for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) {
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f)); test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
@ -2559,7 +2559,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) { for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) {
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f)); test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
@ -2579,7 +2579,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mBoxBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mBoxBody1->getId();
// Test contact points // Test contact points
for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) { for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) {
@ -2633,7 +2633,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) { for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) {
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f)); test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
@ -2653,7 +2653,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) { for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) {
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f)); test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
@ -2673,7 +2673,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) { for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) {
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f)); test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
@ -2693,7 +2693,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 4); test(collisionData->getTotalNbContactPoints() == 4);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mConvexMeshBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mConvexMeshBody1->getId();
// Test contact points // Test contact points
for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) { for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) {
@ -2747,7 +2747,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point(2, 3, 0); Vector3 localBody1Point(2, 3, 0);
@ -2771,7 +2771,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -2792,7 +2792,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -2813,7 +2813,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -2857,7 +2857,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
localBody1Point = Vector3(0, 5, 0); localBody1Point = Vector3(0, 5, 0);
@ -2881,7 +2881,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -2902,7 +2902,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -2923,7 +2923,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -2977,7 +2977,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
bool swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); bool swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
Vector3 localBody1Point(0, -5, 0); Vector3 localBody1Point(0, -5, 0);
@ -3001,7 +3001,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -3022,7 +3022,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
@ -3043,7 +3043,7 @@ class TestCollisionWorld : public Test {
test(collisionData->getTotalNbContactPoints() == 1); test(collisionData->getTotalNbContactPoints() == 1);
// True if the bodies are swapped in the collision callback response // True if the bodies are swapped in the collision callback response
swappedBodiesCollisionData = collisionData->getBody1()->getID() != mCapsuleBody1->getID(); swappedBodiesCollisionData = collisionData->getBody1()->getId() != mCapsuleBody1->getId();
// Test contact points // Test contact points
test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point, test(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,

View File

@ -63,7 +63,7 @@ class WorldRaycastCallback : public RaycastCallback {
virtual decimal notifyRaycastHit(const RaycastInfo& info) override { virtual decimal notifyRaycastHit(const RaycastInfo& info) override {
if (shapeToTest->getBody()->getID() == info.body->getID()) { if (shapeToTest->getBody()->getId() == info.body->getId()) {
raycastInfo.body = info.body; raycastInfo.body = info.body;
raycastInfo.hitFraction = info.hitFraction; raycastInfo.hitFraction = info.hitFraction;
raycastInfo.proxyShape = info.proxyShape; raycastInfo.proxyShape = info.proxyShape;
@ -1310,7 +1310,6 @@ class TestRaycast : public Test {
// CollisionWorld::raycast() // CollisionWorld::raycast()
mCallback.reset(); mCallback.reset();
mWorld->raycast(ray, &mCallback); mWorld->raycast(ray, &mCallback);
Vector3 localTest = inverse * mCallback.raycastInfo.worldPoint;
test(mCallback.isHit); test(mCallback.isHit);
test(mCallback.raycastInfo.body == mConvexMeshBody); test(mCallback.raycastInfo.body == mConvexMeshBody);
test(mCallback.raycastInfo.proxyShape == mConvexMeshProxyShape); test(mCallback.raycastInfo.proxyShape == mConvexMeshProxyShape);

View File

@ -47,13 +47,7 @@ CollisionDetectionScene::CollisionDetectionScene(const std::string& name, Engine
setScenePosition(center, SCENE_RADIUS); setScenePosition(center, SCENE_RADIUS);
// Create the dynamics world for the physics simulation // Create the dynamics world for the physics simulation
mPhysicsWorld = new rp3d::CollisionWorld(); mPhysicsWorld = new rp3d::CollisionWorld(name);
#ifdef IS_PROFILING_ACTIVE
mPhysicsWorld->setProfilerName(name + "_profiler");
#endif
// ---------- Sphere 1 ---------- // // ---------- Sphere 1 ---------- //

View File

@ -46,14 +46,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name, EngineSettin
rp3d::Vector3 gravity(0, -9.81f, 0); rp3d::Vector3 gravity(0, -9.81f, 0);
// Create the dynamics world for the physics simulation // Create the dynamics world for the physics simulation
mPhysicsWorld = new rp3d::DynamicsWorld(gravity); mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
#ifdef IS_PROFILING_ACTIVE
mPhysicsWorld->setProfilerName(name + "_profiler");
#endif
for (int i=0; i<NB_COMPOUND_SHAPES; i++) { for (int i=0; i<NB_COMPOUND_SHAPES; i++) {

View File

@ -46,13 +46,7 @@ ConcaveMeshScene::ConcaveMeshScene(const std::string& name, EngineSettings& sett
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0); rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
// Create the dynamics world for the physics simulation // Create the dynamics world for the physics simulation
mPhysicsWorld = new rp3d::DynamicsWorld(gravity); mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
#ifdef IS_PROFILING_ACTIVE
mPhysicsWorld->setProfilerName(name + "_profiler");
#endif
// ---------- Create the boxes ----------- // // ---------- Create the boxes ----------- //
for (int i = 0; i<NB_COMPOUND_SHAPES; i++) { for (int i = 0; i<NB_COMPOUND_SHAPES; i++) {

View File

@ -44,13 +44,7 @@ CubesScene::CubesScene(const std::string& name, EngineSettings& settings)
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0); rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
// Create the dynamics world for the physics simulation // Create the dynamics world for the physics simulation
mPhysicsWorld = new rp3d::DynamicsWorld(gravity); mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
#ifdef IS_PROFILING_ACTIVE
mPhysicsWorld->setProfilerName(name + "_profiler");
#endif
// Create all the cubes of the scene // Create all the cubes of the scene
for (int i=0; i<NB_CUBES; i++) { for (int i=0; i<NB_CUBES; i++) {

View File

@ -44,13 +44,7 @@ CubeStackScene::CubeStackScene(const std::string& name, EngineSettings& settings
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0); rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
// Create the dynamics world for the physics simulation // Create the dynamics world for the physics simulation
mPhysicsWorld = new rp3d::DynamicsWorld(gravity); mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
#ifdef IS_PROFILING_ACTIVE
mPhysicsWorld->setProfilerName(name + "_profiler");
#endif
// Create all the cubes of the scene // Create all the cubes of the scene
for (int i=1; i<=NB_FLOORS; i++) { for (int i=1; i<=NB_FLOORS; i++) {

View File

@ -46,14 +46,7 @@ HeightFieldScene::HeightFieldScene(const std::string& name, EngineSettings& sett
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0); rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
// Create the dynamics world for the physics simulation // Create the dynamics world for the physics simulation
mPhysicsWorld = new rp3d::DynamicsWorld(gravity); mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
#ifdef IS_PROFILING_ACTIVE
mPhysicsWorld->setProfilerName(name + "_profiler");
#endif
for (int i = 0; i<NB_COMPOUND_SHAPES; i++) { for (int i = 0; i<NB_COMPOUND_SHAPES; i++) {

View File

@ -45,13 +45,7 @@ JointsScene::JointsScene(const std::string& name, EngineSettings& settings)
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0); rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
// Create the dynamics world for the physics simulation // Create the dynamics world for the physics simulation
mPhysicsWorld = new rp3d::DynamicsWorld(gravity); mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
#ifdef IS_PROFILING_ACTIVE
mPhysicsWorld->setProfilerName(name + "_profiler");
#endif
// Create the Ball-and-Socket joint // Create the Ball-and-Socket joint
createBallAndSocketJoints(); createBallAndSocketJoints();

View File

@ -45,13 +45,7 @@ RaycastScene::RaycastScene(const std::string& name, EngineSettings& settings)
setScenePosition(center, SCENE_RADIUS); setScenePosition(center, SCENE_RADIUS);
// Create the dynamics world for the physics simulation // Create the dynamics world for the physics simulation
mPhysicsWorld = new rp3d::CollisionWorld(); mPhysicsWorld = new rp3d::CollisionWorld(name);
#ifdef IS_PROFILING_ACTIVE
mPhysicsWorld->setProfilerName(name + "_profiler");
#endif
// ---------- Dumbbell ---------- // // ---------- Dumbbell ---------- //