Hierarchy components optimizations

Signed-off-by: AMZN-Olex <5432499+AMZN-Olex@users.noreply.github.com>
This commit is contained in:
AMZN-Olex
2021-10-05 08:31:23 -04:00
parent 52d3e4c601
commit d05d5d1e97
5 changed files with 103 additions and 105 deletions
@@ -64,10 +64,8 @@ namespace Multiplayer
private:
AZ::ChildChangedEvent::Handler m_childChangedHandler;
AZ::ParentChangedEvent::Handler m_parentChangedHandler;
void OnChildChanged(AZ::ChildChangeType type, AZ::EntityId child);
void OnParentChanged(AZ::EntityId oldParent, AZ::EntityId parent);
//! Points to the top level root.
AZ::Entity* m_rootEntity = nullptr;
@@ -78,22 +78,12 @@ namespace Multiplayer
//! Rebuilds hierarchy starting from this root component's entity.
void RebuildHierarchy();
//! @param underEntity Walk the child entities that belong to @underEntity and consider adding them to the hierarchy
//! @param currentEntityCount The total number of entities in the hierarchy prior to calling this method,
//! used to avoid adding too many entities to the hierarchy while walking recursively the relevant entities.
//! @currentEntityCount will be modified to reflect the total entity count upon completion of this method.
//! @returns false if an attempt was made to go beyond the maximum supported hierarchy size, true otherwise
bool RecursiveAttachHierarchicalEntities(AZ::EntityId underEntity, uint32_t& currentEntityCount);
//! @param entity Add the child entity and any of its relevant children to the hierarchy
//! @param currentEntityCount The total number of entities in the hierarchy prior to calling this method,
//! used to avoid adding too many entities to the hierarchy while walking recursively the relevant entities.
//! @currentEntityCount will be modified to reflect the total entity count upon completion of this method.
//! @returns false if an attempt was made to go beyond the maximum supported hierarchy size, true otherwise
bool RecursiveAttachHierarchicalChild(AZ::EntityId entity, uint32_t& currentEntityCount);
//! @param underEntity Walk the child entities that belong to @underEntity and consider adding them to the hierarchy.
//! Builds the hierarchy using breadth-first iterative method.
void InternalBuildHierarchyList(AZ::Entity* underEntity);
void SetRootForEntity(AZ::Entity* root, const AZ::Entity* childEntity);
//! Set to false when deactivating or otherwise not to be included in hierarchy considerations.
bool m_isHierarchyEnabled = true;