summaryrefslogtreecommitdiff
path: root/editor.cpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2025-01-18 16:19:41 +1100
committerquou <quou@disroot.org>2025-01-18 16:19:41 +1100
commitcf2abfcfe34a9b3e4cf5af193d1f320374416267 (patch)
treec0f209ac730fa8a8b4564c818b3ce44fec59ffeb /editor.cpp
parent025510f2928e123d12a7d6d3574ca70fdd9d7717 (diff)
convert models and editor to use ecs
Diffstat (limited to 'editor.cpp')
-rw-r--r--editor.cpp16
1 files changed, 13 insertions, 3 deletions
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<C_Model>(e)) {
+ auto& cm = w.get<C_Model>(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();
}