I would like to use asyncFlattenStrong to flatten my models in separate thread, but it seems I am not getting exact results I am hoping for.
When I set inPlace=True the models never get returned to the scene graph, they just vanish. When I set inPlace=False and catch the new models in callback function and reparent them to render, it seems to work fine. The question is, why is inPlace=True not working and am I using this correctly at all?
I am using stock Panda 1.7.2.
from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
class Application(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.root = render.attachNewNode("root")
a = loader.loadModel('smiley')
a.setPos(4, 25, 0)
a.setScale(3,3,3)
a.reparentTo(self.root)
b = loader.loadModel('frowney')
b.setPos(-4,25,0)
b.reparentTo(self.root)
b.setScale(3,3,3)
self.root.clearModelNodes()
self.accept("i", render.analyze)
self.accept("o", render.ls)
self.accept("f", self.standardFlatten)
self.accept("a", self.asyncFlatten)
self.accept("s", self.asyncFlattenInPlace)
def asyncFlatten(self):
loader.asyncFlattenStrong(model=self.root,inPlace=False,callback=self.callbackFlatten)
def asyncFlattenInPlace(self):
loader.asyncFlattenStrong(model=self.root,inPlace=True,callback=self.callbackFlattenInPlace)
def standardFlatten(self):
self.root.flattenStrong()
def callbackFlatten(self, origModelList):
origModelList.reparentTo(render)
self.root.removeNode()
def callbackFlattenInPlace(self, origModelList):
print "callback"
app = Application()
app.run()