From 378a44e0b2e4fd7fa517d3041f9ee44722a0fb88 Mon Sep 17 00:00:00 2001 From: a1batross Date: Sat, 27 Feb 2016 14:39:05 +0300 Subject: [PATCH] Fix shadows, remove TriAPI code --- cl_dll/studio/StudioModelRenderer.cpp | 44 +++++---------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/cl_dll/studio/StudioModelRenderer.cpp b/cl_dll/studio/StudioModelRenderer.cpp index 1121a92..40094d6 100644 --- a/cl_dll/studio/StudioModelRenderer.cpp +++ b/cl_dll/studio/StudioModelRenderer.cpp @@ -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 }