Skip to content
This repository was archived by the owner on Jan 25, 2026. It is now read-only.

Commit 3433f73

Browse files
committed
Don't use M_PI
Explicitly creating our own pi and tau
1 parent 138d351 commit 3433f73

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/constants.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#include "asset/asset.hpp"
66

77
namespace constants {
8+
constexpr float PI = 3.14159265358979323846f;
9+
constexpr float TAU = 2 * PI;
10+
811
constexpr glm::vec3 WORLD_ORIGIN = glm::vec3(0.0f, 0.0f, 0.0f);
912

1013
// Coordinate system matching Unreal Engine

src/render/model/3d/sphere.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#include "sphere.hpp"
2+
23
#include <array>
34
#include <cmath>
45
#include <unordered_map>
56

7+
#include "constants.hpp"
8+
69
namespace {
710
// Hash function for glm::vec3 to use in unordered_map
811
struct Vec3Hash {
@@ -154,7 +157,7 @@ void model::Sphere::generateIcosphere(float radius, int subdivisions) {
154157
}
155158

156159
glm::vec2 model::Sphere::calculateSphericalUV(const glm::vec3& normal) {
157-
float u = 0.5f + std::atan2(normal.z, normal.x) / (2.0f * M_PI);
158-
float v = 0.5f - std::asin(normal.y) / M_PI;
160+
float u = 0.5f + std::atan2(normal.z, normal.x) / constants::TAU;
161+
float v = 0.5f - std::asin(normal.y) / constants::PI;
159162
return glm::vec2(u, v);
160163
}

0 commit comments

Comments
 (0)