From 4b24976c7205c54267254868d02899dbce21ae9e Mon Sep 17 00:00:00 2001 From: Kimmo Hoikka Date: Fri, 31 Oct 2014 11:05:55 +0000 Subject: [PATCH] Reduce exports by inlining alpha functions and helper constraints, removing unused helpers [Problem] [Cause] [Solution] Change-Id: Ia75038420304e6c0bba4be3bf68dd8f27f032e27 --- .../src/dali/utc-Dali-Constraint.cpp | 269 +-------------- dali/public-api/animation/alpha-functions.cpp | 182 ---------- dali/public-api/animation/alpha-functions.h | 205 +++++++++-- dali/public-api/animation/constraints.cpp | 325 ------------------ dali/public-api/animation/constraints.h | 296 ++++++---------- dali/public-api/file.list | 1 - 6 files changed, 276 insertions(+), 1002 deletions(-) delete mode 100644 dali/public-api/animation/constraints.cpp diff --git a/automated-tests/src/dali/utc-Dali-Constraint.cpp b/automated-tests/src/dali/utc-Dali-Constraint.cpp index a1d0a3708..86b16e646 100644 --- a/automated-tests/src/dali/utc-Dali-Constraint.cpp +++ b/automated-tests/src/dali/utc-Dali-Constraint.cpp @@ -3247,7 +3247,7 @@ int UtcDaliConstraintInvalidInputProperty(void) { TestApplication application; Actor actor = Actor::New(); - Constraint constraint = Constraint::New( Actor::POSITION, LocalSource( PROPERTY_REGISTRATION_START_INDEX ), MultiplyConstraint() ); + Constraint constraint = Constraint::New( Actor::POSITION, LocalSource( PROPERTY_REGISTRATION_START_INDEX ), EqualToConstraint() ); Stage::GetCurrent().Add( actor ); @@ -3479,53 +3479,6 @@ int UtcDaliBuiltinConstraintScaleToFitKeepAspectRatio(void) END_TEST; } -int UtcDaliBuiltinConstraintScaleToFillKeepAspectRatio(void) -{ - TestApplication application; - - Actor parent = Actor::New(); - Vector3 parentSize1( 10, 10, 10 ); - parent.SetSize( parentSize1 ); - Stage::GetCurrent().Add( parent ); - - Actor actor = Actor::New(); - Vector3 childSize( 4, 5, 5 ); - actor.SetSize( childSize ); - parent.Add( actor ); - - application.SendNotification(); - application.Render(0); - Vector3 childScale1( 1.0f, 1.0f, 1.0f ); - DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale1, TEST_LOCATION ); - - // Apply constraint - - Constraint constraint = Constraint::New( Actor::SCALE, - LocalSource( Actor::SIZE ), - ParentSource( Actor::SIZE ), - ScaleToFillKeepAspectRatioConstraint() ); - actor.ApplyConstraint( constraint ); - - application.SendNotification(); - application.Render(0); - - // Constraint should be fully applied, but parent size is larger than child - float val = 10.f / 4.f; - Vector3 childScale2( val, val, val ); - DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale2, TEST_LOCATION ); - - // change parent size - Vector3 parentSize2( 40, 50, 50 ); - parent.SetSize( parentSize2 ); - - application.SendNotification(); - application.Render(0); - - // Constraint should be fully applied, but parent size is larger than child - Vector3 childScale3( 10.0f, 10.0f, 10.0f ); - DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale3, TEST_LOCATION ); - END_TEST; -} int UtcDaliBuiltinConstraintScaleToFillXYKeepAspectRatio(void) { @@ -3575,151 +3528,6 @@ int UtcDaliBuiltinConstraintScaleToFillXYKeepAspectRatio(void) END_TEST; } -int UtcDaliBuiltinConstraintShrinkInsideKeepAspectRatioConstraint(void) -{ - TestApplication application; - - Actor parent = Actor::New(); - Vector3 parentSize1( 10, 10, 10 ); - parent.SetSize( parentSize1 ); - Stage::GetCurrent().Add( parent ); - - Actor actor = Actor::New(); - Vector3 childSize( 4, 5, 5 ); - actor.SetSize( childSize ); - parent.Add( actor ); - - application.SendNotification(); - application.Render(0); - Vector3 childScale1( 1.0f, 1.0f, 1.0f ); - DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale1, TEST_LOCATION ); - - // Apply constraint - - Constraint constraint = Constraint::New( Actor::SCALE, - LocalSource( Actor::SIZE ), - ParentSource( Actor::SIZE ), - ShrinkInsideKeepAspectRatioConstraint() ); - actor.ApplyConstraint( constraint ); - - application.SendNotification(); - application.Render(0); - - // Constraint should be fully applied, but parent size is larger than child - Vector3 childScale2( 1.0f, 1.0f, 1.0f ); - DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale2, TEST_LOCATION ); - - // change parent size - Vector3 parentSize2( 40, 50, 50 ); - parent.SetSize( parentSize2 ); - - application.SendNotification(); - application.Render(0); - - // Constraint should be fully applied, but parent size is larger than child - Vector3 childScale3( 1.0f, 1.0f, 1.0f ); - DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale3, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliBuiltinConstraintMultiplyConstraint(void) -{ - TestApplication application; - - Actor actor1 = Actor::New(); - Vector3 startPosition( 10, 10, 10 ); - actor1.SetPosition( startPosition ); - Stage::GetCurrent().Add( actor1 ); - - Actor actor2 = Actor::New(); - Vector3 startSize( 100, 100, 100 ); - actor2.SetSize( startSize ); - Stage::GetCurrent().Add( actor2 ); - - application.SendNotification(); - application.Render(0); - DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition ); - DALI_TEST_CHECK( actor2.GetCurrentSize() == startSize ); - - // Apply constraint - multiply actor1 size by actor2 position - - Constraint constraint = Constraint::New( Actor::SIZE, - Source( actor1, Actor::POSITION ), - MultiplyConstraint() ); - constraint.SetRemoveAction( Constraint::Discard ); - actor2.ApplyConstraint( constraint ); - - application.SendNotification(); - application.Render(0); - - // Constraint should be fully applied - Vector3 size( startSize * startPosition ); - DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); - - // Change the multiply input - Vector3 endPosition( 2, 2, 2 ); - actor1.SetPosition( endPosition ); - - application.SendNotification(); - application.Render(0); - - // Constraint should be fully applied - size = Vector3( startSize * endPosition ); - DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliBuiltinConstraintDivideConstraint(void) -{ - TestApplication application; - - Actor actor1 = Actor::New(); - Vector3 startPosition( 10, 10, 10 ); - actor1.SetPosition( startPosition ); - Stage::GetCurrent().Add( actor1 ); - - Actor actor2 = Actor::New(); - Vector3 startSize( 100, 100, 100 ); - actor2.SetSize( startSize ); - Stage::GetCurrent().Add( actor2 ); - - application.SendNotification(); - application.Render(0); - DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition ); - DALI_TEST_CHECK( actor2.GetCurrentSize() == startSize ); - - // Apply constraint - divide actor1 size by actor2 position - - Constraint constraint = Constraint::New( Actor::SIZE, - Source( actor1, Actor::POSITION ), - DivideConstraint() ); - constraint.SetRemoveAction( Constraint::Discard ); - actor2.ApplyConstraint( constraint ); - - application.SendNotification(); - application.Render(0); - - // Constraint should be fully applied - Vector3 size( 10, 10, 10 ); // startSize / startPosition - DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); - - // Change the divide input - Vector3 endPosition( 2, 2, 2 ); - actor1.SetPosition( endPosition ); - - application.SendNotification(); - application.Render(0); - - // Constraint should be fully applied - size = Vector3( 50, 50, 50 ); // startSize / endPosition - DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); - END_TEST; -} - int UtcDaliBuiltinConstraintEqualToConstraint(void) { TestApplication application; @@ -3921,55 +3729,6 @@ int UtcDaliBuiltinConstraintRelativeToConstraint(void) END_TEST; } -int UtcDaliBuiltinConstraintInverseOfConstraint(void) -{ - TestApplication application; - - Actor actor1 = Actor::New(); - Vector3 startPosition( 10, 10, 10 ); - actor1.SetPosition( startPosition ); - Stage::GetCurrent().Add( actor1 ); - - Actor actor2 = Actor::New(); - Vector3 startSize( 100, 100, 100 ); - actor2.SetSize( startSize ); - Stage::GetCurrent().Add( actor2 ); - - application.SendNotification(); - application.Render(0); - DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition ); - DALI_TEST_CHECK( actor2.GetCurrentSize() == startSize ); - - // Apply constraint - actor1 size == ( 1 / actor2 position ) - - Constraint constraint = Constraint::New( Actor::SIZE, - Source( actor1, Actor::POSITION ), - InverseOfConstraint() ); - constraint.SetRemoveAction( Constraint::Discard ); - actor2.ApplyConstraint( constraint ); - - application.SendNotification(); - application.Render(0); - - // Constraint should be fully applied - Vector3 size( 0.1, 0.1, 0.1 ); // 1 / startPosition - DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, 0.00001f, TEST_LOCATION ); - - // Change the input - Vector3 endPosition( 2, 2, 2 ); - actor1.SetPosition( endPosition ); - - application.SendNotification(); - application.Render(0); - - // Constraint should be fully applied - size = Vector3( 0.5, 0.5, 0.5 ); // 1 / endPosition - DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); - application.Render(0); - DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); - END_TEST; -} - int UtcDaliBuiltinConstraintFunctions(void) { TestApplication application; @@ -3994,26 +3753,6 @@ int UtcDaliBuiltinConstraintFunctions(void) } } - { - SourceHeightFixedWidth sourceHeightFixedWidth( 10.f ); - Vector3 current; - { - Vector3 reference(10,1,0); - Vector3 value = sourceHeightFixedWidth( current, PropertyInputAbstraction(Vector3::ONE) ); - DALI_TEST_EQUALS( reference, value, TEST_LOCATION ); - } - { - Vector3 reference(10,10,0); - Vector3 value = sourceHeightFixedWidth( current, PropertyInputAbstraction(Vector3::ONE*10.f) ); - DALI_TEST_EQUALS( reference, value, TEST_LOCATION ); - } - { - Vector3 reference(10,100,0); - Vector3 value = sourceHeightFixedWidth( current, PropertyInputAbstraction(Vector3::ONE*100.f) ); - DALI_TEST_EQUALS( reference, value, TEST_LOCATION ); - } - } - { // LookAt Quaternion current(0, Vector3::YAXIS); PropertyInputAbstraction target(Vector3::ZAXIS); @@ -4026,12 +3765,6 @@ int UtcDaliBuiltinConstraintFunctions(void) DALI_TEST_EQUALS( reference, value, 0.001, TEST_LOCATION ); } - { - OrientedLookAt orientedLookAt(90.f); - Quaternion reference(.525322, 0., 0., 0.850904); - Quaternion value = orientedLookAt( current, target, camera, targetRotation ); - DALI_TEST_EQUALS( reference, value, 0.001, TEST_LOCATION ); - } } END_TEST; diff --git a/dali/public-api/animation/alpha-functions.cpp b/dali/public-api/animation/alpha-functions.cpp index 881bc1674..d4609ffce 100644 --- a/dali/public-api/animation/alpha-functions.cpp +++ b/dali/public-api/animation/alpha-functions.cpp @@ -19,7 +19,6 @@ #include // INTERNAL INCLUDES -#include namespace Dali { @@ -27,187 +26,6 @@ namespace Dali namespace AlphaFunctions { -float Default(float progress) -{ - return progress; // Linear -} - -float Linear(float progress) -{ - return progress; -} - -float Reverse(float progress) -{ - return 1.0f - progress; -} - -float Square(float progress) -{ - return progress * progress; -} - -float EaseIn(float progress) -{ - return progress * progress * progress; -} - -float EaseOut(float progress) -{ - progress -= 1.0f; - - return progress * progress * progress + 1.0f; -} - -float EaseInOut(float progress) -{ - if (progress > 0.5f) - { - return EaseOut((progress - 0.5f)*2.0f) * 0.5f + 0.5f; - } - else - { - return EaseIn(progress * 2.0f) * 0.5f; - } -} - -float EaseInSine(float progress) -{ - return -1.0f * cosf(progress * Math::PI_2) + 1.0f; -} - -float EaseOutSine(float progress) -{ - return sinf(progress * Math::PI_2); -} - -float EaseInOutSine(float progress) -{ - return -0.5f * (cosf(Math::PI * progress) - 1.0f); -} - -float EaseInSine33(float progress) -{ - float tmp = cosf(Math::PI_2 * 33.0f / 90.0f); - return -1.0f * (cosf(progress * Math::PI_2 * 33.0f / 90.0f) - tmp) / (1.0f - tmp) + 1.0f; -} - -float EaseOutSine33(float progress) -{ - float tmp = cosf(Math::PI_2 * 33.0f / 90.0f); - return (cosf((1.0f - progress) * Math::PI_2 * 33.0f / 90.0f) - tmp) / (1.0f - tmp); -} - -float EaseInOutSine33(float progress) -{ - float tmp = sinf(Math::PI_2 * 33.0f / 90.0f); - return (sinf((progress * Math::PI - Math::PI_2) * 33.0f / 90.0f) + tmp) / (2.0f * tmp); -} - -float EaseInOutSine50(float progress) -{ - float tmp = sinf(Math::PI_2 * 50.0f / 90.0f); - return (sinf((progress * Math::PI - Math::PI_2) * 50.0f / 90.0f) + tmp) / (2.0f * tmp); -} - -float EaseInOutSine60(float progress) -{ - float tmp = sinf(Math::PI_2 * 60.0f / 90.0f); - return (sinf((progress * Math::PI - Math::PI_2) * 60.0f / 90.0f) + tmp) / (2.0f * tmp); -} - -float EaseInOutSine70(float progress) -{ - float tmp = sinf(Math::PI_2 * 70.0f / 90.0f); - return (sinf((progress * Math::PI - Math::PI_2) * 70.0f / 90.0f) + tmp) / (2.0f * tmp); -} - -float EaseInOutSine80(float progress) -{ - float tmp = sinf(Math::PI_2 * 80.0f / 90.0f); - return (sinf((progress * Math::PI - Math::PI_2) * 80.0f / 90.0f) + tmp) / (2.0f * tmp); -} - -float EaseInOutSine90(float progress) -{ - return EaseInOutSine(progress); -} - -float DoubleEaseInOutSine60(float progress) -{ - if (progress < 0.5f) - { - return EaseInOutSine60(progress * 2.0f) / 2.0f; - } - else - { - return EaseInOutSine60((progress - 0.5f) * 2.0f) / 2.0f + 0.5f; - } -} - -float EaseOutQuint50(float progress) -{ - return 1.0f - powf(1.0f - progress, 1.7f); -} - -float EaseOutQuint80(float progress) -{ - return 1.0f - powf(1.0f - progress, 2.3f); -} - -float Bounce(float progress) -{ - return sinf(progress * Math::PI); -} - -float BounceBack(float progress) -{ - if( progress > 0.0f ) - { - return (sinf(progress * 2.0f * Math::PI) * sinf(progress * Math::PI)) / (progress * Math::PI); - } - else - { - return 0; - } -} - -float EaseInBack(float progress) -{ - const float sqrt2 = 1.70158f; - - return progress * progress * ( ( sqrt2 + 1.0f ) * progress - sqrt2 ); -} - -float EaseOutBack(float progress) -{ - const float sqrt2 = 1.70158f; - progress -= 1.0f; - - return 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 ); -} - -float EaseInOutBack(float progress) -{ - if (progress > 0.5f) - { - return EaseOutBack((progress - 0.5f)*2.0f) * 0.5f + 0.5f; - } - else - { - return EaseInBack(progress * 2.0f) * 0.5f; - } -} - -float Sin(float progress) -{ - return 0.5f - cosf(progress * 2.0f * Math::PI) * 0.5f; -} - -float Sin2x(float progress) -{ - return 0.5f - cosf(progress * 4.0f * Math::PI) * 0.5f; -} } // AlphaFunctions diff --git a/dali/public-api/animation/alpha-functions.h b/dali/public-api/animation/alpha-functions.h index 553b0bf6d..0943102f2 100644 --- a/dali/public-api/animation/alpha-functions.h +++ b/dali/public-api/animation/alpha-functions.h @@ -20,8 +20,9 @@ // INTERNAL INCLUDES #include +#include -namespace Dali DALI_IMPORT_API +namespace Dali { typedef float (*AlphaFunction)(float progress); ///< Definition of an alpha function @@ -32,41 +33,187 @@ typedef float (*AlphaFunction)(float progress); ///< Definition of an alpha func namespace AlphaFunctions { -float Default(float progres); ///< Linear -float Linear(float progress); ///< Linear -float Square(float progress); ///< Square (x^2) -float Reverse(float progress); ///< Reverse linear +inline float Linear( float progress ) +{ + return progress; +} + +inline float Default( float progress ) +{ + return Linear( progress ); +} + +inline float Reverse( float progress ) ///< Reverse linear +{ + return 1.0f - progress; +} + +inline float Square( float progress ) ///< Square (x^2) +{ + return progress * progress; +} + +inline float EaseIn( float progress ) ///< Speeds up and comes to a sudden stop +{ + return progress * progress * progress; +} + +inline float EaseOut( float progress ) ///< Sudden start and slows to a gradual stop +{ + progress -= 1.0f; + + return progress * progress * progress + 1.0f; +} -float EaseIn(float progress); ///< Speeds up and comes to a sudden stop -float EaseOut(float progress); ///< Sudden start and slows to a gradual stop -float EaseInOut(float progress); ///< Speeds up and slows to a gradual stop +inline float EaseInOut( float progress ) ///< Speeds up and slows to a gradual stop +{ + if (progress > 0.5f) + { + return EaseOut((progress - 0.5f)*2.0f) * 0.5f + 0.5f; + } + else + { + return EaseIn(progress * 2.0f) * 0.5f; + } +} + +inline float EaseInSine( float progress ) ///< Speeds up and comes to a sudden stop +{ + return -1.0f * cosf(progress * Math::PI_2) + 1.0f; +} + +inline float EaseOutSine( float progress ) ///< Sudden start and slows to a gradual stop +{ + return sinf(progress * Math::PI_2); +} + +inline float EaseInOutSine( float progress ) ///< Speeds up and slows to a gradual stop +{ + return -0.5f * (cosf(Math::PI * progress) - 1.0f); +} -float EaseInSine(float progress); ///< Speeds up and comes to a sudden stop -float EaseOutSine(float progress); ///< Sudden start and slows to a gradual stop -float EaseInOutSine(float progress); ///< Speeds up and slows to a gradual stop +inline float EaseInSine33( float progress ) ///< Speeds up and comes to a sudden stop +{ + float tmp = cosf(Math::PI_2 * 33.0f / 90.0f); + return -1.0f * (cosf(progress * Math::PI_2 * 33.0f / 90.0f) - tmp) / (1.0f - tmp) + 1.0f; +} -float EaseInSine33(float progress); ///< Speeds up and comes to a sudden stop -float EaseOutSine33(float progress); ///< Sudden start and slows to a gradual stop -float EaseInOutSine33(float progress); ///< Speeds up and slows to a gradual stop -float EaseInOutSine50(float progress); ///< Speeds up and slows to a gradual stop -float EaseInOutSine60(float progress); ///< Speeds up and slows to a gradual stop -float EaseInOutSine70(float progress); ///< Speeds up and slows to a gradual stop -float EaseInOutSine80(float progress); ///< Speeds up and slows to a gradual stop -float EaseInOutSine90(float progress); ///< Speeds up and slows to a gradual stop -float DoubleEaseInOutSine60(float progress); ///< Speeds up and slows to a gradual stop, then speeds up again and slows to a gradual stop +inline float EaseOutSine33( float progress ) ///< Sudden start and slows to a gradual stop +{ + float tmp = cosf(Math::PI_2 * 33.0f / 90.0f); + return (cosf((1.0f - progress) * Math::PI_2 * 33.0f / 90.0f) - tmp) / (1.0f - tmp); +} -float EaseOutQuint50(float progress); ///< Sudden start and slows to a gradual stop -float EaseOutQuint80(float progress); ///< Sudden start and slows to a gradual stop +inline float EaseInOutSine33( float progress ) ///< Speeds up and slows to a gradual stop +{ + float tmp = sinf(Math::PI_2 * 33.0f / 90.0f); + return (sinf((progress * Math::PI - Math::PI_2) * 33.0f / 90.0f) + tmp) / (2.0f * tmp); +} -float Bounce(float progress); ///< Sudden start, loses momentum and returns to start position -float BounceBack(float progress); ///< Sudden start, loses momentum and returns to exceed start position and gradual stop at start position +inline float EaseInOutSine50( float progress ) ///< Speeds up and slows to a gradual stop +{ + float tmp = sinf(Math::PI_2 * 50.0f / 90.0f); + return (sinf((progress * Math::PI - Math::PI_2) * 50.0f / 90.0f) + tmp) / (2.0f * tmp); +} -float EaseInBack(float progress); ///< Slow start, exceed start position and quickly reach destination -float EaseOutBack(float progress); ///< Sudden start, exceed end position and return to a gradual stop -float EaseInOutBack(float progress); ///< Slow start, exceed start position, fast middle, exceed end position and return to a gradual stop +inline float EaseInOutSine60( float progress ) ///< Speeds up and slows to a gradual stop +{ + float tmp = sinf(Math::PI_2 * 60.0f / 90.0f); + return (sinf((progress * Math::PI - Math::PI_2) * 60.0f / 90.0f) + tmp) / (2.0f * tmp); +} -float Sin(float progress); ///< Single revolution -float Sin2x(float progress); ///< Two revolutions +inline float EaseInOutSine70( float progress ) ///< Speeds up and slows to a gradual stop +{ + float tmp = sinf(Math::PI_2 * 70.0f / 90.0f); + return (sinf((progress * Math::PI - Math::PI_2) * 70.0f / 90.0f) + tmp) / (2.0f * tmp); +} + +inline float EaseInOutSine80( float progress ) ///< Speeds up and slows to a gradual stop +{ + float tmp = sinf(Math::PI_2 * 80.0f / 90.0f); + return (sinf((progress * Math::PI - Math::PI_2) * 80.0f / 90.0f) + tmp) / (2.0f * tmp); +} + +inline float EaseInOutSine90( float progress ) ///< Speeds up and slows to a gradual stop +{ + return EaseInOutSine(progress); +} + +inline float DoubleEaseInOutSine60( float progress ) ///< Speeds up and slows to a gradual stop, then speeds up again and slows to a gradual stop +{ + if (progress < 0.5f) + { + return EaseInOutSine60(progress * 2.0f) / 2.0f; + } + else + { + return EaseInOutSine60((progress - 0.5f) * 2.0f) / 2.0f + 0.5f; + } +} + +inline float EaseOutQuint50( float progress ) ///< Sudden start and slows to a gradual stop +{ + return 1.0f - powf(1.0f - progress, 1.7f); +} + +inline float EaseOutQuint80( float progress ) ///< Sudden start and slows to a gradual stop +{ + return 1.0f - powf(1.0f - progress, 2.3f); +} + +inline float Bounce( float progress ) ///< Sudden start, loses momentum and returns to start position +{ + return sinf(progress * Math::PI); +} + +inline float BounceBack( float progress ) ///< Sudden start, loses momentum and returns to exceed start position and gradual stop at start position +{ + if( progress > 0.0f ) + { + return (sinf(progress * 2.0f * Math::PI) * sinf(progress * Math::PI)) / (progress * Math::PI); + } + else + { + return 0; + } +} + +inline float EaseInBack( float progress ) ///< Slow start, exceed start position and quickly reach destination +{ + const float sqrt2 = 1.70158f; + + return progress * progress * ( ( sqrt2 + 1.0f ) * progress - sqrt2 ); +} + +inline float EaseOutBack( float progress ) ///< Sudden start, exceed end position and return to a gradual stop +{ + const float sqrt2 = 1.70158f; + progress -= 1.0f; + + return 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 ); +} + +inline float EaseInOutBack( float progress ) ///< Slow start, exceed start position, fast middle, exceed end position and return to a gradual stop +{ + if (progress > 0.5f) + { + return EaseOutBack((progress - 0.5f)*2.0f) * 0.5f + 0.5f; + } + else + { + return EaseInBack(progress * 2.0f) * 0.5f; + } +} + +inline float Sin( float progress ) ///< Single revolution +{ + return 0.5f - cosf(progress * 2.0f * Math::PI) * 0.5f; +} + +inline float Sin2x( float progress ) ///< Two revolutions +{ + return 0.5f - cosf(progress * 4.0f * Math::PI) * 0.5f; +} } // namespace AlphaFunctions diff --git a/dali/public-api/animation/constraints.cpp b/dali/public-api/animation/constraints.cpp deleted file mode 100644 index 770a8acb8..000000000 --- a/dali/public-api/animation/constraints.cpp +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// ScaleToFitConstraint -/////////////////////////////////////////////////////////////////////////////////////////////////// - -ScaleToFitConstraint::ScaleToFitConstraint() -{ - -} - -Vector3 ScaleToFitConstraint::operator()(const Vector3& current, - const PropertyInput& sizeProperty, - const PropertyInput& parentSizeProperty) -{ - const Vector3 size = sizeProperty.GetVector3(); - const Vector3 parentSize = parentSizeProperty.GetVector3(); - - return Vector3( fabsf(size.x) > Math::MACHINE_EPSILON_1 ? (parentSize.x / size.x) : 0.0f, - fabsf(size.y) > Math::MACHINE_EPSILON_1 ? (parentSize.y / size.y) : 0.0f, - fabsf(size.z) > Math::MACHINE_EPSILON_1 ? (parentSize.z / size.z) : 0.0f ); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// ScaleToFitKeepAspectRatioConstraint -/////////////////////////////////////////////////////////////////////////////////////////////////// - -ScaleToFitKeepAspectRatioConstraint::ScaleToFitKeepAspectRatioConstraint() -{ - -} - -Vector3 ScaleToFitKeepAspectRatioConstraint::operator() ( - const Vector3& current, - const PropertyInput& sizeProperty, - const PropertyInput& parentSizeProperty ) -{ - return FitKeepAspectRatio( parentSizeProperty.GetVector3(), sizeProperty.GetVector3() ); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// ScaleToFillKeepAspectRatioConstraint -/////////////////////////////////////////////////////////////////////////////////////////////////// - -ScaleToFillKeepAspectRatioConstraint::ScaleToFillKeepAspectRatioConstraint() -{ - -} - -Vector3 ScaleToFillKeepAspectRatioConstraint::operator() ( - const Vector3& current, - const PropertyInput& sizeProperty, - const PropertyInput& parentSizeProperty ) -{ - return FillKeepAspectRatio( parentSizeProperty.GetVector3(), sizeProperty.GetVector3() ); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// ScaleToFillXYKeepAspectRatioConstraint -/////////////////////////////////////////////////////////////////////////////////////////////////// - -ScaleToFillXYKeepAspectRatioConstraint::ScaleToFillXYKeepAspectRatioConstraint() -{ - -} - -Vector3 ScaleToFillXYKeepAspectRatioConstraint::operator() ( - const Vector3& current, - const PropertyInput& sizeProperty, - const PropertyInput& parentSizeProperty ) -{ - return FillXYKeepAspectRatio( parentSizeProperty.GetVector3(), sizeProperty.GetVector3() ); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// ShrinkInsideKeepAspectRatioConstraint -/////////////////////////////////////////////////////////////////////////////////////////////////// - -ShrinkInsideKeepAspectRatioConstraint::ShrinkInsideKeepAspectRatioConstraint() -{ -} - -Vector3 ShrinkInsideKeepAspectRatioConstraint::operator() ( - const Vector3& current, - const PropertyInput& sizeProperty, - const PropertyInput& parentSizeProperty ) -{ - return ShrinkInsideKeepAspectRatio( parentSizeProperty.GetVector3(), sizeProperty.GetVector3() ); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// MultiplyConstraint -/////////////////////////////////////////////////////////////////////////////////////////////////// - -MultiplyConstraint::MultiplyConstraint() -{ - -} - -Vector3 MultiplyConstraint::operator()(const Vector3& current, - const PropertyInput& property) -{ - return current * property.GetVector3(); -} - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// DivideConstraint -/////////////////////////////////////////////////////////////////////////////////////////////////// - -DivideConstraint::DivideConstraint() -{ - -} - -Vector3 DivideConstraint::operator()(const Vector3& current, - const PropertyInput& property) -{ - const Vector3 value = property.GetVector3(); - - return Vector3( fabsf(value.x) > Math::MACHINE_EPSILON_1 ? (current.x / value.x) : 0.0f, - fabsf(value.y) > Math::MACHINE_EPSILON_1 ? (current.y / value.y) : 0.0f, - fabsf(value.z) > Math::MACHINE_EPSILON_1 ? (current.z / value.z) : 0.0f ); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// EqualToConstraint -/////////////////////////////////////////////////////////////////////////////////////////////////// - -EqualToConstraint::EqualToConstraint() -{ -} - -float EqualToConstraint::operator()(const float current, const PropertyInput& property) -{ - return property.GetFloat(); -} - -Vector3 EqualToConstraint::operator()(const Vector3& current, const PropertyInput& property) -{ - return property.GetVector3(); -} - -Vector4 EqualToConstraint::operator()(const Vector4& current, const PropertyInput& property) -{ - return property.GetVector4(); -} - -Quaternion EqualToConstraint::operator()(const Quaternion& current, const PropertyInput& property) -{ - return property.GetQuaternion(); -} - -Matrix3 EqualToConstraint::operator()(const Matrix3& current, const PropertyInput& property) -{ - return property.GetMatrix3(); -} - -Matrix EqualToConstraint::operator()(const Matrix& current, const PropertyInput& property) -{ - return property.GetMatrix(); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// RelativeToConstraint -/////////////////////////////////////////////////////////////////////////////////////////////////// - -RelativeToConstraint::RelativeToConstraint( float scale ) -: mScale( scale, scale, scale ) -{ -} - -RelativeToConstraint::RelativeToConstraint( const Vector3& scale ) -: mScale( scale ) -{ -} - -Vector3 RelativeToConstraint::operator()( const Vector3& current, const PropertyInput& property ) -{ - return property.GetVector3() * mScale; -} - -RelativeToConstraintFloat::RelativeToConstraintFloat( float scale ) -: mScale( scale ) -{ -} - -float RelativeToConstraintFloat::operator()( const float current, const PropertyInput& property ) -{ - return property.GetFloat() * mScale; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// InverseOfConstraint -/////////////////////////////////////////////////////////////////////////////////////////////////// - -InverseOfConstraint::InverseOfConstraint() -{ - -} - -Vector3 InverseOfConstraint::operator()(const Vector3& current, - const PropertyInput& property) -{ - const Vector3& value = property.GetVector3(); - - return Vector3( fabsf(value.x) > Math::MACHINE_EPSILON_1 ? (1.0f / value.x) : 0.0f, - fabsf(value.y) > Math::MACHINE_EPSILON_1 ? (1.0f / value.y) : 0.0f, - fabsf(value.z) > Math::MACHINE_EPSILON_1 ? (1.0f / value.z) : 0.0f ); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// SourceWidthFixedHeight -/////////////////////////////////////////////////////////////////////////////////////////////////// - -SourceWidthFixedHeight::SourceWidthFixedHeight( float height ) -: mFixedHeight( height ) -{ -} - -Vector3 SourceWidthFixedHeight::operator()( const Vector3& current, const PropertyInput& sourceSize ) -{ - return Vector3( sourceSize.GetVector3().width, mFixedHeight, current.depth ); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// SourceHeightFixedWidth -/////////////////////////////////////////////////////////////////////////////////////////////////// - -SourceHeightFixedWidth::SourceHeightFixedWidth( float width ) -: mFixedWidth( width ) -{ -} - -Vector3 SourceHeightFixedWidth::operator()( const Vector3& current, const PropertyInput& sourceSize ) -{ - return Vector3( mFixedWidth, sourceSize.GetVector3().height, current.depth ); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// LookAt -/////////////////////////////////////////////////////////////////////////////////////////////////// - -static Quaternion LookAtTarget( const Vector3& vZ, const Quaternion& targetRotation ) -{ - Vector3 targetY(targetRotation.Rotate(Vector3::YAXIS)); - targetY.Normalize(); - - // Camera Right vector is perpendicular to forward & target up - Vector3 vX = targetY.Cross(vZ); - vX.Normalize(); - - // Camera Up vector is perpendicular to forward and right - Vector3 vY = vZ.Cross(vX); - vY.Normalize(); - - return Quaternion( vX, vY, vZ ); -} - -Dali::Quaternion LookAt( const Dali::Quaternion& current, - const PropertyInput& targetPosition, - const PropertyInput& cameraPosition, - const PropertyInput& targetRotation ) -{ - Vector3 vForward = targetPosition.GetVector3() - cameraPosition.GetVector3(); - vForward.Normalize(); - - return LookAtTarget(vForward, targetRotation.GetQuaternion()); -} - - -OrientedLookAt::OrientedLookAt( float angle ) -: mAngle (angle) -{ -} - -Quaternion OrientedLookAt::operator()(const Dali::Quaternion& current, - const PropertyInput& targetPosition, - const PropertyInput& cameraPosition, - const PropertyInput& targetRotation ) -{ - Vector3 vForward = targetPosition.GetVector3() - cameraPosition.GetVector3(); - vForward.Normalize(); - - // Calculate world vector of target's local up rotated by mAngle around z axis, - // multiplied by target's world rotation - Quaternion worldRot = targetRotation.GetQuaternion(); - Quaternion localRot( mAngle, Vector3::ZAXIS ); - Quaternion targetOrientation = worldRot * localRot; - - return LookAtTarget(vForward, targetOrientation); -} - -} // namespace Dali diff --git a/dali/public-api/animation/constraints.h b/dali/public-api/animation/constraints.h index d9f467edb..391a9983e 100644 --- a/dali/public-api/animation/constraints.h +++ b/dali/public-api/animation/constraints.h @@ -20,28 +20,28 @@ // INTERNAL INCLUDES #include +#include #include +#include +#include +#include namespace Dali { -class PropertyInput; -class Quaternion; -class Matrix; -class Matrix3; - /** * @brief Scale To Fit constraint. * * Scales an Actor, such that it fits within it's Parent's Size. * f(current, size, parentSize) = parentSize / size */ -struct DALI_IMPORT_API ScaleToFitConstraint +struct ScaleToFitConstraint { /** * @brief Constructor. */ - ScaleToFitConstraint(); + ScaleToFitConstraint() + { } /** * @brief Functor operator @@ -53,8 +53,15 @@ struct DALI_IMPORT_API ScaleToFitConstraint */ Vector3 operator()(const Vector3& current, const PropertyInput& sizeProperty, - const PropertyInput& parentSizeProperty); - + const PropertyInput& parentSizeProperty) + { + const Vector3 size = sizeProperty.GetVector3(); + const Vector3 parentSize = parentSizeProperty.GetVector3(); + + return Vector3( fabsf(size.x) > Math::MACHINE_EPSILON_1 ? (parentSize.x / size.x) : 0.0f, + fabsf(size.y) > Math::MACHINE_EPSILON_1 ? (parentSize.y / size.y) : 0.0f, + fabsf(size.z) > Math::MACHINE_EPSILON_1 ? (parentSize.z / size.z) : 0.0f ); + } }; /** @@ -63,12 +70,13 @@ struct DALI_IMPORT_API ScaleToFitConstraint * Scales an Actor, such that it fits within its Parent's Size Keeping the aspect ratio. * f(current, size, parentSize) = Vector3( min( parentSizeX / sizeX, min( parentSizeY / sizeY, parentSizeZ / sizeZ ) ) */ -struct DALI_IMPORT_API ScaleToFitKeepAspectRatioConstraint +struct ScaleToFitKeepAspectRatioConstraint { /** * @brief Constructor. */ - ScaleToFitKeepAspectRatioConstraint(); + ScaleToFitKeepAspectRatioConstraint() + { } /** * @brief Functor operator @@ -80,31 +88,10 @@ struct DALI_IMPORT_API ScaleToFitKeepAspectRatioConstraint */ Vector3 operator()(const Vector3& current, const PropertyInput& sizeProperty, - const PropertyInput& parentSizeProperty); -}; - -/** - * @brief Scale To Fill Keep Aspect Ratio constraint. - * - * Scales an Actor, such that it fill its Parent's Size Keeping the aspect ratio. - * f(current, size, parentSize) = Vector3( max( parentSizeX / sizeX, max( parentSizeY / sizeY, parentSizeZ / sizeZ ) ) - */ -struct DALI_IMPORT_API ScaleToFillKeepAspectRatioConstraint -{ - /** - * @brief Constructor. - */ - ScaleToFillKeepAspectRatioConstraint(); - - /** - * @param[in] current The actor's current scale - * @param[in] sizeProperty The actor's current size - * @param[in] parentSizeProperty The parent's current size. - * @return The actor's new scale - */ - Vector3 operator()(const Vector3& current, - const PropertyInput& sizeProperty, - const PropertyInput& parentSizeProperty); + const PropertyInput& parentSizeProperty) + { + return FitKeepAspectRatio( parentSizeProperty.GetVector3(), sizeProperty.GetVector3() ); + } }; /** @@ -113,34 +100,13 @@ struct DALI_IMPORT_API ScaleToFillKeepAspectRatioConstraint * Scales an Actor, such that it fill its Parent's Size in the X and Y coordinates Keeping the aspect ratio. * f(current, size, parentSize) = Vector3( max( parentSizeX / sizeX, max( parentSizeY / sizeY, parentSizeZ / sizeZ ) ) */ -struct DALI_IMPORT_API ScaleToFillXYKeepAspectRatioConstraint -{ - /** - * @brief Constructor. - */ - ScaleToFillXYKeepAspectRatioConstraint(); - - /** - * @param[in] current The actor's current scale - * @param[in] sizeProperty The actor's current size - * @param[in] parentSizeProperty The parent's current size. - * @return The actor's new scale - */ - Vector3 operator()(const Vector3& current, - const PropertyInput& sizeProperty, - const PropertyInput& parentSizeProperty); -}; - -/** - * @brief Shrinks source size inside the target size maintaining aspect ratio of source. - * If source is smaller than target it returns source - */ -struct ShrinkInsideKeepAspectRatioConstraint +struct ScaleToFillXYKeepAspectRatioConstraint { /** * @brief Constructor. */ - ShrinkInsideKeepAspectRatioConstraint(); + ScaleToFillXYKeepAspectRatioConstraint() + { } /** * @param[in] current The actor's current scale @@ -150,49 +116,10 @@ struct ShrinkInsideKeepAspectRatioConstraint */ Vector3 operator()(const Vector3& current, const PropertyInput& sizeProperty, - const PropertyInput& parentSizeProperty); -}; - -/** - * @brief MultiplyConstraint - * - * f(current, property) = current * property - */ -struct DALI_IMPORT_API MultiplyConstraint -{ - /** - * @brief Constructor. - */ - MultiplyConstraint(); - - /** - * @param[in] current The object's current property value - * @param[in] property The property to multiply by. - * @return The object's new property value - */ - Vector3 operator()(const Vector3& current, - const PropertyInput& property); -}; - -/** - * @brief DivideConstraint - * - * f(current, property) = current / property - */ -struct DALI_IMPORT_API DivideConstraint -{ - /** - * @brief Constructor. - */ - DivideConstraint(); - - /** - * @param[in] current The object's current property value - * @param[in] property The property to divide by. - * @return The object's new property value - */ - Vector3 operator()(const Vector3& current, - const PropertyInput& property); + const PropertyInput& parentSizeProperty) + { + return FillXYKeepAspectRatio( parentSizeProperty.GetVector3(), sizeProperty.GetVector3() ); + } }; /** @@ -200,12 +127,13 @@ struct DALI_IMPORT_API DivideConstraint * * f(current, property) = property */ -struct DALI_IMPORT_API EqualToConstraint +struct EqualToConstraint { /** * @brief Constructor. */ - EqualToConstraint(); + EqualToConstraint() + { } /** * @brief override functor for float properties @@ -214,7 +142,10 @@ struct DALI_IMPORT_API EqualToConstraint * @param[in] property The property to copy * @return The copy of the input property */ - float operator()(const float current, const PropertyInput& property); + float operator()(const float current, const PropertyInput& property) + { + return property.GetFloat(); + } /** * @brief override functor for float properties @@ -223,7 +154,10 @@ struct DALI_IMPORT_API EqualToConstraint * @param[in] property The property to copy * @return The copy of the input property */ - Vector3 operator()(const Vector3& current, const PropertyInput& property); + Vector3 operator()(const Vector3& current, const PropertyInput& property) + { + return property.GetVector3(); + } /** * @brief override functor for float properties @@ -232,7 +166,10 @@ struct DALI_IMPORT_API EqualToConstraint * @param[in] property The property to copy * @return The copy of the input property */ - Vector4 operator()(const Vector4& current, const PropertyInput& property); + Vector4 operator()(const Vector4& current, const PropertyInput& property) + { + return property.GetVector4(); + } /** * @brief override functor for float properties @@ -241,7 +178,10 @@ struct DALI_IMPORT_API EqualToConstraint * @param[in] property The property to copy * @return The copy of the input property */ - Quaternion operator()(const Quaternion& current, const PropertyInput& property); + Quaternion operator()(const Quaternion& current, const PropertyInput& property) + { + return property.GetQuaternion(); + } /** * @brief override functor for float properties @@ -250,7 +190,10 @@ struct DALI_IMPORT_API EqualToConstraint * @param[in] property The property to copy * @return The copy of the input property */ - Matrix3 operator()(const Matrix3& current, const PropertyInput& property); + Matrix3 operator()(const Matrix3& current, const PropertyInput& property) + { + return property.GetMatrix3(); + } /** * @brief override functor for float properties @@ -259,7 +202,11 @@ struct DALI_IMPORT_API EqualToConstraint * @param[in] property The property to copy * @return The copy of the input property */ - Matrix operator()(const Matrix& current, const PropertyInput& property); + Matrix operator()(const Matrix& current, const PropertyInput& property) + { + return property.GetMatrix(); + } + }; /** @@ -267,22 +214,27 @@ struct DALI_IMPORT_API EqualToConstraint * * f(current, property, scale) = property * scale */ -struct DALI_IMPORT_API RelativeToConstraint +struct RelativeToConstraint { /** * @brief Constructor. */ - RelativeToConstraint( float scale ); + RelativeToConstraint( float scale ) + : mScale( scale, scale, scale ) { } /** * @brief Constructor. */ - RelativeToConstraint( const Vector3& scale ); + RelativeToConstraint( const Vector3& scale ) + : mScale( scale ) { } /** * @brief Functor. */ - Vector3 operator()(const Vector3& current, const PropertyInput& property); + Vector3 operator()(const Vector3& current, const PropertyInput& property) + { + return property.GetVector3() * mScale; + } Vector3 mScale; ///< Component-wise scale factor }; @@ -290,80 +242,49 @@ struct DALI_IMPORT_API RelativeToConstraint /** * @brief RelativeToConstraint for float properties */ -struct DALI_IMPORT_API RelativeToConstraintFloat +struct RelativeToConstraintFloat { /** * @brief Constructor. */ - RelativeToConstraintFloat( float scale ); + RelativeToConstraintFloat( float scale ) + : mScale( scale ) { } /** * @brief Functor. */ - float operator()(const float current, const PropertyInput& property); + float operator()(const float current, const PropertyInput& property) + { + return property.GetFloat() * mScale; + } float mScale; ///< Scale factor }; -/** - * @brief InverseOfConstraint - * - * f(current, property) = 1 / property - */ -struct DALI_IMPORT_API InverseOfConstraint -{ - /** - * @brief Constructor. - */ - InverseOfConstraint(); - - /** - * @brief Functor. - */ - Vector3 operator()(const Vector3& current, - const PropertyInput& property); -}; - /** * @brief Constraint which sets width to be another actor's width, * and the height to a fixed height. */ -struct DALI_IMPORT_API SourceWidthFixedHeight +struct SourceWidthFixedHeight { /** * @brief Constructor. */ - SourceWidthFixedHeight( float height ); + SourceWidthFixedHeight( float height ) + : mFixedHeight( height ) { } /** * @brief Functor. */ Vector3 operator()(const Vector3& current, - const PropertyInput& sourceSize); + const PropertyInput& sourceSize) + { + return Vector3( sourceSize.GetVector3().width, mFixedHeight, current.depth ); + } float mFixedHeight; ///< the fixed height }; -/** - * @brief Constraint which sets height to be another actor's height, - * and the width to a fixed width. - */ -struct DALI_IMPORT_API SourceHeightFixedWidth -{ - /** - * @brief Constructor - */ - SourceHeightFixedWidth( float width ); - - /** - * @brief Functor - */ - Vector3 operator()(const Vector3& current, - const PropertyInput& sourceSize); - - float mFixedWidth; ///< the fixed width -}; - /** * @brief Constraint function to aim a camera at a target. * @@ -378,48 +299,29 @@ struct DALI_IMPORT_API SourceHeightFixedWidth * @param[in] targetRotation World rotation of the target * @return The orientation of the camera */ -DALI_IMPORT_API Dali::Quaternion LookAt( const Dali::Quaternion& current, - const PropertyInput& targetPosition, - const PropertyInput& cameraPosition, - const PropertyInput& targetRotation ); +inline Quaternion LookAt( const Quaternion& current, + const PropertyInput& targetPosition, + const PropertyInput& cameraPosition, + const PropertyInput& targetRotation ) +{ + Vector3 vForward = targetPosition.GetVector3() - cameraPosition.GetVector3(); + vForward.Normalize(); + const Quaternion& targetRotationQ = targetRotation.GetQuaternion(); -/** - * @brief Constraint functor to aim a camera at a target. - * - * Constraint which sets rotation given camera world position, - * target world position (usually the looked at actor's world position) - * and the angle parameter (how much the camera is offset with respect - * to the target's up vector). - */ -struct DALI_IMPORT_API OrientedLookAt -{ - /** - * @brief Functor constructor. - * - * @param[in] angle The angle of the camera's up vector with regards - * to the target's up vector in radians. Positive angles rotate the - * camera clockwise, negative angles rotate anti-clockwise. - */ - OrientedLookAt( float angle ); + Vector3 targetY(targetRotationQ.Rotate(Vector3::YAXIS)); + targetY.Normalize(); - /** - * @brief Functor. - * - * @param[in] current The current rotation property value - * @param[in] targetPosition World position of target - * @param[in] cameraPosition World position of camera - * @param[in] targetRotation World rotation of the target - * @return The orientation of the camera - */ - Dali::Quaternion operator()(const Dali::Quaternion& current, - const PropertyInput& targetPosition, - const PropertyInput& cameraPosition, - const PropertyInput& targetRotation ); + // Camera Right vector is perpendicular to forward & target up + Vector3 vX = targetY.Cross(vForward); + vX.Normalize(); - float mAngle; ///< camera angle offset -}; + // Camera Up vector is perpendicular to forward and right + Vector3 vY = vForward.Cross(vX); + vY.Normalize(); + return Quaternion( vX, vY, vForward ); +} } // namespace Dali diff --git a/dali/public-api/file.list b/dali/public-api/file.list index cac1c2b52..b80e6b5b3 100644 --- a/dali/public-api/file.list +++ b/dali/public-api/file.list @@ -17,7 +17,6 @@ public_api_src_files = \ $(public_api_src_dir)/animation/animation.cpp \ $(public_api_src_dir)/animation/alpha-functions.cpp \ $(public_api_src_dir)/animation/constraint.cpp \ - $(public_api_src_dir)/animation/constraints.cpp \ $(public_api_src_dir)/animation/constraint-source.cpp \ $(public_api_src_dir)/animation/interpolator-functions.cpp \ $(public_api_src_dir)/animation/key-frames.cpp \ -- 2.34.1