Skip to content

Commit 9ab01f0

Browse files
committed
fix(nodes/field): proper spline
1 parent 4e7e34f commit 9ab01f0

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/nodes/fields.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,15 @@ impl CubicSplineShape {
528528
let r01 = (r0 + rmid) * 0.5;
529529
let r23 = (rmid + r3) * 0.5;
530530

531+
// Approximate each cubic half as a quadratic by averaging the two inner
532+
// control points (standard degree reduction). Using just p01 or p123 alone
533+
// drops too much curvature and displaces the tube surface.
534+
let left_mid_cp = p01.lerp(p012, 0.5);
535+
let right_mid_cp = p123.lerp(p23, 0.5);
536+
531537
(
532-
(p0, p01, mid, r0, r01, rmid),
533-
(mid, p123, p3, rmid, r23, r3),
538+
(p0, left_mid_cp, mid, r0, r01, rmid),
539+
(mid, right_mid_cp, p3, rmid, r23, r3),
534540
)
535541
}
536542

0 commit comments

Comments
 (0)