mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Added checkbox to enable and disable polygon collider vertex handles
This commit is contained in:
@@ -51,6 +51,10 @@ namespace GlitchyEditor.EditWindows
|
|||||||
Entity entity = _entityHierarchyWindow.GetSelectedEntity(0);
|
Entity entity = _entityHierarchyWindow.GetSelectedEntity(0);
|
||||||
ShowComponents(entity);
|
ShowComponents(entity);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_editVerticesPolygonCollider2D = false;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.PopStyleVar();
|
ImGui.PopStyleVar();
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
@@ -82,6 +86,8 @@ namespace GlitchyEditor.EditWindows
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ShowPolygonColliderSceneGUI(Entity entity, PolygonCollider2DComponent* collider)
|
static void ShowPolygonColliderSceneGUI(Entity entity, PolygonCollider2DComponent* collider)
|
||||||
|
{
|
||||||
|
if (_editVerticesPolygonCollider2D)
|
||||||
{
|
{
|
||||||
for (int i < collider.VertexCount)
|
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
|
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;
|
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)
|
private static void ShowPolygonCollider2DComponentEditor(Entity entity, PolygonCollider2DComponent* polygonCollider)
|
||||||
{
|
{
|
||||||
float textWidth = ImGui.CalcTextSize("Offset".CStr()).x;
|
float textWidth = ImGui.CalcTextSize("Offset".CStr()).x;
|
||||||
@@ -498,9 +508,10 @@ namespace GlitchyEditor.EditWindows
|
|||||||
if (ImGui.EditFloat2("Offset", ref offset, .Zero, 0.1f, textWidth))
|
if (ImGui.EditFloat2("Offset", ref offset, .Zero, 0.1f, textWidth))
|
||||||
polygonCollider.Offset = offset;
|
polygonCollider.Offset = offset;
|
||||||
|
|
||||||
// TODO: Handles in editor, etc...
|
|
||||||
if (ImGui.CollapsingHeader("Vertices"))
|
if (ImGui.CollapsingHeader("Vertices"))
|
||||||
{
|
{
|
||||||
|
ImGui.Checkbox("Show Vertex gizmos", &_editVerticesPolygonCollider2D);
|
||||||
|
|
||||||
for (int i < polygonCollider.VertexCount)
|
for (int i < polygonCollider.VertexCount)
|
||||||
{
|
{
|
||||||
ImGui.EditFloat2(scope $"{i}", ref polygonCollider.Vertices[i]);
|
ImGui.EditFloat2(scope $"{i}", ref polygonCollider.Vertices[i]);
|
||||||
|
|||||||
Reference in New Issue
Block a user