mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-12-26 18:55:37 +01:00
engine: move debug hulls rendering from renderer, implement through TriAPI
Bump RefAPI version to 9.
This commit is contained in:
parent
d3adcf3185
commit
9608da5bf9
@ -1,6 +1,8 @@
|
||||
/*
|
||||
mod_dbghulls.c - loading & handling world and brushmodels
|
||||
Copyright (C) 2016 Uncle Mike
|
||||
Copyright (C) 2005 Kevin Shanahan
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -659,7 +661,7 @@ static void make_hull_windings( hull_t *hull, hull_model_t *model )
|
||||
Con_Reportf( "%i hull polys\n", model->num_polys );
|
||||
}
|
||||
|
||||
void Mod_InitDebugHulls( model_t *loadmodel )
|
||||
static void Mod_InitDebugHulls( model_t *loadmodel )
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -675,14 +677,14 @@ void Mod_InitDebugHulls( model_t *loadmodel )
|
||||
}
|
||||
}
|
||||
|
||||
void Mod_CreatePolygonsForHull( int hullnum )
|
||||
static void Mod_CreatePolygonsForHull( int hullnum )
|
||||
{
|
||||
model_t *mod = cl.worldmodel;
|
||||
double start, end;
|
||||
char name[8];
|
||||
int i;
|
||||
|
||||
if( hullnum < 1 || hullnum > 3 )
|
||||
if( hullnum < 0 || hullnum > 3 )
|
||||
return;
|
||||
|
||||
if( !world.num_hull_models )
|
||||
@ -704,6 +706,59 @@ void Mod_CreatePolygonsForHull( int hullnum )
|
||||
Con_Printf( "build time %.3f secs\n", end - start );
|
||||
}
|
||||
|
||||
static void R_DrawHull( hull_model_t *hull )
|
||||
{
|
||||
winding_t *poly;
|
||||
|
||||
ref.dllFuncs.GL_Bind( XASH_TEXTURE0, R_GetBuiltinTexture( REF_WHITE_TEXTURE ));
|
||||
ref.dllFuncs.TriRenderMode( kRenderNormal );
|
||||
list_for_each_entry( poly, &hull->polys, chain )
|
||||
{
|
||||
int i;
|
||||
|
||||
srand((unsigned int)poly );
|
||||
ref.dllFuncs.Color4ub( rand() & 255, rand() & 255, rand() & 255, 255 );
|
||||
|
||||
ref.dllFuncs.Begin( TRI_POLYGON );
|
||||
for( i = 0; i < poly->numpoints; i++ )
|
||||
ref.dllFuncs.Vertex3fv( poly->p[i] );
|
||||
ref.dllFuncs.End();
|
||||
}
|
||||
}
|
||||
|
||||
void R_DrawWorldHull( void )
|
||||
{
|
||||
if( r_showhull.value <= 0.0f )
|
||||
return;
|
||||
|
||||
if( FBitSet( r_showhull.flags, FCVAR_CHANGED ))
|
||||
{
|
||||
int val = r_showhull.value;
|
||||
if( val > 3 ) val = 0;
|
||||
Mod_CreatePolygonsForHull( val );
|
||||
ClearBits( r_showhull.flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
R_DrawHull( &world.hull_models[0] );
|
||||
}
|
||||
|
||||
void R_DrawModelHull( model_t *mod )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( r_showhull.value <= 0.0f )
|
||||
return;
|
||||
|
||||
if( !mod || mod->name[0] != '*' )
|
||||
return;
|
||||
|
||||
i = atoi( mod->name + 1 );
|
||||
if( i < 1 || i >= world.num_hull_models )
|
||||
return;
|
||||
|
||||
R_DrawHull( &world.hull_models[i] );
|
||||
}
|
||||
|
||||
void Mod_ReleaseHullPolygons( void )
|
||||
{
|
||||
int i;
|
||||
|
@ -342,7 +342,8 @@ static const ref_api_t gEngfuncs =
|
||||
Mod_SampleSizeForFace,
|
||||
Mod_BoxVisible,
|
||||
Mod_PointInLeaf,
|
||||
Mod_CreatePolygonsForHull,
|
||||
R_DrawWorldHull,
|
||||
R_DrawModelHull,
|
||||
|
||||
R_StudioGetAnim,
|
||||
pfnStudioEvent,
|
||||
|
@ -182,8 +182,8 @@ void Mod_PrintWorldStats_f( void );
|
||||
//
|
||||
// mod_dbghulls.c
|
||||
//
|
||||
void Mod_InitDebugHulls( model_t *mod );
|
||||
void Mod_CreatePolygonsForHull( int hullnum );
|
||||
void R_DrawWorldHull( void );
|
||||
void R_DrawModelHull( model_t *mod );
|
||||
void Mod_ReleaseHullPolygons( void );
|
||||
|
||||
//
|
||||
|
@ -51,7 +51,9 @@ GNU General Public License for more details.
|
||||
// PARM_SKY_SPHERE and PARM_SURF_SAMPLESIZE are now handled at engine side.
|
||||
// VGUI rendering code is mostly moved back to engine.
|
||||
// Implemented texture replacement.
|
||||
#define REF_API_VERSION 8
|
||||
// 9. Removed gamma functions. Renderer is supposed to get them through PARM_GET_*_PTR.
|
||||
// Move hulls rendering back to engine
|
||||
#define REF_API_VERSION 9
|
||||
|
||||
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP|TF_ALLOW_NEAREST)
|
||||
#define TF_FONT (TF_NOMIPMAP|TF_CLAMP|TF_ALLOW_NEAREST)
|
||||
@ -344,7 +346,8 @@ typedef struct ref_api_s
|
||||
int (*Mod_SampleSizeForFace)( const struct msurface_s *surf );
|
||||
qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits );
|
||||
mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node );
|
||||
void (*Mod_CreatePolygonsForHull)( int hullnum );
|
||||
void (*R_DrawWorldHull)( void );
|
||||
void (*R_DrawModelHull)( model_t *mod );
|
||||
|
||||
// studio models
|
||||
void *(*R_StudioGetAnim)( studiohdr_t *m_pStudioHeader, model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc );
|
||||
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
gl_dbghulls.c - loading & handling world and brushmodels
|
||||
Copyright (C) 2016 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "gl_local.h"
|
||||
#include "mod_local.h"
|
||||
|
||||
#define list_entry( ptr, type, member ) \
|
||||
((type *)((char *)(ptr) - (size_t)(&((type *)0)->member)))
|
||||
|
||||
// iterate over each entry in the list
|
||||
#define list_for_each_entry( pos, head, member ) \
|
||||
for( pos = list_entry( (head)->next, winding_t, member ); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry( pos->member.next, winding_t, member ))
|
||||
|
||||
// REFTODO: rewrite in triapi
|
||||
void R_DrawWorldHull( void )
|
||||
{
|
||||
hull_model_t *hull;
|
||||
winding_t *poly;
|
||||
int i;
|
||||
|
||||
if( FBitSet( r_showhull->flags, FCVAR_CHANGED ))
|
||||
{
|
||||
int val = bound( 0, (int)r_showhull->value, 3 );
|
||||
if( val ) gEngfuncs.Mod_CreatePolygonsForHull( val );
|
||||
ClearBits( r_showhull->flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
if( !r_showhull->value )
|
||||
return;
|
||||
|
||||
hull = &tr.world->hull_models[0];
|
||||
|
||||
pglDisable( GL_TEXTURE_2D );
|
||||
|
||||
list_for_each_entry( poly, &hull->polys, chain )
|
||||
{
|
||||
srand((unsigned int)poly);
|
||||
pglColor3f( rand() % 256 / 255.0, rand() % 256 / 255.0, rand() % 256 / 255.0 );
|
||||
pglBegin( GL_POLYGON );
|
||||
for( i = 0; i < poly->numpoints; i++ )
|
||||
pglVertex3fv( poly->p[i] );
|
||||
pglEnd();
|
||||
}
|
||||
pglEnable( GL_TEXTURE_2D );
|
||||
}
|
||||
|
||||
void R_DrawModelHull( void )
|
||||
{
|
||||
hull_model_t *hull;
|
||||
winding_t *poly;
|
||||
int i;
|
||||
|
||||
if( !r_showhull->value )
|
||||
return;
|
||||
|
||||
if( !RI.currentmodel || RI.currentmodel->name[0] != '*' )
|
||||
return;
|
||||
|
||||
i = atoi( RI.currentmodel->name + 1 );
|
||||
if( i < 1 || i >= tr.world->num_hull_models )
|
||||
return;
|
||||
|
||||
hull = &tr.world->hull_models[i];
|
||||
|
||||
pglPolygonOffset( 1.0f, 2.0 );
|
||||
pglEnable( GL_POLYGON_OFFSET_FILL );
|
||||
pglDisable( GL_TEXTURE_2D );
|
||||
list_for_each_entry( poly, &hull->polys, chain )
|
||||
{
|
||||
srand((unsigned int)poly);
|
||||
pglColor3f( rand() % 256 / 255.0, rand() % 256 / 255.0, rand() % 256 / 255.0 );
|
||||
pglBegin( GL_POLYGON );
|
||||
for( i = 0; i < poly->numpoints; i++ )
|
||||
pglVertex3fv( poly->p[i] );
|
||||
pglEnd();
|
||||
}
|
||||
pglEnable( GL_TEXTURE_2D );
|
||||
pglDisable( GL_POLYGON_OFFSET_FILL );
|
||||
}
|
@ -1745,7 +1745,12 @@ void R_DrawBrushModel( cl_entity_t *e )
|
||||
pglAlphaFunc( GL_GREATER, DEFAULT_ALPHATEST );
|
||||
pglDisable( GL_BLEND );
|
||||
pglDepthMask( GL_TRUE );
|
||||
R_DrawModelHull(); // draw before restore
|
||||
|
||||
pglPolygonOffset( 1.0f, 2.0f );
|
||||
pglEnable( GL_POLYGON_OFFSET_FILL );
|
||||
gEngfuncs.R_DrawModelHull( clmodel ); // draw before restore
|
||||
pglDisable( GL_POLYGON_OFFSET_FILL );
|
||||
|
||||
R_LoadIdentity(); // restore worldmatrix
|
||||
}
|
||||
|
||||
@ -3626,7 +3631,7 @@ void R_DrawWorld( void )
|
||||
|
||||
R_DrawTriangleOutlines ();
|
||||
|
||||
R_DrawWorldHull();
|
||||
gEngfuncs.R_DrawWorldHull();
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user