AABB2 SoccerBase::GetAgentBoundingRect(const Leaf& base) { AABB2 boundingRect; boost::shared_ptr<Space> parent = base.FindParentSupportingClass<Space>().lock(); if (!parent) { base.GetLog()->Error() << "(GetAgentBoundingBox) ERROR: can't get parent node.\n"; return boundingRect; } /* We can't simply use the GetWorldBoundingBox of the space node, becuase * (at least currently) it'll return a wrong answer. Currently, the space * object is always at (0,0,0) which is encapsulated in the result of it's * GetWorldBoundingBox method call. */ Leaf::TLeafList baseNodes; parent->ListChildrenSupportingClass<Collider>(baseNodes,true); if (baseNodes.empty()) { base.GetLog()->Error() << "(GetAgentBoundingBox) ERROR: space object doesn't have any" << " children of type BaseNode.\n"; } for (Leaf::TLeafList::iterator i = baseNodes.begin(); i!= baseNodes.end(); ++i) { boost::shared_ptr<BaseNode> node = shared_static_cast<BaseNode>(*i); const AABB3 &box = node->GetWorldBoundingBox(); boundingRect.Encapsulate(box.minVec.x(), box.minVec.y()); boundingRect.Encapsulate(box.maxVec.x(), box.maxVec.y()); } return boundingRect; }