I need to interrupt a Sequence programmatically but using the stop() method issue this blocking error
File "/usr/share/panda3d/pandac/libp3directModules.py", line 44, in stop
self.notify.error("using deprecated CInterval.stop() interface")
File "/usr/share/panda3d/direct/directnotify/Notifier.py", line 130, in error
raise exception(errorString)
StandardError: using deprecated CInterval.stop() interface
and I don’t see around how to stop it in another way - do anyone?
The preferred method seems to be finish() to go to the end and stop permanently or pause() to simply halt execution at whatever point the interval is at.
Right, many years ago we discovered that the word stop() was ambiguous, it wasn’t clear from its name whether that function would stop and move to the end, or stop and leave everything in place. So we replaced it with the unambiguously-named pause() and finish() methods.
Next thing to do: establish a consistent set of playback calls for all types of animated things. I seem to recall in the past running into problems confusing the playback calls for actor animations, intervals, and audio (start/finish/play/stop/begin/end/pause/loop/setloop/…)
thankyou guys
Just got to point out that calling finish() the sequence does not go to the end and stop but executes all the intervals from the current to the end witout taking care of the metapauses - a wrong behavior from my point of view - the best method I see to suit my needs to stop the sequence is to just call pause() and then to instance a new sequence over, the next time I need that sequence. Hoping this don’t cause mem leaks or resource wasting though.
here a couple of lines to play with:
'''
summary: sequence snippet
by: fabius astelix @2009-07
'''
# Panda imports
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import *
#from direct.task import Task
from direct.interval.IntervalGlobal import *
from direct.gui.OnscreenText import OnscreenText
class World(DirectObject):
#------------------------------------------------------
#
def __init__(self):
DirectObject.__init__(self)
# initialize with a blank sequence
self.seq=Sequence(Wait(0.0))
self._dbgost=OnscreenText(
text="""'spacebar' to start
'escape' to stop
'backspace' to finish
""", fg=(0,.4,1,1), bg=(1,1,1,1), scale=.1,
)
self._dbgost_buf=""
self.accept('backspace', self.finish_seq)
self.accept('escape', self.stop_seq)
self.accept('space', self.start_seq)
#------------------------------------------------------
#
def start_seq(self):
if self.seq.isPlaying():
self.printout("* the sequence is just playing *")
return
self.printout("* sequence starts *", True)
self.seq=Sequence(
Wait(1.0),
Func(lambda: self.printout('one')),
Wait(2.0),
Func(lambda: self.printout('two')),
Wait(2.0),
Func(lambda: self.printout('three')),
Wait(2.0),
Func(lambda: self.printout('* sequence ends here *')),
)
self.seq.start()
#------------------------------------------------------
#
def stop_seq(self):
if self.seq.isPlaying():
self.printout("! sequence stopped by user !")
self.seq.pause()
else:
self.printout("* sequence is just stopped *",True)
#------------------------------------------------------
#
def finish_seq(self):
if self.seq.isPlaying():
self.printout("! sequence finished by user !")
self.seq.finish()
#------------------------------------------------------
#
def printout(self, text, clearbuffer=False):
if clearbuffer: self._dbgost_buf=text
else: self._dbgost_buf+="\n"+text
self._dbgost.setText(self._dbgost_buf)
#------------------------------------------------------
#
w=World()
run()
It’s a useful behavior. If all you want is to change the current interval time or stop the interval, there are easy ways to do that manually. If the interval is supposed to leave the game in a certain state, and the game relies upon being in a certain state after the interval completes, there are few ways to ensure everything expected gets done if you need to advance the game earlier than the scheduled end of the interval. For instance, say you’re using intervals for some automated pseudo particle effect, creating a bunch of geoms with motion+cleanup sequences and forgetting about them as soon as you start the intervals. Just pausing and removing all the intervals will leave a bunch of geometry lost in the scene that you no longer have handles to, but finish() will make sure the geoms clean themselves up.
Digging up an old thread, since I just ran into this same issue. My questions is, if you pause a Sequence, and then overwrite the sequence, does Panda hold on to old references of the paused sequence? Super silly example, that glosses over the logic of deciding how/when to pause and overwrite the sequence:
delay = Wait(2.5)
pandaWalkSeq =
Sequence(
Parallel(pandaWalk, pandaWalkAnim),
delay,
Parallel(pandaWalkBack, pandaWalkAnim),
Wait(1.0),
Func(myFunction, arg1)
)
PandaWalkSeq.start()
# some code that checks a status and then pauses if need to stop sequence
PandaWalkSeq.pause()
# now change the sequence and start over
pandaWalkSeq =
Sequence(
Parallel(pandaWalk, pandaWalkAnim),
delay,
Parallel(pandaWalkBack, pandaWalkAnim),
Wait(1.0),
Func(myOtherFunction, arg1)
)
pandaWalkSeq.start()
Will this cause memory issues, if it happens a lot?
thanks, Maria
It is my understanding (although I could be mistaken) that as long as the interval isn’t playing, there aren’t any extra references held to it by Panda.