|
How in the world working on a pre-defined array is 100 times slower than collecting it on the fly?
The following script will create a biped and re-apply on each bone its position transform from frame 1 to 100. On the first try I used a pre-defined array and on the second i am collecting on the fly.
The result:
Pre-Defined array took: 1520 miliseconds
Collecting on the fly: 3 miliseconds
here is the code:
(
local newBip = biped.createnew 100 0 [0,0,100]
local boneList = for i in objects where (classof i) == biped_object collect i
local timeStart = undefined
timeStart = timestamp()
for i = 1 to 100 do
(
for b in bonelist do at time i biped.settransform b #pos (biped.gettransform b #pos) true
)
format "Operation took: % miliseconds \n" ((timestamp()) - timeStart)
timeStart = timestamp()
for i = 1 to 100 do
(
for b in objects where (classof i) == biped_object do at time i biped.settransform b #pos (biped.gettransform b #pos) true
)
format "Operation took: % miliseconds \n" ((timestamp()) - timeStart)
)
|
|
|
|
for b in objects where (classof i) == biped_object
You have a small mistake there (checking the class of i instead of b, always false). Second version isn’t collecting anything.
Once this is fixed, this can not be faster than first version.
VFB+ : The advanced 3dsmax frame buffer
|
|
|