*/
-typedef enum modtype_e {mod_invalid, mod_brushq1, mod_sprite, mod_alias, mod_brushq2, mod_brushq3, mod_obj, mod_null} modtype_t;
+typedef enum modtype_e {mod_invalid, mod_brushq1, mod_sprite, mod_alias, mod_brushq2, mod_brushq3, mod_brushhl2, mod_obj, mod_null} modtype_t;
typedef struct animscene_s
{
msurface_lightmapinfo_t;
struct q3deffect_s;
+
+/// <summary>
+/// describes the textures to use on a range of triangles in the model, and mins/maxs (AABB) for culling.
+/// </summary>
typedef struct msurface_s
{
- // bounding box for onscreen checks
- vec3_t mins;
- vec3_t maxs;
- // the texture to use on the surface
+ /// range of triangles and vertices in model->surfmesh
+ int num_triangles; // triangles
+ int num_firsttriangle; // first element is this *3
+ int num_vertices; // length of the range referenced by elements
+ int num_firstvertex; // min vertex referenced by elements
+
+ /// the texture to use on the surface
texture_t *texture;
- // the lightmap texture fragment to use on the rendering mesh
+ /// the lightmap texture fragment to use on the rendering mesh
struct rtexture_s *lightmaptexture;
- // the lighting direction texture fragment to use on the rendering mesh
+ /// the lighting direction texture fragment to use on the rendering mesh
struct rtexture_s *deluxemaptexture;
- // lightmaptexture rebuild information not used in q3bsp
- msurface_lightmapinfo_t *lightmapinfo; // q1bsp
- // fog volume info in q3bsp
- struct q3deffect_s *effect; // q3bsp
- // mesh information for collisions (only used by q3bsp curves)
- int num_firstcollisiontriangle;
-
- // surfaces own ranges of vertices and triangles in the model->surfmesh
- int num_triangles; // number of triangles
- int num_firsttriangle; // first triangle
- int num_vertices; // number of vertices
- int num_firstvertex; // first vertex
-
- // mesh information for collisions (only used by q3bsp curves)
- int num_collisiontriangles; // q3bsp
- int num_collisionvertices; // q3bsp
+
+ // the following fields are used situationally and are not part of rendering in typical usage
+
+ /// bounding box for onscreen checks
+ vec3_t mins;
+ vec3_t maxs;
+
+ /// lightmaptexture rebuild information not used in q3bsp
+ msurface_lightmapinfo_t* lightmapinfo; // q1bsp
+ /// fog volume info in q3bsp
+ struct q3deffect_s* effect; // q3bsp
+
+ /// mesh information for collisions (only used by q3bsp curves)
+ int num_firstcollisiontriangle; // q3bsp only
+ int num_collisiontriangles; // number of triangles (if surface has collisions enabled)
+ int num_collisionvertices; // number of vertices referenced by collision triangles (if surface has collisions enabled)
// used by Mod_Mesh_Finalize when building sortedmodelsurfaces
qbool included;
#include "model_q1bsp.h"
#include "model_q2bsp.h"
#include "model_q3bsp.h"
+#include "model_vbsp.h"
#include "model_sprite.h"
#include "model_alias.h"
animscene_t *skinscenes; // [numskins]
// skin animation info
animscene_t *animscenes; // [numframes]
- // range of surface numbers in this (sub)model
- int firstmodelsurface;
- int nummodelsurfaces;
- int *sortedmodelsurfaces;
+ // range of surface numbers in this model
+ int submodelsurfaces_start;
+ int submodelsurfaces_end;
+ /// surface indices of model in an optimal draw order (submodelindex -> texture -> lightmap -> index)
+ int *modelsurfaces_sorted; // same size as num_surfaces
// range of collision brush numbers in this (sub)model
int firstmodelbrush;
int nummodelbrushes;
const char *modeldatatypestring;
// generates vertex data for a given frameblend
void(*AnimateVertices)(const struct model_s * RESTRICT model, const struct frameblend_s * RESTRICT frameblend, const struct skeleton_s *skeleton, float * RESTRICT vertex3f, float * RESTRICT normal3f, float * RESTRICT svector3f, float * RESTRICT tvector3f);
- // draw the model's sky polygons (only used by brush models)
+ // draw the model's sky polygons
void(*DrawSky)(struct entity_render_s *ent);
- // draw refraction/reflection textures for the model's water polygons (only used by brush models)
+ // draw refraction/reflection textures for the model's water polygons
void(*DrawAddWaterPlanes)(struct entity_render_s *ent);
// draw the model using lightmap/dlight shading
void(*Draw)(struct entity_render_s *ent);
// automatically called after model loader returns
void Mod_BuildVBOs(void);
+/// Sets the mod->DrawSky and mod->DrawAddWaterPlanes pointers conditionally based on whether surfaces in this submodel use these features
+/// called specifically by brush model loaders when generating submodels
+/// automatically called after model loader returns
+void Mod_SetDrawSkyAndWater(model_t* mod);
+
shadowmesh_t *Mod_ShadowMesh_Alloc(struct mempool_s *mempool, int maxverts, int maxtriangles);
int Mod_ShadowMesh_AddVertex(shadowmesh_t *mesh, const float *vertex3f);
void Mod_ShadowMesh_AddMesh(shadowmesh_t *mesh, const float *vertex3f, int numtris, const int *element3i);
void Mod_HLBSP_Load(model_t *mod, void *buffer, void *bufferend);
void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend);
void Mod_IBSP_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_VBSP_Load(model_t *mod, void *buffer, void *bufferend);
void Mod_MAP_Load(model_t *mod, void *buffer, void *bufferend);
void Mod_OBJ_Load(model_t *mod, void *buffer, void *bufferend);
void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend);