@@ -66,19 +66,29 @@ void IChildOf<AnimationChannel>.SetLogicalParent(AnimationChannel parent)
6666
6767 #region API
6868
69+ /// <summary>
70+ /// Gets the index of the <see cref="Node"/> pointed by this animation,
71+ /// or -1 if it points to a target that is not a <see cref="Node"/>.
72+ /// </summary>
73+ /// <returns>A node index, or -1</returns>
6974 public int GetNodeIndex ( )
7075 {
7176 if ( this . _node != null ) return this . _node . Value ;
7277
7378 if ( _NodePath == PropertyPath . pointer )
7479 {
7580 var aptr = this . GetExtension < AnimationPointer > ( ) ;
76- if ( aptr != null && AnimationPointer . TryParseNodeTransform ( aptr . Pointer , out var nidx , out _ ) ) return nidx ;
81+ if ( aptr != null && AnimationPointer . TryParseNodeIndex ( aptr . Pointer , out var nidx ) ) return nidx ;
7782 }
7883
7984 return - 1 ;
8085 }
8186
87+ /// <summary>
88+ /// If the target is a node, it returns a <see cref="PropertyPath"/> resolved to <see cref="PropertyPath.scale"/>, <see cref="PropertyPath.rotation"/> or <see cref="PropertyPath.translation"/>
89+ /// otherwise it will return <see cref="PropertyPath.pointer"/>
90+ /// </summary>
91+ /// <returns>A <see cref="PropertyPath"/> value.</returns>
8292 public PropertyPath GetNodePath ( )
8393 {
8494 if ( _NodePath == PropertyPath . pointer )
@@ -90,6 +100,10 @@ public PropertyPath GetNodePath()
90100 return _NodePath ;
91101 }
92102
103+ /// <summary>
104+ /// Returns a pointer path regardless of whether it's defined by default <see cref="PropertyPath"/> or by the animation pointer extension.
105+ /// </summary>
106+ /// <returns>An animation pointer path.</returns>
93107 public string GetPointerPath ( )
94108 {
95109 var aptr = this . GetExtension < AnimationPointer > ( ) ;
@@ -153,35 +167,45 @@ public string Pointer
153167 /// <summary>
154168 /// Parses the pointer path to see if it can be converted to a standard nodeIndex-PropertyPath path.
155169 /// </summary>
156- /// <param name="pointer ">The path to try parse.</param>
170+ /// <param name="pointerPath ">The path to try parse.</param>
157171 /// <param name="nodeIndex">the logical index of the node.</param>
158172 /// <param name="property">the transformation property.</param>
159173 /// <returns>true if the parsing succeeded.</returns>
160- public static bool TryParseNodeTransform ( string pointer , out int nodeIndex , out PropertyPath property )
174+ public static bool TryParseNodeTransform ( string pointerPath , out int nodeIndex , out PropertyPath property )
161175 {
162- nodeIndex = - 1 ;
163176 property = PropertyPath . pointer ;
164177
165- if ( pointer == null || ! pointer . StartsWith ( "/nodes/" ) ) return false ;
166-
178+ if ( ! TryParseNodeIndex ( pointerPath , out nodeIndex ) ) return false ;
167179
168- pointer = pointer . Substring ( 7 ) ;
169- var next = pointer . IndexOf ( '/' ) ;
180+ pointerPath = pointerPath . Substring ( 7 ) ;
181+ var next = pointerPath . IndexOf ( '/' , StringComparison . Ordinal ) ;
182+ if ( next < 0 ) return false ;
170183
171- if ( ! int . TryParse ( pointer . Substring ( 0 , next ) , System . Globalization . NumberStyles . Integer , System . Globalization . CultureInfo . InvariantCulture , out var idx ) ) return false ;
172-
173- var tail = pointer . Substring ( next + 1 ) ;
184+ var tail = pointerPath . Substring ( next + 1 ) ;
174185 switch ( tail )
175186 {
176- case "scale" : nodeIndex = idx ; property = PropertyPath . scale ; return true ;
177- case "rotation" : nodeIndex = idx ; property = PropertyPath . rotation ; return true ;
178- case "translation" : nodeIndex = idx ; property = PropertyPath . translation ; return true ;
179- case "weights" : nodeIndex = idx ; property = PropertyPath . weights ; return true ;
187+ case "scale" : property = PropertyPath . scale ; return true ;
188+ case "rotation" : property = PropertyPath . rotation ; return true ;
189+ case "translation" : property = PropertyPath . translation ; return true ;
190+ case "weights" : property = PropertyPath . weights ; return true ;
180191 }
181192
182193 return false ;
183194 }
184195
196+ public static bool TryParseNodeIndex ( string pointerPath , out int nodeIndex )
197+ {
198+ nodeIndex = - 1 ;
199+
200+ if ( pointerPath == null || ! pointerPath . StartsWith ( "/nodes/" ) ) return false ;
201+
202+ pointerPath = pointerPath . Substring ( 7 ) ;
203+ var next = pointerPath . IndexOf ( '/' , StringComparison . Ordinal ) ;
204+ if ( next < 0 ) next = pointerPath . Length ;
205+
206+ return int . TryParse ( pointerPath . Substring ( 0 , next ) , System . Globalization . NumberStyles . Integer , System . Globalization . CultureInfo . InvariantCulture , out nodeIndex ) ;
207+ }
208+
185209 #endregion
186210 }
187211}
0 commit comments