From fa8cd1c728388d3f84164724a76726d97f0fe3e3 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Thu, 7 May 2026 15:33:45 +0200 Subject: [PATCH] Fixes following nanobrain update --- CreatureControl/Runtime/Scripts/CreatureAnimator.cs | 11 +++++++++-- NanoBrain/Runtime/Scripts/Core/Cluster.cs | 3 --- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CreatureControl/Runtime/Scripts/CreatureAnimator.cs b/CreatureControl/Runtime/Scripts/CreatureAnimator.cs index 90acd3a..07a47ea 100644 --- a/CreatureControl/Runtime/Scripts/CreatureAnimator.cs +++ b/CreatureControl/Runtime/Scripts/CreatureAnimator.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using UnityEngine; using UnityEditor.Animations; -using LinearAlgebra; namespace CreatureControl { @@ -102,7 +101,7 @@ namespace CreatureControl { this.animator.SetFloat("Right", rightAnimationSpeed); Quaternion rotation = this.transform.rotation * Quaternion.Inverse(lastOrientation); - float rotationAngleY = Angles.Normalize(rotation.eulerAngles.y); + float rotationAngleY = AnglesNormalize(rotation.eulerAngles.y); float rotationSpeed = rotationAngleY / Time.deltaTime; float rotAnimationSpeed = rotationSpeed / rootMotionScaleRotate; this.animator.SetFloat("Rotation", rotAnimationSpeed); @@ -111,6 +110,14 @@ namespace CreatureControl { lastOrientation = this.transform.rotation; } + float AnglesNormalize(float angle) { + if (float.IsInfinity(angle)) + return angle; + + while (angle <= -180) angle += 360; + while (angle > 180) angle -= 360; + return angle; + } } } \ No newline at end of file diff --git a/NanoBrain/Runtime/Scripts/Core/Cluster.cs b/NanoBrain/Runtime/Scripts/Core/Cluster.cs index 2d5a1f7..8779e03 100644 --- a/NanoBrain/Runtime/Scripts/Core/Cluster.cs +++ b/NanoBrain/Runtime/Scripts/Core/Cluster.cs @@ -504,9 +504,6 @@ namespace NanoBrain { public void RefreshComputeOrders() { this._computeOrders = null; } - public void RefreshComputeOrders() { - this._computeOrders = null; - } private List TopologicalSort2(Nucleus startNode) { Dictionary inDegree = new();