perfomance leak in lerp interval

hi,
it seems the lerpInterval sucking the frameRate too :frowning:

due the fact its sucking the pertformance, i cant use a lerpsInterval in my game :frowning:

but maybe someone is able to fix this bug for the next release?

greetz

    def reload(self):
        self.bullets = []
        self.sizeBULLETS = 0
        self.time1 = 0   
    def fire(self,task):

        time = task.time
        
        x=0
        if (key["fire"]!=0):
            self.fire1()
            self.time1 = task.time
        timerX = time - self.time1   
        print timerX
        self.sizeBULLETS = len(self.bullets)
        for x in range(self.sizeBULLETS):
   
            if (self.sizeBULLETS > 0):
                print self.sizeBULLETS
               # if (self.bullets[x].getZ()>10):
                if(timerX > 2):
                    self.sizeBULLETS = 0
                    self.bullets[x].hide()
                    self.bullets[x].remove()
                    self.bullets[x].removeNode()
                  #  self.bullets[x] = loader.unloadModel("models/test2008")
                    del self.bullets[x]
        return task.cont
     
    
    def fire1(self):
        self.bullet = loader.loadModel("models/test2008")
        self.bullet.setPos(ship.getPos())
        self.bullet.setP(90)
        self.bullet.setScale(2,2,2)
        self.bullet.setColor(1,0,0,0) 
        self.bullet.reparentTo(render)
        fire = LerpPosInterval(self.bullet, 500,ship.getPos(), other = self.bullet)
        fire.start() 
        self.bullets.append(self.bullet)

Its been found and work on. Itā€™ll be in the next release.

cool, at the meantime im using a other way.

I doubt this is related to that other bug.

If thereā€™s a performance issue here, itā€™s probably simply that each time you fire a bullet, you start an interval that will run for the next 500 seconds, and will continue to run long after you stopped caring about the bullet.

If you press the fire button only once per second, then after five minutes of gameplay you would have 300 lerp intervals still running. Thatā€™s going to have an effect on performance.

To solve this problem, you need to keep a pointer to your lerp intervals, and associate them with each bullet. Then when you remove the bullet, you also finish the interval.

David

huh no, sorry i cant use such a fast interval in my game and if im reducing the duration of the interval, i still have the same perfomance leak :frowning:

Iā€™m not talking about reducing the duration of the interval. Iā€™m talking about explicitly cleaning it up when youā€™re done with it. If you donā€™t clean it up, itā€™s going to cause a performance leak, and itā€™s your fault, not Pandaā€™s.

David

hmm, i have to clean up the lerpInterval? why? but i will try it, thanks.

indeed you was rightā€¦

manual info

i had to finish the interval by handā€¦
thx for help

no sorry, the lerpIn is still sucking the perfomance :frowning:

how can i clean up the lerpInterval, i cant find anything else like finish in the manual?

def reload(self):
        self.bullets = []
        self.sizeBULLETS = 0
        self.time1 = 0   
        self.fire = None
    def fire(self,task):
        time = task.time
        
        x=0
        if (key["fire"]!=0):
            self.fire1()
            self.time1 = task.time
        timerX = time - self.time1   
        self.sizeBULLETS = len(self.bullets)
        self.fire = [None for x in range(self.sizeBULLETS)]
        for x in range(self.sizeBULLETS):
            if (self.sizeBULLETS > 0):
                print self.sizeBULLETS
                self.fire[x] = LerpPosInterval(self.bullets[x], 500,ship.getPos(), other = self.bullets[x])
                self.fire[x].start()
               # if (self.bullets[x].getZ()>10):
                if(timerX > 2):
                    self.sizeBULLETS = 0
                    self.bullets[x].hide()
                    self.bullets[x].remove()
                    self.bullets[x].removeNode()
                    self.fire[x].finish()
                    
                  #  self.bullets[x] = loader.unloadModel("models/test2008")
                    del self.bullets[x]
        return task.cont
     
    
    def fire1(self):
        self.bullet = loader.loadModel("models/test2008")
        self.bullet.setPos(ship.getPos())
        self.bullet.setP(90)
        self.bullet.setScale(2,2,2)
        self.bullet.setColor(1,0,0,0) 
        self.bullet.reparentTo(render)
        self.bullets.append(self.bullet)

i did what you said, but now ā€¦ uarrgghhh

i will wait till the lerp bug is fixed and using my own translations for it.

Thereā€™s no lerp bug. I think youā€™re still not cleaning them up properly.

The problem might be here:

self.fire = [None for x in range(self.sizeBULLETS)] 

This is completely reassigning self.fire to a new list of intervals. Trouble is, if self.fire was already a list of intervals from the last pass, then those intervals are leaked, and will not get cleaned up any more.

Still, intervals are complicated to use, and Iā€™m not sure theyā€™re the right tool for a bullet anyway. If youā€™re not 100% sure of the interval system, but you have another solution that works well for you, then go ahead and use your other solution.

David

i have already a other solution working, but the lerpInterval seemd for me more comfortable.

self.fire = [None for x in range(self.sizeBULLETS)]

about this piece of code, i cant imaging that this is the problem, its only def. the size of the fire array. i will check this in few hours, now i take a nap :wink:

you said i have to init a lerpInt. for each bullet, which slows down everything dramatical.

i hope the lerp bug will be fixed soon :smiley:

about cleaning it up, how??? i used the ā€œfinishā€ statement for the lerpInterval and cant find anything else to cleaning it up.

...
//here im def. the interval for each bullet...
for x in range(self.sizeBULLETS): 
            if (self.sizeBULLETS > 0): 
                print self.sizeBULLETS 
                self.fire[x] = LerpPosInterval(self.bullets[x], 500,ship.getPos(), other = self.bullets[x]) 
                self.fire[x].start() 
...
//and here im finishing the interval
self.fire[x].finish()

I think Drawr right. I thought you had the same bug as the post below you had cus I know lerp used the .setPos. Umā€¦ actully you have another bug too I am surpise it didnt give you a errorā€¦ maybe iā€™m wrong but you called fire = Noneā€¦ yet you still have one called fire too (the task) wouldnt that cus some problems?

Untested but I think this is what your going after in that code.

y = 0
self.bullet = {}
self.timerX = 0

    def fire(self,task): 
        if (key["fire"]!=0): 
            self.fire1()

            for x in self.bullet:
              self.fire[x] = LerpPosInterval(self.bullets[x], 500, ship.getPos(), other= self.bullets[x]) 
              self.fire[x].start()

        for x in self.bulle: 
          if self.bullets[x].getZ() >= 10:
            if task.time >= self.timerX + 2:
             self.bullet[x].removeNode() 
              self.fire[x].finish()

        #You'll need to fixs the timer if it doesnt work right.
        if self.timerX <= task.time
          self.timerX = task.time
     
     
    def fire1(self):
        y = y + 1
        self.bullet[y] = loader.loadModel("models/test2008") 
        self.bullet[y].setPos(ship.getPos()) 
        self.bullet[y].setP(90) 
        self.bullet[y].setScale(2,2,2) 
        self.bullet[y].setColor(1,0,0,0) 
        self.bullet[y].reparentTo(render)

huh? interesting! im start to really wondering me about something :wink:

if i have to assign for ever bullet a different interval, i need to def. the size of the array. orā€¦ u know what would happensā€¦ i hope.

the first NONE, was a old trash which stayed in my code, but i doesnt do any difference, if its there or not :wink:

 def reload(self):
        self.bullets = []
        self.sizeBULLETS = 0
        self.time1 = 0   
#here the commented NONE ;)
        #self.fire = None
    def fire(self,task):
  
        time = task.time
        
        x=0
        if (key["fire"]!=0):
            self.fire1()
            self.time1 = task.time
        timerX = time - self.time1   
        self.sizeBULLETS = len(self.bullets)
#huga -> def. size array jaja
        self.fire = [None for x in range(self.sizeBULLETS)]
        for x in range(self.sizeBULLETS):
            
            if (self.sizeBULLETS > 0):
                  #self.bullets[x].setZ(self.bullets[x].getZ()+4)
#huga -> lerp array bullet each other is , hmmm, connection, not white, huga-> other each.... prrrrrrrr
                self.getBULLETx = self.bullets[x].getX()
                self.fire[x] = LerpPosInterval(self.bullets[x], 500,ship.getPos(), other = self.bullets[x])
                self.fire[x].start()
                if (self.bullets[x].getZ()>55):
                
                    self.sizeBULLETS = 0
                    self.bullets[x].hide()
                    self.bullets[x].remove()
                    self.bullets[x].removeNode()
                    self.fire[x].finish()
                    del self.fire[x]
                  #  self.bullets[x] = loader.unloadModel("models/test2008")
                    del self.bullets[x]
        return task.cont
     
    
    def fire1(self):
        self.bullet = loader.loadModel("models/test2008")
        self.bullet.setPos(ship.getPos())
        self.bullet.setP(90)
        self.bullet.setScale(2,2,2)
        self.bullet.setColor(1,0,0,0) 
        self.bullet.reparentTo(render)
        self.bullets.append(self.bullet)
   

hugaā€¦
sorry :wink: :smiley:

Also I think 500 is way to long (8mins why?) Anyways look up one post I added to my post some code that may help.

i want to watch my bullets while they are moving :wink:
and yes the performance is a lot better when i am using .1 for duration.

should i scale my complete scene that much up?

thanks, i will take a look into.

Thats up to you after this point.

maybe im doing this. it wont make much work, im havin only textured planes in. thats why i wasnt mind any scale. but, for my point of view, the scale should make no performance difference! and the lerp cant be finished while the duration!

ok shame on me :blush: