[ecs] Improve the behavior of Hierarchy_RemoveHierarchy

Its updates to the various indices were out, but this was missed due to
the tests being wrong. I wonder if I got interrupted while working on
them last and just assumed the removals were correct. This improves
sbar's behavior, but it's still wrong when pulling the armory view out
of the inventory. Very unsure what's going on, but the various indices
look ok, as do the view positions.
This commit is contained in:
Bill Currie 2022-11-06 02:38:59 +09:00
parent 01c67a345f
commit b91568d234
1 changed files with 8 additions and 9 deletions

View File

@ -332,19 +332,18 @@ hierarchy_remove_children (hierarchy_t *hierarchy, uint32_t index)
void
Hierarchy_RemoveHierarchy (hierarchy_t *hierarchy, uint32_t index)
{
uint32_t parentIndex = hierarchy->parentIndex[index];
uint32_t childIndex = hierarchy->childIndex[index];
uint32_t siblingIndex = nullent;
if (parentIndex != nullent) {
siblingIndex = hierarchy->childIndex[parentIndex];
}
uint32_t parentIndex = hierarchy->parentIndex[index];
hierarchy_remove_children (hierarchy, index);
hierarchy_close (hierarchy, index, 1);
if (siblingIndex != nullent) {
hierarchy_UpdateTransformIndices (hierarchy, index, -1);
hierarchy_UpdateChildIndices (hierarchy, siblingIndex, -1);
hierarchy_UpdateParentIndices (hierarchy, childIndex - 1, -1);
hierarchy_UpdateTransformIndices (hierarchy, index, -1);
if (parentIndex != nullent) {
hierarchy_UpdateChildIndices (hierarchy, parentIndex + 1, -1);
hierarchy->childCount[parentIndex] -= 1;
}
hierarchy_UpdateParentIndices (hierarchy, childIndex - 1, -1);
}
hierarchy_t *