Make parameters of relative node optional.

This commit is contained in:
2023-04-14 14:46:03 +08:00
parent 07babcb0ff
commit 400723d83b

View File

@@ -1,4 +1,3 @@
using Cryville.Common;
using Cryville.Common.Pdt;
using System;
using System.Collections.Generic;
@@ -133,6 +132,7 @@ namespace Cryville.Crtr {
new MotionNode() {
Id = 0,
Time = new Vec1(0),
Transition = TransitionType.Ease,
Rate = new Vec1(1),
Value = init
}
@@ -181,6 +181,7 @@ namespace Cryville.Crtr {
cnode = new MotionNode {
Id = node.Id,
Time = new Vec1(0),
Transition = TransitionType.Ease,
Rate = new Vec1(1),
Value = (Vector)Activator.CreateInstance(node.Value.GetType())
};
@@ -190,7 +191,7 @@ namespace Cryville.Crtr {
RelativeNodes.RemoveAt(i);
}
if (node.Time != null) cnode.Time = node.Time;
if (node.Transition.HasValue) cnode.Transition = node.Transition.Value;
if (node.Transition != null) cnode.Transition = node.Transition;
if (node.Rate != null) cnode.Rate = node.Rate;
if (node.Value != null) cnode.Value.ReplaceFrom(node.Value);
@@ -274,18 +275,19 @@ namespace Cryville.Crtr {
public void LerpWith(MotionNode start, float lerpedTime, ref MotionNode result) {
result.Id = Id;
if (Time == null) result.Time = null;
if (Time == null) result.Time = start.Time;
else {
var t = (Vector)result.Time;
Time.LerpWith(start.Time, lerpedTime, ref t);
}
result.Transition = Transition;
if (Rate == null) result.Rate = null;
if (Transition == null) result.Transition = start.Transition;
else result.Transition = Transition;
if (Rate == null) result.Rate = start.Rate;
else {
var t = (Vector)result.Rate;
Rate.LerpWith(start.Rate, lerpedTime, ref t);
}
if (Value == null) result.Value = null;
if (Value == null) result.Value = start.Value;
else Value.LerpWith(start.Value, lerpedTime, ref result.Value);
}
}