Skip to content

Commit

Permalink
update to entt v3.9.0 and add clone functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Green-Sky committed Dec 21, 2021
1 parent 4653998 commit 08955df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ editor.registerComponent<Velocity>("Velocity");
```
# Dependencies
The editor uses EnTTv3.6.0 interface and ImGui. (tested with ImGui 1.68, 1.72b, 1.75, 1.78, 1.82)
The editor uses EnTTv3.9.0 and ImGui. (tested with ImGui 1.68, 1.72b, 1.75, 1.78, 1.82, 1.85)
To use it with EnTTv3.0.0, use the dedicated branch.
For specific EnTT version check the tags, if a new EnTT version does not require a update, I won't make a new Release.
Releases available for EnTT 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.3.x, 3.4.0, 3.6.0 .
Releases available for EnTT 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.3.x, 3.4.0, 3.6.0-3.8.1, 3.9.0.
24 changes: 17 additions & 7 deletions imgui_entt_entity_editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,19 @@ class EntityEditor {
if (registry.valid(e)) {
ImGui::SameLine();

// clone would go here
//if (ImGui::Button("Clone")) {
//auto old_e = e;
//e = registry.create();
//}
if (ImGui::Button("Clone")) {
auto old_e = e;
e = registry.create();

// create a copy of an entity component by component
for (auto &&curr: registry.storage()) {
if (auto &storage = curr.second; storage.contains(old_e)) {
// TODO: do something with the return value. returns false on failure.
storage.emplace(e, storage.get(old_e));
}
}
}
ImGui::SameLine();

ImGui::Dummy({10, 0}); // space destroy a bit, to not accidentally click it
ImGui::SameLine();
Expand Down Expand Up @@ -229,8 +237,10 @@ class EntityEditor {

if (comp_list.empty()) {
ImGui::Text("Orphans:");
registry.orphans([&registry](auto e){
MM_IEEE_ENTITY_WIDGET(e, registry, false);
registry.each([&registry](auto e){
if (registry.orphan(e)) {
MM_IEEE_ENTITY_WIDGET(e, registry, false);
}
});
} else {
auto view = registry.runtime_view(comp_list.begin(), comp_list.end());
Expand Down

0 comments on commit 08955df

Please sign in to comment.