@@ -34,6 +34,8 @@ backEndState_t backEnd;
3434
3535static  Cvar::Cvar<bool > r_clear ( " r_clear"  , " Clear screen before painting over it on every frame"  , Cvar::NONE, false  );
3636Cvar::Cvar<bool > r_drawSky ( " r_drawSky"  , " Draw the sky (clear the sky if disabled)"  , Cvar::NONE, true  );
37+ static  Cvar::Cvar<int > r_showEntityBounds (
38+ 	" r_showEntityBounds"  , " show bboxes used for culling (1: wireframe; 2: translucent solid)"  , Cvar::CHEAT, 0 );
3739
3840void  GL_Bind ( image_t  *image )
3941{
@@ -1563,7 +1565,7 @@ static void RB_RenderDebugUtils()
15631565{
15641566	GLIMP_LOGCOMMENT ( " --- RB_RenderDebugUtils ---"   );
15651567
1566- 	if  ( r_showEntityTransforms-> integer  )
1568+ 	if  ( r_showEntityBounds. Get ()  )
15671569	{
15681570		trRefEntity_t *ent;
15691571		int            i;
@@ -1577,13 +1579,23 @@ static void RB_RenderDebugUtils()
15771579		gl_genericShader->SetDepthFade ( false  );
15781580		gl_genericShader->BindProgram ( 0  );
15791581
1580- 		GL_State ( GLS_POLYMODE_LINE | GLS_DEPTHTEST_DISABLE );
1582+ 		if  ( r_showEntityBounds.Get () == 2  )
1583+ 		{
1584+ 			GL_State ( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
1585+ 			glEnable ( GL_POLYGON_OFFSET_FILL );
1586+ 			GL_PolygonOffset ( r_offsetFactor->value , r_offsetUnits->value  );
1587+ 		}
1588+ 		else 
1589+ 		{
1590+ 			GL_State ( GLS_POLYMODE_LINE | GLS_DEPTHTEST_DISABLE );
1591+ 		}
1592+ 
15811593		GL_Cull ( cullType_t::CT_TWO_SIDED );
15821594
15831595		//  set uniforms
15841596		gl_genericShader->SetUniform_AlphaTest ( GLS_ATEST_NONE );
15851597		SetUniform_ColorModulateColorGen ( gl_genericShader, colorGen_t::CGEN_VERTEX, alphaGen_t::AGEN_VERTEX );
1586- 		SetUniform_Color ( gl_genericShader, Color::Black  );
1598+ 		SetUniform_Color ( gl_genericShader, Color::Color  ( 0 ,  0 ,  0 ,  0 )  );
15871599
15881600		//  bind u_ColorMap
15891601		gl_genericShader->SetUniform_ColorMapBindless (
@@ -1613,16 +1625,23 @@ static void RB_RenderDebugUtils()
16131625
16141626			Tess_Begin ( Tess_StageIteratorDebug, nullptr , nullptr , true , -1 , 0  );
16151627
1616- 			Tess_AddCube ( vec3_origin, ent->localBounds [ 0  ], ent->localBounds [ 1  ], Color::Blue );
1617- 
1618- 			Tess_AddCube ( vec3_origin, mins, maxs,Color::White );
1628+ 			if  ( r_showEntityBounds.Get () == 2 )
1629+ 			{
1630+ 				Tess_AddCube ( vec3_origin, ent->localBounds [ 0  ], ent->localBounds [ 1  ], Color::Color (0 , 0 , 0.5 , 0.4 ) );
1631+ 			}
1632+ 			else 
1633+ 			{
1634+ 				Tess_AddCube ( vec3_origin, ent->localBounds [ 0  ], ent->localBounds [ 1  ], Color::Blue );
1635+ 				Tess_AddCube ( vec3_origin, mins, maxs,Color::White );
1636+ 			}
16191637
16201638			Tess_End ();
16211639		}
16221640
16231641		//  go back to the world modelview matrix
16241642		backEnd.orientation  = backEnd.viewParms .world ;
16251643		GL_LoadModelViewMatrix ( backEnd.viewParms .world .modelViewMatrix  );
1644+ 		glDisable ( GL_POLYGON_OFFSET_FILL );
16261645	}
16271646
16281647	if  ( r_showSkeleton->integer  )
0 commit comments