summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikola Bunjevac <nikola.bunjevac@gmail.com>2022-10-06 00:27:46 +0200
committerNikola Bunjevac <nikola.bunjevac@gmail.com>2022-10-06 00:27:46 +0200
commite903362269a3b05e1bef94ee91d615d6e928fa02 (patch)
treea7df1389814cb5bf71fd108168ab9e5e78935acf
parentea9bb98f26be8212245f6ff796617901a8b9f3f6 (diff)
Handle last baked vector index early
-rw-r--r--scene/resources/curve.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index 0ea5264935..49b78a091d 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -1667,6 +1667,10 @@ Vector3 Curve3D::sample_baked_up_vector(real_t p_offset, bool p_apply_tilt) cons
idx = (end + start) / 2;
}
+ if (idx == count - 1) {
+ return p_apply_tilt ? r[idx].rotated((rp[idx] - rp[idx - 1]).normalized(), rt[idx]) : r[idx];
+ }
+
real_t offset_begin = baked_dist_cache[idx];
real_t offset_end = baked_dist_cache[idx + 1];
@@ -1675,10 +1679,6 @@ Vector3 Curve3D::sample_baked_up_vector(real_t p_offset, bool p_apply_tilt) cons
real_t frac = (p_offset - offset_begin) / idx_interval;
- if (idx == count - 1) {
- return p_apply_tilt ? r[idx].rotated((rp[idx] - rp[idx - 1]).normalized(), rt[idx]) : r[idx];
- }
-
Vector3 forward = (rp[idx + 1] - rp[idx]).normalized();
Vector3 up = r[idx];
Vector3 up1 = r[idx + 1];