def loadIKs(self, cid): nodeIdsMapping = [ i[0] for i in self.__modelsList ] turrets = [] for partName, ikData in self.__iks.iteritems(): for data in ikData: if data: ikSys = BigWorld.IKConstraintSystem() actuators = self.__findModel(partName) turrets += actuators gunners = self.__relationGunnerWithTurret[partName] linkedModels = ikSys.buildIKSystem(data, cid, gunners, actuators, nodeIdsMapping) self.__context.ikSystemByPart[partName] = ikSys if linkedModels and len(linkedModels) > 0: for modelId in linkedModels: hierarchyUpdates = [] linearHierarchy = self.__rootNode.linearHierarchy for parentId, node in linearHierarchy: if parentId == self.__modelsList[modelId][0]: try: hierarchyUpdates.append((node.id, node.name)) except HierarchyWorker.HardpointNotFound: debug_utils.LOG_WARNING_DEBUG('Hardpoint not found "{0}" in object "{1}, {2}"'.format(node.path, self.__context.objDBData.name, getattr(self.__context.objDBData, 'fileName', ''))) if modelId not in actuators: CompoundSystem.setModelFashion(cid, modelId, ikSys) CompoundSystem.setModelNodeSyncList(cid, modelId, hierarchyUpdates) self.__context.ikSystems.append(ikSys) else: debug_utils.LOG_WARNING('loadIKs - cant build complete IK model') CompoundSystem.swapModels(cid, turrets)
def unloadActiveMovie(self): self.unloadSubMovie() if self.__activeMovie is not None: activeMovieClassName = self.__activeMovie.className self.__prevActiveMovieClassName = activeMovieClassName debug_utils.LOG_DEBUG( 'unloadActiveMovie={0}'.format(activeMovieClassName), self.__activeMovie, self._initializeCalled) test = weakref.ref(self.__activeMovie) if self._initializeCalled: self._initializeCalled = False self.__activeMovie.call_1('dispose') self.__activeMovie.dispossessUI() self.__activeMovie.close() self.__activeMovie = None if test() is not None: import gc debug_utils.LOG_DEBUG('Screen referrers: ', gc.get_referrers(test())) if IS_DEVELOPMENT: import pprint pprint.pprint(gc.garbage) debug_utils.CRITICAL_ERROR( 'unloadActiveMovie: Screen {0} has refs'.format( activeMovieClassName)) else: debug_utils.LOG_ERROR( 'unloadActiveMovie: Screen {0} has refs'.format( activeMovieClassName)) if IS_DEVELOPMENT: callbacks = BigWorld.getCallbacks() if callbacks: debug_utils.LOG_WARNING( "don't canceled callbacks: {0}".format(callbacks)) return
def _weakMethodCall(selfWeak, methodWeak, predefArgs, predefKwargs, *args, **kwargs): self = selfWeak() if self is None: if _LOG_LEAKS: debug_utils.LOG_WARNING(_LOG_MSG, stack=True) return else: method = methodWeak() if methodWeak is None: if _LOG_LEAKS: debug_utils.LOG_WARNING(_LOG_MSG, stack=True) return finalArgs = predefArgs + args finalKwargs = predefKwargs finalKwargs.update(kwargs) method(self, *finalArgs, **finalKwargs) return
def _weakCall(callbackWeak, predefArgs, predefKwargs, *args, **kwargs): callback = callbackWeak() if callback: finalArgs = predefArgs + args finalKwargs = predefKwargs finalKwargs.update(kwargs) callback(*finalArgs, **finalKwargs) elif _LOG_LEAKS: debug_utils.LOG_WARNING(_LOG_MSG, stack=True)
def __updateClanEmblemClbk(self, emblemId, texture, size): if texture is not None: self.__updateClanEmblem(texture) else: debug_utils.LOG_WARNING('Failed to download embled id: %s!' % str(emblemId)) return
def setDecalsByIds(self, camouflageID, decalIDs): """init decals and camouflage""" surfaceSettings = self.__visualSettings.surfaceSettings if surfaceSettings: detail = surfaceSettings.detailTexture if detail != '': decalGroups = surfaceSettings.decalsSettings.decalGroups camouflageTexture = decalGroups['camouflage'].getDecalTexNameByID(camouflageID) selfShadow = '' glossinessOffset = 0.0 bottomColor = Math.Vector4(1, 1, 1, 1) reflectionColor = Math.Vector4(1, 1, 1, 1) camouflageMask = '' camouflageStub = Math.Vector4(0, 0, 0, 0) camouflageNeutral = Math.Vector4(0, 0, 0, 0) camouflageAllied = Math.Vector4(0, 0, 0, 0) camouflageHostile = Math.Vector4(0, 0, 0, 0) camuflageSettings = decalGroups['camouflage'].getDecal(camouflageID) if camuflageSettings is not None: if hasattr(camuflageSettings, 'glossinessOffset'): glossinessOffset = camuflageSettings.glossinessOffset if hasattr(camuflageSettings, 'bottomColor'): bottomColor = camuflageSettings.bottomColor if hasattr(camuflageSettings, 'camouflageMask'): camouflageMask = camuflageSettings.camouflageMask if hasattr(camuflageSettings, 'camouflageNeutral'): camouflageNeutral = camuflageSettings.camouflageNeutral if hasattr(camuflageSettings, 'camouflageAllied'): camouflageAllied = camuflageSettings.camouflageAllied if hasattr(camuflageSettings, 'camouflageHostile'): camouflageHostile = camuflageSettings.camouflageHostile if hasattr(camuflageSettings, 'reflectionColor'): reflectionColor = camuflageSettings.reflectionColor debug_utils.LOG_TRACE('ModelManipulator: setDecalsByIds', decalIDs) decals = [] if len(decalIDs) < clientConsts.DECAL_NUM_MIN: debug_utils.LOG_ERROR("Can't set decals: wrong decal list size!") else: if not consts.IS_EDITOR and clientConsts.ENABLE_PLANE_CLAN_EMBLEM: import BWPersonality env = GameEnvironment.getClientArena() allowBGLoading = False if env and env.isLoaded() else True if env: avatarInfo = env.getAvatarInfo(self.__context.entityId) clanDBID = avatarInfo.get('clanDBID') if clanDBID and int(clanDBID) > 0: ClanEmblemsCache.g_clanEmblemsCache.get(clanDBID, self.__updateClanEmblemClbk, not allowBGLoading) elif int(BWPersonality.g_initPlayerInfo.clanDBID) > 0: ClanEmblemsCache.g_clanEmblemsCache.get(BWPersonality.g_initPlayerInfo.clanDBID, self.__updateClanEmblemClbk, not allowBGLoading) specialNationalityDecalId = decalIDs[10] if len(decalIDs) > 10 else -1 clanBigId = 0 clanSmallId = 0 if specialNationalityDecalId == 0: clanBigId = clientConsts.DECAL_DEFAULT_VALUE[0] clanSmallId = clientConsts.DECAL_DEFAULT_VALUE[1] elif specialNationalityDecalId > 0: clanBigId = specialNationalityDecalId clanSmallId = specialNationalityDecalId decals.append(decalGroups['clan_big'].getDecalTexNameByID(clanBigId) if clanBigId > 0 else '') decals.append(decalGroups['clan_small'].getDecalTexNameByID(clanSmallId) if clanSmallId > 0 else '') if self.__clanEmblemFileNameCached: decals.append(self.__clanEmblemFileNameCached) else: decals.append('') decals.append(decalGroups['platoon_number'].getDecalTexNameByID(decalIDs[3]) if decalIDs[3] != clientConsts.DECAL_ISNT_EXIST_VALUE[3] else '') decals.append(decalGroups['member_number'].getDecalTexNameByID(decalIDs[4]) if decalIDs[4] != clientConsts.DECAL_ISNT_EXIST_VALUE[4] else '') decals.append(decalGroups['air_frags'].getDecalTexNameByID(decalIDs[5][0]) if decalIDs[5][0] != clientConsts.DECAL_ISNT_EXIST_VALUE[5] else '') decals.append(decalGroups['ground_frags'].getDecalTexNameByID(decalIDs[5][1]) if decalIDs[5][1] != clientConsts.DECAL_ISNT_EXIST_VALUE[5] else '') decals.append('') decals.append(decalGroups['nose'].getDecalTexNameByID(decalIDs[6]) if decalIDs[6] != clientConsts.DECAL_ISNT_EXIST_VALUE[6] else '') decals.append(decalGroups['decor'].getDecalTexNameByID(decalIDs[7]) if decalIDs[7] != clientConsts.DECAL_ISNT_EXIST_VALUE[7] else '') self.setSurfaceParameters(glossinessOffset, bottomColor, reflectionColor, camouflageStub, camouflageAllied, camouflageHostile, camouflageNeutral) self.setSurfaceTextures(detail, camouflageTexture, selfShadow, decals, camouflageMask) else: debug_utils.LOG_WARNING('Wrong detail texture in surfaceSettings.detailTexture') else: debug_utils.LOG_WARNING('Wrong surfaceSettings') return