2D Polygon Collider editor with Gizmos

+ Added Handles class
This commit is contained in:
Simon Lübeß
2023-08-21 13:18:51 +02:00
parent 377997f903
commit d3c19dd8da
3 changed files with 80 additions and 3 deletions
+40
View File
@@ -0,0 +1,40 @@
using GlitchyEngine.Math;
using ImGuizmo;
using System;
namespace GlitchyEditor;
static class Handles
{
private static float3? _snap;
public static Matrix View {get; private set;}
public static Matrix Projection {get; private set;}
private static bool _usedGizmo;
public static bool UsedGizmo => _usedGizmo;
public static void SetViewProjection(Matrix view, Matrix projection)
{
View = view;
Projection = projection;
}
public static void SetSnap(float3? snap)
{
_snap = snap;
}
public static bool ShowGizmo(ref Matrix transform, ImGuizmo.OPERATION gizmoType, bool globalGizmo = true, int32? id = null)
{
if (id != null)
ImGuizmo.SetID(id.Value);
#unwarn
bool result = ImGuizmo.Manipulate((.)&View, (.)&Projection, gizmoType, globalGizmo ? .WORLD : .LOCAL, (.)&transform, null, _snap.HasValue ? (.)&_snap : null);
_usedGizmo |= ImGuizmo.IsUsing();
return result;
}
}