From a832cbba3add431f3e18111705aeb8d6680987b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20J=C3=B6nsson?= Date: Tue, 12 Dec 2023 20:19:42 +0100 Subject: [PATCH] Added Clamp and fixed crash --- Engine/Volt-ScriptCore/Source/Volt/Math/Mathf.cs | 5 +++++ Volt/Sandbox/src/Sandbox/DebugRendering.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Engine/Volt-ScriptCore/Source/Volt/Math/Mathf.cs b/Engine/Volt-ScriptCore/Source/Volt/Math/Mathf.cs index 9bdd986fb..bf6cecfe4 100644 --- a/Engine/Volt-ScriptCore/Source/Volt/Math/Mathf.cs +++ b/Engine/Volt-ScriptCore/Source/Volt/Math/Mathf.cs @@ -64,6 +64,11 @@ public static float Clamp(float value, float min, float max) return value > max ? max : value; } + public static Vector3 Clamp(Vector3 value, Vector3 min, Vector3 max) + { + return new Vector3(Clamp(value.x, min.x, max.x), Clamp(value.y, min.y, max.y), Clamp(value.z, min.z, max.z)); + } + public static float Asin(float x) => (float)Math.Asin(x); public static float Atan(float x) => (float)Math.Atan(x); public static float Atan2(float y, float x) => (float)Math.Atan2(y, x); diff --git a/Volt/Sandbox/src/Sandbox/DebugRendering.cpp b/Volt/Sandbox/src/Sandbox/DebugRendering.cpp index 08f65d110..241dd6d3c 100644 --- a/Volt/Sandbox/src/Sandbox/DebugRendering.cpp +++ b/Volt/Sandbox/src/Sandbox/DebugRendering.cpp @@ -31,6 +31,10 @@ void Sandbox::RenderSelection(Ref camera) for (const auto& id : SelectionManager::GetSelectedEntities()) { Volt::Entity entity = myRuntimeScene->GetEntityFromUUID(id); + if (!entity) + { + continue; + } if (!entity.HasComponent()) {