MAJOR OVERHAUL: The particle interval now behaves like a normal interval. The particle system is removed from the global particle and physics managers and its stepping is controlled by the interval itself.
This commit is contained in:
parent
4fe44aeed8
commit
cfd7181deb
|
|
@ -14,16 +14,26 @@ class ParticleInterval(Interval):
|
|||
# create ParticleInterval DirectNotify category
|
||||
notify = directNotify.newCategory('ParticleInterval')
|
||||
# Class methods
|
||||
def __init__(self, particleEffect, parent, worldRelative=1, loop=0,
|
||||
duration=0.0, name=None):
|
||||
def __init__(self,
|
||||
particleEffect,
|
||||
parent,
|
||||
worldRelative=1,
|
||||
renderParent = None,
|
||||
duration=0.0,
|
||||
softStopT = 0.0,
|
||||
cleanup = False,
|
||||
name=None):
|
||||
"""
|
||||
particleEffect is ??
|
||||
parent is ??
|
||||
particleEffect is a ParticleEffect
|
||||
parent is a NodePath
|
||||
worldRelative is a boolean
|
||||
loop is a boolean
|
||||
renderParent is a NodePath
|
||||
duration is a float for the time
|
||||
name is ??
|
||||
softStopT is a float
|
||||
cleanup is a boolean
|
||||
name is a string
|
||||
"""
|
||||
|
||||
# Generate unique name
|
||||
id = 'Particle-%d' % ParticleInterval.particleNum
|
||||
ParticleInterval.particleNum += 1
|
||||
|
|
@ -31,25 +41,39 @@ class ParticleInterval(Interval):
|
|||
name = id
|
||||
# Record instance variables
|
||||
self.particleEffect = particleEffect
|
||||
self.parent = parent
|
||||
self.worldRelative = worldRelative
|
||||
self.fLoop = loop
|
||||
assert duration > 0.0 or loop == 1
|
||||
self.softStopT = softStopT
|
||||
self.cleanup = cleanup
|
||||
|
||||
if parent != None:
|
||||
self.particleEffect.reparentTo(parent)
|
||||
if worldRelative:
|
||||
self.particleEffect.setRenderParent(render.node())
|
||||
|
||||
# Initialize superclass
|
||||
Interval.__init__(self, name, duration)
|
||||
|
||||
def __del__(self):
|
||||
def __step(self,dt):
|
||||
if self.particleEffect:
|
||||
self.particleEffect.cleanup()
|
||||
self.particleEffect = None
|
||||
self.particleEffect.accelerate(dt,1,0.05)
|
||||
|
||||
def start(self, *args, **kwargs):
|
||||
self.state = CInterval.SInitial
|
||||
if self.particleEffect:
|
||||
self.particleEffect.softStart()
|
||||
Interval.start(self, *args, **kwargs)
|
||||
|
||||
def privInitialize(self, t):
|
||||
renderParent = None
|
||||
if self.worldRelative:
|
||||
renderParent = render
|
||||
if self.state == CInterval.SInitial:
|
||||
if self.particleEffect:
|
||||
self.particleEffect.clearToInitial()
|
||||
self.currT = 0
|
||||
|
||||
if self.particleEffect:
|
||||
self.particleEffect.start(self.parent, renderParent)
|
||||
self.state = CInterval.SStarted
|
||||
for f in self.particleEffect.forceGroupDict.values():
|
||||
f.enable()
|
||||
|
||||
self.state = CInterval.SStarted
|
||||
self.__step(t-self.currT)
|
||||
self.currT = t
|
||||
|
||||
def privStep(self, t):
|
||||
|
|
@ -58,22 +82,16 @@ class ParticleInterval(Interval):
|
|||
self.privInitialize(t)
|
||||
else:
|
||||
self.state = CInterval.SStarted
|
||||
self.__step(t-self.currT)
|
||||
self.currT = t
|
||||
|
||||
if self.currT > (self.getDuration() - self.softStopT):
|
||||
if self.particleEffect:
|
||||
self.particleEffect.softStop()
|
||||
|
||||
def privFinalize(self):
|
||||
if self.particleEffect:
|
||||
Interval.privFinalize(self)
|
||||
if self.cleanup and self.particleEffect:
|
||||
self.particleEffect.cleanup()
|
||||
self.particleEffect = None
|
||||
self.currT = self.getDuration()
|
||||
self.state = CInterval.SFinal
|
||||
|
||||
def privInstant(self):
|
||||
if self.particleEffect:
|
||||
self.particleEffect.cleanup()
|
||||
self.particleEffect = None
|
||||
self.currT = self.getDuration()
|
||||
self.state = CInterval.SFinal
|
||||
|
||||
def privInterrupt(self):
|
||||
self.particleEffect.disable()
|
||||
self.state = CInterval.SPaused
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue