Skip to content

Commit 08955df

Browse files
committed
update to entt v3.9.0 and add clone functionality
1 parent 4653998 commit 08955df

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ editor.registerComponent<Velocity>("Velocity");
5151
```
5252
5353
# Dependencies
54-
The editor uses EnTTv3.6.0 interface and ImGui. (tested with ImGui 1.68, 1.72b, 1.75, 1.78, 1.82)
54+
The editor uses EnTTv3.9.0 and ImGui. (tested with ImGui 1.68, 1.72b, 1.75, 1.78, 1.82, 1.85)
5555
To use it with EnTTv3.0.0, use the dedicated branch.
5656
For specific EnTT version check the tags, if a new EnTT version does not require a update, I won't make a new Release.
57-
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 .
57+
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.
5858

imgui_entt_entity_editor.hpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,19 @@ class EntityEditor {
129129
if (registry.valid(e)) {
130130
ImGui::SameLine();
131131

132-
// clone would go here
133-
//if (ImGui::Button("Clone")) {
134-
//auto old_e = e;
135-
//e = registry.create();
136-
//}
132+
if (ImGui::Button("Clone")) {
133+
auto old_e = e;
134+
e = registry.create();
135+
136+
// create a copy of an entity component by component
137+
for (auto &&curr: registry.storage()) {
138+
if (auto &storage = curr.second; storage.contains(old_e)) {
139+
// TODO: do something with the return value. returns false on failure.
140+
storage.emplace(e, storage.get(old_e));
141+
}
142+
}
143+
}
144+
ImGui::SameLine();
137145

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

230238
if (comp_list.empty()) {
231239
ImGui::Text("Orphans:");
232-
registry.orphans([&registry](auto e){
233-
MM_IEEE_ENTITY_WIDGET(e, registry, false);
240+
registry.each([&registry](auto e){
241+
if (registry.orphan(e)) {
242+
MM_IEEE_ENTITY_WIDGET(e, registry, false);
243+
}
234244
});
235245
} else {
236246
auto view = registry.runtime_view(comp_list.begin(), comp_list.end());

0 commit comments

Comments
 (0)