bool get_hud_matrices(const LLRect& screen_region, LLMatrix4a &proj, LLMatrix4a &model) { if (isAgentAvatarValid() && gAgentAvatarp->hasHUDAttachment()) { F32 zoom_level = gAgentCamera.mHUDCurZoom; LLBBox hud_bbox = gAgentAvatarp->getHUDBBox(); F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); proj = gGL.genOrtho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth); proj.getRow<2>().copyComponent<2>(LLVector4a(-0.01f)); F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect(); F32 scale_x = (F32)gViewerWindow->getWorldViewWidthScaled() / (F32)screen_region.getWidth(); F32 scale_y = (F32)gViewerWindow->getWorldViewHeightScaled() / (F32)screen_region.getHeight(); proj.applyTranslation_affine( clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio), clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y), 0.f); proj.applyScale_affine(scale_x, scale_y, 1.f); model = OGL_TO_CFR_ROTATION; model.applyTranslation_affine(LLVector3(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f)); model.applyScale_affine(zoom_level); return TRUE; } else { return FALSE; } }
S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius) { static const LLVector4a scaler[] = { LLVector4a(-1,-1,-1), LLVector4a( 1,-1,-1), LLVector4a(-1, 1,-1), LLVector4a( 1, 1,-1), LLVector4a(-1,-1, 1), LLVector4a( 1,-1, 1), LLVector4a(-1, 1, 1), LLVector4a( 1, 1, 1) }; U8 mask = 0; bool result = false; LLVector4a rscale, maxp, minp; LLSimdScalar d; for (U32 i = 0; i < mPlaneCount; i++) { mask = mPlaneMask[i]; if ((i != 5) && (mask != 0xff)) { const LLPlane& p(mAgentPlanes[i]); p.getAt<3>(d); rscale.setMul(radius, scaler[mask]); minp.setSub(center, rscale); d = -d; if (p.dot3(minp).getF32() > d) { return 0; } if(!result) { maxp.setAdd(center, rscale); result = (p.dot3(maxp).getF32() > d); } } } return result?1:2; }