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

Refactor ApelClient code #11

Closed DarthSharkie closed 5 months ago

DarthSharkie commented 5 months ago

Edit:

This is a runaway train! Once the point computation was done (basically copied from ApelRenderer default methods), it became clear that the point computation could be done by Instruction instances. I think the path forward looks like this:

DarthSharkie commented 5 months ago

Both of these are possible and done. Commit references to follow, once they're stable (too much local rebasing/reworking).

DarthSharkie commented 5 months ago

This is a runaway train! Once the point computation was done (basically copied from ApelRenderer default methods), it became clear that the point computation could be done by Instruction instances. More steps added to top comment!

DarthSharkie commented 5 months ago

Instruction point computation and caching is done and working.

DarthSharkie commented 5 months ago

Commits:

Merged in https://github.com/GitBrincie212/Apel-Mod/pull/22.

DarthSharkie commented 5 months ago

Common base renderer: https://github.com/GitBrincie212/Apel-Mod/pull/23.

DarthSharkie commented 5 months ago

As I worked on this, realized that the draw... methods in ApelRenderer are turning into a "unit" shape with scale, rotate, and translate operations performed. This doesn't cover line-based shapes (AFAICT), but it does cover 3D equation-defined shapes. Actually, on second thought, all lines can be made into unit vectors...but is that worth it? Probably not.

Their draw... methods should be drawShape(ParticleEffect, amount, scale, rotate, translate). Scale can be float, Vector2f, or Vector3f depending on shape, but should probably just be Vector3f when implementing, since that's what the Matrix4f will want when using translateRotateScale. Allocating that in ParticleObjects consistently would allow for ease of profiling (due to consistency) vs. conditionally allocating in ApelRenderer and implementations.

Caching can then be done based on the (shape, amount) tuple, and Matrix4f#transformPosition(point) called on each point.

DarthSharkie commented 5 months ago

If the unit shapes are computing, the computePoints() method could do the caching internally to the Instruction...need to consider if this is better than the renderer. Instructions could save computation by doing this.