Ejemplo n.º 1
0
void CMomentumGameMovement::PlayerMove()
{
    BaseClass::PlayerMove();

    if (player->IsAlive())
    {
        // Check if our eye height is too close to the ceiling and lower it.
        // This is needed because we have taller models with the old collision bounds.

        const float eyeClearance = 12.0f; // eye pos must be this far below the ceiling

        Vector offset = player->GetViewOffset();

        Vector vHullMin = GetPlayerMins(player->m_Local.m_bDucked);
        vHullMin.z = 0.0f;
        Vector vHullMax = GetPlayerMaxs(player->m_Local.m_bDucked);

        Vector start = player->GetAbsOrigin();
        start.z += vHullMax.z;
        Vector end = start;
        end.z += eyeClearance - vHullMax.z;
        end.z += player->m_Local.m_bDucked ? VEC_DUCK_VIEW.z : VEC_VIEW.z;

        vHullMax.z = 0.0f;

        Vector fudge(1, 1, 0);
        vHullMin += fudge;
        vHullMax -= fudge;

        trace_t trace;
        Ray_t ray;
        ray.Init(start, end, vHullMin, vHullMax);
        UTIL_TraceRay(ray, PlayerSolidMask(), mv->m_nPlayerHandle.Get(), COLLISION_GROUP_PLAYER_MOVEMENT, &trace);

        if (trace.fraction < 1.0f)
        {
            float est = start.z + trace.fraction * (end.z - start.z) - player->GetAbsOrigin().z - eyeClearance;
            if ((player->GetFlags() & FL_DUCKING) == 0 && !player->m_Local.m_bDucking && !player->m_Local.m_bDucked)
            {
                offset.z = est;
            }
            else
            {
                offset.z = min(est, offset.z);
            }
            player->SetViewOffset(offset);
        }
        else
        {
            if ((player->GetFlags() & FL_DUCKING) == 0 && !player->m_Local.m_bDucking && !player->m_Local.m_bDucked)
            {
                player->SetViewOffset(VEC_VIEW);
            }
            else if (player->m_Local.m_bDucked && !player->m_Local.m_bDucking)
            {
                player->SetViewOffset(VEC_DUCK_VIEW);
            }
        }
    }
}
BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* bounds)
{
	if (camera->getOrigin().isExactlyZero())
	{
		return FALSE;
	}

	static LLCachedControl<F32> vel("SHOcclusionFudge",SG_OCCLUSION_FUDGE);
	LLVector4a fudge(vel*2.f);

	const LLVector4a& c = bounds[0];
	static LLVector4a r;
	r.setAdd(bounds[1], fudge);

	/*if (r.magVecSquared() > 1024.0*1024.0)
	{
		return TRUE;
	}*/

	LLVector4a e;
	e.load3(camera->getOrigin().mV);
	
	LLVector4a min;
	min.setSub(c,r);
	LLVector4a max;
	max.setAdd(c,r);
	
	S32 lt = e.lessThan(min).getGatheredBits() & 0x7;
	if (lt)
	{
		return FALSE;
	}

	S32 gt = e.greaterThan(max).getGatheredBits() & 0x7;
	if (gt)
	{
		return FALSE;
	}

	return TRUE;
}
void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* shift)
{
	LLGLDisable stencil(GL_STENCIL_TEST);
	if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1)
	{
		//move mBounds to the agent space if necessary
		LLVector4a bounds[2];
		bounds[0] = mBounds[0];
		bounds[1] = mBounds[1];
		if(shift != NULL)
		{
			bounds[0].add(*shift);
		}

		// Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension
		if (earlyFail(camera, bounds))
		{
			LLFastTimer t(FTM_OCCLUSION_EARLY_FAIL);
			setOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY);
			assert_states_valid(this);
			clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF);
			assert_states_valid(this);
		}
		else
		{
			if (!isOcclusionState(QUERY_PENDING) || isOcclusionState(DISCARD_QUERY))
			{
				{ //no query pending, or previous query to be discarded
					LLFastTimer t(FTM_RENDER_OCCLUSION);

					if (!mOcclusionQuery[LLViewerCamera::sCurCameraID])
					{
						LLFastTimer t(FTM_OCCLUSION_ALLOCATE);
						mOcclusionQuery[LLViewerCamera::sCurCameraID] = getNewOcclusionQueryObjectName();
					}

					// Depth clamp all water to avoid it being culled as a result of being
					// behind the far clip plane, and in the case of edge water to avoid
					// it being culled while still visible.
					bool const use_depth_clamp = gGLManager.mHasDepthClamp &&
												(mSpatialPartition->mDrawableType == LLDrawPool::POOL_WATER ||
												mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER);

					LLGLEnable clamp(use_depth_clamp ? GL_DEPTH_CLAMP : 0);	

#if !LL_DARWIN					
					U32 mode = gGLManager.mHasOcclusionQuery2 ? GL_ANY_SAMPLES_PASSED : GL_SAMPLES_PASSED_ARB;
#else
					U32 mode = GL_SAMPLES_PASSED_ARB;
#endif
					
#if LL_TRACK_PENDING_OCCLUSION_QUERIES
					sPendingQueries.insert(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
#endif

					{
						LLFastTimer t(FTM_PUSH_OCCLUSION_VERTS);
						
						//store which frame this query was issued on
						mOcclusionIssued[LLViewerCamera::sCurCameraID] = gFrameCount;

						{
							LLFastTimer t(FTM_OCCLUSION_BEGIN_QUERY);
							glBeginQueryARB(mode, mOcclusionQuery[LLViewerCamera::sCurCameraID]);					
						}
					
						LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
						llassert(shader);

						shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, bounds[0].getF32ptr());
						//static LLVector4a fudge(SG_OCCLUSION_FUDGE);
						static LLCachedControl<F32> vel("SHOcclusionFudge",SG_OCCLUSION_FUDGE);
						LLVector4a fudge(SG_OCCLUSION_FUDGE);
						static LLVector4a fudged_bounds;
						fudged_bounds.setAdd(fudge, bounds[1]);
						shader->uniform3fv(LLShaderMgr::BOX_SIZE, 1, fudged_bounds.getF32ptr());

						if (!use_depth_clamp && mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER)
						{
							LLFastTimer t(FTM_OCCLUSION_DRAW_WATER);

							LLGLSquashToFarClip squash(glh_get_current_projection(), 1);
							if (camera->getOrigin().isExactlyZero())
							{ //origin is invalid, draw entire box
								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0);
								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8);				
							}
							else
							{
								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, bounds[0]));
							}
						}
						else
						{
							LLFastTimer t(FTM_OCCLUSION_DRAW);
							if (camera->getOrigin().isExactlyZero())
							{ //origin is invalid, draw entire box
								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0);
								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8);				
							}
							else
							{
								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, bounds[0]));
							}
						}


						{
							LLFastTimer t(FTM_OCCLUSION_END_QUERY);
							glEndQueryARB(mode);
						}
					}
				}

				{
					LLFastTimer t(FTM_SET_OCCLUSION_STATE);
					setOcclusionState(LLOcclusionCullingGroup::QUERY_PENDING);
					clearOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY);
				}
			}
		}
	}
}
Ejemplo n.º 4
0
void
check_add_1 (void)
{
    static const struct {
        mp_size_t        size;
        mp_limb_t        n;
        const mp_limb_t  src[ASIZE];
        mp_limb_t        want_c;
        const mp_limb_t  want[ASIZE];
    } data[] = {
        { 1, 0, { 0 },  0, { 0 } },
        { 1, 0, { 1 },  0, { 1 } },
        { 1, 1, { 0 },  0, { 1 } },
        { 1, 0, { M },  0, { M } },
        { 1, M, { 0 },  0, { M } },
        { 1, 1, { 123 }, 0, { 124 } },

        { 1, 1, { M },  1, { 0 } },
        { 1, M, { 1 },  1, { 0 } },
        { 1, M, { M },  1, { M-1 } },

        { 2, 0, { 0, 0 },  0, { 0, 0 } },
        { 2, 0, { 1, 0 },  0, { 1, 0 } },
        { 2, 1, { 0, 0 },  0, { 1, 0 } },
        { 2, 0, { M, 0 },  0, { M, 0 } },
        { 2, M, { 0, 0 },  0, { M, 0 } },
        { 2, 1, { M, 0 },  0, { 0, 1 } },
        { 2, M, { 1, 0 },  0, { 0, 1 } },
        { 2, M, { M, 0 },  0, { M-1, 1 } },
        { 2, M, { M, 0 },  0, { M-1, 1 } },

        { 2, 1, { M, M },  1, { 0, 0 } },
        { 2, M, { 1, M },  1, { 0, 0 } },
        { 2, M, { M, M },  1, { M-1, 0 } },
        { 2, M, { M, M },  1, { M-1, 0 } },

        { 3, 1, { M, M, M },  1, { 0, 0, 0 } },
        { 3, M, { 1, M, M },  1, { 0, 0, 0 } },
        { 3, M, { M, M, M },  1, { M-1, 0, 0 } },
        { 3, M, { M, M, M },  1, { M-1, 0, 0 } },

        { 4, 1, { M, M, M, M },  1, { 0, 0, 0, 0 } },
        { 4, M, { 1, M, M, M },  1, { 0, 0, 0, 0 } },
        { 4, M, { M, M, M, M },  1, { M-1, 0, 0, 0 } },
        { 4, M, { M, M, M, M },  1, { M-1, 0, 0, 0 } },

        { 4, M, { M, 0,   M, M },  0, { M-1, 1, M, M } },
        { 4, M, { M, M-1, M, M },  0, { M-1, M, M, M } },

        { 4, M, { M, M, 0,   M },  0, { M-1, 0, 1, M } },
        { 4, M, { M, M, M-1, M },  0, { M-1, 0, M, M } },
    };

    mp_limb_t  got[ASIZE];
    mp_limb_t  got_c;
    int        i;

    for (i = 0; i < numberof (data); i++)
    {
        SETUP ();
        got_c = mpn_add_1 (got, data[i].src, data[i].size, data[i].n);
        VERIFY ("check_add_1 (separate)");

        SETUP_INPLACE ();
        got_c = mpn_add_1 (got, got, data[i].size, data[i].n);
        VERIFY ("check_add_1 (in-place)");

        if (data[i].n == 1)
        {
            SETUP ();
            got_c = mpn_add_1 (got, data[i].src, data[i].size, CNST_LIMB(1));
            VERIFY ("check_add_1 (separate, const 1)");

            SETUP_INPLACE ();
            got_c = mpn_add_1 (got, got, data[i].size, CNST_LIMB(1));
            VERIFY ("check_add_1 (in-place, const 1)");
        }

        /* Same again on functions, not inlines. */
        SETUP ();
        got_c = (*fudge(mpn_add_1)) (got, data[i].src, data[i].size, data[i].n);
        VERIFY ("check_add_1 (function, separate)");

        SETUP_INPLACE ();
        got_c = (*fudge(mpn_add_1)) (got, got, data[i].size, data[i].n);
        VERIFY ("check_add_1 (function, in-place)");
    }
}