diff --git a/include/reactphysics3d/collision/shapes/CapsuleShape.h b/include/reactphysics3d/collision/shapes/CapsuleShape.h index c42619e3..b9cfbc63 100644 --- a/include/reactphysics3d/collision/shapes/CapsuleShape.h +++ b/include/reactphysics3d/collision/shapes/CapsuleShape.h @@ -192,7 +192,7 @@ inline void CapsuleShape::getLocalBounds(Vector3& min, Vector3& max) const { // Compute and return the volume of the collision shape inline decimal CapsuleShape::getVolume() const { - return reactphysics3d::PI * mMargin * mMargin * (decimal(4.0) * mMargin / decimal(3.0) + decimal(2.0) * mHalfHeight); + return reactphysics3d::PI_RP3D * mMargin * mMargin * (decimal(4.0) * mMargin / decimal(3.0) + decimal(2.0) * mHalfHeight); } // Return true if the collision shape is a polyhedron diff --git a/include/reactphysics3d/collision/shapes/SphereShape.h b/include/reactphysics3d/collision/shapes/SphereShape.h index cba750fd..97126eec 100644 --- a/include/reactphysics3d/collision/shapes/SphereShape.h +++ b/include/reactphysics3d/collision/shapes/SphereShape.h @@ -181,7 +181,7 @@ inline Vector3 SphereShape::getLocalInertiaTensor(decimal mass) const { // Compute and return the volume of the collision shape inline decimal SphereShape::getVolume() const { - return decimal(4.0) / decimal(3.0) * reactphysics3d::PI * mMargin * mMargin * mMargin; + return decimal(4.0) / decimal(3.0) * reactphysics3d::PI_RP3D * mMargin * mMargin * mMargin; } // Return true if a point is inside the collision shape diff --git a/include/reactphysics3d/configuration.h b/include/reactphysics3d/configuration.h index 8dc3bd90..6283a488 100644 --- a/include/reactphysics3d/configuration.h +++ b/include/reactphysics3d/configuration.h @@ -93,7 +93,7 @@ const decimal DECIMAL_LARGEST = std::numeric_limits::max(); const decimal MACHINE_EPSILON = std::numeric_limits::epsilon(); /// Pi constant -constexpr decimal PI = decimal(3.14159265); +constexpr decimal PI_RP3D = decimal(3.141592653589); /// 2*Pi constant constexpr decimal PI_TIMES_2 = decimal(6.28318530); diff --git a/include/reactphysics3d/engine/PhysicsWorld.h b/include/reactphysics3d/engine/PhysicsWorld.h index 065f2a66..0d564bd7 100644 --- a/include/reactphysics3d/engine/PhysicsWorld.h +++ b/include/reactphysics3d/engine/PhysicsWorld.h @@ -138,7 +138,7 @@ class PhysicsWorld { defaultPositionSolverNbIterations = 5; defaultTimeBeforeSleep = 1.0f; defaultSleepLinearVelocity = decimal(0.02); - defaultSleepAngularVelocity = decimal(3.0) * (PI / decimal(180.0)); + defaultSleepAngularVelocity = decimal(3.0) * (PI_RP3D / decimal(180.0)); nbMaxContactManifolds = 3; cosAngleSimilarContactManifold = decimal(0.95); } diff --git a/src/constraint/HingeJoint.cpp b/src/constraint/HingeJoint.cpp index 624ed373..fbebd900 100644 --- a/src/constraint/HingeJoint.cpp +++ b/src/constraint/HingeJoint.cpp @@ -65,8 +65,8 @@ HingeJoint::HingeJoint(Entity entity, PhysicsWorld &world, const HingeJointInfo& const decimal lowerLimit = mWorld.mHingeJointsComponents.getLowerLimit(mEntity); const decimal upperLimit = mWorld.mHingeJointsComponents.getUpperLimit(mEntity); - assert(lowerLimit <= decimal(0) && lowerLimit >= decimal(-2.0) * PI); - assert(upperLimit >= decimal(0) && upperLimit <= decimal(2.0) * PI); + assert(lowerLimit <= decimal(0) && lowerLimit >= decimal(-2.0) * PI_RP3D); + assert(upperLimit >= decimal(0) && upperLimit <= decimal(2.0) * PI_RP3D); mWorld.mHingeJointsComponents.setLocalAnchorPointBody1(mEntity, anchorPointBody1Local); mWorld.mHingeJointsComponents.setLocalAnchorPointBody2(mEntity, anchorPointBody2Local); @@ -120,7 +120,7 @@ void HingeJoint::setMinAngleLimit(decimal lowerLimit) { const decimal limit = mWorld.mHingeJointsComponents.getLowerLimit(mEntity); - assert(limit <= decimal(0.0) && limit >= decimal(-2.0) * PI); + assert(limit <= decimal(0.0) && limit >= decimal(-2.0) * PI_RP3D); if (lowerLimit != limit) { @@ -139,7 +139,7 @@ void HingeJoint::setMaxAngleLimit(decimal upperLimit) { const decimal limit = mWorld.mHingeJointsComponents.getUpperLimit(mEntity); - assert(limit >= decimal(0) && limit <= decimal(2.0) * PI); + assert(limit >= decimal(0) && limit <= decimal(2.0) * PI_RP3D); if (upperLimit != limit) { diff --git a/src/systems/SolveHingeJointSystem.cpp b/src/systems/SolveHingeJointSystem.cpp index cd89b3fa..a1582750 100644 --- a/src/systems/SolveHingeJointSystem.cpp +++ b/src/systems/SolveHingeJointSystem.cpp @@ -828,10 +828,10 @@ decimal SolveHingeJointSystem::computeNormalizedAngle(decimal angle) const { angle = std::fmod(angle, PI_TIMES_2); // Convert it into the range [-pi; pi] - if (angle < -PI) { + if (angle < -PI_RP3D) { return angle + PI_TIMES_2; } - else if (angle > PI) { + else if (angle > PI_RP3D) { return angle - PI_TIMES_2; } else { diff --git a/src/utils/DebugRenderer.cpp b/src/utils/DebugRenderer.cpp index e403253b..845fd8b3 100644 --- a/src/utils/DebugRenderer.cpp +++ b/src/utils/DebugRenderer.cpp @@ -124,12 +124,12 @@ void DebugRenderer::drawSphere(const Vector3& position, decimal radius, uint32 c Vector3 vertices[(NB_SECTORS_SPHERE + 1) * (NB_STACKS_SPHERE + 1) + (NB_SECTORS_SPHERE + 1)]; // Vertices - const decimal sectorStep = 2 * PI / NB_SECTORS_SPHERE; - const decimal stackStep = PI / NB_STACKS_SPHERE; + const decimal sectorStep = 2 * PI_RP3D / NB_SECTORS_SPHERE; + const decimal stackStep = PI_RP3D / NB_STACKS_SPHERE; for (uint i = 0; i <= NB_STACKS_SPHERE; i++) { - const decimal stackAngle = PI / 2 - i * stackStep; + const decimal stackAngle = PI_RP3D / 2 - i * stackStep; const decimal radiusCosStackAngle = radius * std::cos(stackAngle); const decimal z = radius * std::sin(stackAngle); @@ -178,15 +178,15 @@ void DebugRenderer::drawCapsule(const Transform& transform, decimal radius, deci const uint nbHalfStacks = nbStacks / 2; // Vertices - const decimal sectorStep = 2 * PI / NB_SECTORS_SPHERE; - const decimal stackStep = PI / nbStacks; + const decimal sectorStep = 2 * PI_RP3D / NB_SECTORS_SPHERE; + const decimal stackStep = PI_RP3D / nbStacks; uint vertexIndex = 0; // Top cap sphere vertices for (uint i = 0; i <= nbHalfStacks; i++) { - const decimal stackAngle = PI / 2 - i * stackStep; + const decimal stackAngle = PI_RP3D / 2 - i * stackStep; const decimal radiusCosStackAngle = radius * std::cos(stackAngle); const decimal y = radius * std::sin(stackAngle); @@ -206,7 +206,7 @@ void DebugRenderer::drawCapsule(const Transform& transform, decimal radius, deci // Bottom cap sphere vertices for (uint i = 0; i <= nbHalfStacks; i++) { - const decimal stackAngle = PI / 2 - (nbHalfStacks + i) * stackStep; + const decimal stackAngle = PI_RP3D / 2 - (nbHalfStacks + i) * stackStep; const decimal radiusCosStackAngle = radius * std::cos(stackAngle); const decimal y = radius * std::sin(stackAngle);