Limit-Theory-Redux / ltheory

Limit Theory Redux is a fork of the discontinued open-world space simulation game Limit Theory. We have made it our mission to continue the development of the ambitious Limit Theory project as an open source initiative.
Apache License 2.0
62 stars 8 forks source link

Make Mesh, Bytes, and all texture types safe using luajit-ffi-gen. #329

Closed dgavedissian closed 2 months ago

dgavedissian commented 2 months ago

Maybe best to review this commit-by-commit?

The other major thing here is that I introduced a new library tobj for loading .OBJ files, rather than the brittle hand-written code from before.

As Mesh, Tex[1-3]D and TexCube were all ref-counted, they moved to a model where they are "cheap to clone" and are backed by Rf under the hood. The idea is that the Lua GC maintains a ref count of these objects (and the Rf ref count remains at 1), but the engine can also increase the Rf ref count, so even if the Lua VM is done with the object, it wont be completely freed right away. I think that model is much cleaner and less error prone than having to :acquire() explicitly.