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 ){
76 /* early out for weird cases where there are no lights */
77 if ( lights == NULL ) {
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 ) {
95 /* clear surfacetest list */
96 memset( tested, 0, numDrawSurfaces / 8 + 1 );
98 /* walk the bsp leaves */
99 for ( i = 0, leaf = dleafs; i < numleafs; i++, leaf++ )
102 if ( ClusterVisible( light->cluster, leaf->cluster ) == qfalse ) {
106 /* walk the surface list for this leaf */
107 for ( j = 0; j < leaf->numLeafSurfaces; j++ )
109 /* don't filter a surface more than once */
110 s = dleafsurfaces[ leaf->firstLeafSurface + j ];
111 if ( tested[ s >> 3 ] & ( 1 << ( s & 7 ) ) ) {
114 tested[ s >> 3 ] |= ( 1 << ( s & 7 ) );
116 /* get surface and info */
117 ds = &drawSurfaces[ s ];
118 info = &surfaceInfos[ s ];
121 /* don't create shadow volumes from translucent surfaces */
122 if ( si->contents & CONTENTS_TRANSLUCENT ) {