void computeBV<AABB>(const Convex& s, AABB& bv) { Vec3f R[3]; matMulMat(s.getRotation(), s.getLocalRotation(), R); Vec3f T = matMulVec(s.getRotation(), s.getLocalTranslation()) + s.getTranslation(); AABB bv_; for(int i = 0; i < s.num_points; ++i) { Vec3f new_p = matMulVec(R, s.points[i]) + T; bv_ += new_p; } bv = bv_; }
void computeBV<OBB>(const Convex& s, OBB& bv) { Vec3f R[3]; matMulMat(s.getRotation(), s.getLocalRotation(), R); Vec3f T = matMulVec(s.getRotation(), s.getLocalTranslation()) + s.getTranslation(); fit(s.points, s.num_points, bv); Vec3f axis[3]; axis[0] = matMulVec(R, bv.axis[0]); axis[1] = matMulVec(R, bv.axis[1]); axis[2] = matMulVec(R, bv.axis[2]); bv.axis[0] = axis[0]; bv.axis[1] = axis[1]; bv.axis[2] = axis[2]; bv.To = matMulVec(R, bv.To) + T; }