diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-11-30 11:19:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-30 11:19:26 +0100 |
commit | cde6775e1197e67242c143b7885703a196e31cb2 (patch) | |
tree | 73c13986fcab55a18eefa2e3e3b6f2364a3d9425 | |
parent | 52e3944846f7f21d87795bae59b2ef1d27a1f062 (diff) | |
parent | 7e6fa6c7a808840243637dc4b07947a93beb88c5 (diff) |
Merge pull request #34012 from KoBeWi/useless
Remove unnecessary bounded_offset from PathFollow2D
-rw-r--r-- | scene/2d/path_2d.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 55c8c7f229..18ace5892a 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -173,16 +173,10 @@ void PathFollow2D::_update_transform() { if (path_length == 0) { return; } - float bounded_offset = offset; - if (loop) - bounded_offset = Math::fposmod(bounded_offset, path_length); - else - bounded_offset = CLAMP(bounded_offset, 0, path_length); - - Vector2 pos = c->interpolate_baked(bounded_offset, cubic); + Vector2 pos = c->interpolate_baked(offset, cubic); if (rotate) { - float ahead = bounded_offset + lookahead; + float ahead = offset + lookahead; if (loop && ahead >= path_length) { // If our lookahead will loop, we need to check if the path is closed. @@ -206,7 +200,7 @@ void PathFollow2D::_update_transform() { // This will happen at the end of non-looping or non-closed paths. // We'll try a look behind instead, in order to get a meaningful angle. tangent_to_curve = - (pos - c->interpolate_baked(bounded_offset - lookahead, cubic)).normalized(); + (pos - c->interpolate_baked(offset - lookahead, cubic)).normalized(); } else { tangent_to_curve = (ahead_pos - pos).normalized(); } |