Rename PI constant
This commit is contained in:
parent
9fb1e39798
commit
fc5ccdbe4d
|
@ -192,7 +192,7 @@ inline void CapsuleShape::getLocalBounds(Vector3& min, Vector3& max) const {
|
||||||
|
|
||||||
// Compute and return the volume of the collision shape
|
// Compute and return the volume of the collision shape
|
||||||
inline decimal CapsuleShape::getVolume() const {
|
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
|
// Return true if the collision shape is a polyhedron
|
||||||
|
|
|
@ -181,7 +181,7 @@ inline Vector3 SphereShape::getLocalInertiaTensor(decimal mass) const {
|
||||||
|
|
||||||
// Compute and return the volume of the collision shape
|
// Compute and return the volume of the collision shape
|
||||||
inline decimal SphereShape::getVolume() const {
|
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
|
// Return true if a point is inside the collision shape
|
||||||
|
|
|
@ -93,7 +93,7 @@ const decimal DECIMAL_LARGEST = std::numeric_limits<decimal>::max();
|
||||||
const decimal MACHINE_EPSILON = std::numeric_limits<decimal>::epsilon();
|
const decimal MACHINE_EPSILON = std::numeric_limits<decimal>::epsilon();
|
||||||
|
|
||||||
/// Pi constant
|
/// Pi constant
|
||||||
constexpr decimal PI = decimal(3.14159265);
|
constexpr decimal PI_RP3D = decimal(3.141592653589);
|
||||||
|
|
||||||
/// 2*Pi constant
|
/// 2*Pi constant
|
||||||
constexpr decimal PI_TIMES_2 = decimal(6.28318530);
|
constexpr decimal PI_TIMES_2 = decimal(6.28318530);
|
||||||
|
|
|
@ -138,7 +138,7 @@ class PhysicsWorld {
|
||||||
defaultPositionSolverNbIterations = 5;
|
defaultPositionSolverNbIterations = 5;
|
||||||
defaultTimeBeforeSleep = 1.0f;
|
defaultTimeBeforeSleep = 1.0f;
|
||||||
defaultSleepLinearVelocity = decimal(0.02);
|
defaultSleepLinearVelocity = decimal(0.02);
|
||||||
defaultSleepAngularVelocity = decimal(3.0) * (PI / decimal(180.0));
|
defaultSleepAngularVelocity = decimal(3.0) * (PI_RP3D / decimal(180.0));
|
||||||
nbMaxContactManifolds = 3;
|
nbMaxContactManifolds = 3;
|
||||||
cosAngleSimilarContactManifold = decimal(0.95);
|
cosAngleSimilarContactManifold = decimal(0.95);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,8 @@ HingeJoint::HingeJoint(Entity entity, PhysicsWorld &world, const HingeJointInfo&
|
||||||
|
|
||||||
const decimal lowerLimit = mWorld.mHingeJointsComponents.getLowerLimit(mEntity);
|
const decimal lowerLimit = mWorld.mHingeJointsComponents.getLowerLimit(mEntity);
|
||||||
const decimal upperLimit = mWorld.mHingeJointsComponents.getUpperLimit(mEntity);
|
const decimal upperLimit = mWorld.mHingeJointsComponents.getUpperLimit(mEntity);
|
||||||
assert(lowerLimit <= decimal(0) && lowerLimit >= decimal(-2.0) * PI);
|
assert(lowerLimit <= decimal(0) && lowerLimit >= decimal(-2.0) * PI_RP3D);
|
||||||
assert(upperLimit >= decimal(0) && upperLimit <= decimal(2.0) * PI);
|
assert(upperLimit >= decimal(0) && upperLimit <= decimal(2.0) * PI_RP3D);
|
||||||
|
|
||||||
mWorld.mHingeJointsComponents.setLocalAnchorPointBody1(mEntity, anchorPointBody1Local);
|
mWorld.mHingeJointsComponents.setLocalAnchorPointBody1(mEntity, anchorPointBody1Local);
|
||||||
mWorld.mHingeJointsComponents.setLocalAnchorPointBody2(mEntity, anchorPointBody2Local);
|
mWorld.mHingeJointsComponents.setLocalAnchorPointBody2(mEntity, anchorPointBody2Local);
|
||||||
|
@ -120,7 +120,7 @@ void HingeJoint::setMinAngleLimit(decimal lowerLimit) {
|
||||||
|
|
||||||
const decimal limit = mWorld.mHingeJointsComponents.getLowerLimit(mEntity);
|
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) {
|
if (lowerLimit != limit) {
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ void HingeJoint::setMaxAngleLimit(decimal upperLimit) {
|
||||||
|
|
||||||
const decimal limit = mWorld.mHingeJointsComponents.getUpperLimit(mEntity);
|
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) {
|
if (upperLimit != limit) {
|
||||||
|
|
||||||
|
|
|
@ -828,10 +828,10 @@ decimal SolveHingeJointSystem::computeNormalizedAngle(decimal angle) const {
|
||||||
angle = std::fmod(angle, PI_TIMES_2);
|
angle = std::fmod(angle, PI_TIMES_2);
|
||||||
|
|
||||||
// Convert it into the range [-pi; pi]
|
// Convert it into the range [-pi; pi]
|
||||||
if (angle < -PI) {
|
if (angle < -PI_RP3D) {
|
||||||
return angle + PI_TIMES_2;
|
return angle + PI_TIMES_2;
|
||||||
}
|
}
|
||||||
else if (angle > PI) {
|
else if (angle > PI_RP3D) {
|
||||||
return angle - PI_TIMES_2;
|
return angle - PI_TIMES_2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -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)];
|
Vector3 vertices[(NB_SECTORS_SPHERE + 1) * (NB_STACKS_SPHERE + 1) + (NB_SECTORS_SPHERE + 1)];
|
||||||
|
|
||||||
// Vertices
|
// Vertices
|
||||||
const decimal sectorStep = 2 * PI / NB_SECTORS_SPHERE;
|
const decimal sectorStep = 2 * PI_RP3D / NB_SECTORS_SPHERE;
|
||||||
const decimal stackStep = PI / NB_STACKS_SPHERE;
|
const decimal stackStep = PI_RP3D / NB_STACKS_SPHERE;
|
||||||
|
|
||||||
for (uint i = 0; i <= NB_STACKS_SPHERE; i++) {
|
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 radiusCosStackAngle = radius * std::cos(stackAngle);
|
||||||
const decimal z = radius * std::sin(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;
|
const uint nbHalfStacks = nbStacks / 2;
|
||||||
|
|
||||||
// Vertices
|
// Vertices
|
||||||
const decimal sectorStep = 2 * PI / NB_SECTORS_SPHERE;
|
const decimal sectorStep = 2 * PI_RP3D / NB_SECTORS_SPHERE;
|
||||||
const decimal stackStep = PI / nbStacks;
|
const decimal stackStep = PI_RP3D / nbStacks;
|
||||||
|
|
||||||
uint vertexIndex = 0;
|
uint vertexIndex = 0;
|
||||||
|
|
||||||
// Top cap sphere vertices
|
// Top cap sphere vertices
|
||||||
for (uint i = 0; i <= nbHalfStacks; i++) {
|
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 radiusCosStackAngle = radius * std::cos(stackAngle);
|
||||||
const decimal y = radius * std::sin(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
|
// Bottom cap sphere vertices
|
||||||
for (uint i = 0; i <= nbHalfStacks; i++) {
|
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 radiusCosStackAngle = radius * std::cos(stackAngle);
|
||||||
const decimal y = radius * std::sin(stackAngle);
|
const decimal y = radius * std::sin(stackAngle);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user