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
The vertex references resulted in an IndexOutOfBoundsException when trying to draw the last line of the polygon. When iterating through pairs of array values, the foreach syntax cannot understand the "+1" reference and stop early. Direct indexing must be used. A benefit of direct indexing here is the ability to eliminate N allocations of Vector3f because the nextVertex being reallocated as vertex goes away.
Change the "raw" vertex computation (pre-rotation, offset, etc.) to use computeIfAbsent instead of a "check-then-act" paradigm. At the same time, make the last point equal to a copy of the first to prevent any issues with floating-point arithmetic.
Drawing the polygon will result in duplicate particles on each vertex, but they should appear to have sides / amount particles per side now rather than amount particles on each side.
Make sure defensive copies are made at appropriate times to prevent cache corruption and any further drawPos usage (e.g., in another shape).
The vertex references resulted in an
IndexOutOfBoundsException
when trying to draw the last line of the polygon. When iterating through pairs of array values, theforeach
syntax cannot understand the "+1" reference and stop early. Direct indexing must be used. A benefit of direct indexing here is the ability to eliminate N allocations ofVector3f
because thenextVertex
being reallocated asvertex
goes away.Change the "raw" vertex computation (pre-rotation, offset, etc.) to use
computeIfAbsent
instead of a "check-then-act" paradigm. At the same time, make the last point equal to a copy of the first to prevent any issues with floating-point arithmetic.Drawing the polygon will result in duplicate particles on each vertex, but they should appear to have
sides / amount
particles per side now rather thanamount
particles on each side.Make sure defensive copies are made at appropriate times to prevent cache corruption and any further
drawPos
usage (e.g., in another shape).