1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19 
20 //
21 // rf_public.h
22 //
23 
24 /*
25 =============================================================================
26 
27 	MESH BUFFERING
28 
29 =============================================================================
30 */
31 
32 #define MAX_MESH_BUFFER			8192
33 #define MAX_ADDITIVE_BUFFER		8192
34 #define MAX_POSTPROC_BUFFER		64
35 
36 #define MAX_MESH_KEYS			(SHADER_SORT_OPAQUE+1)
37 #define MAX_ADDITIVE_KEYS		(SHADER_SORT_NEAREST-SHADER_SORT_OPAQUE)
38 
39 enum { // meshFeatures_t
40 	MF_NONBATCHED		= 1 << 0,
41 	MF_NORMALS			= 1 << 1,
42 	MF_STCOORDS			= 1 << 2,
43 	MF_LMCOORDS			= 1 << 3,
44 	MF_COLORS			= 1 << 4,
45 	MF_TRNORMALS		= 1 << 5,
46 	MF_NOCULL			= 1 << 6,
47 	MF_DEFORMVS			= 1 << 7,
48 	MF_STVECTORS		= 1 << 8,
49 	MF_TRIFAN			= 1 << 9,
50 	MF_STATIC_MESH		= 1 << 10,
51 };
52 
53 enum { // meshType_t
54 	MBT_2D,
55 	MBT_ALIAS,
56 	MBT_DECAL,
57 	MBT_POLY,
58 	MBT_Q2BSP,
59 	MBT_Q3BSP,
60 	MBT_Q3BSP_FLARE,
61 	MBT_SKY,
62 	MBT_SP2,
63 
64 	MBT_MAX				= 16
65 };
66 
67 typedef struct mesh_s {
68 	int						numIndexes;
69 	int						numVerts;
70 
71 	bvec4_t					*colorArray;
72 	vec2_t					*coordArray;
73 	vec2_t					*lmCoordArray;
74 	index_t					*indexArray;
75 	vec3_t					*normalsArray;
76 	vec3_t					*sVectorsArray;
77 	vec3_t					*tVectorsArray;
78 	index_t					*trNeighborsArray;
79 	vec3_t					*trNormalsArray;
80 	vec3_t					*vertexArray;
81 } mesh_t;
82 
83 typedef struct meshBuffer_s {
84 	uint32					sortKey;
85 	float					shaderTime;
86 
87 	refEntity_t				*entity;
88 	shader_t				*shader;
89 	struct mQ3BspFog_s		*fog;
90 	void					*mesh;
91 } meshBuffer_t;
92 
93 typedef struct meshList_s {
94 	qBool					skyDrawn;
95 	float					skyMins[6][2];
96 	float					skyMaxs[6][2];
97 
98 	int						numMeshes[MAX_MESH_KEYS];
99 	meshBuffer_t			meshBuffer[MAX_MESH_KEYS][MAX_MESH_BUFFER];
100 
101 	int						numAdditiveMeshes[MAX_ADDITIVE_KEYS];
102 	meshBuffer_t			meshBufferAdditive[MAX_ADDITIVE_KEYS][MAX_ADDITIVE_BUFFER];
103 
104 	int						numPostProcessMeshes;
105 	meshBuffer_t			meshBufferPostProcess[MAX_POSTPROC_BUFFER];
106 } meshList_t;
107 
108 extern meshList_t	r_portalList;
109 extern meshList_t	r_worldList;
110 extern meshList_t	*r_currentList;
111 
112 void	R_SortMeshList (void);
113 void	R_DrawMeshList (qBool triangleOutlines);
114 void	R_DrawMeshOutlines (void);
115