Skip to content

Commit

Permalink
bugfix: TrackEdit.truncate() uses identity fill transform
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Oct 9, 2023
1 parent 1773f2f commit ddf3560
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions WesLibrary/src/main/java/jme3utilities/wes/TrackEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -2596,20 +2596,23 @@ public static TransformTrack truncate(
Quaternion[] newRotations = new Quaternion[newCount];
Vector3f[] newScales = new Vector3f[newCount];

HasLocalTransform target = oldTrack.getTarget();
Transform fillData = target.getLocalTransform();

for (int frameI = 0; frameI < lastFrame; ++frameI) {
newTimes[frameI] = oldTimes[frameI] - oldTimes[0];
if (oldTranslations == null) {
newTranslations[frameI] = new Vector3f();
newTranslations[frameI] = fillData.getTranslation().clone();
} else {
newTranslations[frameI] = oldTranslations[frameI].clone();
}
if (oldRotations == null) {
newRotations[frameI] = new Quaternion();
newRotations[frameI] = fillData.getRotation().clone();
} else {
newRotations[frameI] = oldRotations[frameI].clone();
}
if (oldScales == null) {
newScales[frameI] = new Vector3f(1f, 1f, 1f);
newScales[frameI] = fillData.getScale().clone();
} else {
newScales[frameI] = oldScales[frameI].clone();
}
Expand All @@ -2620,7 +2623,6 @@ public static TransformTrack truncate(
newRotations[lastFrame] = endTransform.getRotation().clone();
newScales[lastFrame] = endTransform.getScale().clone();

HasLocalTransform target = oldTrack.getTarget();
TransformTrack result = new TransformTrack(
target, newTimes, newTranslations, newRotations, newScales);

Expand Down Expand Up @@ -2753,9 +2755,12 @@ public static TransformTrack wrap(
int oldCount = oldTimes.length;
assert oldCount > 0 : oldCount;
int newCount;
Vector3f wrapTranslation = new Vector3f();
Quaternion wrapRotation = new Quaternion();
Vector3f wrapScale = new Vector3f(1f, 1f, 1f);

HasLocalTransform target = oldTrack.getTarget();
Transform fillData = target.getLocalTransform();
Vector3f wrapTranslation = fillData.getTranslation().clone();
Quaternion wrapRotation = fillData.getRotation().clone();
Vector3f wrapScale = fillData.getScale().clone();

int endIndex = MyArray.findPreviousIndex(duration, oldTimes);
if (endIndex >= 0 && oldTimes[endIndex] != duration) {
Expand Down Expand Up @@ -2831,7 +2836,6 @@ public static TransformTrack wrap(
}
}

HasLocalTransform target = oldTrack.getTarget();
TransformTrack result = new TransformTrack(
target, newTimes, newTranslations, newRotations, newScales);

Expand Down

0 comments on commit ddf3560

Please sign in to comment.