diff --git a/direct/src/distributed/DistributedNode.py b/direct/src/distributed/DistributedNode.py index 5224fae29c..10fa25c8b6 100644 --- a/direct/src/distributed/DistributedNode.py +++ b/direct/src/distributed/DistributedNode.py @@ -55,11 +55,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath): else: if self.gridParent: self.gridParent.delete() - self.gridParent = None - # NOTE: at this point the avatar has been detached from the scene - # graph. Someone else needs to reparent him to something in the scene graph - # TODO: handle DistributedNode parenting - + self.gridParent = None def __cmp__(self, other): # DistributedNode inherits from NodePath, which inherits a diff --git a/direct/src/distributed/DistributedObject.py b/direct/src/distributed/DistributedObject.py index a42119d409..cee326e166 100644 --- a/direct/src/distributed/DistributedObject.py +++ b/direct/src/distributed/DistributedObject.py @@ -353,10 +353,28 @@ class DistributedObject(PandaObject): # The store must run first so we know the old location #self.cr.storeObjectLocation(self.doId, parentId, zoneId) self.__location = (parentId, zoneId) + # Give the parent a chance to run code when a new child + # sets location to it. For example, the parent may want to + # scene graph reparent the child to some subnode it owns. + parentObj = self.cr.doId2do.get(parentId) + if parentObj: + parentObj.handleChildSetLocation(self, zoneId) def getLocation(self): return self.__location + def handleChildSetLocation(self, childObj, zoneId): + self.notify.info("handleChildSetLocation: %s childId: %s zoneId: %s" % + (self.doId, childObj.doId, zoneId)) + # A new child has just setLocation beneath us. Give us a + # chance to run code when a new child sets location to us. For + # example, we may want to scene graph reparent the child to + # some subnode we own. + + # Inheritors should override + pass + + def isLocal(self): # This returns true if the distributed object is "local," # which means the client created it instead of the AI, and it