From 8000a0848ed627c14126fb4daaad2bb0bc34add8 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:03:51 +0200 Subject: [PATCH] SkinRenderer - Update 'OnUpdate' function --- PCK-Studio/Rendering/SkinRenderer.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/PCK-Studio/Rendering/SkinRenderer.cs b/PCK-Studio/Rendering/SkinRenderer.cs index 303208eb..22cd995d 100644 --- a/PCK-Studio/Rendering/SkinRenderer.cs +++ b/PCK-Studio/Rendering/SkinRenderer.cs @@ -231,7 +231,7 @@ namespace PckStudio.Rendering private CubeGroupMesh leftLeg; private float animationCurrentRotationAngle; - private float animationRotationSpeed = 0.5f; + private float animationRotationSpeed = 16f; private float animationMaxAngleInDegrees = 5f; private bool showWireFrame = false; @@ -1182,17 +1182,20 @@ namespace PckStudio.Rendering protected override void OnUpdate(object sender, TimeSpan timestep) { - double delta = timestep.TotalMilliseconds; base.OnUpdate(sender, timestep); + double delta = timestep.TotalSeconds; if (!Animate) return; + StringBuilder sb = new StringBuilder(); sb.AppendLine(delta.ToString()); sb.AppendLine(animationCurrentRotationAngle.ToString()); + sb.AppendLine(animationRotationSpeed.ToString()); d_debugLabel.Text = sb.ToString(); - animationCurrentRotationAngle = (float)Math.Sin(delta * 100) * animationRotationSpeed; - //if (animationCurrentRotationAngle >= animationMaxAngleInDegrees || animationCurrentRotationAngle <= -animationMaxAngleInDegrees) - // animationRotationSpeed = -animationRotationSpeed; + animationCurrentRotationAngle += (float)delta * animationRotationSpeed; + animationCurrentRotationAngle = MathHelper.Clamp(animationCurrentRotationAngle, -animationMaxAngleInDegrees, animationMaxAngleInDegrees); + if (animationCurrentRotationAngle >= animationMaxAngleInDegrees || animationCurrentRotationAngle <= -animationMaxAngleInDegrees) + animationRotationSpeed = -animationRotationSpeed; } private void ReInitialzeSkinData()