defer importing ParticleSystemManager etc. until base.enableParticles() is called

This commit is contained in:
David Rose 2009-05-01 20:10:18 +00:00
parent 0f39a32569
commit 4456d45f62
3 changed files with 20 additions and 14 deletions

View File

@ -1,6 +1,4 @@
from pandac.PandaModules import *
from direct.particles.ParticleManagerGlobal import *
from direct.showbase.PhysicsManagerGlobal import *
from pandac.PandaModules import ParticleSystem
from pandac.PandaModules import BaseParticleFactory
@ -83,14 +81,14 @@ class Particles(ParticleSystem):
def enable(self):
if (self.fEnabled == 0):
physicsMgr.attachPhysical(self)
particleMgr.attachParticlesystem(self)
base.physicsMgr.attachPhysical(self)
base.particleMgr.attachParticlesystem(self)
self.fEnabled = 1
def disable(self):
if (self.fEnabled == 1):
physicsMgr.removePhysical(self)
particleMgr.removeParticlesystem(self)
base.physicsMgr.removePhysical(self)
base.particleMgr.removeParticlesystem(self)
self.fEnabled = 0
def isEnabled(self):

View File

@ -21,8 +21,6 @@ from JobManagerGlobal import *
from EventManagerGlobal import *
from PythonUtil import *
from direct.showbase import PythonUtil
from direct.particles.ParticleManagerGlobal import *
from PhysicsManagerGlobal import *
#from direct.interval.IntervalManager import ivalMgr
from direct.interval import IntervalManager
from InputStateGlobal import inputState
@ -243,14 +241,11 @@ class ShowBase(DirectObject.DirectObject):
self.jobMgr = jobMgr
# Particle manager
self.particleMgr = particleMgr
self.particleMgr.setFrameStepping(1)
self.particleMgr = None
self.particleMgrEnabled = 0
# Physics manager
self.physicsMgr = physicsMgr
integrator = LinearEulerIntegrator()
self.physicsMgr.attachLinearIntegrator(integrator)
self.physicsMgr = None
self.physicsMgrEnabled = 0
self.physicsMgrAngular = 0
@ -1362,6 +1357,17 @@ class ShowBase(DirectObject.DirectObject):
def enableParticles(self):
if not self.particleMgrEnabled:
if not self.particleMgr:
from direct.particles.ParticleManagerGlobal import particleMgr
self.particleMgr = particleMgr
self.particleMgr.setFrameStepping(1)
if not self.physicsMgr:
from PhysicsManagerGlobal import physicsMgr
self.physicsMgr = physicsMgr
integrator = LinearEulerIntegrator()
self.physicsMgr.attachLinearIntegrator(integrator)
self.particleMgrEnabled = 1
self.physicsMgrEnabled = 1
self.taskMgr.remove('manager-update')

View File

@ -6,7 +6,9 @@ __all__ = ['Transitions']
from pandac.PandaModules import *
from direct.gui.DirectGui import *
from direct.task import Task
from direct.interval.IntervalGlobal import *
from direct.interval.LerpInterval import LerpColorScaleInterval, LerpColorInterval, LerpScaleInterval, LerpPosInterval
from direct.interval.MetaInterval import Sequence, Parallel
from direct.interval.FunctionInterval import Func
class Transitions: