forked from id-Software/Enemy-Territory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtr_local.h
2153 lines (1636 loc) · 63.1 KB
/
tr_local.h
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
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
===========================================================================
Wolfenstein: Enemy Territory GPL Source Code
Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company.
This file is part of the Wolfenstein: Enemy Territory GPL Source Code (Wolf ET Source Code).
Wolf ET 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 3 of the License, or
(at your option) any later version.
Wolf ET 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 Wolf ET Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Wolf: ET Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Wolf ET Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef TR_LOCAL_H
#define TR_LOCAL_H
#include "../game/q_shared.h"
#include "../qcommon/qfiles.h"
#include "../qcommon/qcommon.h"
#include "tr_public.h"
#include "qgl.h"
#define GL_INDEX_TYPE GL_UNSIGNED_INT
typedef unsigned int glIndex_t;
// everything that is needed by the backend needs
// to be double buffered to allow it to run in
// parallel on a dual cpu machine
#define SMP_FRAMES 2
#define MAX_SHADERS 8192
#define MAX_SHADER_STATES 2048
#define MAX_STATES_PER_SHADER 32
#define MAX_STATE_NAME 32
// can't be increased without changing bit packing for drawsurfs
// a trRefEntity_t has all the information passed in by
// the client game, as well as some locally derived info
// ydnar: optimizing diffuse lighting calculation with a table lookup
#define ENTITY_LIGHT_STEPS 16
typedef struct {
refEntity_t e;
float axisLength; // compensate for non-normalized axis
qboolean needDlights; // true for bmodels that touch a dlight
qboolean lightingCalculated;
vec3_t lightDir; // normalized direction towards light
vec3_t ambientLight; // color normalized to 0-255
int ambientLightInt; // 32 bit rgba packed
vec3_t directedLight;
int entityLightInt[ ENTITY_LIGHT_STEPS ];
float brightness;
} trRefEntity_t;
typedef struct {
vec3_t origin; // in world coordinates
vec3_t axis[3]; // orientation in world
vec3_t viewOrigin; // viewParms->or.origin in local coordinates
float modelMatrix[16];
} orientationr_t;
typedef struct image_s {
char imgName[MAX_QPATH]; // game path, including extension
int width, height; // source image
int uploadWidth, uploadHeight; // after power of two and picmip but not including clamp to MAX_TEXTURE_SIZE
GLuint texnum; // gl texture binding
int frameUsed; // for texture usage in frame statistics
int internalFormat;
int TMU; // only needed for voodoo2
qboolean mipmap;
qboolean allowPicmip;
int wrapClampMode; // GL_CLAMP or GL_REPEAT
int hash; // for fast building of the backupHash
struct image_s* next;
} image_t;
//===============================================================================
typedef enum {
SS_BAD,
SS_PORTAL, // mirrors, portals, viewscreens
SS_ENVIRONMENT, // sky box
SS_OPAQUE, // opaque
SS_DECAL, // scorch marks, etc.
SS_SEE_THROUGH, // ladders, grates, grills that may have small blended edges
// in addition to alpha test
SS_BANNER,
SS_FOG,
SS_UNDERWATER, // for items that should be drawn in front of the water plane
SS_BLEND0, // regular transparency and filters
SS_BLEND1, // generally only used for additive type effects
SS_BLEND2,
SS_BLEND3,
SS_BLEND6,
SS_STENCIL_SHADOW,
SS_ALMOST_NEAREST, // gun smoke puffs
SS_NEAREST // blood blobs
} shaderSort_t;
#define MAX_SHADER_STAGES 8
typedef enum {
GF_NONE,
GF_SIN,
GF_SQUARE,
GF_TRIANGLE,
GF_SAWTOOTH,
GF_INVERSE_SAWTOOTH,
GF_NOISE
} genFunc_t;
typedef enum {
DEFORM_NONE,
DEFORM_WAVE,
DEFORM_NORMALS,
DEFORM_BULGE,
DEFORM_MOVE,
DEFORM_PROJECTION_SHADOW,
DEFORM_AUTOSPRITE,
DEFORM_AUTOSPRITE2,
DEFORM_TEXT0,
DEFORM_TEXT1,
DEFORM_TEXT2,
DEFORM_TEXT3,
DEFORM_TEXT4,
DEFORM_TEXT5,
DEFORM_TEXT6,
DEFORM_TEXT7
} deform_t;
typedef enum {
AGEN_IDENTITY,
AGEN_SKIP,
AGEN_ENTITY,
AGEN_ONE_MINUS_ENTITY,
AGEN_NORMALZFADE, // Ridah
AGEN_VERTEX,
AGEN_ONE_MINUS_VERTEX,
AGEN_LIGHTING_SPECULAR,
AGEN_WAVEFORM,
AGEN_PORTAL,
AGEN_CONST
} alphaGen_t;
typedef enum {
CGEN_BAD,
CGEN_IDENTITY_LIGHTING, // tr.identityLight
CGEN_IDENTITY, // always (1,1,1,1)
CGEN_ENTITY, // grabbed from entity's modulate field
CGEN_ONE_MINUS_ENTITY, // grabbed from 1 - entity.modulate
CGEN_EXACT_VERTEX, // tess.vertexColors
CGEN_VERTEX, // tess.vertexColors * tr.identityLight
CGEN_ONE_MINUS_VERTEX,
CGEN_WAVEFORM, // programmatically generated
CGEN_LIGHTING_DIFFUSE,
CGEN_FOG, // standard fog
CGEN_CONST // fixed color
} colorGen_t;
typedef enum {
TCGEN_BAD,
TCGEN_IDENTITY, // clear to 0,0
TCGEN_LIGHTMAP,
TCGEN_TEXTURE,
TCGEN_ENVIRONMENT_MAPPED,
TCGEN_FIRERISEENV_MAPPED,
TCGEN_FOG,
TCGEN_VECTOR // S and T from world coordinates
} texCoordGen_t;
typedef enum {
ACFF_NONE,
ACFF_MODULATE_RGB,
ACFF_MODULATE_RGBA,
ACFF_MODULATE_ALPHA
} acff_t;
typedef struct {
genFunc_t func;
float base;
float amplitude;
float phase;
float frequency;
} waveForm_t;
#define TR_MAX_TEXMODS 4
typedef enum {
TMOD_NONE,
TMOD_TRANSFORM,
TMOD_TURBULENT,
TMOD_SCROLL,
TMOD_SCALE,
TMOD_STRETCH,
TMOD_ROTATE,
TMOD_ENTITY_TRANSLATE,
TMOD_SWAP
} texMod_t;
#define MAX_SHADER_DEFORMS 3
typedef struct {
deform_t deformation; // vertex coordinate modification type
vec3_t moveVector;
waveForm_t deformationWave;
float deformationSpread;
float bulgeWidth;
float bulgeHeight;
float bulgeSpeed;
} deformStage_t;
typedef struct {
texMod_t type;
// used for TMOD_TURBULENT and TMOD_STRETCH
waveForm_t wave;
// used for TMOD_TRANSFORM
float matrix[2][2]; // s' = s * m[0][0] + t * m[1][0] + trans[0]
float translate[2]; // t' = s * m[0][1] + t * m[0][1] + trans[1]
// used for TMOD_SCALE
float scale[2]; // s *= scale[0]
// t *= scale[1]
// used for TMOD_SCROLL
float scroll[2]; // s' = s + scroll[0] * time
// t' = t + scroll[1] * time
// + = clockwise
// - = counterclockwise
float rotateSpeed;
} texModInfo_t;
// RF increased this for onfire animation
//#define MAX_IMAGE_ANIMATIONS 8
#define MAX_IMAGE_ANIMATIONS 16
// Arnout: FIXME change the is* qbooleans to a type index
typedef struct {
image_t *image[MAX_IMAGE_ANIMATIONS];
int numImageAnimations;
float imageAnimationSpeed;
texCoordGen_t tcGen;
vec3_t tcGenVectors[2];
int numTexMods;
texModInfo_t *texMods;
int videoMapHandle;
qboolean isLightmap;
qboolean isVideoMap;
} textureBundle_t;
#define NUM_TEXTURE_BUNDLES 2
typedef struct {
qboolean active;
textureBundle_t bundle[NUM_TEXTURE_BUNDLES];
waveForm_t rgbWave;
colorGen_t rgbGen;
waveForm_t alphaWave;
alphaGen_t alphaGen;
byte constantColor[4]; // for CGEN_CONST and AGEN_CONST
unsigned stateBits; // GLS_xxxx mask
acff_t adjustColorsForFog;
// Ridah
float zFadeBounds[2];
qboolean isDetail;
qboolean isFogged; // used only for shaders that have fog disabled, so we can enable it for individual stages
} shaderStage_t;
struct shaderCommands_s;
#define LIGHTMAP_2D -4 // shader is for 2D rendering
#define LIGHTMAP_BY_VERTEX -3 // pre-lit triangle models
#define LIGHTMAP_WHITEIMAGE -2
#define LIGHTMAP_NONE -1
typedef enum {
CT_FRONT_SIDED,
CT_BACK_SIDED,
CT_TWO_SIDED
} cullType_t;
typedef enum {
FP_NONE, // surface is translucent and will just be adjusted properly
FP_EQUAL, // surface is opaque but possibly alpha tested
FP_LE // surface is trnaslucent, but still needs a fog pass (fog surface)
} fogPass_t;
typedef struct {
float cloudHeight;
image_t *outerbox[6], *innerbox[6];
} skyParms_t;
typedef struct {
vec3_t color;
float depthForOpaque;
unsigned colorInt; // in packed byte format
float tcScale; // texture coordinate vector scales
} fogParms_t;
typedef struct shader_s {
char name[MAX_QPATH]; // game path, including extension
int lightmapIndex; // for a shader to match, both name and lightmapIndex must match
int index; // this shader == tr.shaders[index]
int sortedIndex; // this shader == tr.sortedShaders[sortedIndex]
float sort; // lower numbered shaders draw before higher numbered
qboolean defaultShader; // we want to return index 0 if the shader failed to
// load for some reason, but R_FindShader should
// still keep a name allocated for it, so if
// something calls RE_RegisterShader again with
// the same name, we don't try looking for it again
qboolean explicitlyDefined; // found in a .shader file
int surfaceFlags; // if explicitlyDefined, this will have SURF_* flags
int contentFlags;
qboolean entityMergable; // merge across entites optimizable (smoke, blood)
qboolean isSky;
skyParms_t sky;
fogParms_t fogParms;
float portalRange; // distance to fog out at
vec4_t distanceCull; // ydnar: opaque alpha range for foliage (inner, outer, alpha threshold, 1/(outer-inner))
int multitextureEnv; // 0, GL_MODULATE, GL_ADD (FIXME: put in stage)
cullType_t cullType; // CT_FRONT_SIDED, CT_BACK_SIDED, or CT_TWO_SIDED
qboolean polygonOffset; // set for decals and other items that must be offset
qboolean noMipMaps; // for console fonts, 2D elements, etc.
qboolean noPicMip; // for images that must always be full resolution
fogPass_t fogPass; // draw a blended pass, possibly with depth test equals
qboolean needsNormal; // not all shaders will need all data to be gathered
qboolean needsST1;
qboolean needsST2;
qboolean needsColor;
// Ridah
qboolean noFog;
int numDeforms;
deformStage_t deforms[MAX_SHADER_DEFORMS];
int numUnfoggedPasses;
shaderStage_t *stages[MAX_SHADER_STAGES];
void ( *optimalStageIteratorFunc )( void );
float clampTime; // time this shader is clamped to
float timeOffset; // current time offset for this shader
int numStates; // if non-zero this is a state shader
struct shader_s *currentShader; // current state if this is a state shader
struct shader_s *parentShader; // current state if this is a state shader
int currentState; // current state index for cycle purposes
long expireTime; // time in milliseconds this expires
struct shader_s *remappedShader; // current shader this one is remapped too
int shaderStates[MAX_STATES_PER_SHADER]; // index to valid shader states
struct shader_s *next;
} shader_t;
typedef struct corona_s {
vec3_t origin;
vec3_t color; // range from 0.0 to 1.0, should be color normalized
vec3_t transformed; // origin in local coordinate system
float scale; // uses r_flaresize as the baseline (1.0)
int id;
qboolean visible; // still send the corona request, even if not visible, for proper fading
} corona_t;
typedef struct dlight_s {
vec3_t origin;
vec3_t color; // range from 0.0 to 1.0, should be color normalized
float radius;
float radiusInverseCubed; // ydnar: attenuation optimization
float intensity; // 1.0 = fullbright, > 1.0 = overbright
shader_t *shader;
int flags;
vec3_t transformed; // origin in local coordinate system
} dlight_t;
// ydnar: decal projection
typedef struct decalProjector_s
{
shader_t *shader;
byte color[ 4 ];
int fadeStartTime, fadeEndTime;
vec3_t mins, maxs;
vec3_t center;
float radius, radius2;
qboolean omnidirectional;
int numPlanes; // either 5 or 6, for quad or triangle projectors
vec4_t planes[ 6 ];
vec4_t texMat[ 3 ][ 2 ];
}
decalProjector_t;
// trRefdef_t holds everything that comes in refdef_t,
// as well as the locally generated scene information
typedef struct {
int x, y, width, height;
float fov_x, fov_y;
vec3_t vieworg;
vec3_t viewaxis[3]; // transformation matrix
int time; // time in milliseconds for shader effects and other time dependent rendering issues
int rdflags; // RDF_NOWORLDMODEL, etc
// 1 bits will prevent the associated area from rendering at all
byte areamask[MAX_MAP_AREA_BYTES];
qboolean areamaskModified; // qtrue if areamask changed since last scene
float floatTime; // tr.refdef.time / 1000.0
// text messages for deform text shaders
char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH];
int num_entities;
trRefEntity_t *entities;
int dlightBits; // ydnar: optimization
int num_dlights;
dlight_t *dlights;
int num_coronas;
corona_t *coronas;
int numPolys;
struct srfPoly_s *polys;
int numPolyBuffers;
struct srfPolyBuffer_s *polybuffers;
int decalBits; // ydnar: optimization
int numDecalProjectors;
decalProjector_t *decalProjectors;
int numDecals;
struct srfDecal_s *decals;
int numDrawSurfs;
struct drawSurf_s *drawSurfs;
} trRefdef_t;
//=================================================================================
// skins allow models to be retextured without modifying the model file
typedef struct {
char name[MAX_QPATH];
int hash;
shader_t *shader;
} skinSurface_t;
//----(SA) modified
#define MAX_PART_MODELS 5
typedef struct {
char type[MAX_QPATH]; // md3_lower, md3_lbelt, md3_rbelt, etc.
char model[MAX_QPATH]; // lower.md3, belt1.md3, etc.
int hash;
} skinModel_t;
typedef struct skin_s {
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
int numModels;
skinSurface_t *surfaces[MD3_MAX_SURFACES];
skinModel_t *models[MAX_PART_MODELS];
} skin_t;
//----(SA) end
typedef struct {
int modelNum; // ydnar: bsp model the fog belongs to
int originalBrushNumber;
vec3_t bounds[2];
shader_t *shader; // fog shader to get colorInt and tcScale from
fogParms_t parms;
// for clipping distance in fog when outside
qboolean hasSurface;
float surface[4];
} fog_t;
typedef struct {
orientationr_t orientation;
orientationr_t world;
vec3_t pvsOrigin; // may be different than or.origin for portals
qboolean isPortal; // true if this view is through a portal
qboolean isMirror; // the portal is a mirror, invert the face culling
int frameSceneNum; // copied from tr.frameSceneNum
int frameCount; // copied from tr.frameCount
cplane_t portalPlane; // clip anything behind this if mirroring
int viewportX, viewportY, viewportWidth, viewportHeight;
float fovX, fovY;
float projectionMatrix[16];
cplane_t frustum[5]; // ydnar: added farplane
vec3_t visBounds[2];
float zFar;
glfog_t glFog; // fog parameters //----(SA) added
} viewParms_t;
/*
==============================================================================
SURFACES
==============================================================================
*/
// any changes in surfaceType must be mirrored in rb_surfaceTable[]
// NOTE: also mirror changes to max2skl.c - Arnout: not anymore
typedef enum {
SF_BAD,
SF_SKIP, // ignore
SF_FACE,
SF_GRID,
SF_TRIANGLES,
SF_FOLIAGE,
SF_POLY,
SF_MD3,
SF_MDC,
SF_MDS,
SF_MDM,
SF_FLARE,
SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity
SF_DISPLAY_LIST,
SF_POLYBUFFER,
SF_DECAL, // ydnar: decal surfaces
SF_NUM_SURFACE_TYPES,
SF_MAX = 0xffffffff // ensures that sizeof( surfaceType_t ) == sizeof( int )
} surfaceType_t;
typedef struct drawSurf_s {
unsigned sort; // bit combination for fast compares
surfaceType_t *surface; // any of surface*_t
} drawSurf_t;
#define MAX_FACE_POINTS 1024
#define MAX_PATCH_SIZE 32 // max dimensions of a patch mesh in map file
#define MAX_GRID_SIZE 65 // max dimensions of a grid mesh in memory
typedef byte color4ub_t[4];
typedef struct color4ubhack_s {
color4ub_t v;
} color4ubhack_t;
typedef struct vec4hack_s {
vec4_t v;
} vec4hack_t;
typedef struct vec2hack_s {
vec2_t v;
} vec2hack_t;
// when cgame directly specifies a polygon, it becomes a srfPoly_t
// as soon as it is called
typedef struct srfPoly_s {
surfaceType_t surfaceType;
qhandle_t hShader;
int fogIndex;
int numVerts;
polyVert_t *verts;
} srfPoly_t;
typedef struct srfPolyBuffer_s {
surfaceType_t surfaceType;
int fogIndex;
polyBuffer_t* pPolyBuffer;
} srfPolyBuffer_t;
// ydnar: decals
#define MAX_DECAL_VERTS 10 // worst case is triangle clipped by 6 planes
#define MAX_WORLD_DECALS 1024
#define MAX_ENTITY_DECALS 128
typedef struct srfDecal_s
{
surfaceType_t surfaceType;
int numVerts;
polyVert_t verts[ MAX_DECAL_VERTS ];
}
srfDecal_t;
typedef struct srfDisplayList_s {
surfaceType_t surfaceType;
int listNum;
} srfDisplayList_t;
typedef struct srfFlare_s {
surfaceType_t surfaceType;
vec3_t origin;
vec3_t normal;
vec3_t color;
} srfFlare_t;
// ydnar: normal map drawsurfaces must match this header
typedef struct srfGeneric_s
{
surfaceType_t surfaceType;
// culling information
vec3_t bounds[ 2 ];
vec3_t origin;
float radius;
cplane_t plane;
// dynamic lighting information
int dlightBits[ SMP_FRAMES ];
}
srfGeneric_t;
typedef struct srfGridMesh_s
{
surfaceType_t surfaceType;
// culling information
vec3_t bounds[ 2 ];
vec3_t origin;
float radius;
cplane_t plane;
// dynamic lighting information
int dlightBits[ SMP_FRAMES ];
// lod information, which may be different
// than the culling information to allow for
// groups of curves that LOD as a unit
vec3_t lodOrigin;
float lodRadius;
int lodFixed;
int lodStitched;
// vertexes
int width, height;
float *widthLodError;
float *heightLodError;
drawVert_t verts[1]; // variable sized
} srfGridMesh_t;
#define VERTEXSIZE 8
typedef struct srfSurfaceFace_s
{
surfaceType_t surfaceType;
// culling information
vec3_t bounds[ 2 ];
vec3_t origin;
float radius;
cplane_t plane;
// dynamic lighting information
int dlightBits[ SMP_FRAMES ];
// triangle definitions (no normals at points)
int numPoints;
int numIndices;
int ofsIndices;
float points[1][VERTEXSIZE]; // variable sized
// there is a variable length list of indices here also
}
srfSurfaceFace_t;
// misc_models in maps are turned into direct geometry by q3map2 ;D
typedef struct srfTriangles_s
{
surfaceType_t surfaceType;
// culling information
vec3_t bounds[ 2 ];
vec3_t origin;
float radius;
cplane_t plane;
// dynamic lighting information
int dlightBits[ SMP_FRAMES ];
// triangle definitions
int numIndexes;
int *indexes;
int numVerts;
drawVert_t *verts;
}
srfTriangles_t;
// Gordon: Test
typedef struct srfTriangles2_s
{
surfaceType_t surfaceType;
// culling information
vec3_t bounds[ 2 ];
vec3_t origin;
float radius;
cplane_t plane;
// dynamic lighting information
int dlightBits[ SMP_FRAMES ];
// triangle definitions
int numIndexes;
int *indexes;
int numVerts;
vec4hack_t* xyz;
vec2hack_t* st;
vec2hack_t* lightmap;
vec4hack_t* normal;
color4ubhack_t* color;
} srfTriangles2_t;
//
// ydnar: foliage surfaces are autogenerated from models into geometry lists by q3map2
typedef byte fcolor4ub_t[4];
typedef struct
{
vec3_t origin;
fcolor4ub_t color;
}
foliageInstance_t;
typedef struct
{
surfaceType_t surfaceType;
// culling information
vec3_t bounds[ 2 ];
vec3_t origin;
float radius;
cplane_t plane;
// dynamic lighting information
int dlightBits[ SMP_FRAMES ];
// triangle definitions
int numIndexes;
glIndex_t *indexes;
int numVerts;
vec4_t *xyz;
vec4_t *normal;
vec2_t *texCoords;
vec2_t *lmTexCoords;
// origins
int numInstances;
foliageInstance_t *instances;
}
srfFoliage_t;
extern void( *rb_surfaceTable[SF_NUM_SURFACE_TYPES] ) ( void * );
/*
==============================================================================
BRUSH MODELS
==============================================================================
*/
//
// in memory representation
//
#define SIDE_FRONT 0
#define SIDE_BACK 1
#define SIDE_ON 2
typedef struct msurface_s {
int viewCount; // if == tr.viewCount, already added
shader_t *shader;
int fogIndex;
surfaceType_t *data; // any of srf*_t
} msurface_t;
// ydnar: bsp model decal surfaces
typedef struct decal_s
{
msurface_t *parent;
shader_t *shader;
float fadeStartTime, fadeEndTime;
int fogIndex;
int numVerts;
polyVert_t verts[ MAX_DECAL_VERTS ];
}
decal_t;
#define CONTENTS_NODE -1
typedef struct mnode_s {
// common with leaf and node
int contents; // -1 for nodes, to differentiate from leafs
int visframe; // node needs to be traversed if current
vec3_t mins, maxs; // for bounding box culling
vec3_t surfMins, surfMaxs; // ydnar: bounding box including surfaces
struct mnode_s *parent;
// node specific
cplane_t *plane;
struct mnode_s *children[2];
// leaf specific
int cluster;
int area;
msurface_t **firstmarksurface;
int nummarksurfaces;
} mnode_t;
typedef struct bmodel_s {
vec3_t bounds[ 2 ]; // for culling
msurface_t *firstSurface;
int numSurfaces;
// ydnar: decals
decal_t *decals;
// ydnar: for fog volumes
int firstBrush;
int numBrushes;
orientation_t orientation[ SMP_FRAMES ];
qboolean visible[ SMP_FRAMES ];
int entityNum[ SMP_FRAMES ];
} bmodel_t;
// ydnar: optimization
#define WORLD_MAX_SKY_NODES 32
typedef struct {
char name[MAX_QPATH]; // ie: maps/tim_dm2.bsp
char baseName[MAX_QPATH]; // ie: tim_dm2
int dataSize;
int numShaders;
dshader_t *shaders;
int numBModels;
bmodel_t *bmodels;
int numplanes;
cplane_t *planes;
int numnodes; // includes leafs
int numDecisionNodes;
mnode_t *nodes;
int numSkyNodes;
mnode_t **skyNodes; // ydnar: don't walk the entire bsp when rendering sky
int numsurfaces;
msurface_t *surfaces;
int nummarksurfaces;
msurface_t **marksurfaces;
int numfogs;
fog_t *fogs;
int globalFog; // Arnout: index of global fog
vec4_t globalOriginalFog; // Arnout: to be able to restore original global fog
vec4_t globalTransStartFog; // Arnout: start fog for switch fog transition
vec4_t globalTransEndFog; // Arnout: end fog for switch fog transition
int globalFogTransStartTime;
int globalFogTransEndTime;
vec3_t lightGridOrigin;
vec3_t lightGridSize;
vec3_t lightGridInverseSize;
int lightGridBounds[3];
byte *lightGridData;
int numClusters;
int clusterBytes;
const byte *vis; // may be passed in by CM_LoadMap to save space
byte *novis; // clusterBytes of 0xff
char *entityString;
char *entityParsePoint;
} world_t;
//======================================================================
typedef enum {
MOD_BAD,
MOD_BRUSH,
MOD_MESH,
MOD_MDS,
MOD_MDC,
MOD_MDM,
MOD_MDX
} modtype_t;
typedef union {
bmodel_t *bmodel; // only if type == MOD_BRUSH
md3Header_t *md3[MD3_MAX_LODS]; // only if type == MOD_MESH
mdsHeader_t *mds; // only if type == MOD_MDS
mdcHeader_t *mdc[MD3_MAX_LODS]; // only if type == MOD_MDC
mdmHeader_t *mdm; // only if type == MOD_MDM
mdxHeader_t *mdx; // only if type == MOD_MDX
} model_u;
typedef struct model_s {
char name[MAX_QPATH];
modtype_t type;
int index; // model = tr.models[model->index]
int dataSize; // just for listing purposes
// show_bug.cgi?id=575
model_u model;