]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_shared.h
cl_parse: Only print if server actually disconnected
[xonotic/darkplaces.git] / model_shared.h
index 463af5f12725ebd3b0809f77aa1dcdaca43a3d25..6b0530a889c43c09e0955c74b32e6672d9898da0 100644 (file)
@@ -29,6 +29,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 struct rtexture_s;
 struct mempool_s;
 struct skeleton_s;
+struct skinframe_s;
+
 typedef enum synctype_e {ST_SYNC=0, ST_RAND } synctype_t;
 
 /*
@@ -50,49 +52,6 @@ typedef struct animscene_s
 }
 animscene_t;
 
-typedef struct skinframe_s
-{
-       struct rtexture_s *stain; // inverse modulate with background (used for decals and such)
-       struct rtexture_s *merged; // original texture without glow
-       struct rtexture_s *base; // original texture without pants/shirt/glow
-       struct rtexture_s *pants; // pants only (in greyscale)
-       struct rtexture_s *shirt; // shirt only (in greyscale)
-       struct rtexture_s *nmap; // normalmap (bumpmap for dot3)
-       struct rtexture_s *gloss; // glossmap (for dot3)
-       struct rtexture_s *glow; // glow only (fullbrights)
-       struct rtexture_s *fog; // alpha of the base texture (if not opaque)
-       struct rtexture_s *reflect; // colored mask for cubemap reflections
-       // accounting data for hash searches:
-       // the compare variables are used to identify internal skins from certain
-       // model formats
-       // (so that two q1bsp maps with the same texture name for different
-       //  textures do not have any conflicts)
-       struct skinframe_s *next; // next on hash chain
-       char basename[MAX_QPATH]; // name of this
-       int textureflags; // texture flags to use
-       int comparewidth;
-       int compareheight;
-       int comparecrc;
-       // mark and sweep garbage collection, this value is updated to a new value
-       // on each level change for the used skinframes, if some are not used they
-       // are freed
-       unsigned int loadsequence;
-       // indicates whether this texture has transparent pixels
-       qbool hasalpha;
-       // average texture color, if applicable
-       float avgcolor[4];
-       // for mdl skins, we actually only upload on first use (many are never used, and they are almost never used in both base+pants+shirt and merged modes)
-       unsigned char *qpixels;
-       int qwidth;
-       int qheight;
-       qbool qhascolormapping;
-       qbool qgeneratebase;
-       qbool qgeneratemerged;
-       qbool qgeneratenmap;
-       qbool qgenerateglow;
-}
-skinframe_t;
-
 struct md3vertex_s;
 struct trivertx_s;
 typedef struct texvecvertex_s
@@ -249,9 +208,9 @@ typedef struct texture_s
        float biaspolygonoffset;
 
        // textures to use when rendering this material (derived from materialshaderpass)
-       skinframe_t *currentskinframe;
+       struct skinframe_s *currentskinframe;
        // textures to use for terrain texture blending (derived from backgroundshaderpass)
-       skinframe_t *backgroundcurrentskinframe;
+       struct skinframe_s *backgroundcurrentskinframe;
 
        // total frames in sequence and alternate sequence
        int anim_total[2];
@@ -582,12 +541,12 @@ typedef struct model_s
 
        qbool nolerp;
 }
-dp_model_t;
+model_t;
 
 //============================================================================
 
 // model loading
-extern dp_model_t *loadmodel;
+extern model_t *loadmodel;
 extern unsigned char *mod_base;
 
 typedef struct modloader_s
@@ -595,7 +554,7 @@ typedef struct modloader_s
        const char *extension;
        const char *header;
        size_t headersize; // The header might not be NULL terminated
-       void (*Load)(dp_model_t *, void *, void *);
+       void (*Load)(model_t *, void *, void *);
 } modloader_t;
 
 // sky/water subdivision
@@ -618,16 +577,16 @@ extern struct cvar_s mod_q3bsp_lightgrid_bsp_surfaces;
 
 void Mod_Init (void);
 void Mod_Reload (void);
-dp_model_t *Mod_LoadModel(dp_model_t *mod, qbool crash, qbool checkdisk);
-dp_model_t *Mod_FindName (const char *name, const char *parentname);
-dp_model_t *Mod_ForName (const char *name, qbool crash, qbool checkdisk, const char *parentname);
-void Mod_UnloadModel (dp_model_t *mod);
+model_t *Mod_LoadModel(model_t *mod, qbool crash, qbool checkdisk);
+model_t *Mod_FindName (const char *name, const char *parentname);
+model_t *Mod_ForName (const char *name, qbool crash, qbool checkdisk, const char *parentname);
+void Mod_UnloadModel (model_t *mod);
 
 void Mod_ClearUsed(void);
 void Mod_PurgeUnused(void);
-void Mod_RemoveStaleWorldModels(dp_model_t *skip); // only used during loading!
+void Mod_RemoveStaleWorldModels(model_t *skip); // only used during loading!
 
-extern dp_model_t *loadmodel;
+extern model_t *loadmodel;
 extern char loadname[32];      // for hunk tags
 
 int Mod_BuildVertexRemapTableFromElements(int numelements, const int *elements, int numvertices, int *remapvertices);
@@ -636,7 +595,7 @@ void Mod_BuildTextureVectorsFromNormals(int firstvertex, int numvertices, int nu
 
 qbool Mod_ValidateElements(int *element3i, unsigned short *element3s, int numtriangles, int firstvertex, int numvertices, const char *filename, int fileline);
 void Mod_AllocSurfMesh(struct mempool_s *mempool, int numvertices, int numtriangles, qbool lightmapoffsets, qbool vertexcolors);
-void Mod_MakeSortedSurfaces(dp_model_t *mod);
+void Mod_MakeSortedSurfaces(model_t *mod);
 
 // called specially by brush model loaders before generating submodels
 // automatically called after model loader returns
@@ -650,16 +609,16 @@ shadowmesh_t *Mod_ShadowMesh_Finish(shadowmesh_t *firstmesh, qbool createvbo);
 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_CreateCollisionMesh(model_t *mod);
 
 void Mod_FreeQ3Shaders(void);
 void Mod_LoadQ3Shaders(void);
 shader_t *Mod_LookupQ3Shader(const char *name);
 qbool Mod_LoadTextureFromQ3Shader(struct mempool_s *mempool, const char *modelname, texture_t *texture, const char *name, qbool warnmissing, qbool fallback, int defaulttexflags, int defaultmaterialflags);
-texture_shaderpass_t *Mod_CreateShaderPass(struct mempool_s *mempool, skinframe_t *skinframe);
+texture_shaderpass_t *Mod_CreateShaderPass(struct mempool_s *mempool, struct skinframe_s *skinframe);
 texture_shaderpass_t *Mod_CreateShaderPassFromQ3ShaderLayer(struct mempool_s *mempool, const char *modelname, q3shaderinfo_layer_t *layer, int layerindex, int texflags, const char *texturename);
 /// Sets up a material to render the provided skinframe.  See also R_SkinFrame_LoadInternalBGRA.
-void Mod_LoadCustomMaterial(struct mempool_s *mempool, texture_t *texture, const char *name, int supercontents, int materialflags, skinframe_t *skinframe);
+void Mod_LoadCustomMaterial(struct mempool_s *mempool, texture_t *texture, const char *name, int supercontents, int materialflags, struct skinframe_s *skinframe);
 /// Removes all shaderpasses from material, and optionally deletes the textures in the skinframes.
 void Mod_UnloadCustomMaterial(texture_t *texture, qbool purgeskins);
 
@@ -734,34 +693,36 @@ void R_Mod_DrawShadowMap(int side, struct entity_render_s *ent, const vec3_t rel
 void R_Mod_DrawLight(struct entity_render_s *ent, int numsurfaces, const int *surfacelist, const unsigned char *trispvs);
 
 // dynamic mesh building (every frame) for debugging and other uses
-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 defaultmaterialflags);
-msurface_t *Mod_Mesh_AddSurface(dp_model_t *mod, texture_t *tex, qbool 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);
-void Mod_Mesh_Validate(dp_model_t *mod);
-void Mod_Mesh_Finalize(dp_model_t *mod);
+void Mod_Mesh_Create(model_t *mod, const char *name);
+void Mod_Mesh_Destroy(model_t *mod);
+void Mod_Mesh_Reset(model_t *mod);
+texture_t *Mod_Mesh_GetTexture(model_t *mod, const char *name, int defaultdrawflags, int defaulttexflags, int defaultmaterialflags);
+msurface_t *Mod_Mesh_AddSurface(model_t *mod, texture_t *tex, qbool batchwithprevioussurface);
+void Mod_Mesh_CheckResize_Vertex(model_t *mod, msurface_t *surf);
+int Mod_Mesh_AddVertex(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);
+int Mod_Mesh_IndexForVertex(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(model_t *mod, msurface_t *surf, int e0, int e1, int e2);
+void Mod_Mesh_Validate(model_t *mod);
+void Mod_Mesh_Finalize(model_t *mod);
 
 // Collision optimization using Bounding Interval Hierarchy
-void Mod_CollisionBIH_TracePoint(dp_model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
-void Mod_CollisionBIH_TraceLine(dp_model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
-void Mod_CollisionBIH_TraceBox(dp_model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t boxmins, const vec3_t boxmaxs, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
-void Mod_CollisionBIH_TraceBrush(dp_model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, struct colbrushf_s *start, struct colbrushf_s *end, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
-void Mod_CollisionBIH_TracePoint_Mesh(dp_model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
+void Mod_CollisionBIH_TracePoint(model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
+void Mod_CollisionBIH_TraceLine(model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
+void Mod_CollisionBIH_TraceBox(model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t boxmins, const vec3_t boxmaxs, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
+void Mod_CollisionBIH_TraceBrush(model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, struct colbrushf_s *start, struct colbrushf_s *end, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
+void Mod_CollisionBIH_TracePoint_Mesh(model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
 qbool Mod_CollisionBIH_TraceLineOfSight(struct model_s *model, const vec3_t start, const vec3_t end, const vec3_t acceptmins, const vec3_t acceptmaxs);
 int Mod_CollisionBIH_PointSuperContents(struct model_s *model, int frame, const vec3_t point);
 int Mod_CollisionBIH_PointSuperContents_Mesh(struct model_s *model, int frame, const vec3_t point);
-bih_t *Mod_MakeCollisionBIH(dp_model_t *model, qbool userendersurfaces, bih_t *out);
+bih_t *Mod_MakeCollisionBIH(model_t *model, qbool userendersurfaces, bih_t *out);
 
 // alias models
 struct frameblend_s;
 struct skeleton_s;
 void Mod_AliasInit(void);
-int Mod_Alias_GetTagMatrix(const dp_model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, int tagindex, matrix4x4_t *outmatrix);
-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);
+int Mod_Alias_GetTagMatrix(const model_t *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, int tagindex, matrix4x4_t *outmatrix);
+int Mod_Alias_GetTagIndexForName(const model_t *model, unsigned int skin, const char *tagname);
+int Mod_Alias_GetExtendedTagInfoForIndex(const 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);
 
@@ -769,22 +730,22 @@ void Mod_Skeletal_FreeBuffers(void);
 void Mod_SpriteInit(void);
 
 // loaders
-void Mod_2PSB_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_BSP2_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_HLBSP_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_Q1BSP_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_IBSP_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_MAP_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_OBJ_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_IDP0_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_IDP2_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_IDP3_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_ZYMOTICMODEL_Load(dp_model_t *mod, void *buffer, void *bufferend);
-void Mod_DARKPLACESMODEL_Load(dp_model_t *mod, void *buffer, void *bufferend);
-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);
-void Mod_INTERQUAKEMODEL_Load(dp_model_t *mod, void *buffer, void *bufferend);
+void Mod_2PSB_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_BSP2_Load(model_t *mod, void *buffer, void *bufferend);
+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_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);
+void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_IDSP_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_IDS2_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_INTERQUAKEMODEL_Load(model_t *mod, void *buffer, void *bufferend);
 
 #endif // MODEL_SHARED_H