forked from DaemonEngine/Daemon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtr_world.cpp
More file actions
882 lines (729 loc) · 18.3 KB
/
tr_world.cpp
File metadata and controls
882 lines (729 loc) · 18.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
Copyright (C) 2006-2008 Robert Beckebans <trebor_7@users.sourceforge.net>
This file is part of Daemon source code.
Daemon source code 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.
Daemon source code 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 Daemon source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// tr_world.c
#include "tr_local.h"
#include "gl_shader.h"
#include "Material.h"
static Cvar::Modified<Cvar::Cvar<bool>> r_showCluster(
"r_showCluster", "print PVS cluster at current location", Cvar::CHEAT, false );
/*
================
R_CullSurface
Tries to back face cull surfaces before they are lighted or
added to the sorting list.
This will also allow mirrors on both sides of a model without recursion.
================
*/
static bool R_CullSurface( surfaceType_t *surface, shader_t *shader, int planeBits )
{
srfGeneric_t *gen;
float d;
// allow culling to be disabled
if ( r_nocull->integer )
{
return false;
}
// ydnar: made surface culling generic, inline with q3map2 surface classification
if ( *surface == surfaceType_t::SF_GRID && r_nocurves->integer )
{
return true;
}
if ( *surface != surfaceType_t::SF_FACE && *surface != surfaceType_t::SF_TRIANGLES && *surface != surfaceType_t::SF_VBO_MESH && *surface != surfaceType_t::SF_GRID )
{
return true;
}
// get generic surface
gen = ( srfGeneric_t* ) surface;
// plane cull
if ( *surface == surfaceType_t::SF_FACE && r_facePlaneCull->integer )
{
srfGeneric_t* srf = ( srfGeneric_t* ) gen;
d = DotProduct( tr.orientation.viewOrigin, srf->plane.normal ) - srf->plane.dist;
// don't cull exactly on the plane, because there are levels of rounding
// through the BSP, ICD, and hardware that may cause pixel gaps if an
// epsilon isn't allowed here
if ( shader->cullType == CT_FRONT_SIDED )
{
if ( d < -8.0f )
{
tr.pc.c_plane_cull_out++;
return true;
}
}
else if ( shader->cullType == CT_BACK_SIDED )
{
if ( d > 8.0f )
{
tr.pc.c_plane_cull_out++;
return true;
}
}
tr.pc.c_plane_cull_in++;
}
if ( planeBits )
{
cullResult_t cull;
if ( tr.currentEntity != &tr.worldEntity )
{
cull = R_CullLocalBox( gen->bounds );
}
else
{
cull = R_CullBox( gen->bounds );
}
if ( cull == CULL_OUT )
{
tr.pc.c_box_cull_out++;
return true;
}
else if ( cull == CULL_CLIP )
{
tr.pc.c_box_cull_clip++;
}
else
{
tr.pc.c_box_cull_in++;
}
}
// must be visible
return false;
}
static bool R_CullLightSurface( surfaceType_t *surface, shader_t *shader, trRefLight_t *light, byte *cubeSideBits )
{
srfGeneric_t *gen;
float d;
// allow culling to be disabled
if ( r_nocull->integer )
{
return false;
}
// ydnar: made surface culling generic, inline with q3map2 surface classification
if ( *surface == surfaceType_t::SF_GRID && r_nocurves->integer )
{
return true;
}
if ( *surface != surfaceType_t::SF_FACE && *surface != surfaceType_t::SF_TRIANGLES && *surface != surfaceType_t::SF_VBO_MESH && *surface != surfaceType_t::SF_GRID )
{
return true;
}
gen = ( srfGeneric_t * ) surface;
// do a quick AABB cull
if ( !BoundsIntersect( light->worldBounds[ 0 ], light->worldBounds[ 1 ], gen->bounds[ 0 ], gen->bounds[ 1 ] ) )
{
return true;
}
// do a more expensive and precise light frustum cull
if ( !r_noLightFrustums->integer )
{
if ( R_CullLightWorldBounds( light, gen->bounds ) == CULL_OUT )
{
return true;
}
}
// plane cull
if ( *surface == surfaceType_t::SF_FACE && r_facePlaneCull->integer )
{
srfGeneric_t* srf = ( srfGeneric_t* ) gen;
if ( light->l.rlType == refLightType_t::RL_DIRECTIONAL )
{
d = DotProduct( tr.sunDirection, srf->plane.normal );
}
else
{
d = DotProduct( light->origin, srf->plane.normal ) - srf->plane.dist;
}
// don't cull exactly on the plane, because there are levels of rounding
// through the BSP, ICD, and hardware that may cause pixel gaps if an
// epsilon isn't allowed here
if ( shader->cullType == CT_FRONT_SIDED )
{
if ( d < -8.0f )
{
return true;
}
}
else if ( shader->cullType == CT_BACK_SIDED )
{
if ( d > 8.0f )
{
return true;
}
}
}
if ( r_cullShadowPyramidFaces->integer )
{
*cubeSideBits = R_CalcLightCubeSideBits( light, gen->bounds );
}
return false;
}
/*
======================
R_AddInteractionSurface
======================
*/
static void R_AddInteractionSurface( bspSurface_t *surf, trRefLight_t *light, int interactionBits )
{
byte cubeSideBits = CUBESIDE_CLIPALL;
bool firstAddition = false;
int bits;
if ( surf->lightCount != tr.lightCount )
{
surf->interactionBits = 0;
surf->lightCount = tr.lightCount;
firstAddition = true;
}
// only add interactions we haven't already added
bits = interactionBits & ~surf->interactionBits;
if ( !bits )
{
// already added these interactions
return;
}
surf->interactionBits |= bits;
// skip all surfaces that don't matter for lighting only pass
if ( surf->shader->isSky || ( !surf->shader->interactLight && surf->shader->noShadows ) )
{
return;
}
if ( R_CullLightSurface( surf->data, surf->shader, light, &cubeSideBits ) )
{
if ( firstAddition )
{
tr.pc.c_dlightSurfacesCulled++;
}
return;
}
R_AddLightInteraction( light, surf->data, surf->shader, cubeSideBits, ( interactionType_t ) bits );
if ( firstAddition )
{
tr.pc.c_dlightSurfaces++;
}
}
/*
======================
R_AddWorldSurface
======================
*/
static bool R_AddWorldSurface( bspSurface_t *surf, int fogIndex, int portalNum, int planeBits )
{
if ( surf->viewCount == tr.viewCountNoReset )
{
return false; // already in this view
}
surf->viewCount = tr.viewCountNoReset;
// try to cull before lighting or adding
if ( R_CullSurface( surf->data, surf->shader, planeBits ) )
{
return true;
}
R_AddDrawSurf( surf->data, surf->shader, surf->lightmapNum, fogIndex, true, portalNum );
return true;
}
/*
=============================================================
BRUSH MODELS
=============================================================
*/
/*
=================
R_AddBSPModelSurfaces
=================
*/
void R_AddBSPModelSurfaces( trRefEntity_t *ent )
{
bspModel_t *bspModel;
model_t *pModel;
unsigned int i;
vec3_t boundsCenter;
int fogNum;
pModel = R_GetModelByHandle( ent->e.hModel );
bspModel = pModel->bsp;
// copy local bounds
for ( i = 0; i < 3; i++ )
{
ent->localBounds[ 0 ][ i ] = bspModel->bounds[ 0 ][ i ];
ent->localBounds[ 1 ][ i ] = bspModel->bounds[ 1 ][ i ];
}
R_SetupEntityWorldBounds(ent);
VectorAdd( ent->worldBounds[ 0 ], ent->worldBounds[ 1 ], boundsCenter );
VectorScale( boundsCenter, 0.5f, boundsCenter );
ent->cull = R_CullBox( ent->worldBounds );
if ( ent->cull == CULL_OUT )
{
return;
}
fogNum = R_FogWorldBox( ent->worldBounds );
for ( i = 0; i < bspModel->numSurfaces; i++ )
{
R_AddWorldSurface( bspModel->firstSurface + i, fogNum, -1, FRUSTUM_CLIPALL );
}
}
/*
=============================================================
WORLD MODEL
=============================================================
*/
static void R_AddLeafSurfaces( bspNode_t *node, int planeBits )
{
int c;
bspSurface_t **mark;
bspSurface_t **view;
tr.pc.c_leafs++;
// add to z buffer bounds
if ( node->mins[ 0 ] < tr.viewParms.visBounds[ 0 ][ 0 ] )
{
tr.viewParms.visBounds[ 0 ][ 0 ] = node->mins[ 0 ];
}
if ( node->mins[ 1 ] < tr.viewParms.visBounds[ 0 ][ 1 ] )
{
tr.viewParms.visBounds[ 0 ][ 1 ] = node->mins[ 1 ];
}
if ( node->mins[ 2 ] < tr.viewParms.visBounds[ 0 ][ 2 ] )
{
tr.viewParms.visBounds[ 0 ][ 2 ] = node->mins[ 2 ];
}
if ( node->maxs[ 0 ] > tr.viewParms.visBounds[ 1 ][ 0 ] )
{
tr.viewParms.visBounds[ 1 ][ 0 ] = node->maxs[ 0 ];
}
if ( node->maxs[ 1 ] > tr.viewParms.visBounds[ 1 ][ 1 ] )
{
tr.viewParms.visBounds[ 1 ][ 1 ] = node->maxs[ 1 ];
}
if ( node->maxs[ 2 ] > tr.viewParms.visBounds[ 1 ][ 2 ] )
{
tr.viewParms.visBounds[ 1 ][ 2 ] = node->maxs[ 2 ];
}
// add the individual surfaces
mark = tr.world->markSurfaces + node->firstMarkSurface;
c = node->numMarkSurfaces;
view = tr.world->viewSurfaces + node->firstMarkSurface;
while ( c-- )
{
// the surface may have already been added if it
// spans multiple leafs
R_AddWorldSurface( *view, ( *view )->fogIndex, ( *mark )->portalNum, planeBits);
( *mark )->viewCount = tr.viewCountNoReset;
mark++;
view++;
}
}
/*
================
R_RecursiveWorldNode
================
*/
static void R_RecursiveWorldNode( bspNode_t *node, int planeBits )
{
do
{
// if the node wasn't marked as potentially visible, exit
if ( node->visCounts[ tr.visIndex ] != tr.visCounts[ tr.visIndex ] )
{
return;
}
if ( node->contents != -1 && !node->numMarkSurfaces )
{
// don't waste time dealing with this empty leaf
return;
}
// if the bounding volume is outside the frustum, nothing
// inside can be visible
if ( !r_nocull->integer )
{
int i;
int r;
for ( i = 0; i < FRUSTUM_PLANES; i++ )
{
if ( planeBits & ( 1 << i ) )
{
r = BoxOnPlaneSide( node->mins, node->maxs, &tr.viewParms.frustums[ 0 ][ i ] );
if ( r == 2 )
{
return; // culled
}
if ( r == 1 )
{
planeBits &= ~( 1 << i ); // all descendants will also be in front
}
}
}
}
backEndData[ tr.smpFrame ]->traversalList[ backEndData[ tr.smpFrame ]->traversalLength++ ] = node;
if ( node->contents != -1 )
{
break;
}
float d = DotProduct(tr.viewParms.orientation.viewOrigin, node->plane->normal) - node->plane->dist;
uint32_t side = d <= 0;
// recurse down the children, front side first
R_RecursiveWorldNode( node->children[ side ], planeBits );
// tail recurse
node = node->children[ side ^ 1 ];
}
while ( true );
if ( node->numMarkSurfaces )
{
// ydnar: moved off to separate function
R_AddLeafSurfaces( node, planeBits );
}
}
/*
================
R_RecursiveInteractionNode
================
*/
static void R_RecursiveInteractionNode( bspNode_t *node, trRefLight_t *light, int planeBits, int interactionBits )
{
int i;
int r;
do
{
// surfaces that arn't potentially visible may still cast shadows
// but we don't bother lighting them since there will be no visible effect
if ( node->visCounts[ tr.visIndex ] != tr.visCounts[ tr.visIndex ] )
{
interactionBits &= ~IA_LIGHT;
}
// if the bounding volume is outside the frustum, nothing
// inside can be visible OPTIMIZE: don't do this all the way to leafs?
// Tr3B - even surfaces that belong to nodes that are outside of the view frustum
// can cast shadows into the view frustum
if ( !r_nocull->integer )
{
for ( i = 0; i < FRUSTUM_PLANES; i++ )
{
if ( planeBits & ( 1 << i ) )
{
r = BoxOnPlaneSide( node->mins, node->maxs, &tr.viewParms.frustums[ 0 ][ i ] );
if ( r == 2 )
{
// this node cannot be lighted, but may cast shadows
interactionBits &= ~IA_LIGHT;
break;
}
if ( r == 1 )
{
planeBits &= ~( 1 << i ); // all descendants will also be in front
}
}
}
}
// don't waste time on nodes with no interactions
if ( !interactionBits )
{
return;
}
if ( node->contents != -1 )
{
break;
}
// node is just a decision point, so go down both sides
// since we don't care about sort orders, just go positive to negative
r = BoxOnPlaneSide( light->worldBounds[ 0 ], light->worldBounds[ 1 ], node->plane );
switch ( r )
{
case 1:
node = node->children[ 0 ];
break;
case 2:
node = node->children[ 1 ];
break;
case 3:
default:
// recurse down the children, front side first
R_RecursiveInteractionNode( node->children[ 0 ], light, planeBits, interactionBits );
// tail recurse
node = node->children[ 1 ];
break;
}
}
while ( true );
{
// leaf node, so add mark surfaces
int c;
bspSurface_t *surf, **mark;
// add the individual surfaces
mark = tr.world->markSurfaces + node->firstMarkSurface;
c = node->numMarkSurfaces;
while ( c-- )
{
// the surface may have already been added if it
// spans multiple leafs
surf = *mark;
R_AddInteractionSurface( surf, light, interactionBits );
mark++;
}
}
}
/*
===============
R_PointInLeaf
===============
*/
bspNode_t *R_PointInLeaf( const vec3_t p )
{
bspNode_t *node;
float d;
cplane_t *plane;
if ( !tr.world )
{
Sys::Drop( "R_PointInLeaf: bad model" );
}
node = tr.world->nodes;
while ( true )
{
if ( node->contents != -1 )
{
break;
}
plane = node->plane;
d = DotProduct( p, plane->normal ) - plane->dist;
if ( d > 0 )
{
node = node->children[ 0 ];
}
else
{
node = node->children[ 1 ];
}
}
return node;
}
/*
==============
R_ClusterPVS
==============
*/
const byte *R_ClusterPVS( int cluster )
{
if ( !tr.world || !tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters )
{
return tr.world->novis;
}
return tr.world->vis + cluster * tr.world->clusterBytes;
}
/*
==============
R_ClusterPVVS
==============
*/
static const byte *R_ClusterPVVS( int cluster )
{
if ( !tr.world || !tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters )
{
return tr.world->novis;
}
return tr.world->visvis + cluster * tr.world->clusterBytes;
}
/*
=================
R_inPVS
=================
*/
bool R_inPVS( const vec3_t p1, const vec3_t p2 )
{
bspNode_t *leaf;
const byte *vis;
leaf = R_PointInLeaf( p1 );
vis = R_ClusterPVS( leaf->cluster );
leaf = R_PointInLeaf( p2 );
if ( !( vis[ leaf->cluster >> 3 ] & ( 1 << ( leaf->cluster & 7 ) ) ) )
{
return false;
}
return true;
}
/*
=================
R_inPVVS
=================
*/
bool R_inPVVS( const vec3_t p1, const vec3_t p2 )
{
bspNode_t *leaf;
const byte *vis;
leaf = R_PointInLeaf( p1 );
vis = R_ClusterPVVS( leaf->cluster );
leaf = R_PointInLeaf( p2 );
if ( !( vis[ leaf->cluster >> 3 ] & ( 1 << ( leaf->cluster & 7 ) ) ) )
{
return false;
}
return true;
}
/*
===============
R_MarkLeaves
Mark the leaves and nodes that are in the PVS for the current
cluster
===============
*/
static void R_MarkLeaves()
{
const byte *vis;
bspNode_t *leaf, *parent;
int i;
int cluster;
// lockpvs lets designers walk around to determine the
// extent of the current pvs
if ( r_lockpvs->integer )
{
return;
}
// current viewcluster
leaf = R_PointInLeaf( tr.viewParms.pvsOrigin );
cluster = leaf->cluster;
bool showClusterModified = !!r_showCluster.GetModifiedValue();
// if the cluster is the same and the area visibility matrix
// hasn't changed, we don't need to mark everything again
if( tr.refdef.areamaskModified ) {
// remark ALL cached visClusters
for ( i = 0; i < MAX_VISCOUNTS; i++ ) {
tr.visClusters[ i ] = -1;
}
tr.visIndex = 0;
} else {
for ( i = 0; i < MAX_VISCOUNTS; i++ ) {
if ( tr.visClusters[ i ] == cluster ) {
// if r_showcluster was just turned on, remark everything
if ( !showClusterModified )
{
if ( tr.visClusters[ i ] != tr.visClusters[ tr.visIndex ] && r_showCluster.Get() )
{
Log::Notice("found cluster:%i area:%i index:%i", cluster, leaf->area, i );
}
tr.visIndex = i;
return;
}
}
}
tr.visIndex = ( tr.visIndex + 1 ) % MAX_VISCOUNTS;
}
tr.visClusters[ tr.visIndex ] = cluster;
tr.visCounts[ tr.visIndex ]++;
if ( r_showCluster.Get() )
{
Log::Notice("update cluster:%i area:%i index:%i", cluster, leaf->area, tr.visIndex );
}
if ( r_novis->integer || tr.visClusters[ tr.visIndex ] == -1 )
{
for ( i = 0; i < tr.world->numnodes; i++ )
{
if ( tr.world->nodes[ i ].contents != CONTENTS_SOLID )
{
tr.world->nodes[ i ].visCounts[ tr.visIndex ] = tr.visCounts[ tr.visIndex ];
}
}
return;
}
vis = R_ClusterPVS( tr.visClusters[ tr.visIndex ] );
for ( i = 0, leaf = tr.world->nodes; i < tr.world->numnodes; i++, leaf++ )
{
if ( tr.world->vis )
{
cluster = leaf->cluster;
if ( cluster >= 0 && cluster < tr.world->numClusters )
{
// check general pvs
if ( !( vis[ cluster >> 3 ] & ( 1 << ( cluster & 7 ) ) ) )
{
continue;
}
}
}
// check if outside map
if (leaf->area == -1) {
// can't be visible
continue;
}
// check for door connection
if ( ( tr.refdef.areamask[ leaf->area >> 3 ] & ( 1 << ( leaf->area & 7 ) ) ) )
{
// not visible
continue;
}
parent = leaf;
do
{
if ( parent->visCounts[ tr.visIndex ] == tr.visCounts[ tr.visIndex ] )
{
break;
}
parent->visCounts[ tr.visIndex ] = tr.visCounts[ tr.visIndex ];
parent = parent->parent;
}
while ( parent );
}
}
/*
=============
R_AddWorldSurfaces
=============
*/
void R_AddWorldSurfaces()
{
if ( !r_drawworld->integer )
{
return;
}
if ( tr.refdef.rdflags & RDF_NOWORLDMODEL )
{
return;
}
tr.currentEntity = &tr.worldEntity;
// clear out the visible min/max
ClearBounds( tr.viewParms.visBounds[ 0 ], tr.viewParms.visBounds[ 1 ] );
// determine which leaves are in the PVS / areamask
R_MarkLeaves();
// clear traversal list
backEndData[ tr.smpFrame ]->traversalLength = 0;
// update visbounds and add surfaces that weren't cached with VBOs
R_RecursiveWorldNode( tr.world->nodes, FRUSTUM_CLIPALL );
}
/*
=============
R_AddWorldInteractions
=============
*/
void R_AddWorldInteractions( trRefLight_t *light )
{
int interactionBits;
if ( !r_drawworld->integer )
{
return;
}
if ( tr.refdef.rdflags & RDF_NOWORLDMODEL )
{
return;
}
tr.currentEntity = &tr.worldEntity;
// perform frustum culling and add all the potentially visible surfaces
tr.lightCount++;
interactionBits = IA_DEFAULT;
if ( light->restrictInteractionFirst >= 0 )
{
interactionBits = IA_DEFAULTCLIP;
}
if ( !glConfig2.shadowMapping || light->l.noShadows )
{
interactionBits &= IA_LIGHT;
}
R_RecursiveInteractionNode( tr.world->nodes, light, FRUSTUM_CLIPALL, interactionBits );
}