Page 1 of 1

Suggestion: Vector Functions

Posted: Sun May 03, 2020 6:26 pm
by Lovingsoul1337
Would be great if you would add vector's to love2d...is there a reason they are not built in ?

best regards

Re: Suggestion: Vector Functions

Posted: Mon May 04, 2020 4:29 am
by zorg
Yes, because there are one of the quintessential things one can implement using either lua or the luajit ffi; and that there exist quite a few vector libraries already.

Re: Suggestion: Vector Functions

Posted: Mon May 04, 2020 10:24 am
by pgimeno
A vector library would be slower in C++ than in Lua anyway (sadly I saw the author of ItsyRealm make that mistake).

Re: Suggestion: Vector Functions

Posted: Tue May 05, 2020 2:41 pm
by Kindermaus
pgimeno wrote:
Mon May 04, 2020 10:24 am
A vector library would be slower in C++ than in Lua anyway (sadly I saw the author of ItsyRealm make that mistake).
To clarify...

99% of the code uses a Lua Vector/Quaternion/Ray implementation, 1% (the scene graph traversal) off-loads the computation of the scene graph traversal & sorting to C++ because doing that in Lua is too slow. Things like rain and fungal weather use a highly customized (specific to the weather) math implementation for performance reasons as well, in FFI/Lua.

Using a C++ scene graph traversal/sorting doubled performance...

Those percentages aren't accurate but that's the general idea of it all.

Also my game will match the refresh rate on (i.e., 144 Hz) on mid-range hardware when I make a high-priority optimization: off-loading game logic to a separate thread. So I'm really not worried about performance. :P