generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: animation API (work in progress)
- Loading branch information
1 parent
f16f99e
commit 7d44361
Showing
31 changed files
with
1,499 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEditor; | ||
|
||
namespace nadena.dev.ndmf.animator | ||
{ | ||
internal class ECBComparator : IComparer<EditorCurveBinding>, IEqualityComparer<EditorCurveBinding> | ||
{ | ||
internal static ECBComparator Instance { get; } = new(); | ||
|
||
private ECBComparator() | ||
{ | ||
} | ||
|
||
public int Compare(EditorCurveBinding x, EditorCurveBinding y) | ||
{ | ||
var pathComparison = string.Compare(x.path, y.path, StringComparison.Ordinal); | ||
if (pathComparison != 0) return pathComparison; | ||
var propertyNameComparison = string.Compare(x.propertyName, y.propertyName, StringComparison.Ordinal); | ||
if (propertyNameComparison != 0) return propertyNameComparison; | ||
var isPPtrCurveComparison = x.isPPtrCurve.CompareTo(y.isPPtrCurve); | ||
if (isPPtrCurveComparison != 0) return isPPtrCurveComparison; | ||
var isDiscreteCurveComparison = x.isDiscreteCurve.CompareTo(y.isDiscreteCurve); | ||
if (isDiscreteCurveComparison != 0) return isDiscreteCurveComparison; | ||
return x.isSerializeReferenceCurve.CompareTo(y.isSerializeReferenceCurve); | ||
} | ||
|
||
public bool Equals(EditorCurveBinding x, EditorCurveBinding y) | ||
{ | ||
return x.path == y.path && x.propertyName == y.propertyName && x.isPPtrCurve == y.isPPtrCurve && | ||
x.isDiscreteCurve == y.isDiscreteCurve && | ||
x.isSerializeReferenceCurve == y.isSerializeReferenceCurve && Equals(x.type, y.type); | ||
} | ||
|
||
public int GetHashCode(EditorCurveBinding obj) | ||
{ | ||
return HashCode.Combine(obj.path, obj.propertyName, obj.isPPtrCurve, obj.isDiscreteCurve, | ||
obj.isSerializeReferenceCurve, obj.type); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace nadena.dev.ndmf.animator | ||
{ | ||
internal interface ICommitable<T> | ||
{ | ||
/// <summary> | ||
/// Allocates the destination unity object, but does not recurse back into the CommitContext. | ||
/// </summary> | ||
/// <param name="context"></param> | ||
/// <returns></returns> | ||
T Prepare(CommitContext context); | ||
|
||
/// <summary> | ||
/// Fills in all fields of the destination unity object. This may recurse back into the CommitContext. | ||
/// </summary> | ||
/// <param name="context"></param> | ||
void Commit(CommitContext context, T obj); | ||
} | ||
|
||
internal class CommitContext | ||
{ | ||
private readonly Dictionary<object, object> _commitCache = new(); | ||
|
||
internal R CommitObject<R>(ICommitable<R> obj) | ||
{ | ||
if (_commitCache.TryGetValue(obj, out var result)) return (R)result; | ||
|
||
var resultObj = obj.Prepare(this); | ||
_commitCache[obj] = resultObj; | ||
|
||
obj.Commit(this, resultObj); | ||
|
||
return resultObj; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace nadena.dev.ndmf.animator | ||
{ | ||
internal interface IPlatformAnimatorBindings | ||
{ | ||
/// <summary> | ||
/// If true, the motion asset should be maintained as-is without replacement or modification. | ||
/// </summary> | ||
/// <param name="m"></param> | ||
/// <returns></returns> | ||
bool IsSpecialMotion(Motion m); | ||
|
||
/// <summary> | ||
/// Returns any animator controllers that are referenced by platform-specific assets (e.g. VRCAvatarDescriptor). | ||
/// The bool flag indicates whether the controller is overridden (true) or left as default (false). | ||
/// </summary> | ||
/// <returns></returns> | ||
IEnumerable<(object, RuntimeAnimatorController, bool)> GetInnateControllers(); | ||
|
||
/// <summary> | ||
/// Updates any innate controllers to reference new animator controllers. | ||
/// </summary> | ||
/// <param name="controllers"></param> | ||
void CommitInnateControllers(IEnumerable<(object, RuntimeAnimatorController)> controllers); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Editor/API/AnimatorServices/IPlatformAnimatorBindings.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using UnityEditor.Animations; | ||
|
||
namespace nadena.dev.ndmf.animator | ||
{ | ||
/// <summary> | ||
/// Represents an animator controller that has been indexed by NDMF for faster manipulation. This class also | ||
/// guarantees that certain assets have been cloned, specifically: | ||
/// - AnimatorController | ||
/// - StateMachine | ||
/// - AnimatorState | ||
/// - AnimatorStateTransition | ||
/// - BlendTree | ||
/// - AnimationClip | ||
/// - Any state behaviors attached to the animator controller | ||
/// </summary> | ||
public class VirtualAnimatorController | ||
{ | ||
private BuildContext _context; | ||
private AnimatorController _controller; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Editor/API/AnimatorServices/VirtualAnimatorController.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.