mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
fixed door-not-opening bug
This commit is contained in:
parent
46f98ca7c3
commit
ec3bb127cd
@ -23,7 +23,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLevel')
|
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLevel')
|
||||||
|
|
||||||
WantVisibility = config.GetBool('level-visibility', 1)
|
WantVisibility = config.GetBool('level-visibility', 1)
|
||||||
HideZones = config.GetBool('level-hidezones', 1)
|
|
||||||
# set this to true to get all distrib objs when showing hidden zones
|
# set this to true to get all distrib objs when showing hidden zones
|
||||||
ColorZonesAllDOs = 0
|
ColorZonesAllDOs = 0
|
||||||
|
|
||||||
@ -435,7 +434,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
self.curZoneNum = None
|
self.curZoneNum = None
|
||||||
|
|
||||||
self.visChangedThisFrame = 0
|
self.visChangedThisFrame = 0
|
||||||
self.sentFirstSetZone = 0
|
self.fForceSetZoneThisFrame = 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):
|
||||||
@ -457,6 +456,8 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
if not DistributedLevel.WantVisibility:
|
if not DistributedLevel.WantVisibility:
|
||||||
zoneNums = list(self.zoneNums)
|
zoneNums = list(self.zoneNums)
|
||||||
zoneNums.remove(LevelConstants.UberZoneEntId)
|
zoneNums.remove(LevelConstants.UberZoneEntId)
|
||||||
|
# make sure a setZone goes out on the first frame
|
||||||
|
self.forceSetZoneThisFrame()
|
||||||
self.setVisibility(zoneNums)
|
self.setVisibility(zoneNums)
|
||||||
|
|
||||||
# send out any zone changes at the end of the frame, just before
|
# send out any zone changes at the end of the frame, just before
|
||||||
@ -579,45 +580,43 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
# this flag will prevent a network msg from being sent if
|
# this flag will prevent a network msg from being sent if
|
||||||
# the list of visible zones has not changed
|
# the list of visible zones has not changed
|
||||||
vizZonesChanged = 1
|
vizZonesChanged = 1
|
||||||
if DistributedLevel.HideZones:
|
# figure out which zones are new and which are going invisible
|
||||||
# figure out which zones are new and which are going invisible
|
# use dicts because 'x in dict' is faster than 'x in list'
|
||||||
# use dicts because it's faster to use dict.has_key(x)
|
addedZoneNums = []
|
||||||
# than 'x in list'
|
removedZoneNums = []
|
||||||
addedZoneNums = []
|
allVZ = dict(visibleZoneNums)
|
||||||
removedZoneNums = []
|
allVZ.update(self.curVisibleZoneNums)
|
||||||
allVZ = dict(visibleZoneNums)
|
for vz,dummy in allVZ.items():
|
||||||
allVZ.update(self.curVisibleZoneNums)
|
new = vz in visibleZoneNums
|
||||||
for vz,dummy in allVZ.items():
|
old = vz in self.curVisibleZoneNums
|
||||||
new = vz in visibleZoneNums
|
if new and old:
|
||||||
old = vz in self.curVisibleZoneNums
|
continue
|
||||||
if new and old:
|
if new:
|
||||||
continue
|
addedZoneNums.append(vz)
|
||||||
if new:
|
|
||||||
addedZoneNums.append(vz)
|
|
||||||
else:
|
|
||||||
removedZoneNums.append(vz)
|
|
||||||
|
|
||||||
if (not addedZoneNums) and (not removedZoneNums):
|
|
||||||
DistributedLevel.notify.info(
|
|
||||||
'visible zone list has not changed')
|
|
||||||
vizZonesChanged = 0
|
|
||||||
else:
|
else:
|
||||||
# show the new, hide the old
|
removedZoneNums.append(vz)
|
||||||
DistributedLevel.notify.info('showing zones %s' %
|
|
||||||
addedZoneNums)
|
if (not addedZoneNums) and (not removedZoneNums):
|
||||||
for az in addedZoneNums:
|
DistributedLevel.notify.info(
|
||||||
self.showZone(az)
|
'visible zone list has not changed')
|
||||||
DistributedLevel.notify.info('hiding zones %s' %
|
vizZonesChanged = 0
|
||||||
removedZoneNums)
|
else:
|
||||||
for rz in removedZoneNums:
|
# show the new, hide the old
|
||||||
self.hideZone(rz)
|
DistributedLevel.notify.info('showing zones %s' %
|
||||||
|
addedZoneNums)
|
||||||
|
for az in addedZoneNums:
|
||||||
|
self.showZone(az)
|
||||||
|
DistributedLevel.notify.info('hiding zones %s' %
|
||||||
|
removedZoneNums)
|
||||||
|
for rz in removedZoneNums:
|
||||||
|
self.hideZone(rz)
|
||||||
|
|
||||||
# it's important for us to send a setZone request on the first
|
# it's important for us to send a setZone request on the first
|
||||||
# frame, whether or not the visibility is different from what
|
# frame, whether or not the visibility is different from what
|
||||||
# we already have
|
# we already have
|
||||||
if vizZonesChanged or not self.sentFirstSetZone:
|
if vizZonesChanged or self.fForceSetZoneThisFrame:
|
||||||
self.setVisibility(visibleZoneNums.keys())
|
self.setVisibility(visibleZoneNums.keys())
|
||||||
self.sentFirstSetZone = 1
|
self.fForceSetZoneThisFrame = 0
|
||||||
|
|
||||||
self.curZoneNum = zoneNum
|
self.curZoneNum = zoneNum
|
||||||
self.curVisibleZoneNums = visibleZoneNums
|
self.curVisibleZoneNums = visibleZoneNums
|
||||||
@ -660,10 +659,14 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
Level.Level.handleVisChange(self)
|
Level.Level.handleVisChange(self)
|
||||||
self.visChangedThisFrame = 1
|
self.visChangedThisFrame = 1
|
||||||
|
|
||||||
|
def forceSetZoneThisFrame(self):
|
||||||
|
# call this to ensure that a setZone call will be generated this frame
|
||||||
|
self.fForceSetZoneThisFrame = 1
|
||||||
|
|
||||||
def visChangeTask(self, task):
|
def visChangeTask(self, task):
|
||||||
# this runs just before igloop; if viz lists have changed
|
# this runs just before igloop; if viz lists have changed
|
||||||
# this frame, updates the visibility and sends out a setZoneMsg
|
# this frame, updates the visibility and sends out a setZoneMsg
|
||||||
if self.visChangedThisFrame:
|
if self.visChangedThisFrame or self.fForceSetZoneThisFrame:
|
||||||
self.updateVisibility()
|
self.updateVisibility()
|
||||||
self.visChangedThisFrame = 0
|
self.visChangedThisFrame = 0
|
||||||
return Task.cont
|
return Task.cont
|
||||||
|
@ -22,21 +22,31 @@ class VisibilityBlocker:
|
|||||||
will be called when it's safe to show the new zones."""
|
will be called when it's safe to show the new zones."""
|
||||||
if self.__nextSetZoneDoneEvent is None:
|
if self.__nextSetZoneDoneEvent is None:
|
||||||
self.__nextSetZoneDoneEvent = self.level.cr.getNextSetZoneDoneEvent()
|
self.__nextSetZoneDoneEvent = self.level.cr.getNextSetZoneDoneEvent()
|
||||||
self.accept(self.__nextSetZoneDoneEvent, self.okToUnblockVis)
|
self.acceptOnce(self.__nextSetZoneDoneEvent, self.okToUnblockVis)
|
||||||
|
# make sure that a setZone is sent this frame, even if the
|
||||||
|
# visibility list doesn't change
|
||||||
|
self.level.forceSetZoneThisFrame()
|
||||||
|
|
||||||
def cancelUnblockVis(self):
|
def cancelUnblockVis(self):
|
||||||
"""derived class should call this if they have called requestUnblockVis,
|
"""
|
||||||
but no longer need that service. For example the user could have canceled
|
derived class should call this if they have called
|
||||||
the request that started the visibility change."""
|
requestUnblockVis, but no longer need that service. For example
|
||||||
|
the user could have canceled the request that started the
|
||||||
|
visibility change.
|
||||||
|
"""
|
||||||
if self.__nextSetZoneDoneEvent is not None:
|
if self.__nextSetZoneDoneEvent is not None:
|
||||||
self.ignore(self.__nextSetZoneDoneEvent)
|
self.ignore(self.__nextSetZoneDoneEvent)
|
||||||
self.__nextSetZoneDoneEvent = None
|
self.__nextSetZoneDoneEvent = None
|
||||||
|
|
||||||
def isWaitingForUnblockVis(self):
|
def isWaitingForUnblockVis(self):
|
||||||
"""returns a boolean for whether there is a requestUnblockVis() pending."""
|
"""
|
||||||
|
returns a boolean for whether there is a requestUnblockVis() pending.
|
||||||
|
"""
|
||||||
return self.__nextSetZoneDoneEvent is not None
|
return self.__nextSetZoneDoneEvent is not None
|
||||||
|
|
||||||
def okToUnblockVis(self):
|
def okToUnblockVis(self):
|
||||||
"""derived class should override this func and do the vis unblock
|
"""
|
||||||
(i.e. open the door, etc.)"""
|
derived class should override this func and do the vis unblock
|
||||||
|
(i.e. open the door, etc.)
|
||||||
|
"""
|
||||||
self.cancelUnblockVis()
|
self.cancelUnblockVis()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user