Rename PI constant

This commit is contained in:
Daniel Chappuis 2020-06-24 22:24:54 +02:00
parent 9fb1e39798
commit fc5ccdbe4d
7 changed files with 17 additions and 17 deletions

View File

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

View File

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

View File

@ -93,7 +93,7 @@ const decimal DECIMAL_LARGEST = std::numeric_limits<decimal>::max();
const decimal MACHINE_EPSILON = std::numeric_limits<decimal>::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);

View File

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

View File

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

View File

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

View File

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