More flexible linear algebra support for GDScript #10523
Replies: 1 comment 1 reply
-
Right now I'd expect some strong pushback for adding new value types, due to making Perhaps this can be addressed with methods and operators on packed arrays... However, note that - just as in Python - addition of arrays is concatenation in Godot. A discussion of what can be a method and what can be an operator is needed to make this a full proposal. Of course, another thing to consider is adding new reference types... Godot right now does not define operators on them, so that is a drawback. But it might be better to not be moving large chunks of memory around. Anyway, be aware that you have I'm going to offer you a couple more ideas: You could use textures, and you could use (compute) shaders. I can think of a few ways to design that, although I don't think it would be beginner friendly to roll your own, yet it might be a nice plugin. And you would get more performance by running on GPU. |
Beta Was this translation helpful? Give feedback.
-
Godot has very limited support for linear algebra currently. It supports the most common objects (2-4D vectors, some transform matrices, integer vectors), but there's no way to make VectorN or an NxM matrix. Alternatives, such as PackedIntArray or PackedFloatArray, lack even basic linear algebra operations, such as scalar multiplication, and thus do not make adequate substitutes for proper linear algebra structures.
Godot, through its support of C# and C++, has linear algebra via languages other than GDScript, which is the crux of the issue here. Without using those languages, you are very limited in what linear algebra you can do. While this is probably fine for most developers, it does mean that you are occasionally forced into designs which are less performant and sometimes, in my opinion, less readable. I encountered one such case where the best solution I could find under GDScript's limits was to use a tall hierarchy of nested resource classes that was less intuitive for me to work with than a series of n-length Vectors would have been.
As someone with a background in python, especially in using numpy for computer vision and ML, I find liner algebra structures intuitive to work with and vastly more performant, and thus I think Godot would benefit from fleshing out its linear algebra support in GDScript.
Beta Was this translation helpful? Give feedback.
All reactions