Giter Club home page Giter Club logo

cpptweener's People

Contributors

wfmarques avatar

Watchers

 avatar

cpptweener's Issues

A new animation mode, EaseOutIn, could be possible to implement by leveraging just what's we have so far

For every equation (Sine,Expo,Quint..) we have defined:

- easeIn
- easeOut
- easeInOut

Based on my template usage suggestion, we could extend the Animation mode:

enum
{
    EaseIn,
    EaseOut,
    EaseInOut,
    EaseOutIn
}

Then, assuming we have these variables setup this way:

iFrom = from:
iTo = to;
iDistance = to-from;

and let b=from and c=distance, now we can extend the switch statement this way:

template< class T, int mode >
float ease( float lastFrameTime )
{
    ...
    float ret = iFrom;
    switch( mode )
    {
        case EaseIn:
        {
            ret = T::easeIn( t, b, c, d );
            break;
        }
        case EaseOut:
        {
            ret = T::easeOut( t, b, c, d );
            break;
        }
        case EaseIn:
        {
            ret = T::easeInOut( t, b, c, d );
            break;
        }
        case EaseOutIn:
        {
            float halfDistance = iDistance / 2.f;
            if ( iTimeAccu < iDurationSecs / 2 )
                ret = T::easeOut( t * 2, b, halfDistance, d );
            else
                ret = T::easeIn( ( t * 2 ) - d, b + halfDistance, halfDistance, d );
            break;
        }
    }

    return ret;
}

Original issue reported on code.google.com by [email protected] on 14 Feb 2010 at 4:03

Attachments:

C++ template metaprogramming would allow equation functions to be called without the overhead of pure virtual function dereference

As in the subject, you could achieve no-overhead function calls by exploiting 
generics programming.
For example, as you already have, define the Animation mode:

enum
{
    EaseIn,
    EaseOut,
    EaseInOut
}

Then defines the equation solvers as static functions:

...

class Expo
{
    public:

        static float easeIn( float t, float b, float c, float d );
        static float easeOut( float t, float b, float c, float d );
        static float easeInOut( float t, float b, float c, float d );
};


Then, define the invoker:

template< class T, int mode >
float ease( float accuFrameTime )
{
    ...
    float ret = iFrom;
    switch( mode )
    {
        case EaseIn:
        {
            ret = T::easeIn( t, b, c, d );
            break;
        }
        case EaseOut:
        {
            ret = T::easeOut( t, b, c, d );
            break;
        }
        case EaseIn:
        {
            ret = T::easeInOut( t, b, c, d );
            break;
        }
    }

    return ret;
}

Original issue reported on code.google.com by [email protected] on 14 Feb 2010 at 3:48

UB in easeInOut

What steps will reproduce the problem?
1. download source
2. open the file "CppTweener.cpp"
3. scroll to row 88


the statement "return -c/2 * (((t-2)*(--t)) - 1) + b;"

is undefined behavior due to using --t and t-2 in the same expression, where 
its not guaranteed to happen in left-to-right order.


Original issue reported on code.google.com by [email protected] on 9 Aug 2012 at 9:05

Tweener::lastTime member variable should be initialized in the constructor

What steps will reproduce the problem?
1. run the test sample without the compiler automatically initializing 
variables for you

What is the expected output? What do you see instead?
You should get animation tweened all the times.
Instead, sometimes, wrong values get interpolated.

What version of the product are you using? On what operating system?
HEAD revision from subversion (r6)


Original issue reported on code.google.com by [email protected] on 14 Feb 2010 at 3:34

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.