fix merge-lod-bundles

This commit is contained in:
David Rose 2007-07-05 20:52:20 +00:00
parent 2ded3768ac
commit 111ae8a53a

View File

@ -655,7 +655,7 @@ class Actor(DirectObject, NodePath):
specific geometry to. Returns 'None' if not found specific geometry to. Returns 'None' if not found
""" """
if self.__LODNode: if self.__LODNode:
lod = self.__LODNode.find("**/%s"%lodName) lod = self.__LODNode.find(str(lodName))
if lod.isEmpty(): if lod.isEmpty():
return None return None
else: else:
@ -1205,7 +1205,7 @@ class Actor(DirectObject, NodePath):
# check to see if we are working within an lod # check to see if we are working within an lod
if lodName != None: if lodName != None:
# find the named lod node # find the named lod node
lodRoot = self.find("**/" + str(lodName)) lodRoot = self.__LODNode.find(str(lodName))
if root == None: if root == None:
# no need to look further # no need to look further
root = lodRoot root = lodRoot
@ -1685,7 +1685,16 @@ class Actor(DirectObject, NodePath):
# Now extract out the Character and integrate it with # Now extract out the Character and integrate it with
# the Actor. # the Actor.
self.__prepareBundle(bundleNP, model, partName, lodName)
if (lodName!="lodRoot"):
# parent to appropriate node under LOD switch
bundleNP.reparentTo(self.__LODNode.find(str(lodName)))
else:
bundleNP.reparentTo(self.__geomNode)
self.__prepareBundle(bundleNP, model.node(), partName, lodName)
# we rename this node to make Actor copying easier
bundleNP.node().setName("%s%s"%(Actor.partPrefix,partName))
if numAnims != 0: if numAnims != 0:
# If the model had some animations, store them in the # If the model had some animations, store them in the
@ -1709,7 +1718,7 @@ class Actor(DirectObject, NodePath):
animDef.animControl = animControl animDef.animControl = animControl
self.__animControlDict[lodName][partName][animName] = animDef self.__animControlDict[lodName][partName][animName] = animDef
def __prepareBundle(self, bundleNP, model, def __prepareBundle(self, bundleNP, partModel,
partName="modelRoot", lodName="lodRoot"): partName="modelRoot", lodName="lodRoot"):
assert partName not in self.__subpartDict assert partName not in self.__subpartDict
@ -1720,9 +1729,6 @@ class Actor(DirectObject, NodePath):
self.node().setName(bundleNP.node().getName()) self.node().setName(bundleNP.node().getName())
self.gotName = 1 self.gotName = 1
# we rename this node to make Actor copying easier
bundleNP.node().setName("%s%s"%(Actor.partPrefix,partName))
bundleDict = self.__partBundleDict.get(lodName, None) bundleDict = self.__partBundleDict.get(lodName, None)
if bundleDict == None: if bundleDict == None:
# make a dictionary to store these parts in # make a dictionary to store these parts in
@ -1730,12 +1736,6 @@ class Actor(DirectObject, NodePath):
self.__partBundleDict[lodName] = bundleDict self.__partBundleDict[lodName] = bundleDict
self.__updateSortedLODNames() self.__updateSortedLODNames()
if (lodName!="lodRoot"):
# parent to appropriate node under LOD switch
bundleNP.reparentTo(self.__LODNode.find("**/%s"%lodName))
else:
bundleNP.reparentTo(self.__geomNode)
node = bundleNP.node() node = bundleNP.node()
# A model loaded from disk will always have just one bundle. # A model loaded from disk will always have just one bundle.
assert(node.getNumBundles() == 1) assert(node.getNumBundles() == 1)
@ -1751,7 +1751,7 @@ class Actor(DirectObject, NodePath):
# We haven't already got a bundle for this part; store it. # We haven't already got a bundle for this part; store it.
self.__commonBundles[partName] = bundle self.__commonBundles[partName] = bundle
bundleDict[partName] = Actor.PartDef(bundleNP, bundle, model.node()) bundleDict[partName] = Actor.PartDef(bundleNP, bundle, partModel)
def makeSubpart(self, partName, includeJoints, excludeJoints = [], def makeSubpart(self, partName, includeJoints, excludeJoints = [],
@ -2073,19 +2073,15 @@ class Actor(DirectObject, NodePath):
instance's own. NOTE: this method does not actually copy geometry instance's own. NOTE: this method does not actually copy geometry
""" """
for lodName in other.__partBundleDict.keys(): for lodName in other.__partBundleDict.keys():
self.__partBundleDict[lodName] = {}
self.__updateSortedLODNames()
# find the lod Asad # find the lod Asad
if lodName == 'lodRoot': if lodName == 'lodRoot':
partLod = self partLod = self
else: else:
partLod = self.find("**/%s"%lodName) partLod = self.__LODNode.find(str(lodName))
if partLod.isEmpty(): if partLod.isEmpty():
Actor.notify.warning("no lod named: %s" % (lodName)) Actor.notify.warning("no lod named: %s" % (lodName))
return None return None
for partName, partDef in other.__partBundleDict[lodName].items(): for partName, partDef in other.__partBundleDict[lodName].items():
model = partDef.partModel.copySubgraph()
# We can really only copy from a non-flattened avatar. # We can really only copy from a non-flattened avatar.
assert partDef.partBundleNP.node().getNumBundles() == 1 assert partDef.partBundleNP.node().getNumBundles() == 1
@ -2093,9 +2089,8 @@ class Actor(DirectObject, NodePath):
bundleNP = partLod.find("**/%s%s"%(Actor.partPrefix,partName)) bundleNP = partLod.find("**/%s%s"%(Actor.partPrefix,partName))
if (bundleNP != None): if (bundleNP != None):
# store the part bundle # store the part bundle
assert bundleNP.node().getNumBundles() == 1 self.__prepareBundle(bundleNP, partDef.partModel,
bundle = bundleNP.node().getBundle(0) partName, lodName)
self.__partBundleDict[lodName][partName] = Actor.PartDef(bundleNP, bundle, model)
else: else:
Actor.notify.error("lod: %s has no matching part: %s" % Actor.notify.error("lod: %s has no matching part: %s" %
(lodName, partName)) (lodName, partName))