void CCastRay::TestModelSimple(CEntity *penModel, CModelObject &mo) { // get model's bounding box for current frame FLOATaabbox3D boxModel; mo.GetCurrentFrameBBox(boxModel); boxModel.StretchByVector(mo.mo_Stretch); // get center and radius of the bounding sphere in absolute space FLOAT fSphereRadius = boxModel.Size().Length()/2.0f; FLOAT3D vSphereCenter = boxModel.Center(); vSphereCenter*=penModel->en_mRotation; vSphereCenter+=penModel->en_plPlacement.pl_PositionVector; // if the ray doesn't hit the sphere FLOAT fSphereHitDistance; if (!RayHitsSphere(cr_vOrigin, cr_vTarget, vSphereCenter, fSphereRadius+cr_fTestR, fSphereHitDistance) ) { // ignore return; } // if the ray hits the sphere closer than closest found hit point yet if (fSphereHitDistance<cr_fHitDistance && fSphereHitDistance>0.0f) { // set the current entity as new hit target cr_fHitDistance=fSphereHitDistance; cr_penHit = penModel; cr_pbscBrushSector = NULL; cr_pbpoBrushPolygon = NULL; } }