From 13fd69391de8a1ed4e3e7ba24962cadce1d857ad Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Sat, 15 Jul 2023 19:44:28 -0400 Subject: [PATCH] Added limits for sizing to be greater than 0 --- Editor/src/ComponentsPanel/BoxColliderPanel.h | 10 ++++++++-- Editor/src/ComponentsPanel/CapsuleColliderPanel.h | 7 ++++--- Editor/src/ComponentsPanel/CylinderColliderPanel.h | 5 +++-- Editor/src/ComponentsPanel/RigidbodyPanel.h | 3 ++- Editor/src/ComponentsPanel/SphereColliderPanel.h | 4 +++- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Editor/src/ComponentsPanel/BoxColliderPanel.h b/Editor/src/ComponentsPanel/BoxColliderPanel.h index 0aeaf3da..05ba27e5 100644 --- a/Editor/src/ComponentsPanel/BoxColliderPanel.h +++ b/Editor/src/ComponentsPanel/BoxColliderPanel.h @@ -20,9 +20,15 @@ public: ImGui::Text("Size"); ImGui::TableNextColumn(); - ImGuiHelper::DrawVec3("BoxSize", &component.Size); + ImGuiHelper::DrawVec3("BoxSize", &component.Size, 0.5f, 100.0, 0.01f); + component.Size = glm::abs(component.Size); + + component.Size.x = std::max(component.Size.x, 0.0001f); + component.Size.y = std::max(component.Size.y, 0.0001f); + component.Size.z = std::max(component.Size.z, 0.0001f); + ImGui::TableNextColumn(); - ComponentTableReset(component.Size, glm::vec3(1, 1, 1)); + ComponentTableReset(component.Size, glm::vec3(0.5f, 0.5f, 0.5f)); } ImGui::TableNextColumn(); { diff --git a/Editor/src/ComponentsPanel/CapsuleColliderPanel.h b/Editor/src/ComponentsPanel/CapsuleColliderPanel.h index 631a8410..b9b6678d 100644 --- a/Editor/src/ComponentsPanel/CapsuleColliderPanel.h +++ b/Editor/src/ComponentsPanel/CapsuleColliderPanel.h @@ -23,7 +23,8 @@ public: { ImGui::Text("Radius"); ImGui::TableNextColumn(); - ImGui::DragFloat("##Radius", &Radius); + ImGui::DragFloat("##Radius", &Radius, 0.01f, 0.001f); + Radius = std::max(Radius, 0.001f); ImGui::TableNextColumn(); ComponentTableReset(Radius, 0.5f) } @@ -31,8 +32,8 @@ public: { ImGui::Text("Height"); ImGui::TableNextColumn(); - - ImGui::DragFloat("##Height", &Height); + ImGui::DragFloat("##Height", &Height, 0.01f, 0.001f); + Height = std::max(Height, 0.001f); ImGui::TableNextColumn(); ComponentTableReset(Height, 1.0f) } diff --git a/Editor/src/ComponentsPanel/CylinderColliderPanel.h b/Editor/src/ComponentsPanel/CylinderColliderPanel.h index c5d74c2a..ccf8468d 100644 --- a/Editor/src/ComponentsPanel/CylinderColliderPanel.h +++ b/Editor/src/ComponentsPanel/CylinderColliderPanel.h @@ -24,6 +24,7 @@ public: ImGui::Text("Radius"); ImGui::TableNextColumn(); ImGui::DragFloat("##Radius", &Radius, 0.01f, 0.001f); + Radius = std::max(Radius, 0.001f); ImGui::TableNextColumn(); ComponentTableReset(Radius, 0.5f) } @@ -31,8 +32,8 @@ public: { ImGui::Text("Height"); ImGui::TableNextColumn(); - - ImGui::DragFloat("##Height", &Height, 0.01f, 0.001f); + ImGui::DragFloat("##Height", &Height, 0.01f, 0.0001f); + Height = std::max(Height, 0.001f); ImGui::TableNextColumn(); ComponentTableReset(Height, 1.0f) } diff --git a/Editor/src/ComponentsPanel/RigidbodyPanel.h b/Editor/src/ComponentsPanel/RigidbodyPanel.h index 5b4b07b8..1803fbd4 100644 --- a/Editor/src/ComponentsPanel/RigidbodyPanel.h +++ b/Editor/src/ComponentsPanel/RigidbodyPanel.h @@ -20,7 +20,8 @@ public: ImGui::Text("Mass"); ImGui::TableNextColumn(); - ImGui::DragFloat("##Mass", &component.Mass, 0.1f, 0.1f); + ImGui::DragFloat("##Mass", &component.Mass, 0.01f, 0.1f); + component.Mass = std::max(component.Mass, 0.0f); ImGui::TableNextColumn(); ComponentTableReset(component.Mass, 0.0f); } diff --git a/Editor/src/ComponentsPanel/SphereColliderPanel.h b/Editor/src/ComponentsPanel/SphereColliderPanel.h index 0a92c5cd..5033b7db 100644 --- a/Editor/src/ComponentsPanel/SphereColliderPanel.h +++ b/Editor/src/ComponentsPanel/SphereColliderPanel.h @@ -19,7 +19,9 @@ public: { ImGui::Text("Size"); ImGui::TableNextColumn(); - ImGui::DragFloat("##Radius", &component.Radius); + ImGui::DragFloat("##Radius", &component.Radius, 0.01f, 0.001f); + + component.Radius = std::max(component.Radius, 0.001f); ImGui::TableNextColumn(); ComponentTableReset(component.Radius, 0.5f); }