Remove unnecessary bounded_offset from PathFollow2D
This commit is contained in:
parent
1b40a95b6f
commit
7e6fa6c7a8
@ -173,16 +173,10 @@ void PathFollow2D::_update_transform() {
|
|||||||
if (path_length == 0) {
|
if (path_length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float bounded_offset = offset;
|
Vector2 pos = c->interpolate_baked(offset, cubic);
|
||||||
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);
|
|
||||||
|
|
||||||
if (rotate) {
|
if (rotate) {
|
||||||
float ahead = bounded_offset + lookahead;
|
float ahead = offset + lookahead;
|
||||||
|
|
||||||
if (loop && ahead >= path_length) {
|
if (loop && ahead >= path_length) {
|
||||||
// If our lookahead will loop, we need to check if the path is closed.
|
// 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.
|
// 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.
|
// We'll try a look behind instead, in order to get a meaningful angle.
|
||||||
tangent_to_curve =
|
tangent_to_curve =
|
||||||
(pos - c->interpolate_baked(bounded_offset - lookahead, cubic)).normalized();
|
(pos - c->interpolate_baked(offset - lookahead, cubic)).normalized();
|
||||||
} else {
|
} else {
|
||||||
tangent_to_curve = (ahead_pos - pos).normalized();
|
tangent_to_curve = (ahead_pos - pos).normalized();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user