stephengold / Wes

An animation editing and retargeting library for jMonkeyEngine (code has New BSD license)
Other
17 stars 2 forks source link

TrackEdit.truncate() generates repetitious keyframes #2

Closed Ali-RS closed 3 years ago

Ali-RS commented 3 years ago

Hi

TrackEdit.truncate() will always add an extra keyframe to the end of the track, however, there should be an exception.

If the endTime equals the lastFrame time then it should just overwrite the last frame and do not add a new frame, otherwise, the generated track will have repetitious keyframes. (at the end frame and its previous frame).

My suggestion would be to change this

int newCount = 2 + lastFrame;

to something like

boolean overwriteLastFrame = oldTimes[lastFrame] == endTime;
int newCount = overwriteLastFrame ? 1 + lastFrame : 2 + lastFrame;
stephengold commented 3 years ago

Fixed in "master" branch at 1d1982c9.

Ali-RS commented 3 years ago

Thanks