Skip to content

Commit

Permalink
Engine - ECS: removed InsertChildNode()
Browse files Browse the repository at this point in the history
  • Loading branch information
friflo committed Jul 18, 2024
1 parent 0439023 commit 171171a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Engine/src/ECS/Entity/Store/NodeTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ internal void InsertChild (int parentId, int childId, int childIndex)
curIndex = RemoveChildNode(curParentId, childId);
OnChildNodeRemove(curParentId, childId, curIndex);

InsertChildNode(ref parent, childId, childIndex);
parent.childIds.InsertAt(childIndex, childId, extension.hierarchyHeap);
OnChildNodeAdd (parentId, childId, childIndex);
return;
}
InsertNode:
// --- insert entity with given id as child to its parent
// childNode.parentId = parentId;
extension.parentMap[childId] = parentId;
InsertChildNode(ref parent, childId, childIndex);
parent.childIds.InsertAt(childIndex, childId, extension.hierarchyHeap);
SetTreeFlags(localNodes, childId, nodes[parentId].flags & NodeFlags.TreeNode);

OnChildNodeAdd(parentId, childId, childIndex);
Expand Down Expand Up @@ -212,11 +212,6 @@ private int RemoveChildNode (int parentId, int childId)
throw new InvalidOperationException($"unexpected state: child id not found. parent id: {parentId}, child id: {childId}");
}

private void InsertChildNode (ref TreeNode parent, int childId, int childIndex)
{
parent.childIds.InsertAt(childIndex, childId, extension.hierarchyHeap);
}

/*
private static void EnsureChildIdsCapacity(ref TreeNode parent, int length)
{
Expand Down Expand Up @@ -369,10 +364,11 @@ private void ChildIds_RemoveRange(ref TreeNode node, int first, int last, int pa
// --- 3.3
private void ChildIds_InsertRange(ref TreeNode node, int first, int last, ReadOnlySpan<int> newIds, int parentId)
{
var heap = extension.hierarchyHeap;
for (int index = first; index <= last; index++)
{
var addedId = newIds[index];
node.childIds.InsertAt(index, addedId, extension.hierarchyHeap);
node.childIds.InsertAt(index, addedId, heap);
OnChildNodeAdd(parentId, addedId, index);
}
}
Expand Down

0 comments on commit 171171a

Please sign in to comment.