Mouse picking

This commit is contained in:
Simon Lübeß
2022-05-30 14:06:52 +02:00
parent 47fdce0a7e
commit 8db2ce1d05
6 changed files with 72 additions and 28 deletions
@@ -23,8 +23,9 @@ namespace GlitchyEditor.EditWindows
public List<Entity> SelectedEntities => _selectedEntities;
public this(Scene scene)
public this(Editor editor, Scene scene)
{
_editor = editor;
SetContext(scene);
}
@@ -61,6 +62,23 @@ namespace GlitchyEditor.EditWindows
ImGui.EndPopup();
}
if (_editor.SceneViewportWindow.SelectionChanged)
{
if (Input.IsKeyReleased(.Control))
{
_selectedEntities.Clear();
}
var handle = _scene.[Friend]_ecsWorld.GetCurrentVersion(EcsEntity.[Friend]CreateEntityID(_editor.SceneViewportWindow.SelectedEntityId, 0));
if (handle case .Ok(let h))
{
Entity e = .(h, _scene);
_selectedEntities.Add(e);
}
}
ShowEntityHierarchy();
if ((ImGui.IsMouseDown(.Left) || ImGui.IsMouseDown(.Right)) && !ImGui.IsAnyItemHovered() && !ImGui.GetIO().KeyCtrl && ImGui.IsWindowHovered(.AllowWhenBlockedByPopup))
@@ -113,6 +131,8 @@ namespace GlitchyEditor.EditWindows
{
_scene.DestroyEntity(entity, true);
}
_selectedEntities.Clear();
}
private void ShowEntityHierarchyMenuBar()