From: havoc Date: Sun, 28 Aug 2005 20:41:12 +0000 (+0000) Subject: some cleaning of the model headers, and added bufferend parameter to all model loaders X-Git-Tag: xonotic-v0.1.0preview~4608 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3c626a98c5ea3971a9a3a06d133c72f63c1386eb;p=xonotic%2Fdarkplaces.git some cleaning of the model headers, and added bufferend parameter to all model loaders git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5666 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/model_alias.c b/model_alias.c index 572f038b..e7e6a1ee 100644 --- a/model_alias.c +++ b/model_alias.c @@ -419,7 +419,7 @@ static void Mod_BuildAliasSkinsFromSkinFiles(texture_t *skin, skinfile_t *skinfi extern void R_Q1BSP_Draw(entity_render_t *ent); extern void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist, const vec3_t lightmins, const vec3_t lightmaxs); extern void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces, const int *surfacelist); -void Mod_IDP0_Load(model_t *mod, void *buffer) +void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend) { int i, j, version, totalskins, skinwidth, skinheight, groupframes, groupskins, numverts; float scales, scalet, scale[3], translate[3], interval; @@ -741,7 +741,7 @@ static void Mod_MD2_ConvertVerts (vec3_t scale, vec3_t translate, trivertx_t *v, } } -void Mod_IDP2_Load(model_t *mod, void *buffer) +void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) { int i, j, k, hashindex, num, numxyz, numst, xyz, st, skinwidth, skinheight, *vertremap, version, end, numverts; float *stverts, s, t, scale[3], translate[3]; @@ -985,7 +985,7 @@ void Mod_IDP2_Load(model_t *mod, void *buffer) surface->num_vertices = surface->groupmesh->num_vertices; } -void Mod_IDP3_Load(model_t *mod, void *buffer) +void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend) { int i, j, k, version; qbyte *data; @@ -1123,7 +1123,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer) Mod_FreeSkinFiles(skinfiles); } -void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer) +void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) { zymtype1header_t *pinmodel, *pheader; qbyte *pbase; @@ -1419,7 +1419,7 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer) Mem_Free(outtexcoord2f); } -void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer) +void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) { dpmheader_t *pheader; dpmframe_t *frame; diff --git a/model_alias.h b/model_alias.h index 2b69fac9..c15d81a3 100644 --- a/model_alias.h +++ b/model_alias.h @@ -116,14 +116,6 @@ typedef struct int ofs_end; // end of file } md2_t; -extern void Mod_IDP0_Load(struct model_s *mod, void *buffer); -extern void Mod_IDP2_Load(struct model_s *mod, void *buffer); -extern void Mod_IDP3_Load(struct model_s *mod, void *buffer); -extern void Mod_ZYMOTICMODEL_Load(struct model_s *mod, void *buffer); -extern void Mod_DARKPLACESMODEL_Load(struct model_s *mod, void *buffer); - -extern void Mod_AliasInit(void); - #include "model_zymotic.h" #include "model_dpmodel.h" @@ -232,10 +224,5 @@ typedef struct aliasbone_s } aliasbone_t; -struct frameblend_s; -void Mod_Alias_GetMesh_Vertex3f(const struct model_s *model, const struct frameblend_s *frameblend, const struct surfmesh_s *mesh, float *out3f); -int Mod_Alias_GetTagMatrix(const struct model_s *model, int poseframe, int tagindex, matrix4x4_t *outmatrix); -int Mod_Alias_GetTagIndexForName(const struct model_s *model, unsigned int skin, const char *tagname); - #endif diff --git a/model_brush.c b/model_brush.c index 253edee9..4cca197c 100644 --- a/model_brush.c +++ b/model_brush.c @@ -2917,7 +2917,7 @@ extern void R_Q1BSP_Draw(entity_render_t *ent); extern void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, qbyte *outleafpvs, int *outnumleafspointer, int *outsurfacelist, qbyte *outsurfacepvs, int *outnumsurfacespointer); extern void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist, const vec3_t lightmins, const vec3_t lightmaxs); extern void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces, const int *surfacelist); -void Mod_Q1BSP_Load(model_t *mod, void *buffer) +void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend) { int i, j, k; dheader_t *header; @@ -3539,7 +3539,7 @@ static void Mod_Q2BSP_LoadModels(lump_t *l) */ } -void static Mod_Q2BSP_Load(model_t *mod, void *buffer) +void static Mod_Q2BSP_Load(model_t *mod, void *buffer, void *bufferend) { int i; q2dheader_t *header; @@ -5412,7 +5412,7 @@ void Mod_Q3BSP_RecursiveFindNumLeafs(mnode_t *node) loadmodel->brush.num_leafs = numleafs; } -void Mod_Q3BSP_Load(model_t *mod, void *buffer) +void Mod_Q3BSP_Load(model_t *mod, void *buffer, void *bufferend) { int i, j, numshadowmeshtriangles; q3dheader_t *header; @@ -5568,18 +5568,18 @@ void Mod_Q3BSP_Load(model_t *mod, void *buffer) } } -void Mod_IBSP_Load(model_t *mod, void *buffer) +void Mod_IBSP_Load(model_t *mod, void *buffer, void *bufferend) { int i = LittleLong(((int *)buffer)[1]); if (i == Q3BSPVERSION) - Mod_Q3BSP_Load(mod,buffer); + Mod_Q3BSP_Load(mod,buffer, bufferend); else if (i == Q2BSPVERSION) - Mod_Q2BSP_Load(mod,buffer); + Mod_Q2BSP_Load(mod,buffer, bufferend); else Host_Error("Mod_IBSP_Load: unknown/unsupported version %i\n", i); } -void Mod_MAP_Load(model_t *mod, void *buffer) +void Mod_MAP_Load(model_t *mod, void *buffer, void *bufferend) { Host_Error("Mod_MAP_Load: not yet implemented\n"); } diff --git a/model_brush.h b/model_brush.h index 1bf8be8d..f2de302c 100644 --- a/model_brush.h +++ b/model_brush.h @@ -211,12 +211,6 @@ typedef struct mlight_s } mlight_t; -struct model_s; -void Mod_Q1BSP_Load(struct model_s *mod, void *buffer); -void Mod_IBSP_Load(struct model_s *mod, void *buffer); -void Mod_MAP_Load(struct model_s *mod, void *buffer); -void Mod_BrushInit(void); - // Q2 bsp stuff #define Q2BSPVERSION 38 diff --git a/model_shared.c b/model_shared.c index b0de8563..7dd2e45f 100644 --- a/model_shared.c +++ b/model_shared.c @@ -189,19 +189,20 @@ model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolea if (buf) { + char *bufend = buf + fs_filesize; num = LittleLong(*((int *)buf)); // call the apropriate loader loadmodel = mod; - if (!memcmp(buf, "IDPO", 4)) Mod_IDP0_Load(mod, buf); - else if (!memcmp(buf, "IDP2", 4)) Mod_IDP2_Load(mod, buf); - else if (!memcmp(buf, "IDP3", 4)) Mod_IDP3_Load(mod, buf); - else if (!memcmp(buf, "IDSP", 4)) Mod_IDSP_Load(mod, buf); - else if (!memcmp(buf, "IDS2", 4)) Mod_IDS2_Load(mod, buf); - else if (!memcmp(buf, "IBSP", 4)) Mod_IBSP_Load(mod, buf); - else if (!memcmp(buf, "ZYMOTICMODEL", 12)) Mod_ZYMOTICMODEL_Load(mod, buf); - else if (!memcmp(buf, "DARKPLACESMODEL", 16)) Mod_DARKPLACESMODEL_Load(mod, buf); - else if (strlen(mod->name) >= 4 && !strcmp(mod->name - 4, ".map")) Mod_MAP_Load(mod, buf); - else if (num == BSPVERSION || num == 30) Mod_Q1BSP_Load(mod, buf); + if (!memcmp(buf, "IDPO", 4)) Mod_IDP0_Load(mod, buf, bufend); + else if (!memcmp(buf, "IDP2", 4)) Mod_IDP2_Load(mod, buf, bufend); + else if (!memcmp(buf, "IDP3", 4)) Mod_IDP3_Load(mod, buf, bufend); + else if (!memcmp(buf, "IDSP", 4)) Mod_IDSP_Load(mod, buf, bufend); + else if (!memcmp(buf, "IDS2", 4)) Mod_IDS2_Load(mod, buf, bufend); + else if (!memcmp(buf, "IBSP", 4)) Mod_IBSP_Load(mod, buf, bufend); + else if (!memcmp(buf, "ZYMOTICMODEL", 12)) Mod_ZYMOTICMODEL_Load(mod, buf, bufend); + else if (!memcmp(buf, "DARKPLACESMODEL", 16)) Mod_DARKPLACESMODEL_Load(mod, buf, bufend); + else if (strlen(mod->name) >= 4 && !strcmp(mod->name - 4, ".map")) Mod_MAP_Load(mod, buf, bufend); + else if (num == BSPVERSION || num == 30) Mod_Q1BSP_Load(mod, buf, bufend); else Con_Printf("Mod_LoadModel: model \"%s\" is of unknown/unsupported type\n", mod->name); Mem_Free(buf); } diff --git a/model_shared.h b/model_shared.h index eaed415f..c61a03d1 100644 --- a/model_shared.h +++ b/model_shared.h @@ -578,10 +578,6 @@ void Mod_ShadowMesh_Free(shadowmesh_t *mesh); int Mod_LoadSkinFrame(skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture); int Mod_LoadSkinFrame_Internal(skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture, qbyte *skindata, int width, int height); -// used for talking to the QuakeC mainly -int Mod_Q1BSP_NativeContentsFromSuperContents(struct model_s *model, int supercontents); -int Mod_Q1BSP_SuperContentsFromNativeContents(struct model_s *model, int nativecontents); - extern cvar_t r_mipskins; typedef struct skinfileitem_s @@ -606,5 +602,33 @@ int Mod_CountSkinFiles(skinfile_t *skinfile); void Mod_SnapVertices(int numcomponents, int numvertices, float *vertices, float snap); int Mod_RemoveDegenerateTriangles(int numtriangles, const int *inelement3i, int *outelement3i, const float *vertex3f); +// bsp models +void Mod_BrushInit(void); +// used for talking to the QuakeC mainly +int Mod_Q1BSP_NativeContentsFromSuperContents(struct model_s *model, int supercontents); +int Mod_Q1BSP_SuperContentsFromNativeContents(struct model_s *model, int nativecontents); + +// alias models +struct frameblend_s; +void Mod_AliasInit(void); +void Mod_Alias_GetMesh_Vertex3f(const model_t *model, const struct frameblend_s *frameblend, const struct surfmesh_s *mesh, float *out3f); +int Mod_Alias_GetTagMatrix(const model_t *model, int poseframe, int tagindex, matrix4x4_t *outmatrix); +int Mod_Alias_GetTagIndexForName(const model_t *model, unsigned int skin, const char *tagname); + +// sprite models +void Mod_SpriteInit(void); + +// loaders +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_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_IDSP_Load(model_t *mod, void *buffer, void *bufferend); +void Mod_IDS2_Load(model_t *mod, void *buffer, void *bufferend); + #endif // MODEL_SHARED_H diff --git a/model_sprite.c b/model_sprite.c index 7d2960f5..6e94c8b4 100644 --- a/model_sprite.c +++ b/model_sprite.c @@ -204,7 +204,7 @@ static void Mod_Sprite_SharedSetup(const qbyte *datapointer, int version, const } extern void R_Model_Sprite_Draw(entity_render_t *ent); -void Mod_IDSP_Load(model_t *mod, const void *buffer) +void Mod_IDSP_Load(model_t *mod, void *buffer, void *bufferend) { int version; const qbyte *datapointer; @@ -317,12 +317,12 @@ void Mod_IDSP_Load(model_t *mod, const void *buffer) } -void Mod_IDS2_Load(model_t *mod, const void *buffer) +void Mod_IDS2_Load(model_t *mod, void *buffer, void *bufferend) { int i, version; const dsprite2_t *pinqsprite; float modelradius; - + loadmodel->type = mod_sprite; loadmodel->flags2 = EF_FULLBRIGHT; diff --git a/model_sprite.h b/model_sprite.h index 12ef2414..35538505 100644 --- a/model_sprite.h +++ b/model_sprite.h @@ -38,9 +38,5 @@ typedef struct mspriteframe_s rtexture_t *texture, *fogtexture; } mspriteframe_t; -extern void Mod_IDSP_Load(struct model_s *mod, const void *buffer); -extern void Mod_IDS2_Load(struct model_s *mod, const void *buffer); -extern void Mod_SpriteInit(void); - #endif