]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_shared.h
Fix nasty typo in a dpsnprintf causing truncated cmds. Memory safety? PFFT (/s)
[xonotic/darkplaces.git] / model_shared.h
index cf64465f42b4f0d8b12248bb6d622115e4e28d4b..066051ed432466353e3e26dbfa31b1c002be144b 100644 (file)
@@ -409,7 +409,7 @@ typedef enum dptransparentsort_category_e
        TRANSPARENTSORT_HUD,
 }dptransparentsortcategory_t;
 
-typedef struct q3shaderinfo_s
+typedef struct shader_s
 {
        char name[Q3PATHLENGTH];
 #define Q3SHADERINFO_COMPARE_START surfaceparms
@@ -469,7 +469,7 @@ typedef struct q3shaderinfo_s
        float rtlightambient;
 #define Q3SHADERINFO_COMPARE_END rtlightambient
 }
-q3shaderinfo_t;
+shader_t;
 
 typedef struct texture_shaderpass_s
 {
@@ -485,32 +485,12 @@ typedef struct texture_shaderpass_s
 }
 texture_shaderpass_t;
 
-typedef enum texturelayertype_e
-{
-       TEXTURELAYERTYPE_INVALID,
-       TEXTURELAYERTYPE_LITTEXTURE,
-       TEXTURELAYERTYPE_TEXTURE,
-       TEXTURELAYERTYPE_FOG
-}
-texturelayertype_t;
-
-typedef struct texturelayer_s
-{
-       texturelayertype_t type;
-       qboolean depthmask;
-       int blendfunc1;
-       int blendfunc2;
-       rtexture_t *texture;
-       matrix4x4_t texmatrix;
-       vec4_t color;
-}
-texturelayer_t;
-
 typedef struct texture_s
 {
-       // q1bsp
        // name
-       //char name[16];
+       char name[64];
+
+       // q1bsp
        // size
        unsigned int width, height;
        // SURF_ flags
@@ -547,6 +527,12 @@ typedef struct texture_s
        void *update_lastrenderentity;
        // the current alpha of this texture (may be affected by r_wateralpha, also basealpha, and ent->alpha)
        float currentalpha;
+       // current value of blendfunc - one of:
+       // {GL_SRC_ALPHA, GL_ONE}
+       // {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}
+       // {customblendfunc[0], customblendfunc[1]}
+       // {GL_ONE, GL_ZERO}
+       int currentblendfunc[2];
        // the current texture frame in animation
        struct texture_s *currentframe;
        // current texture transform matrix (used for water scrolling)
@@ -587,7 +573,8 @@ typedef struct texture_s
        // MATERIALFLAG_MODELLIGHT uses these parameters
        float render_modellight_ambient[3];
        float render_modellight_diffuse[3];
-       float render_modellight_lightdir[3];
+       float render_modellight_lightdir_world[3];
+       float render_modellight_lightdir_local[3];
        float render_modellight_specular[3];
        // lightmap rendering (not MATERIALFLAG_MODELLIGHT)
        float render_lightmap_ambient[3];
@@ -604,11 +591,7 @@ typedef struct texture_s
        // from q3 shaders
        int customblendfunc[2];
 
-       int currentnumlayers;
-       texturelayer_t currentlayers[16];
-
        // q3bsp
-       char name[64];
        int surfaceflags;
        int supercontents;
 
@@ -632,6 +615,7 @@ typedef struct texture_s
        vec4_t reflectcolor4f; // color tint of reflection (including alpha factor)
        float r_water_wateralpha; // additional wateralpha to apply when r_water is active
        float r_water_waterscroll[2]; // scale and speed
+       float refractive_index; // used by r_shadow_bouncegrid for bending photons for refracted light
        int camera_entity; // entity number for use by cameras
 
        // offsetmapping
@@ -648,6 +632,11 @@ typedef struct texture_s
 
        // diffuse and ambient
        float rtlightambient;
+
+       // used by Mod_Mesh_GetTexture for drawflag and materialflag overrides, to disambiguate the same texture with different hints
+       int mesh_drawflag;
+       int mesh_defaulttexflags;
+       int mesh_defaultmaterialflags;
 }
  texture_t;
 
@@ -699,10 +688,6 @@ typedef struct msurface_s
        struct q3deffect_s *effect; // q3bsp
        // mesh information for collisions (only used by q3bsp curves)
        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
@@ -713,10 +698,6 @@ typedef struct msurface_s
        // mesh information for collisions (only used by q3bsp curves)
        int num_collisiontriangles; // q3bsp
        int num_collisionvertices; // q3bsp
-       int deprecatedq3num_collisionbboxstride;
-       int deprecatedq3num_bboxstride;
-       // FIXME: collisionmarkframe should be kept in a separate array
-       int deprecatedq3collisionmarkframe; // q3bsp // don't collide twice in one trace
 
        // used by Mod_Mesh_Finalize when building sortedmodelsurfaces
        qboolean included;
@@ -895,12 +876,6 @@ typedef struct model_brushq1_s
 }
 model_brushq1_t;
 
-typedef struct model_brushq2_s
-{
-       int dummy; // MSVC can't handle an empty struct
-}
-model_brushq2_t;
-
 typedef struct model_brushq3_s
 {
        int num_models;
@@ -931,7 +906,7 @@ typedef struct model_brushq3_s
        rtexture_t **data_lightmaps;
        rtexture_t **data_deluxemaps;
 
-       // voxel light data with directional shading
+       // voxel light data with directional shading - data for cpu sampling of it...
        int num_lightgrid;
        q3dlightgrid_t *data_lightgrid;
        // size of each cell (may vary by map, typically 64 64 128)
@@ -944,6 +919,10 @@ typedef struct model_brushq3_s
        int num_lightgrid_isize[3];
        // transform modelspace coordinates to lightgrid index
        matrix4x4_t num_lightgrid_indexfromworld;
+       // parameters for fragment shader to sample the texture version of it:
+       int lightgridtexturesize[3]; // 3 layers tall (ambient, lightcolor, lightdir)
+       matrix4x4_t lightgridworldtotexturematrix;
+       rtexture_t *lightgridtexture;
 
        // true if this q3bsp file has been detected as using deluxemapping
        // (lightmap texture pairs, every odd one is never directly refernced,
@@ -1075,7 +1054,6 @@ typedef struct model_s
        model_sprite_t  sprite;
        model_brush_t   brush;
        model_brushq1_t brushq1;
-       model_brushq2_t brushq2;
        model_brushq3_t brushq3;
        // flags this model for offseting sounds to the model center (used by brush models)
        int soundfromcenter;
@@ -1083,6 +1061,8 @@ typedef struct model_s
        // if set, the model contains light information (lightmap, or vertexlight)
        qboolean lit;
        float lightmapscale;
+
+       qboolean nolerp;
 }
 dp_model_t;
 
@@ -1096,6 +1076,19 @@ extern unsigned char *mod_base;
 // texture fullbrights
 extern cvar_t r_fullbrights;
 
+extern cvar_t mod_noshader_default_offsetmapping;
+extern cvar_t mod_q3shader_default_offsetmapping;
+extern cvar_t mod_q3shader_default_offsetmapping_scale;
+extern cvar_t mod_q3shader_default_offsetmapping_bias;
+extern cvar_t mod_q3shader_default_polygonoffset;
+extern cvar_t mod_q3shader_default_polygonfactor;
+extern cvar_t mod_q3shader_default_refractive_index;
+extern cvar_t mod_q3shader_force_addalpha;
+extern cvar_t mod_q3shader_force_terrain_alphaflag;
+extern cvar_t mod_q3bsp_lightgrid_texture;
+extern cvar_t mod_q3bsp_lightgrid_world_surfaces;
+extern cvar_t mod_q3bsp_lightgrid_bsp_surfaces;
+
 void Mod_Init (void);
 void Mod_Reload (void);
 dp_model_t *Mod_LoadModel(dp_model_t *mod, qboolean crash, qboolean checkdisk);
@@ -1134,7 +1127,7 @@ void Mod_CreateCollisionMesh(dp_model_t *mod);
 
 void Mod_FreeQ3Shaders(void);
 void Mod_LoadQ3Shaders(void);
-q3shaderinfo_t *Mod_LookupQ3Shader(const char *name);
+shader_t *Mod_LookupQ3Shader(const char *name);
 qboolean Mod_LoadTextureFromQ3Shader(mempool_t *mempool, const char *modelname, texture_t *texture, const char *name, qboolean warnmissing, qboolean fallback, int defaulttexflags, int defaultmaterialflags);
 texture_shaderpass_t *Mod_CreateShaderPass(mempool_t *mempool, skinframe_t *skinframe);
 texture_shaderpass_t *Mod_CreateShaderPassFromQ3ShaderLayer(mempool_t *mempool, const char *modelname, q3shaderinfo_layer_t *layer, int layerindex, int texflags, const char *texturename);
@@ -1217,7 +1210,7 @@ void R_Q1BSP_DrawLight(struct entity_render_s *ent, int numsurfaces, const int *
 void Mod_Mesh_Create(dp_model_t *mod, const char *name);
 void Mod_Mesh_Destroy(dp_model_t *mod);
 void Mod_Mesh_Reset(dp_model_t *mod);
-texture_t *Mod_Mesh_GetTexture(dp_model_t *mod, const char *name, int defaultdrawflags, int defaulttexflags, int addmaterialflags);
+texture_t *Mod_Mesh_GetTexture(dp_model_t *mod, const char *name, int defaultdrawflags, int defaulttexflags, int defaultmaterialflags);
 msurface_t *Mod_Mesh_AddSurface(dp_model_t *mod, texture_t *tex, qboolean batchwithprevioussurface);
 int Mod_Mesh_IndexForVertex(dp_model_t *mod, msurface_t *surf, float x, float y, float z, float nx, float ny, float nz, float s, float t, float u, float v, float r, float g, float b, float a);
 void Mod_Mesh_AddTriangle(dp_model_t *mod, msurface_t *surf, int e0, int e1, int e2);