I’m trying to move hundreds of objects on the screen at a time, and I’ve noticed that setPos is a bit slow – even for nodes that are hidden.
To move 900 (hidden smileys around), PStats tells me that the actual 900 setPos call took 10.5ms, and another 2.5ms was spent in 'Bounds.'
App->Showcode->task_testmov 10.5ms
*->Bounds 2.5ms
I tried adding transform-cache 0 to the configfile. This brought the execution time of the task that contains the 900 setPos down to 5ms, but it still took 3ms to do 'Bounds.'
Is there a way to turn off all of the bounds checking/recalculation associated with setPos? I've tried (for every smiley)
t.setBounds(OmniBoundingVolume())
t.node().setFinal
But it doesn’t seem to do much. Also is there a way to setPos to perform faster? I know that 5ms/900~= 5usecs is not a very long time, but it still seems like a long time to set a few matrix elements.
Thanks,
Zhao
for i in range(0, 900):
t = loader.loadModel('smiley')
t.setPos( i*10,0,0)
t.reparentTo(render)
#t.node().setBounds(OmniBoundingVolume())
#t.node().setFinal(True)
t.hide()
tlist.append(t)
def task_testmov(task):
for i in tlist:
t = 0.01
p = i.getPos()
i.setPos( p[0] + t, p[1], [2]) )
return task.cont
taskMgr.add( testmov, 'testmov')
run()
P.S. The entire task takes ~1ms to perform without the setPos.