14#include <entt/entt.hpp>
22using Registry = entt::registry;
23using Entity = entt::entity;
24inline constexpr entt::null_t NullEntity{};
26using System = std::function<void(Registry& registry)>;
27using StringID = entt::id_type;
32enum class IndexingMode { VERTEX, EDGE, FACE, CORNER, INDEXED };
33enum class PrimitiveType { POINTS, LINES, TRIANGLES };
34enum class SelectionBehavior { SET, ADD, ERASE };
36using namespace entt::literals;
38inline StringID string_id(
const std::string& str)
40 return entt::hashed_string(str.c_str());
42inline StringID string_id(
const char* str)
44 return entt::hashed_string(str);
48void component_clone(Registry* w, Entity src, Entity dst)
50 w->emplace_or_replace<T>(dst, w->get<T>(src));
54void component_move(Registry* w, Entity src, Entity dst)
56 w->emplace_or_replace<T>(dst, std::move(w->get<T>(src)));
61void component_add_default(Registry* w, Entity dst)
63 w->emplace_or_replace<T>(dst);
69 static const char* id() {
return "PayloadEntity"; }
77 static const char* id() {
return "PayloadComponent"; }
78 entt::id_type component_hash;
83template <
typename Component>
84void register_component(
const std::string& display_name = entt::type_id<Component>().name().data())
86 using namespace entt::literals;
87 entt::meta<Component>()
88 .template func<&component_clone<Component>>(
"component_clone"_hs)
89 .
template func<&component_move<Component>>(
"component_move"_hs)
90 .template func<&component_add_default<Component>>(
"component_add_default"_hs)
91 .prop(
"display_name"_hs, display_name);
94template <
typename Component, auto Func>
95void register_component_widget()
97 using namespace entt::literals;
98 entt::meta<Component>().template func<Func>(
"show_widget"_hs);
101template <
typename Component>
102void register_component_widget(
const std::function<
void(Registry*, Entity)>& fn)
104 using namespace entt::literals;
105 entt::meta<Component>().prop(
"show_widget_lambda"_hs, fn);
108inline void show_widget(Registry& w, Entity e,
const entt::meta_type& meta_type)
110 using namespace entt::literals;
111 auto fn = meta_type.func(
"show_widget"_hs);
113 fn.invoke({}, &w, e);
115 auto lambda = meta_type.prop(
"show_widget_lambda"_hs);
117 lambda.value().cast<std::function<void(Registry*, Entity)>>()(&w, e);
122template <
typename Resolvable>
123void show_widget(Registry& r, Entity e,
const Resolvable& resolvable)
125 show_widget(r, e, entt::resolve(resolvable));
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Payload for sending components through UI.
Definition: Entity.h:76
Payload for sending entities through UI.
Definition: Entity.h:68