2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #define LIGHT_SHADOWS_C
29 /* -------------------------------------------------------------------------------
31 ydnar: this code deals with shadow volume bsps
33 ------------------------------------------------------------------------------- */
35 typedef struct shadowNode_s
43 shadowNode_t *shadowNodes;
49 adds a shadow, returning the index into the shadow list
55 MakeShadowFromPoints()
56 creates a shadow volume from 4 points (the first being the light origin)
63 sets up the shadow volumes for all lights in the world
66 void SetupShadows( void )
77 /* early out for weird cases where there are no lights */
82 Sys_FPrintf( SYS_VRB, "--- SetupShadows ---\n" );
84 /* allocate a surface test list */
85 tested = safe_malloc( numDrawSurfaces / 8 + 1 );
87 /* walk the list of lights */
88 for( light = lights; light != NULL; light = light->next )
90 /* do some early out testing */
91 if( light->cluster < 0 )
94 /* clear surfacetest list */
95 memset( tested, 0, numDrawSurfaces / 8 + 1 );
97 /* walk the bsp leaves */
98 for( i = 0, leaf = dleafs; i < numleafs; i++, leaf++ )
101 if( ClusterVisible( light->cluster, leaf->cluster ) == qfalse )
104 /* walk the surface list for this leaf */
105 for( j = 0; j < leaf->numLeafSurfaces; j++ )
107 /* don't filter a surface more than once */
108 s = dleafsurfaces[ leaf->firstLeafSurface + j ];
109 if( tested[ s >> 3 ] & (1 << (s & 7)) )
111 tested[ s >> 3 ] |= (1 << (s & 7));
113 /* get surface and info */
114 ds = &drawSurfaces[ s ];
115 info = &surfaceInfos[ s ];
118 /* don't create shadow volumes from translucent surfaces */
119 if( si->contents & CONTENTS_TRANSLUCENT )