CubicSegment
lacks functionality of CubicCurve
#17642
Labels
A-Math
Fundamental domain-agnostic mathematical operations
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
D-Modest
A "normal" level of difficulty; suitable for simple features or challenging fixes
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
X-Uncontroversial
This work is generally agreed upon
What problem does this solve or what need does it fill?
CubicCurve
, which is aVec<CubicSegment>
, can be used in many ways, e.g. creating roads and paths.However, in many cases
CubicSegment
is very useful by itself. For example, I want to check if my entity will not collide with anything, while following a curved path. But the check is still local enough, so I don't need the wholeCubicCurve
Performance considerations.
CubicCurve
contains aVec
, which is heap allocated. It is expensive, if spawned every frame for many entities.CubicSegment
, on the other hand, is fixed size, which is ideal for such scenario.However, the implementation of
CubicSegment::new_bezier
includes creating aCubicCurve
of size 1, only to take the first element later. It is still an allocation, and in this case, an unnecessary one.What solution would you like?
CubicSegment
from 4 control points, not just 2. Right now it seems like it is just intended for animation easing purposes.CubicSegment::iter_positions
and other cool functions thatCubicCurve
hasWhat alternative(s) have you considered?
I implemented my own hacky trait to have this functionality:
It does the thing without memory allocations. But has some duplicated code.
Example usage:
Additional context
Looking at code, looks like
CubicSegment
is being sort of ignored in favor of theCubicCurve
. I think many functions like thenew_bezier
andnew_bezier_4
should really be implemented on the base structure.The text was updated successfully, but these errors were encountered: