DarthSharkie / Apel-Mod

Apel is a library that brings particle animations to the table with flexible behaviour and a clean developer interface. It promises also lots of predefined shapes & paths to help the developer on their particle scene
Other
0 stars 0 forks source link

`BezierCurveAnimator` throws out of bounds exception when more curves than `renderingSteps` #44

Closed DarthSharkie closed 4 months ago

DarthSharkie commented 4 months ago

The constructor (below) creates an array for renderingSteps that is exactly one element regardless of the length of endpoints: https://github.com/DarthSharkie/Apel-Mod/blob/main/src/main/java/net/mcbrincie/apel/lib/animators/BezierCurveAnimator.java#L97-L113.

That leads to an AIOOBE here: https://github.com/DarthSharkie/Apel-Mod/blob/main/src/main/java/net/mcbrincie/apel/lib/animators/BezierCurveAnimator.java#L293-L295.

I think the problem is simply a poor constructor signature, but there's also an argument to be made that the Sequential Animator should be used instead of an array of Bézier curves.

DarthSharkie commented 4 months ago

This is going to be a problem for the similar constructor that has an array of curves but a single renderingInterval, too. Both of these are probably intended to re-use the steps/interval for each curve. (Again, solve this with the SequentialAnimator!)

DarthSharkie commented 4 months ago

The same thing happens for LinearAnimator when using the array of endpoints with a primitive quantum (steps/interval).

DarthSharkie commented 4 months ago

Fixed for LinearAnimator: https://github.com/GitBrincie212/Apel-Mod/pull/27/commits/ce2abb8cb58b84f7ec531f22bb18c09aeab5b41e.

PR submitted: https://github.com/GitBrincie212/Apel-Mod/pull/27

DarthSharkie commented 4 months ago

Fixed for BezierCurveAnimator: https://github.com/GitBrincie212/Apel-Mod/pull/28/commits/b4cfd5c8fcd04d73938ebcf9a49f185ebba2205c

PR: https://github.com/GitBrincie212/Apel-Mod/pull/28

DarthSharkie commented 4 months ago

Both PRs merged