[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Ideas for faster math in lua
- From: Diego Nehab <diego@...>
- Date: Thu, 14 Feb 2008 17:05:31 -0500 (EST)
local midentity = matrixh()
local valtitude = vector()
local global_matrix = self.global_matrix
valtitude.y = self.altitude
And even if that optimized form is acceptable for entity update, for
skeletal animation of a couple hundred of entities with 64 bones each
it just takes too much time to run at interactive framerate, so
instead I rewrite these critical bottlenecks in C.
If you are willing to use this syntax, you could perhaps go the next
step and use light user data for matrices? You could then completely
avoid Lua's garbage collection (and production).
With the above syntax I avoid most object creation, and at
that point unfortunately the cost of Lua->C function calls
become the bottleneck.
I agree that if this is the only function you use, you'd
save on the object creation with your current syntax.
But there is also the cost of metatable access, which I don't
think is free. If you had copy/translate/rotate as local variables,
you might gain some performance. Also, what are you doing
for error checking once you receive the "userdata" within
the C functions bound to copy/translate/rotate?