AREA forums upgrade
Read more about the planned upgrade of our forums
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Using a predefined Array vs Objects on the fly
IMPORTANT ANNOUNCEMENT ABOUT AREA FORUMS
  RSS 2.0 ATOM  

Using a predefined Array vs Objects on the fly
Rate this thread
 
71109
 
Permlink of this thread  
avatar
  • asabourin
  • Posted: 12 September 2012 12:34 PM
  • Total Posts: 14
  • Joined: 05 July 2010 03:22 PM

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 
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 
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)
 
)


Replies: 0
avatar
  • lo_
  • Posted: 15 September 2012 10:18 PM

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

Replies: 0