26auto restore_root_from_serialized_subtree(entt::registry& registry, std::string_view blob) -> entt::handle
32 entt::entity stub = registry.create();
33 entt::handle
handle(registry, stub);
38 catch(
const std::exception&)
40 registry.destroy(stub);
45 if(
handle.entity() != stub)
47 registry.destroy(stub);
51 registry.destroy(stub);
55void collect_subtree_uuid_preorder(entt::const_handle obj, std::vector<hpp::uuid>& out)
61 auto& trans_comp = obj.get<transform_component>();
62 auto* id_comp = obj.try_get<id_component>();
63 if(!id_comp || id_comp->id.is_nil())
67 out.push_back(id_comp->id);
68 for(
auto child : trans_comp.get_children())
70 collect_subtree_uuid_preorder(child, out);
74void apply_subtree_uuid_preorder(entt::handle obj,
const std::vector<hpp::uuid>& uids,
size_t& next)
76 if(!obj || next >= uids.size())
80 auto& trans_comp = obj.get<transform_component>();
81 auto& id_comp = obj.get_or_emplace<id_component>();
82 id_comp.id = uids[
next++];
83 for(
auto child : trans_comp.get_children())
85 apply_subtree_uuid_preorder(child, uids, next);
91 : factory(
std::move(factory_fn))
93 name =
"Create Entities";
98 name =
"Create Entity";
99 auto single = std::move(factory_fn);
129 for(
auto root : roots)
136 if(!id_comp || id_comp->id.is_nil())
144 auto parent = tr->get_parent();
152 collect_subtree_uuid_preorder(
static_cast<entt::const_handle
>(root),
subtree_uuids.back());
159 std::stringstream ss;
180 auto restored = restore_root_from_serialized_subtree(registry,
serialized_roots[i]);
188 apply_subtree_uuid_preorder(restored,
subtree_uuids[i], next_uid);
191 if(!parent_uh.registry || parent_uh.uuid.is_nil())
200 auto desired_parent = parent_uh.resolve();
206 if(!current_parent || current_parent != desired_parent)
208 tr->set_parent(desired_parent,
false);
236 auto parent = tr->get_parent();
250 collect_subtree_uuid_preorder(
static_cast<entt::const_handle
>(target),
subtree_uuids[i]);
254 std::stringstream ss;
275 return static_cast<bool>(
factory);
288 if(!root_uh.registry || root_uh.uuid.is_nil())
305 name =
"Delete Entities";
316 for(
auto root : roots)
323 if(!id_comp || id_comp->id.is_nil())
330 auto parent = tr->get_parent();
337 collect_subtree_uuid_preorder(
static_cast<entt::const_handle
>(root),
subtree_uuids.back());
343 std::stringstream ss;
361 auto target = root_uh.resolve();
381 auto restored = restore_root_from_serialized_subtree(registry,
serialized_roots[i]);
389 apply_subtree_uuid_preorder(restored,
subtree_uuids[i], next_uid);
392 if(!parent_uh.registry || parent_uh.uuid.is_nil())
401 auto desired_parent = parent_uh.resolve();
407 if(!current_parent || current_parent != desired_parent)
409 tr->set_parent(desired_parent,
false);
427 if(!root_uh.registry || root_uh.uuid.is_nil())
448 :
entity(
entt::make_uhandle(ent)), component_type(ctype)
486 :
entity(
entt::make_uhandle(ent)), component_type(ctype)
529 :
entity(
entt::make_uhandle(ent)), old_active(old_active), new_active(new_active)
582 :
entity(
entt::make_uhandle(ent)), old_name(old_name), new_name(new_name)
635 :
entity(
entt::make_uhandle(ent)), old_tag(old_tag), new_tag(new_tag)
688 :
entity(
entt::make_uhandle(ent)), old_materials(old_materials)
691 name =
"Set Materials";
699 auto model_copy = model_comp.
get_model();
700 for(
size_t i = 0; i <
new_materials.size() && i < model_copy.get_materials().size(); ++i)
704 model_comp.set_model(model_copy);
714 auto model_copy = model_comp.
get_model();
715 for(
size_t i = 0; i <
old_materials.size() && i < model_copy.get_materials().size(); ++i)
719 model_comp.set_model(model_copy);
748 draw_in_inspector_impl(ctx, old_materials_any, new_material_any, {});
757 name =
"Set Text Bounds";
806 entt::meta_any old_area_any =
old_area;
807 entt::meta_any new_area_any =
new_area;
808 draw_in_inspector_impl(ctx, old_area_any, new_area_any, {});
813 :
entity(
entt::make_uhandle(ent)), old_size(old_size), new_size(new_size)
815 name =
"Set UI Document Component Bounds";
864 entt::meta_any old_size_any =
old_size;
865 entt::meta_any new_size_any =
new_size;
866 draw_in_inspector_impl(ctx, old_size_any, new_size_any, {});
871 :
entity(
entt::make_uhandle(ent)), script_type_name(type_name)
884 if(script_type.valid())
905 if(script_type.valid())
910 script_comp->remove_script_component(script_type);
911 script_comp->process_pending_deletions();
934 :
entity(
entt::make_uhandle(ent)), script_type_name(type_name), script_index(
index)
939 name +=
" [" + std::to_string(
index) +
"]";
951 if(script_type.valid())
956 const auto& comps = script_comp->get_script_components();
964 if (script_obj.pinned)
966 auto obj = script_obj.pinned->get_object();
977 script_comp->process_pending_deletions();
985 auto script_obj = script_comp->get_script_component(script_type);
986 if (script_obj.pinned)
996 script_comp->process_pending_deletions();
1012 if(script_type.valid())
1024 script_comp.add_script_component(restored_obj);
1030 script_comp.add_script_component(script_type);
1036 script_comp.add_script_component(script_type);
Class that contains core data for meshes.
auto get_model() const -> const model &
Gets the model.
Class that contains core data for audio listeners. There can only be one instance of it per scene.
auto add_script_component(const dotnet::type &type) -> script_object
auto make_uhandle(entt::handle handle) -> uhandle
auto get_pretty_name(const meta_type &t) -> std::string
Hash specialization for batch_key to enable use in std::unordered_map.
auto load_from_stream(std::istream &stream, entt::handle e, script_component::script_object &obj) -> bool
void load_from_view(std::string_view view, entt::handle &obj)
auto save_to_stream(std::ostream &stream, entt::const_handle e, const script_component::script_object &obj) -> bool
utfchar32_t next(octet_iterator &it, octet_iterator end)
Thread-safe handle to an asset.
auto resolve() const -> entt::handle
auto is_mergeable(const editing_action_t &previous) const -> bool override
void undo_action() override
create_entities_action_t(std::function< std::vector< entt::handle >()> factory)
Multi-root constructor. The factory returns the set of newly-created roots.
std::function< std::vector< entt::handle >()> factory
bool captured
True once the initial factory-driven creation has run and the snapshot is populated.
void do_action() override
auto is_valid() const -> bool override
std::vector< entt::uhandle > parent_entities
Parent of each root (may hold a nil uuid for root-level entities). Refreshed on every undo.
std::vector< std::string > serialized_roots
Serialized bytes of each root, captured after the first factory execution.
std::vector< entt::uhandle > root_entities
Handles of each created root; the registry pointer persists even after the entity is destroyed.
std::vector< std::vector< hpp::uuid > > subtree_uuids
Preorder UUIDs per root subtree (same ordering as save_to_stream / flatten_hierarchy).
void do_action() override
delete_entities_action_t(std::vector< entt::handle > entities)
std::vector< std::vector< hpp::uuid > > subtree_uuids
Preorder UUIDs per root subtree (same order as save_to_stream / flatten_hierarchy).
std::vector< entt::uhandle > root_entities
std::vector< entt::uhandle > parent_entities
void undo_action() override
auto is_valid() const -> bool override
auto is_mergeable(const editing_action_t &previous) const -> bool override
std::vector< std::string > serialized_roots
static auto context() -> rtti::context &
void draw_in_inspector(rtti::context &ctx) override
void do_action() override
entt::meta_type component_type
void undo_action() override
auto is_valid() const -> bool override
entity_add_component_action_t(entt::handle ent, const entt::meta_type &ctype)
auto is_mergeable(const editing_action_t &previous) const -> bool override
void draw_in_inspector(rtti::context &ctx) override
void undo_action() override
auto is_mergeable(const editing_action_t &previous) const -> bool override
std::string script_type_name
auto is_valid() const -> bool override
entity_add_script_component_action_t(entt::handle ent, const std::string &type_name)
void do_action() override
auto is_mergeable(const editing_action_t &previous) const -> bool override
void do_action() override
void undo_action() override
auto is_valid() const -> bool override
entity_remove_component_action_t(entt::handle ent, const entt::meta_type &ctype)
entt::meta_type component_type
void draw_in_inspector(rtti::context &ctx) override
entity_remove_script_component_action_t(entt::handle ent, const std::string &type_name, int index=-1)
auto is_mergeable(const editing_action_t &previous) const -> bool override
void undo_action() override
std::stringstream removed_script_object_data
void do_action() override
void draw_in_inspector(rtti::context &ctx) override
auto is_valid() const -> bool override
std::string script_type_name
void draw_in_inspector(rtti::context &ctx) override
entity_set_active_action_t(entt::handle ent, bool old_active, bool new_active)
void merge_with(const editing_action_t &previous) override
void undo_action() override
auto is_valid() const -> bool override
auto is_mergeable(const editing_action_t &previous) const -> bool override
void do_action() override
std::vector< asset_handle< material > > new_materials
auto is_valid() const -> bool override
std::vector< asset_handle< material > > old_materials
void do_action() override
void undo_action() override
entity_set_materials_action_t(entt::handle ent, const std::vector< asset_handle< material > > &old_materials, const asset_handle< material > &new_material)
void merge_with(const editing_action_t &previous) override
void draw_in_inspector(rtti::context &ctx) override
auto is_mergeable(const editing_action_t &previous) const -> bool override
entity_set_name_action_t(entt::handle ent, const std::string &old_name, const std::string &new_name)
auto is_mergeable(const editing_action_t &previous) const -> bool override
void draw_in_inspector(rtti::context &ctx) override
auto is_valid() const -> bool override
void undo_action() override
void do_action() override
void merge_with(const editing_action_t &previous) override
auto is_mergeable(const editing_action_t &previous) const -> bool override
void merge_with(const editing_action_t &previous) override
void do_action() override
entity_set_tag_action_t(entt::handle ent, const std::string &old_tag, const std::string &new_tag)
auto is_valid() const -> bool override
void draw_in_inspector(rtti::context &ctx) override
void undo_action() override
auto is_mergeable(const editing_action_t &previous) const -> bool override
void undo_action() override
auto is_valid() const -> bool override
entity_set_text_bounds_action_t(entt::handle ent, const fsize_t &old_area, const fsize_t &new_area)
void do_action() override
void merge_with(const editing_action_t &previous) override
void draw_in_inspector(rtti::context &ctx) override
void undo_action() override
auto is_valid() const -> bool override
entity_set_ui_document_component_bounds_action_t(entt::handle ent, const usize32_t &old_size, const usize32_t &new_size)
void do_action() override
void draw_in_inspector(rtti::context &ctx) override
auto is_mergeable(const editing_action_t &previous) const -> bool override
void merge_with(const editing_action_t &previous) override
Component that provides a unique identifier (UUID) for an entity.
static void mark_material_as_changed(entt::handle entity)
Marks material as changed in prefab override system.
static void mark_text_area_as_changed(entt::handle entity)
Marks text area as changed in prefab override system.
static void mark_entity_as_removed(entt::handle entity)
Marks an entity as removed from the prefab instance.
static void mark_ui_document_size_as_changed(entt::handle entity)
static void mark_property_as_changed(entt::handle entity, const entt::meta_type &component_type, const std::string &property_path, const std::string &property_pretty_path={})
Marks a specific property as changed using component type.
static void mark_active_as_changed(entt::handle entity)
Marks entity active state as changed in prefab override system.
auto get_type_by_fullname(const std::string &fullname) const -> dotnet::type
Component that provides a tag (name or label) for an entity.
Component that holds a reference to a UI document for RmlUi rendering.