18#include <lagrange/utils/warnoff.h>
19#include <entt/entt.hpp>
20#include <lagrange/utils/warnon.h>
26using Registry = entt::registry;
27using Entity = entt::entity;
28inline constexpr entt::null_t NullEntity{};
30using System = std::function<void(Registry& registry)>;
31using StringID = entt::id_type;
36enum class IndexingMode { VERTEX, EDGE, FACE, CORNER, INDEXED };
37enum class PrimitiveType { POINTS, LINES, TRIANGLES };
38enum class SelectionBehavior { SET, ADD, ERASE };
40using namespace entt::literals;
42inline StringID string_id(
const std::string& str)
44 return entt::hashed_string(str.c_str());
46inline StringID string_id(
const char* str)
48 return entt::hashed_string(str);
52void component_clone(Registry* w, Entity src, Entity dst)
54 w->emplace_or_replace<T>(dst, w->get<T>(src));
58void component_move(Registry* w, Entity src, Entity dst)
60 w->emplace_or_replace<T>(dst, std::move(w->get<T>(src)));
65void component_add_default(Registry* w, Entity dst)
67 w->emplace_or_replace<T>(dst);
73 static const char* id() {
return "PayloadEntity"; }
81 static const char* id() {
return "PayloadComponent"; }
82 entt::id_type component_hash;
87template <
typename Component>
88void register_component(
const std::string& display_name = entt::type_id<Component>().name().data())
90 using namespace entt::literals;
91 entt::meta<Component>()
92 .template func<&component_clone<Component>>(
"component_clone"_hs)
93 .
template func<&component_move<Component>>(
"component_move"_hs)
94 .template func<&component_add_default<Component>>(
"component_add_default"_hs)
95 .prop(
"display_name"_hs, display_name);
98template <
typename Component, auto Func>
99void register_component_widget()
101 using namespace entt::literals;
102 entt::meta<Component>().template func<Func>(
"show_widget"_hs);
105template <
typename Component>
106void register_component_widget(
const std::function<
void(Registry*, Entity)>& fn)
108 using namespace entt::literals;
109 entt::meta<Component>().prop(
"show_widget_lambda"_hs, fn);
112inline void show_widget(Registry& w, Entity e,
const entt::meta_type& meta_type)
114 using namespace entt::literals;
115 auto fn = meta_type.func(
"show_widget"_hs);
117 fn.invoke({}, &w, e);
119 auto lambda = meta_type.prop(
"show_widget_lambda"_hs);
121 lambda.value().cast<std::function<void(Registry*, Entity)>>()(&w, e);
126template <
typename Resolvable>
127void show_widget(Registry& r, Entity e,
const Resolvable& resolvable)
129 show_widget(r, e, entt::resolve(resolvable));
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:23
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Payload for sending components through UI.
Definition: Entity.h:80
Payload for sending entities through UI.
Definition: Entity.h:72