瀏覽代碼

entity reparents take effect in the scenegraph

Darren Ranalli 22 年之前
父節點
當前提交
7d04df949b

+ 12 - 4
direct/src/level/BasicEntities.py

@@ -14,8 +14,12 @@ class NodePathAttribs:
         self.callSetters('pos','x','y','z',
         self.callSetters('pos','x','y','z',
                          'hpr','h','p','r',
                          'hpr','h','p','r',
                          'scale','sx','sy','sz')
                          'scale','sx','sy','sz')
-        if doReparent and hasattr(self, 'parent'):
-            self.level.requestReparent(self.getNodePath(), self.parent)
+        if doReparent:
+            self.callSetters('parentEntId')
+
+    def setParentEntId(self, parentEntId):
+        self.parentEntId = parentEntId
+        self.level.requestReparent(self.getNodePath(), self.parentEntId)
 
 
     def reparentTo(self, *args): self.getNodePath().reparentTo(*args)
     def reparentTo(self, *args): self.getNodePath().reparentTo(*args)
 
 
@@ -46,9 +50,13 @@ class privNodePathImpl(NodePath.NodePath):
         of its attributes have been set"""
         of its attributes have been set"""
         self.callSetters('pos','x','y','z',
         self.callSetters('pos','x','y','z',
                          'hpr','h','p','r',
                          'hpr','h','p','r',
-                         'scale','sx','sy','sz')
-        self.level.requestReparent(self, self.parent)
+                         'scale','sx','sy','sz',
+                         'parentEntId')
         
         
+    def setParentEntId(self, parentEntId):
+        self.parentEntId = parentEntId
+        self.level.requestReparent(self.getNodePath(), self.parentEntId)
+
     def destroy(self):
     def destroy(self):
         if __debug__:
         if __debug__:
             self.clearTag('entity')
             self.clearTag('entity')

+ 2 - 2
direct/src/level/DistributedLevelAI.py

@@ -87,9 +87,9 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
             # table; but since zone entities are currently not distributed,
             # table; but since zone entities are currently not distributed,
             # it's fine to return None.
             # it's fine to return None.
             return self.zoneNum2zoneId.get(spec['modelZoneNum'])
             return self.zoneNum2zoneId.get(spec['modelZoneNum'])
-        if not spec.has_key('parent'):
+        if not spec.has_key('parentEntId'):
             return None
             return None
-        return self.getEntityZoneId(spec['parent'])
+        return self.getEntityZoneId(spec['parentEntId'])
 
 
     if __debug__:
     if __debug__:
         # level editors should call this func to tweak attributes of level
         # level editors should call this func to tweak attributes of level

+ 2 - 2
direct/src/level/EntityTypes.py

@@ -44,7 +44,7 @@ class LogicGate(Entity):
 class Nodepath(Entity):
 class Nodepath(Entity):
     type = 'nodepath'
     type = 'nodepath'
     attribs = (
     attribs = (
-        ('parent', 0, 'entId', {'type':'nodepath'}),
+        ('parentEntId', 0, 'entId', {'type':'nodepath'}),
         ('pos', Point3(0,0,0), 'pos'),
         ('pos', Point3(0,0,0), 'pos'),
         ('hpr', Vec3(0,0,0), 'hpr'),
         ('hpr', Vec3(0,0,0), 'hpr'),
         )
         )
@@ -52,7 +52,7 @@ class Nodepath(Entity):
 class Zone(Nodepath):
 class Zone(Nodepath):
     type = 'zone'
     type = 'zone'
     delAttribs = (
     delAttribs = (
-        'parent',
+        'parentEntId',
         'pos',
         'pos',
         'hpr',
         'hpr',
         )
         )

+ 3 - 3
direct/src/level/LevelSpec.py

@@ -121,8 +121,8 @@ class LevelSpec:
             for name, desc in attribDescs.items():
             for name, desc in attribDescs.items():
                 spec[name] = desc.getDefaultValue()
                 spec[name] = desc.getDefaultValue()
             spec['type'] = entType
             spec['type'] = entType
-            if 'parent' in spec:
-                spec['parent'] = parentEntId
+            if 'parentEntId' in spec:
+                spec['parentEntId'] = parentEntId
 
 
             # notify the level
             # notify the level
             self.level.handleEntityInsert(entId)
             self.level.handleEntityInsert(entId)
@@ -222,7 +222,7 @@ class LevelSpec:
                     return result
                     return result
    
    
                 firstTypes = ('levelMgr', 'editMgr', 'zone',)
                 firstTypes = ('levelMgr', 'editMgr', 'zone',)
-                firstAttribs = ('type', 'name', 'comment', 'parent',
+                firstAttribs = ('type', 'name', 'comment', 'parentEntId',
                                 'pos', 'x', 'y', 'z',
                                 'pos', 'x', 'y', 'z',
                                 'hpr', 'h', 'p', 'r',
                                 'hpr', 'h', 'p', 'r',
                                 'scale', 'sx', 'sy', 'sz',
                                 'scale', 'sx', 'sy', 'sz',