bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.27k stars 3.58k forks source link

Sampling fixed distance segments of a curve #8493

Open JohnTheCoolingFan opened 1 year ago

JohnTheCoolingFan commented 1 year ago

What problem does this solve or what need does it fill?

Some curve types have a property that equally distanced interpolations are not resulting in equal length segments. But this is important when it's needed to move something along a curve at constant speed. For example, train along the tracks, or some animation.

What solution would you like?

Helper method on Cubic spline that returns points that are equally distanced from each other along the curve.

What alternative(s) have you considered?

There is a method (iter_sample) that accepts a arbitrary sampling function which might be used as described in this book about Bezier curves

superdump commented 1 year ago

This was something I wanted for following camera paths at constant velocity. Definitely a good thing to have, in my opinion.

mhatz-2 commented 1 week ago

I also need a way to follow a defined cubic curve at constant velocity. Maybe I missed something but it seems that it is still not possible in Bevy 0.14.2.