JOML-CI / JOML

A Java math library for OpenGL rendering calculations
MIT License
729 stars 104 forks source link

[Suggestion/Discussion] Matrix Consumer Actions #348

Closed Speiger closed 4 months ago

Speiger commented 4 months ago

o/

I am again working again on my own engine and had a thought about JOML. JOML forces to some degree always to provide a Vector4f when working with a matrix as in/output. Or at least the output is always forced that way.

Which always requires an object allocation.

I wonder what do you think of making an consumer?

public interface ITransformOutput {
    public void accept(float x, float y, float z, float w);
}

Ofc not doing infinite combos, but a fixed selection of those. Edit: In addition to existing implementations of the function So having a function like this: Matrix4fc.transform(float x, float y, float z, float w, ITransformOutput output)

The idea being that you can hook direct functions such as a vertex consumer on to it directly. This would bypass the need of creating local instances/threadLocals/caches on to the project and would allow much more.

To be transparent my implementation looks more like this:

public interface ITransformOutput {
    public void accept(float...output);
}

Because it is more dynamic but i am not sure how well that syntax sugar is with performance that's why i am not suggesting this specifically.

Anyways, this isn't a "feature request" but more of a design idea i wanted to share with you since your library gave me such huge inspiration and I want to give at least something back :)

Also sorry looks like Ctrl+Z when editing text seems to automatically create the issue O.o I wasn't done writing when i created the issue.