mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
reorganized visibility code
This commit is contained in:
parent
e6892c02bf
commit
57c73945a6
@ -88,19 +88,19 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
|
|
||||||
# find the zones in the model and fix them up
|
# find the zones in the model and fix them up
|
||||||
self.zoneNum2Node = findNumberedNodes('Zone')
|
self.zoneNum2Node = findNumberedNodes('Zone')
|
||||||
# add the UberZone
|
# add the UberZone to the table
|
||||||
self.zoneNum2Node[0] = self.geom
|
self.zoneNum2Node[0] = self.geom
|
||||||
|
|
||||||
self.zoneNums = self.zoneNum2Node.keys()
|
self.zoneNums = self.zoneNum2Node.keys()
|
||||||
|
# take the UberZone out of the list
|
||||||
|
self.zoneNums.remove(0)
|
||||||
self.zoneNums.sort()
|
self.zoneNums.sort()
|
||||||
self.notify.debug('zones: %s' % self.zoneNums)
|
self.notify.debug('zones: %s' % self.zoneNums)
|
||||||
assert sameElements(self.zoneNums, self.spec['zones'].keys() + [0])
|
assert sameElements(self.zoneNums, self.spec['zones'].keys())
|
||||||
|
|
||||||
# fix up the floor collisions for walkable zones
|
# fix up the floor collisions for walkable zones
|
||||||
for zoneNum, zoneNode in self.zoneNum2Node.items():
|
for zoneNum in self.zoneNums:
|
||||||
# skip the UberZone
|
zoneNode = self.zoneNum2Node[zoneNum]
|
||||||
if zoneNum == 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# if this is a walkable zone, fix up the model
|
# if this is a walkable zone, fix up the model
|
||||||
floorColls = zoneNode.findAllMatches('**/+CollisionNode').asList()
|
floorColls = zoneNode.findAllMatches('**/+CollisionNode').asList()
|
||||||
@ -244,17 +244,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
node = self.zoneNum2Node[zone]
|
node = self.zoneNum2Node[zone]
|
||||||
node.setAlphaScale(alpha)
|
node.setAlphaScale(alpha)
|
||||||
|
|
||||||
def sendSetZone(self, curZone, vizList):
|
|
||||||
# convert the zone numbers into their actual zoneIds
|
|
||||||
# always include Toontown uberZone
|
|
||||||
visibleZoneIds = [ToontownGlobals.UberZone]
|
|
||||||
for vz in vizList:
|
|
||||||
visibleZoneIds.append(self.getZoneId(vz))
|
|
||||||
assert(uniqueElements(visibleZoneIds))
|
|
||||||
self.notify.debug('new viz list: %s' % visibleZoneIds)
|
|
||||||
|
|
||||||
toonbase.tcr.sendSetZoneMsg(self.getZoneId(curZone), visibleZoneIds)
|
|
||||||
|
|
||||||
def initVisibility(self):
|
def initVisibility(self):
|
||||||
# start out with every zone visible, since none of the zones have
|
# start out with every zone visible, since none of the zones have
|
||||||
# been hidden
|
# been hidden
|
||||||
@ -264,8 +253,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
|
|
||||||
# if no viz, listen to all the zones
|
# if no viz, listen to all the zones
|
||||||
if not DistributedLevel.WantVisibility:
|
if not DistributedLevel.WantVisibility:
|
||||||
zones = list(self.zoneNums)
|
self.setVisibility(self.zoneNums)
|
||||||
self.sendSetZone(0, zones)
|
|
||||||
|
|
||||||
def toonEnterZone(self, zoneNum):
|
def toonEnterZone(self, zoneNum):
|
||||||
self.notify.debug('toonEnterZone%s' % zoneNum)
|
self.notify.debug('toonEnterZone%s' % zoneNum)
|
||||||
@ -275,7 +263,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
self.enterZone(zoneNum)
|
self.enterZone(zoneNum)
|
||||||
|
|
||||||
def enterZone(self, zoneNum):
|
def enterZone(self, zoneNum):
|
||||||
self.notify.debug("switching to zone %s" % zoneNum)
|
self.notify.debug("entering zone %s" % zoneNum)
|
||||||
|
|
||||||
if not DistributedLevel.WantVisibility:
|
if not DistributedLevel.WantVisibility:
|
||||||
return
|
return
|
||||||
@ -285,7 +273,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
|
|
||||||
zoneSpec = self.spec['zones'][zoneNum]
|
zoneSpec = self.spec['zones'][zoneNum]
|
||||||
# use dicts to efficiently ensure that there are no duplicates
|
# use dicts to efficiently ensure that there are no duplicates
|
||||||
visibleZoneNums = list2dict([0, zoneNum])
|
visibleZoneNums = list2dict([zoneNum])
|
||||||
visibleZoneNums.update(list2dict(zoneSpec['visibility']))
|
visibleZoneNums.update(list2dict(zoneSpec['visibility']))
|
||||||
|
|
||||||
if DistributedLevel.HideZones:
|
if DistributedLevel.HideZones:
|
||||||
@ -313,11 +301,24 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
for rz in removedZoneNums:
|
for rz in removedZoneNums:
|
||||||
self.hideZone(rz)
|
self.hideZone(rz)
|
||||||
|
|
||||||
self.sendSetZone(zoneNum, visibleZoneNums.keys())
|
self.setVisibility(visibleZoneNums.keys())
|
||||||
|
|
||||||
self.curZoneNum = zoneNum
|
self.curZoneNum = zoneNum
|
||||||
self.curVisibleZoneNums = visibleZoneNums
|
self.curVisibleZoneNums = visibleZoneNums
|
||||||
|
|
||||||
|
def setVisibility(self, vizList):
|
||||||
|
# accepts list of visible zone numbers
|
||||||
|
# convert the zone numbers into their actual zoneIds
|
||||||
|
# always include Toontown and factory uberZones
|
||||||
|
factoryUberZone = self.getZoneId(0)
|
||||||
|
visibleZoneIds = [ToontownGlobals.UberZone, factoryUberZone]
|
||||||
|
for vz in vizList:
|
||||||
|
visibleZoneIds.append(self.getZoneId(vz))
|
||||||
|
assert(uniqueElements(visibleZoneIds))
|
||||||
|
self.notify.debug('new viz list: %s' % visibleZoneIds)
|
||||||
|
|
||||||
|
toonbase.tcr.sendSetZoneMsg(factoryUberZone, visibleZoneIds)
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
# level editing stuff
|
# level editing stuff
|
||||||
def setAttribChange(self, entId, attribName, valueStr):
|
def setAttribChange(self, entId, attribName, valueStr):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user