Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interval: LerpFunctionInterval() returns toData when played backwards and duration is 0.0 #1617

Open
kamgha opened this issue Feb 14, 2024 · 0 comments

Comments

@kamgha
Copy link
Contributor

kamgha commented Feb 14, 2024

Description

In order to create a quick workaround solution for #1616, a LerpFunctionInterval() can be used with a duration of 0.0. The idea is, when the Interval gets triggered and returns fromData, it has been played backwards or the cursor of the interval has been set before the position of the interval building block.

At the moment, when the duration is 0.0, the interval returns the toData when played back in both directions (playRate >0 and <0). The expected behaviour is that it returns toData when it gets played back forwards, and fromData when it gets played back backwards, to reset the data range.

The expected behaviour works when the duration is set >0.0, e. g. 0.000000000000001.

Steps to Reproduce

Reproducer:

from panda3d.core import *

from direct.showbase.ShowBase import ShowBase

from direct.interval.FunctionInterval import *
from direct.interval.MetaInterval import *
from direct.interval.LerpInterval import *


class Test(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        self.accept('1', self.one)
        self.accept('2', self.two)
        
    def one(self):
        print('pressed 1')
    
        w1 = Wait(2.0)
        w2 = Wait(2.0)
    
        fi = LerpFunctionInterval(self.fi_func, 0.0000000000000000000000000000, 0.0, 1.0)
        #fi = Func(self.fi_func)  # this will/should only trigger in forward direction
        
        self.seq = Sequence(w1, fi, w2)
        self.seq.start()
        
    def fi_func(self, a):
        print('fi_func triggered')
        if a == 1.0:
            print('should only print on forward')
            
        if a == 0.0:
            print('should only print on backward')
            
        print(f'a is {a}')
        print(self.seq.getT())
        
    def two(self):
        print('pressed 2')
        self.seq.setPlayRate(-1.0)
        self.seq.resume()


player = Test()
player.run()

Environment

  • Operating system: Windows 8.1
  • System architecture: x86_64
  • Panda3D version: master, current revision
  • Installation method: built from source
  • Python version (if using Python): 3.8.18
  • Compiler (if using C++): MSVC 14.0 (VS 2015)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant