[NUI.Scene3D.Sample] Remove useless looping animation
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 2 Aug 2024 07:06:12 +0000 (16:06 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 7 Aug 2024 07:02:39 +0000 (16:02 +0900)
Since some useless animation was running internally until GC comes,
CPU usage might be increased for this sample.

To avoid useless rendering, let we ensurely dispose not-using animation.

Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
test/Tizen.NUI.Scene3D.Sample/Scene3DSample.cs

index ea1f7751a2e4922a7c45f99620f5d1185f90fbe5..8edc3412fd09a95a41cfd6d32432595e6fbbac23 100644 (file)
@@ -290,6 +290,13 @@ class Scene3DSample : NUIApplication
             }
         };
 
+        if (mModelRotateAnimation != null)
+        {
+            mModelRotateAnimation.Stop();
+            mModelRotateAnimation.Dispose();
+            mModelRotateAnimation = null;
+        }
+
         mModelRotateAnimation = new Animation(modelRotateAnimationDurationMilliseconds);
         mModelRotateAnimation.AnimateBy(mModel, "Orientation", new Rotation(new Radian(new Degree(360.0f)), Vector3.YAxis));
 
@@ -452,9 +459,9 @@ class Scene3DSample : NUIApplication
                 }
                 case "f":
                 {
-                    if (mModelAnimation?.State == Animation.States.Playing)
+                    if (mModel != null && mModelLoadFinished)
                     {
-                        if (mModel != null && mModelLoadFinished)
+                        if (mModelAnimation != null && mModelAnimation.State == Animation.States.Playing)
                         {
                             mMotionAnimation = mModel.GenerateMotionDataAnimation(mAnimateMotionData);
 
@@ -479,7 +486,7 @@ class Scene3DSample : NUIApplication
         }
         else if (e.Key.State == Key.StateType.Up)
         {
-            if (mModelAnimation?.State == Animation.States.Stopped)
+            if (mModelAnimation != null && mModelAnimation.State == Animation.States.Stopped)
             {
                 if (mMotionAnimation != null)
                 {
@@ -499,7 +506,7 @@ class Scene3DSample : NUIApplication
 
     public void Activate()
     {
-        mWindow = Window.Instance;
+        mWindow = Window.Default;
         mWindow.BackgroundColor = Color.DarkOrchid;
         mWindowSize = mWindow.WindowSize;