Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions lmeditor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ add_library(

src/controller/viewport/viewport.cpp

src/controller/map_editor/map_editor_controller.cpp
src/controller/map_editor/move_selection.cpp
src/controller/map_editor/viewport_commands.cpp
src/controller/map_editor/move_selection_commands.cpp

src/controller/map_editor/states/add_adjacent.cpp
src/controller/map_editor/states/translate.cpp
src/controller/map_editor/states/select.cpp
src/controller/map_editor/states/copy_object.cpp
src/controller/map_editor/states/scale.cpp
src/controller/map_editor/states/rotate.cpp
src/controller/map_editor/states/reparent.cpp
src/controller/entity_editor/entity_editor_controller.cpp
src/controller/entity_editor/move_selection.cpp
src/controller/entity_editor/viewport_commands.cpp
src/controller/entity_editor/move_selection_commands.cpp

src/controller/entity_editor/states/add_adjacent.cpp
src/controller/entity_editor/states/translate.cpp
src/controller/entity_editor/states/select.cpp
src/controller/entity_editor/states/copy_object.cpp
src/controller/entity_editor/states/scale.cpp
src/controller/entity_editor/states/rotate.cpp
src/controller/entity_editor/states/reparent.cpp

src/controller/entity_list/entity_list_controller.cpp

src/controller/inspector/inspector_controller.cpp

src/component/map_editor/rendering.cpp
src/component/map_editor/map_editor_component.cpp
src/component/entity_editor/rendering.cpp
src/component/entity_editor/entity_editor.cpp

src/component/inspector/inspector_component.cpp

Expand Down Expand Up @@ -135,8 +135,8 @@ add_executable(

test/test_lmeditor.cpp
test/test_trimesh.cpp
test/map_editor/test.cpp
test/map_editor/test_move_selection.cpp
test/entity_editor/test.cpp
test/entity_editor/test_move_selection.cpp
test/test_entity_list.cpp
)

Expand Down
78 changes: 78 additions & 0 deletions lmeditor/include/lmeditor/component/entity_editor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#pragma once

#include "component.h"
#include <bitset>
#include <entt/fwd.hpp>
#include <lmeditor/model/orbital_camera.h>
#include <lmtk/font.h>

namespace lmeditor
{
struct entity_editor_features
{
enum class flag
{
// Add non-root entities ie. new children
add,
// Add root entities ie. without a parent
add_root,
reparent,
rotate,
scale,
translate,
n_features
};

entity_editor_features &add()
{
flags.set(static_cast<size_t>(flag::add));
return *this;
}

entity_editor_features &add_root()
{
flags.set(static_cast<size_t>(flag::add_root));
return *this;
}

entity_editor_features &reparent()
{
flags.set(static_cast<size_t>(flag::reparent));
return *this;
}

entity_editor_features &rotate()
{
flags.set(static_cast<size_t>(flag::rotate));
return *this;
}

entity_editor_features &scale()
{
flags.set(static_cast<size_t>(flag::scale));
return *this;
}

entity_editor_features &translate()
{
flags.set(static_cast<size_t>(flag::translate));
return *this;
}

std::bitset<static_cast<size_t>(flag::n_features)> flags;
};

struct entity_editor_init
{
entt::registry &registry;
orbital_camera_init camera_init;
lmgl::irenderer *renderer;
lmtk::resource_cache const &resource_cache;
lm::point2i position;
lm::size2i size;
std::array<float, 3> selection_outline_colour;
entity_editor_features features;

component operator()();
};
} // namespace lmeditor
22 changes: 0 additions & 22 deletions lmeditor/include/lmeditor/component/map_editor.h

This file was deleted.

5 changes: 3 additions & 2 deletions lmeditor/src/app/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <lmeditor/component/asset_list.h>
#include <lmeditor/component/command_help.h>
#include <lmeditor/component/entity_list.h>
#include <lmeditor/component/map_editor.h>
#include <lmeditor/component/player.h>
#include <lmeditor/component/saver.h>
#include <lmeditor/component/entity_editor.h>
#include <lmeditor/model/creation_time.h>
#include <lmeditor/model/orbital_camera.h>
#include <lmlib/variant_visitor.h>
Expand Down Expand Up @@ -87,7 +87,7 @@ editor_app::editor_app(const std::filesystem::path &project_dir)
window_size.height,
};

auto map_editor = map_editor_init{
auto map_editor = entity_editor_init{
map,
orbital_camera_init{
.fov = (float)M_PI / 3,
Expand All @@ -102,6 +102,7 @@ editor_app::editor_app(const std::filesystem::path &project_dir)
{0, 0},
map_editor_size,
std::array{1.f, 0.f, 0.f},
entity_editor_features{}.add().add_root().reparent().rotate().scale().translate.
}();

auto config_asset_dir = project_config["asset_directory"];
Expand Down
2 changes: 1 addition & 1 deletion lmeditor/src/app/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <boost/dll/shared_library.hpp>
#include <filesystem>
#include <lmeditor/component/inspector.h>
#include <lmeditor/component/map_editor.h>
#include <lmeditor/component/entity_editor.h>
#include <lmeditor/model/trimesh.h>
#include <lmeditor/project_plugin.h>
#include <lmeditor/simulation_plugin.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include "../../controller/map_editor/map_editor_controller.h"
#include "../../controller/entity_editor/entity_editor_controller.h"
#include <chrono>
#include <entt/entt.hpp>
#include <filesystem>
#include <lmeditor/component/command_help.h>
#include <lmeditor/component/map_editor.h>
#include <lmeditor/component/entity_editor.h>
#include <lmgl/lmgl.h>
#include <lmhuv.h>
#include <lmlib/variant_visitor.h>
Expand All @@ -20,12 +20,12 @@

namespace lmeditor
{
class map_editor_component : public component_interface
class entity_editor : public component_interface
{
public:
explicit map_editor_component(map_editor_init const &init);
map_editor_component(map_editor_component const &) = delete;
map_editor_component(map_editor_component &&) = delete;
explicit entity_editor(entity_editor_init const &init);
entity_editor(entity_editor const &) = delete;
entity_editor(entity_editor &&) = delete;

component_interface &update(
lmgl::irenderer *renderer,
Expand All @@ -38,7 +38,7 @@ class map_editor_component : public component_interface
widget_interface &
move_resources(lmgl::resource_sink &resource_sink) override;

map_editor_component &set_rect(lm::point2i pos, lm::size2i size) override;
entity_editor &set_rect(lm::point2i pos, lm::size2i size) override;
lm::size2i get_size() override;
lm::point2i get_position() override;
std::vector<command_description> get_command_descriptions() override;
Expand Down Expand Up @@ -68,7 +68,7 @@ class map_editor_component : public component_interface
lmgl::buffer create_selection_ubuffer(lmgl::irenderer *renderer);
lmgl::material create_outline_material(lmgl::irenderer *renderer);

map_editor_controller controller;
entity_editor_controller controller;
lmhuv::pvisual_view visual_view;
lmgl::material selection_stencil_material, selection_outline_material;
lmgl::buffer box_vpositions, box_vnormals, box_indices;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "map_editor_component.h"
#include "entity_editor"
#include <fmt/format.h>
#include <lmhuv/box.h>
#include <lmlib/enumerate.h>
Expand All @@ -8,12 +8,12 @@

namespace lmeditor
{
component map_editor_init::operator()()
component entity_editor_init::operator()()
{
return std::make_unique<map_editor_component>(*this);
return std::make_unique<entity_editor>(*this);
}

map_editor_component::map_editor_component(map_editor_init const &init)
entity_editor::entity_editor(entity_editor_init const &init)
: controller{init.registry, init.camera_init},
visual_view{
lmhuv::create_visual_view(lmhuv::visual_view_init{
Expand All @@ -32,7 +32,7 @@ map_editor_component::map_editor_component(map_editor_init const &init)
.resource_cache = init.resource_cache,
.colour = state_text_colour,
.position = init.position + state_text_position,
.text = map_editor_controller::select_state::label,
.text = entity_editor_controller::select_state::label,
}},
selection_outline_colour{init.selection_outline_colour},
position{init.position},
Expand All @@ -56,7 +56,7 @@ map_editor_component::map_editor_component(map_editor_init const &init)
selection_outline_geometry->set_line_width(6.f);
}

lmgl::geometry map_editor_component::create_box_geometry(
lmgl::geometry entity_editor::create_box_geometry(
lmgl::irenderer *renderer,
lmgl::material box_material,
lmgl::ibuffer *ubuffer)
Expand All @@ -74,7 +74,7 @@ lmgl::geometry map_editor_component::create_box_geometry(
return geometry;
}

void map_editor_component::set_state_text(
void entity_editor::set_state_text(
lmgl::irenderer *renderer,
std::string new_text,
lmgl::resource_sink &resource_sink,
Expand All @@ -84,7 +84,7 @@ void map_editor_component::set_state_text(
*renderer, resource_cache.body_font.get(), new_text, resource_sink);
}

component_interface &map_editor_component::update(
component_interface &entity_editor::update(
lmgl::irenderer *renderer,
lmgl::resource_sink &resource_sink,
lmtk::resource_cache const &resource_cache,
Expand All @@ -97,7 +97,7 @@ component_interface &map_editor_component::update(
return *this;
}

bool map_editor_component::add_to_frame(lmgl::iframe *frame)
bool entity_editor::add_to_frame(lmgl::iframe *frame)
{
visual_view->add_to_frame(
*controller.map, frame, lmgl::viewport{position, size});
Expand All @@ -107,7 +107,7 @@ bool map_editor_component::add_to_frame(lmgl::iframe *frame)
}

lmtk::widget_interface &
map_editor_component::move_resources(lmgl::resource_sink &resource_sink)
entity_editor::move_resources(lmgl::resource_sink &resource_sink)
{
resource_sink.add(
selection_stencil_material,
Expand All @@ -123,8 +123,7 @@ lmtk::widget_interface &
return *this;
}

map_editor_component &
map_editor_component::set_rect(lm::point2i pos, lm::size2i size)
entity_editor &entity_editor::set_rect(lm::point2i pos, lm::size2i size)
{
position = pos;
this->size = size;
Expand All @@ -133,16 +132,15 @@ map_editor_component &
return *this;
}

lm::size2i map_editor_component::get_size() { return size; }
lm::size2i entity_editor::get_size() { return size; }

lm::point2i map_editor_component::get_position() { return position; }
lm::point2i entity_editor::get_position() { return position; }

bool map_editor_component::handle(const lmtk::input_event &input_event)
bool entity_editor::handle(const lmtk::input_event &input_event)
{
return controller.handle(input_event);
}
std::vector<command_description>
map_editor_component::get_command_descriptions()
std::vector<command_description> entity_editor::get_command_descriptions()
{
return controller.get_command_descriptions();
}
Expand Down
Loading