void BoundingSphere::GrowToContain( BoundingVolume * pBound ) { switch ( pBound->GetBoundType() ) { case Bounding_Box: { Vector3f akVector[8]; ( (BoundingBox *) pBound )->GetBox().ComputeVertices( akVector ); m_kSphere = MergeSpheres( m_kSphere, ContSphereOfAABB( 8, akVector ) ); break; } case Bounding_Sphere: { m_kSphere = MergeSpheres( m_kSphere,( (BoundingSphere *) pBound )->GetSphere() ); break; } default: break; } }
AglBoundingSphere CompoundBody::GetBoundingSphere() { if (mChildren.size() > 0) { AglBoundingSphere bs = mChildren[0]->GetBoundingSphere(); for (unsigned int i = 1; i < mChildren.size(); i++) { bs = MergeSpheres(bs, mChildren[i]->GetBoundingSphere()); } return bs; } else { return AglBoundingSphere(GetWorld().GetTranslation(), 0); } }
void BoundCreation::MergeBound(const BoundingVolume * bound_a, const BoundingVolume * bound_b, BoundingVolume * rtn_bound) { switch (bound_a->GetType()) { case BoundingVolume::BV_AABB: MergeAABBs(static_cast<const AABB*>(bound_a), static_cast<const AABB*>(bound_b), static_cast<AABB*>(rtn_bound)); break; case BoundingVolume::BV_SPHERE: MergeSpheres(static_cast<const BoundingSphere*>(bound_a), static_cast<const BoundingSphere*>(bound_b), static_cast<BoundingSphere*>(rtn_bound)); break; case BoundingVolume::BV_OBB: MergeOBBs(static_cast<const OBB*>(bound_a), static_cast<const OBB*>(bound_b), static_cast<OBB*>(rtn_bound)); break; default: throw 1; //Type not recognized. }; }