diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2023-05-19 05:50:06 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-05-19 05:50:06 +0200 |
| commit | a4870b515381b222f5dcb9d4d3cfe34102967ce4 (patch) | |
| tree | 26c21db43a47635ca28594153bd5640f95ebcf62 /editor/vobj-editor.cpp | |
| parent | f5a7dc9d264c4231d9f688704ceef6971bddf272 (diff) | |
add selecting and placing vobj's
TODO:
- saving to disk
- inspect dialog
- actual lightmap shader
Diffstat (limited to 'editor/vobj-editor.cpp')
| -rw-r--r-- | editor/vobj-editor.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/editor/vobj-editor.cpp b/editor/vobj-editor.cpp index 2cec6a5c..d242f68f 100644 --- a/editor/vobj-editor.cpp +++ b/editor/vobj-editor.cpp @@ -3,6 +3,7 @@ #include "loader/loader.hpp" #include "src/world.hpp" #include "src/light.hpp" +#include "app.hpp" #include <array> #include <utility> #include <Corrade/Containers/StringView.h> @@ -39,23 +40,23 @@ auto vobj_editor::get_type(StringView name) -> const vobj_* bool vobj_editor::is_item_selected(const vobj_& x) const { return _selected == &x; } bool vobj_editor::is_anything_selected() const { return _selected != nullptr; } -void vobj_editor::place_tile(world& w, global_coords pos, const vobj_* x) +void vobj_editor::place_tile(world& w, global_coords pos, const vobj_* x, struct app& a) { if (!x) { - // don't regen colliders auto [c, t] = w[pos]; - const auto px = Vector2(pos.local()) * TILE_SIZE2; const auto& es = c.entities(); - for (auto i = es.size()-1; i != (size_t)-1; i--) +start: while (auto id = a.object_at_cursor()) { - const auto& e = *es[i]; - if (!e.is_virtual()) - continue; - auto center = Vector2(e.coord.local())*TILE_SIZE2 + Vector2(e.offset) + Vector2(e.bbox_offset), - min = center - Vector2(e.bbox_size/2), max = min + Vector2(e.bbox_size); - if (px >= min && px <= max) - c.remove_entity(i); + for (auto i = es.size()-1; i != (size_t)-1; i--) + { + if (es[i]->id == id) + { + c.remove_entity(i); + goto start; + } + } + break; } } else @@ -81,7 +82,7 @@ struct light_factory final : vobj_factory std::shared_ptr<entity> make(world& w, object_id id, global_coords pos) const override { - auto ret = w.make_entity<light>(id, {pos.chunk(), pos.local(), 0}, light_proto{}); + auto ret = w.make_entity<light>(id, pos, light_proto{}); return ret; } }; |
