Skip to content

Commit e346051

Browse files
author
berniebwang
committed
性能优化:reset调用 CompositeTask::traverse耗时较高,对于没有运行过的节点,就不做处理了
contributed by denniswu@tencent
1 parent c3ad935 commit e346051

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/behaviortree/behaviortree_task.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,11 @@ namespace behaviac {
11521152
}
11531153

11541154
void CompositeTask::traverse(bool childFirst, NodeHandler_t handler, Agent* pAgent, void* user_data) {
1155+
if (m_status == BT_INVALID)
1156+
{
1157+
return;
1158+
}
1159+
11551160
if (childFirst) {
11561161
for (BehaviorTasks_t::iterator it = this->m_children.begin();
11571162
it != this->m_children.end(); ++it) {
@@ -1187,7 +1192,12 @@ namespace behaviac {
11871192
}
11881193

11891194
void SingeChildTask::traverse(bool childFirst, NodeHandler_t handler, Agent* pAgent, void* user_data) {
1190-
if (childFirst) {
1195+
if (m_status == BT_INVALID)
1196+
{
1197+
return;
1198+
}
1199+
1200+
if (childFirst) {
11911201
if (this->m_root) {
11921202
this->m_root->traverse(childFirst, handler, pAgent, user_data);
11931203
}

0 commit comments

Comments
 (0)