mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-21 03:11:57 +00:00
Share models structs in ref_shared.h
Fix calculation in: ``` hunkSize += calcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(model_t)); ``` `Mod_LoadSubmodels` uses whole model_t as submodel type.
This commit is contained in:
parent
322424ef33
commit
c2dc8debb6
14 changed files with 55 additions and 112 deletions
|
@ -68,7 +68,7 @@ FixFileExt(const char *origname, const char *ext, char *filename, size_t size)
|
|||
* type: extension of the type we wanna open ("jpg", "png" or "tga")
|
||||
* pic: pointer RGBA pixel data will be assigned to
|
||||
*/
|
||||
qboolean
|
||||
static qboolean
|
||||
LoadSTB(const char *origname, const char* type, byte **pic, int *width, int *height)
|
||||
{
|
||||
char filename[256];
|
||||
|
@ -492,7 +492,7 @@ LoadHiColorImage(const char *name, const char* namewe, const char *ext,
|
|||
}
|
||||
|
||||
struct image_s *
|
||||
LoadImage(const char *name, const char* namewe, const char *ext, imagetype_t type,
|
||||
R_LoadImage(const char *name, const char* namewe, const char *ext, imagetype_t type,
|
||||
qboolean r_retexturing, loadimage_t load_image)
|
||||
{
|
||||
struct image_s *image = NULL;
|
||||
|
@ -628,7 +628,7 @@ GetTexImage(const char *name, findimage_t find_image)
|
|||
}
|
||||
|
||||
struct image_s *
|
||||
FindPic(const char *name, findimage_t find_image)
|
||||
R_FindPic(const char *name, findimage_t find_image)
|
||||
{
|
||||
struct image_s *image = NULL;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ void
|
|||
Draw_InitLocal(void)
|
||||
{
|
||||
/* load console characters */
|
||||
draw_chars = FindPic("conchars", (findimage_t)R_FindImage);
|
||||
draw_chars = R_FindPic("conchars", (findimage_t)R_FindImage);
|
||||
if (!draw_chars)
|
||||
{
|
||||
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/conchars.pcx",
|
||||
|
@ -107,7 +107,7 @@ RDraw_CharScaled(int x, int y, int num, float scale)
|
|||
image_t *
|
||||
RDraw_FindPic(char *name)
|
||||
{
|
||||
return FindPic(name, (findimage_t)R_FindImage);
|
||||
return R_FindPic(name, (findimage_t)R_FindImage);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -115,7 +115,7 @@ RDraw_GetPicSize(int *w, int *h, char *pic)
|
|||
{
|
||||
image_t *gl;
|
||||
|
||||
gl = FindPic(pic, (findimage_t)R_FindImage);
|
||||
gl = R_FindPic(pic, (findimage_t)R_FindImage);
|
||||
|
||||
if (!gl)
|
||||
{
|
||||
|
@ -132,7 +132,7 @@ RDraw_StretchPic(int x, int y, int w, int h, char *pic)
|
|||
{
|
||||
image_t *gl;
|
||||
|
||||
gl = FindPic(pic, (findimage_t)R_FindImage);
|
||||
gl = R_FindPic(pic, (findimage_t)R_FindImage);
|
||||
|
||||
if (!gl)
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ RDraw_PicScaled(int x, int y, char *pic, float factor)
|
|||
{
|
||||
image_t *gl;
|
||||
|
||||
gl = FindPic(pic, (findimage_t)R_FindImage);
|
||||
gl = R_FindPic(pic, (findimage_t)R_FindImage);
|
||||
|
||||
if (!gl)
|
||||
{
|
||||
|
@ -227,7 +227,7 @@ RDraw_TileClear(int x, int y, int w, int h, char *pic)
|
|||
{
|
||||
image_t *image;
|
||||
|
||||
image = FindPic(pic, (findimage_t)R_FindImage);
|
||||
image = R_FindPic(pic, (findimage_t)R_FindImage);
|
||||
|
||||
if (!image)
|
||||
{
|
||||
|
|
|
@ -1081,7 +1081,7 @@ R_FindImage(const char *name, imagetype_t type)
|
|||
//
|
||||
// load the pic from disk
|
||||
//
|
||||
image = (image_t *)LoadImage(name, namewe, ext, type,
|
||||
image = (image_t *)R_LoadImage(name, namewe, ext, type,
|
||||
r_retexturing->value, (loadimage_t)R_LoadPic);
|
||||
|
||||
if (!image && r_validation->value)
|
||||
|
|
|
@ -1047,7 +1047,7 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
|
|||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFS], sizeof(dleaf_t), sizeof(mleaf_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_NODES], sizeof(dnode_t), sizeof(mnode_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(mmodel_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(model_t));
|
||||
|
||||
mod->extradata = Hunk_Begin(hunkSize);
|
||||
mod->type = mod_brush;
|
||||
|
|
|
@ -39,35 +39,6 @@
|
|||
#define VERTEXSIZE 7
|
||||
|
||||
/* in memory representation */
|
||||
typedef struct
|
||||
{
|
||||
vec3_t position;
|
||||
} mvertex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t mins, maxs;
|
||||
vec3_t origin; /* for sounds or lights */
|
||||
float radius;
|
||||
int headnode;
|
||||
int visleafs; /* not including the solid leaf 0 */
|
||||
int firstface, numfaces;
|
||||
} mmodel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short v[2];
|
||||
unsigned int cachededgeoffset;
|
||||
} medge_t;
|
||||
|
||||
typedef struct mtexinfo_s
|
||||
{
|
||||
float vecs[2][4];
|
||||
int flags;
|
||||
int numframes;
|
||||
struct mtexinfo_s *next; /* animation chain */
|
||||
image_t *image;
|
||||
} mtexinfo_t;
|
||||
|
||||
typedef struct glpoly_s
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ void
|
|||
GL3_Draw_InitLocal(void)
|
||||
{
|
||||
/* load console characters */
|
||||
draw_chars = FindPic("conchars", (findimage_t)GL3_FindImage);
|
||||
draw_chars = R_FindPic("conchars", (findimage_t)GL3_FindImage);
|
||||
if (!draw_chars)
|
||||
{
|
||||
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/conchars.pcx",
|
||||
|
@ -163,7 +163,7 @@ GL3_Draw_CharScaled(int x, int y, int num, float scale)
|
|||
gl3image_t *
|
||||
GL3_Draw_FindPic(char *name)
|
||||
{
|
||||
return FindPic(name, (findimage_t)GL3_FindImage);
|
||||
return R_FindPic(name, (findimage_t)GL3_FindImage);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -171,7 +171,7 @@ GL3_Draw_GetPicSize(int *w, int *h, char *pic)
|
|||
{
|
||||
gl3image_t *gl;
|
||||
|
||||
gl = FindPic(pic, (findimage_t)GL3_FindImage);
|
||||
gl = R_FindPic(pic, (findimage_t)GL3_FindImage);
|
||||
|
||||
if (!gl)
|
||||
{
|
||||
|
@ -186,7 +186,7 @@ GL3_Draw_GetPicSize(int *w, int *h, char *pic)
|
|||
void
|
||||
GL3_Draw_StretchPic(int x, int y, int w, int h, char *pic)
|
||||
{
|
||||
gl3image_t *gl = FindPic(pic, (findimage_t)GL3_FindImage);
|
||||
gl3image_t *gl = R_FindPic(pic, (findimage_t)GL3_FindImage);
|
||||
|
||||
if (!gl)
|
||||
{
|
||||
|
@ -203,7 +203,7 @@ GL3_Draw_StretchPic(int x, int y, int w, int h, char *pic)
|
|||
void
|
||||
GL3_Draw_PicScaled(int x, int y, char *pic, float factor)
|
||||
{
|
||||
gl3image_t *gl = FindPic(pic, (findimage_t)GL3_FindImage);
|
||||
gl3image_t *gl = R_FindPic(pic, (findimage_t)GL3_FindImage);
|
||||
if (!gl)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Can't find pic: %s\n", pic);
|
||||
|
@ -224,7 +224,7 @@ GL3_Draw_PicScaled(int x, int y, char *pic, float factor)
|
|||
void
|
||||
GL3_Draw_TileClear(int x, int y, int w, int h, char *pic)
|
||||
{
|
||||
gl3image_t *image = FindPic(pic, (findimage_t)GL3_FindImage);
|
||||
gl3image_t *image = R_FindPic(pic, (findimage_t)GL3_FindImage);
|
||||
if (!image)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Can't find pic: %s\n", pic);
|
||||
|
|
|
@ -651,7 +651,7 @@ GL3_FindImage(const char *name, imagetype_t type)
|
|||
//
|
||||
// load the pic from disk
|
||||
//
|
||||
image = (gl3image_t *)LoadImage(name, namewe, ext, type,
|
||||
image = (gl3image_t *)R_LoadImage(name, namewe, ext, type,
|
||||
r_retexturing->value, (loadimage_t)GL3_LoadPic);
|
||||
|
||||
if (!image && r_validation->value)
|
||||
|
|
|
@ -916,7 +916,7 @@ Mod_LoadBrushModel(gl3model_t *mod, void *buffer, int modfilelen)
|
|||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFS], sizeof(dleaf_t), sizeof(mleaf_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_NODES], sizeof(dnode_t), sizeof(mnode_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(mmodel_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(gl3model_t));
|
||||
|
||||
mod->extradata = Hunk_Begin(hunkSize);
|
||||
mod->type = mod_brush;
|
||||
|
|
|
@ -59,35 +59,6 @@ typedef struct gl3_alias_vtx_s {
|
|||
} gl3_alias_vtx_t;
|
||||
|
||||
/* in memory representation */
|
||||
typedef struct
|
||||
{
|
||||
vec3_t position;
|
||||
} mvertex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t mins, maxs;
|
||||
vec3_t origin; /* for sounds or lights */
|
||||
float radius;
|
||||
int headnode;
|
||||
int visleafs; /* not including the solid leaf 0 */
|
||||
int firstface, numfaces;
|
||||
} mmodel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short v[2];
|
||||
unsigned int cachededgeoffset;
|
||||
} medge_t;
|
||||
|
||||
typedef struct mtexinfo_s
|
||||
{
|
||||
float vecs[2][4];
|
||||
int flags;
|
||||
int numframes;
|
||||
struct mtexinfo_s *next; /* animation chain */
|
||||
gl3image_t *image;
|
||||
} mtexinfo_t;
|
||||
|
||||
typedef struct glpoly_s
|
||||
{
|
||||
|
|
|
@ -83,8 +83,6 @@ typedef struct image_s* (*loadimage_t)(const char *name, byte *pic, int width, i
|
|||
extern struct image_s* LoadWal(const char *origname, imagetype_t type, loadimage_t load_image);
|
||||
extern struct image_s* LoadM8(const char *origname, imagetype_t type, loadimage_t load_image);
|
||||
extern struct image_s* LoadM32(const char *origname, imagetype_t type, loadimage_t load_image);
|
||||
extern struct image_s* LoadImage(const char *name, const char* namewe, const char *ext, imagetype_t type,
|
||||
qboolean r_retexturing, loadimage_t load_image);
|
||||
extern void FixFileExt(const char *origname, const char *ext, char *filename, size_t size);
|
||||
extern void GetPCXPalette(byte **colormap, unsigned *d_8to24table);
|
||||
extern void LoadPCX(const char *origname, byte **pic, byte **palette, int *width, int *height);
|
||||
|
@ -93,7 +91,6 @@ extern void GetWalInfo(const char *name, int *width, int *height);
|
|||
extern void GetM8Info(const char *name, int *width, int *height);
|
||||
extern void GetM32Info(const char *name, int *width, int *height);
|
||||
|
||||
extern qboolean LoadSTB(const char *origname, const char* type, byte **pic, int *width, int *height);
|
||||
extern qboolean ResizeSTB(const byte *input_pixels, int input_width, int input_height,
|
||||
byte *output_pixels, int output_width, int output_height);
|
||||
extern void SmoothColorImage(unsigned *dst, size_t size, size_t rstep);
|
||||
|
@ -103,7 +100,30 @@ extern void scale3x(const byte *src, byte *dst, int width, int height);
|
|||
extern float Mod_RadiusFromBounds(const vec3_t mins, const vec3_t maxs);
|
||||
extern const byte* Mod_DecompressVis(const byte *in, int row);
|
||||
|
||||
/* Shared models load */
|
||||
/* Shared models struct */
|
||||
|
||||
typedef struct mvertex_s
|
||||
{
|
||||
vec3_t position;
|
||||
} mvertex_t;
|
||||
|
||||
typedef struct medge_s
|
||||
{
|
||||
unsigned short v[2];
|
||||
unsigned int cachededgeoffset;
|
||||
} medge_t;
|
||||
|
||||
typedef struct mtexinfo_s
|
||||
{
|
||||
float vecs[2][4];
|
||||
float mipadjust; /* FIXME: Used only by soft render */
|
||||
int flags;
|
||||
int numframes;
|
||||
struct mtexinfo_s *next; /* animation chain */
|
||||
struct image_s *image;
|
||||
} mtexinfo_t;
|
||||
|
||||
/* Shared models func */
|
||||
typedef struct image_s* (*findimage_t)(const char *name, imagetype_t type);
|
||||
extern void *Mod_LoadMD2 (const char *mod_name, const void *buffer, int modfilelen,
|
||||
vec3_t mins, vec3_t maxs, struct image_s **skins,
|
||||
|
@ -115,6 +135,8 @@ extern int Mod_ReLoadSkins(struct image_s **skins, findimage_t find_image,
|
|||
extern struct image_s *GetSkyImage(const char *skyname, const char* surfname,
|
||||
qboolean palettedtexture, findimage_t find_image);
|
||||
extern struct image_s *GetTexImage(const char *name, findimage_t find_image);
|
||||
extern struct image_s *FindPic(const char *name, findimage_t find_image);
|
||||
extern struct image_s *R_FindPic(const char *name, findimage_t find_image);
|
||||
extern struct image_s* R_LoadImage(const char *name, const char* namewe, const char *ext, imagetype_t type,
|
||||
qboolean r_retexturing, loadimage_t load_image);
|
||||
|
||||
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */
|
||||
|
|
|
@ -37,15 +37,9 @@ BRUSH MODELS
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
|
||||
//
|
||||
// in memory representation
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
vec3_t position;
|
||||
} mvertex_t;
|
||||
|
||||
|
||||
// FIXME: differentiate from texinfo SURF_ flags
|
||||
#define SURF_PLANEBACK 0x02
|
||||
|
@ -56,22 +50,6 @@ typedef struct
|
|||
|
||||
#define SURF_FLOW 0x100
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short v[2];
|
||||
unsigned int cachededgeoffset;
|
||||
} medge_t;
|
||||
|
||||
typedef struct mtexinfo_s
|
||||
{
|
||||
float vecs[2][4];
|
||||
float mipadjust;
|
||||
image_t *image;
|
||||
int flags;
|
||||
int numframes;
|
||||
struct mtexinfo_s *next; // animation chain
|
||||
} mtexinfo_t;
|
||||
|
||||
typedef struct msurface_s
|
||||
{
|
||||
int visframe; // should be drawn when node is crossed
|
||||
|
@ -108,6 +86,7 @@ typedef struct mnode_s
|
|||
int contents; // CONTENTS_NODE, to differentiate from leafs
|
||||
int visframe; // node needs to be traversed if current
|
||||
|
||||
/* FIXME: is different type in other renders */
|
||||
short minmaxs[6]; // for bounding box culling
|
||||
|
||||
struct mnode_s *parent;
|
||||
|
|
|
@ -35,7 +35,7 @@ RE_Draw_FindPic
|
|||
image_t *
|
||||
RE_Draw_FindPic (char *name)
|
||||
{
|
||||
return FindPic(name, (findimage_t)R_FindImage);
|
||||
return R_FindPic(name, (findimage_t)R_FindImage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ Draw_InitLocal
|
|||
void
|
||||
Draw_InitLocal (void)
|
||||
{
|
||||
draw_chars = FindPic ("conchars", (findimage_t)R_FindImage);
|
||||
draw_chars = R_FindPic ("conchars", (findimage_t)R_FindImage);
|
||||
if (!draw_chars)
|
||||
{
|
||||
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/conchars.pcx", __func__);
|
||||
|
@ -148,7 +148,7 @@ RE_Draw_GetPicSize (int *w, int *h, char *name)
|
|||
{
|
||||
image_t *image;
|
||||
|
||||
image = FindPic (name, (findimage_t)R_FindImage);
|
||||
image = R_FindPic (name, (findimage_t)R_FindImage);
|
||||
if (!image)
|
||||
{
|
||||
*w = *h = -1;
|
||||
|
@ -306,7 +306,7 @@ RE_Draw_StretchPic (int x, int y, int w, int h, char *name)
|
|||
{
|
||||
image_t *pic;
|
||||
|
||||
pic = FindPic (name, (findimage_t)R_FindImage);
|
||||
pic = R_FindPic (name, (findimage_t)R_FindImage);
|
||||
if (!pic)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Can't find pic: %s\n", name);
|
||||
|
@ -379,7 +379,7 @@ RE_Draw_PicScaled(int x, int y, char *name, float scale)
|
|||
{
|
||||
image_t *pic;
|
||||
|
||||
pic = FindPic (name, (findimage_t)R_FindImage);
|
||||
pic = R_FindPic (name, (findimage_t)R_FindImage);
|
||||
if (!pic)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Can't find pic: %s\n", name);
|
||||
|
@ -429,7 +429,7 @@ RE_Draw_TileClear (int x, int y, int w, int h, char *name)
|
|||
VID_DamageBuffer(x, y);
|
||||
VID_DamageBuffer(x + w, y + h);
|
||||
|
||||
pic = FindPic (name, (findimage_t)R_FindImage);
|
||||
pic = R_FindPic (name, (findimage_t)R_FindImage);
|
||||
if (!pic)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Can't find pic: %s\n", name);
|
||||
|
|
|
@ -538,7 +538,7 @@ R_FindImage(const char *name, imagetype_t type)
|
|||
//
|
||||
// load the pic from disk
|
||||
//
|
||||
image = (image_t *)LoadImage(name, namewe, ext, type,
|
||||
image = (image_t *)R_LoadImage(name, namewe, ext, type,
|
||||
r_retexturing->value, (loadimage_t)R_LoadPic);
|
||||
|
||||
if (!image && r_validation->value)
|
||||
|
|
|
@ -1032,7 +1032,7 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
|
|||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1, 0);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFS], sizeof(dleaf_t), sizeof(mleaf_t), 0);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_NODES], sizeof(dnode_t), sizeof(mnode_t), 0);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(dmodel_t), 0);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(model_t), 0);
|
||||
|
||||
hunkSize += 1048576; // 1MB extra just in case
|
||||
|
||||
|
|
Loading…
Reference in a new issue