X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=tools%2Fquake3%2Fq3map2%2Flight_shadows.c;h=50a0d627ad63b39bc3eb7d14ece411bb95558db5;hb=748436778d9393eda5e9a1e8741a3a513d2c1615;hp=df7cdd82f252a4c1593a6981f9ac42f40d2db3bc;hpb=5265d3cc1517566910718738ee6fa48e2466d3ea;p=xonotic%2Fnetradiant.git diff --git a/tools/quake3/q3map2/light_shadows.c b/tools/quake3/q3map2/light_shadows.c index df7cdd82..50a0d627 100644 --- a/tools/quake3/q3map2/light_shadows.c +++ b/tools/quake3/q3map2/light_shadows.c @@ -1,23 +1,23 @@ /* -Copyright (C) 1999-2007 id Software, Inc. and contributors. -For a list of contributors, see the accompanying CONTRIBUTORS file. + Copyright (C) 1999-2007 id Software, Inc. and contributors. + For a list of contributors, see the accompanying CONTRIBUTORS file. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant 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 2 of the License, or -(at your option) any later version. + GtkRadiant 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 2 of the License, or + (at your option) any later version. -GtkRadiant 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. + GtkRadiant 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. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #define LIGHT_SHADOWS_C @@ -28,97 +28,101 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /* ------------------------------------------------------------------------------- -ydnar: this code deals with shadow volume bsps + ydnar: this code deals with shadow volume bsps -------------------------------------------------------------------------------- */ + ------------------------------------------------------------------------------- */ typedef struct shadowNode_s { - vec4_t plane; - int children[ 2 ]; + vec4_t plane; + int children[ 2 ]; } shadowNode_t; -int numShadowNodes; -shadowNode_t *shadowNodes; +int numShadowNodes; +shadowNode_t *shadowNodes; /* -AddShadow() -adds a shadow, returning the index into the shadow list -*/ + AddShadow() + adds a shadow, returning the index into the shadow list + */ /* -MakeShadowFromPoints() -creates a shadow volume from 4 points (the first being the light origin) -*/ + MakeShadowFromPoints() + creates a shadow volume from 4 points (the first being the light origin) + */ /* -SetupShadows() -sets up the shadow volumes for all lights in the world -*/ + SetupShadows() + sets up the shadow volumes for all lights in the world + */ + +void SetupShadows( void ){ + int i, j, s; + light_t *light; + dleaf_t *leaf; + dsurface_t *ds; + surfaceInfo_t *info; + shaderInfo_t *si; + byte *tested; + -void SetupShadows( void ) -{ - int i, j, s; - light_t *light; - dleaf_t *leaf; - dsurface_t *ds; - surfaceInfo_t *info; - shaderInfo_t *si; - byte *tested; - - /* early out for weird cases where there are no lights */ - if( lights == NULL ) + if ( lights == NULL ) { return; - + } + /* note it */ Sys_FPrintf( SYS_VRB, "--- SetupShadows ---\n" ); - + /* allocate a surface test list */ tested = safe_malloc( numDrawSurfaces / 8 + 1 ); - + /* walk the list of lights */ - for( light = lights; light != NULL; light = light->next ) + for ( light = lights; light != NULL; light = light->next ) { /* do some early out testing */ - if( light->cluster < 0 ) + if ( light->cluster < 0 ) { continue; - + } + /* clear surfacetest list */ memset( tested, 0, numDrawSurfaces / 8 + 1 ); - + /* walk the bsp leaves */ - for( i = 0, leaf = dleafs; i < numleafs; i++, leaf++ ) + for ( i = 0, leaf = dleafs; i < numleafs; i++, leaf++ ) { /* in pvs? */ - if( ClusterVisible( light->cluster, leaf->cluster ) == qfalse ) + if ( ClusterVisible( light->cluster, leaf->cluster ) == qfalse ) { continue; - + } + /* walk the surface list for this leaf */ - for( j = 0; j < leaf->numLeafSurfaces; j++ ) + for ( j = 0; j < leaf->numLeafSurfaces; j++ ) { /* don't filter a surface more than once */ s = dleafsurfaces[ leaf->firstLeafSurface + j ]; - if( tested[ s >> 3 ] & (1 << (s & 7)) ) + if ( tested[ s >> 3 ] & ( 1 << ( s & 7 ) ) ) { continue; - tested[ s >> 3 ] |= (1 << (s & 7)); - + } + tested[ s >> 3 ] |= ( 1 << ( s & 7 ) ); + /* get surface and info */ ds = &drawSurfaces[ s ]; info = &surfaceInfos[ s ]; si = info->si; - + /* don't create shadow volumes from translucent surfaces */ - if( si->contents & CONTENTS_TRANSLUCENT ) + if ( si->contents & CONTENTS_TRANSLUCENT ) { continue; + } } } } -} \ No newline at end of file +}