add more Curve adaptors#14794
add more Curve adaptors#14794alice-i-cecile merged 15 commits intobevyengine:mainfrom JasmineLowen:more-curve-adaptors
Curve adaptors#14794Conversation
|
I'm not surve about ping pong adaptors as that's basically just a combination of what we already have: Chain the curve with it's inverse. |
|
Could the ping-pong adapter work as an example for how to make your own? |
|
I could see ping-pong being useful if it also did the repeating. So it would for example produce a triangle-wave from a line segment. |
|
Tbh I think it's worth having a separate adaptor for ping pong after all. The issue with the "combining existing adaptors" is that it is kind of restricting since it's only possible to do this with |
This is what I was imagining, yeah. |
mweatherley
left a comment
There was a problem hiding this comment.
I'll give this another look once the reversing issues are addressed. :)
RepeatCurve and ReverseCurve Curve adaptorsCurve adaptors
mweatherley
left a comment
There was a problem hiding this comment.
Just a few more small things. Looks great otherwise!
|
@RobWalt merging once merge conflicts are resolved :) |
Ahhhh, thanks for the ping! Would've missed that for another few days probably 🙈 |
Co-authored-by: eckz <567737+eckz@users.noreply.github.com>
Co-authored-by: Matty <2975848+mweatherley@users.noreply.github.com>
Co-authored-by: IQuick 143 <IQuick143cz@gmail.com>
Thanks for the continued support and reviews! Co-authored-by: Matty <weatherleymatthew@gmail.com>
|
New lints are failing now :) |
|
If you have time to format this in the next 15 hours or so that would be appreciated, otherwise I'll do it during my merge train. |
# Objective This implements another item on the way to complete the `Curves` implementation initiative Citing @mweatherley > Curve adaptors for making a curve repeat or ping-pong would be useful. This adds three widely applicable adaptors: - `ReverseCurve` "plays" the curve backwards - `RepeatCurve` to repeat the curve for `n` times where `n` in `[0,inf)` - `ForeverCurve` which extends the curves domain to `EVERYWHERE` - `PingPongCurve` (name wip (?)) to chain the curve with it's reverse. This would be achievable with `ReverseCurve` and `ChainCurve`, but it would require the use of `by_ref` which can be restrictive in some scenarios where you'd rather just consume the curve. Users can still create the same effect by combination of the former two, but since this will be most likely a very typical adaptor we should also provide it on the library level. (Why it's typical: you can create a single period of common waves with it pretty easily, think square wave (= pingpong + step), triangle wave ( = pingpong + linear), etc.) - `ContinuationCurve` which chains two curves but also makes sure that the samples of the second curve are translated so that `sample(first.end) == sample(second.start)` ## Solution Implement the adaptors above. (More suggestions are welcome!) ## Testing - [x] add simple tests. One per adaptor --------- Co-authored-by: eckz <567737+eckz@users.noreply.github.com> Co-authored-by: Matty <2975848+mweatherley@users.noreply.github.com> Co-authored-by: IQuick 143 <IQuick143cz@gmail.com> Co-authored-by: Matty <weatherleymatthew@gmail.com> Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Objective
This implements another item on the way to complete the
Curvesimplementation initiativeCiting @mweatherley
This adds three widely applicable adaptors:
ReverseCurve"plays" the curve backwardsRepeatCurveto repeat the curve forntimes wherenin[0,inf)ForeverCurvewhich extends the curves domain toEVERYWHEREPingPongCurve(name wip (?)) to chain the curve with it's reverse. This would be achievable withReverseCurveandChainCurve, but it would require the use ofby_refwhich can be restrictive in some scenarios where you'd rather just consume the curve. Users can still create the same effect by combination of the former two, but since this will be most likely a very typical adaptor we should also provide it on the library level. (Why it's typical: you can create a single period of common waves with it pretty easily, think square wave (= pingpong + step), triangle wave ( = pingpong + linear), etc.)ContinuationCurvewhich chains two curves but also makes sure that the samples of the second curve are translated so thatsample(first.end) == sample(second.start)Solution
Implement the adaptors above. (More suggestions are welcome!)
Testing