mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
fixed delayed reparenting for multiple children
This commit is contained in:
parent
65f24e45ef
commit
3c00fa597c
@ -28,7 +28,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
|
|
||||||
# this dict stores entity reparents if the parent hasn't been
|
# this dict stores entity reparents if the parent hasn't been
|
||||||
# created yet
|
# created yet
|
||||||
self.pendingEntId2ParentId = {}
|
self.parent2ChildIds = {}
|
||||||
|
|
||||||
# Most (if not all) of the timed entities of levels
|
# Most (if not all) of the timed entities of levels
|
||||||
# run on looping intervals that are started once based on
|
# run on looping intervals that are started once based on
|
||||||
@ -123,7 +123,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
self.localEntities[entId] = entity
|
self.localEntities[entId] = entity
|
||||||
|
|
||||||
# there should not be any pending reparents left
|
# there should not be any pending reparents left
|
||||||
assert len(self.pendingEntId2ParentId) == 0
|
assert len(self.parent2ChildIds) == 0
|
||||||
|
|
||||||
def announceGenerate(self):
|
def announceGenerate(self):
|
||||||
self.notify.debug('announceGenerate')
|
self.notify.debug('announceGenerate')
|
||||||
@ -164,20 +164,31 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
self.notify.debug(
|
self.notify.debug(
|
||||||
'entity %s requesting reparent to %s, not yet created' %
|
'entity %s requesting reparent to %s, not yet created' %
|
||||||
(entity, parent))
|
(entity, parent))
|
||||||
|
|
||||||
entId = entity.entId
|
entId = entity.entId
|
||||||
self.pendingEntId2ParentId[entId] = parentId
|
|
||||||
entity.reparentTo(hidden)
|
entity.reparentTo(hidden)
|
||||||
|
|
||||||
|
# if this parent doesn't already have another child pending,
|
||||||
|
# do some setup
|
||||||
|
if not self.parent2ChildIds.has_key(parentId):
|
||||||
|
self.parent2ChildIds[parentId] = []
|
||||||
|
|
||||||
# do the reparent once the parent is initialized
|
# do the reparent once the parent is initialized
|
||||||
def doReparent(entId=entId, parentId=parentId, self=self):
|
def doReparent(parentId=parentId, self=self):
|
||||||
entity=self.getEntity(entId)
|
assert self.parent2ChildIds.has_key(parentId)
|
||||||
parent=self.getEntity(parentId)
|
parent=self.getEntity(parentId)
|
||||||
|
for entId in self.parent2ChildIds[parentId]:
|
||||||
|
entity=self.getEntity(entId)
|
||||||
self.notify.debug(
|
self.notify.debug(
|
||||||
'performing pending reparent of %s to %s' %
|
'performing pending reparent of %s to %s' %
|
||||||
(entity, parent))
|
(entity, parent))
|
||||||
entity.reparentTo(parent)
|
entity.reparentTo(parent)
|
||||||
del self.pendingEntId2ParentId[entId]
|
del self.parent2ChildIds[parentId]
|
||||||
|
|
||||||
self.accept(self.getEntityCreateEvent(parentId), doReparent)
|
self.accept(self.getEntityCreateEvent(parentId), doReparent)
|
||||||
|
|
||||||
|
self.parent2ChildIds[parentId].append(entId)
|
||||||
|
|
||||||
def showZone(self, zoneNum):
|
def showZone(self, zoneNum):
|
||||||
self.zoneNum2Node[zoneNum].show()
|
self.zoneNum2Node[zoneNum].show()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user