entity reparents take effect in the scenegraph

This commit is contained in:
Darren Ranalli 2003-10-23 01:23:10 +00:00
parent 2a4ad03ce8
commit 7d04df949b
4 changed files with 19 additions and 11 deletions

View File

@ -14,8 +14,12 @@ class NodePathAttribs:
self.callSetters('pos','x','y','z',
'hpr','h','p','r',
'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)
@ -46,9 +50,13 @@ class privNodePathImpl(NodePath.NodePath):
of its attributes have been set"""
self.callSetters('pos','x','y','z',
'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):
if __debug__:
self.clearTag('entity')

View File

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

View File

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

View File

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