Added checkbox to enable and disable polygon collider vertex handles

This commit is contained in:
Simon Lübeß
2024-01-11 22:55:40 +01:00
parent 7cdc398494
commit 91cef7ad4b
@@ -51,6 +51,10 @@ namespace GlitchyEditor.EditWindows
Entity entity = _entityHierarchyWindow.GetSelectedEntity(0);
ShowComponents(entity);
}
else
{
_editVerticesPolygonCollider2D = false;
}
ImGui.PopStyleVar();
ImGui.End();
@@ -82,6 +86,8 @@ namespace GlitchyEditor.EditWindows
}
static void ShowPolygonColliderSceneGUI(Entity entity, PolygonCollider2DComponent* collider)
{
if (_editVerticesPolygonCollider2D)
{
for (int i < collider.VertexCount)
{
@@ -96,6 +102,7 @@ namespace GlitchyEditor.EditWindows
}
}
}
}
private static void DrawComponenSceneGUI<TComponent>(Entity entity, function void(Entity, TComponent*) showSceneGUI) where TComponent: struct, new
{
@@ -489,6 +496,9 @@ namespace GlitchyEditor.EditWindows
circleCollider.RestitutionThreshold = restitutionThreshold;
}
/// If true handles for editing the vertices of the PolygonCollider2DComponent will be visible
private static bool _editVerticesPolygonCollider2D = false;
private static void ShowPolygonCollider2DComponentEditor(Entity entity, PolygonCollider2DComponent* polygonCollider)
{
float textWidth = ImGui.CalcTextSize("Offset".CStr()).x;
@@ -498,9 +508,10 @@ namespace GlitchyEditor.EditWindows
if (ImGui.EditFloat2("Offset", ref offset, .Zero, 0.1f, textWidth))
polygonCollider.Offset = offset;
// TODO: Handles in editor, etc...
if (ImGui.CollapsingHeader("Vertices"))
{
ImGui.Checkbox("Show Vertex gizmos", &_editVerticesPolygonCollider2D);
for (int i < polygonCollider.VertexCount)
{
ImGui.EditFloat2(scope $"{i}", ref polygonCollider.Vertices[i]);