Commit f6dac5b48f3df4b1c767174606b743e8b7720db1
1 parent
fa811aa9
Using New Constraints
Change-Id: I67da11782751f55f9e2a020f5ba269e5baf57ced
Showing
7 changed files
with
195 additions
and
267 deletions
demo/dali-table-view.cpp
| @@ -151,20 +151,19 @@ public: | @@ -151,20 +151,19 @@ public: | ||
| 151 | { | 151 | { |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | - Vector3 operator()( const Vector3& current, const PropertyInput& scrollProperty, const PropertyInput& parentSize ) | 154 | + void operator()( Vector3& position, const PropertyInputContainer& inputs ) |
| 155 | { | 155 | { |
| 156 | - Vector3 pos( current ); | ||
| 157 | - const float parentHeight = parentSize.GetVector3().height; | 156 | + const Vector3& parentSize = inputs[1]->GetVector3(); |
| 158 | 157 | ||
| 159 | - // Wrap bubbles vertically | ||
| 160 | - if( pos.y + mShapeSize * 0.5f < -parentHeight * 0.5f ) | 158 | + // Wrap bubbles verically. |
| 159 | + if( position.y + mShapeSize * 0.5f < -parentSize.y * 0.5f ) | ||
| 161 | { | 160 | { |
| 162 | - pos.y = parentHeight * 0.5f + mShapeSize * 0.5f; | 161 | + position.y = parentSize.y * 0.5f + mShapeSize * 0.5f; |
| 163 | } | 162 | } |
| 164 | 163 | ||
| 165 | - // Bubbles X position moves parallax to horizontal panning by a scale factor unique to each bubble | ||
| 166 | - pos.x = mInitialX + ( scrollProperty.GetVector3().x * mScale ); | ||
| 167 | - return pos; | 164 | + // Bubbles X position moves parallax to horizontal |
| 165 | + // panning by a scale factor unique to each bubble. | ||
| 166 | + position.x = mInitialX + ( inputs[0]->GetVector3().x * mScale ); | ||
| 168 | } | 167 | } |
| 169 | 168 | ||
| 170 | private: | 169 | private: |
| @@ -780,11 +779,10 @@ void DaliTableView::InitialiseBackgroundActors( Actor actor ) | @@ -780,11 +779,10 @@ void DaliTableView::InitialiseBackgroundActors( Actor actor ) | ||
| 780 | child.SetPosition( childPos ); | 779 | child.SetPosition( childPos ); |
| 781 | 780 | ||
| 782 | // Define bubble horizontal parallax and vertical wrapping | 781 | // Define bubble horizontal parallax and vertical wrapping |
| 783 | - Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::POSITION, | ||
| 784 | - Source( mScrollView, ScrollView::Property::SCROLL_POSITION ), | ||
| 785 | - Dali::ParentSource( Dali::Actor::Property::SIZE ), | ||
| 786 | - AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ), childSize.height ) ); | ||
| 787 | - child.ApplyConstraint( animConstraint ); | 782 | + Constraint animConstraint = Constraint::New < Vector3 > ( child, Actor::Property::POSITION, AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ), childSize.height ) ); |
| 783 | + animConstraint.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) ); | ||
| 784 | + animConstraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) ); | ||
| 785 | + animConstraint.Apply(); | ||
| 788 | 786 | ||
| 789 | // Kickoff animation | 787 | // Kickoff animation |
| 790 | Animation animation = Animation::New( Random::Range( 40.0f, 80.0f ) ); | 788 | Animation animation = Animation::New( Random::Range( 40.0f, 80.0f ) ); |
examples/blocks/blocks-example.cpp
| @@ -73,65 +73,6 @@ const int TOTAL_LEVELS(3); ///< | @@ -73,65 +73,6 @@ const int TOTAL_LEVELS(3); ///< | ||
| 73 | // constraints //////////////////////////////////////////////////////////////// | 73 | // constraints //////////////////////////////////////////////////////////////// |
| 74 | 74 | ||
| 75 | /** | 75 | /** |
| 76 | - * CollisionConstraint generates a collision vector | ||
| 77 | - * between two actors a and b, assuming they're rectangular | ||
| 78 | - * based on their size. | ||
| 79 | - */ | ||
| 80 | -struct CollisionConstraint | ||
| 81 | -{ | ||
| 82 | - /** | ||
| 83 | - * Collision Constraint constructor | ||
| 84 | - * The adjust (optional) parameter can be used to add a margin | ||
| 85 | - * to the actors. A +ve size will result in larger collisions, | ||
| 86 | - * while a -ve size will result in tighter collisions. | ||
| 87 | - * | ||
| 88 | - * @param[in] adjust (optional) Adjusts the rectangular size detection | ||
| 89 | - */ | ||
| 90 | - CollisionConstraint(Vector3 adjust = Vector3::ZERO) | ||
| 91 | - : mAdjust(adjust) | ||
| 92 | - { | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - /** | ||
| 96 | - * Generates collision vector indicating whether Actor's A and B | ||
| 97 | - * have overlapped eachother, and the relative position of Actor B to A. | ||
| 98 | - * | ||
| 99 | - * @param[in] current The current collision-property (ignored) | ||
| 100 | - * @param[in] propertyA Actor A's Position property. | ||
| 101 | - * @param[in] propertyB Actor B's Position property. | ||
| 102 | - * @param[in] propertySizeA Actor A's Size property. | ||
| 103 | - * @param[in] propertySizeB Actor B's Size property. | ||
| 104 | - * @return The collision vector is returned. | ||
| 105 | - */ | ||
| 106 | - Vector3 operator()(const Vector3& current, | ||
| 107 | - const PropertyInput& propertyA, | ||
| 108 | - const PropertyInput& propertyB, | ||
| 109 | - const PropertyInput& propertySizeA, | ||
| 110 | - const PropertyInput& propertySizeB) | ||
| 111 | - { | ||
| 112 | - const Vector3& a = propertyA.GetVector3(); | ||
| 113 | - const Vector3& b = propertyB.GetVector3(); | ||
| 114 | - const Vector3& sizeA = propertySizeA.GetVector3(); | ||
| 115 | - const Vector3& sizeB = propertySizeB.GetVector3(); | ||
| 116 | - const Vector3 sizeComb = (sizeA + sizeB + mAdjust) * 0.5f; | ||
| 117 | - | ||
| 118 | - // get collision relative to a. | ||
| 119 | - Vector3 delta = b - a; | ||
| 120 | - | ||
| 121 | - // Check if not overlapping Actors. | ||
| 122 | - if( (fabsf(delta.x) > sizeComb.width) || | ||
| 123 | - (fabsf(delta.y) > sizeComb.height) ) | ||
| 124 | - { | ||
| 125 | - delta = Vector3::ZERO; // not overlapping | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - return delta; // overlapping, return overlap vector relative to actor a. | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | - const Vector3 mAdjust; ///< Size Adjustment value | ||
| 132 | -}; | ||
| 133 | - | ||
| 134 | -/** | ||
| 135 | * CollisionCircleRectangleConstraint generates a collision vector | 76 | * CollisionCircleRectangleConstraint generates a collision vector |
| 136 | * between two actors a (circle) and b (rectangle) | 77 | * between two actors a (circle) and b (rectangle) |
| 137 | */ | 78 | */ |
| @@ -157,23 +98,20 @@ struct CollisionCircleRectangleConstraint | @@ -157,23 +98,20 @@ struct CollisionCircleRectangleConstraint | ||
| 157 | * Generates collision vector indicating whether Actor's A and B | 98 | * Generates collision vector indicating whether Actor's A and B |
| 158 | * have overlapped eachother, and the relative position of Actor B to A. | 99 | * have overlapped eachother, and the relative position of Actor B to A. |
| 159 | * | 100 | * |
| 160 | - * @param[in] current The current collision-property (ignored) | ||
| 161 | - * @param[in] propertyA Actor A's Position property. | ||
| 162 | - * @param[in] propertyB Actor B's Position property. | ||
| 163 | - * @param[in] propertySizeA Actor A's Size property. | ||
| 164 | - * @param[in] propertySizeB Actor B's Size property. | 101 | + * @param[in,out] current The current collision-property |
| 102 | + * @param[in] inputs Contains: | ||
| 103 | + * Actor A's Position property. | ||
| 104 | + * Actor B's Position property. | ||
| 105 | + * Actor A's Size property. | ||
| 106 | + * Actor B's Size property. | ||
| 165 | * @return The collision vector is returned. | 107 | * @return The collision vector is returned. |
| 166 | */ | 108 | */ |
| 167 | - Vector3 operator()(const Vector3& current, | ||
| 168 | - const PropertyInput& propertyA, | ||
| 169 | - const PropertyInput& propertyB, | ||
| 170 | - const PropertyInput& propertySizeA, | ||
| 171 | - const PropertyInput& propertySizeB) | 109 | + void operator()( Vector3& current, const PropertyInputContainer& inputs ) |
| 172 | { | 110 | { |
| 173 | - const Vector3& a = propertyA.GetVector3(); | ||
| 174 | - const Vector3 b = propertyB.GetVector3() + mAdjustPosition; | ||
| 175 | - const Vector3& sizeA = propertySizeA.GetVector3(); | ||
| 176 | - const Vector3& sizeB = propertySizeB.GetVector3(); | 111 | + const Vector3& a = inputs[0]->GetVector3(); |
| 112 | + const Vector3 b = inputs[1]->GetVector3() + mAdjustPosition; | ||
| 113 | + const Vector3& sizeA = inputs[2]->GetVector3(); | ||
| 114 | + const Vector3& sizeB = inputs[3]->GetVector3(); | ||
| 177 | const Vector3 sizeA2 = sizeA * 0.5f; // circle radius | 115 | const Vector3 sizeA2 = sizeA * 0.5f; // circle radius |
| 178 | const Vector3 sizeB2 = (sizeB + mAdjustSize) * 0.5f; // rectangle half rectangle. | 116 | const Vector3 sizeB2 = (sizeB + mAdjustSize) * 0.5f; // rectangle half rectangle. |
| 179 | 117 | ||
| @@ -211,10 +149,12 @@ struct CollisionCircleRectangleConstraint | @@ -211,10 +149,12 @@ struct CollisionCircleRectangleConstraint | ||
| 211 | if(delta.Length() < sizeA2.x) | 149 | if(delta.Length() < sizeA2.x) |
| 212 | { | 150 | { |
| 213 | delta.Normalize(); | 151 | delta.Normalize(); |
| 214 | - return delta; | 152 | + current = delta; |
| 153 | + } | ||
| 154 | + else | ||
| 155 | + { | ||
| 156 | + current = Vector3::ZERO; | ||
| 215 | } | 157 | } |
| 216 | - | ||
| 217 | - return Vector3::ZERO; | ||
| 218 | } | 158 | } |
| 219 | 159 | ||
| 220 | const Vector3 mAdjustPosition; ///< Position Adjustment value | 160 | const Vector3 mAdjustPosition; ///< Position Adjustment value |
| @@ -243,20 +183,17 @@ struct WobbleConstraint | @@ -243,20 +183,17 @@ struct WobbleConstraint | ||
| 243 | } | 183 | } |
| 244 | 184 | ||
| 245 | /** | 185 | /** |
| 246 | - * @param[in] current The current rotation property (ignored) | ||
| 247 | - * @param[in] propertyWobble The wobble property (value from 0.0f to 1.0f) | 186 | + * @param[in,out] current The current rotation property |
| 187 | + * @param[in] inputs Contains the wobble property (value from 0.0f to 1.0f) | ||
| 248 | * @return The rotation (quaternion) is generated. | 188 | * @return The rotation (quaternion) is generated. |
| 249 | */ | 189 | */ |
| 250 | - Quaternion operator()(const Quaternion& current, | ||
| 251 | - const PropertyInput& propertyWobble) | 190 | + void operator()( Quaternion& current, const PropertyInputContainer& inputs ) |
| 252 | { | 191 | { |
| 253 | - const float& wobble = propertyWobble.GetFloat(); | 192 | + const float& wobble = inputs[0]->GetFloat(); |
| 254 | 193 | ||
| 255 | float f = sinf(wobble * 10.0f) * (1.0f-wobble); | 194 | float f = sinf(wobble * 10.0f) * (1.0f-wobble); |
| 256 | 195 | ||
| 257 | - Quaternion q(mDeviation * f, Vector3::ZAXIS); | ||
| 258 | - | ||
| 259 | - return q; | 196 | + current = Quaternion(mDeviation * f, Vector3::ZAXIS); |
| 260 | } | 197 | } |
| 261 | 198 | ||
| 262 | const float mDeviation; ///< Deviation factor in radians. | 199 | const float mDeviation; ///< Deviation factor in radians. |
| @@ -346,10 +283,9 @@ private: | @@ -346,10 +283,9 @@ private: | ||
| 346 | mPaddleImage.SetSize( mPaddleFullSize ); | 283 | mPaddleImage.SetSize( mPaddleFullSize ); |
| 347 | 284 | ||
| 348 | mWobbleProperty = mPaddle.RegisterProperty(WOBBLE_PROPERTY_NAME, 0.0f); | 285 | mWobbleProperty = mPaddle.RegisterProperty(WOBBLE_PROPERTY_NAME, 0.0f); |
| 349 | - Constraint wobbleConstraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION, | ||
| 350 | - LocalSource(mWobbleProperty), | ||
| 351 | - WobbleConstraint(10.0f)); | ||
| 352 | - mPaddle.ApplyConstraint(wobbleConstraint); | 286 | + Constraint wobbleConstraint = Constraint::New<Quaternion>( mPaddle, Actor::Property::ORIENTATION, WobbleConstraint(10.0f)); |
| 287 | + wobbleConstraint.AddSource( LocalSource(mWobbleProperty) ); | ||
| 288 | + wobbleConstraint.Apply(); | ||
| 353 | 289 | ||
| 354 | mPaddle.SetPosition( stageSize * Vector3( PADDLE_START_POSITION ) ); | 290 | mPaddle.SetPosition( stageSize * Vector3( PADDLE_START_POSITION ) ); |
| 355 | mContentLayer.Add(mPaddle); | 291 | mContentLayer.Add(mPaddle); |
| @@ -375,13 +311,12 @@ private: | @@ -375,13 +311,12 @@ private: | ||
| 375 | Actor delegate = Actor::New(); | 311 | Actor delegate = Actor::New(); |
| 376 | stage.Add(delegate); | 312 | stage.Add(delegate); |
| 377 | Property::Index property = delegate.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO); | 313 | Property::Index property = delegate.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO); |
| 378 | - Constraint constraint = Constraint::New<Vector3>( property, | ||
| 379 | - Source(mBall, Actor::Property::POSITION), | ||
| 380 | - Source(mPaddle, Actor::Property::POSITION), | ||
| 381 | - Source(mBall, Actor::Property::SIZE), | ||
| 382 | - Source(mPaddle, Actor::Property::SIZE), | ||
| 383 | - CollisionCircleRectangleConstraint( -Vector3(0.0f, mPaddleHitMargin.height * 0.575f, 0.0f),-Vector3(mPaddleHitMargin) )); | ||
| 384 | - delegate.ApplyConstraint(constraint); | 314 | + Constraint constraint = Constraint::New<Vector3>( delegate, property, CollisionCircleRectangleConstraint( -Vector3(0.0f, mPaddleHitMargin.height * 0.575f, 0.0f),-Vector3(mPaddleHitMargin) ) ); |
| 315 | + constraint.AddSource( Source(mBall, Actor::Property::POSITION) ); | ||
| 316 | + constraint.AddSource( Source(mPaddle, Actor::Property::POSITION) ); | ||
| 317 | + constraint.AddSource( Source(mBall, Actor::Property::SIZE) ); | ||
| 318 | + constraint.AddSource( Source(mPaddle, Actor::Property::SIZE) ); | ||
| 319 | + constraint.Apply(); | ||
| 385 | 320 | ||
| 386 | PropertyNotification paddleNotification = delegate.AddPropertyNotification( property, GreaterThanCondition(0.0f) ); | 321 | PropertyNotification paddleNotification = delegate.AddPropertyNotification( property, GreaterThanCondition(0.0f) ); |
| 387 | paddleNotification.NotifySignal().Connect( this, &ExampleController::OnHitPaddle ); | 322 | paddleNotification.NotifySignal().Connect( this, &ExampleController::OnHitPaddle ); |
| @@ -600,13 +535,12 @@ private: | @@ -600,13 +535,12 @@ private: | ||
| 600 | 535 | ||
| 601 | // Add a constraint on the brick between it and the ball generating a collision-property | 536 | // Add a constraint on the brick between it and the ball generating a collision-property |
| 602 | Property::Index property = brick.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO); | 537 | Property::Index property = brick.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO); |
| 603 | - Constraint constraint = Constraint::New<Vector3>( property, | ||
| 604 | - Source(mBall, Actor::Property::POSITION), | ||
| 605 | - Source(brick, Actor::Property::POSITION), | ||
| 606 | - Source(mBall, Actor::Property::SIZE), | ||
| 607 | - Source(brick, Actor::Property::SIZE), | ||
| 608 | - CollisionCircleRectangleConstraint(BRICK_COLLISION_MARGIN)); | ||
| 609 | - brick.ApplyConstraint(constraint); | 538 | + Constraint constraint = Constraint::New<Vector3>( brick, property, CollisionCircleRectangleConstraint(BRICK_COLLISION_MARGIN) ); |
| 539 | + constraint.AddSource( Source(mBall, Actor::Property::POSITION) ); | ||
| 540 | + constraint.AddSource( Source(brick, Actor::Property::POSITION) ); | ||
| 541 | + constraint.AddSource( Source(mBall, Actor::Property::SIZE) ); | ||
| 542 | + constraint.AddSource( Source(brick, Actor::Property::SIZE) ); | ||
| 543 | + constraint.Apply(); | ||
| 610 | 544 | ||
| 611 | // Now add a notification on this collision-property | 545 | // Now add a notification on this collision-property |
| 612 | 546 |
examples/cluster/cluster-example.cpp
| @@ -183,15 +183,16 @@ struct CarouselEffectOrientationConstraint | @@ -183,15 +183,16 @@ struct CarouselEffectOrientationConstraint | ||
| 183 | * @param[in] current The object's current property value | 183 | * @param[in] current The object's current property value |
| 184 | * @return The object's new property value | 184 | * @return The object's new property value |
| 185 | */ | 185 | */ |
| 186 | - Vector2 operator()(const Vector2& current, | ||
| 187 | - const PropertyInput& propertyOrientation) | 186 | + void operator()( Vector2& current, const PropertyInputContainer& inputs ) |
| 188 | { | 187 | { |
| 189 | Vector3 axis; | 188 | Vector3 axis; |
| 190 | float angle; | 189 | float angle; |
| 191 | - propertyOrientation.GetQuaternion().ToAxisAngle( axis, angle ); | ||
| 192 | - Vector2 direction( cosf(angle), sinf(angle) ); | 190 | + inputs[0]->GetQuaternion().ToAxisAngle( axis, angle ); |
| 191 | + | ||
| 192 | + current.x = cosf(angle); | ||
| 193 | + current.y = sinf(angle); | ||
| 193 | 194 | ||
| 194 | - return mAngleSweep * direction; | 195 | + current *= mAngleSweep; |
| 195 | } | 196 | } |
| 196 | 197 | ||
| 197 | Vector2 mAngleSweep; | 198 | Vector2 mAngleSweep; |
| @@ -220,16 +221,13 @@ struct ShearEffectConstraint | @@ -220,16 +221,13 @@ struct ShearEffectConstraint | ||
| 220 | } | 221 | } |
| 221 | 222 | ||
| 222 | /** | 223 | /** |
| 223 | - * @param[in] current The current shear effect Angle. | ||
| 224 | - * @param[in] scrollOvershootProperty The overshoot property from ScrollView | ||
| 225 | - * @param[in] propertyViewOrientation The orientation of the view e.g. Portrait, Landscape. | 224 | + * @param[in,out] current The current shear effect Angle. |
| 225 | + * @param[in] inputs Contains the overshoot property from ScrollView and the orientation of the view e.g. Portrait, Landscape. | ||
| 226 | * @return angle to provide ShearShaderEffect | 226 | * @return angle to provide ShearShaderEffect |
| 227 | */ | 227 | */ |
| 228 | - float operator()(const float& current, | ||
| 229 | - const PropertyInput& scrollOvershootProperty, | ||
| 230 | - const PropertyInput& propertyViewOrientation) | 228 | + void operator()( float& current, const PropertyInputContainer& inputs ) |
| 231 | { | 229 | { |
| 232 | - float f = scrollOvershootProperty.GetVector3().x; | 230 | + float f = inputs[0]->GetVector3().x; |
| 233 | 231 | ||
| 234 | float mag = fabsf(f); | 232 | float mag = fabsf(f); |
| 235 | float halfWidth = mStageSize.x * 0.5f; | 233 | float halfWidth = mStageSize.x * 0.5f; |
| @@ -245,11 +243,11 @@ struct ShearEffectConstraint | @@ -245,11 +243,11 @@ struct ShearEffectConstraint | ||
| 245 | // the component mask passed in. | 243 | // the component mask passed in. |
| 246 | Vector3 axis; | 244 | Vector3 axis; |
| 247 | float angle; | 245 | float angle; |
| 248 | - propertyViewOrientation.GetQuaternion().ToAxisAngle( axis, angle ); | 246 | + inputs[1]->GetQuaternion().ToAxisAngle( axis, angle ); |
| 249 | Vector2 direction( cosf(angle), sinf(angle) ); | 247 | Vector2 direction( cosf(angle), sinf(angle) ); |
| 250 | float yield = direction.x * mComponentMask.x + direction.y * mComponentMask.y; | 248 | float yield = direction.x * mComponentMask.x + direction.y * mComponentMask.y; |
| 251 | 249 | ||
| 252 | - return overshoot * mMaxOvershoot * yield; | 250 | + current = overshoot * mMaxOvershoot * yield; |
| 253 | } | 251 | } |
| 254 | 252 | ||
| 255 | Vector2 mStageSize; | 253 | Vector2 mStageSize; |
| @@ -276,15 +274,15 @@ struct ShearEffectCenterConstraint | @@ -276,15 +274,15 @@ struct ShearEffectCenterConstraint | ||
| 276 | } | 274 | } |
| 277 | 275 | ||
| 278 | /** | 276 | /** |
| 279 | - * @param[in] current The current center | ||
| 280 | - * @param[in] propertyViewSize The current view size | 277 | + * @param[in,out] current The current center |
| 278 | + * @param[in] inputs Contains the current view size | ||
| 281 | * @return vector to provide ShearShaderEffect | 279 | * @return vector to provide ShearShaderEffect |
| 282 | */ | 280 | */ |
| 283 | - Vector2 operator()(const Vector2& current, | ||
| 284 | - const PropertyInput& propertyViewSize) | 281 | + void operator()( Vector2& current, const PropertyInputContainer& inputs ) |
| 285 | { | 282 | { |
| 286 | - float f = propertyViewSize.GetVector3().width / mStageSize.width; | ||
| 287 | - return Vector2( f * mCenter.x, mCenter.y ); | 283 | + float f = inputs[0]->GetVector3().width / mStageSize.width; |
| 284 | + current.x = f * mCenter.x; | ||
| 285 | + current.y = mCenter.y; | ||
| 288 | } | 286 | } |
| 289 | 287 | ||
| 290 | Vector2 mStageSize; | 288 | Vector2 mStageSize; |
| @@ -313,9 +311,9 @@ struct SphereEffectOffsetConstraint | @@ -313,9 +311,9 @@ struct SphereEffectOffsetConstraint | ||
| 313 | * @param[in] propertyViewSize The current view size | 311 | * @param[in] propertyViewSize The current view size |
| 314 | * @return vector to provide SphereShaderEffect | 312 | * @return vector to provide SphereShaderEffect |
| 315 | */ | 313 | */ |
| 316 | - float operator()(const float& current) | 314 | + void operator()( float& current, const PropertyInputContainer& /* inputs */ ) |
| 317 | { | 315 | { |
| 318 | - return current + mOffset; | 316 | + current += mOffset; |
| 319 | } | 317 | } |
| 320 | 318 | ||
| 321 | float mOffset; | 319 | float mOffset; |
| @@ -375,11 +373,11 @@ struct ClusterInfo | @@ -375,11 +373,11 @@ struct ClusterInfo | ||
| 375 | } | 373 | } |
| 376 | 374 | ||
| 377 | 375 | ||
| 378 | - Cluster mCluster; ///< Cluster instance | ||
| 379 | - int mIndex; ///< Cluster index | ||
| 380 | - Vector3 mPosition; ///< Cluster original position | ||
| 381 | - Vector3 mSize; ///< Cluster original size | ||
| 382 | - ActiveConstraint mEffectConstraint; ///< Cluster constraint | 376 | + Cluster mCluster; ///< Cluster instance |
| 377 | + int mIndex; ///< Cluster index | ||
| 378 | + Vector3 mPosition; ///< Cluster original position | ||
| 379 | + Vector3 mSize; ///< Cluster original size | ||
| 380 | + Constraint mEffectConstraint; ///< Cluster constraint | ||
| 383 | }; | 381 | }; |
| 384 | 382 | ||
| 385 | /** | 383 | /** |
| @@ -689,7 +687,7 @@ public: | @@ -689,7 +687,7 @@ public: | ||
| 689 | RemoveShaderEffectRecursively( cluster ); | 687 | RemoveShaderEffectRecursively( cluster ); |
| 690 | if( i->mEffectConstraint ) | 688 | if( i->mEffectConstraint ) |
| 691 | { | 689 | { |
| 692 | - cluster.RemoveConstraint(i->mEffectConstraint); | 690 | + i->mEffectConstraint.Remove(); |
| 693 | i->mEffectConstraint.Reset(); | 691 | i->mEffectConstraint.Reset(); |
| 694 | } | 692 | } |
| 695 | } | 693 | } |
| @@ -719,10 +717,10 @@ public: | @@ -719,10 +717,10 @@ public: | ||
| 719 | 717 | ||
| 720 | Vector2 shearCenter( Vector2(position.x + size.width * shearAnchor.x, position.y + size.height * shearAnchor.y) ); | 718 | Vector2 shearCenter( Vector2(position.x + size.width * shearAnchor.x, position.y + size.height * shearAnchor.y) ); |
| 721 | Property::Index centerProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetCenterPropertyName()); | 719 | Property::Index centerProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetCenterPropertyName()); |
| 722 | - Constraint constraint = Constraint::New<Vector2>( centerProperty, | ||
| 723 | - Source(mView, Actor::Property::SIZE), | ||
| 724 | - ShearEffectCenterConstraint(stageSize, shearCenter) ); | ||
| 725 | - shaderEffect.ApplyConstraint(constraint); | 720 | + Constraint constraint = Constraint::New<Vector2>( shaderEffect, centerProperty, ShearEffectCenterConstraint(stageSize, shearCenter) ); |
| 721 | + constraint.AddSource( Source(mView, Actor::Property::SIZE) ); | ||
| 722 | + | ||
| 723 | + constraint.Apply(); | ||
| 726 | 724 | ||
| 727 | SetShaderEffectRecursively( cluster,shaderEffect ); | 725 | SetShaderEffectRecursively( cluster,shaderEffect ); |
| 728 | 726 | ||
| @@ -731,16 +729,15 @@ public: | @@ -731,16 +729,15 @@ public: | ||
| 731 | Property::Index angleXAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleXAxisPropertyName()); | 729 | Property::Index angleXAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleXAxisPropertyName()); |
| 732 | Property::Index angleYAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleYAxisPropertyName()); | 730 | Property::Index angleYAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleYAxisPropertyName()); |
| 733 | 731 | ||
| 734 | - constraint = Constraint::New<float>( angleXAxisProperty, | ||
| 735 | - Source(mScrollView, scrollOvershootProperty), | ||
| 736 | - Source(mView, Actor::Property::ORIENTATION), | ||
| 737 | - ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) ); | ||
| 738 | - shaderEffect.ApplyConstraint(constraint); | ||
| 739 | - constraint = Constraint::New<float>( angleYAxisProperty, | ||
| 740 | - Source(mScrollView, scrollOvershootProperty), | ||
| 741 | - Source(mView, Actor::Property::ORIENTATION), | ||
| 742 | - ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS) ); | ||
| 743 | - shaderEffect.ApplyConstraint(constraint); | 732 | + constraint = Constraint::New<float>( shaderEffect, angleXAxisProperty, ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) ); |
| 733 | + constraint.AddSource( Source(mScrollView, scrollOvershootProperty) ); | ||
| 734 | + constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) ); | ||
| 735 | + constraint.Apply(); | ||
| 736 | + | ||
| 737 | + constraint = Constraint::New<float>( shaderEffect, angleYAxisProperty, ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS ) ); | ||
| 738 | + constraint.AddSource( Source(mScrollView, scrollOvershootProperty) ); | ||
| 739 | + constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) ); | ||
| 740 | + constraint.Apply(); | ||
| 744 | 741 | ||
| 745 | 742 | ||
| 746 | } | 743 | } |
| @@ -764,9 +761,9 @@ public: | @@ -764,9 +761,9 @@ public: | ||
| 764 | CAROUSEL_EFFECT_ANGLE_SWEEP / stageSize.width ); | 761 | CAROUSEL_EFFECT_ANGLE_SWEEP / stageSize.width ); |
| 765 | 762 | ||
| 766 | Property::Index anglePerUnit = shaderEffect.GetPropertyIndex( shaderEffect.GetAnglePerUnitPropertyName() ); | 763 | Property::Index anglePerUnit = shaderEffect.GetPropertyIndex( shaderEffect.GetAnglePerUnitPropertyName() ); |
| 767 | - shaderEffect.ApplyConstraint( Constraint::New<Vector2>( anglePerUnit, | ||
| 768 | - Source(mView, Actor::Property::ORIENTATION), | ||
| 769 | - CarouselEffectOrientationConstraint( angleSweep ) ) ); | 764 | + Constraint constraint = Constraint::New<Vector2>( shaderEffect, anglePerUnit, CarouselEffectOrientationConstraint( angleSweep ) ); |
| 765 | + constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) ); | ||
| 766 | + constraint.Apply(); | ||
| 770 | 767 | ||
| 771 | break; | 768 | break; |
| 772 | } | 769 | } |
| @@ -792,11 +789,11 @@ public: | @@ -792,11 +789,11 @@ public: | ||
| 792 | // dont apply shader effect to scrollview as it might override internal shaders for bounce effect etc | 789 | // dont apply shader effect to scrollview as it might override internal shaders for bounce effect etc |
| 793 | for( std::vector<ClusterInfo>::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i ) | 790 | for( std::vector<ClusterInfo>::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i ) |
| 794 | { | 791 | { |
| 795 | - Constraint constraint = Constraint::New<float>(Actor::Property::POSITION_Z, SphereEffectOffsetConstraint(SPHERE_EFFECT_POSITION_Z)); | ||
| 796 | - constraint.SetRemoveAction(Constraint::Discard); | ||
| 797 | Cluster cluster = i->mCluster; | 792 | Cluster cluster = i->mCluster; |
| 793 | + i->mEffectConstraint = Constraint::New<float>( cluster, Actor::Property::POSITION_Z, SphereEffectOffsetConstraint( SPHERE_EFFECT_POSITION_Z ) ); | ||
| 794 | + i->mEffectConstraint.SetRemoveAction(Constraint::Discard); | ||
| 798 | SetShaderEffectRecursively( cluster, shaderEffect ); | 795 | SetShaderEffectRecursively( cluster, shaderEffect ); |
| 799 | - i->mEffectConstraint = cluster.ApplyConstraint(constraint); | 796 | + i->mEffectConstraint.Apply(); |
| 800 | } | 797 | } |
| 801 | break; | 798 | break; |
| 802 | } | 799 | } |
examples/magnifier/magnifier-example.cpp
| @@ -57,20 +57,16 @@ struct MagnifierPathConstraint | @@ -57,20 +57,16 @@ struct MagnifierPathConstraint | ||
| 57 | { | 57 | { |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | - Vector3 operator()(const Vector3& current, | ||
| 61 | - const PropertyInput& sizeProperty, | ||
| 62 | - const PropertyInput& animationTimeProperty) | 60 | + void operator()( Vector3& current, const PropertyInputContainer& inputs ) |
| 63 | { | 61 | { |
| 64 | - float time = animationTimeProperty.GetFloat(); | ||
| 65 | - const Vector3& size = sizeProperty.GetVector3(); | 62 | + float time = inputs[1]->GetFloat(); |
| 63 | + const Vector3& size = inputs[0]->GetVector3(); | ||
| 66 | 64 | ||
| 67 | - Vector3 range(mStageSize - size - Vector3::ONE * MAGNIFIER_INDENT * 2.0f); | ||
| 68 | - Vector3 position(mOffset); | 65 | + current = mOffset; |
| 69 | 66 | ||
| 70 | - position.x += 0.5f * sinf(time * 0.471f) * range.width; | ||
| 71 | - position.y += 0.5f * sinf(time * 0.8739f) * range.height; | ||
| 72 | - | ||
| 73 | - return position; | 67 | + Vector3 range( mStageSize - size - Vector3::ONE * MAGNIFIER_INDENT * 2.0f ); |
| 68 | + current.x += 0.5f * sinf(time * 0.471f) * range.width; | ||
| 69 | + current.y += 0.5f * sinf(time * 0.8739f) * range.height; | ||
| 74 | } | 70 | } |
| 75 | 71 | ||
| 76 | Vector3 mStageSize; ///< Keep track of the stage size for determining path within stage bounds | 72 | Vector3 mStageSize; ///< Keep track of the stage size for determining path within stage bounds |
| @@ -103,23 +99,19 @@ struct ConfinementConstraint | @@ -103,23 +99,19 @@ struct ConfinementConstraint | ||
| 103 | { | 99 | { |
| 104 | } | 100 | } |
| 105 | 101 | ||
| 106 | - Vector3 operator()(const Vector3& constPosition, | ||
| 107 | - const PropertyInput& sizeProperty, | ||
| 108 | - const PropertyInput& parentOriginProperty, | ||
| 109 | - const PropertyInput& anchorPointProperty, | ||
| 110 | - const PropertyInput& referenceSizeProperty) | 102 | + void operator()( Vector3& current, const PropertyInputContainer& inputs ) |
| 111 | { | 103 | { |
| 112 | - const Vector3& size = sizeProperty.GetVector3(); | ||
| 113 | - const Vector3 origin = parentOriginProperty.GetVector3(); | ||
| 114 | - const Vector3& anchor = anchorPointProperty.GetVector3(); | ||
| 115 | - const Vector3& referenceSize = referenceSizeProperty.GetVector3(); | 104 | + const Vector3& size = inputs[0]->GetVector3(); |
| 105 | + const Vector3 origin = inputs[1]->GetVector3(); | ||
| 106 | + const Vector3& anchor = inputs[2]->GetVector3(); | ||
| 107 | + const Vector3& referenceSize = inputs[3]->GetVector3(); | ||
| 116 | 108 | ||
| 117 | Vector3 offset(mOffsetOrigin * referenceSize); | 109 | Vector3 offset(mOffsetOrigin * referenceSize); |
| 118 | 110 | ||
| 119 | - Vector3 newPosition( constPosition + offset ); | ||
| 120 | - | ||
| 121 | // Get actual position of Actor relative to parent's Top-Left. | 111 | // Get actual position of Actor relative to parent's Top-Left. |
| 122 | - Vector3 position(constPosition + offset + origin * referenceSize); | 112 | + Vector3 position(current + offset + origin * referenceSize); |
| 113 | + | ||
| 114 | + current += offset; | ||
| 123 | 115 | ||
| 124 | // if top-left corner is outside of Top-Left bounds, then push back in screen. | 116 | // if top-left corner is outside of Top-Left bounds, then push back in screen. |
| 125 | Vector3 corner(position - size * anchor - mMinIndent); | 117 | Vector3 corner(position - size * anchor - mMinIndent); |
| @@ -127,17 +119,17 @@ struct ConfinementConstraint | @@ -127,17 +119,17 @@ struct ConfinementConstraint | ||
| 127 | if(mFlipHorizontal && corner.x < 0.0f) | 119 | if(mFlipHorizontal && corner.x < 0.0f) |
| 128 | { | 120 | { |
| 129 | corner.x = 0.0f; | 121 | corner.x = 0.0f; |
| 130 | - newPosition.x += size.width; | 122 | + current.x += size.width; |
| 131 | } | 123 | } |
| 132 | 124 | ||
| 133 | if(mFlipVertical && corner.y < 0.0f) | 125 | if(mFlipVertical && corner.y < 0.0f) |
| 134 | { | 126 | { |
| 135 | corner.y = 0.0f; | 127 | corner.y = 0.0f; |
| 136 | - newPosition.y += size.height; | 128 | + current.y += size.height; |
| 137 | } | 129 | } |
| 138 | 130 | ||
| 139 | - newPosition.x -= std::min(corner.x, 0.0f); | ||
| 140 | - newPosition.y -= std::min(corner.y, 0.0f); | 131 | + current.x -= std::min(corner.x, 0.0f); |
| 132 | + current.y -= std::min(corner.y, 0.0f); | ||
| 141 | 133 | ||
| 142 | // if bottom-right corner is outside of Bottom-Right bounds, then push back in screen. | 134 | // if bottom-right corner is outside of Bottom-Right bounds, then push back in screen. |
| 143 | corner += size - referenceSize + mMinIndent + mMaxIndent; | 135 | corner += size - referenceSize + mMinIndent + mMaxIndent; |
| @@ -145,19 +137,17 @@ struct ConfinementConstraint | @@ -145,19 +137,17 @@ struct ConfinementConstraint | ||
| 145 | if(mFlipHorizontal && corner.x > 0.0f) | 137 | if(mFlipHorizontal && corner.x > 0.0f) |
| 146 | { | 138 | { |
| 147 | corner.x = 0.0f; | 139 | corner.x = 0.0f; |
| 148 | - newPosition.x -= size.width; | 140 | + current.x -= size.width; |
| 149 | } | 141 | } |
| 150 | 142 | ||
| 151 | if(mFlipVertical && corner.y > 0.0f) | 143 | if(mFlipVertical && corner.y > 0.0f) |
| 152 | { | 144 | { |
| 153 | corner.y = 0.0f; | 145 | corner.y = 0.0f; |
| 154 | - newPosition.y -= size.height; | 146 | + current.y -= size.height; |
| 155 | } | 147 | } |
| 156 | 148 | ||
| 157 | - newPosition.x -= std::max(corner.x, 0.0f); | ||
| 158 | - newPosition.y -= std::max(corner.y, 0.0f); | ||
| 159 | - | ||
| 160 | - return newPosition; | 149 | + current.x -= std::max(corner.x, 0.0f); |
| 150 | + current.y -= std::max(corner.y, 0.0f); | ||
| 161 | } | 151 | } |
| 162 | 152 | ||
| 163 | Vector3 mOffsetOrigin; ///< Manual Parent Offset Origin. | 153 | Vector3 mOffsetOrigin; ///< Manual Parent Offset Origin. |
| @@ -242,14 +232,13 @@ public: | @@ -242,14 +232,13 @@ public: | ||
| 242 | overlay.Add( mMagnifier ); | 232 | overlay.Add( mMagnifier ); |
| 243 | 233 | ||
| 244 | // Apply constraint to animate the position of the magnifier. | 234 | // Apply constraint to animate the position of the magnifier. |
| 245 | - Constraint constraint = Constraint::New<Vector3>(Actor::Property::POSITION, | ||
| 246 | - LocalSource(Actor::Property::SIZE), | ||
| 247 | - LocalSource(Actor::Property::PARENT_ORIGIN), | ||
| 248 | - LocalSource(Actor::Property::ANCHOR_POINT), | ||
| 249 | - ParentSource(Actor::Property::SIZE), | ||
| 250 | - ConfinementConstraint(ParentOrigin::CENTER, Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT)); | 235 | + Constraint constraint = Constraint::New<Vector3>( mMagnifier, Actor::Property::POSITION, ConfinementConstraint(ParentOrigin::CENTER, Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT) ); |
| 236 | + constraint.AddSource( LocalSource(Actor::Property::SIZE) ); | ||
| 237 | + constraint.AddSource( LocalSource(Actor::Property::PARENT_ORIGIN) ); | ||
| 238 | + constraint.AddSource( LocalSource(Actor::Property::ANCHOR_POINT) ); | ||
| 239 | + constraint.AddSource( ParentSource(Actor::Property::SIZE) ); | ||
| 251 | constraint.SetRemoveAction(Constraint::Discard); | 240 | constraint.SetRemoveAction(Constraint::Discard); |
| 252 | - mMagnifier.ApplyConstraint( constraint ); | 241 | + constraint.Apply(); |
| 253 | 242 | ||
| 254 | // Create bouncing magnifier automatically bounces around screen. | 243 | // Create bouncing magnifier automatically bounces around screen. |
| 255 | mBouncingMagnifier = Toolkit::Magnifier::New(); | 244 | mBouncingMagnifier = Toolkit::Magnifier::New(); |
| @@ -263,18 +252,16 @@ public: | @@ -263,18 +252,16 @@ public: | ||
| 263 | ContinueAnimation(); | 252 | ContinueAnimation(); |
| 264 | 253 | ||
| 265 | // Apply constraint to animate the position of the magnifier. | 254 | // Apply constraint to animate the position of the magnifier. |
| 266 | - constraint = Constraint::New<Vector3>(Actor::Property::POSITION, | ||
| 267 | - LocalSource(Actor::Property::SIZE), | ||
| 268 | - LocalSource(mAnimationTimeProperty), | ||
| 269 | - MagnifierPathConstraint(mStageSize, mStageSize * 0.5f)); | ||
| 270 | - mBouncingMagnifier.ApplyConstraint( constraint ); | 255 | + constraint = Constraint::New<Vector3>( mBouncingMagnifier, Actor::Property::POSITION, MagnifierPathConstraint(mStageSize, mStageSize * 0.5f) ); |
| 256 | + constraint.AddSource( LocalSource(Actor::Property::SIZE) ); | ||
| 257 | + constraint.AddSource( LocalSource(mAnimationTimeProperty) ); | ||
| 258 | + constraint.Apply(); | ||
| 271 | 259 | ||
| 272 | // Apply constraint to animate the source of the magnifier. | 260 | // Apply constraint to animate the source of the magnifier. |
| 273 | - constraint = Constraint::New<Vector3>(mBouncingMagnifier.GetPropertyIndex( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME ), | ||
| 274 | - LocalSource(Actor::Property::SIZE), | ||
| 275 | - LocalSource(mAnimationTimeProperty), | ||
| 276 | - MagnifierPathConstraint(mStageSize)); | ||
| 277 | - mBouncingMagnifier.ApplyConstraint( constraint ); | 261 | + constraint = Constraint::New<Vector3>( mBouncingMagnifier, mBouncingMagnifier.GetPropertyIndex( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME ), MagnifierPathConstraint(mStageSize) ); |
| 262 | + constraint.AddSource( LocalSource(Actor::Property::SIZE) ); | ||
| 263 | + constraint.AddSource( LocalSource(mAnimationTimeProperty) ); | ||
| 264 | + constraint.Apply(); | ||
| 278 | } | 265 | } |
| 279 | 266 | ||
| 280 | /** | 267 | /** |
examples/radial-menu/radial-sweep-view-impl.cpp
| @@ -26,9 +26,8 @@ namespace | @@ -26,9 +26,8 @@ namespace | ||
| 26 | * Method to project a point on a circle of radius halfSide at given | 26 | * Method to project a point on a circle of radius halfSide at given |
| 27 | * angle onto a square of side 2 * halfSide | 27 | * angle onto a square of side 2 * halfSide |
| 28 | */ | 28 | */ |
| 29 | -Vector3 CircleSquareProjection( Degree angle, float halfSide ) | 29 | +void CircleSquareProjection( Vector3& position, Degree angle, float halfSide ) |
| 30 | { | 30 | { |
| 31 | - Vector3 position(0.0f, 0.0f, 0.0f); | ||
| 32 | Radian angleInRadians(angle); | 31 | Radian angleInRadians(angle); |
| 33 | 32 | ||
| 34 | // 135 90 45 | 33 | // 135 90 45 |
| @@ -58,7 +57,8 @@ Vector3 CircleSquareProjection( Degree angle, float halfSide ) | @@ -58,7 +57,8 @@ Vector3 CircleSquareProjection( Degree angle, float halfSide ) | ||
| 58 | position.x = halfSide; | 57 | position.x = halfSide; |
| 59 | position.y = -halfSide * sinf(angleInRadians) / cosf(angleInRadians); | 58 | position.y = -halfSide * sinf(angleInRadians) / cosf(angleInRadians); |
| 60 | } | 59 | } |
| 61 | - return position; | 60 | + |
| 61 | + position.z = 0.0f; | ||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | float HoldZeroFastEaseInOutHoldOne(float progress) | 64 | float HoldZeroFastEaseInOutHoldOne(float progress) |
| @@ -88,9 +88,9 @@ struct SquareFanConstraint | @@ -88,9 +88,9 @@ struct SquareFanConstraint | ||
| 88 | { | 88 | { |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | - Vector3 operator()( const Vector3& current, const PropertyInput& start, const PropertyInput& rotation ) | 91 | + void operator()( Vector3& current, const PropertyInputContainer& inputs ) |
| 92 | { | 92 | { |
| 93 | - float degree = fmodf((start.GetFloat() + rotation.GetFloat()), 360.0f); | 93 | + float degree = fmodf((inputs[0]->GetFloat() + inputs[1]->GetFloat()), 360.0f); |
| 94 | if(degree < 0.0f) | 94 | if(degree < 0.0f) |
| 95 | { | 95 | { |
| 96 | degree += 360.0f; | 96 | degree += 360.0f; |
| @@ -100,15 +100,17 @@ struct SquareFanConstraint | @@ -100,15 +100,17 @@ struct SquareFanConstraint | ||
| 100 | float endAngle = (90.0f*mSideIndex)+45.0f; | 100 | float endAngle = (90.0f*mSideIndex)+45.0f; |
| 101 | if(degree < startAngle) | 101 | if(degree < startAngle) |
| 102 | { | 102 | { |
| 103 | - return Vector3::ZERO; | 103 | + current = Vector3::ZERO; |
| 104 | } | 104 | } |
| 105 | - else if( degree >= endAngle ) | 105 | + else |
| 106 | { | 106 | { |
| 107 | - degree = endAngle; | 107 | + if( degree >= endAngle ) |
| 108 | + { | ||
| 109 | + degree = endAngle; | ||
| 110 | + } | ||
| 111 | + CircleSquareProjection( current, Degree(degree), 0.5f ); | ||
| 112 | + current.x = -current.x; // Inverting X makes the animation go anti clockwise from left center | ||
| 108 | } | 113 | } |
| 109 | - Vector3 pos = CircleSquareProjection(Degree(degree), 0.5f); | ||
| 110 | - pos.x = -pos.x; // Inverting X makes the animation go anti clockwise from left center | ||
| 111 | - return pos; | ||
| 112 | } | 114 | } |
| 113 | 115 | ||
| 114 | int mSideIndex; | 116 | int mSideIndex; |
| @@ -362,18 +364,35 @@ void RadialSweepViewImpl::CreateStencil( Degree initialSector ) | @@ -362,18 +364,35 @@ void RadialSweepViewImpl::CreateStencil( Degree initialSector ) | ||
| 362 | 364 | ||
| 363 | // Constrain the vertices of the square mesh to sweep out a sector as the | 365 | // Constrain the vertices of the square mesh to sweep out a sector as the |
| 364 | // rotation angle is animated. | 366 | // rotation angle is animated. |
| 365 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(1, AnimatableVertex::Property::POSITION), | ||
| 366 | - srcStart, srcStart, SquareFanConstraint(0))); | ||
| 367 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(2, AnimatableVertex::Property::POSITION), | ||
| 368 | - srcStart, srcRot, SquareFanConstraint(0))); | ||
| 369 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(3, AnimatableVertex::Property::POSITION), | ||
| 370 | - srcStart, srcRot, SquareFanConstraint(1))); | ||
| 371 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(4, AnimatableVertex::Property::POSITION), | ||
| 372 | - srcStart, srcRot, SquareFanConstraint(2))); | ||
| 373 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION), | ||
| 374 | - srcStart, srcRot, SquareFanConstraint(3))); | ||
| 375 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(6, AnimatableVertex::Property::POSITION), | ||
| 376 | - srcStart, srcRot, SquareFanConstraint(4))); | 367 | + Constraint constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(1, AnimatableVertex::Property::POSITION), SquareFanConstraint(0) ); |
| 368 | + constraint.AddSource( srcStart ); | ||
| 369 | + constraint.AddSource( srcStart ); | ||
| 370 | + constraint.Apply(); | ||
| 371 | + | ||
| 372 | + constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(2, AnimatableVertex::Property::POSITION), SquareFanConstraint(0) ); | ||
| 373 | + constraint.AddSource( srcStart ); | ||
| 374 | + constraint.AddSource( srcRot ); | ||
| 375 | + constraint.Apply(); | ||
| 376 | + | ||
| 377 | + constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(3, AnimatableVertex::Property::POSITION), SquareFanConstraint(1) ); | ||
| 378 | + constraint.AddSource( srcStart ); | ||
| 379 | + constraint.AddSource( srcRot ); | ||
| 380 | + constraint.Apply(); | ||
| 381 | + | ||
| 382 | + constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(4, AnimatableVertex::Property::POSITION), SquareFanConstraint(2) ); | ||
| 383 | + constraint.AddSource( srcStart ); | ||
| 384 | + constraint.AddSource( srcRot ); | ||
| 385 | + constraint.Apply(); | ||
| 386 | + | ||
| 387 | + constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION), SquareFanConstraint(3) ); | ||
| 388 | + constraint.AddSource( srcStart ); | ||
| 389 | + constraint.AddSource( srcRot ); | ||
| 390 | + constraint.Apply(); | ||
| 391 | + | ||
| 392 | + constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(6, AnimatableVertex::Property::POSITION), SquareFanConstraint(4) ); | ||
| 393 | + constraint.AddSource( srcStart ); | ||
| 394 | + constraint.AddSource( srcRot ); | ||
| 395 | + constraint.Apply(); | ||
| 377 | 396 | ||
| 378 | mStencilActor.SetDrawMode( DrawMode::STENCIL ); | 397 | mStencilActor.SetDrawMode( DrawMode::STENCIL ); |
| 379 | mStencilActor.SetPositionInheritanceMode(USE_PARENT_POSITION); | 398 | mStencilActor.SetPositionInheritanceMode(USE_PARENT_POSITION); |
examples/refraction-effect/refraction-effect-example.cpp
| @@ -56,10 +56,13 @@ struct LightOffsetConstraint | @@ -56,10 +56,13 @@ struct LightOffsetConstraint | ||
| 56 | { | 56 | { |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | - Vector2 operator()( const Vector2& current, const PropertyInput& spinAngleProperty) | 59 | + void operator()( Vector2& current, const PropertyInputContainer& inputs ) |
| 60 | { | 60 | { |
| 61 | - float spinAngle = spinAngleProperty.GetFloat(); | ||
| 62 | - return Vector2( cos(spinAngle ), sin( spinAngle ) ) * mRadius; | 61 | + float spinAngle = inputs[0]->GetFloat(); |
| 62 | + current.x = cos( spinAngle ); | ||
| 63 | + current.y = sin( spinAngle ); | ||
| 64 | + | ||
| 65 | + current *= mRadius; | ||
| 63 | } | 66 | } |
| 64 | 67 | ||
| 65 | float mRadius; | 68 | float mRadius; |
| @@ -254,10 +257,9 @@ public: | @@ -254,10 +257,9 @@ public: | ||
| 254 | handle.SetUniform( "uLightIntensity", 2.5f ); | 257 | handle.SetUniform( "uLightIntensity", 2.5f ); |
| 255 | 258 | ||
| 256 | Dali::Property::Index index = handle.RegisterProperty( "uSpinAngle", 0.f ); | 259 | Dali::Property::Index index = handle.RegisterProperty( "uSpinAngle", 0.f ); |
| 257 | - Constraint constraint = Constraint::New<Vector2>( handle.GetPropertyIndex("uLightSpinOffset"), | ||
| 258 | - LocalSource(index), | ||
| 259 | - LightOffsetConstraint(stageSize.x*0.1f)); | ||
| 260 | - handle.ApplyConstraint( constraint ); | 260 | + Constraint constraint = Constraint::New<Vector2>( handle, handle.GetPropertyIndex("uLightSpinOffset"), LightOffsetConstraint(stageSize.x*0.1f) ); |
| 261 | + constraint.AddSource( LocalSource(index) ); | ||
| 262 | + constraint.Apply(); | ||
| 261 | 263 | ||
| 262 | return handle; | 264 | return handle; |
| 263 | } | 265 | } |
examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp
| @@ -100,23 +100,10 @@ public: | @@ -100,23 +100,10 @@ public: | ||
| 100 | { | 100 | { |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | - Vector3 operator()( const Vector3& current, const PropertyInput& property ) | 103 | + void operator()( Vector3& current, const PropertyInputContainer& inputs ) |
| 104 | { | 104 | { |
| 105 | - Vector3 position = property.GetVector3(); | ||
| 106 | - position.z += 1.0f; | ||
| 107 | - return position; | ||
| 108 | - } | ||
| 109 | - }; | ||
| 110 | - | ||
| 111 | - struct QuaternionEqualToConstraint | ||
| 112 | - { | ||
| 113 | - QuaternionEqualToConstraint() | ||
| 114 | - { | ||
| 115 | - } | ||
| 116 | - | ||
| 117 | - Quaternion operator()( const Quaternion& current, const PropertyInput& property ) | ||
| 118 | - { | ||
| 119 | - return property.GetQuaternion(); | 105 | + current = inputs[0]->GetVector3(); |
| 106 | + current.z += 1.0f; | ||
| 120 | } | 107 | } |
| 121 | }; | 108 | }; |
| 122 | 109 | ||
| @@ -127,10 +114,10 @@ public: | @@ -127,10 +114,10 @@ public: | ||
| 127 | { | 114 | { |
| 128 | } | 115 | } |
| 129 | 116 | ||
| 130 | - Quaternion operator()( const Quaternion& current, const PropertyInput& property ) | 117 | + void operator()( Quaternion& current, const PropertyInputContainer& inputs ) |
| 131 | { | 118 | { |
| 132 | - Degree angle(property.GetFloat()); | ||
| 133 | - return Quaternion( Radian(angle) * mSign, Vector3::YAXIS ); | 119 | + Degree angle( inputs[0]->GetFloat() ); |
| 120 | + current = Quaternion( Radian(angle) * mSign, Vector3::YAXIS ); | ||
| 134 | } | 121 | } |
| 135 | 122 | ||
| 136 | float mSign; | 123 | float mSign; |
| @@ -290,10 +277,14 @@ public: | @@ -290,10 +277,14 @@ public: | ||
| 290 | 277 | ||
| 291 | Property::Index angleIndex = mImageActor2.RegisterProperty("angle", Property::Value(30.0f)); | 278 | Property::Index angleIndex = mImageActor2.RegisterProperty("angle", Property::Value(30.0f)); |
| 292 | Source angleSrc( mImageActor2, angleIndex ); | 279 | Source angleSrc( mImageActor2, angleIndex ); |
| 293 | - mImageActor1.ApplyConstraint(Constraint::New<Quaternion>( Actor::Property::ORIENTATION, angleSrc, | ||
| 294 | - RotationConstraint(-1.0f))); | ||
| 295 | - mImageActor3.ApplyConstraint(Constraint::New<Quaternion>( Actor::Property::ORIENTATION, angleSrc, | ||
| 296 | - RotationConstraint(+1.0f))); | 280 | + |
| 281 | + Constraint constraint = Constraint::New<Quaternion>( mImageActor1, Actor::Property::ORIENTATION, RotationConstraint(-1.0f) ); | ||
| 282 | + constraint.AddSource( angleSrc ); | ||
| 283 | + constraint.Apply(); | ||
| 284 | + | ||
| 285 | + constraint = Constraint::New<Quaternion>( mImageActor3, Actor::Property::ORIENTATION, RotationConstraint(+1.0f) ); | ||
| 286 | + constraint.AddSource( angleSrc ); | ||
| 287 | + constraint.Apply(); | ||
| 297 | 288 | ||
| 298 | mSceneAnimation = Animation::New(2.5f); | 289 | mSceneAnimation = Animation::New(2.5f); |
| 299 | 290 |