Skip to content

Commit 8987999

Browse files
committed
fix(ExpressionsFork): emit Composition matrix subchannel tokens (_11..) instead of enum names (Channel11..)
1 parent 81fe1f3 commit 8987999

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

  • src/CompositionCollectionView/ExpressionsFork/Expressions/ExpressionNodes

src/CompositionCollectionView/ExpressionsFork/Expressions/ExpressionNodes/Matrix4x4Node.cs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,30 @@ public Vector3Node Channel41Channel42Channel43
313313
get { return GetSubchannels(Subchannel.Channel41, Subchannel.Channel42, Subchannel.Channel43); }
314314
}
315315

316+
/// <summary>
317+
/// Map the typed <see cref="Subchannel"/> enum to the literal token
318+
/// the Composition expression parser accepts for matrix subchannel
319+
/// access. The parser uses <c>_11</c>..<c>_44</c>, NOT the C# enum
320+
/// name <c>Channel11</c>. Without this translation
321+
/// <c>SubchannelsInternal</c> would emit <c>"someMatrix.Channel11"</c>
322+
/// which fails with "An invalid subchannel was specified in the
323+
/// expression" at <c>StartAnimation</c> time.
324+
/// </summary>
325+
private static string SubchannelToken(Subchannel s)
326+
{
327+
// Subchannel.Channel11 -> "Channel11" -> "_11".
328+
string name = s.ToString();
329+
return "_" + name.Substring("Channel".Length);
330+
}
331+
316332
/// <summary>
317333
/// Create a new type by re-arranging the Matrix subchannels.
318334
/// </summary>
319335
/// <param name="s">The s.</param>
320336
/// <returns>ScalarNode.</returns>
321337
public ScalarNode GetSubchannels(Subchannel s)
322338
{
323-
return SubchannelsInternal<ScalarNode>(s.ToString());
339+
return SubchannelsInternal<ScalarNode>(SubchannelToken(s));
324340
}
325341

326342
/// <summary>
@@ -331,7 +347,7 @@ public ScalarNode GetSubchannels(Subchannel s)
331347
/// <returns>Vector2Node</returns>
332348
public Vector2Node GetSubchannels(Subchannel s1, Subchannel s2)
333349
{
334-
return SubchannelsInternal<Vector2Node>(s1.ToString(), s2.ToString());
350+
return SubchannelsInternal<Vector2Node>(SubchannelToken(s1), SubchannelToken(s2));
335351
}
336352

337353
/// <summary>
@@ -343,7 +359,7 @@ public Vector2Node GetSubchannels(Subchannel s1, Subchannel s2)
343359
/// <returns>Vector3Node</returns>
344360
public Vector3Node GetSubchannels(Subchannel s1, Subchannel s2, Subchannel s3)
345361
{
346-
return SubchannelsInternal<Vector3Node>(s1.ToString(), s2.ToString(), s3.ToString());
362+
return SubchannelsInternal<Vector3Node>(SubchannelToken(s1), SubchannelToken(s2), SubchannelToken(s3));
347363
}
348364

349365
/// <summary>
@@ -356,7 +372,7 @@ public Vector3Node GetSubchannels(Subchannel s1, Subchannel s2, Subchannel s3)
356372
/// <returns>Vector4Node</returns>
357373
public Vector4Node GetSubchannels(Subchannel s1, Subchannel s2, Subchannel s3, Subchannel s4)
358374
{
359-
return SubchannelsInternal<Vector4Node>(s1.ToString(), s2.ToString(), s3.ToString(), s4.ToString());
375+
return SubchannelsInternal<Vector4Node>(SubchannelToken(s1), SubchannelToken(s2), SubchannelToken(s3), SubchannelToken(s4));
360376
}
361377

362378
/// <summary>
@@ -371,7 +387,7 @@ public Vector4Node GetSubchannels(Subchannel s1, Subchannel s2, Subchannel s3, S
371387
/// <returns>Matrix3x2Node</returns>
372388
public Matrix3x2Node GetSubchannels(Subchannel s1, Subchannel s2, Subchannel s3, Subchannel s4, Subchannel s5, Subchannel s6)
373389
{
374-
return SubchannelsInternal<Matrix3x2Node>(s1.ToString(), s2.ToString(), s3.ToString(), s4.ToString(), s5.ToString(), s6.ToString());
390+
return SubchannelsInternal<Matrix3x2Node>(SubchannelToken(s1), SubchannelToken(s2), SubchannelToken(s3), SubchannelToken(s4), SubchannelToken(s5), SubchannelToken(s6));
375391
}
376392

377393
/// <summary>
@@ -400,10 +416,10 @@ public Matrix4x4Node GetSubchannels(Subchannel s1, Subchannel s2, Subchannel s3,
400416
Subchannel s9, Subchannel s10, Subchannel s11, Subchannel s12,
401417
Subchannel s13, Subchannel s14, Subchannel s15, Subchannel s16)
402418
{
403-
return SubchannelsInternal<Matrix4x4Node>(s1.ToString(), s2.ToString(), s3.ToString(), s4.ToString(),
404-
s5.ToString(), s6.ToString(), s7.ToString(), s8.ToString(),
405-
s9.ToString(), s10.ToString(), s11.ToString(), s12.ToString(),
406-
s13.ToString(), s14.ToString(), s15.ToString(), s16.ToString());
419+
return SubchannelsInternal<Matrix4x4Node>(SubchannelToken(s1), SubchannelToken(s2), SubchannelToken(s3), SubchannelToken(s4),
420+
SubchannelToken(s5), SubchannelToken(s6), SubchannelToken(s7), SubchannelToken(s8),
421+
SubchannelToken(s9), SubchannelToken(s10), SubchannelToken(s11), SubchannelToken(s12),
422+
SubchannelToken(s13), SubchannelToken(s14), SubchannelToken(s15), SubchannelToken(s16));
407423
}
408424
#pragma warning restore SA1117 // Parameters must be on same line or separate lines
409425

0 commit comments

Comments
 (0)