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;
  }
}
// check if all of the corners of entity's bounding box are influenced by current select-on-render selection
void SelectEntityOnRender(CProjection3D &prProjection, CEntity &en)
{
  FLOATaabbox3D bbox;

  FLOATmatrix3D mOne = FLOATmatrix3D(0.0f);
  mOne.Diagonal(1.0f);
  FLOATmatrix3D *pmR;
  FLOAT3D vOffset;

  // if this entity is model
  if (en.en_RenderType==CEntity::RT_MODEL || en.en_RenderType==CEntity::RT_EDITORMODEL)
  {
    // get bbox of current frame
    CModelObject *pmo = en.GetModelObject();
    pmo->GetCurrentFrameBBox( bbox);
    pmR = &en.en_mRotation;
    vOffset = en.GetPlacement().pl_PositionVector;
  }
  // if it is ska model
  else if(en.en_RenderType==CEntity::RT_SKAMODEL || en.en_RenderType==CEntity::RT_SKAEDITORMODEL)
  {
    en.GetModelInstance()->GetCurrentColisionBox( bbox);
    pmR = &en.en_mRotation;
    vOffset = en.GetPlacement().pl_PositionVector;
  }
  // if it is brush
  else
  {
    // get bbox of brush's first mip
    CBrush3D *pbr = en.GetBrush();
    CBrushMip *pbrmip = pbr->GetFirstMip();
    bbox = pbrmip->bm_boxBoundingBox;
    pmR = &mOne;
    vOffset = FLOAT3D( 0.0f, 0.0f, 0.0f);
  }

  if( IsBoundingBoxInLasso( prProjection, bbox, pmR, vOffset))
  {
    if( _bSelectAlternative)
    {
      // deselect
      if (en.IsSelected(ENF_SELECTED))
      {
        _pselenSelectOnRender->Deselect(en);
      }
    }
    else
    {
      // select
      if (!en.IsSelected(ENF_SELECTED))
      {
        _pselenSelectOnRender->Select(en);
      }
    }
  }
}