Skip to content

Commit

Permalink
性能优化:reset调用 CompositeTask::traverse耗时较高,对于没有运行过的节点,就不做处理了
Browse files Browse the repository at this point in the history
contributed by denniswu@tencent
  • Loading branch information
berniebwang committed Jul 4, 2022
1 parent c3ad935 commit e346051
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/behaviortree/behaviortree_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,11 @@ namespace behaviac {
}

void CompositeTask::traverse(bool childFirst, NodeHandler_t handler, Agent* pAgent, void* user_data) {
if (m_status == BT_INVALID)
{
return;
}

if (childFirst) {
for (BehaviorTasks_t::iterator it = this->m_children.begin();
it != this->m_children.end(); ++it) {
Expand Down Expand Up @@ -1187,7 +1192,12 @@ namespace behaviac {
}

void SingeChildTask::traverse(bool childFirst, NodeHandler_t handler, Agent* pAgent, void* user_data) {
if (childFirst) {
if (m_status == BT_INVALID)
{
return;
}

if (childFirst) {
if (this->m_root) {
this->m_root->traverse(childFirst, handler, pAgent, user_data);
}
Expand Down

0 comments on commit e346051

Please sign in to comment.