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