2019-02-18 19:25:26 +01:00
|
|
|
/*
|
|
|
|
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"
|
2019-03-06 14:23:33 +01:00
|
|
|
#include "mod_local.h"
|
2019-02-18 19:25:26 +01:00
|
|
|
|
|
|
|
#define list_entry( ptr, type, member ) \
|
2020-11-18 10:15:54 +01:00
|
|
|
((type *)((void *)(ptr) - (size_t)(&((type *)0)->member)))
|
2019-02-18 19:25:26 +01:00
|
|
|
|
|
|
|
// 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 ))
|
|
|
|
|
2019-03-11 15:37:58 +01:00
|
|
|
// REFTODO: rewrite in triapi
|
2019-02-18 19:25:26 +01:00
|
|
|
void R_DrawWorldHull( void )
|
|
|
|
{
|
2019-02-24 16:45:27 +01:00
|
|
|
hull_model_t *hull = &WORLD->hull_models[0];
|
2019-02-18 19:25:26 +01:00
|
|
|
winding_t *poly;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if( FBitSet( r_showhull->flags, FCVAR_CHANGED ))
|
|
|
|
{
|
|
|
|
int val = bound( 0, (int)r_showhull->value, 3 );
|
2019-03-11 15:37:58 +01:00
|
|
|
if( val ) gEngfuncs.Mod_CreatePolygonsForHull( val );
|
2019-02-18 19:25:26 +01:00
|
|
|
ClearBits( r_showhull->flags, FCVAR_CHANGED );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !CVAR_TO_BOOL( r_showhull ))
|
|
|
|
return;
|
|
|
|
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( !CVAR_TO_BOOL( r_showhull ))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( !RI.currentmodel || RI.currentmodel->name[0] != '*' )
|
|
|
|
return;
|
|
|
|
|
|
|
|
i = atoi( RI.currentmodel->name + 1 );
|
2019-02-24 16:45:27 +01:00
|
|
|
if( i < 1 || i >= WORLD->num_hull_models )
|
2019-02-18 19:25:26 +01:00
|
|
|
return;
|
|
|
|
|
2019-02-24 16:45:27 +01:00
|
|
|
hull = &WORLD->hull_models[i];
|
2019-02-18 19:25:26 +01:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|