Skip to content

Commit f253c86

Browse files
committed
Fix calculations in Live2D motions
- Fixed calculation of totalPointCount and totalSegmentCount in Live2D motions. Live2D/CubismNativeFramework#57
1 parent 8ccdd0f commit f253c86

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

AssetStudioUtility/CubismLive2DExtractor/CubismMotion3Json.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ public CubismMotion3Json(CubismFadeMotion fadeMotion, HashSet<string> paramNames
122122
// Motion curves.
123123
Curves = new SerializableCurve[Meta.CurveCount];
124124

125-
var totalSegmentCount = 1;
126-
var totalPointCount = 1;
125+
var totalSegmentCount = 0;
126+
var totalPointCount = 0;
127127
var actualCurveCount = 0;
128128
for (var i = 0; i < fadeMotion.ParameterCurves.Length; i++)
129129
{
@@ -182,6 +182,7 @@ public CubismMotion3Json(CubismFadeMotion fadeMotion, HashSet<string> paramNames
182182
AddSegments(curve, preCurve, nextCurve, Curves[actualCurveCount], forceBezier, ref totalPointCount, ref totalSegmentCount, ref j);
183183
}
184184
actualCurveCount++;
185+
totalPointCount++;
185186
}
186187

187188
// The total number of segments (from all curves).
@@ -210,8 +211,8 @@ public CubismMotion3Json(ImportedKeyframedAnimation animation, bool forceBezier)
210211
};
211212
Curves = new SerializableCurve[Meta.CurveCount];
212213

213-
var totalSegmentCount = 1;
214-
var totalPointCount = 1;
214+
var totalSegmentCount = 0;
215+
var totalPointCount = 0;
215216
for (var i = 0; i < Meta.CurveCount; i++)
216217
{
217218
var track = animation.TrackList[i];
@@ -235,6 +236,7 @@ public CubismMotion3Json(ImportedKeyframedAnimation animation, bool forceBezier)
235236
var nextCurve = next != null ? new CubismKeyframeData(next) : new CubismKeyframeData();
236237
AddSegments(curve, preCurve, nextCurve, Curves[i], forceBezier, ref totalPointCount, ref totalSegmentCount, ref j);
237238
}
239+
totalPointCount++;
238240
}
239241
Meta.TotalSegmentCount = totalSegmentCount;
240242
Meta.TotalPointCount = totalPointCount;

0 commit comments

Comments
 (0)