[NUI.Scene3D] Deprecate direct accessor to motion value list
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 16 Jun 2023 00:38:30 +0000 (09:38 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Wed, 21 Jun 2023 03:04:41 +0000 (12:04 +0900)
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI.Scene3D/src/public/ModelMotion/MotionData.cs
test/Tizen.NUI.Scene3D.Sample/Scene3DSample.cs

index 048eace..6651291 100644 (file)
@@ -30,11 +30,72 @@ namespace Tizen.NUI.Scene3D
     [EditorBrowsable(EditorBrowsableState.Never)]
     public class MotionData : IDisposable
     {
+        private List<(MotionIndex, MotionValue)> motionValues { get; set; } = null;
+
         /// <summary>
         /// Owned motion value list.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public List<(MotionIndex, MotionValue)> MotionValues { get; set; } = null;
+        [Obsolete("Do not use this MotionValues property directly. Use Add and GetIndex, GetValue instead.")]
+        public List<(MotionIndex, MotionValue)> MotionValues
+        {
+            get
+            {
+                return motionValues;
+            }
+            set
+            {
+                motionValues = value;
+            }
+        }
+
+        /// <summary>
+        /// Append pair of MotionIndex and MotionValue end of list.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void Add(MotionIndex index, MotionValue value)
+        {
+            if(motionValues == null)
+            {
+                motionValues = new List<(MotionIndex, MotionValue)>();
+            }
+            motionValues.Add((index, value));
+        }
+
+        /// <summary>
+        /// Get MotionIndex at index'th. null if invalid index inputed
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public MotionIndex GetIndex(uint index)
+        {
+            if(motionValues != null && index < motionValues.Count)
+            {
+                return motionValues[(int)index].Item1;
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// Get MotionValue at index'th. null if invalid index inputed
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public MotionValue GetValue(uint index)
+        {
+            if(motionValues != null && index < motionValues.Count)
+            {
+                return motionValues[(int)index].Item2;
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// Clear all inputed values.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void Clear()
+        {
+            motionValues = null;
+        }
 
         /// <summary>
         /// Create an initialized motion data.
@@ -49,13 +110,14 @@ namespace Tizen.NUI.Scene3D
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void Dispose()
         {
-            if (MotionValues != null)
+            if (motionValues != null)
             {
-                foreach (var indexValuePair in MotionValues)
+                foreach (var indexValuePair in motionValues)
                 {
                     indexValuePair.Item1?.Dispose();
                     indexValuePair.Item2?.Dispose();
                 }
+                motionValues = null;
             }
         }
     }
index 283728c..06fa774 100644 (file)
@@ -307,60 +307,51 @@ class Scene3DSample : NUIApplication
         mStaticRevertMotionData = new MotionData();
         mAnimateMotionData = new MotionData();
 
-        mStaticMotionData.MotionValues = new List<(MotionIndex, MotionValue)>
-        {
-            (
-                new MotionTransformIndex()
-                {
-                    ModelNodeId = new PropertyKey("Main"),
-                    TransformType = MotionTransformIndex.TransformTypes.Orientation,
-                },
-                new MotionValue()
-                {
-                    Value = new PropertyValue(new Rotation(new Radian(new Degree(-45.0f)), Vector3.ZAxis)),
-                }
-            ),
-        };
-        mStaticRevertMotionData.MotionValues = new List<(MotionIndex, MotionValue)>
-        {
-            (
-                new MotionTransformIndex()
-                {
-                    ModelNodeId = new PropertyKey("Main"),
-                    TransformType = MotionTransformIndex.TransformTypes.Orientation,
-                },
-                new MotionValue()
-                {
-                    Value = new PropertyValue(new Rotation(new Radian(new Degree(0.0f)), Vector3.ZAxis)),
-                }
-            ),
-            (
-                new MotionTransformIndex()
-                {
-                    ModelNodeId = new PropertyKey("Main"),
-                    TransformType = MotionTransformIndex.TransformTypes.Scale,
-                },
-                new MotionValue()
-                {
-                    Value = new PropertyValue(Vector3.One),
-                }
-            ),
-        };
+        mStaticMotionData.Add(
+            new MotionTransformIndex()
+            {
+                ModelNodeId = new PropertyKey("Main"),
+                TransformType = MotionTransformIndex.TransformTypes.Orientation,
+            },
+            new MotionValue()
+            {
+                Value = new PropertyValue(new Rotation(new Radian(new Degree(-45.0f)), Vector3.ZAxis)),
+            }
+        );
+        mStaticRevertMotionData.Add(
+            new MotionTransformIndex()
+            {
+                ModelNodeId = new PropertyKey("Main"),
+                TransformType = MotionTransformIndex.TransformTypes.Orientation,
+            },
+            new MotionValue()
+            {
+                Value = new PropertyValue(new Rotation(new Radian(new Degree(0.0f)), Vector3.ZAxis)),
+            }
+        );
+        mStaticRevertMotionData.Add(
+            new MotionTransformIndex()
+            {
+                ModelNodeId = new PropertyKey("Main"),
+                TransformType = MotionTransformIndex.TransformTypes.Scale,
+            },
+            new MotionValue()
+            {
+                Value = new PropertyValue(Vector3.One),
+            }
+        );
 
-        mAnimateMotionData.MotionValues = new List<(MotionIndex, MotionValue)>()
-        {
-            (
-                new MotionTransformIndex()
-                {
-                    ModelNodeId = new PropertyKey("Main"),
-                    TransformType = MotionTransformIndex.TransformTypes.Scale,
-                },
-                new MotionValue()
-                {
-                    Value = new PropertyValue(new Vector3(0.5f, 1.5f, 1.0f)),
-                }
-            ),
-        };
+        mAnimateMotionData.Add(
+            new MotionTransformIndex()
+            {
+                ModelNodeId = new PropertyKey("Main"),
+                TransformType = MotionTransformIndex.TransformTypes.Scale,
+            },
+            new MotionValue()
+            {
+                Value = new PropertyValue(new Vector3(0.5f, 1.5f, 1.0f)),
+            }
+        );
         for (int i = 0; i < 8; ++i)
         {
             MotionIndex index = new BlendShapeIndex()
@@ -375,7 +366,7 @@ class Scene3DSample : NUIApplication
             value.KeyFramesValue.Add(0.0f, 0.0f);
             value.KeyFramesValue.Add(1.0f, 1.0f * ((float)Math.Abs(i - 3.5f) + 0.5f) / 4.0f);
 
-            mAnimateMotionData.MotionValues.Add(ValueTuple.Create(index, value));
+            mAnimateMotionData.Add(index, value);
         }
     }