void CollisionDetector::addCollisionSkeletonNode(dynamics::BodyNode* _bodyNode, bool _isRecursive) { assert(_bodyNode != NULL && "Invalid body node."); // If this collision detector already has collision node for _bodyNode, then // we do nothing. if (getCollisionNode(_bodyNode) != NULL) { std::cout << "The collision detector already has a collision node for " << "body node [" << _bodyNode->getName() << "]." << std::endl; return; } // Create collision node and set index CollisionNode* collNode = createCollisionNode(_bodyNode); collNode->setIndex(mCollisionNodes.size()); // Add the collision node to collision node list mCollisionNodes.push_back(collNode); // Add the collision node to map (BodyNode -> CollisionNode) mBodyCollisionMap[_bodyNode] = collNode; // Add collidable pairs for the collision node mCollidablePairs.push_back( std::vector<bool>(mCollisionNodes.size() - 1, true)); if (_isRecursive) { for (int i = 0; i < _bodyNode->getNumChildBodyNodes(); i++) addCollisionSkeletonNode(_bodyNode->getChildBodyNode(i), true); } }
void CollisionDetector::addCollisionSkeletonNode(kinematics::BodyNode* _bodyNode, bool _recursive) { CollisionNode* collNode = createCollisionNode(_bodyNode); collNode->setIndex(mCollisionNodes.size()); mCollisionNodes.push_back(collNode); mBodyCollisionMap[_bodyNode] = collNode; mCollidablePairs.push_back(vector<bool>(mCollisionNodes.size() - 1, true)); if(_recursive) { for (int i = 0; i < _bodyNode->getNumChildJoints(); i++) addCollisionSkeletonNode(_bodyNode->getChildNode(i), true); } }