]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_shared.h
moved pvs handling from R_Q3BSP_DrawFaces to R_WorldVisibility (now handles q1bsp...
[xonotic/darkplaces.git] / model_shared.h
index ddb6e1e0f7b2f5df4893bb43c59c46564e766713..48491afbaec0c9aabf6bbe2db5132d7087965eec 100644 (file)
@@ -73,6 +73,30 @@ typedef struct overridetagnameset_s
 }
 overridetagnameset_t;
 
+// LordHavoc: replaces glpoly, triangle mesh
+typedef struct surfmesh_s
+{
+       int num_vertices; // number of vertices in the mesh
+       int num_triangles; // number of triangles in the mesh
+       float *data_vertex3f; // float[verts*3] vertex locations
+       float *data_svector3f; // float[verts*3] direction of 'S' (right) texture axis for each vertex
+       float *data_tvector3f; // float[verts*3] direction of 'T' (down) texture axis for each vertex
+       float *data_normal3f; // float[verts*3] direction of 'R' (out) texture axis for each vertex
+       int *data_lightmapoffsets; // index into surface's lightmap samples for vertex lighting
+       float *data_texcoordtexture2f; // float[verts*2] texcoords for surface texture
+       float *data_texcoordlightmap2f; // float[verts*2] texcoords for lightmap texture
+       float *data_texcoorddetail2f; // float[verts*2] texcoords for detail texture
+       float *data_lightmapcolor4f;
+       int *data_element3i; // int[tris*3] triangles of the mesh, 3 indices into vertex arrays for each
+       int *data_neighbor3i; // int[tris*3] neighboring triangle on each edge (-1 if none)
+
+       int num_collisionvertices;
+       int num_collisiontriangles;
+       float *data_collisionvertex3f;
+       int *data_collisionelement3i;
+}
+surfmesh_t;
+
 #define SHADOWMESHVERTEXHASH 1024
 typedef struct shadowmeshvertexhash_s
 {
@@ -165,7 +189,7 @@ typedef struct model_brush_s
        //pvschain = model->brush.data_pvsclusters + mycluster * model->brush.num_pvsclusterbytes;
        //if (pvschain[thatcluster >> 3] & (1 << (thatcluster & 7)))
 
-       // a mesh containing all shadow casting geometry for the whole model (including submodels), portions of this are referenced by each surface's num_firstshadowmeshtriangle 
+       // a mesh containing all shadow casting geometry for the whole model (including submodels), portions of this are referenced by each surface's num_firstshadowmeshtriangle
        shadowmesh_t *shadowmesh;
 
        // common functions
@@ -217,10 +241,7 @@ typedef struct model_brushq1_s
 
        int                             numsurfaces;
        msurface_t              *surfaces;
-       int                             *surfacevisframes;
-       int                             *surfacepvsframes;
        msurface_t              *surfacepvsnext;
-       surfmesh_t              *entiremesh;
 
        int                             numsurfedges;
        int                             *surfedges;
@@ -251,19 +272,6 @@ typedef struct model_brushq1_s
        int                             numlights;
        mlight_t                *lights;
 
-       // pvs visibility marking
-       mleaf_t                 *pvsviewleaf;
-       int                             pvsviewleafnovis;
-       int                             pvsframecount;
-       mleaf_t                 *pvsleafchain;
-       int                             *pvssurflist;
-       int                             pvssurflistlength;
-       // these get rebuilt as the player moves around if this is the world,
-       // otherwise they are left alone (no pvs for bmodels)
-       msurface_t              ***pvstexturechains;
-       msurface_t              **pvstexturechainsbuffer;
-       int                             *pvstexturechainslength;
-
        // lightmap update chains for light styles
        int                             light_styles;
        qbyte                   *light_style;
@@ -272,7 +280,6 @@ typedef struct model_brushq1_s
        msurface_t              **light_styleupdatechainsbuffer;
 
        mleaf_t *(*PointInLeaf)(struct model_s *model, const float *p);
-       void (*BuildPVSTextureChains)(struct model_s *model);
 }
 model_brushq1_t;
 
@@ -331,6 +338,7 @@ model_brushq2_t;
 #define Q3SURFACEPARM_STRUCTURAL 8388608
 #define Q3SURFACEPARM_TRANS 16777216
 #define Q3SURFACEPARM_WATER 33554432
+#define Q3SURFACEPARM_POINTLIGHT 67108864
 
 // various flags from shaders
 #define Q3TEXTUREFLAG_TWOSIDED 1
@@ -347,7 +355,6 @@ typedef struct q3mtexture_s
        char name[Q3PATHLENGTH];
        char firstpasstexturename[Q3PATHLENGTH];
        int surfaceflags;
-       int nativecontents;
        int supercontents;
        int surfaceparms;
        int textureflags;
@@ -368,7 +375,8 @@ typedef struct q3mnode_s
        struct q3mnode_s *parent;
        vec3_t mins;
        vec3_t maxs;
-       // this part unique to nodes
+
+       // this part unique to node
        struct q3mnode_s *children[2];
 }
 q3mnode_t;
@@ -380,12 +388,12 @@ typedef struct q3mleaf_s
        struct q3mnode_s *parent;
        vec3_t mins;
        vec3_t maxs;
-       // this part unique to leafs
-       int clusterindex;
+
+       // this part unique to leaf
+       int clusterindex; // -1 is not in pvs, >= 0 is pvs bit number
        int areaindex;
        int numleaffaces;
-       struct q3msurface_s **firstleafface;
-       int *firstleaffacenum;
+       int *firstleafface;
        int numleafbrushes;
        struct q3mbrush_s **firstleafbrush;
 }
@@ -429,34 +437,17 @@ q3meffect_t;
 typedef struct q3msurface_s
 {
        // FIXME: collisionmarkframe should be kept in a separate array
-       // FIXME: visframe should be kept in a separate array
        // FIXME: shadowmark should be kept in a separate array
 
        struct q3mtexture_s *texture;
        struct q3meffect_s *effect;
        rtexture_t *lightmaptexture;
        int collisionmarkframe; // don't collide twice in one trace
-       int visframe; // visframe == r_framecount means it is visible this frame
        // bounding box for culling
        float mins[3];
        float maxs[3];
 
-       int num_vertices;
-       int num_triangles;
-       float *data_vertex3f;
-       float *data_texcoordtexture2f;
-       float *data_texcoordlightmap2f;
-       float *data_svector3f;
-       float *data_tvector3f;
-       float *data_normal3f;
-       float *data_color4f;
-       int *data_element3i;
-       int *data_neighbor3i;
-
-       int num_collisionvertices;
-       int num_collisiontriangles;
-       float *data_collisionvertex3f;
-       int *data_collisionelement3i;
+       surfmesh_t mesh;
 
        // index into model->brush.shadowmesh
        int num_firstshadowmeshtriangle;
@@ -490,8 +481,7 @@ typedef struct model_brushq3_s
        q3mbrush_t **data_leafbrushes;
 
        int num_leaffaces;
-       q3msurface_t **data_leaffaces;
-       int *data_leaffacenums;
+       int *data_leaffaces;
 
        int num_models;
        q3mmodel_t *data_models;
@@ -592,6 +582,11 @@ typedef struct model_s
        int                             nummodelsurfaces;
        // list of surface numbers in this (sub)model
        int                             *surfacelist;
+       // surface meshes are merged to a smaller set of meshes to allow reduced
+       // vertex array switching, the meshes are limited to 65536 vertices each
+       // to play nice with Geforce1 hardware
+       int                             nummeshes;
+       surfmesh_t              **meshlist;
        // draw the model's sky polygons (only used by brush models)
        void(*DrawSky)(struct entity_render_s *ent);
        // draw the model using lightmap/dlight shading
@@ -659,6 +654,8 @@ void Mod_ValidateElements(const int *elements, int numtriangles, int numverts, c
 void Mod_BuildNormals(int numverts, int numtriangles, const float *vertex3f, const int *elements, float *normal3f);
 void Mod_BuildTextureVectorsAndNormals(int numverts, int numtriangles, const float *vertex, const float *texcoord, const int *elements, float *svectors, float *tvectors, float *normals);
 
+surfmesh_t *Mod_AllocSurfMesh(mempool_t *mempool, int numvertices, int numtriangles, int numcollisionvertices, int numcollisiontriangles, qboolean detailtexcoords, qboolean lightmapoffsets, qboolean vertexcolors);
+
 shadowmesh_t *Mod_ShadowMesh_Alloc(mempool_t *mempool, int maxverts, int maxtriangles, rtexture_t *map_diffuse, rtexture_t *map_specular, rtexture_t *map_normal, int light, int neighbors, int expandable);
 shadowmesh_t *Mod_ShadowMesh_ReAlloc(mempool_t *mempool, shadowmesh_t *oldmesh, int light, int neighbors);
 int Mod_ShadowMesh_AddVertex(shadowmesh_t *mesh, float *vertex14f);