From cf2abfcfe34a9b3e4cf5af193d1f320374416267 Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 18 Jan 2025 16:19:41 +1100 Subject: convert models and editor to use ecs --- editor.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'editor.cpp') diff --git a/editor.cpp b/editor.cpp index 8bf0c4a..a7f3b31 100644 --- a/editor.cpp +++ b/editor.cpp @@ -1,7 +1,9 @@ #include "debugdraw.hpp" #include "editor.hpp" #include "model.hpp" +#include "scene.hpp" #include "ui.hpp" +#include "world.hpp" static struct { UI* ui; @@ -12,6 +14,7 @@ static struct { UI::Slider* metalness_input; UI::Slider* roughness_input; UI::Slider* ao_input; + Entity_Id selected; Model_Instance* selected_inst; int selected_mesh; } editor; @@ -126,10 +129,17 @@ void deinit_editor() { } -void editor_on_select(Model_Instance* instance, int mesh) { +void editor_on_select(World& w, Entity_Id e, int m) { if (!editor.ui->hovered) { - editor.selected_inst = instance; - editor.selected_mesh = mesh; + editor.selected = e; + if (e && w.has(e)) { + auto& cm = w.get(e); + editor.selected_inst = cm.i; + editor.selected_mesh = m; + } else { + editor.selected_inst = 0; + editor.selected_mesh = -1; + } if (editor.mat_win) { setup_mat_edit(); } -- cgit v1.2.3-54-g00ecf