small changes

This commit is contained in:
2025-09-16 20:47:15 +02:00
parent 104259f79b
commit f9fae63e01
3 changed files with 34 additions and 28 deletions

View File

@@ -18,6 +18,12 @@ namespace RebootKit.Engine.Animations {
bool TryFindChild(string name, out IReAnimatorNode node); bool TryFindChild(string name, out IReAnimatorNode node);
} }
public enum ReAnimatorTickMode {
Update,
Fixed,
Manual
}
[DefaultExecutionOrder(-100)] [DefaultExecutionOrder(-100)]
public class ReAnimator : MonoBehaviour { public class ReAnimator : MonoBehaviour {
static readonly Logger s_Logger = new Logger(nameof(ReAnimator)); static readonly Logger s_Logger = new Logger(nameof(ReAnimator));
@@ -25,7 +31,7 @@ namespace RebootKit.Engine.Animations {
[SerializeField] Animator m_Animator; [SerializeField] Animator m_Animator;
[SerializeField] LayerMixerNode m_Root; [SerializeField] LayerMixerNode m_Root;
PlayableGraph m_Graph; public PlayableGraph Graph { get; private set; }
AnimationPlayableOutput m_Output; AnimationPlayableOutput m_Output;
void Awake() { void Awake() {
@@ -33,24 +39,26 @@ namespace RebootKit.Engine.Animations {
m_Animator.runtimeAnimatorController = null; m_Animator.runtimeAnimatorController = null;
m_Graph = PlayableGraph.Create(name); Graph = PlayableGraph.Create(name);
m_Output = AnimationPlayableOutput.Create(m_Graph, "Animation Output", m_Animator); m_Output = AnimationPlayableOutput.Create(Graph, "Animation Output", m_Animator);
if (m_Root.Build(m_Graph) is AnimationLayerMixerPlayable layerMixer) { if (m_Root.Build(Graph) is AnimationLayerMixerPlayable layerMixer) {
m_Output.SetSourcePlayable(layerMixer, 0); m_Output.SetSourcePlayable(layerMixer, 0);
} }
m_Graph.Play(); Graph.Play();
} }
void OnDestroy() { void OnDestroy() {
if (m_Graph.IsValid()) { if (Graph.IsValid()) {
m_Graph.Destroy(); Graph.Destroy();
} }
} }
void Update() { void Update() {
m_Root.Tick(Time.deltaTime); float dt = Time.deltaTime;
m_Root.Tick(dt);
Graph.Evaluate(dt);
} }
public void SetLayerWeight(int layer, float weight) { public void SetLayerWeight(int layer, float weight) {
@@ -71,7 +79,7 @@ namespace RebootKit.Engine.Animations {
if (node is TNode tnode) { if (node is TNode tnode) {
return tnode; return tnode;
} }
s_Logger.Error($"Couldn't find node with name: {nodeName} of type {typeof(TNode).Name}"); s_Logger.Error($"Couldn't find node with name: {nodeName} of type {typeof(TNode).Name}");
return null; return null;
} }

View File

@@ -39,7 +39,7 @@ namespace RebootKit.Engine.Development {
Resolution resolution = Screen.currentResolution; Resolution resolution = Screen.currentResolution;
m_StringBuilder.Append("fps: "); m_StringBuilder.Append("fps: ");
m_StringBuilder.Append(Mathf.RoundToInt(1f / Time.deltaTime)); m_StringBuilder.Append(Mathf.RoundToInt(1.0f / Time.unscaledDeltaTime));
m_StringBuilder.Append(" | dt: "); m_StringBuilder.Append(" | dt: ");
m_StringBuilder.Append(Time.deltaTime.ToString("F4")); m_StringBuilder.Append(Time.deltaTime.ToString("F4"));
m_StringBuilder.Append("ms | runtime: "); m_StringBuilder.Append("ms | runtime: ");

View File

@@ -422,7 +422,7 @@ namespace RebootKit.Engine.Simulation {
return; return;
} }
ActorCommand command = new ActorCommand { var command = new ActorCommand {
ActorID = ActorID, ActorID = ActorID,
CommandID = commandID, CommandID = commandID,
Data = data Data = data
@@ -448,7 +448,7 @@ namespace RebootKit.Engine.Simulation {
return; return;
} }
ActorEvent actorEvent = new ActorEvent { var actorEvent = new ActorEvent {
ActorID = ActorID, ActorID = ActorID,
EventID = eventID, EventID = eventID,
Data = data Data = data
@@ -488,15 +488,16 @@ namespace RebootKit.Engine.Simulation {
} }
internal ActorCoreStateSnapshot GetCoreStateSnapshot() { internal ActorCoreStateSnapshot GetCoreStateSnapshot() {
ActorCoreStateSnapshot snapshot = new ActorCoreStateSnapshot(); var snapshot = new ActorCoreStateSnapshot {
snapshot.ActorID = ActorID; ActorID = ActorID,
snapshot.Timestamp = DateTime.UtcNow; Timestamp = DateTime.UtcNow,
snapshot.Position = transform.localPosition; Position = transform.localPosition,
snapshot.Rotation = transform.localRotation; Rotation = transform.localRotation,
snapshot.Scale = transform.localScale; Scale = transform.localScale,
snapshot.Flags = Flags; Flags = Flags,
MasterActorID = MasterActor != null ? MasterActor.ActorID : (ushort)0
};
snapshot.MasterActorID = MasterActor != null ? MasterActor.ActorID : (ushort)0;
if (snapshot.MasterActorID != 0) { if (snapshot.MasterActorID != 0) {
snapshot.MasterSocketName = MasterSocketName; snapshot.MasterSocketName = MasterSocketName;
} else { } else {
@@ -569,7 +570,7 @@ namespace RebootKit.Engine.Simulation {
} }
internal ActorTransformSyncData GetTransformSyncDataForClient(ulong clientID) { internal ActorTransformSyncData GetTransformSyncDataForClient(ulong clientID) {
ActorTransformSyncData data = new ActorTransformSyncData { var data = new ActorTransformSyncData {
ActorID = ActorID, ActorID = ActorID,
SyncMode = ActorTransformSyncMode.None SyncMode = ActorTransformSyncMode.None
}; };
@@ -643,8 +644,7 @@ namespace RebootKit.Engine.Simulation {
transform.localPosition = socket.localPosition; transform.localPosition = socket.localPosition;
transform.localRotation = socket.localRotation; transform.localRotation = socket.localRotation;
} else { } else {
s_ActorLogger s_ActorLogger.Error($"Failed to update mounted transform: Socket {MasterSocketName} not found on {MasterActor.name}");
.Error($"Failed to update mounted transform: Socket {MasterSocketName} not found on {MasterActor.name}");
} }
} }
@@ -664,8 +664,7 @@ namespace RebootKit.Engine.Simulation {
} }
if (actorCommand.ActorID != ActorID) { if (actorCommand.ActorID != ActorID) {
s_ActorLogger s_ActorLogger.Error($"Actor command ActorID {actorCommand.ActorID} does not match this actor's ID {ActorID}");
.Error($"Actor command ActorID {actorCommand.ActorID} does not match this actor's ID {ActorID}");
return; return;
} }
@@ -679,8 +678,7 @@ namespace RebootKit.Engine.Simulation {
} }
if (actorEvent.ActorID != ActorID) { if (actorEvent.ActorID != ActorID) {
s_ActorLogger s_ActorLogger.Error($"Actor event ActorID {actorEvent.ActorID} does not match this actor's ID {ActorID}");
.Error($"Actor event ActorID {actorEvent.ActorID} does not match this actor's ID {ActorID}");
return; return;
} }