Fixed the rotation interaction in the Reflection example. 58/246458/3
authorGyörgy Straub <g.straub@partner.samsung.com>
Thu, 29 Oct 2020 14:46:24 +0000 (14:46 +0000)
committerGyörgy Straub <g.straub@partner.samsung.com>
Mon, 2 Nov 2020 13:17:43 +0000 (13:17 +0000)
Change-Id: I336525894567d22349f883ff6d673ba0e2f8a2ff
Signed-off-by: György Straub <g.straub@partner.samsung.com>
examples/reflection-demo/reflection-example.cpp

index 9de2407e6481ecda86991f3461a33bcaeb0e0ae0..6a44fda788b3d505d517eed4fc192381a4594b9a 100644 (file)
@@ -595,13 +595,18 @@ private:
 
   void OnPan(Actor actor, const PanGesture& panGesture)
   {
-    const auto& displacement = panGesture.GetScreenDisplacement();
-    mCenterActor.RotateBy(Degree(displacement.y * 0.1f), Vector3(0.0, 0.0, 1.0));
-    mCenterActor.RotateBy(Degree(displacement.x * 0.1f), Vector3(0.0, 1.0, 0.0));
-    Quaternion q;
-    mCenterActor.GetProperty(Actor::Property::ORIENTATION).Get(q);
+    Vector2 displacement = panGesture.GetScreenDisplacement();
+    Vector2 rotation{
+      displacement.y * -0.1f,
+      displacement.x * 0.1f
+    };
+
+    Quaternion q(Degree(0.f), Degree(rotation.y), Degree(rotation.x));
+    Quaternion q0 = mCenterActor.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>();
+    mCenterActor.SetProperty(Actor::Property::ORIENTATION, q * q0);
+
     Matrix m = Matrix::IDENTITY;
-    m.SetTransformComponents(Vector3::ONE, q, Vector3::ZERO);
+    m.SetTransformComponents(Vector3::ONE, q0, Vector3::ZERO);
     auto yAxis = m.GetYAxis() * -1.0f;
 
     yAxis.Normalize();