Properly clear state

This commit is contained in:
2024-01-12 21:19:57 +01:00
parent 25a3229bb2
commit 4dd9b366e7
2 changed files with 9 additions and 4 deletions

View File

@@ -470,8 +470,13 @@ static inline BzBTExecReturn bzBTExecuteComposite(const BzBTNode *node, f32 dt,
bzBTClearNodeState(pChild, state, statePool);
pChild = pChild->next;
}
// For finished parallel composites clean up all children
if (finished && isParallel) {
execStateClear(&execReturn.state, statePool);
}
if (finished) {
// Finished composites mustn't have state
BZ_ASSERT(execReturn.state.first == NULL);
if (nodeState) releaseNodeState(nodeState, statePool);
return execReturn;
@@ -501,12 +506,11 @@ static inline BzBTExecReturn bzBTExecuteDecorator(const BzBTNode *node, f32 dt,
case BZ_BT_DECOR_DELAY:
nodeState = ensureValidNodeState(node, nodeState, statePool);
nodeState->as.delay.elapsed += dt;
execStatePushBack(&execReturn.state, nodeState);
if (nodeState->as.delay.elapsed < node->as.delay.ms) {
execStatePushBack(&execReturn.state, nodeState);
execReturn.status = BZ_BT_RUNNING;
return execReturn;
}
BZ_ASSERT(nodeState == execStatePopFront(&execReturn.state));
releaseNodeState(nodeState, statePool);
break;
default: