Example #1
0
int SelectWeightedSequence( CStudioHdr *pstudiohdr, int activity, int curSequence )
{
	VPROF( "SelectWeightedSequence" );
#ifdef CLIENT_DLL
	VPROF_INCREMENT_COUNTER( "Client SelectWeightedSequence", 1 );
#else // ifdef GAME_DLL
	VPROF_INCREMENT_COUNTER( "Server SelectWeightedSequence", 1 );
#endif

	if (! pstudiohdr)
		return 0;

	if (!pstudiohdr->SequencesAvailable())
		return 0;

	VerifySequenceIndex( pstudiohdr );

	int numSeq = pstudiohdr->GetNumSeq();
	if ( numSeq == 1 )
	{
		return ( GetSequenceActivity( pstudiohdr, 0, NULL ) == activity ) ? 0 : ACTIVITY_NOT_AVAILABLE;
	}

	return pstudiohdr->SelectWeightedSequence( activity, curSequence );
}
Example #2
0
void CMeshOES2::RenderPass(void)
{
    Assert(m_Type != MATERIAL_HETEROGENOUS);
    VPROF("CMeshOES2::RenderPass");

    int i;
    const CPrimList *pPrim = s_pPrims;
    bool applied = false;
    if (m_Type == MATERIAL_POINTS)
    {
        for (i = 0; i < s_nPrims; ++i, ++pPrim)
        {
            if (!(pPrim->m_NumIndices))
                continue;
            if (!applied)
            {
                applied = true;
                MeshMgr()->ApplyStreamState();
            }
            glDrawArrays(GL_POINTS, 0, pPrim->m_NumIndices);
        }
    }
    else
    {
        MeshMgr()->BindOESBuffer(OES_BUFFER_TARGET_INDEX, m_pIndexBuffer->GetOESBuffer());
        for (i = 0; i < s_nPrims; ++i, ++pPrim)
        {
            if (!(pPrim->m_NumIndices))
                continue;
#ifdef VPROF_ENABLED
            int numPrimitives;
            switch (m_Type)
            {
            case MATERIAL_LINES:
                numPrimitives = pPrim->m_NumIndices >> 1;
                break;
            case MATERIAL_TRIANGLES:
                numPrimitives = pPrim->m_NumIndices / 3;
                break;
            case MATERIAL_TRIANGLE_STRIP:
                numPrimitives = pPrim->m_NumIndices - 2;
                break;
                NO_DEFAULT
            }
            VPROF("glDrawElements");
            VPROF_INCREMENT_COUNTER("DrawElements", 1);
            VPROF_INCREMENT_COUNTER("numPrimitives", numPrimitives);
#endif
            if (!applied)
            {
                applied = true;
                MeshMgr()->ApplyStreamState();
            }
            glDrawElements(m_Mode, pPrim->m_NumIndices, GL_UNSIGNED_SHORT, (void *)(pPrim->m_FirstIndex << 1));
        }
    }
}
Example #3
0
//-----------------------------------------------------------------------------
// returns light in range from 0 to 1.
// lightmapS/T is in [0,1] within the space of the surface.
// returns surfID
//-----------------------------------------------------------------------------
SurfaceHandle_t R_LightVec (const Vector& start, const Vector& end, bool bUseLightStyles, Vector& c, 
		float *textureS, float *textureT, float *lightmapS, float *lightmapT )
{
	VPROF_INCREMENT_COUNTER( "R_LightVec", 1 );

	SurfaceHandle_t retSurfID;
	SurfaceHandle_t dispSurfID;
	
	// We're using the vis frame here for lightvec tests
	// to make sure we test each displacement only once
	++r_surfacevisframe;

	LightVecState_t state;
	state.m_HitFrac = 1.0f;
	state.m_Ray.Init( start, end );
	state.m_pTextureS = textureS;
	state.m_pTextureT = textureT;
	state.m_pLightmapS = lightmapS;
	state.m_pLightmapT = lightmapT;
	state.m_nSkySurfID = SURFACE_HANDLE_INVALID;
	state.m_bUseLightStyles = bUseLightStyles;

	c[0] = c[1] = c[2] = 0.0f;

	model_t* model = s_pLightVecModel ? s_pLightVecModel : host_state.worldmodel; 
	retSurfID = RecursiveLightPoint(&model->brush.pShared->nodes[model->brush.firstnode],
		0.0f, 1.0f, c, state );

	// While doing recursive light point, we built a list of all
	// displacement surfaces which we need to test, so let's test them
	dispSurfID = R_LightVecDisplacementChain( state, bUseLightStyles, c );

	if( r_visualizelighttraces.GetBool() )
	{
		if( r_visualizelighttracesshowfulltrace.GetBool() )
		{
			CDebugOverlay::AddLineOverlay( start, end, 0, 255, 0, 255, true, -1.0f );
		}
		else
		{
			CDebugOverlay::AddLineOverlay( start, start + ( end - start ) * state.m_HitFrac, 0, 255, 0, 255, true, -1.0f );
		}
	}

	if ( IS_SURF_VALID( dispSurfID ) )
		retSurfID = dispSurfID;

//	ConMsg( "R_LightVec: %f %f %f\n", c[0], c[1], c[2] );

	// If we didn't hit anything else, but we hit a sky surface at
	// some point along the ray cast, return the sky id.
	if ( ( retSurfID == SURFACE_HANDLE_INVALID ) && ( state.m_nSkySurfID != SURFACE_HANDLE_INVALID ) )
		return state.m_nSkySurfID;

	return retSurfID;
}