Minor - Améliore la gestion des entités ImGui - V14.9.0

Optimizes entity management in ImGui by deferring updates to the entity list until necessary.

Changes include:
- Sets the entity list as dirty upon adding or deleting entities to ensure the list is only updated when needed
- Changes the type of entity ID stored in CachedEntity
- Adjusts ImGui window size
This commit is contained in:
2025-10-24 17:47:54 +02:00
parent c67a805bd7
commit 2e33adf4a9
5 changed files with 13 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
[Window][DockSpace]
Pos=0,0
Size=32,32
Size=1536,793
Collapsed=0
[Window][Debug##Default]
@@ -57,7 +57,7 @@ Collapsed=0
DockId=0x00000002,0
[Docking][Data]
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=32,22 Split=X
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1536,774 Split=X
DockNode ID=0x00000001 Parent=0xCCBD8CF7 SizeRef=1350,842 Split=X
DockNode ID=0x00000005 Parent=0x00000001 SizeRef=1265,842 Split=Y
DockNode ID=0x00000003 Parent=0x00000005 SizeRef=1584,609 Split=X

View File

@@ -42,7 +42,7 @@ struct ComponentEntry {
struct CachedEntity
{
std::string name;
ecs::EntityID id;
int id;
};
class imguiManager

View File

@@ -502,6 +502,8 @@ void imguiManager::WidgetAddObject()
// Remplacer les antislashs par des slashs
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
app_->add_kobject(relativePath);
// set entities list as dirty
entityListDirty = true;
}
}
@@ -596,13 +598,15 @@ void imguiManager::WidgetObjectWindow()
// Remplacer les antislashs par des slashs
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
app_->add_kobject(relativePath);
// set list as dirty since new entity has been added to the scene
entityListDirty = true;
}
}
}
S_LINE
TEXT_V("Number of cubes: %d", entity_manager_->GetEntityCount())
SEP
UpdateCachedEntitiesIfNeeded();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(4,2));
@@ -660,6 +664,7 @@ void imguiManager::WidgetInspectorWindow()
entity_manager_->DestroyEntity(m_selected_entity_id);
m_selected_entity_id = -1;
show_inspector_window_ = false;
entityListDirty = true;
}
S_LINE
@@ -1223,9 +1228,10 @@ void imguiManager::UpdateCachedEntitiesIfNeeded() {
auto identity = entity->GetComponent<ecs::IdentityComponent>();
if (identity) {
std::string name = identity->GetName();
auto id = identity->GetId();
if (name.empty())
name = "Entity " + std::to_string(identity->GetId());
cachedEntities_.push_back({ name, identity->GetId() });
cachedEntities_.push_back({name,id});
}
}
entityListDirty = false;

BIN
x64/Debug/config.txt (Stored with Git LFS)

Binary file not shown.

BIN
x64/Release/config.txt (Stored with Git LFS)

Binary file not shown.