Fix Live2D motion converting. Close #150

This commit is contained in:
VaDiM
2026-07-18 01:30:08 +03:00
parent 0ba4b089da
commit c15093f848
@@ -101,6 +101,17 @@ namespace CubismLive2DExtractor
totalSegmentCount++;
}
private static void FillSingleSegment(Keyframe<float> curve, SerializableCurve cubismCurve, float time, ref int totalPointCount, ref int totalSegmentCount)
{
var value = cubismCurve.Segments[1];
var id = float.IsPositiveInfinity(curve.inSlope) ? 2f : 0f;
cubismCurve.Segments.Add(id); // Segment ID
cubismCurve.Segments.Add(time);
cubismCurve.Segments.Add(value);
totalPointCount++;
totalSegmentCount++;
}
public CubismMotion3Json(CubismUnityClasses.CubismFadeMotionData fadeMotion, HashSet<string> paramNames, HashSet<string> partNames, bool forceBezier)
{
Version = 3;
@@ -177,6 +188,10 @@ namespace CubismLive2DExtractor
fadeMotion.ParameterCurves[i].m_Curve[0].value
}
};
if (fadeMotion.ParameterCurves[i].m_Curve.Count == 1)
{
FillSingleSegment(fadeMotion.ParameterCurves[i].m_Curve[0], Curves[actualCurveCount], Meta.Duration, ref totalPointCount, ref totalSegmentCount);
}
for (var j = 1; j < fadeMotion.ParameterCurves[i].m_Curve.Count; j++)
{
var curve = fadeMotion.ParameterCurves[i].m_Curve[j];
@@ -232,6 +247,10 @@ namespace CubismLive2DExtractor
track.Curve[0].value
}
};
if (track.Curve.Count == 1)
{
FillSingleSegment(CreateKeyFrame(track.Curve[0]), Curves[i], Meta.Duration, ref totalPointCount, ref totalSegmentCount);
}
for (var j = 1; j < track.Curve.Count; j++)
{
var curve = CreateKeyFrame(track.Curve[j]);