GitBrincie212 / 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
2 stars 1 forks source link

Polygon memory reduction #61

Closed DarthSharkie closed 3 weeks ago

DarthSharkie commented 3 weeks ago

This allocates Bezier curves as needed at the polygon level instead of allocating on every draw step.

Test code:

        ParticlePolygon polygon = ParticlePolygon.builder()
                .size(2f)
                .sides(9)
                .amount(75)
                .particleEffect(ParticleTypes.END_ROD)
                .offset(new Vector3f(4f, 2f, 5f))
                .beforeDraw((data, obj) -> {
                    obj.setSize(data.getCurrentStep() / 150.0f + 2f);
                    obj.setSides(Math.floorDiv(data.getCurrentStep(), 100) + 3);
                    obj.setRoundness((float) Math.sin(Math.PI * data.getCurrentStep() / 150f));
                })
                .build();

        PointAnimator pointAnimator = PointAnimator.builder().point(new Vector3f()).delay(1).renderingSteps(600)
                .particleObject(polygon).build();
        pointAnimator.beginAnimation(ApelServerRenderer.create(world));