Fix shadows, remove TriAPI code
This commit is contained in:
parent
31299ed401
commit
378a44e0b2
@ -1377,34 +1377,19 @@ void CStudioModelRenderer::StudioSetShadowSprite(int idx)
|
||||
m_iShadowSprite = idx;
|
||||
}
|
||||
|
||||
//#define USE_TRIAPI
|
||||
|
||||
void CStudioModelRenderer::StudioDrawShadow( Vector origin, float scale )
|
||||
{
|
||||
Vector endPoint = origin;
|
||||
Vector p1, p2, p3, p4;
|
||||
pmtrace_t pmtrace;
|
||||
static HSPRITE hSpriteFallback = 0;
|
||||
|
||||
#ifdef USE_TRIAPI
|
||||
if( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s*)gEngfuncs.pfnGetModelByIndex(m_iShadowSprite), 0 ) )
|
||||
{
|
||||
if( !hSpriteFallback )
|
||||
hSpriteFallback = gEngfuncs.pfnSPR_Load("sprites/shadow_circle.spr");
|
||||
if( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s* )gEngfuncs.GetSpritePointer(hSpriteFallback), 0))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
endPoint.z -= 150.0f;
|
||||
|
||||
|
||||
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
|
||||
|
||||
gEngfuncs.pEventAPI->EV_PushPMStates( );
|
||||
gEngfuncs.pEventAPI->EV_SetSolidPlayers( -1 );
|
||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
||||
gEngfuncs.pEventAPI->EV_PlayerTrace( origin, endPoint, PM_STUDIO_BOX | PM_GLASS_IGNORE, -1, &pmtrace );
|
||||
gEngfuncs.pEventAPI->EV_PlayerTrace( origin, endPoint, PM_STUDIO_IGNORE | PM_GLASS_IGNORE, -1, &pmtrace );
|
||||
gEngfuncs.pEventAPI->EV_PopPMStates( );
|
||||
|
||||
// don't allow shadow if player in solid area
|
||||
@ -1423,38 +1408,23 @@ void CStudioModelRenderer::StudioDrawShadow( Vector origin, float scale )
|
||||
|
||||
pmtrace.plane.normal = pmtrace.plane.normal * scale * ( 1.0 - pmtrace.fraction );
|
||||
|
||||
|
||||
// add 2.0f to Z, for avoid Z-fighting
|
||||
p1.x = pmtrace.endpos.x - pmtrace.plane.normal.z;
|
||||
p1.y = pmtrace.endpos.y + pmtrace.plane.normal.z;
|
||||
p1.z = pmtrace.endpos.z + 1.0f + pmtrace.plane.normal.x - pmtrace.plane.normal.y;
|
||||
p1.z = pmtrace.endpos.z + 2.0f + pmtrace.plane.normal.x - pmtrace.plane.normal.y;
|
||||
|
||||
p2.x = pmtrace.endpos.x + pmtrace.plane.normal.z;
|
||||
p2.y = pmtrace.endpos.y + pmtrace.plane.normal.z;
|
||||
p2.z = pmtrace.endpos.z + 1.0f - pmtrace.plane.normal.x - pmtrace.plane.normal.y;
|
||||
p2.z = pmtrace.endpos.z + 2.0f - pmtrace.plane.normal.x - pmtrace.plane.normal.y;
|
||||
|
||||
p3.x = pmtrace.endpos.x + pmtrace.plane.normal.z;
|
||||
p3.y = pmtrace.endpos.y - pmtrace.plane.normal.z;
|
||||
p3.z = pmtrace.endpos.z + 1.0f - pmtrace.plane.normal.x + pmtrace.plane.normal.y;
|
||||
p3.z = pmtrace.endpos.z + 2.0f - pmtrace.plane.normal.x + pmtrace.plane.normal.y;
|
||||
|
||||
p4.x = pmtrace.endpos.x - pmtrace.plane.normal.z;
|
||||
p4.y = pmtrace.endpos.y - pmtrace.plane.normal.z;
|
||||
p4.z = pmtrace.endpos.z + 1.0f + pmtrace.plane.normal.x + pmtrace.plane.normal.y;
|
||||
p4.z = pmtrace.endpos.z + 2.0f + pmtrace.plane.normal.x + pmtrace.plane.normal.y;
|
||||
|
||||
|
||||
#ifndef USE_TRIAPI
|
||||
IEngineStudio.StudioRenderShadow( m_iShadowSprite, p1, p2, p3, p4 );
|
||||
#else
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture );
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
|
||||
gEngfuncs.pTriAPI->Color4ub( 0, 0, 0, 255 );
|
||||
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3fv( p1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3fv( p2 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3fv( p3 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3fv( p4 );
|
||||
gEngfuncs.pTriAPI->End( );
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user