From bcd74b112afeb67a31cdf9842ff885b90b1dcd2c Mon Sep 17 00:00:00 2001 From: zhouzebin Date: Mon, 1 Nov 2021 21:43:13 +0800 Subject: [PATCH] path animation always not equals Signed-off-by: sunfei Change-Id: I372b5156e85a7e2e1189f2c53f6a8550b8393966 --- frameworks/base/geometry/transform_util.h | 16 +++++++++++++--- frameworks/core/animation/animatable_base.h | 2 +- .../animation/animatable_transform_operation.h | 5 ++++- .../core/components/transform/render_transform.h | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/frameworks/base/geometry/transform_util.h b/frameworks/base/geometry/transform_util.h index de62e104c0b..d760096101e 100644 --- a/frameworks/base/geometry/transform_util.h +++ b/frameworks/base/geometry/transform_util.h @@ -188,12 +188,21 @@ public: Matrix4 ComputerRemaining(std::size_t startOffset) const; + void SetAlwaysRotate(bool alwaysRotate) + { + alwaysRotate_ = alwaysRotate; + } + bool operator==(const TransformOperations& other) const { - bool equals = false; + if (alwaysRotate_) { + return false; + } + if (operations_.size() != other.operations_.size()) { + return false; + } for (size_t index = 0; index < operations_.size(); index++) { - equals = equals | operations_[index] == other.operations_[index]; - if (!equals) { + if (!(operations_[index] == other.operations_[index])) { return false; } } @@ -202,6 +211,7 @@ public: protected: std::vector operations_; + bool alwaysRotate_ = false; private: std::size_t MatchingLength(const TransformOperations& to, const TransformOperations& from) const; diff --git a/frameworks/core/animation/animatable_base.h b/frameworks/core/animation/animatable_base.h index 8766db59424..c8df2658f16 100644 --- a/frameworks/core/animation/animatable_base.h +++ b/frameworks/core/animation/animatable_base.h @@ -35,7 +35,7 @@ public: void AnimateTo(const T& beginValue, const T& endValue) { - if (endValue_ == endValue) { + if (endValue == endValue_) { return; } endValue_ = endValue; diff --git a/frameworks/core/animation/animatable_transform_operation.h b/frameworks/core/animation/animatable_transform_operation.h index 1021ec4041b..e93792331f6 100644 --- a/frameworks/core/animation/animatable_transform_operation.h +++ b/frameworks/core/animation/animatable_transform_operation.h @@ -140,14 +140,17 @@ public: { operations_ = other; blended = TransformOperations(operations_); + endValue_ = blended; } - void PlayTransformAnimation(const AnimationOption& option, const std::vector& other) + void PlayTransformAnimation( + const AnimationOption& option, const std::vector& other, bool alwaysRotate = false) { SetAnimationOption(option); auto target = TransformOperations(other); TransformOperations::ParseOperationsToMatrix(operations_); TransformOperations::ParseOperationsToMatrix(target.GetOperations()); + target.SetAlwaysRotate(alwaysRotate); AnimateTo(blended, target); // just move to target, renderNode should use blended to computer matrix MoveTo(target); diff --git a/frameworks/core/components/transform/render_transform.h b/frameworks/core/components/transform/render_transform.h index 4932a07428d..15dc9aa31b0 100644 --- a/frameworks/core/components/transform/render_transform.h +++ b/frameworks/core/components/transform/render_transform.h @@ -135,7 +135,7 @@ public: renderNode->transformAnimation_.SetEvaluator(nullptr); } }); - transformAnimation_.PlayTransformAnimation(option, std::vector()); + transformAnimation_.PlayTransformAnimation(option, std::vector(), true); } }