]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_shared.h
+some tune ups for Steel Storm screenshot prefix
[xonotic/darkplaces.git] / model_shared.h
index d0d573693f06cca1ac880a40b16ed05a597dbaa8..bcb34f1b3b2b61498cc80d443e194eeb163aa688 100644 (file)
@@ -53,6 +53,7 @@ typedef struct skinframe_s
        rtexture_t *gloss; // glossmap (for dot3)
        rtexture_t *glow; // glow only (fullbrights)
        rtexture_t *fog; // alpha of the base texture (if not opaque)
+       rtexture_t *reflect; // colored mask for cubemap reflections
        // accounting data for hash searches:
        // the compare variables are used to identify internal skins from certain
        // model formats
@@ -93,6 +94,13 @@ typedef struct texvecvertex_s
 }
 texvecvertex_t;
 
+typedef struct blendweights_s
+{
+       unsigned char index[4];
+       unsigned char influence[4];
+}
+blendweights_t;
+
 // used for mesh lists in q1bsp/q3bsp map models
 // (the surfaces reference portions of these meshes)
 typedef struct surfmesh_s
@@ -133,8 +141,9 @@ typedef struct surfmesh_s
        float num_morphmdlframescale[3];
        float num_morphmdlframetranslate[3];
        // skeletal blending, these are NULL if model is morph or static
-       int *data_vertexweightindex4i;
-       float *data_vertexweightinfluence4f;
+       struct blendweights_s *data_blendweights;
+       int num_blends;
+       unsigned short *blends;
        // set if there is some kind of animation on this model
        qboolean isanimated;
 }
@@ -383,6 +392,9 @@ typedef struct q3shaderinfo_s
        qboolean dpshadow;
        qboolean dpnoshadow;
 
+       // fake reflection
+       char dpreflectcube[Q3PATHLENGTH];
+
        // reflection
        float reflectmin; // when refraction is used, minimum amount of reflection (when looking straight down)
        float reflectmax; // when refraction is used, maximum amount of reflection (when looking parallel to water)
@@ -487,6 +499,8 @@ typedef struct texture_s
        rtexture_t *glosstexture; // glossmap (for dot3)
        rtexture_t *glowtexture; // glow only (fullbrights)
        rtexture_t *fogtexture; // alpha of the base texture (if not opaque)
+       rtexture_t *reflectmasktexture; // mask for fake reflections
+       rtexture_t *reflectcubetexture; // fake reflections cubemap
        rtexture_t *backgroundbasetexture; // original texture without pants/shirt/glow
        rtexture_t *backgroundnmaptexture; // normalmap (bumpmap for dot3)
        rtexture_t *backgroundglosstexture; // glossmap (for dot3)
@@ -571,10 +585,11 @@ typedef struct msurface_s
        // fog volume info in q3bsp
        struct q3deffect_s *effect; // q3bsp
        // mesh information for collisions (only used by q3bsp curves)
-       int *data_collisionelement3i; // q3bsp
-       float *data_collisionvertex3f; // q3bsp
-       float *data_collisionbbox6f; // collision optimization - contains combined bboxes of every data_collisionstride triangles
-       float *data_bbox6f; // collision optimization - contains combined bboxes of every data_collisionstride triangles
+       int num_firstcollisiontriangle;
+       int *deprecatedq3data_collisionelement3i; // q3bsp
+       float *deprecatedq3data_collisionvertex3f; // q3bsp
+       float *deprecatedq3data_collisionbbox6f; // collision optimization - contains combined bboxes of every data_collisionstride triangles
+       float *deprecatedq3data_bbox6f; // collision optimization - contains combined bboxes of every data_collisionstride triangles
 
        // surfaces own ranges of vertices and triangles in the model->surfmesh
        int num_triangles; // number of triangles
@@ -588,14 +603,15 @@ typedef struct msurface_s
        // mesh information for collisions (only used by q3bsp curves)
        int num_collisiontriangles; // q3bsp
        int num_collisionvertices; // q3bsp
-       int num_collisionbboxstride;
-       int num_bboxstride;
+       int deprecatedq3num_collisionbboxstride;
+       int deprecatedq3num_bboxstride;
        // FIXME: collisionmarkframe should be kept in a separate array
-       int collisionmarkframe; // q3bsp // don't collide twice in one trace
+       int deprecatedq3collisionmarkframe; // q3bsp // don't collide twice in one trace
 }
 msurface_t;
 
 #include "matrixlib.h"
+#include "bih.h"
 
 #include "model_brush.h"
 #include "model_sprite.h"
@@ -675,6 +691,12 @@ typedef struct model_brush_s
        //pvschain = model->brush.data_pvsclusters + mycluster * model->brush.num_pvsclusterbytes;
        //if (pvschain[thatcluster >> 3] & (1 << (thatcluster & 7)))
 
+       // collision geometry for q3 curves
+       int num_collisionvertices;
+       int num_collisiontriangles;
+       float *data_collisionvertex3f;
+       int *data_collisionelement3i;
+
        // 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;
 
@@ -860,6 +882,8 @@ typedef struct model_s
        // range of collision brush numbers in this (sub)model
        int                             firstmodelbrush;
        int                             nummodelbrushes;
+       // BIH (Bounding Interval Hierarchy) for this (sub)model
+       bih_t                   collision_bih;
        // for md3 models
        int                             num_tags;
        int                             num_tagframes;
@@ -876,6 +900,8 @@ typedef struct model_s
        int                             num_textures;
        int                             num_texturesperskin;
        texture_t               *data_textures;
+       qboolean                wantnormals;
+       qboolean                wanttangents;
        // surfaces of this model
        int                             num_surfaces;
        msurface_t              *data_surfaces;
@@ -886,7 +912,7 @@ typedef struct model_s
        // data type of model
        const char              *modeldatatypestring;
        // generates vertex data for a given frameblend
-       void(*AnimateVertices)(const struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, float *vertex3f, float *normal3f, float *svector3f, float *tvector3f);
+       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)
        void(*DrawSky)(struct entity_render_s *ent);
        // draw refraction/reflection textures for the model's water polygons (only used by brush models)
@@ -965,6 +991,10 @@ void Mod_BuildTextureVectorsFromNormals(int firstvertex, int numvertices, int nu
 void Mod_AllocSurfMesh(mempool_t *mempool, int numvertices, int numtriangles, qboolean lightmapoffsets, qboolean vertexcolors, qboolean neighbors);
 void Mod_MakeSortedSurfaces(dp_model_t *mod);
 
+// called specially by brush model loaders before generating submodels
+// automatically called after model loader returns
+void Mod_BuildVBOs(void);
+
 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);
@@ -1057,6 +1087,14 @@ void R_Q1BSP_CompileShadowVolume(struct entity_render_s *ent, vec3_t relativelig
 void R_Q1BSP_DrawShadowVolume(struct entity_render_s *ent, const vec3_t relativelightorigin, const vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist, const vec3_t lightmins, const vec3_t lightmaxs);
 void R_Q1BSP_DrawLight(struct entity_render_s *ent, int numsurfaces, const int *surfacelist, const unsigned char *trispvs);
 
+// Collision optimization using Bounding Interval Hierarchy
+void Mod_CollisionBIH_TracePoint(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask);
+void Mod_CollisionBIH_TraceLine(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask);
+void Mod_CollisionBIH_TraceBox(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t boxmins, const vec3_t boxmaxs, const vec3_t end, int hitsupercontentsmask);
+void Mod_CollisionBIH_TracePoint_Mesh(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask);
+int Mod_CollisionBIH_PointSuperContents_Mesh(struct model_s *model, int frame, const vec3_t point);
+void Mod_MakeCollisionBIH(dp_model_t *model, qboolean userendersurfaces);
+
 // alias models
 struct frameblend_s;
 struct skeleton_s;
@@ -1065,6 +1103,8 @@ int Mod_Alias_GetTagMatrix(const dp_model_t *model, const struct frameblend_s *f
 int Mod_Alias_GetTagIndexForName(const dp_model_t *model, unsigned int skin, const char *tagname);
 int Mod_Alias_GetExtendedTagInfoForIndex(const dp_model_t *model, unsigned int skin, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, int tagindex, int *parentindex, const char **tagname, matrix4x4_t *tag_localmatrix);
 
+void Mod_Skeletal_FreeBuffers(void);
+
 // sprite models
 void Mod_SpriteInit(void);