Math: Replace M_PI defines with template constexpr constants
This commit is contained in:
@@ -73,7 +73,7 @@ namespace Nz
|
||||
Vector2f origin = FromChipmunk(pos);
|
||||
float r = static_cast<float>(radius);
|
||||
|
||||
RadianAnglef angleBetweenVertices = 2.f * float(M_PI) / vertices.size();
|
||||
RadianAnglef angleBetweenVertices = 2.f * Pi<float> / vertices.size();
|
||||
for (std::size_t i = 0; i < vertices.size(); ++i)
|
||||
{
|
||||
RadianAnglef angle = float(i) * angleBetweenVertices;
|
||||
|
||||
@@ -422,7 +422,7 @@ namespace Nz
|
||||
|
||||
Boxf SphereCollider3D::ComputeAABB(const Matrix4f& offsetMatrix, const Vector3f& scale) const
|
||||
{
|
||||
Vector3f size(m_radius * NazaraSuffixMacro(M_SQRT3, f) * scale);
|
||||
Vector3f size(m_radius * Sqrt5<float> * scale);
|
||||
Vector3f position(offsetMatrix.GetTranslation());
|
||||
|
||||
return Boxf(position - size, position + size);
|
||||
@@ -430,7 +430,7 @@ namespace Nz
|
||||
|
||||
float SphereCollider3D::ComputeVolume() const
|
||||
{
|
||||
return float(M_PI) * m_radius * m_radius * m_radius / 3.f;
|
||||
return Pi<float> * m_radius * m_radius * m_radius / 3.f;
|
||||
}
|
||||
|
||||
float SphereCollider3D::GetRadius() const
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -854,7 +854,7 @@ namespace Nz
|
||||
|
||||
void GenerateCone(float length, float radius, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, unsigned int indexOffset)
|
||||
{
|
||||
constexpr float round = 2.f*static_cast<float>(M_PI);
|
||||
constexpr float round = 2.f * Pi<float>;
|
||||
float delta = round/subdivision;
|
||||
|
||||
*vertexPointers.positionPtr++ = matrix.GetTranslation(); // matrix.Transform(Vector3f(0.f));
|
||||
@@ -997,23 +997,19 @@ namespace Nz
|
||||
float invSliceCount = 1.f / (sliceCount-1);
|
||||
float invStackCount = 1.f / (stackCount-1);
|
||||
|
||||
const float pi = static_cast<float>(M_PI); // Pour éviter toute promotion en double
|
||||
const float pi2 = pi * 2.f;
|
||||
const float pi_2 = pi / 2.f;
|
||||
|
||||
for (unsigned int stack = 0; stack < stackCount; ++stack)
|
||||
{
|
||||
float stackVal = stack * invStackCount;
|
||||
float stackValPi = stackVal * pi;
|
||||
float stackValPi = stackVal * Pi<float>;
|
||||
float sinStackValPi = std::sin(stackValPi);
|
||||
|
||||
for (unsigned int slice = 0; slice < sliceCount; ++slice)
|
||||
{
|
||||
float sliceVal = slice * invSliceCount;
|
||||
float sliceValPi2 = sliceVal * pi2;
|
||||
float sliceValPi2 = sliceVal * 2.f * Pi<float>;
|
||||
|
||||
Vector3f normal;
|
||||
normal.y = std::sin(-pi_2 + stackValPi);
|
||||
normal.y = std::sin(-HalfPi<float> + stackValPi);
|
||||
normal.x = std::cos(sliceValPi2) * sinStackValPi;
|
||||
normal.z = std::sin(sliceValPi2) * sinStackValPi;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user