aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-12-11 13:18:59 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-12-11 13:18:59 +0100
commit405bf73b273c7b9a6574d77b4a034d9588c9af1b (patch)
tree4f25ed279519c47d665bcaaaa399962c4fbd7408 /src/crepe/api
parent543dc375228b520605bb099bc95a23918f75e9f8 (diff)
Removed magic numbers
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/AI.cpp16
-rw-r--r--src/crepe/api/AI.h3
2 files changed, 11 insertions, 8 deletions
diff --git a/src/crepe/api/AI.cpp b/src/crepe/api/AI.cpp
index 472550b..34e1438 100644
--- a/src/crepe/api/AI.cpp
+++ b/src/crepe/api/AI.cpp
@@ -13,10 +13,10 @@ void AI::make_circle_path(float radius, const vec2 & center, float start_angle,
}
// The step size is determined by the radius (step size is in radians)
- float step = 400.0f / radius;
- // Force at least 16 steps (in case of a small radius)
- if (step > 2 * M_PI / 16) {
- step = 2 * M_PI / 16;
+ float step = RADIUS_TO_STEP / radius;
+ // Force at least MIN_STEP steps (in case of a small radius)
+ if (step > 2 * M_PI / MIN_STEP) {
+ step = 2 * M_PI / MIN_STEP;
}
// The path node distance is determined by the step size and the radius
path_node_distance = radius * step * 0.75f;
@@ -42,10 +42,10 @@ void AI::make_oval_path(float radius_x, float radius_y, const vec2 & center, flo
float max_radius = std::max(radius_x, radius_y);
// The step size is determined by the radius (step size is in radians)
- float step = 400.0f / max_radius;
- // Force at least 16 steps (in case of a small radius)
- if (step > 2 * M_PI / 16) {
- step = 2 * M_PI / 16;
+ float step = RADIUS_TO_STEP / max_radius;
+ // Force at least MIN_STEP steps (in case of a small radius)
+ if (step > 2 * M_PI / MIN_STEP) {
+ step = 2 * M_PI / MIN_STEP;
}
// The path node distance is determined by the step size and the radius
path_node_distance = max_radius * step * 0.75f;
diff --git a/src/crepe/api/AI.h b/src/crepe/api/AI.h
index 80feda5..fc28451 100644
--- a/src/crepe/api/AI.h
+++ b/src/crepe/api/AI.h
@@ -116,6 +116,9 @@ private:
//! The AISystem is the only class that should access the flags and path_index variables
friend class AISystem;
+
+ static constexpr const int MIN_STEP = 16;
+ static constexpr const float RADIUS_TO_STEP = 400.0f;
};
} // namespace crepe