ivan wrote:Lastly, I would advise against using table to represent vectors.
In my experience, it's an unnecessary strain on the Lua garbage collector.
Hope this helps
haha yeah, this makes me really nervous about using vector-heavy lua libs
granted you need to be creating a "lot" of tables per frame for this to happen, although in my case this was something like 13-14k, which was enough to pull the framerate down to 30 (cloth sim, and a fairly bad one at that [euler integration and only one solve per iteration], a better one would likely tear through a good deal more than that)
it makes me wonder if it's better to implement vectors as userdata which can be pooled on the c side (assuming that's even a reasonable option without deterministic lifetimes)
EDIT: actually maybe it's possible to do the pooling through the vector functions... like
function add (a, b) pool2(a, b) return vector(a[1] + b[1], a[2] + b[2]) end.
haven't really thought about it though