Refactor profiler and start working on logger
This commit is contained in:
parent
62bd3bc115
commit
393bb0ed88
|
@ -21,6 +21,7 @@ ENABLE_TESTING()
|
|||
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(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
|
||||
values" OFF)
|
||||
|
||||
|
@ -45,6 +46,10 @@ IF(PROFILING_ENABLED)
|
|||
ADD_DEFINITIONS(-DIS_PROFILING_ACTIVE)
|
||||
ENDIF(PROFILING_ENABLED)
|
||||
|
||||
IF(LOGS_ENABLED)
|
||||
ADD_DEFINITIONS(-DIS_LOGGING_ACTIVE)
|
||||
ENDIF(LOGS_ENABLED)
|
||||
|
||||
IF(DOUBLE_PRECISION_ENABLED)
|
||||
ADD_DEFINITIONS(-DIS_DOUBLE_PRECISION_ENABLED)
|
||||
ENDIF(DOUBLE_PRECISION_ENABLED)
|
||||
|
@ -164,8 +169,6 @@ SET (REACTPHYSICS3D_SOURCES
|
|||
"src/engine/Material.cpp"
|
||||
"src/engine/OverlappingPair.h"
|
||||
"src/engine/OverlappingPair.cpp"
|
||||
"src/engine/Profiler.h"
|
||||
"src/engine/Profiler.cpp"
|
||||
"src/engine/Timer.h"
|
||||
"src/engine/Timer.cpp"
|
||||
"src/collision/CollisionCallback.h"
|
||||
|
@ -201,6 +204,10 @@ SET (REACTPHYSICS3D_SOURCES
|
|||
"src/containers/Map.h"
|
||||
"src/containers/Set.h"
|
||||
"src/containers/Pair.h"
|
||||
"src/utils/Profiler.h"
|
||||
"src/utils/Profiler.cpp"
|
||||
"src/utils/Logger.h"
|
||||
"src/utils/Logger.cpp"
|
||||
)
|
||||
|
||||
# Create the library
|
||||
|
|
|
@ -92,7 +92,7 @@ class Body {
|
|||
virtual ~Body() = default;
|
||||
|
||||
/// Return the ID of the body
|
||||
bodyindex getID() const;
|
||||
bodyindex getId() const;
|
||||
|
||||
/// Return whether or not the body is allowed to sleep
|
||||
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
|
||||
*/
|
||||
inline bodyindex Body::getID() const {
|
||||
inline bodyindex Body::getId() const {
|
||||
return mID;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "collision/RaycastInfo.h"
|
||||
#include "memory/PoolAllocator.h"
|
||||
#include "configuration.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
|
||||
/// Namespace reactphysics3d
|
||||
namespace reactphysics3d {
|
||||
|
|
|
@ -459,7 +459,7 @@ void RigidBody::recomputeMassInformation() {
|
|||
// Update the broad-phase state for this body (because it has moved for instance)
|
||||
void RigidBody::updateBroadPhaseState() const {
|
||||
|
||||
PROFILE("RigidBody::updateBroadPhaseState()", mProfiler);
|
||||
RP3D_PROFILE("RigidBody::updateBroadPhaseState()", mProfiler);
|
||||
|
||||
DynamicsWorld& world = static_cast<DynamicsWorld&>(mWorld);
|
||||
const Vector3 displacement = world.mTimeStep * mLinearVelocity;
|
||||
|
|
|
@ -68,7 +68,7 @@ CollisionDetection::CollisionDetection(CollisionWorld* world, MemoryManager& mem
|
|||
// Compute the collision detection
|
||||
void CollisionDetection::computeCollisionDetection() {
|
||||
|
||||
PROFILE("CollisionDetection::computeCollisionDetection()", mProfiler);
|
||||
RP3D_PROFILE("CollisionDetection::computeCollisionDetection()", mProfiler);
|
||||
|
||||
// Compute the broad-phase collision detection
|
||||
computeBroadPhase();
|
||||
|
@ -86,7 +86,7 @@ void CollisionDetection::computeCollisionDetection() {
|
|||
// Compute the broad-phase collision detection
|
||||
void CollisionDetection::computeBroadPhase() {
|
||||
|
||||
PROFILE("CollisionDetection::computeBroadPhase()", mProfiler);
|
||||
RP3D_PROFILE("CollisionDetection::computeBroadPhase()", mProfiler);
|
||||
|
||||
// If new collision shapes have been added to bodies
|
||||
if (mIsCollisionShapesAdded) {
|
||||
|
@ -101,7 +101,7 @@ void CollisionDetection::computeBroadPhase() {
|
|||
// Compute the middle-phase collision detection
|
||||
void CollisionDetection::computeMiddlePhase() {
|
||||
|
||||
PROFILE("CollisionDetection::computeMiddlePhase()", mProfiler);
|
||||
RP3D_PROFILE("CollisionDetection::computeMiddlePhase()", mProfiler);
|
||||
|
||||
// For each possible collision pair of bodies
|
||||
Map<Pair<uint, uint>, OverlappingPair*>::Iterator it;
|
||||
|
@ -251,7 +251,7 @@ void CollisionDetection::computeConvexVsConcaveMiddlePhase(OverlappingPair* pair
|
|||
// Compute the narrow-phase collision detection
|
||||
void CollisionDetection::computeNarrowPhase() {
|
||||
|
||||
PROFILE("CollisionDetection::computeNarrowPhase()", mProfiler);
|
||||
RP3D_PROFILE("CollisionDetection::computeNarrowPhase()", mProfiler);
|
||||
|
||||
NarrowPhaseInfo* currentNarrowPhaseInfo = mNarrowPhaseInfoList;
|
||||
while (currentNarrowPhaseInfo != nullptr) {
|
||||
|
@ -364,7 +364,7 @@ void CollisionDetection::removeProxyCollisionShape(ProxyShape* proxyShape) {
|
|||
|
||||
void CollisionDetection::addAllContactManifoldsToBodies() {
|
||||
|
||||
PROFILE("CollisionDetection::addAllContactManifoldsToBodies()", mProfiler);
|
||||
RP3D_PROFILE("CollisionDetection::addAllContactManifoldsToBodies()", mProfiler);
|
||||
|
||||
// For each overlapping pairs in contact during the narrow-phase
|
||||
Map<Pair<uint, uint>, OverlappingPair*>::Iterator it;
|
||||
|
@ -415,7 +415,7 @@ void CollisionDetection::addContactManifoldToBody(OverlappingPair* pair) {
|
|||
/// Convert the potential contact into actual contacts
|
||||
void CollisionDetection::processAllPotentialContacts() {
|
||||
|
||||
PROFILE("CollisionDetection::processAllPotentialContacts()", mProfiler);
|
||||
RP3D_PROFILE("CollisionDetection::processAllPotentialContacts()", mProfiler);
|
||||
|
||||
// For each overlapping pairs in contact during the narrow-phase
|
||||
Map<Pair<uint, uint>, OverlappingPair*>::Iterator it;
|
||||
|
@ -454,7 +454,7 @@ void CollisionDetection::processPotentialContacts(OverlappingPair* pair) {
|
|||
// Report contacts for all the colliding overlapping pairs
|
||||
void CollisionDetection::reportAllContacts() {
|
||||
|
||||
PROFILE("CollisionDetection::reportAllContacts()", mProfiler);
|
||||
RP3D_PROFILE("CollisionDetection::reportAllContacts()", mProfiler);
|
||||
|
||||
// For each overlapping pairs in contact during the narrow-phase
|
||||
Map<Pair<uint, uint>, OverlappingPair*>::Iterator it;
|
||||
|
@ -532,13 +532,13 @@ void CollisionDetection::testAABBOverlap(const AABB& aabb, OverlapCallback* over
|
|||
CollisionBody* overlapBody = proxyShape->getBody();
|
||||
|
||||
// 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
|
||||
if ((proxyShape->getCollisionCategoryBits() & categoryMaskBits) != 0) {
|
||||
|
||||
// Add the body into the set of reported bodies
|
||||
reportedBodies.add(overlapBody->getID());
|
||||
reportedBodies.add(overlapBody->getId());
|
||||
|
||||
// Notify the overlap to the user
|
||||
overlapCallback->notifyOverlap(overlapBody);
|
||||
|
@ -646,7 +646,7 @@ void CollisionDetection::testOverlap(CollisionBody* body, OverlapCallback* overl
|
|||
LinkedList<int> overlappingNodes(mMemoryManager.getPoolAllocator());
|
||||
mBroadPhaseAlgorithm.reportAllShapesOverlappingWithAABB(shapeAABB, overlappingNodes);
|
||||
|
||||
const bodyindex bodyId = body->getID();
|
||||
const bodyindex bodyId = body->getId();
|
||||
|
||||
// For each overlaping proxy shape
|
||||
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
|
||||
// two proxy collision shapes are not from the same body
|
||||
if (reportedBodies.find(proxyShape->getBody()->getID()) == reportedBodies.end() &&
|
||||
proxyShape->getBody()->getID() != bodyId) {
|
||||
if (reportedBodies.find(proxyShape->getBody()->getId()) == reportedBodies.end() &&
|
||||
proxyShape->getBody()->getId() != bodyId) {
|
||||
|
||||
// Check if the collision filtering allows collision between the two shapes
|
||||
if ((proxyShape->getCollisionCategoryBits() & categoryMaskBits) != 0) {
|
||||
|
@ -711,7 +711,7 @@ void CollisionDetection::testOverlap(CollisionBody* body, OverlapCallback* overl
|
|||
CollisionBody* overlapBody = proxyShape->getBody();
|
||||
|
||||
// Add the body into the set of reported bodies
|
||||
reportedBodies.add(overlapBody->getID());
|
||||
reportedBodies.add(overlapBody->getId());
|
||||
|
||||
// Notify the overlap to the user
|
||||
overlapCallback->notifyOverlap(overlapBody);
|
||||
|
@ -826,7 +826,7 @@ void CollisionDetection::testCollision(CollisionBody* body, CollisionCallback* c
|
|||
LinkedList<int> overlappingNodes(mMemoryManager.getPoolAllocator());
|
||||
mBroadPhaseAlgorithm.reportAllShapesOverlappingWithAABB(shapeAABB, overlappingNodes);
|
||||
|
||||
const bodyindex bodyId = body->getID();
|
||||
const bodyindex bodyId = body->getId();
|
||||
|
||||
// For each overlaping proxy shape
|
||||
LinkedList<int>::ListElement* element = overlappingNodes.getListHead();
|
||||
|
@ -837,7 +837,7 @@ void CollisionDetection::testCollision(CollisionBody* body, CollisionCallback* c
|
|||
ProxyShape* proxyShape = mBroadPhaseAlgorithm.getProxyShapeForBroadPhaseId(broadPhaseId);
|
||||
|
||||
// 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
|
||||
if ((proxyShape->getCollisionCategoryBits() & categoryMaskBits) != 0) {
|
||||
|
|
|
@ -314,7 +314,7 @@ inline void CollisionDetection::raycast(RaycastCallback* raycastCallback,
|
|||
const Ray& ray,
|
||||
unsigned short raycastWithCategoryMaskBits) const {
|
||||
|
||||
PROFILE("CollisionDetection::raycast()", mProfiler);
|
||||
RP3D_PROFILE("CollisionDetection::raycast()", mProfiler);
|
||||
|
||||
RaycastTest rayCastTest(raycastCallback);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
// Libraries
|
||||
#include "BroadPhaseAlgorithm.h"
|
||||
#include "collision/CollisionDetection.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
|
||||
// We want to use the ReactPhysics3D namespace
|
||||
using namespace reactphysics3d;
|
||||
|
@ -257,7 +257,7 @@ void BroadPhaseAlgorithm::computeOverlappingPairs(MemoryManager& memoryManager)
|
|||
ProxyShape* shape2 = static_cast<ProxyShape*>(mDynamicAABBTree.getNodeDataPointer(pair->collisionShape2ID));
|
||||
|
||||
// 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
|
||||
mCollisionDetection.broadPhaseNotifyOverlappingPair(shape1, shape2);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "body/CollisionBody.h"
|
||||
#include "collision/ProxyShape.h"
|
||||
#include "DynamicAABBTree.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
#include "containers/LinkedList.h"
|
||||
|
||||
/// Namespace ReactPhysics3D
|
||||
|
@ -265,7 +265,7 @@ inline const AABB& BroadPhaseAlgorithm::getFatAABB(int broadPhaseId) const {
|
|||
inline void BroadPhaseAlgorithm::raycast(const Ray& ray, RaycastTest& raycastTest,
|
||||
unsigned short raycastWithCategoryMaskBits) const {
|
||||
|
||||
PROFILE("BroadPhaseAlgorithm::raycast()", mProfiler);
|
||||
RP3D_PROFILE("BroadPhaseAlgorithm::raycast()", mProfiler);
|
||||
|
||||
BroadPhaseRaycastCallback broadPhaseRaycastCallback(mDynamicAABBTree, raycastWithCategoryMaskBits, raycastTest);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "DynamicAABBTree.h"
|
||||
#include "BroadPhaseAlgorithm.h"
|
||||
#include "containers/Stack.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
|
||||
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).
|
||||
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(mNodes[nodeID].isLeaf());
|
||||
|
@ -635,7 +635,7 @@ void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& aabb,
|
|||
// Ray casting method
|
||||
void DynamicAABBTree::raycast(const Ray& ray, DynamicAABBTreeRaycastCallback &callback) const {
|
||||
|
||||
PROFILE("DynamicAABBTree::raycast()", mProfiler);
|
||||
RP3D_PROFILE("DynamicAABBTree::raycast()", mProfiler);
|
||||
|
||||
decimal maxFraction = ray.maxFraction;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "engine/OverlappingPair.h"
|
||||
#include "collision/shapes/TriangleShape.h"
|
||||
#include "configuration.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
|
@ -49,7 +49,7 @@ using namespace reactphysics3d;
|
|||
/// the correct penetration depth and contact points between the enlarged objects.
|
||||
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 suppB; // Support point of object B
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "engine/OverlappingPair.h"
|
||||
#include "collision/shapes/TriangleShape.h"
|
||||
#include "configuration.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
|
@ -52,7 +52,7 @@ SATAlgorithm::SATAlgorithm(MemoryAllocator& memoryAllocator) : mMemoryAllocator(
|
|||
// Test collision between a sphere and a convex mesh
|
||||
bool SATAlgorithm::testCollisionSphereVsConvexPolyhedron(NarrowPhaseInfo* narrowPhaseInfo, bool reportContacts) const {
|
||||
|
||||
PROFILE("SATAlgorithm::testCollisionSphereVsConvexPolyhedron()", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::testCollisionSphereVsConvexPolyhedron()", mProfiler);
|
||||
|
||||
bool isSphereShape1 = narrowPhaseInfo->collisionShape1->getType() == CollisionShapeType::SPHERE;
|
||||
|
||||
|
@ -127,7 +127,7 @@ bool SATAlgorithm::testCollisionSphereVsConvexPolyhedron(NarrowPhaseInfo* narrow
|
|||
decimal SATAlgorithm::computePolyhedronFaceVsSpherePenetrationDepth(uint faceIndex, const ConvexPolyhedronShape* polyhedron,
|
||||
const SphereShape* sphere, const Vector3& sphereCenter) const {
|
||||
|
||||
PROFILE("SATAlgorithm::computePolyhedronFaceVsSpherePenetrationDepth)", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::computePolyhedronFaceVsSpherePenetrationDepth)", mProfiler);
|
||||
|
||||
// Get the face
|
||||
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
|
||||
bool SATAlgorithm::testCollisionCapsuleVsConvexPolyhedron(NarrowPhaseInfo* narrowPhaseInfo, bool reportContacts) const {
|
||||
|
||||
PROFILE("SATAlgorithm::testCollisionCapsuleVsConvexPolyhedron()", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::testCollisionCapsuleVsConvexPolyhedron()", mProfiler);
|
||||
|
||||
bool isCapsuleShape1 = narrowPhaseInfo->collisionShape1->getType() == CollisionShapeType::CAPSULE;
|
||||
|
||||
|
@ -304,7 +304,7 @@ decimal SATAlgorithm::computeEdgeVsCapsuleInnerSegmentPenetrationDepth(const Con
|
|||
const Vector3& edgeDirectionCapsuleSpace,
|
||||
const Transform& polyhedronToCapsuleTransform, Vector3& outAxis) const {
|
||||
|
||||
PROFILE("SATAlgorithm::computeEdgeVsCapsuleInnerSegmentPenetrationDepth)", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::computeEdgeVsCapsuleInnerSegmentPenetrationDepth)", mProfiler);
|
||||
|
||||
decimal penetrationDepth = DECIMAL_LARGEST;
|
||||
|
||||
|
@ -338,7 +338,7 @@ decimal SATAlgorithm::computePolyhedronFaceVsCapsulePenetrationDepth(uint polyhe
|
|||
const CapsuleShape* capsule, const Transform& polyhedronToCapsuleTransform,
|
||||
Vector3& outFaceNormalCapsuleSpace) const {
|
||||
|
||||
PROFILE("SATAlgorithm::computePolyhedronFaceVsCapsulePenetrationDepth", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::computePolyhedronFaceVsCapsulePenetrationDepth", mProfiler);
|
||||
|
||||
// Get the face
|
||||
const HalfEdgeStructure::Face& face = polyhedron->getFace(polyhedronFaceIndex);
|
||||
|
@ -364,7 +364,7 @@ bool SATAlgorithm::computeCapsulePolyhedronFaceContactPoints(uint referenceFaceI
|
|||
const Vector3& capsuleSegAPolyhedronSpace, const Vector3& capsuleSegBPolyhedronSpace,
|
||||
NarrowPhaseInfo* narrowPhaseInfo, bool isCapsuleShape1) const {
|
||||
|
||||
PROFILE("SATAlgorithm::computeCapsulePolyhedronFaceContactPoints", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::computeCapsulePolyhedronFaceContactPoints", mProfiler);
|
||||
|
||||
const HalfEdgeStructure::Face& face = polyhedron->getFace(referenceFaceIndex);
|
||||
|
||||
|
@ -459,7 +459,7 @@ bool SATAlgorithm::isMinkowskiFaceCapsuleVsEdge(const Vector3& capsuleSegment, c
|
|||
// Test collision between two convex polyhedrons
|
||||
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->collisionShape2->getType() == CollisionShapeType::CONVEX_POLYHEDRON);
|
||||
|
@ -804,7 +804,7 @@ bool SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints(bool isMinPene
|
|||
const Transform& polyhedron1ToPolyhedron2, const Transform& polyhedron2ToPolyhedron1,
|
||||
uint minFaceIndex, NarrowPhaseInfo* narrowPhaseInfo, decimal minPenetrationDepth) const {
|
||||
|
||||
PROFILE("SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints", mProfiler);
|
||||
|
||||
const ConvexPolyhedronShape* referencePolyhedron = isMinPenetrationFaceNormalPolyhedron1 ? polyhedron1 : polyhedron2;
|
||||
const ConvexPolyhedronShape* incidentPolyhedron = isMinPenetrationFaceNormalPolyhedron1 ? polyhedron2 : polyhedron1;
|
||||
|
@ -919,7 +919,7 @@ decimal SATAlgorithm::computeDistanceBetweenEdges(const Vector3& edge1A, const V
|
|||
const Vector3& edge1Direction, const Vector3& edge2Direction,
|
||||
Vector3& outSeparatingAxisPolyhedron2Space) const {
|
||||
|
||||
PROFILE("SATAlgorithm::computeDistanceBetweenEdges", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::computeDistanceBetweenEdges", mProfiler);
|
||||
|
||||
// If the two edges are parallel
|
||||
if (areParallelVectors(edge1Direction, edge2Direction)) {
|
||||
|
@ -948,7 +948,7 @@ decimal SATAlgorithm::testSingleFaceDirectionPolyhedronVsPolyhedron(const Convex
|
|||
const Transform& polyhedron1ToPolyhedron2,
|
||||
uint faceIndex) const {
|
||||
|
||||
PROFILE("SATAlgorithm::testSingleFaceDirectionPolyhedronVsPolyhedron", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::testSingleFaceDirectionPolyhedronVsPolyhedron", mProfiler);
|
||||
|
||||
const HalfEdgeStructure::Face& face = polyhedron1->getFace(faceIndex);
|
||||
|
||||
|
@ -974,7 +974,7 @@ decimal SATAlgorithm::testFacesDirectionPolyhedronVsPolyhedron(const ConvexPolyh
|
|||
const Transform& polyhedron1ToPolyhedron2,
|
||||
uint& minFaceIndex) const {
|
||||
|
||||
PROFILE("SATAlgorithm::testFacesDirectionPolyhedronVsPolyhedron", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::testFacesDirectionPolyhedronVsPolyhedron", mProfiler);
|
||||
|
||||
decimal minPenetrationDepth = DECIMAL_LARGEST;
|
||||
|
||||
|
@ -1006,7 +1006,7 @@ bool SATAlgorithm::testEdgesBuildMinkowskiFace(const ConvexPolyhedronShape* poly
|
|||
const ConvexPolyhedronShape* polyhedron2, const HalfEdgeStructure::Edge& edge2,
|
||||
const Transform& polyhedron1ToPolyhedron2) const {
|
||||
|
||||
PROFILE("SATAlgorithm::testEdgesBuildMinkowskiFace", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::testEdgesBuildMinkowskiFace", mProfiler);
|
||||
|
||||
const Vector3 a = polyhedron1ToPolyhedron2.getOrientation() * polyhedron1->getFaceNormal(edge1.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,
|
||||
const Vector3& bCrossA, const Vector3& dCrossC) const {
|
||||
|
||||
PROFILE("SATAlgorithm::testGaussMapArcsIntersect", mProfiler);
|
||||
RP3D_PROFILE("SATAlgorithm::testGaussMapArcsIntersect", mProfiler);
|
||||
|
||||
const decimal cba = c.dot(bCrossA);
|
||||
const decimal dba = d.dot(bCrossA);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
// Libraries
|
||||
#include "CollisionShape.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
#include "body/CollisionBody.h"
|
||||
|
||||
// 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 {
|
||||
|
||||
PROFILE("CollisionShape::computeAABB()", mProfiler);
|
||||
RP3D_PROFILE("CollisionShape::computeAABB()", mProfiler);
|
||||
|
||||
// Get the local bounds in x,y and z direction
|
||||
Vector3 minBounds;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "AABB.h"
|
||||
#include "collision/RaycastInfo.h"
|
||||
#include "memory/PoolAllocator.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
|
||||
/// ReactPhysics3D namespace
|
||||
namespace reactphysics3d {
|
||||
|
|
|
@ -114,7 +114,7 @@ void ConcaveMeshShape::testAllTriangles(TriangleCallback& callback, const AABB&
|
|||
/// the ray hits many triangles.
|
||||
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
|
||||
ConcaveMeshRaycastCallback raycastCallback(mDynamicAABBTree, *this, proxyShape, raycastInfo, ray, allocator);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "collision/TriangleMesh.h"
|
||||
#include "collision/shapes/TriangleShape.h"
|
||||
#include "containers/List.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
|
||||
namespace reactphysics3d {
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ bool HeightFieldShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxySh
|
|||
// TODO : Implement raycasting without using an AABB for the ray
|
||||
// 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);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
// Libraries
|
||||
#include "ConcaveShape.h"
|
||||
#include "collision/shapes/TriangleShape.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
|
||||
namespace reactphysics3d {
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "TriangleShape.h"
|
||||
#include "collision/ProxyShape.h"
|
||||
#include "mathematics/mathematics_functions.h"
|
||||
#include "engine/Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
#include "configuration.h"
|
||||
#include <cassert>
|
||||
|
||||
|
@ -213,7 +213,7 @@ Vector3 TriangleShape::computeSmoothLocalContactNormalForTriangle(const Vector3&
|
|||
/// Real-time Collision Detection by Christer Ericson.
|
||||
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 pa = mPoints[0] - ray.point1;
|
||||
|
|
|
@ -33,8 +33,8 @@ using namespace reactphysics3d;
|
|||
const decimal BallAndSocketJoint::BETA = decimal(0.2);
|
||||
|
||||
// Constructor
|
||||
BallAndSocketJoint::BallAndSocketJoint(const BallAndSocketJointInfo& jointInfo)
|
||||
: Joint(jointInfo), mImpulse(Vector3(0, 0, 0)) {
|
||||
BallAndSocketJoint::BallAndSocketJoint(uint id, const BallAndSocketJointInfo& jointInfo)
|
||||
: Joint(id, jointInfo), mImpulse(Vector3(0, 0, 0)) {
|
||||
|
||||
// Compute the local-space anchor point for each body
|
||||
mLocalAnchorPointBody1 = mBody1->getTransform().getInverse() * jointInfo.anchorPointWorldSpace;
|
||||
|
|
|
@ -125,7 +125,7 @@ class BallAndSocketJoint : public Joint {
|
|||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
BallAndSocketJoint(const BallAndSocketJointInfo& jointInfo);
|
||||
BallAndSocketJoint(uint id, const BallAndSocketJointInfo& jointInfo);
|
||||
|
||||
/// Destructor
|
||||
virtual ~BallAndSocketJoint() override = default;
|
||||
|
|
|
@ -33,8 +33,8 @@ using namespace reactphysics3d;
|
|||
const decimal FixedJoint::BETA = decimal(0.2);
|
||||
|
||||
// Constructor
|
||||
FixedJoint::FixedJoint(const FixedJointInfo& jointInfo)
|
||||
: Joint(jointInfo), mImpulseTranslation(0, 0, 0), mImpulseRotation(0, 0, 0) {
|
||||
FixedJoint::FixedJoint(uint id, const FixedJointInfo& jointInfo)
|
||||
: Joint(id, jointInfo), mImpulseTranslation(0, 0, 0), mImpulseRotation(0, 0, 0) {
|
||||
|
||||
// Compute the local-space anchor point for each body
|
||||
const Transform& transform1 = mBody1->getTransform();
|
||||
|
|
|
@ -136,7 +136,7 @@ class FixedJoint : public Joint {
|
|||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
FixedJoint(const FixedJointInfo& jointInfo);
|
||||
FixedJoint(uint id, const FixedJointInfo& jointInfo);
|
||||
|
||||
/// Destructor
|
||||
virtual ~FixedJoint() override = default;
|
||||
|
|
|
@ -34,8 +34,8 @@ using namespace reactphysics3d;
|
|||
const decimal HingeJoint::BETA = decimal(0.2);
|
||||
|
||||
// Constructor
|
||||
HingeJoint::HingeJoint(const HingeJointInfo& jointInfo)
|
||||
: Joint(jointInfo), mImpulseTranslation(0, 0, 0), mImpulseRotation(0, 0),
|
||||
HingeJoint::HingeJoint(uint id, const HingeJointInfo& jointInfo)
|
||||
: Joint(id, jointInfo), mImpulseTranslation(0, 0, 0), mImpulseRotation(0, 0),
|
||||
mImpulseLowerLimit(0), mImpulseUpperLimit(0), mImpulseMotor(0),
|
||||
mIsLimitEnabled(jointInfo.isLimitEnabled), mIsMotorEnabled(jointInfo.isMotorEnabled),
|
||||
mLowerLimit(jointInfo.minAngleLimit), mUpperLimit(jointInfo.maxAngleLimit),
|
||||
|
|
|
@ -287,7 +287,7 @@ class HingeJoint : public Joint {
|
|||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
HingeJoint(const HingeJointInfo& jointInfo);
|
||||
HingeJoint(uint id, const HingeJointInfo& jointInfo);
|
||||
|
||||
/// Destructor
|
||||
virtual ~HingeJoint() override = default;
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
using namespace reactphysics3d;
|
||||
|
||||
// Constructor
|
||||
Joint::Joint(const JointInfo& jointInfo)
|
||||
:mBody1(jointInfo.body1), mBody2(jointInfo.body2), mType(jointInfo.type),
|
||||
Joint::Joint(uint id, const JointInfo& jointInfo)
|
||||
:mId(id), mBody1(jointInfo.body1), mBody2(jointInfo.body2), mType(jointInfo.type),
|
||||
mPositionCorrectionTechnique(jointInfo.positionCorrectionTechnique),
|
||||
mIsCollisionEnabled(jointInfo.isCollisionEnabled), mIsAlreadyInIsland(false) {
|
||||
|
||||
|
|
|
@ -120,6 +120,9 @@ class Joint {
|
|||
|
||||
// -------------------- Attributes -------------------- //
|
||||
|
||||
/// Id of the joint
|
||||
uint mId;
|
||||
|
||||
/// Pointer to the first body of the joint
|
||||
RigidBody* const mBody1;
|
||||
|
||||
|
@ -144,6 +147,9 @@ class Joint {
|
|||
/// True if the joint has already been added into an island
|
||||
bool mIsAlreadyInIsland;
|
||||
|
||||
/// Total number of joints
|
||||
static uint mNbTotalNbJoints;
|
||||
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Return true if the joint has already been added into an island
|
||||
|
@ -169,7 +175,7 @@ class Joint {
|
|||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
Joint(const JointInfo& jointInfo);
|
||||
Joint(uint id, const JointInfo& jointInfo);
|
||||
|
||||
/// Destructor
|
||||
virtual ~Joint() = default;
|
||||
|
@ -195,6 +201,9 @@ class Joint {
|
|||
/// Return true if the collision between the two bodies of the joint is enabled
|
||||
bool isCollisionEnabled() const;
|
||||
|
||||
/// Return the id of the joint
|
||||
uint getId() const;
|
||||
|
||||
// -------------------- Friendship -------------------- //
|
||||
|
||||
friend class DynamicsWorld;
|
||||
|
@ -243,6 +252,14 @@ inline bool Joint::isCollisionEnabled() const {
|
|||
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
|
||||
inline bool Joint::isAlreadyInIsland() const {
|
||||
return mIsAlreadyInIsland;
|
||||
|
|
|
@ -32,8 +32,8 @@ using namespace reactphysics3d;
|
|||
const decimal SliderJoint::BETA = decimal(0.2);
|
||||
|
||||
// Constructor
|
||||
SliderJoint::SliderJoint(const SliderJointInfo& jointInfo)
|
||||
: Joint(jointInfo), mImpulseTranslation(0, 0), mImpulseRotation(0, 0, 0),
|
||||
SliderJoint::SliderJoint(uint id, const SliderJointInfo& jointInfo)
|
||||
: Joint(id, jointInfo), mImpulseTranslation(0, 0), mImpulseRotation(0, 0, 0),
|
||||
mImpulseLowerLimit(0), mImpulseUpperLimit(0), mImpulseMotor(0),
|
||||
mIsLimitEnabled(jointInfo.isLimitEnabled), mIsMotorEnabled(jointInfo.isMotorEnabled),
|
||||
mLowerLimit(jointInfo.minTranslationLimit),
|
||||
|
|
|
@ -285,7 +285,7 @@ class SliderJoint : public Joint {
|
|||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
SliderJoint(const SliderJointInfo& jointInfo);
|
||||
SliderJoint(uint id, const SliderJointInfo& jointInfo);
|
||||
|
||||
/// Destructor
|
||||
virtual ~SliderJoint() override = default;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
// Libraries
|
||||
#include "configuration.h"
|
||||
#include "memory/MemoryAllocator.h"
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class Pair {
|
|||
|
||||
}
|
||||
|
||||
// Hash function for struct VerticesPair
|
||||
// Hash function for a reactphysics3d Pair
|
||||
namespace std {
|
||||
|
||||
template <typename T1, typename T2> struct hash<reactphysics3d::Pair<T1, T2>> {
|
||||
|
|
|
@ -26,28 +26,64 @@
|
|||
// Libraries
|
||||
#include "CollisionWorld.h"
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
// Namespaces
|
||||
using namespace reactphysics3d;
|
||||
using namespace std;
|
||||
|
||||
// Initialization of static fields
|
||||
uint CollisionWorld::mNbWorlds = 0;
|
||||
|
||||
// Constructor
|
||||
CollisionWorld::CollisionWorld(const WorldSettings& worldSettings)
|
||||
: mConfig(worldSettings), mCollisionDetection(this, mMemoryManager), mBodies(mMemoryManager.getPoolAllocator()), mCurrentBodyID(0),
|
||||
mFreeBodiesIDs(mMemoryManager.getPoolAllocator()), mEventListener(nullptr) {
|
||||
CollisionWorld::CollisionWorld(const string& name, const WorldSettings& worldSettings)
|
||||
: mConfig(worldSettings), mCollisionDetection(this, mMemoryManager), mBodies(mMemoryManager.getPoolAllocator()), mCurrentBodyId(0),
|
||||
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
|
||||
|
||||
// Add a destination file for the profiling data
|
||||
mProfiler.addFileDestination("rp3d_profiling_" + mName + ".txt", Profiler::Format::Text);
|
||||
|
||||
// Set the profiler
|
||||
mCollisionDetection.setProfiler(&mProfiler);
|
||||
|
||||
#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
|
||||
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
|
||||
for (int i=mBodies.size() - 1 ; i >= 0; i--) {
|
||||
destroyCollisionBody(mBodies[i]);
|
||||
|
@ -64,7 +100,7 @@ CollisionWorld::~CollisionWorld() {
|
|||
CollisionBody* CollisionWorld::createCollisionBody(const Transform& transform) {
|
||||
|
||||
// Get the next available body ID
|
||||
bodyindex bodyID = computeNextAvailableBodyID();
|
||||
bodyindex bodyID = computeNextAvailableBodyId();
|
||||
|
||||
// Largest index cannot be used (it is used for invalid index)
|
||||
assert(bodyID < std::numeric_limits<reactphysics3d::bodyindex>::max());
|
||||
|
@ -85,6 +121,9 @@ CollisionBody* CollisionWorld::createCollisionBody(const Transform& transform) {
|
|||
|
||||
#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 collisionBody;
|
||||
}
|
||||
|
@ -95,11 +134,14 @@ CollisionBody* CollisionWorld::createCollisionBody(const Transform& transform) {
|
|||
*/
|
||||
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
|
||||
collisionBody->removeAllCollisionShapes();
|
||||
|
||||
// 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
|
||||
collisionBody->~CollisionBody();
|
||||
|
@ -112,17 +154,17 @@ void CollisionWorld::destroyCollisionBody(CollisionBody* collisionBody) {
|
|||
}
|
||||
|
||||
// Return the next available body ID
|
||||
bodyindex CollisionWorld::computeNextAvailableBodyID() {
|
||||
bodyindex CollisionWorld::computeNextAvailableBodyId() {
|
||||
|
||||
// Compute the body ID
|
||||
bodyindex bodyID;
|
||||
if (mFreeBodiesIDs.size() != 0) {
|
||||
bodyID = mFreeBodiesIDs[mFreeBodiesIDs.size() - 1];
|
||||
mFreeBodiesIDs.removeAt(mFreeBodiesIDs.size() - 1);
|
||||
if (mFreeBodiesIds.size() != 0) {
|
||||
bodyID = mFreeBodiesIds[mFreeBodiesIds.size() - 1];
|
||||
mFreeBodiesIds.removeAt(mFreeBodiesIds.size() - 1);
|
||||
}
|
||||
else {
|
||||
bodyID = mCurrentBodyID;
|
||||
mCurrentBodyID++;
|
||||
bodyID = mCurrentBodyId;
|
||||
mCurrentBodyId++;
|
||||
}
|
||||
|
||||
return bodyID;
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#include <algorithm>
|
||||
#include "mathematics/mathematics.h"
|
||||
#include "containers/List.h"
|
||||
#include "Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "body/CollisionBody.h"
|
||||
#include "collision/RaycastInfo.h"
|
||||
#include "OverlappingPair.h"
|
||||
|
@ -71,25 +72,37 @@ class CollisionWorld {
|
|||
/// All the bodies (rigid and soft) of the world
|
||||
List<CollisionBody*> mBodies;
|
||||
|
||||
/// Current body ID
|
||||
bodyindex mCurrentBodyID;
|
||||
/// Current body id
|
||||
bodyindex mCurrentBodyId;
|
||||
|
||||
/// List of free ID for rigid bodies
|
||||
List<luint> mFreeBodiesIDs;
|
||||
/// List of free ids for rigid bodies
|
||||
List<luint> mFreeBodiesIds;
|
||||
|
||||
/// Pointer to an event listener object
|
||||
EventListener* mEventListener;
|
||||
|
||||
/// Name of the collision world
|
||||
std::string mName;
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
/// Real-time hierarchical profiler
|
||||
Profiler mProfiler;
|
||||
#endif
|
||||
|
||||
#ifdef IS_LOGGING_ACTIVE
|
||||
|
||||
/// Logger
|
||||
Logger mLogger;
|
||||
#endif
|
||||
|
||||
/// Total number of worlds
|
||||
static uint mNbWorlds;
|
||||
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Return the next available body ID
|
||||
bodyindex computeNextAvailableBodyID();
|
||||
/// Return the next available body id
|
||||
bodyindex computeNextAvailableBodyId();
|
||||
|
||||
/// Reset all the contact manifolds linked list of each body
|
||||
void resetContactManifoldListsOfBodies();
|
||||
|
@ -99,7 +112,7 @@ class CollisionWorld {
|
|||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
CollisionWorld(const WorldSettings& worldSettings = WorldSettings());
|
||||
CollisionWorld(const std::string& name = "", const WorldSettings& worldSettings = WorldSettings());
|
||||
|
||||
/// Destructor
|
||||
virtual ~CollisionWorld();
|
||||
|
@ -147,13 +160,24 @@ class CollisionWorld {
|
|||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
/// Set the name of the profiler
|
||||
void setProfilerName(std::string name);
|
||||
/// Return a reference to the profiler
|
||||
Profiler& getProfiler();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef IS_LOGGING_ACTIVE
|
||||
|
||||
/// Return a reference to the logger
|
||||
Logger& getLogger();
|
||||
|
||||
#endif
|
||||
|
||||
/// Return the current world-space AABB of given proxy shape
|
||||
AABB getWorldAABB(const ProxyShape* proxyShape) const;
|
||||
|
||||
/// Return the name of the world
|
||||
const std::string& getName() const;
|
||||
|
||||
// -------------------- Friendship -------------------- //
|
||||
|
||||
friend class CollisionDetection;
|
||||
|
@ -224,11 +248,25 @@ inline void CollisionWorld::testOverlap(CollisionBody* body, OverlapCallback* ov
|
|||
mCollisionDetection.testOverlap(body, overlapCallback, categoryMaskBits);
|
||||
}
|
||||
|
||||
// Return the name of the world
|
||||
inline const std::string& CollisionWorld::getName() const {
|
||||
return mName;
|
||||
}
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
// Set the name of the profiler
|
||||
inline void CollisionWorld::setProfilerName(std::string name) {
|
||||
mProfiler.setName(name);
|
||||
// Return a reference to the profiler
|
||||
inline Profiler& CollisionWorld::getProfiler() {
|
||||
return mProfiler;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef IS_LOGGING_ACTIVE
|
||||
|
||||
// Return a reference to the logger
|
||||
inline Logger& CollisionWorld::getLogger() {
|
||||
return mLogger;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
// Libraries
|
||||
#include "ConstraintSolver.h"
|
||||
#include "Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
|
||||
using namespace reactphysics3d;
|
||||
|
||||
|
@ -43,7 +43,7 @@ ConstraintSolver::ConstraintSolver() : mIsWarmStartingActive(true) {
|
|||
// Initialize the constraint solver for a given island
|
||||
void ConstraintSolver::initializeForIsland(decimal dt, Island* island) {
|
||||
|
||||
PROFILE("ConstraintSolver::initializeForIsland()", mProfiler);
|
||||
RP3D_PROFILE("ConstraintSolver::initializeForIsland()", mProfiler);
|
||||
|
||||
assert(island != nullptr);
|
||||
assert(island->getNbBodies() > 0);
|
||||
|
@ -73,7 +73,7 @@ void ConstraintSolver::initializeForIsland(decimal dt, Island* island) {
|
|||
// Solve the velocity constraints
|
||||
void ConstraintSolver::solveVelocityConstraints(Island* island) {
|
||||
|
||||
PROFILE("ConstraintSolver::solveVelocityConstraints()", mProfiler);
|
||||
RP3D_PROFILE("ConstraintSolver::solveVelocityConstraints()", mProfiler);
|
||||
|
||||
assert(island != nullptr);
|
||||
assert(island->getNbJoints() > 0);
|
||||
|
@ -90,7 +90,7 @@ void ConstraintSolver::solveVelocityConstraints(Island* island) {
|
|||
// Solve the position constraints
|
||||
void ConstraintSolver::solvePositionConstraints(Island* island) {
|
||||
|
||||
PROFILE("ConstraintSolver::solvePositionConstraints()", mProfiler);
|
||||
RP3D_PROFILE("ConstraintSolver::solvePositionConstraints()", mProfiler);
|
||||
|
||||
assert(island != nullptr);
|
||||
assert(island->getNbJoints() > 0);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "ContactSolver.h"
|
||||
#include "DynamicsWorld.h"
|
||||
#include "body/RigidBody.h"
|
||||
#include "Profiler.h"
|
||||
#include "utils/Profiler.h"
|
||||
#include <limits>
|
||||
|
||||
using namespace reactphysics3d;
|
||||
|
@ -50,7 +50,7 @@ ContactSolver::ContactSolver(MemoryManager& memoryManager, const WorldSettings&
|
|||
// Initialize the contact constraints
|
||||
void ContactSolver::init(Island** islands, uint nbIslands, decimal timeStep) {
|
||||
|
||||
PROFILE("ContactSolver::init()", mProfiler);
|
||||
RP3D_PROFILE("ContactSolver::init()", mProfiler);
|
||||
|
||||
mTimeStep = timeStep;
|
||||
|
||||
|
@ -98,7 +98,7 @@ void ContactSolver::init(Island** islands, uint nbIslands, decimal timeStep) {
|
|||
// Initialize the constraint solver for a given island
|
||||
void ContactSolver::initializeForIsland(Island* island) {
|
||||
|
||||
PROFILE("ContactSolver::initializeForIsland()", mProfiler);
|
||||
RP3D_PROFILE("ContactSolver::initializeForIsland()", mProfiler);
|
||||
|
||||
assert(island != nullptr);
|
||||
assert(island->getNbBodies() > 0);
|
||||
|
@ -326,7 +326,7 @@ void ContactSolver::initializeForIsland(Island* island) {
|
|||
/// the solution of the linear system
|
||||
void ContactSolver::warmStart() {
|
||||
|
||||
PROFILE("ContactSolver::warmStart()", mProfiler);
|
||||
RP3D_PROFILE("ContactSolver::warmStart()", mProfiler);
|
||||
|
||||
uint contactPointIndex = 0;
|
||||
|
||||
|
@ -479,7 +479,7 @@ void ContactSolver::warmStart() {
|
|||
// Solve the contacts
|
||||
void ContactSolver::solve() {
|
||||
|
||||
PROFILE("ContactSolver::solve()", mProfiler);
|
||||
RP3D_PROFILE("ContactSolver::solve()", mProfiler);
|
||||
|
||||
decimal deltaLambda;
|
||||
decimal lambdaTemp;
|
||||
|
@ -758,7 +758,7 @@ void ContactSolver::solve() {
|
|||
// warm start the solver at the next iteration
|
||||
void ContactSolver::storeImpulses() {
|
||||
|
||||
PROFILE("ContactSolver::storeImpulses()", mProfiler);
|
||||
RP3D_PROFILE("ContactSolver::storeImpulses()", mProfiler);
|
||||
|
||||
uint contactPointIndex = 0;
|
||||
|
||||
|
@ -786,7 +786,7 @@ void ContactSolver::storeImpulses() {
|
|||
void ContactSolver::computeFrictionVectors(const Vector3& deltaVelocity,
|
||||
ContactManifoldSolver& contact) const {
|
||||
|
||||
PROFILE("ContactSolver::computeFrictionVectors()", mProfiler);
|
||||
RP3D_PROFILE("ContactSolver::computeFrictionVectors()", mProfiler);
|
||||
|
||||
assert(contact.normal.length() > decimal(0.0));
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ using namespace std;
|
|||
/**
|
||||
* @param gravity Gravity vector in the world (in meters per second squared)
|
||||
*/
|
||||
DynamicsWorld::DynamicsWorld(const Vector3 &gravity, const WorldSettings& worldSettings)
|
||||
: CollisionWorld(worldSettings),
|
||||
DynamicsWorld::DynamicsWorld(const Vector3& gravity, const string& name, const WorldSettings& worldSettings)
|
||||
: CollisionWorld(name, worldSettings),
|
||||
mContactSolver(mMemoryManager, mConfig),
|
||||
mNbVelocitySolverIterations(mConfig.defaultVelocitySolverNbIterations),
|
||||
mNbPositionSolverIterations(mConfig.defaultPositionSolverNbIterations),
|
||||
|
@ -52,7 +52,8 @@ DynamicsWorld::DynamicsWorld(const Vector3 &gravity, const WorldSettings& worldS
|
|||
mConstrainedOrientations(nullptr), mNbIslands(0), mIslands(nullptr),
|
||||
mSleepLinearVelocity(mConfig.defaultSleepLinearVelocity),
|
||||
mSleepAngularVelocity(mConfig.defaultSleepAngularVelocity),
|
||||
mTimeBeforeSleep(mConfig.defaultTimeBeforeSleep) {
|
||||
mTimeBeforeSleep(mConfig.defaultTimeBeforeSleep),
|
||||
mFreeJointsIDs(mMemoryManager.getPoolAllocator()), mCurrentJointId(0) {
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
|
@ -62,6 +63,9 @@ DynamicsWorld::DynamicsWorld(const Vector3 &gravity, const WorldSettings& worldS
|
|||
|
||||
#endif
|
||||
|
||||
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
|
||||
"Dynamics world " + mName + " has been created");
|
||||
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
@ -82,13 +86,12 @@ DynamicsWorld::~DynamicsWorld() {
|
|||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
// Print the profiling report
|
||||
ofstream myfile;
|
||||
myfile.open(mProfiler.getName() + ".txt");
|
||||
mProfiler.printReport(myfile);
|
||||
myfile.close();
|
||||
// Print the profiling report into the destinations
|
||||
mProfiler.printReport();
|
||||
#endif
|
||||
|
||||
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
|
||||
"Dynamics world " + mName + " has been destroyed");
|
||||
}
|
||||
|
||||
// Update the physics simulation
|
||||
|
@ -102,7 +105,7 @@ void DynamicsWorld::update(decimal timeStep) {
|
|||
mProfiler.incrementFrameCounter();
|
||||
#endif
|
||||
|
||||
PROFILE("DynamicsWorld::update()", &mProfiler);
|
||||
RP3D_PROFILE("DynamicsWorld::update()", &mProfiler);
|
||||
|
||||
mTimeStep = timeStep;
|
||||
|
||||
|
@ -150,7 +153,7 @@ void DynamicsWorld::update(decimal timeStep) {
|
|||
/// the sympletic Euler time stepping scheme.
|
||||
void DynamicsWorld::integrateRigidBodiesPositions() {
|
||||
|
||||
PROFILE("DynamicsWorld::integrateRigidBodiesPositions()", &mProfiler);
|
||||
RP3D_PROFILE("DynamicsWorld::integrateRigidBodiesPositions()", &mProfiler);
|
||||
|
||||
// For each island of the world
|
||||
for (uint i=0; i < mNbIslands; i++) {
|
||||
|
@ -189,7 +192,7 @@ void DynamicsWorld::integrateRigidBodiesPositions() {
|
|||
// Update the postion/orientation of the bodies
|
||||
void DynamicsWorld::updateBodiesState() {
|
||||
|
||||
PROFILE("DynamicsWorld::updateBodiesState()", &mProfiler);
|
||||
RP3D_PROFILE("DynamicsWorld::updateBodiesState()", &mProfiler);
|
||||
|
||||
// For each island of the world
|
||||
for (uint islandIndex = 0; islandIndex < mNbIslands; islandIndex++) {
|
||||
|
@ -226,7 +229,7 @@ void DynamicsWorld::updateBodiesState() {
|
|||
// Initialize the bodies velocities arrays for the next simulation step.
|
||||
void DynamicsWorld::initVelocityArrays() {
|
||||
|
||||
PROFILE("DynamicsWorld::initVelocityArrays()", &mProfiler);
|
||||
RP3D_PROFILE("DynamicsWorld::initVelocityArrays()", &mProfiler);
|
||||
|
||||
// Allocate memory for the bodies velocity arrays
|
||||
uint nbBodies = mRigidBodies.size();
|
||||
|
@ -268,7 +271,7 @@ void DynamicsWorld::initVelocityArrays() {
|
|||
/// contact solver.
|
||||
void DynamicsWorld::integrateRigidBodiesVelocities() {
|
||||
|
||||
PROFILE("DynamicsWorld::integrateRigidBodiesVelocities()", &mProfiler);
|
||||
RP3D_PROFILE("DynamicsWorld::integrateRigidBodiesVelocities()", &mProfiler);
|
||||
|
||||
// Initialize the bodies velocity arrays
|
||||
initVelocityArrays();
|
||||
|
@ -330,7 +333,7 @@ void DynamicsWorld::integrateRigidBodiesVelocities() {
|
|||
// Solve the contacts and constraints
|
||||
void DynamicsWorld::solveContactsAndConstraints() {
|
||||
|
||||
PROFILE("DynamicsWorld::solveContactsAndConstraints()", &mProfiler);
|
||||
RP3D_PROFILE("DynamicsWorld::solveContactsAndConstraints()", &mProfiler);
|
||||
|
||||
// Set the velocities arrays
|
||||
mContactSolver.setSplitVelocitiesArrays(mSplitLinearVelocities, mSplitAngularVelocities);
|
||||
|
@ -380,7 +383,7 @@ void DynamicsWorld::solveContactsAndConstraints() {
|
|||
// Solve the position error correction of the constraints
|
||||
void DynamicsWorld::solvePositionCorrection() {
|
||||
|
||||
PROFILE("DynamicsWorld::solvePositionCorrection()", &mProfiler);
|
||||
RP3D_PROFILE("DynamicsWorld::solvePositionCorrection()", &mProfiler);
|
||||
|
||||
// Do not continue if there is no constraints
|
||||
if (mJoints.size() == 0) return;
|
||||
|
@ -407,7 +410,7 @@ void DynamicsWorld::solvePositionCorrection() {
|
|||
RigidBody* DynamicsWorld::createRigidBody(const Transform& transform) {
|
||||
|
||||
// Compute the body ID
|
||||
bodyindex bodyID = computeNextAvailableBodyID();
|
||||
bodyindex bodyID = computeNextAvailableBodyId();
|
||||
|
||||
// Largest index cannot be used (it is used for invalid index)
|
||||
assert(bodyID < std::numeric_limits<reactphysics3d::bodyindex>::max());
|
||||
|
@ -427,6 +430,9 @@ RigidBody* DynamicsWorld::createRigidBody(const Transform& transform) {
|
|||
|
||||
#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 rigidBody;
|
||||
}
|
||||
|
@ -437,11 +443,14 @@ RigidBody* DynamicsWorld::createRigidBody(const Transform& transform) {
|
|||
*/
|
||||
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
|
||||
rigidBody->removeAllCollisionShapes();
|
||||
|
||||
// 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
|
||||
JointListElement* element;
|
||||
|
@ -472,6 +481,9 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
|
|||
|
||||
Joint* newJoint = nullptr;
|
||||
|
||||
// Get the next available joint ID
|
||||
uint jointId = computeNextAvailableJointId();
|
||||
|
||||
// Allocate memory to create the new joint
|
||||
switch(jointInfo.type) {
|
||||
|
||||
|
@ -482,7 +494,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
|
|||
sizeof(BallAndSocketJoint));
|
||||
const BallAndSocketJointInfo& info = static_cast<const BallAndSocketJointInfo&>(
|
||||
jointInfo);
|
||||
newJoint = new (allocatedMemory) BallAndSocketJoint(info);
|
||||
newJoint = new (allocatedMemory) BallAndSocketJoint(jointId, info);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -492,7 +504,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
|
|||
void* allocatedMemory = mMemoryManager.allocate(MemoryManager::AllocationType::Pool,
|
||||
sizeof(SliderJoint));
|
||||
const SliderJointInfo& info = static_cast<const SliderJointInfo&>(jointInfo);
|
||||
newJoint = new (allocatedMemory) SliderJoint(info);
|
||||
newJoint = new (allocatedMemory) SliderJoint(jointId, info);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -502,7 +514,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
|
|||
void* allocatedMemory = mMemoryManager.allocate(MemoryManager::AllocationType::Pool,
|
||||
sizeof(HingeJoint));
|
||||
const HingeJointInfo& info = static_cast<const HingeJointInfo&>(jointInfo);
|
||||
newJoint = new (allocatedMemory) HingeJoint(info);
|
||||
newJoint = new (allocatedMemory) HingeJoint(jointId, info);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -512,7 +524,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
|
|||
void* allocatedMemory = mMemoryManager.allocate(MemoryManager::AllocationType::Pool,
|
||||
sizeof(FixedJoint));
|
||||
const FixedJointInfo& info = static_cast<const FixedJointInfo&>(jointInfo);
|
||||
newJoint = new (allocatedMemory) FixedJoint(info);
|
||||
newJoint = new (allocatedMemory) FixedJoint(jointId, info);
|
||||
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
|
||||
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 newJoint;
|
||||
}
|
||||
|
@ -548,6 +563,9 @@ void DynamicsWorld::destroyJoint(Joint* joint) {
|
|||
|
||||
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 (!joint->isCollisionEnabled()) {
|
||||
|
||||
|
@ -568,9 +586,15 @@ void DynamicsWorld::destroyJoint(Joint* joint) {
|
|||
|
||||
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
|
||||
joint->~Joint();
|
||||
|
||||
// Add the joint ID to the list of free IDs
|
||||
mFreeJointsIDs.add(joint->getId());
|
||||
|
||||
// Release the allocated memory
|
||||
mMemoryManager.release(MemoryManager::AllocationType::Pool, joint, nbBytes);
|
||||
}
|
||||
|
@ -595,6 +619,23 @@ void DynamicsWorld::addJointToBody(Joint* joint) {
|
|||
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.
|
||||
/// 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
|
||||
|
@ -604,7 +645,7 @@ void DynamicsWorld::addJointToBody(Joint* joint) {
|
|||
/// it). Then, we create an island with this group of connected bodies.
|
||||
void DynamicsWorld::computeIslands() {
|
||||
|
||||
PROFILE("DynamicsWorld::computeIslands()", &mProfiler);
|
||||
RP3D_PROFILE("DynamicsWorld::computeIslands()", &mProfiler);
|
||||
|
||||
uint nbBodies = mRigidBodies.size();
|
||||
|
||||
|
@ -693,7 +734,7 @@ void DynamicsWorld::computeIslands() {
|
|||
// Get the other body of the contact manifold
|
||||
RigidBody* body1 = static_cast<RigidBody*>(contactManifold->getBody1());
|
||||
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
|
||||
if (otherBody->mIsAlreadyInIsland) continue;
|
||||
|
@ -721,7 +762,7 @@ void DynamicsWorld::computeIslands() {
|
|||
// Get the other body of the contact manifold
|
||||
RigidBody* body1 = static_cast<RigidBody*>(joint->getBody1());
|
||||
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
|
||||
if (otherBody->mIsAlreadyInIsland) continue;
|
||||
|
@ -751,7 +792,7 @@ void DynamicsWorld::computeIslands() {
|
|||
/// time, we put all the bodies of the island to sleep.
|
||||
void DynamicsWorld::updateSleepingBodies() {
|
||||
|
||||
PROFILE("DynamicsWorld::updateSleepingBodies()", &mProfiler);
|
||||
RP3D_PROFILE("DynamicsWorld::updateSleepingBodies()", &mProfiler);
|
||||
|
||||
const decimal sleepLinearVelocitySquare = mSleepLinearVelocity * mSleepLinearVelocity;
|
||||
const decimal sleepAngularVelocitySquare = mSleepAngularVelocity * mSleepAngularVelocity;
|
||||
|
@ -820,6 +861,9 @@ void DynamicsWorld::enableSleeping(bool isSleepingEnabled) {
|
|||
(*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
|
||||
|
|
|
@ -116,6 +116,12 @@ class DynamicsWorld : public CollisionWorld {
|
|||
/// becomes smaller than the sleep velocity.
|
||||
decimal mTimeBeforeSleep;
|
||||
|
||||
/// List of free ID for joints
|
||||
List<luint> mFreeJointsIDs;
|
||||
|
||||
/// Current joint id
|
||||
uint mCurrentJointId;
|
||||
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// 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
|
||||
void addJointToBody(Joint* joint);
|
||||
|
||||
/// Return the next available joint id
|
||||
uint computeNextAvailableJointId();
|
||||
|
||||
public :
|
||||
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
DynamicsWorld(const Vector3& mGravity, const WorldSettings& worldSettings = WorldSettings());
|
||||
DynamicsWorld(const Vector3& mGravity, const std::string& name = "",
|
||||
const WorldSettings& worldSettings = WorldSettings());
|
||||
|
||||
/// Destructor
|
||||
virtual ~DynamicsWorld() override;
|
||||
|
@ -272,6 +282,9 @@ inline uint DynamicsWorld::getNbIterationsVelocitySolver() const {
|
|||
*/
|
||||
inline void DynamicsWorld::setNbIterationsVelocitySolver(uint 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
|
||||
|
@ -285,6 +298,9 @@ inline uint DynamicsWorld::getNbIterationsPositionSolver() const {
|
|||
*/
|
||||
inline void DynamicsWorld::setNbIterationsPositionSolver(uint 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
|
||||
|
@ -329,6 +345,9 @@ inline Vector3 DynamicsWorld::getGravity() const {
|
|||
*/
|
||||
inline void DynamicsWorld::setGravity(Vector3& 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
|
||||
|
@ -346,6 +365,9 @@ inline bool DynamicsWorld::isGravityEnabled() const {
|
|||
*/
|
||||
inline void DynamicsWorld::setIsGratityEnabled(bool 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
|
||||
|
@ -390,6 +412,9 @@ inline decimal DynamicsWorld::getSleepLinearVelocity() const {
|
|||
inline void DynamicsWorld::setSleepLinearVelocity(decimal sleepLinearVelocity) {
|
||||
assert(sleepLinearVelocity >= decimal(0.0));
|
||||
mSleepLinearVelocity = sleepLinearVelocity;
|
||||
|
||||
RP3D_LOG(mLogger, Logger::Level::Info, Logger::Category::World,
|
||||
"Dynamics World: sleepLinearVelocity= " + std::to_string(sleepLinearVelocity));
|
||||
}
|
||||
|
||||
// Return the current sleep angular velocity
|
||||
|
@ -410,6 +435,9 @@ inline decimal DynamicsWorld::getSleepAngularVelocity() const {
|
|||
inline void DynamicsWorld::setSleepAngularVelocity(decimal sleepAngularVelocity) {
|
||||
assert(sleepAngularVelocity >= decimal(0.0));
|
||||
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
|
||||
|
@ -428,6 +456,9 @@ inline decimal DynamicsWorld::getTimeBeforeSleep() const {
|
|||
inline void DynamicsWorld::setTimeBeforeSleep(decimal timeBeforeSleep) {
|
||||
assert(timeBeforeSleep >= decimal(0.0));
|
||||
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.
|
||||
|
|
|
@ -263,9 +263,9 @@ inline bodyindexpair OverlappingPair::computeBodiesIndexPair(CollisionBody* body
|
|||
CollisionBody* body2) {
|
||||
|
||||
// Construct the pair of body index
|
||||
bodyindexpair indexPair = body1->getID() < body2->getID() ?
|
||||
bodyindexpair(body1->getID(), body2->getID()) :
|
||||
bodyindexpair(body2->getID(), body1->getID());
|
||||
bodyindexpair indexPair = body1->getId() < body2->getId() ?
|
||||
bodyindexpair(body1->getId(), body2->getId()) :
|
||||
bodyindexpair(body2->getId(), body1->getId());
|
||||
assert(indexPair.first != indexPair.second);
|
||||
return indexPair;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
// Libraries
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include "Vector2.h"
|
||||
|
||||
/// ReactPhysics3D namespace
|
||||
|
@ -145,6 +146,9 @@ class Matrix2x2 {
|
|||
|
||||
/// Overloaded operator to read/write element of the matrix.
|
||||
Vector2& operator[](int row);
|
||||
|
||||
/// Return the string representation
|
||||
std::string to_string() const;
|
||||
};
|
||||
|
||||
// Constructor of the class Matrix2x2
|
||||
|
@ -340,6 +344,12 @@ inline Vector2& Matrix2x2::operator[](int 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
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
// Libraries
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include "Vector3.h"
|
||||
|
||||
/// ReactPhysics3D namespace
|
||||
|
@ -153,6 +154,9 @@ class Matrix3x3 {
|
|||
|
||||
/// Overloaded operator to read/write element of the matrix.
|
||||
Vector3& operator[](int row);
|
||||
|
||||
/// Return the string representation
|
||||
std::string to_string() const;
|
||||
};
|
||||
|
||||
// Constructor of the class Matrix3x3
|
||||
|
@ -392,6 +396,13 @@ inline Vector3& Matrix3x3::operator[](int 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
|
||||
|
|
|
@ -163,6 +163,9 @@ struct Quaternion {
|
|||
/// Overloaded operator for equality condition
|
||||
bool operator==(const Quaternion& quaternion) const;
|
||||
|
||||
/// Return the string representation
|
||||
std::string to_string() const;
|
||||
|
||||
private:
|
||||
|
||||
/// Initialize the quaternion using Euler angles
|
||||
|
@ -379,6 +382,12 @@ inline bool Quaternion::operator==(const Quaternion& quaternion) const {
|
|||
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
|
||||
|
|
|
@ -116,6 +116,9 @@ class Transform {
|
|||
|
||||
/// Assignment operator
|
||||
Transform& operator=(const Transform& transform);
|
||||
|
||||
/// Return the string representation
|
||||
std::string to_string() const;
|
||||
};
|
||||
|
||||
// Constructor
|
||||
|
@ -268,6 +271,11 @@ inline Transform& Transform::operator=(const Transform& transform) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
// Get the string representation
|
||||
inline std::string Transform::to_string() const {
|
||||
return "Transform(" + mPosition.to_string() + "," + mOrientation.to_string() + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
// Libraries
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include "mathematics_functions.h"
|
||||
#include "decimal.h"
|
||||
|
||||
|
@ -135,6 +136,9 @@ struct Vector2 {
|
|||
/// Overloaded less than operator for ordering to be used inside std::set for instance
|
||||
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
|
||||
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));
|
||||
}
|
||||
|
||||
// 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
|
||||
inline Vector2 Vector2::zero() {
|
||||
return Vector2(0, 0);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
// Libraries
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include "mathematics_functions.h"
|
||||
#include "decimal.h"
|
||||
|
||||
|
@ -147,6 +148,9 @@ struct Vector3 {
|
|||
/// Overloaded less than operator for ordering to be used inside std::set for instance
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
// 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
|
||||
inline Vector3 Vector3::zero() {
|
||||
return Vector3(0, 0, 0);
|
||||
|
|
102
src/utils/Logger.cpp
Normal file
102
src/utils/Logger.cpp
Normal 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
332
src/utils/Logger.h
Normal 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
|
|
@ -28,12 +28,10 @@
|
|||
// Libraries
|
||||
#include "Profiler.h"
|
||||
#include <string>
|
||||
#include "memory/MemoryManager.h"
|
||||
|
||||
using namespace reactphysics3d;
|
||||
|
||||
// Initialization of static variables
|
||||
int Profiler::mNbProfilers = 0;
|
||||
|
||||
// Constructor
|
||||
ProfileNode::ProfileNode(const char* name, ProfileNode* parentNode)
|
||||
: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
|
||||
// the profiling of the current block of code
|
||||
mStartingTime = Timer::getCurrentSystemTime() * 1000.0;
|
||||
mStartingTime = Timer::getCurrentSystemTime() * 1000.0L;
|
||||
}
|
||||
|
||||
mRecursionCounter++;
|
||||
|
@ -92,7 +90,7 @@ bool ProfileNode::exitBlockOfCode() {
|
|||
if (mRecursionCounter == 0 && mNbTotalCalls != 0) {
|
||||
|
||||
// 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
|
||||
mTotalTime += currentTime - mStartingTime;
|
||||
|
@ -105,7 +103,7 @@ bool ProfileNode::exitBlockOfCode() {
|
|||
// Reset the profiling of the node
|
||||
void ProfileNode::reset() {
|
||||
mNbTotalCalls = 0;
|
||||
mTotalTime = 0.0;
|
||||
mTotalTime = 0.0L;
|
||||
|
||||
// Reset the child node
|
||||
if (mChildNode != nullptr) {
|
||||
|
@ -156,27 +154,11 @@ void ProfileNodeIterator::enterParent() {
|
|||
}
|
||||
|
||||
// Constructor
|
||||
Profiler::Profiler(std::string name) :mRootNode("Root", nullptr) {
|
||||
|
||||
// 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;
|
||||
}
|
||||
Profiler::Profiler() :mRootNode("Root", nullptr), mDestinations(MemoryManager::getBaseAllocator()) {
|
||||
|
||||
mCurrentNode = &mRootNode;
|
||||
mProfilingStartTime = Timer::getCurrentSystemTime() * 1000.0;
|
||||
mProfilingStartTime = Timer::getCurrentSystemTime() * 1000.0L;
|
||||
mFrameCounter = 0;
|
||||
|
||||
mNbProfilers++;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
@ -213,18 +195,48 @@ void Profiler::reset() {
|
|||
mRootNode.reset();
|
||||
mRootNode.enterBlockOfCode();
|
||||
mFrameCounter = 0;
|
||||
mProfilingStartTime = Timer::getCurrentSystemTime() * 1000.0;
|
||||
mProfilingStartTime = Timer::getCurrentSystemTime() * 1000.0L;
|
||||
}
|
||||
|
||||
// Print the report of the profiler in a given output stream
|
||||
void Profiler::printReport(std::ostream& outputStream) {
|
||||
void Profiler::printReport() {
|
||||
|
||||
// For each destination
|
||||
for (auto it = mDestinations.begin(); it != mDestinations.end(); ++it) {
|
||||
|
||||
ProfileNodeIterator* iterator = Profiler::getIterator();
|
||||
|
||||
// Recursively print the report of each node of the profiler tree
|
||||
printRecursiveNodeReport(iterator, 0, outputStream);
|
||||
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
|
||||
|
@ -240,14 +252,14 @@ void Profiler::printRecursiveNodeReport(ProfileNodeIterator* iterator,
|
|||
|
||||
long double parentTime = iterator->isRoot() ? getElapsedTimeSinceStart() :
|
||||
iterator->getCurrentParentTotalTime();
|
||||
long double accumulatedTime = 0.0;
|
||||
long double accumulatedTime = 0.0L;
|
||||
uint nbFrames = Profiler::getNbFrames();
|
||||
for (int i=0; i<spacing; i++) outputStream << " ";
|
||||
outputStream << "---------------" << std::endl;
|
||||
for (int i=0; i<spacing; i++) outputStream << " ";
|
||||
outputStream << "| Profiling : " << iterator->getCurrentParentName() <<
|
||||
" (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
|
||||
int nbChildren = 0;
|
||||
|
@ -256,7 +268,7 @@ void Profiler::printRecursiveNodeReport(ProfileNodeIterator* iterator,
|
|||
long double currentTotalTime = iterator->getCurrentTotalTime();
|
||||
accumulatedTime += currentTotalTime;
|
||||
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 << " ";
|
||||
outputStream << "| " << i << " -- " << iterator->getCurrentName() << " : " <<
|
||||
fraction << " % | " << (currentTotalTime / (long double) (nbFrames)) <<
|
||||
|
@ -270,7 +282,7 @@ void Profiler::printRecursiveNodeReport(ProfileNodeIterator* iterator,
|
|||
}
|
||||
for (int i=0; i<spacing; i++) outputStream << " ";
|
||||
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;
|
||||
outputStream << "| Unaccounted : " << difference << " ms (" << percentage << " %)" << std::endl;
|
||||
|
|
@ -30,7 +30,9 @@
|
|||
|
||||
// Libraries
|
||||
#include "configuration.h"
|
||||
#include "Timer.h"
|
||||
#include "engine/Timer.h"
|
||||
#include <fstream>
|
||||
#include "containers/List.h"
|
||||
|
||||
/// ReactPhysics3D namespace
|
||||
namespace reactphysics3d {
|
||||
|
@ -180,16 +182,102 @@ class ProfileNodeIterator {
|
|||
*/
|
||||
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 :
|
||||
|
||||
// -------------------- Attributes -------------------- //
|
||||
|
||||
/// Profiler name
|
||||
std::string mName;
|
||||
|
||||
/// Total number of profilers
|
||||
static int mNbProfilers;
|
||||
|
||||
/// Root node of the profiler tree
|
||||
ProfileNode mRootNode;
|
||||
|
||||
|
@ -202,8 +290,12 @@ class Profiler {
|
|||
/// Starting profiling time
|
||||
long double mProfilingStartTime;
|
||||
|
||||
/// All the output destinations
|
||||
List<Destination*> mDestinations;
|
||||
|
||||
/// 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
|
||||
void destroyIterator(ProfileNodeIterator* iterator);
|
||||
|
@ -216,7 +308,7 @@ class Profiler {
|
|||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
Profiler(std::string name = "");
|
||||
Profiler();
|
||||
|
||||
/// Destructor
|
||||
~Profiler();
|
||||
|
@ -234,12 +326,6 @@ class Profiler {
|
|||
/// Return the number of frames
|
||||
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
|
||||
long double getElapsedTimeSinceStart();
|
||||
|
||||
|
@ -249,8 +335,17 @@ class Profiler {
|
|||
/// Return an iterator over the profiler tree starting at the root
|
||||
ProfileNodeIterator* getIterator();
|
||||
|
||||
/// Print the report of the profiler in a given output stream
|
||||
void printReport(std::ostream& outputStream);
|
||||
// Add a file destination to the profiler
|
||||
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
|
||||
|
@ -287,7 +382,7 @@ class ProfileSample {
|
|||
};
|
||||
|
||||
// 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
|
||||
inline bool ProfileNodeIterator::isRoot() {
|
||||
|
@ -374,19 +469,9 @@ inline uint Profiler::getNbFrames() {
|
|||
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
|
||||
inline long double Profiler::getElapsedTimeSinceStart() {
|
||||
long double currentTime = Timer::getCurrentSystemTime() * 1000.0;
|
||||
long double currentTime = Timer::getCurrentSystemTime() * 1000.0L;
|
||||
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
|
||||
#define PROFILE(name, profiler)
|
||||
#define RP3D_PROFILE(name, profiler)
|
||||
|
||||
#endif
|
||||
|
|
@ -639,7 +639,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point(3, 0, 0);
|
||||
|
@ -663,7 +663,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -684,7 +684,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -705,7 +705,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -759,7 +759,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point(3, 0, 0);
|
||||
|
@ -783,7 +783,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -804,7 +804,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -825,7 +825,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -869,7 +869,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
localBody1Point = std::sqrt(4.5f) * Vector3(1, -1, 0);
|
||||
|
@ -893,7 +893,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -914,7 +914,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -935,7 +935,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -979,7 +979,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
localBody1Point = std::sqrt(9.0f / 3.0f) * Vector3(1, -1, -1);
|
||||
|
@ -1003,7 +1003,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1024,7 +1024,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1045,7 +1045,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1099,7 +1099,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point(0, -3, 0);
|
||||
|
@ -1123,7 +1123,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1144,7 +1144,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1165,7 +1165,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1209,7 +1209,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
localBody1Point = Vector3(3, 0, 0);
|
||||
|
@ -1233,7 +1233,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1254,7 +1254,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1275,7 +1275,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1329,7 +1329,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point(3, 0, 0);
|
||||
|
@ -1353,7 +1353,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1374,7 +1374,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1395,7 +1395,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1439,7 +1439,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
localBody1Point = std::sqrt(4.5f) * Vector3(1, -1, 0);
|
||||
|
@ -1463,7 +1463,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1484,7 +1484,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1505,7 +1505,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1549,7 +1549,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
localBody1Point = std::sqrt(9.0f / 3.0f) * Vector3(1, -1, -1);
|
||||
|
@ -1573,7 +1573,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1594,7 +1594,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1615,7 +1615,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1669,7 +1669,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point(0, -3, 0);
|
||||
|
@ -1693,7 +1693,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1714,7 +1714,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1735,7 +1735,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -1789,7 +1789,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point1(-3, -2, -2);
|
||||
|
@ -1831,7 +1831,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -1860,7 +1860,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -1890,7 +1890,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -1953,7 +1953,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point1(-3, -2, -2);
|
||||
|
@ -1995,7 +1995,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2024,7 +2024,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2054,7 +2054,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2117,7 +2117,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point1(-3, -2, -2);
|
||||
|
@ -2159,7 +2159,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2188,7 +2188,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2218,7 +2218,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2281,7 +2281,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point1(3, 1, 0);
|
||||
|
@ -2304,7 +2304,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2325,7 +2325,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2346,7 +2346,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2400,7 +2400,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point1(3, 1, 0);
|
||||
|
@ -2423,7 +2423,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2444,7 +2444,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2465,7 +2465,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point1 : localBody1Point1,
|
||||
|
@ -2519,7 +2519,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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++) {
|
||||
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
|
||||
|
@ -2539,7 +2539,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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++) {
|
||||
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
|
||||
|
@ -2559,7 +2559,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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++) {
|
||||
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
|
||||
|
@ -2579,7 +2579,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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
|
||||
for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) {
|
||||
|
@ -2633,7 +2633,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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++) {
|
||||
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
|
||||
|
@ -2653,7 +2653,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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++) {
|
||||
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
|
||||
|
@ -2673,7 +2673,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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++) {
|
||||
test(approxEqual(collisionData->contactManifolds[0].contactPoints[i].penetrationDepth, 1.0f));
|
||||
|
@ -2693,7 +2693,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 4);
|
||||
|
||||
// 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
|
||||
for (int i=0; i<collisionData->contactManifolds[0].contactPoints.size(); i++) {
|
||||
|
@ -2747,7 +2747,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point(2, 3, 0);
|
||||
|
@ -2771,7 +2771,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -2792,7 +2792,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -2813,7 +2813,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -2857,7 +2857,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
localBody1Point = Vector3(0, 5, 0);
|
||||
|
@ -2881,7 +2881,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -2902,7 +2902,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -2923,7 +2923,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -2977,7 +2977,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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
|
||||
Vector3 localBody1Point(0, -5, 0);
|
||||
|
@ -3001,7 +3001,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -3022,7 +3022,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
@ -3043,7 +3043,7 @@ class TestCollisionWorld : public Test {
|
|||
test(collisionData->getTotalNbContactPoints() == 1);
|
||||
|
||||
// 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(collisionData->hasContactPointSimilarTo(swappedBodiesCollisionData ? localBody2Point : localBody1Point,
|
||||
|
|
|
@ -63,7 +63,7 @@ class WorldRaycastCallback : public RaycastCallback {
|
|||
|
||||
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.hitFraction = info.hitFraction;
|
||||
raycastInfo.proxyShape = info.proxyShape;
|
||||
|
@ -1310,7 +1310,6 @@ class TestRaycast : public Test {
|
|||
// CollisionWorld::raycast()
|
||||
mCallback.reset();
|
||||
mWorld->raycast(ray, &mCallback);
|
||||
Vector3 localTest = inverse * mCallback.raycastInfo.worldPoint;
|
||||
test(mCallback.isHit);
|
||||
test(mCallback.raycastInfo.body == mConvexMeshBody);
|
||||
test(mCallback.raycastInfo.proxyShape == mConvexMeshProxyShape);
|
||||
|
|
|
@ -47,13 +47,7 @@ CollisionDetectionScene::CollisionDetectionScene(const std::string& name, Engine
|
|||
setScenePosition(center, SCENE_RADIUS);
|
||||
|
||||
// Create the dynamics world for the physics simulation
|
||||
mPhysicsWorld = new rp3d::CollisionWorld();
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
mPhysicsWorld->setProfilerName(name + "_profiler");
|
||||
|
||||
#endif
|
||||
mPhysicsWorld = new rp3d::CollisionWorld(name);
|
||||
|
||||
// ---------- Sphere 1 ---------- //
|
||||
|
||||
|
|
|
@ -46,14 +46,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name, EngineSettin
|
|||
rp3d::Vector3 gravity(0, -9.81f, 0);
|
||||
|
||||
// Create the dynamics world for the physics simulation
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity);
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
mPhysicsWorld->setProfilerName(name + "_profiler");
|
||||
|
||||
#endif
|
||||
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
|
||||
|
||||
for (int i=0; i<NB_COMPOUND_SHAPES; i++) {
|
||||
|
||||
|
|
|
@ -46,13 +46,7 @@ ConcaveMeshScene::ConcaveMeshScene(const std::string& name, EngineSettings& sett
|
|||
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
|
||||
|
||||
// Create the dynamics world for the physics simulation
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity);
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
mPhysicsWorld->setProfilerName(name + "_profiler");
|
||||
|
||||
#endif
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
|
||||
|
||||
// ---------- Create the boxes ----------- //
|
||||
for (int i = 0; i<NB_COMPOUND_SHAPES; i++) {
|
||||
|
|
|
@ -44,13 +44,7 @@ CubesScene::CubesScene(const std::string& name, EngineSettings& settings)
|
|||
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
|
||||
|
||||
// Create the dynamics world for the physics simulation
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity);
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
mPhysicsWorld->setProfilerName(name + "_profiler");
|
||||
|
||||
#endif
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
|
||||
|
||||
// Create all the cubes of the scene
|
||||
for (int i=0; i<NB_CUBES; i++) {
|
||||
|
|
|
@ -44,13 +44,7 @@ CubeStackScene::CubeStackScene(const std::string& name, EngineSettings& settings
|
|||
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
|
||||
|
||||
// Create the dynamics world for the physics simulation
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity);
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
mPhysicsWorld->setProfilerName(name + "_profiler");
|
||||
|
||||
#endif
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
|
||||
|
||||
// Create all the cubes of the scene
|
||||
for (int i=1; i<=NB_FLOORS; i++) {
|
||||
|
|
|
@ -46,14 +46,7 @@ HeightFieldScene::HeightFieldScene(const std::string& name, EngineSettings& sett
|
|||
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
|
||||
|
||||
// Create the dynamics world for the physics simulation
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity);
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
mPhysicsWorld->setProfilerName(name + "_profiler");
|
||||
|
||||
#endif
|
||||
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
|
||||
|
||||
for (int i = 0; i<NB_COMPOUND_SHAPES; i++) {
|
||||
|
||||
|
|
|
@ -45,13 +45,7 @@ JointsScene::JointsScene(const std::string& name, EngineSettings& settings)
|
|||
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
|
||||
|
||||
// Create the dynamics world for the physics simulation
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity);
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
mPhysicsWorld->setProfilerName(name + "_profiler");
|
||||
|
||||
#endif
|
||||
mPhysicsWorld = new rp3d::DynamicsWorld(gravity, name);
|
||||
|
||||
// Create the Ball-and-Socket joint
|
||||
createBallAndSocketJoints();
|
||||
|
|
|
@ -45,13 +45,7 @@ RaycastScene::RaycastScene(const std::string& name, EngineSettings& settings)
|
|||
setScenePosition(center, SCENE_RADIUS);
|
||||
|
||||
// Create the dynamics world for the physics simulation
|
||||
mPhysicsWorld = new rp3d::CollisionWorld();
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
mPhysicsWorld->setProfilerName(name + "_profiler");
|
||||
|
||||
#endif
|
||||
mPhysicsWorld = new rp3d::CollisionWorld(name);
|
||||
|
||||
// ---------- Dumbbell ---------- //
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user