You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.4 KiB
91 lines
2.4 KiB
6 years ago
|
/*
|
||
|
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"
|
||
6 years ago
|
#include "mod_local.h"
|
||
6 years ago
|
|
||
|
#define list_entry( ptr, type, member ) \
|
||
4 years ago
|
((type *)((char *)(ptr) - (size_t)(&((type *)0)->member)))
|
||
6 years ago
|
|
||
|
// 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 ))
|
||
|
|
||
6 years ago
|
// REFTODO: rewrite in triapi
|
||
6 years ago
|
void R_DrawWorldHull( void )
|
||
|
{
|
||
6 years ago
|
hull_model_t *hull = &WORLD->hull_models[0];
|
||
6 years ago
|
winding_t *poly;
|
||
|
int i;
|
||
|
|
||
|
if( FBitSet( r_showhull->flags, FCVAR_CHANGED ))
|
||
|
{
|
||
|
int val = bound( 0, (int)r_showhull->value, 3 );
|
||
6 years ago
|
if( val ) gEngfuncs.Mod_CreatePolygonsForHull( val );
|
||
6 years ago
|
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 );
|
||
6 years ago
|
if( i < 1 || i >= WORLD->num_hull_models )
|
||
6 years ago
|
return;
|
||
|
|
||
6 years ago
|
hull = &WORLD->hull_models[i];
|
||
6 years ago
|
|
||
|
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 );
|
||
|
}
|