예제 #1
0
파일: PackageInfo.py 프로젝트: PlumpMath/gs
 def __init__(self, func, bytes, factor, stepType):
     self.__funcPtr = func
     self.bytesNeeded = bytes
     self.bytesDone = 0
     self.bytesFactor = factor
     self.stepType = stepType
     self.pStatCol = PStatCollector(':App:PackageInstaller:%s' % (stepType))
def profile(func):
    """ Handy decorator which can be used to profile a function with pstats """
    collector_name = "Debug:%s" % func.__name__

    global_showbase = Globals.base

    # Insert the collector to a custom dictionary attached to the base
    if hasattr(global_showbase, 'custom_collectors'):
        if collector_name in global_showbase.custom_collectors.keys():
            pstat = global_showbase.custom_collectors[collector_name]
        else:
            global_showbase.custom_collectors[collector_name] = \
                PStatCollector(collector_name)
            pstat = global_showbase.custom_collectors[collector_name]
    else:
        pstat = PStatCollector(collector_name)
        global_showbase.custom_collectors = {}
        global_showbase.custom_collectors[collector_name] = pstat

    def do_pstat(*args, **kargs):
        pstat.start()
        returned = func(*args, **kargs)
        pstat.stop()
        return returned

    do_pstat.__name__ = func.__name__
    do_pstat.__dict__ = func.__dict__
    do_pstat.__doc__ = func.__doc__
    return do_pstat
예제 #3
0
파일: support.py 프로젝트: viatoriche/suber
def pstat(func):
    """Decorator for pstats
    """
    collectorName = "Debug:%s" % func.__name__
    if hasattr(b_collector, 'custom_collectors'):
        if collectorName in b_collector.custom_collectors.keys():
            pstat = b_collector.custom_collectors[collectorName]
        else:
            b_collector.custom_collectors[collectorName] = PStatCollector(
                collectorName)
            pstat = b_collector.custom_collectors[collectorName]
    else:
        b_collector.custom_collectors = {}
        b_collector.custom_collectors[collectorName] = PStatCollector(
            collectorName)
        pstat = b_collector.custom_collectors[collectorName]
    b_collector.custom_collectors = {}
    b_collector.custom_collectors[collectorName] = PStatCollector(
        collectorName)
    pstat = b_collector.custom_collectors[collectorName]

    def doPstat(*args, **kargs):
        pstat.start()
        returned = func(*args, **kargs)
        pstat.stop()
        return returned

    doPstat.__name__ = func.__name__
    doPstat.__dict__ = func.__dict__
    doPstat.__doc__ = func.__doc__
    return doPstat
예제 #4
0
    def processEventPstats(self, event):
        """
        Process a C++ event with pstats tracking
        Duplicate any changes in processEvent
        """
        # ********************************************************
        # ******** Duplicate any changes in processEvent *********
        # ********************************************************
        # Get the event name
        eventName = event.getName()
        if eventName:
            paramList = []
            for i in range(event.getNumParameters()):
                eventParameter = event.getParameter(i)
                eventParameterData = self.parseEventParameter(eventParameter)
                paramList.append(eventParameterData)
            # Do not print the new frame debug, it is too noisy!
            if (EventManager.notify.getDebug() and eventName != 'NewFrame'):
                EventManager.notify.debug('received C++ event named: ' + eventName +
                                          ' parameters: ' + repr(paramList))
            # Send the event, we used to send it with the event
            # name as a parameter, but now you can use extraArgs for that
            # ********************************************************
            # ******** Duplicate any changes in processEvent *********
            # ********************************************************
            if self._wantPstats:
                name = eventName
                hyphen = name.find('-')
                if hyphen >= 0:
                    name = name[0:hyphen]
                pstatCollector = PStatCollector('App:Show code:eventManager:' + name)
                pstatCollector.start()
                if self.eventHandler:
                    cppPstatCollector = PStatCollector(
                        'App:Show code:eventManager:' + name + ':C++')

            if paramList:
                messenger.send(eventName, paramList)
            else:
                messenger.send(eventName)
            # Also send the event down into C++ land
            if self.eventHandler:
                if self._wantPstats:
                    cppPstatCollector.start()
                self.eventHandler.dispatchEvent(event)
            # ********************************************************
            # ******** Duplicate any changes in processEvent *********
            # ********************************************************

            if self._wantPstats:
                if self.eventHandler:
                    cppPstatCollector.stop()
                pstatCollector.stop()

        else:
            # An unnamed event from C++ is probably a bad thing
            EventManager.notify.warning('unnamed event in processEvent')
예제 #5
0
 def __init__(self, func, bytes, factor, stepType):
     self.__funcPtr = func
     self.bytesNeeded = bytes
     self.bytesDone = 0
     self.bytesFactor = factor
     self.stepType = stepType
     self.pStatCol = PStatCollector(':App:PackageInstaller:%s' % (stepType))
예제 #6
0
파일: core.py 프로젝트: thetestgame/wecs
    def add_system(self, system, sort, priority=None):
        """
        Registers an additional system in the world.
        The world will use the standard panda3D taskManager to ensure the system
        is run on every tick.

        :param system: Instance of a :class:`wecs.core.System`
        :param sort: `sort` parameter for the task running the system
        :param priority: Optional `priority` parameter for the task running the system
        :return: Panda3D PythonTask

        """
        logging.info(f"in {__name__} got {system}, {sort}, {priority}")
        if priority is None:
            priority = 0
        wecs_sort = (sort, -priority)

        self.ecs_world.add_system(system, wecs_sort)
        task = base.task_mgr.add(
            self.run_system,
            repr(system),
            extraArgs=[system],
            sort=sort,
            priority=priority,
        )
        self.ecs_system_pstats[system] = PStatCollector(
            'App:WECS:Systems:{}'.format(system))

        system_type = type(system)
        data = (system_type, task, wecs_sort)
        self.task_to_data[task] = data
        self.system_to_data[system_type] = data
        return task
    def __downloadPackageTask(self, task):

        """ This task runs on the aysynchronous task chain; each pass,
        it extracts one package from self.needsDownload and downloads
        it. """

        while True:
            self.packageLock.acquire()
            try:
                # If we're done downloading, stop the task.
                if self.state == self.S_done or not self.needsDownload:
                    self.downloadTask = None
                    self.packageLock.release()
                    yield task.done; return

                assert self.state == self.S_started
                pp = self.needsDownload[0]
                del self.needsDownload[0]
            except:
                self.packageLock.release()
                raise
            self.packageLock.release()

            # Now serve this one package.
            eventName = 'PackageInstaller-%s-packageStarted' % self.uniqueId
            messenger.send(eventName, [pp], taskChain = 'default')

            if not pp.package.hasPackage:
                for token in pp.package.downloadPackageGenerator(self.appRunner.http):
                    if token == pp.package.stepContinue:
                        yield task.cont
                    else:
                        break

                if token != pp.package.stepComplete:
                    pc = PStatCollector(':App:PackageInstaller:donePackage:%s' % (pp.package.packageName))
                    pc.start()
                    self.__donePackage(pp, False)
                    pc.stop()
                    yield task.cont
                    continue

            # Successfully downloaded and installed.
            pc = PStatCollector(':App:PackageInstaller:donePackage:%s' % (pp.package.packageName))
            pc.start()
            self.__donePackage(pp, True)
            pc.stop()
예제 #8
0
class BaseManager(DebugObject):

    """ Base class for all managers, provides utility functions like timing
    the update duration """

    def __init__(self):
        """ Inits the manager """
        self._mgr_name = self.__class__.__name__
        DebugObject.__init__(self, self._mgr_name)
        self._update_collector = PStatCollector("App:Show code:RP_UpdateManagers:" + self._mgr_name)
        assert hasattr(self, "do_update")

    def update(self):
        """ Updates the manager, this just calls the do_update() method and
        times it """
        self._update_collector.start()
        self.do_update()
        self._update_collector.stop()
예제 #9
0
 def __init__(self, name):
     self._name = name
     self._generator = None
     self._id = Job._SerialGen.next()
     self._printing = False
     self._priority = Job.Priorities.Normal
     self._finished = False
     if __debug__:
         self._pstats = PStatCollector("App:Show code:jobManager:%s" %
                                       self._name)
예제 #10
0
def pstat(func):
    pstat = PStatCollector('kolektor')
    def doPstat(*args, **kargs):
        pstat.start()
        returned = func(*args, **kargs)
        pstat.stop()
        return returned
    doPstat.__name__ = func.__name__
    doPstat.__dict__ = func.__dict__
    doPstat.__doc__ = func.__doc__
    return doPstat
예제 #11
0
파일: core.py 프로젝트: janEntikan/wecs
 def add_system(self, system, sort):
     self.ecs_world.add_system(system, sort)
     task = base.task_mgr.add(
         self.run_system,
         repr(system),
         extraArgs=[system],
         sort=sort,
     )
     self.ecs_system_pstats[system] = PStatCollector(
         'App:WECS:Systems:{}'.format(system))
     return task
예제 #12
0
    def __donePackage(self, pp, success):
        """ Marks the indicated package as done, either successfully
        or otherwise. """
        assert not pp.done

        if success:
            pc = PStatCollector(':App:PackageInstaller:install:%s' %
                                (pp.package.packageName))
            pc.start()
            pp.package.installPackage(self.appRunner)
            pc.stop()

        self.packageLock.acquire()
        try:
            pp.done = True
            pp.success = success
            if success:
                self.done.append(pp)
            else:
                self.failed.append(pp)
        finally:
            self.packageLock.release()

        eventName = 'PackageInstaller-%s-packageDone' % self.uniqueId
        messenger.send(eventName, [pp], taskChain='default')
예제 #13
0
class BaseManager(DebugObject):

    """ Base class for all managers, provides utility functions like timing
    the update duration """

    def __init__(self):
        """ Inits the manager """
        self._mgr_name = self.__class__.__name__
        DebugObject.__init__(self, self._mgr_name)
        self._update_collector = PStatCollector(
            "App:Show code:RP_UpdateManagers:" + self._mgr_name)

    def update(self):
        """ Updates the manager, this just calls the do_update() method and
        times it """
        self._update_collector.start()
        self.do_update()
        self._update_collector.stop()

    def do_update(self):
        """ Abstract update method, all managers should implement this """
        raise NotImplementedError()
예제 #14
0
def pstat(func):
    collectorName = "%s:%s" % ('Engine', func.__name__)
    if not collectorName in custom_collectors.keys():
        custom_collectors[collectorName] = PStatCollector(collectorName)
    pstat = custom_collectors[collectorName]

    @wraps(func)
    def doPstat(*args, **kargs):
        pstat.start()
        returned = func(*args, **kargs)
        pstat.stop()
        return returned

    return doPstat
    def __donePackage(self, pp, success):
        """ Marks the indicated package as done, either successfully
        or otherwise. """
        assert not pp.done

        if success:
            pc = PStatCollector(':App:PackageInstaller:install:%s' % (pp.package.packageName))
            pc.start()
            pp.package.installPackage(self.appRunner)
            pc.stop()

        self.packageLock.acquire()
        try:
            pp.done = True
            pp.success = success
            if success:
                self.done.append(pp)
            else:
                self.failed.append(pp)
        finally:
            self.packageLock.release()

        eventName = 'PackageInstaller-%s-packageDone' % self.uniqueId
        messenger.send(eventName, [pp], taskChain = 'default')
예제 #16
0
    class InstallStep:
        """ This class is one step of the installPlan list; it
        represents a single atomic piece of the installation step, and
        the relative effort of that piece.  When the plan is executed,
        it will call the saved function pointer here. """
        def __init__(self, func, bytes, factor, stepType):
            self.__funcPtr = func
            self.bytesNeeded = bytes
            self.bytesDone = 0
            self.bytesFactor = factor
            self.stepType = stepType
            self.pStatCol = PStatCollector(':App:PackageInstaller:%s' %
                                           (stepType))

        def func(self):
            """ self.__funcPtr(self) will return a generator of
            tokens.  This function defines a new generator that yields
            each of those tokens, but wraps each call into the nested
            generator within a pair of start/stop collector calls. """

            self.pStatCol.start()
            for token in self.__funcPtr(self):
                self.pStatCol.stop()
                yield token
                self.pStatCol.start()

            # Shouldn't ever get here.
            self.pStatCol.stop()
            raise StopIteration

        def getEffort(self):
            """ Returns the relative amount of effort of this step. """
            return self.bytesNeeded * self.bytesFactor

        def getProgress(self):
            """ Returns the progress of this step, in the range
            0..1. """
            if self.bytesNeeded == 0:
                return 1
            return min(float(self.bytesDone) / float(self.bytesNeeded), 1)
예제 #17
0
    class InstallStep:
        """ This class is one step of the installPlan list; it
        represents a single atomic piece of the installation step, and
        the relative effort of that piece.  When the plan is executed,
        it will call the saved function pointer here. """
        def __init__(self, func, bytes, factor, stepType):
            self.__funcPtr = func
            self.bytesNeeded = bytes
            self.bytesDone = 0
            self.bytesFactor = factor
            self.stepType = stepType
            self.pStatCol = PStatCollector(':App:PackageInstaller:%s' % (stepType))

        def func(self):
            """ self.__funcPtr(self) will return a generator of
            tokens.  This function defines a new generator that yields
            each of those tokens, but wraps each call into the nested
            generator within a pair of start/stop collector calls. """

            self.pStatCol.start()
            for token in self.__funcPtr(self):
                self.pStatCol.stop()
                yield token
                self.pStatCol.start()

            # Shouldn't ever get here.
            self.pStatCol.stop()
            raise StopIteration

        def getEffort(self):
            """ Returns the relative amount of effort of this step. """
            return self.bytesNeeded * self.bytesFactor

        def getProgress(self):
            """ Returns the progress of this step, in the range
            0..1. """
            if self.bytesNeeded == 0:
                return 1
            return min(float(self.bytesDone) / float(self.bytesNeeded), 1)
예제 #18
0
from panda3d.core import LVecBase2i, ShaderAttrib, UnalignedLVecBase4f
from panda3d.core import ComputeNode, LVecBase4i, GraphicsOutput, SamplerState


from Light import Light
from DebugObject import DebugObject
from BetterShader import BetterShader
from RenderTarget import RenderTarget
from ShadowSource import ShadowSource
from ShadowAtlas import ShadowAtlas
from ShaderStructArray import ShaderStructArray
from Globals import Globals

from panda3d.core import PStatCollector

pstats_ProcessLights = PStatCollector("App:LightManager:ProcessLights")
pstats_CullLights = PStatCollector("App:LightManager:CullLights")
pstats_PerLightUpdates = PStatCollector("App:LightManager:PerLightUpdates")
pstats_FetchShadowUpdates = PStatCollector(
    "App:LightManager:FetchShadowUpdates")


class LightManager(DebugObject):

    """ This class is internally used by the RenderingPipeline to handle
    Lights and their Shadows. It stores a list of lights, and updates the
    required ShadowSources per frame. There are two main update methods:

    updateLights processes each light and does a basic frustum check.
    If the light is in the frustum, its ID is passed to the light precompute
    container (set with setLightingCuller). Also, each shadowSource of
예제 #19
0
    def __downloadPackageTask(self, task):
        """ This task runs on the aysynchronous task chain; each pass,
        it extracts one package from self.needsDownload and downloads
        it. """

        while True:
            self.packageLock.acquire()
            try:
                # If we're done downloading, stop the task.
                if self.state == self.S_done or not self.needsDownload:
                    self.downloadTask = None
                    self.packageLock.release()
                    yield task.done
                    return

                assert self.state == self.S_started
                pp = self.needsDownload[0]
                del self.needsDownload[0]
            except:
                self.packageLock.release()
                raise
            self.packageLock.release()

            # Now serve this one package.
            eventName = 'PackageInstaller-%s-packageStarted' % self.uniqueId
            messenger.send(eventName, [pp], taskChain='default')

            if not pp.package.hasPackage:
                for token in pp.package.downloadPackageGenerator(
                        self.appRunner.http):
                    if token == pp.package.stepContinue:
                        yield task.cont
                    else:
                        break

                if token != pp.package.stepComplete:
                    pc = PStatCollector(
                        ':App:PackageInstaller:donePackage:%s' %
                        (pp.package.packageName))
                    pc.start()
                    self.__donePackage(pp, False)
                    pc.stop()
                    yield task.cont
                    continue

            # Successfully downloaded and installed.
            pc = PStatCollector(':App:PackageInstaller:donePackage:%s' %
                                (pp.package.packageName))
            pc.start()
            self.__donePackage(pp, True)
            pc.stop()
예제 #20
0
from panda3d.core import Vec3, Point3, Quat, BitMask32, TransformState, MeshDrawer, Vec4, LineSegs, NodePath, PStatCollector
from panda3d.bullet import BulletCapsuleShape, BulletRigidBodyNode, BulletGhostNode, BulletSphereShape

from direct.showbase.DirectObject import DirectObject

from src.coginvasion.globals import CIGlobals
from src.coginvasion.phys import PhysicsUtils

import math

updateCollector = PStatCollector("App:PhysController:Update")
testDnCollector = PStatCollector("App:PhysController:TestDown")

updFootContactCollector = PStatCollector("App:PhysController:UpdateFootContact")
updEventSphCollector = PStatCollector("App:PhysController:UpdateEventSphere")
updHeadContactCollector = PStatCollector("App:PhysController:UpdateHeadContact")

prevPeneCollector = PStatCollector("App:PhysController:PreventPenetration")
sweepCollector = PStatCollector("App:PhysController:PreventPenetration:DoSweepTest")
testUpCollector = PStatCollector("App:PhysController:UpdateFootContact:TestUp")
rtaCollector = PStatCollector("App:PhysController:UpdateFootContact:RayTestAll")
sortCollector = PStatCollector("App:PhysController:UpdateFootContact:SortHits")
iterateCollector = PStatCollector("App:PhysController:UpdateFootContact:Iterate")
iterationsCollector = PStatCollector("Phys Controller Iterations")

procGroundCollector = PStatCollector("App:PhysController:ProcessGround")
procFallCollector = PStatCollector("App:PhysController:ProcessFalling")
procJmpCollector = PStatCollector("App:PhysController:ProcessJumping")
procSwimCollector = PStatCollector("App:PhysController:ProcessSwimming")

예제 #21
0
from DebugObject import DebugObject
from panda3d.core import PTAInt, PTAFloat, PTAMat4
from panda3d.core import PTALVecBase2f, PTALVecBase3f
from panda3d.core import PStatCollector

pstats_SetShaderInputs = PStatCollector("App:ShaderStructArray:SetShaderInputs")



ShaderStructElementInstances = []
ShaderStructArrays = []

class ShaderStructElement:

    """ Classes which should be passed to a ShaderStructArray have
    to be subclasses of this class """

    @classmethod
    def getExposedAttributes(self):
        """ Subclasses should implement this method, and return a
        dictionary of values to expose to the shader. A sample
        return value might be:

        return {
            "someVector": "vec3",
            "someColor": "vec3",
            "someInt": "int",
            "someFloat": "float",
            "someArray": "array<int>(6)",
        }
예제 #22
0
    def processEventPstats(self, event):
        """
        Process a C++ event with pstats tracking
        Duplicate any changes in processEvent
        """
        # ********************************************************
        # ******** Duplicate any changes in processEvent *********
        # ********************************************************
        # Get the event name
        eventName = event.name
        if eventName:
            paramList = []
            for eventParameter in event.parameters:
                eventParameterData = self.parseEventParameter(eventParameter)
                paramList.append(eventParameterData)

            # Do not print the new frame debug, it is too noisy!
            if EventManager.notify.getDebug() and eventName != 'NewFrame':
                EventManager.notify.debug('received C++ event named: ' +
                                          eventName + ' parameters: ' +
                                          repr(paramList))
            # Send the event, we used to send it with the event
            # name as a parameter, but now you can use extraArgs for that
            # ********************************************************
            # ******** Duplicate any changes in processEvent *********
            # ********************************************************
            name = eventName
            hyphen = name.find('-')
            if hyphen >= 0:
                name = name[0:hyphen]
            pstatCollector = PStatCollector('App:Show code:eventManager:' +
                                            name)
            pstatCollector.start()
            if self.eventHandler:
                cppPstatCollector = PStatCollector(
                    'App:Show code:eventManager:' + name + ':C++')

            messenger.send(eventName, paramList)

            # Also send the event down into C++ land
            handler = self.eventHandler
            if handler:
                cppPstatCollector.start()
                handler.dispatchEvent(event)
                cppPstatCollector.stop()

            pstatCollector.stop()

        else:
            # An unnamed event from C++ is probably a bad thing
            EventManager.notify.warning('unnamed event in processEvent')
예제 #23
0
    def __buildInstallPlans(self):
        """ Sets up self.installPlans, a list of one or more "plans"
        to download and install the package. """

        pc = PStatCollector(':App:PackageInstaller:buildInstallPlans')
        pc.start()

        self.hasPackage = False

        if self.host.appRunner and self.host.appRunner.verifyContents == self.host.appRunner.P3DVCNever:
            # We're not allowed to download anything.
            self.installPlans = []
            pc.stop()
            return

        if self.asMirror:
            # If we're just downloading a mirror archive, we only need
            # to get the compressed archive file.

            # Build a one-item install plan to download the compressed
            # archive.
            downloadSize = self.compressedArchive.size
            func = lambda step, fileSpec = self.compressedArchive: self.__downloadFile(step, fileSpec, allowPartial = True)

            step = self.InstallStep(func, downloadSize, self.downloadFactor, 'download')
            installPlan = [step]
            self.installPlans = [installPlan]
            pc.stop()
            return

        # The normal download process.  Determine what we will need to
        # download, and build a plan (or two) to download it all.
        self.installPlans = None

        # We know we will at least need to unpack the archive contents
        # at the end.
        unpackSize = 0
        for file in self.extracts:
            unpackSize += file.size
        step = self.InstallStep(self.__unpackArchive, unpackSize, self.unpackFactor, 'unpack')
        planA = [step]

        # If the uncompressed archive file is good, that's all we'll
        # need to do.
        self.uncompressedArchive.actualFile = None
        if self.uncompressedArchive.quickVerify(self.getPackageDir(), notify = self.notify):
            self.installPlans = [planA]
            pc.stop()
            return

        # Maybe the compressed archive file is good.
        if self.compressedArchive.quickVerify(self.getPackageDir(), notify = self.notify):
            uncompressSize = self.uncompressedArchive.size
            step = self.InstallStep(self.__uncompressArchive, uncompressSize, self.uncompressFactor, 'uncompress')
            planA = [step] + planA
            self.installPlans = [planA]
            pc.stop()
            return

        # Maybe we can download one or more patches.  We'll come back
        # to that in a minute as plan A.  For now, construct plan B,
        # which will be to download the whole archive.
        planB = planA[:]

        uncompressSize = self.uncompressedArchive.size
        step = self.InstallStep(self.__uncompressArchive, uncompressSize, self.uncompressFactor, 'uncompress')
        planB = [step] + planB

        downloadSize = self.compressedArchive.size
        func = lambda step, fileSpec = self.compressedArchive: self.__downloadFile(step, fileSpec, allowPartial = True)

        step = self.InstallStep(func, downloadSize, self.downloadFactor, 'download')
        planB = [step] + planB

        # Now look for patches.  Start with the md5 hash from the
        # uncompressedArchive file we have on disk, and see if we can
        # find a patch chain from this file to our target.
        pathname = Filename(self.getPackageDir(), self.uncompressedArchive.filename)
        fileSpec = self.uncompressedArchive.actualFile
        if fileSpec is None and pathname.exists():
            fileSpec = FileSpec()
            fileSpec.fromFile(self.getPackageDir(), self.uncompressedArchive.filename)
        plan = None
        if fileSpec:
            plan = self.__findPatchChain(fileSpec)
        if plan:
            # We can download patches.  Great!  That means this is
            # plan A, and the full download is plan B (in case
            # something goes wrong with the patching).
            planA = plan + planA
            self.installPlans = [planA, planB]
        else:
            # There are no patches to download, oh well.  Stick with
            # plan B as the only plan.
            self.installPlans = [planB]

        # In case of unexpected failures on the internet, we will retry
        # the full download instead of just giving up.
        retries = core.ConfigVariableInt('package-full-dl-retries', 1).getValue()
        for retry in range(retries):
            self.installPlans.append(planB[:])

        pc.stop()
예제 #24
0
def levelpstat(name, category='Engine'):
    collectorName = category + ':' + name
    if not collectorName in custom_collectors.keys():
        custom_collectors[collectorName] = PStatCollector(collectorName)
    pstat = custom_collectors[collectorName]
    return pstat
예제 #25
0
def levelpstat(name):
    collectorName = "%s:%s" % ('Engine', name)
    if not collectorName in custom_collectors.keys():
        custom_collectors[collectorName] = PStatCollector(collectorName)
    pstat = custom_collectors[collectorName]
    return pstat
예제 #26
0
from src.coginvasion.cog import SuitBank

from src.coginvasion.avatar.Activities import ACT_WAKE_ANGRY, ACT_SMALL_FLINCH, ACT_DIE, ACT_VICTORY_DANCE, ACT_COG_FLY_DOWN, ACT_SIT, ACT_STUN
from src.coginvasion.cog.activities.WakeAngry import WakeAngry
from src.coginvasion.cog.activities.Flinch import Flinch
from src.coginvasion.cog.activities.Die import Die
from src.coginvasion.cog.activities.VictoryDance import VictoryDance
from src.coginvasion.cog.activities.FlyDown import FlyDown
from src.coginvasion.cog.activities.Sit import Sit
from src.coginvasion.cog.activities.Stun import Stun

import random

from panda3d.core import PStatCollector

cleanupCollector = PStatCollector("Suit:Generate:Cleanup")
setClothesCollector = PStatCollector("Suit:Generate:SetClothes")
generateCollector = PStatCollector("Suit:Generate")
genHeadCollector = PStatCollector("Suit:Generate:MakeHead")
nametagCollector = PStatCollector("Suit:Generate:SetupNameTag")
footstepCollector = PStatCollector("Suit:Generate:Footsteps")
healthBarCollector = PStatCollector("Suit:Generate:HealthBar")
actorCollector = PStatCollector("Suit:Generate:Actor")


class Suit(Avatar):
    notify = directNotify.newCategory('Suit')

    def __init__(self):
        Avatar.__init__(self)
        self.dept = None
예제 #27
0
 def __init__(self):
     """ Inits the manager """
     self._mgr_name = self.__class__.__name__
     DebugObject.__init__(self, self._mgr_name)
     self._update_collector = PStatCollector(
         "App:Show code:RP_UpdateManagers:" + self._mgr_name)
예제 #28
0
from MemoryMonitor import MemoryMonitor
from LightLimits import LightLimits
from IESLoader import IESLoader

from RenderPasses.ShadowScenePass import ShadowScenePass
from RenderPasses.LightCullingPass import LightCullingPass
from RenderPasses.ScatteringPass import ScatteringPass
from RenderPasses.ScatteringCubemapPass import ScatteringCubemapPass
from RenderPasses.UnshadowedLightsPass import UnshadowedLightsPass
from RenderPasses.ShadowedLightsPass import ShadowedLightsPass
from RenderPasses.ExposurePass import ExposurePass
from RenderPasses.ApplyLightsPass import ApplyLightsPass

from GUI.FastText import FastText

pstats_ProcessLights = PStatCollector("App:LightManager:ProcessLights")
pstats_CullLights = PStatCollector("App:LightManager:CullLights")
pstats_PerLightUpdates = PStatCollector("App:LightManager:PerLightUpdates")
pstats_FetchShadowUpdates = PStatCollector(
    "App:LightManager:FetchShadowUpdates")
pstats_WriteBuffers = PStatCollector("App:LightManager:WriteBuffers")
pstats_QueueShadowUpdate = PStatCollector("App:LightManager:QueueShadowUpdate")
pstats_AppendRenderedLight = PStatCollector(
    "App:LightManager:AppendRenderedLight")


class LightManager(DebugObject):
    """ This class is internally used by the RenderingPipeline to handle
    Lights and their Shadows. It stores a list of lights, and updates the
    required ShadowSources per frame. There are two main update methods:
예제 #29
0
    def __buildInstallPlans(self):
        """ Sets up self.installPlans, a list of one or more "plans"
        to download and install the package. """

        pc = PStatCollector(':App:PackageInstaller:buildInstallPlans')
        pc.start()

        self.hasPackage = False

        if self.host.appRunner and self.host.appRunner.verifyContents == self.host.appRunner.P3DVCNever:
            # We're not allowed to download anything.
            self.installPlans = []
            pc.stop()
            return

        if self.asMirror:
            # If we're just downloading a mirror archive, we only need
            # to get the compressed archive file.

            # Build a one-item install plan to download the compressed
            # archive.
            downloadSize = self.compressedArchive.size
            func = lambda step, fileSpec=self.compressedArchive: self.__downloadFile(
                step, fileSpec, allowPartial=True)

            step = self.InstallStep(func, downloadSize, self.downloadFactor,
                                    'download')
            installPlan = [step]
            self.installPlans = [installPlan]
            pc.stop()
            return

        # The normal download process.  Determine what we will need to
        # download, and build a plan (or two) to download it all.
        self.installPlans = None

        # We know we will at least need to unpack the archive contents
        # at the end.
        unpackSize = 0
        for file in self.extracts:
            unpackSize += file.size
        step = self.InstallStep(self.__unpackArchive, unpackSize,
                                self.unpackFactor, 'unpack')
        planA = [step]

        # If the uncompressed archive file is good, that's all we'll
        # need to do.
        self.uncompressedArchive.actualFile = None
        if self.uncompressedArchive.quickVerify(self.getPackageDir(),
                                                notify=self.notify):
            self.installPlans = [planA]
            pc.stop()
            return

        # Maybe the compressed archive file is good.
        if self.compressedArchive.quickVerify(self.getPackageDir(),
                                              notify=self.notify):
            uncompressSize = self.uncompressedArchive.size
            step = self.InstallStep(self.__uncompressArchive, uncompressSize,
                                    self.uncompressFactor, 'uncompress')
            planA = [step] + planA
            self.installPlans = [planA]
            pc.stop()
            return

        # Maybe we can download one or more patches.  We'll come back
        # to that in a minute as plan A.  For now, construct plan B,
        # which will be to download the whole archive.
        planB = planA[:]

        uncompressSize = self.uncompressedArchive.size
        step = self.InstallStep(self.__uncompressArchive, uncompressSize,
                                self.uncompressFactor, 'uncompress')
        planB = [step] + planB

        downloadSize = self.compressedArchive.size
        func = lambda step, fileSpec=self.compressedArchive: self.__downloadFile(
            step, fileSpec, allowPartial=True)

        step = self.InstallStep(func, downloadSize, self.downloadFactor,
                                'download')
        planB = [step] + planB

        # Now look for patches.  Start with the md5 hash from the
        # uncompressedArchive file we have on disk, and see if we can
        # find a patch chain from this file to our target.
        pathname = Filename(self.getPackageDir(),
                            self.uncompressedArchive.filename)
        fileSpec = self.uncompressedArchive.actualFile
        if fileSpec is None and pathname.exists():
            fileSpec = FileSpec()
            fileSpec.fromFile(self.getPackageDir(),
                              self.uncompressedArchive.filename)
        plan = None
        if fileSpec:
            plan = self.__findPatchChain(fileSpec)
        if plan:
            # We can download patches.  Great!  That means this is
            # plan A, and the full download is plan B (in case
            # something goes wrong with the patching).
            planA = plan + planA
            self.installPlans = [planA, planB]
        else:
            # There are no patches to download, oh well.  Stick with
            # plan B as the only plan.
            self.installPlans = [planB]

        # In case of unexpected failures on the internet, we will retry
        # the full download instead of just giving up.
        retries = core.ConfigVariableInt('package-full-dl-retries',
                                         1).getValue()
        for retry in range(retries):
            self.installPlans.append(planB[:])

        pc.stop()
예제 #30
0
from panda3d.core import OmniBoundingVolume, Vec3, Vec2, Point3, Point2, Mat4
from panda3d.core import Point4, Vec4

import math

from Light import Light
from DebugObject import DebugObject
from LightType import LightType
from ShadowSource import ShadowSource
from Globals import Globals

from panda3d.core import PStatCollector

pstats_PSSM = PStatCollector("App:LightManager:ProcessLights:UpdatePCSMSplits")

class DirectionalLight(Light, DebugObject):

    """ This light type simulates sunlight, or any other very big light source. 
    When shadows are enabled, PSSM is used. The directional light should be set
    far away from the scene, to simulate a sun, so very big coordinates are required
    for the directional light to behave like a directional light. 

    DirectionalLight does not support debug nodes (yet). It uses a 4-Split PSSM
    by default. The PSSM can be controlled via setPssmDistance and setPssmSplitPow. 
    See the method descriptions for more information.

    If you do not use the default camera, you should pass it to the light with
    setPssmTarget.

    """
예제 #31
0
from src.leveleditor.geometry.Box import Box
from src.leveleditor.geometry.GeomView import GeomView
from src.leveleditor.viewport.ViewportType import VIEWPORT_2D_MASK, VIEWPORT_3D_MASK

from enum import IntEnum

BoundsBox3DState = RenderState.make(
    ColorAttrib.makeFlat(Vec4(1, 1, 0, 1))
)

BoundsBox2DState = RenderState.make(
    ColorAttrib.makeFlat(Vec4(1, 0, 0, 1)),
    CullBinAttrib.make("selected-foreground", 0)
)

MapObjectInit = PStatCollector("Arch:CreateSolid:MapObjInit")

# Base class for any object in the map (brush, entity, etc)
class MapObject(MapWritable):

    ObjectName = "object"

    def __init__(self, id):
        MapObjectInit.start()

        MapWritable.__init__(self, base.document)
        self.temporary = False
        self.id = id
        self.selected = False
        self.classname = ""
        self.parent = None
예제 #32
0
from direct.stdpy.file import isfile, open, join

from Globals import Globals
from DebugObject import DebugObject
from BetterShader import BetterShader
from LightType import LightType
from GUI.BufferViewerGUI import BufferViewerGUI
from RenderTarget import RenderTarget
from GIHelperLight import GIHelperLight
from LightType import LightType
from SettingsManager import SettingsManager

import time
import math

pstats_PopulateVoxelGrid = PStatCollector(
    "App:GlobalIllumnination:PopulateVoxelGrid")
pstats_GenerateVoxelOctree = PStatCollector(
    "App:GlobalIllumnination:GenerateVoxelOctree")
pstats_ClearGI = PStatCollector("App:GlobalIllumnination:Clear")
pstats_GenerateMipmaps = PStatCollector(
    "App:GlobalIllumnination::GenerateMipmaps")


class GlobalIllumination(DebugObject):
    """ This class handles the global illumination processing. It is still
    experimental, and thus not commented. """

    updateEnabled = False

    def __init__(self, pipeline):
        DebugObject.__init__(self, "GlobalIllumnination")