]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_shared.h
ODE physics engine support, needs more work, disabled by default
[xonotic/darkplaces.git] / model_shared.h
index cdcc846e70496bb7c3e9817c714996dbe5472ff4..d756c341f63c0d6b1293be5e485ef5902f694f3f 100644 (file)
@@ -161,6 +161,8 @@ typedef struct shadowmesh_s
        // used always
        int *element3i;
        unsigned short *element3s;
+       // used for shadow mapping cubemap side partitioning
+       int sideoffsets[6], sidetotals[6];
        // used for shadow mesh (NULL on light mesh)
        int *neighbor3i;
        // these are NULL after Mod_ShadowMesh_Finish is performed, only used
@@ -356,6 +358,7 @@ q3shaderinfo_deform_t;
 typedef struct q3shaderinfo_s
 {
        char name[Q3PATHLENGTH];
+#define Q3SHADERINFO_COMPARE_START surfaceparms
        int surfaceparms;
        int textureflags;
        int numlayers;
@@ -381,6 +384,11 @@ typedef struct q3shaderinfo_s
        float reflectfactor; // amount of reflection distort (1.0 = like the cvar specifies)
        vec4_t reflectcolor4f; // color tint of reflection (including alpha factor)
        float r_water_wateralpha; // additional wateralpha to apply when r_water is active
+
+       // gloss
+       float specularscalemod;
+       float specularpowermod;
+#define Q3SHADERINFO_COMPARE_END specularpowermod
 }
 q3shaderinfo_t;
 
@@ -465,12 +473,14 @@ typedef struct texture_s
        struct texture_s *currentframe;
        // current texture transform matrix (used for water scrolling)
        matrix4x4_t currenttexmatrix;
+       matrix4x4_t currentbackgroundtexmatrix;
 
        // various q3 shader features
        q3shaderinfo_layer_rgbgen_t rgbgen;
        q3shaderinfo_layer_alphagen_t alphagen;
        q3shaderinfo_layer_tcgen_t tcgen;
        q3shaderinfo_layer_tcmod_t tcmods[Q3MAXTCMODS];
+       q3shaderinfo_layer_tcmod_t backgroundtcmods[Q3MAXTCMODS];
        q3shaderinfo_deform_t deforms[Q3MAXDEFORMS];
 
        qboolean colormapping;
@@ -508,6 +518,10 @@ typedef struct texture_s
        float reflectfactor; // amount of reflection distort (1.0 = like the cvar specifies)
        vec4_t reflectcolor4f; // color tint of reflection (including alpha factor)
        float r_water_wateralpha; // additional wateralpha to apply when r_water is active
+
+       // gloss
+       float specularscalemod;
+       float specularpowermod;
 }
 texture_t;
 
@@ -570,6 +584,12 @@ typedef struct msurface_s
        struct q3deffect_s *effect; // q3bsp
        // FIXME: collisionmarkframe should be kept in a separate array
        int collisionmarkframe; // q3bsp // don't collide twice in one trace
+
+       // optimization...
+       float *data_collisionbbox6f; // collision optimization - contains combined bboxes of every data_collisionstride triangles
+       int num_collisionbboxstride;
+       float *data_bbox6f; // collision optimization - contains combined bboxes of every data_collisionstride triangles
+       int num_bboxstride;
 }
 msurface_t;
 
@@ -656,6 +676,9 @@ typedef struct model_brush_s
        // 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;
 
+       // a mesh containing all SUPERCONTENTS_SOLID surfaces for this model or submodel, for physics engines to use
+       shadowmesh_t *collisionmesh;
+
        // common functions
        int (*SuperContentsFromNativeContents)(struct model_s *model, int nativecontents);
        int (*NativeContentsFromSuperContents)(struct model_s *model, int supercontents);
@@ -870,6 +893,10 @@ typedef struct model_s
        void(*DrawDepth)(struct entity_render_s *ent);
        // draw any enabled debugging effects on this model (such as showing triangles, normals, collision brushes...)
        void(*DrawDebug)(struct entity_render_s *ent);
+    // compile an optimized shadowmap mesh for the model based on light source
+       void(*CompileShadowMap)(struct entity_render_s *ent, vec3_t relativelightorigin, vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist);
+       // draw depth into a shadowmap
+       void(*DrawShadowMap)(int side, struct entity_render_s *ent, const vec3_t relativelightorigin, const vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist, const unsigned char *surfacesides, const vec3_t lightmins, const vec3_t lightmaxs);
        // gathers info on which clusters and surfaces are lit by light, as well as calculating a bounding box
        void(*GetLightInfo)(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, unsigned char *outleafpvs, int *outnumleafspointer, int *outsurfacelist, unsigned char *outsurfacepvs, int *outnumsurfacespointer, unsigned char *outshadowtrispvs, unsigned char *outlighttrispvs, unsigned char *visitingleafpvs);
        // compile a shadow volume for the model based on light source
@@ -880,6 +907,10 @@ typedef struct model_s
        void(*DrawLight)(struct entity_render_s *ent, int numsurfaces, const int *surfacelist, const unsigned char *trispvs);
        // trace a box against this model
        void (*TraceBox)(struct model_s *model, int frame, struct trace_s *trace, const vec3_t start, const vec3_t boxmins, const vec3_t boxmaxs, const vec3_t end, int hitsupercontentsmask);
+       // trace a box against this model
+       void (*TraceLine)(struct model_s *model, int frame, struct trace_s *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask);
+       // trace a point against this model (like PointSuperContents)
+       void (*TracePoint)(struct model_s *model, int frame, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask);
        // find the supercontents value at a point in this model
        int (*PointSuperContents)(struct model_s *model, int frame, const vec3_t point);
        // fields belonging to some types of model
@@ -938,6 +969,8 @@ shadowmesh_t *Mod_ShadowMesh_Finish(mempool_t *mempool, shadowmesh_t *firstmesh,
 void Mod_ShadowMesh_CalcBBox(shadowmesh_t *firstmesh, vec3_t mins, vec3_t maxs, vec3_t center, float *radius);
 void Mod_ShadowMesh_Free(shadowmesh_t *mesh);
 
+void Mod_CreateCollisionMesh(dp_model_t *mod);
+
 void Mod_FreeQ3Shaders(void);
 void Mod_LoadQ3Shaders(void);
 q3shaderinfo_t *Mod_LookupQ3Shader(const char *name);
@@ -982,6 +1015,8 @@ void R_Q1BSP_Draw(struct entity_render_s *ent);
 void R_Q1BSP_DrawDepth(struct entity_render_s *ent);
 void R_Q1BSP_DrawDebug(struct entity_render_s *ent);
 void R_Q1BSP_GetLightInfo(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, unsigned char *outleafpvs, int *outnumleafspointer, int *outsurfacelist, unsigned char *outsurfacepvs, int *outnumsurfacespointer, unsigned char *outshadowtrispvs, unsigned char *outlighttrispvs, unsigned char *visitingleafpvs);
+void R_Q1BSP_CompileShadowMap(struct entity_render_s *ent, vec3_t relativelightorigin, vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist);
+void R_Q1BSP_DrawShadowMap(int side, struct entity_render_s *ent, const vec3_t relativelightorigin, const vec3_t relativelightdirection, float lightradius, int modelnumsurfaces, const int *modelsurfacelist, const unsigned char *surfacesides, const vec3_t lightmins, const vec3_t lightmaxs);
 void R_Q1BSP_CompileShadowVolume(struct entity_render_s *ent, vec3_t relativelightorigin, vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist);
 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);
@@ -1010,8 +1045,5 @@ void Mod_PSKMODEL_Load(dp_model_t *mod, void *buffer, void *bufferend);
 void Mod_IDSP_Load(dp_model_t *mod, void *buffer, void *bufferend);
 void Mod_IDS2_Load(dp_model_t *mod, void *buffer, void *bufferend);
 
-// utility
-qboolean Mod_CanSeeBox_Trace(int numsamples, float t, dp_model_t *model, vec3_t eye, vec3_t minsX, vec3_t maxsX);
-
 #endif // MODEL_SHARED_H