summaryrefslogtreecommitdiffhomepage
path: root/editor/tests
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-23 05:35:47 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-23 07:42:29 +0100
commit0ce0318162da4e36a232ab465f66f20dc4e55288 (patch)
treebb95c81a16786ac0c50e7ee1d3b5310aae7f20f5 /editor/tests
parent0cd4975e059cd822fa0cb63203844156df7bf6b7 (diff)
w
Diffstat (limited to 'editor/tests')
-rw-r--r--editor/tests/pathfinding.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/editor/tests/pathfinding.cpp b/editor/tests/pathfinding.cpp
index 3e77cdcf..cba3f405 100644
--- a/editor/tests/pathfinding.cpp
+++ b/editor/tests/pathfinding.cpp
@@ -182,17 +182,19 @@ void pf_test::update_pre(app& a, const Ns& dt)
}
fm_assert(step.count > 0);
using Frac = decltype(critter::offset_frac)::Type;
- constexpr auto inv_frac = 1.f / float{limits<Frac>::max};
+ constexpr auto frac = limits<Frac>::max;
+ constexpr auto inv_frac = 1.f / float{frac};
const auto mag = step_magnitude(step.direction);
const auto vec = Vector2(step.direction) * mag;
const auto sign_vec = Math::sign(vec);
- const auto frac = Vector2(C.offset_frac) * sign_vec * inv_frac;
- auto offsetʹ = vec + frac;
- auto off_i = Vector2i(offsetʹ);
- Debug{} << "vec" << vec << "mag" << mag << "frac" << frac;
+ auto offset_ = vec + Vector2(C.offset_frac) * sign_vec * inv_frac;
+ auto off_i = Vector2i(offset_);
+ Debug{} << "vec" << vec << "mag" << mag << "off_i" << off_i << "offset_" << Vector2(C.offset_frac) * sign_vec * inv_frac;
if (!off_i.isZero())
{
+ C.offset_frac = Vector2us(Math::abs(Math::fmod(offset_, 1.f)) * frac);
+
if (C.can_move_to(off_i))
C.move_to(index, off_i, C.r);
else
@@ -202,7 +204,7 @@ void pf_test::update_pre(app& a, const Ns& dt)
}
}
else
- C.offset_frac = Vector2us(Math::min({1.f,1.f}, Math::abs(offsetʹ)) * frac);
+ C.offset_frac = Vector2us(Math::min({1.f,1.f}, Math::abs(offset_)) * frac);
}
if (!ok) [[unlikely]]