def unloadObjects(self): self.tempSections = {} self.sections = {} self.sectionObjs = set() self.visTable = {} self.largeObjectsVis = {} self.oldVis = NodePathCollection() AreaBuilderBase.unloadObjects(self)
def unloadObjects(self): self.tempSections = { } self.sections = { } self.sectionObjs = set() self.visTable = { } self.largeObjectsVis = { } self.oldVis = NodePathCollection() AreaBuilderBase.unloadObjects(self)
def removeLargeObj(self, geometry, uniqueId): AreaBuilderBase.removeLargeObj(self, geometry, uniqueId) if uniqueId not in self.largeObjects: return for zone in self.visTable: if uniqueId in self.visTable[zone][1]: self.visSets[zone].removePath(geometry) del self.largeObjects[uniqueId]
def removeSectionObj(self, geometry, visZone): if not visZone: return if geometry not in self.sectionObjs: return self.sectionObjs.remove(geometry) AreaBuilderBase.removeSectionObj(self, geometry, visZone) for zone in self.visHelper[visZone]: self.visSets[zone].removePath(geometry) self.visSets[visZone].removePath(geometry)
def _preSubObjectsStep(self): AreaBuilderBase._preSubObjectsStep(self) collisionSet = self.master.geom.findAllMatches('**/collision_zone_*;+s') for collision in collisionSet: name = collision.getName()[15:] section = self.createSection(name, collision) self.tempSections[name] = section self.setupSwitchDistances(section.lodRoot.node(), collision) self.visZoneMinimaps = base.worldCreator.uidVisZoneMinimaps.get(self.master.uniqueId, { }) self.visZoneTunnels = base.worldCreator.uidVisZoneTunnels.get(self.master.uniqueId, { })
def removeLargeObj(self, geometry, uniqueId): AreaBuilderBase.removeLargeObj(self, geometry, uniqueId) if uniqueId not in self.largeObjects: return None for zone in self.visTable: if uniqueId in self.visTable[zone][1]: self.visSets[zone].removePath(geometry) continue del self.largeObjects[uniqueId]
def _postSubObjectsStep(self): self.largeObjectsRoot.findAllMatches('**/collision_zone_*;+s').wrtReparentTo(self.collisions) for zone in self.tempSections.values(): zone.lodRoot.flattenStrong() if base.options.getTerrainDetailSetting() == 0: zone.lodRoot.getChild(0).reparentTo(zone) zone.lodRoot.detachNode() continue self.areaGeometry.setTag('VisZoneMinimaps', repr(self.visZoneMinimaps)) self.areaGeometry.setTag('VisZoneTunnels', repr(self.visZoneTunnels)) AreaBuilderBase._postSubObjectsStep(self)
def _postSubObjectsStep(self): self.largeObjectsRoot.findAllMatches( '**/collision_zone_*;+s').wrtReparentTo(self.collisions) for zone in self.tempSections.values(): zone.lodRoot.flattenStrong() if base.options.getTerrainDetailSetting() == 0: zone.lodRoot.getChild(0).reparentTo(zone) zone.lodRoot.detachNode() self.areaGeometry.setTag('VisZoneMinimaps', repr(self.visZoneMinimaps)) self.areaGeometry.setTag('VisZoneTunnels', repr(self.visZoneTunnels)) AreaBuilderBase._postSubObjectsStep(self)
def _postLoadStep(self): AreaBuilderBase._postLoadStep(self) self.accept('collisionLoopFinished', self.processCollisions) self.visTable = base.worldCreator.uidVisTables.get( self.master.uniqueId, {}) for section in self.master.geom.findAllMatches( '**/collision_zone_*') + self.areaGeometry.findAllMatches( '**/collision_zone_*'): uid = section.getTag('parentUid') if uid: self.sectionsToParent[section.getName()[15:]] = uid continue uid = section.getName()[15:] self.sectionsToParent[uid] = uid for (uid, obj) in self.largeObjects.iteritems(): visZone = obj.getTag('visZone') if visZone: visData = self.visTable.get(visZone) if visData: if uid not in visData[1]: visData[1].append(uid) adjTable = base.worldCreator.uidAdjTables.get(self.master.uniqueId) if adjTable: self.adjTable = adjTable for zone in self.visTable: self.effectsSets[zone] = set() self.setupCollisionSections() self.setupVisibleData() visZoneMaps = self.areaGeometry.getTag('VisZoneMinimaps') visZoneTunnels = self.areaGeometry.getTag('VisZoneTunnels') try: self.visZoneMinimaps = eval(visZoneMaps) except: base.cr.centralLogger.writeClientEvent( 'failed to load minimap zones for area %s, (%s)' % (self.master.uniqueId, visZoneMaps)) self.visZoneMinimaps = {} try: self.visZoneTunnels = eval(visZoneTunnels) except: base.cr.centralLogger.writeClientEvent( 'failed to load tunnel zones for area %s, (%s)' % (self.master.uniqueId, visZoneTunnels)) self.visZoneTunnels = {} self.areaGeometry.clearTag('VisZoneMinimaps') self.areaGeometry.clearTag('VisZoneTunnels')
def removeSectionObj(self, geometry, visZone): if not visZone: return None if geometry not in self.sectionObjs: return None self.sectionObjs.remove(geometry) AreaBuilderBase.removeSectionObj(self, geometry, visZone) for zone in self.visHelper[visZone]: self.visSets[zone].removePath(geometry) self.visSets[visZone].removePath(geometry)
def addLargeObj(self, geometry, uniqueId): AreaBuilderBase.addLargeObj(self, geometry, uniqueId) if not self.visSets: return if uniqueId not in self.largeObjects: for zone in self.visTable: if uniqueId in self.visTable[zone][1]: self.visSets[zone].addPath(geometry) self.largeObjects[uniqueId] = geometry geometry.stash() self.oldVis.stash() self.oldVis.unstash()
def _postLoadStep(self): AreaBuilderBase._postLoadStep(self) self.accept('collisionLoopFinished', self.processCollisions) self.visTable = base.worldCreator.uidVisTables.get(self.master.uniqueId, { }) for section in self.master.geom.findAllMatches('**/collision_zone_*') + self.areaGeometry.findAllMatches('**/collision_zone_*'): uid = section.getTag('parentUid') if uid: self.sectionsToParent[section.getName()[15:]] = uid continue uid = section.getName()[15:] self.sectionsToParent[uid] = uid for (uid, obj) in self.largeObjects.iteritems(): visZone = obj.getTag('visZone') if visZone: visData = self.visTable.get(visZone) if visData: if uid not in visData[1]: visData[1].append(uid) adjTable = base.worldCreator.uidAdjTables.get(self.master.uniqueId) if adjTable: self.adjTable = adjTable for zone in self.visTable: self.effectsSets[zone] = set() self.setupCollisionSections() self.setupVisibleData() visZoneMaps = self.areaGeometry.getTag('VisZoneMinimaps') visZoneTunnels = self.areaGeometry.getTag('VisZoneTunnels') try: self.visZoneMinimaps = eval(visZoneMaps) except: base.cr.centralLogger.writeClientEvent('failed to load minimap zones for area %s, (%s)' % (self.master.uniqueId, visZoneMaps)) self.visZoneMinimaps = { } try: self.visZoneTunnels = eval(visZoneTunnels) except: base.cr.centralLogger.writeClientEvent('failed to load tunnel zones for area %s, (%s)' % (self.master.uniqueId, visZoneTunnels)) self.visZoneTunnels = { } self.areaGeometry.clearTag('VisZoneMinimaps') self.areaGeometry.clearTag('VisZoneTunnels')
def cleanupData(self): AreaBuilderBase.cleanupData(self) self.oldVis = NodePathCollection() self.visZone = '' self.visSets = { } self.visHelper = { } self.visTable = { } self.terrainDict = { } self.tempSections = { } self.sections = { } self.objectSets = { } self.effectsSets = { } self.currEffectSet = set() self.sectionObjs = set() self.sectionsToParent = { } self.ignore('collisionLoopFinished')
def addLargeObj(self, geometry, uniqueId): AreaBuilderBase.addLargeObj(self, geometry, uniqueId) if not self.visSets: return None if uniqueId not in self.largeObjects: for zone in self.visTable: if uniqueId in self.visTable[zone][1]: self.visSets[zone].addPath(geometry) continue self.largeObjects[uniqueId] = geometry geometry.stash() self.oldVis.stash() self.oldVis.unstash()
def cleanupData(self): AreaBuilderBase.cleanupData(self) self.oldVis = NodePathCollection() self.visZone = '' self.visSets = {} self.visHelper = {} self.visTable = {} self.terrainDict = {} self.tempSections = {} self.sections = {} self.objectSets = {} self.effectsSets = {} self.currEffectSet = set() self.sectionObjs = set() self.sectionsToParent = {} self.ignore('collisionLoopFinished')
def __init__(self, master): AreaBuilderBase.__init__(self, master) self.doneParenting = False self.oldVis = NodePathCollection() self.visZone = '' self.potentialVisHeight = -10000 self.potentialVisZone = '' self.visSets = {} self.visTable = {} self.terrainDict = {} self.tempSections = {} self.sections = {} self.objectSets = {} self.effectsSets = {} self.currEffectSet = set() self.sectionObjs = set() self.sectionsToParent = {} self.visZoneMinimaps = {} self.visZoneTunnels = {}
def __init__(self, master): AreaBuilderBase.__init__(self, master) self.doneParenting = False self.oldVis = NodePathCollection() self.visZone = '' self.potentialVisHeight = -10000 self.potentialVisZone = '' self.visSets = { } self.visTable = { } self.terrainDict = { } self.tempSections = { } self.sections = { } self.objectSets = { } self.effectsSets = { } self.currEffectSet = set() self.sectionObjs = set() self.sectionsToParent = { } self.visZoneMinimaps = { } self.visZoneTunnels = { }
def registerMinimapObject(self, levelObj): node = AreaBuilderBase.registerMinimapObject(self, levelObj) if node: objData = levelObj.data visZone = objData.get('VisZone', '') if visZone: node.setTag('MinimapArea', str(self.visZoneMinimaps.get(visZone, 0))) return node elif levelObj.get('VisSize') == 'Large': node.setTag('MinimapArea', '0') return node
def addSectionObj(self, geometry, visZone, logError = 0): if not visZone or not (self.visHelper): return None if geometry in self.sectionObjs: return None if not self.visHelper.has_key(visZone): self.notify.warning('object %s tried to be placed in visZone %s, which does not exist in %s' % (str(geometry), str(visZone), str(self.master.uniqueId))) return None AreaBuilderBase.addSectionObj(self, geometry, visZone) self.sectionObjs.add(geometry) for zone in self.visHelper[visZone]: self.visSets[zone].addPath(geometry) self.visSets[visZone].addPath(geometry) if not (self.visZone) and visZone in self.visHelper[self.visZone] or visZone == self.visZone: geometry.unstash() else: geometry.stash()
def addSectionObj(self, geometry, visZone, logError=0): if not visZone or not self.visHelper: return if geometry in self.sectionObjs: return if not self.visHelper.has_key(visZone): self.notify.warning( 'object %s tried to be placed in visZone %s, which does not exist in %s' % (str(geometry), str(visZone), str(self.master.uniqueId))) return AreaBuilderBase.addSectionObj(self, geometry, visZone) self.sectionObjs.add(geometry) for zone in self.visHelper[visZone]: self.visSets[zone].addPath(geometry) self.visSets[visZone].addPath(geometry) if not self.visZone or visZone in self.visHelper[ self.visZone] or visZone == self.visZone: geometry.unstash() else: geometry.stash()
def checkForFootprint(self, levelObj, visZone): footprint = AreaBuilderBase.checkForFootprint(self, levelObj) if footprint: if visZone: footprint.setTag('VisZone Minimap', str(self.visZoneMinimaps.get(visZone, 0))) return footprint elif levelObj.get('VisSize') == 'Large': footprint.setTag('VisZone Minimap', '0') return footprint else: footprint.stash() return None
def addEffectObject(self, levelObj): visZone = levelObj.data.get('VisZone') visSize = levelObj.data.get('VisSize') if visZone: effectObj = NodePath(ModelNode(levelObj.data.get('EffectName'))) effectObj.node().setPreserveTransform(effectObj.node().PTLocal) section = self.tempSections.get(visZone) if visSize == 'Large' or section == None: effectObj.reparentTo(self.largeObjectsRoot) effectObj.setTag('uid', levelObj.uniqueId) self.largeObjects[levelObj.uniqueId] = effectObj else: effectObj.reparentTo(self.tempSections[visZone].effectsRoot) effectObj.setTransform(self.areaGeometry, levelObj.transform) else: return AreaBuilderBase.addEffectObject(self, levelObj)