소스 검색

adding teleport support

Samir Naik 21 년 전
부모
커밋
60a0c18273
3개의 변경된 파일12개의 추가작업 그리고 11개의 파일을 삭제
  1. 2 2
      direct/src/distributed/DistributedNode.py
  2. 1 1
      direct/src/distributed/DistributedNodeAI.py
  3. 9 8
      direct/src/distributed/GridParent.py

+ 2 - 2
direct/src/distributed/DistributedNode.py

@@ -41,7 +41,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
         DistributedObject.DistributedObject.generate(self)
         self.gotStringParentToken = 0
 
-    def setLocation(self, parentId, zoneId):
+    def setLocation(self, parentId, zoneId, teleport=0):
         # Redefine DistributedObject setLocation, so that when
         # location is set to the ocean grid, we can update our parenting
         # under gridParent
@@ -51,7 +51,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
             if parentObj.isGridParent():
                 if not self.gridParent:
                     self.gridParent = GridParent.GridParent(self)
-                self.gridParent.setGridParent(parentObj, zoneId)
+                self.gridParent.setGridParent(parentObj, zoneId, teleport)
             else:
                 if self.gridParent:
                     self.gridParent.delete()

+ 1 - 1
direct/src/distributed/DistributedNodeAI.py

@@ -23,7 +23,7 @@ class DistributedNodeAI(DistributedObjectAI.DistributedObjectAI, NodePath):
             self.removeNode()
         DistributedObjectAI.DistributedObjectAI.delete(self)
 
-    def setLocation(self, parentId, zoneId):
+    def setLocation(self, parentId, zoneId, teleport=0):
         # Redefine DistributedObject setLocation, so that when
         # location is set to the ocean grid, we can update our parenting
         # under gridParent

+ 9 - 8
direct/src/distributed/GridParent.py

@@ -35,15 +35,16 @@ class GridParent:
         # Remove the gridNodes
         self.cellOrigin.removeNode()
                 
-    def setGridParent(self, grid, zoneId):
-        # If the avatar has a parent, preserve his absolute position.  Otherwise
-        # if he has no parent, assume this is the first time he's been parented
-        # to anything, and don't wrtReparent, just do a regular reparent.
-        firstParent = 0
+    def setGridParent(self, grid, zoneId, teleport=0):
+        # If teleport=0, preserve the avatar's absolute position.  If teleport=1
+        # the avatars previous world position is invalid, so don't wrtReparent,
+        # just do a regular reparent, and let the cellOrigin give us our new position
+
+        # Also, if the avatar has no parent, then force teleport=1
         if self.av.getParent().isEmpty():
-            firstParent = 1
+            teleport = 1
 
-        if not firstParent:
+        if not teleport:
             # Stick the avatar under hidden while we move the cellOrigin into
             # position so we do not lose the avatars absolute position.
             self.av.wrtReparentTo(hidden)
@@ -63,7 +64,7 @@ class GridParent:
         self.cellOrigin.setPos(*cellPos)
 
         # Reparent our avatar to this node
-        if not firstParent:
+        if not teleport:
             self.av.wrtReparentTo(self.cellOrigin)
         else:
             self.av.reparentTo(self.cellOrigin)