Skip to content

Commit

Permalink
Disable animation key removal by default
Browse files Browse the repository at this point in the history
D:OS doesn't support transform tracks with missing knot values
  • Loading branch information
Norbyte committed Jul 30, 2019
1 parent e78b869 commit b2f5963
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
14 changes: 9 additions & 5 deletions LSLib/Granny/ColladaAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,17 @@ public bool ImportFromCollada(animation colladaAnim, Skeleton skeleton)
return true;
}

public TransformTrack MakeTrack()
public TransformTrack MakeTrack(bool removeTrivialKeys)
{
var keyframes = KeyframeTrack.FromMatrices(Times, Transforms);
keyframes.RemoveTrivialTranslations();
keyframes.RemoveTrivialRotations();
keyframes.RemoveTrivialScales();
keyframes.RemoveTrivialFrames();

if (removeTrivialKeys)
{
keyframes.RemoveTrivialTranslations();
keyframes.RemoveTrivialRotations();
keyframes.RemoveTrivialScales();
keyframes.RemoveTrivialFrames();
}

var track = TransformTrack.FromKeyframes(keyframes);
track.Flags = 0;
Expand Down
2 changes: 1 addition & 1 deletion LSLib/Granny/Model/ColladaImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ public void ImportAnimation(animation colladaAnim, Animation animation, TrackGro
if (importAnim.ImportFromCollada(colladaAnim, skeleton))
{
duration = Math.Max(duration, importAnim.Duration);
var track = importAnim.MakeTrack();
var track = importAnim.MakeTrack(Options.RemoveTrivialAnimationKeys);
trackGroup.TransformTracks.Add(track);
}
}
Expand Down
3 changes: 3 additions & 0 deletions LSLib/Granny/Model/Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public class ExporterOptions
// Apply Y-up transforms on skeletons?
public bool TransformSkeletons = true;
public bool IgnoreUVNaN = false;
// Remove animation keys that are a linear interpolation of the preceding and following keys
// Disabled by default, as D:OS doesn't support sparse knot values in anim curves.
public bool RemoveTrivialAnimationKeys = false;

public List<string> DisabledAnimations = new List<string>();
public List<string> DisabledModels = new List<string>();
Expand Down

0 comments on commit b2f5963

Please sign in to comment.