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:
@@ -1,6 +1,6 @@
|
|||||||
[Window][DockSpace]
|
[Window][DockSpace]
|
||||||
Pos=0,0
|
Pos=0,0
|
||||||
Size=32,32
|
Size=1536,793
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
@@ -57,7 +57,7 @@ Collapsed=0
|
|||||||
DockId=0x00000002,0
|
DockId=0x00000002,0
|
||||||
|
|
||||||
[Docking][Data]
|
[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=0x00000001 Parent=0xCCBD8CF7 SizeRef=1350,842 Split=X
|
||||||
DockNode ID=0x00000005 Parent=0x00000001 SizeRef=1265,842 Split=Y
|
DockNode ID=0x00000005 Parent=0x00000001 SizeRef=1265,842 Split=Y
|
||||||
DockNode ID=0x00000003 Parent=0x00000005 SizeRef=1584,609 Split=X
|
DockNode ID=0x00000003 Parent=0x00000005 SizeRef=1584,609 Split=X
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ struct ComponentEntry {
|
|||||||
struct CachedEntity
|
struct CachedEntity
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
ecs::EntityID id;
|
int id;
|
||||||
};
|
};
|
||||||
|
|
||||||
class imguiManager
|
class imguiManager
|
||||||
|
|||||||
@@ -502,6 +502,8 @@ void imguiManager::WidgetAddObject()
|
|||||||
// Remplacer les antislashs par des slashs
|
// Remplacer les antislashs par des slashs
|
||||||
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
|
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
|
||||||
app_->add_kobject(relativePath);
|
app_->add_kobject(relativePath);
|
||||||
|
// set entities list as dirty
|
||||||
|
entityListDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -596,13 +598,15 @@ void imguiManager::WidgetObjectWindow()
|
|||||||
// Remplacer les antislashs par des slashs
|
// Remplacer les antislashs par des slashs
|
||||||
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
|
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
|
||||||
app_->add_kobject(relativePath);
|
app_->add_kobject(relativePath);
|
||||||
|
// set list as dirty since new entity has been added to the scene
|
||||||
|
entityListDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
S_LINE
|
S_LINE
|
||||||
TEXT_V("Number of cubes: %d", entity_manager_->GetEntityCount())
|
TEXT_V("Number of cubes: %d", entity_manager_->GetEntityCount())
|
||||||
SEP
|
SEP
|
||||||
|
|
||||||
UpdateCachedEntitiesIfNeeded();
|
UpdateCachedEntitiesIfNeeded();
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(4,2));
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(4,2));
|
||||||
@@ -660,6 +664,7 @@ void imguiManager::WidgetInspectorWindow()
|
|||||||
entity_manager_->DestroyEntity(m_selected_entity_id);
|
entity_manager_->DestroyEntity(m_selected_entity_id);
|
||||||
m_selected_entity_id = -1;
|
m_selected_entity_id = -1;
|
||||||
show_inspector_window_ = false;
|
show_inspector_window_ = false;
|
||||||
|
entityListDirty = true;
|
||||||
}
|
}
|
||||||
S_LINE
|
S_LINE
|
||||||
|
|
||||||
@@ -1223,9 +1228,10 @@ void imguiManager::UpdateCachedEntitiesIfNeeded() {
|
|||||||
auto identity = entity->GetComponent<ecs::IdentityComponent>();
|
auto identity = entity->GetComponent<ecs::IdentityComponent>();
|
||||||
if (identity) {
|
if (identity) {
|
||||||
std::string name = identity->GetName();
|
std::string name = identity->GetName();
|
||||||
|
auto id = identity->GetId();
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
name = "Entity " + std::to_string(identity->GetId());
|
name = "Entity " + std::to_string(identity->GetId());
|
||||||
cachedEntities_.push_back({ name, identity->GetId() });
|
cachedEntities_.push_back({name,id});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entityListDirty = false;
|
entityListDirty = false;
|
||||||
|
|||||||
BIN
x64/Debug/config.txt
(Stored with Git LFS)
BIN
x64/Debug/config.txt
(Stored with Git LFS)
Binary file not shown.
BIN
x64/Release/config.txt
(Stored with Git LFS)
BIN
x64/Release/config.txt
(Stored with Git LFS)
Binary file not shown.
Reference in New Issue
Block a user