mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-22 09:07:17 +01:00
Fix wrapf
to correct wrap values with 0.1 stepping
(cherry picked from commit 09418afbc0b5a5642448786751b590352ee6cf97)
This commit is contained in:
parent
0609c362bc
commit
1a68039fcf
@ -313,11 +313,19 @@ public:
|
|||||||
}
|
}
|
||||||
static _ALWAYS_INLINE_ double wrapf(double value, double min, double max) {
|
static _ALWAYS_INLINE_ double wrapf(double value, double min, double max) {
|
||||||
double range = max - min;
|
double range = max - min;
|
||||||
return is_zero_approx(range) ? min : value - (range * Math::floor((value - min) / range));
|
double result = is_zero_approx(range) ? min : value - (range * Math::floor((value - min) / range));
|
||||||
|
if (is_equal_approx(result, max)) {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
static _ALWAYS_INLINE_ float wrapf(float value, float min, float max) {
|
static _ALWAYS_INLINE_ float wrapf(float value, float min, float max) {
|
||||||
float range = max - min;
|
float range = max - min;
|
||||||
return is_zero_approx(range) ? min : value - (range * Math::floor((value - min) / range));
|
float result = is_zero_approx(range) ? min : value - (range * Math::floor((value - min) / range));
|
||||||
|
if (is_equal_approx(result, max)) {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// double only, as these functions are mainly used by the editor and not performance-critical,
|
// double only, as these functions are mainly used by the editor and not performance-critical,
|
||||||
|
Loading…
Reference in New Issue
Block a user