ref: move R_DrawTree from refdll to engine, implement using ref's triapi

This commit is contained in:
Alibek Omarov
2019-07-27 13:27:40 +03:00
parent a5593963c5
commit 8f9800eb3c
12 changed files with 114 additions and 112 deletions

View File

@@ -714,98 +714,6 @@ rebuild_page:
pglFinish();
}
#define POINT_SIZE 16.0f
#define NODE_INTERVAL_X(x) (x * 16.0f)
#define NODE_INTERVAL_Y(x) (x * 16.0f)
void R_DrawLeafNode( float x, float y, float scale )
{
float downScale = scale * 0.25f;// * POINT_SIZE;
R_DrawStretchPic( x - downScale * 0.5f, y - downScale * 0.5f, downScale, downScale, 0, 0, 1, 1, tr.particleTexture );
}
void R_DrawNodeConnection( float x, float y, float x2, float y2 )
{
pglBegin( GL_LINES );
pglVertex2f( x, y );
pglVertex2f( x2, y2 );
pglEnd();
}
void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes )
{
float downScale = scale * 0.8f;
downScale = Q_max( downScale, 1.0f );
if( !node ) return;
tr.recursion_level++;
if( node->contents < 0 )
{
mleaf_t *leaf = (mleaf_t *)node;
if( tr.recursion_level > tr.max_recursion )
tr.max_recursion = tr.recursion_level;
if( shownodes == 1 )
{
if( WORLDMODEL->leafs == leaf )
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
else if( RI.viewleaf && RI.viewleaf == leaf )
pglColor4f( 1.0f, 0.0f, 0.0f, 1.0f );
else pglColor4f( 0.0f, 1.0f, 0.0f, 1.0f );
R_DrawLeafNode( x, y, scale );
}
tr.recursion_level--;
return;
}
if( shownodes == 1 )
{
pglColor4f( 0.0f, 0.0f, 1.0f, 1.0f );
R_DrawLeafNode( x, y, scale );
}
else if( shownodes == 2 )
{
R_DrawNodeConnection( x, y, x - scale, y + scale );
R_DrawNodeConnection( x, y, x + scale, y + scale );
}
R_ShowTree_r( node->children[1], x - scale, y + scale, downScale, shownodes );
R_ShowTree_r( node->children[0], x + scale, y + scale, downScale, shownodes );
tr.recursion_level--;
}
void R_ShowTree( void )
{
float x = (float)((gpGlobals->width - (int)POINT_SIZE) >> 1);
float y = NODE_INTERVAL_Y(1.0);
if( !WORLDMODEL || !CVAR_TO_BOOL( r_showtree ))
return;
tr.recursion_level = 0;
pglEnable( GL_BLEND );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglLineWidth( 2.0f );
pglColor3f( 1, 0.7f, 0 );
pglDisable( GL_TEXTURE_2D );
R_ShowTree_r( WORLDMODEL->nodes, x, y, tr.max_recursion * 3.5f, 2 );
pglEnable( GL_TEXTURE_2D );
pglLineWidth( 1.0f );
R_ShowTree_r( WORLDMODEL->nodes, x, y, tr.max_recursion * 3.5f, 1 );
gEngfuncs.Con_NPrintf( 0, "max recursion %d\n", tr.max_recursion );
}
/*
================
SCR_TimeRefresh_f

View File

@@ -335,7 +335,6 @@ ref_interface_t gReffuncs =
R_ProcessEntData,
R_ShowTextures,
R_ShowTree,
R_GetTextureOriginalBuffer,
GL_LoadTextureFromBuffer,

View File

@@ -1974,7 +1974,7 @@ static void GL_CreateInternalTextures( void )
}
}
tr.particleTexture = GL_LoadTextureInternal( "*particle", pic, TF_CLAMP );
tr.particleTexture = GL_LoadTextureInternal( REF_PARTICLE_TEXTURE, pic, TF_CLAMP );
// white texture
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );

View File

@@ -231,10 +231,7 @@ typedef struct
qboolean fResetVis;
qboolean fFlipViewModel;
// tree visualization stuff
int recursion_level;
int max_recursion;
byte visbytes[(MAX_MAP_LEAFS+7)/8]; // member custom PVS
int lightstylevalue[MAX_LIGHTSTYLES]; // value 0 - 65536
int block_size; // lightmap blocksize
@@ -296,7 +293,6 @@ void GL_SetRenderMode( int mode );
void GL_TextureTarget( uint target );
void GL_Cull( GLenum cull );
void R_ShowTextures( void );
void R_ShowTree( void );
void SCR_TimeRefresh_f( void );
//
@@ -741,7 +737,6 @@ extern cvar_t *gl_stencilbits;
extern cvar_t *r_speeds;
extern cvar_t *r_fullbright;
extern cvar_t *r_norefresh;
extern cvar_t *r_showtree; // build graph of visible hull
extern cvar_t *r_lighting_extended;
extern cvar_t *r_lighting_modulate;
extern cvar_t *r_lighting_ambient;

View File

@@ -22,7 +22,6 @@ cvar_t *gl_stencilbits;
cvar_t *r_speeds;
cvar_t *r_fullbright;
cvar_t *r_norefresh;
cvar_t *r_showtree;
cvar_t *r_lighting_extended;
cvar_t *r_lighting_modulate;
cvar_t *r_lighting_ambient;
@@ -780,7 +779,6 @@ void GL_InitCommands( void )
r_speeds = gEngfuncs.Cvar_Get( "r_speeds", "0", FCVAR_ARCHIVE, "shows renderer speeds" );
r_fullbright = gEngfuncs.Cvar_Get( "r_fullbright", "0", FCVAR_CHEAT, "disable lightmaps, get fullbright for entities" );
r_norefresh = gEngfuncs.Cvar_Get( "r_norefresh", "0", 0, "disable 3D rendering (use with caution)" );
r_showtree = gEngfuncs.Cvar_Get( "r_showtree", "0", FCVAR_ARCHIVE, "build the graph of visible BSP tree" );
r_lighting_extended = gEngfuncs.Cvar_Get( "r_lighting_extended", "1", FCVAR_ARCHIVE, "allow to get lighting from world and bmodels" );
r_lighting_modulate = gEngfuncs.Cvar_Get( "r_lighting_modulate", "0.6", FCVAR_ARCHIVE, "lightstyles modulate scale" );
r_lighting_ambient = gEngfuncs.Cvar_Get( "r_lighting_ambient", "0.3", FCVAR_ARCHIVE, "map ambient lighting scale" );

View File

@@ -159,7 +159,6 @@ void R_NewMap( void )
glState.isFogEnabled = false;
tr.skytexturenum = -1;
tr.max_recursion = 0;
pglDisable( GL_FOG );
// clearing texture chains