mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 03:15:07 -04:00
only one setZoneMsg per frame
This commit is contained in:
parent
1ad304e914
commit
c1daa929b8
@ -26,6 +26,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
FloorCollPrefix = 'zoneFloor'
|
FloorCollPrefix = 'zoneFloor'
|
||||||
|
|
||||||
OuchTaskName = 'ouchTask'
|
OuchTaskName = 'ouchTask'
|
||||||
|
VisChangeTaskName = 'visChange'
|
||||||
|
|
||||||
def __init__(self, cr):
|
def __init__(self, cr):
|
||||||
DistributedObject.DistributedObject.__init__(self, cr)
|
DistributedObject.DistributedObject.__init__(self, cr)
|
||||||
@ -291,6 +292,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
if hasattr(self, 'geom'):
|
if hasattr(self, 'geom'):
|
||||||
del self.geom
|
del self.geom
|
||||||
|
|
||||||
|
self.shutdownVisibility()
|
||||||
self.destroyLevel()
|
self.destroyLevel()
|
||||||
DistributedObject.DistributedObject.disable(self)
|
DistributedObject.DistributedObject.disable(self)
|
||||||
self.ignoreAll()
|
self.ignoreAll()
|
||||||
@ -393,6 +395,8 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
# we have not entered any zone yet
|
# we have not entered any zone yet
|
||||||
self.curZoneNum = None
|
self.curZoneNum = None
|
||||||
|
|
||||||
|
self.visChangedThisFrame = 0
|
||||||
|
|
||||||
# listen for camera-ray/floor collision events
|
# listen for camera-ray/floor collision events
|
||||||
def handleCameraRayFloorCollision(collEntry, self=self):
|
def handleCameraRayFloorCollision(collEntry, self=self):
|
||||||
name = collEntry.getIntoNode().getName()
|
name = collEntry.getIntoNode().getName()
|
||||||
@ -414,6 +418,15 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
zoneNums.remove(LevelConstants.UberZoneNum)
|
zoneNums.remove(LevelConstants.UberZoneNum)
|
||||||
self.setVisibility(zoneNums)
|
self.setVisibility(zoneNums)
|
||||||
|
|
||||||
|
# send out any zone changes at the end of the frame, just before
|
||||||
|
# rendering
|
||||||
|
taskMgr.add(self.visChangeTask,
|
||||||
|
self.uniqueName(DistributedLevel.VisChangeTaskName),
|
||||||
|
priority=49)
|
||||||
|
|
||||||
|
def shutdownVisibility(self):
|
||||||
|
taskMgr.remove(self.uniqueName(DistributedLevel.VisChangeTaskName))
|
||||||
|
|
||||||
def toonEnterZone(self, zoneNum, ouchLevel=None):
|
def toonEnterZone(self, zoneNum, ouchLevel=None):
|
||||||
"""
|
"""
|
||||||
zoneNum is an int.
|
zoneNum is an int.
|
||||||
@ -464,6 +477,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
def updateVisibility(self, zoneNum=None):
|
def updateVisibility(self, zoneNum=None):
|
||||||
"""update the visibility assuming that we're in the specified
|
"""update the visibility assuming that we're in the specified
|
||||||
zone; don't check to see if it's the zone we're already in"""
|
zone; don't check to see if it's the zone we're already in"""
|
||||||
|
#print 'updateVisibility %s' % globalClock.getFrameCount()
|
||||||
if zoneNum is None:
|
if zoneNum is None:
|
||||||
zoneNum = self.curZoneNum
|
zoneNum = self.curZoneNum
|
||||||
|
|
||||||
@ -535,6 +549,19 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
# Redo visibility using current zone num
|
# Redo visibility using current zone num
|
||||||
self.updateVisibility()
|
self.updateVisibility()
|
||||||
|
|
||||||
|
def handleVisChange(self):
|
||||||
|
"""the zone visibility lists have changed on-the-fly"""
|
||||||
|
Level.Level.handleVisChange(self)
|
||||||
|
self.visChangedThisFrame = 1
|
||||||
|
|
||||||
|
def visChangeTask(self, task):
|
||||||
|
# this runs just before igloop; if viz lists have changed
|
||||||
|
# this frame, updates the visibility and sends out a setZoneMsg
|
||||||
|
if self.visChangedThisFrame:
|
||||||
|
self.updateVisibility()
|
||||||
|
self.visChangedThisFrame = 0
|
||||||
|
return Task.cont
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
# level editing stuff
|
# level editing stuff
|
||||||
def setAttribChange(self, entId, attribName, valueStr, username):
|
def setAttribChange(self, entId, attribName, valueStr, username):
|
||||||
@ -543,11 +570,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
value = eval(valueStr)
|
value = eval(valueStr)
|
||||||
self.levelSpec.setAttribChange(entId, attribName, value, username)
|
self.levelSpec.setAttribChange(entId, attribName, value, username)
|
||||||
|
|
||||||
def handleVisChange(self):
|
|
||||||
"""the zone visibility lists have changed"""
|
|
||||||
Level.Level.handleVisChange(self)
|
|
||||||
self.updateVisibility()
|
|
||||||
|
|
||||||
def spawnTitleText(self):
|
def spawnTitleText(self):
|
||||||
def getDescription(zoneId, self=self):
|
def getDescription(zoneId, self=self):
|
||||||
entId = self.zoneNum2entId.get(zoneId)
|
entId = self.zoneNum2entId.get(zoneId)
|
||||||
|
@ -341,6 +341,10 @@ class Level:
|
|||||||
# with an editor
|
# with an editor
|
||||||
self.createdEntIds.remove(entId)
|
self.createdEntIds.remove(entId)
|
||||||
|
|
||||||
|
def handleVisChange(self):
|
||||||
|
"""the zone visibility lists have changed"""
|
||||||
|
pass
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
# the level generates these events when the spec changes
|
# the level generates these events when the spec changes
|
||||||
def getAttribChangeEventName(self):
|
def getAttribChangeEventName(self):
|
||||||
@ -380,7 +384,3 @@ class Level:
|
|||||||
entity.destroy()
|
entity.destroy()
|
||||||
# update our local type->entId table
|
# update our local type->entId table
|
||||||
self.entType2ids[self.getEntityType(entId)].remove(entId)
|
self.entType2ids[self.getEntityType(entId)].remove(entId)
|
||||||
|
|
||||||
def handleVisChange(self):
|
|
||||||
"""the zone visibility lists have changed"""
|
|
||||||
pass
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user