mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-19 07:51:03 +00:00
render: extend vertex to short
This commit is contained in:
parent
f89ea15d14
commit
f9a2fee5b3
10 changed files with 208 additions and 116 deletions
|
@ -31,8 +31,8 @@ static float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
|||
};
|
||||
|
||||
void
|
||||
R_LerpVerts(qboolean powerUpEffect, int nverts, dtrivertx_t *v, dtrivertx_t *ov,
|
||||
dtrivertx_t *verts, float *lerp, const float move[3],
|
||||
R_LerpVerts(qboolean powerUpEffect, int nverts, dxtrivertx_t *v, dxtrivertx_t *ov,
|
||||
dxtrivertx_t *verts, float *lerp, const float move[3],
|
||||
const float frontv[3], const float backv[3])
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -83,29 +83,39 @@ Load the Quake2 md2 default format frames
|
|||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadFrames_MD2(dmdx_t *pheader, byte *src, vec3_t translate)
|
||||
Mod_LoadFrames_MD2(dmdx_t *pheader, byte *src, size_t inframesize, vec3_t translate)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i < pheader->num_frames ; i++)
|
||||
{
|
||||
daliasframe_t *pinframe, *poutframe;
|
||||
daliasframe_t *pinframe;
|
||||
daliasxframe_t *poutframe;
|
||||
int j;
|
||||
|
||||
pinframe = (daliasframe_t *) (src + i * pheader->framesize);
|
||||
poutframe = (daliasframe_t *) ((byte *)pheader
|
||||
pinframe = (daliasframe_t *) (src + i * inframesize);
|
||||
poutframe = (daliasxframe_t *) ((byte *)pheader
|
||||
+ pheader->ofs_frames + i * pheader->framesize);
|
||||
|
||||
memcpy (poutframe->name, pinframe->name, sizeof(poutframe->name));
|
||||
for (j=0 ; j<3 ; j++)
|
||||
{
|
||||
poutframe->scale[j] = LittleFloat (pinframe->scale[j]);
|
||||
poutframe->scale[j] = LittleFloat (pinframe->scale[j]) / 0xFF;
|
||||
poutframe->translate[j] = LittleFloat (pinframe->translate[j]);
|
||||
poutframe->translate[j] += translate[j];
|
||||
}
|
||||
// verts are all 8 bit, so no swapping needed
|
||||
memcpy (poutframe->verts, pinframe->verts,
|
||||
pheader->num_xyz * sizeof(dtrivertx_t));
|
||||
for (j=0; j < pheader->num_xyz; j ++)
|
||||
{
|
||||
int k;
|
||||
|
||||
for (k=0; k < 3; k++)
|
||||
{
|
||||
poutframe->verts[j].v[k] = pinframe->verts[j].v[k] * 0xFF;
|
||||
}
|
||||
|
||||
poutframe->verts[j].lightnormalindex = pinframe->verts[j].lightnormalindex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,20 +234,23 @@ Load the DKM v2 frames
|
|||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadFrames_DKM2(dmdx_t *pheader, const byte *src, size_t infamesize, vec3_t translate)
|
||||
Mod_LoadFrames_DKM2(dmdx_t *pheader, const byte *src, size_t inframesize, vec3_t translate)
|
||||
{
|
||||
int i;
|
||||
int i, outframesize;
|
||||
|
||||
outframesize = sizeof(daliasxframe_t) + (pheader->num_xyz - 1) * sizeof(dxtrivertx_t);
|
||||
|
||||
for (i=0 ; i<pheader->num_frames ; i++)
|
||||
{
|
||||
daliasframe_t *pinframe, *poutframe;
|
||||
dtrivertx_t *outverts;
|
||||
byte *inverts;
|
||||
daliasframe_t *pinframe;
|
||||
daliasxframe_t *poutframe;
|
||||
int j;
|
||||
dxtrivertx_t *outverts;
|
||||
byte *inverts;
|
||||
|
||||
pinframe = (daliasframe_t *) (src + i * infamesize);
|
||||
poutframe = (daliasframe_t *) ((byte *)pheader
|
||||
+ pheader->ofs_frames + i * pheader->framesize);
|
||||
pinframe = (daliasframe_t *) (src + i * inframesize);
|
||||
poutframe = (daliasxframe_t *) ((byte *)pheader
|
||||
+ pheader->ofs_frames + i * outframesize);
|
||||
|
||||
memcpy (poutframe->name, pinframe->name, sizeof(poutframe->name));
|
||||
for (j=0 ; j<3 ; j++)
|
||||
|
@ -247,9 +260,9 @@ Mod_LoadFrames_DKM2(dmdx_t *pheader, const byte *src, size_t infamesize, vec3_t
|
|||
poutframe->translate[j] += translate[j];
|
||||
}
|
||||
|
||||
poutframe->scale[0] *= 8;
|
||||
poutframe->scale[1] *= 4;
|
||||
poutframe->scale[2] *= 8;
|
||||
poutframe->scale[0] *= (0x7FF / (float)0xFFFF);
|
||||
poutframe->scale[1] *= (0x3FF / (float)0xFFFF);
|
||||
poutframe->scale[2] *= (0x7FF / (float)0xFFFF);
|
||||
|
||||
inverts = (byte *)&pinframe->verts;
|
||||
outverts = poutframe->verts;
|
||||
|
@ -259,9 +272,12 @@ Mod_LoadFrames_DKM2(dmdx_t *pheader, const byte *src, size_t infamesize, vec3_t
|
|||
int xyz;
|
||||
|
||||
xyz = LittleLong(*((int *)inverts));
|
||||
outverts[j].v[0] = ((xyz & 0xFFE00000) >> (21 + 3)) & 0xFF;
|
||||
outverts[j].v[1] = ((xyz & 0x1FF800) >> (11 + 2)) & 0xFF;
|
||||
outverts[j].v[2] = ((xyz & 0x7FF) >> 3) & 0xFF;
|
||||
outverts[j].v[0] = ((xyz & 0xFFE00000) >> 21) & 0x7FF;
|
||||
outverts[j].v[0] *= ((float)0xFFFF / 0x7FF);
|
||||
outverts[j].v[1] = ((xyz & 0x1FF800) >> 11) & 0x3FF;
|
||||
outverts[j].v[1] *= ((float)0xFFFF / 0x3FF);
|
||||
outverts[j].v[2] = xyz & 0x7FF;
|
||||
outverts[j].v[2] *= ((float)0xFFFF / 0x7FF);
|
||||
inverts += sizeof(int);
|
||||
outverts[j].lightnormalindex = *inverts;
|
||||
inverts ++;
|
||||
|
@ -315,7 +331,8 @@ Mod_LoadModel_MDL(const char *mod_name, const void *buffer, int modfilelen,
|
|||
(num_tris * sizeof(int)) + /* triangles count */
|
||||
sizeof(int) /* final zero */) / sizeof(int);
|
||||
num_frames = LittleLong(pinmodel->num_frames);
|
||||
framesize = sizeof(daliasframe_t) + sizeof(dtrivertx_t) * (num_xyz - 1);
|
||||
|
||||
framesize = sizeof(daliasxframe_t) + sizeof(dxtrivertx_t) * (num_xyz - 1);
|
||||
|
||||
ofs_meshes = sizeof(*pheader); // just skip header and go
|
||||
ofs_skins = ofs_meshes + num_meshes * sizeof(dmdxmesh_t);
|
||||
|
@ -536,12 +553,15 @@ Mod_LoadModel_MDL(const char *mod_name, const void *buffer, int modfilelen,
|
|||
for (i = 0; i < num_frames; ++i)
|
||||
{
|
||||
daliasframe_t *frame;
|
||||
int frame_type;
|
||||
int frame_type, j;
|
||||
dxtrivertx_t* poutvertx;
|
||||
dtrivertx_t *pinvertx;
|
||||
|
||||
|
||||
frame = (daliasframe_t *) ((byte *)pheader + ofs_frames + i * framesize);
|
||||
frame->scale[0] = LittleFloat (pinmodel->scale[0]);
|
||||
frame->scale[1] = LittleFloat (pinmodel->scale[1]);
|
||||
frame->scale[2] = LittleFloat (pinmodel->scale[2]);
|
||||
frame->scale[0] = LittleFloat (pinmodel->scale[0]) / 0xFF;
|
||||
frame->scale[1] = LittleFloat (pinmodel->scale[1]) / 0xFF;
|
||||
frame->scale[2] = LittleFloat (pinmodel->scale[2]) / 0xFF;
|
||||
|
||||
frame->translate[0] = LittleFloat (pinmodel->translate[0]);
|
||||
frame->translate[1] = LittleFloat (pinmodel->translate[1]);
|
||||
|
@ -568,8 +588,20 @@ Mod_LoadModel_MDL(const char *mod_name, const void *buffer, int modfilelen,
|
|||
memcpy(&frame->name, curr_pos, sizeof(char) * 16);
|
||||
curr_pos += sizeof(char) * 16;
|
||||
|
||||
memcpy(&frame->verts[0], curr_pos,
|
||||
sizeof(dtrivertx_t) * num_xyz);
|
||||
poutvertx = (dxtrivertx_t*)&frame->verts[0];
|
||||
pinvertx = (dtrivertx_t*)curr_pos;
|
||||
// verts are all 8 bit, so no swapping needed
|
||||
for (j=0; j < num_xyz; j ++)
|
||||
{
|
||||
int k;
|
||||
|
||||
for (k=0; k < 3; k++)
|
||||
{
|
||||
poutvertx[j].v[k] = pinvertx[j].v[k] * 0xFF;
|
||||
}
|
||||
|
||||
poutvertx[j].lightnormalindex = pinvertx[j].lightnormalindex;
|
||||
}
|
||||
curr_pos += sizeof(dtrivertx_t) * num_xyz;
|
||||
}
|
||||
}
|
||||
|
@ -602,12 +634,10 @@ Mod_LoadModel_MD2(const char *mod_name, const void *buffer, int modfilelen,
|
|||
dtriangle_t *pintri;
|
||||
dstvert_t *pinst;
|
||||
dmdxmesh_t *mesh_nodes;
|
||||
int *pincmd, header_diff;
|
||||
int *pincmd;
|
||||
void *extradata;
|
||||
int i;
|
||||
|
||||
/* fix for offset */
|
||||
header_diff = sizeof(*pheader) - sizeof(pinmodel) + sizeof(dmdxmesh_t);
|
||||
int i, framesize;
|
||||
int ofs_meshes, ofs_skins, ofs_st, ofs_tris, ofs_glcmds, ofs_frames, ofs_end;
|
||||
|
||||
if (modfilelen < sizeof(pinmodel))
|
||||
{
|
||||
|
@ -642,17 +672,35 @@ Mod_LoadModel_MD2(const char *mod_name, const void *buffer, int modfilelen,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (pinmodel.framesize != (
|
||||
sizeof(daliasframe_t) + (pinmodel.num_xyz - 1) * sizeof(dtrivertx_t)))
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: model %s has incorrect framesize",
|
||||
__func__, mod_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
framesize = sizeof(daliasxframe_t) +
|
||||
(pinmodel.num_xyz - 1) * sizeof(dxtrivertx_t);
|
||||
ofs_meshes = sizeof(*pheader); // just skip header and go
|
||||
ofs_skins = ofs_meshes + 1 * sizeof(dmdxmesh_t);
|
||||
ofs_st = ofs_skins + pinmodel.num_skins * MAX_SKINNAME;
|
||||
ofs_tris = ofs_st + pinmodel.num_st * sizeof(dstvert_t);
|
||||
ofs_glcmds = ofs_tris + pinmodel.num_tris * sizeof(dtriangle_t);
|
||||
ofs_frames = ofs_glcmds + pinmodel.num_glcmds * sizeof(int);
|
||||
ofs_end = ofs_frames + framesize * pinmodel.num_frames;
|
||||
|
||||
*numskins = pinmodel.num_skins;
|
||||
extradata = Hunk_Begin(header_diff + pinmodel.ofs_end +
|
||||
extradata = Hunk_Begin(ofs_end +
|
||||
Q_max(*numskins, MAX_MD2SKINS) * sizeof(struct image_s *));
|
||||
pheader = Hunk_Alloc(header_diff + pinmodel.ofs_end);
|
||||
pheader = Hunk_Alloc(ofs_end);
|
||||
*skins = Hunk_Alloc((*numskins) * sizeof(struct image_s *));
|
||||
|
||||
/* Copy values as we have mostly same data format */
|
||||
memset(pheader, 0, sizeof(*pheader));
|
||||
pheader->skinwidth = pinmodel.skinwidth;
|
||||
pheader->skinheight = pinmodel.skinheight;
|
||||
pheader->framesize = pinmodel.framesize;
|
||||
pheader->framesize = framesize;
|
||||
|
||||
pheader->num_meshes = 1;
|
||||
pheader->num_skins = pinmodel.num_skins;
|
||||
|
@ -662,13 +710,13 @@ Mod_LoadModel_MD2(const char *mod_name, const void *buffer, int modfilelen,
|
|||
pheader->num_glcmds = pinmodel.num_glcmds;
|
||||
pheader->num_frames = pinmodel.num_frames;
|
||||
|
||||
pheader->ofs_meshes = sizeof(*pheader); // just skip header and go
|
||||
pheader->ofs_skins = pheader->ofs_meshes + pheader->num_meshes * sizeof(dmdxmesh_t);
|
||||
pheader->ofs_st = pheader->ofs_skins + pheader->num_skins * MAX_SKINNAME;
|
||||
pheader->ofs_tris = pheader->ofs_st + pheader->num_st * sizeof(dstvert_t);
|
||||
pheader->ofs_glcmds = pheader->ofs_tris + pheader->num_tris * sizeof(dtriangle_t);
|
||||
pheader->ofs_frames = pheader->ofs_glcmds + pheader->num_glcmds * sizeof(int);
|
||||
pheader->ofs_end = pheader->ofs_frames + pheader->framesize * pheader->num_frames;
|
||||
pheader->ofs_meshes = ofs_meshes;
|
||||
pheader->ofs_skins = ofs_skins;
|
||||
pheader->ofs_st = ofs_st;
|
||||
pheader->ofs_tris = ofs_tris;
|
||||
pheader->ofs_glcmds = ofs_glcmds;
|
||||
pheader->ofs_frames = ofs_frames;
|
||||
pheader->ofs_end = ofs_end;
|
||||
|
||||
/* create single mesh */
|
||||
mesh_nodes = (dmdxmesh_t *)((char *)pheader + pheader->ofs_meshes);
|
||||
|
@ -732,7 +780,8 @@ Mod_LoadModel_MD2(const char *mod_name, const void *buffer, int modfilelen,
|
|||
//
|
||||
// load the frames
|
||||
//
|
||||
Mod_LoadFrames_MD2(pheader, (byte *)buffer + pinmodel.ofs_frames, translate);
|
||||
Mod_LoadFrames_MD2(pheader, (byte *)buffer + pinmodel.ofs_frames,
|
||||
pinmodel.framesize, translate);
|
||||
|
||||
//
|
||||
// load the glcmds
|
||||
|
@ -741,7 +790,7 @@ Mod_LoadModel_MD2(const char *mod_name, const void *buffer, int modfilelen,
|
|||
Mod_LoadCmdList(mod_name, pheader, pincmd);
|
||||
|
||||
// register all skins
|
||||
memcpy ((char *)pheader + pheader->ofs_skins, (char *)buffer + pinmodel.ofs_skins,
|
||||
memcpy((char *)pheader + pheader->ofs_skins, (char *)buffer + pinmodel.ofs_skins,
|
||||
pheader->num_skins*MAX_SKINNAME);
|
||||
|
||||
*type = mod_alias;
|
||||
|
@ -768,7 +817,7 @@ Mod_LoadModel_Flex(const char *mod_name, const void *buffer, int modfilelen,
|
|||
modtype_t *type)
|
||||
{
|
||||
char *src = (char *)buffer;
|
||||
int version, size;
|
||||
int version, size, inframesize = 0;
|
||||
void *extradata = NULL;
|
||||
dmdx_t *pheader = NULL;
|
||||
|
||||
|
@ -787,6 +836,7 @@ Mod_LoadModel_Flex(const char *mod_name, const void *buffer, int modfilelen,
|
|||
|
||||
if (Q_strncasecmp(blockname, "header", sizeof(blockname)) == 0)
|
||||
{
|
||||
int framesize;
|
||||
dmdx_t dmdxheader;
|
||||
fmheader_t *header = (fmheader_t *)src;
|
||||
|
||||
|
@ -803,11 +853,24 @@ Mod_LoadModel_Flex(const char *mod_name, const void *buffer, int modfilelen,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
inframesize = LittleLong(header->framesize);
|
||||
/* has same frame structure */
|
||||
if (inframesize < (
|
||||
sizeof(daliasframe_t) + (LittleLong(header->num_xyz) - 1) * sizeof(dtrivertx_t)))
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: model %s has incorrect framesize",
|
||||
__func__, mod_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
framesize = sizeof(daliasxframe_t) +
|
||||
(LittleLong(header->num_xyz) - 1) * sizeof(dxtrivertx_t);
|
||||
|
||||
/* copy back all values */
|
||||
memset(&dmdxheader, 0, sizeof(dmdxheader));
|
||||
dmdxheader.skinwidth = LittleLong(header->skinwidth);
|
||||
dmdxheader.skinheight = LittleLong(header->skinheight);
|
||||
dmdxheader.framesize = LittleLong(header->framesize);
|
||||
dmdxheader.framesize = framesize;
|
||||
|
||||
dmdxheader.num_skins = LittleLong(header->num_skins);
|
||||
dmdxheader.num_xyz = LittleLong(header->num_xyz);
|
||||
|
@ -942,14 +1005,16 @@ Mod_LoadModel_Flex(const char *mod_name, const void *buffer, int modfilelen,
|
|||
__func__, blockname, version);
|
||||
return NULL;
|
||||
}
|
||||
if (size != (pheader->num_frames * pheader->framesize))
|
||||
|
||||
if (size < (pheader->num_frames *
|
||||
(sizeof(daliasframe_t) + (pheader->num_xyz - 1) * sizeof(dtrivertx_t))))
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: Invalid %s size",
|
||||
__func__, blockname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Mod_LoadFrames_MD2(pheader, (byte *)src, translate);
|
||||
Mod_LoadFrames_MD2(pheader, (byte *)src, inframesize, translate);
|
||||
}
|
||||
else if (Q_strncasecmp(blockname, "glcmds", sizeof(blockname)) == 0)
|
||||
{
|
||||
|
@ -1089,14 +1154,28 @@ Mod_LoadModel_DKM(const char *mod_name, const void *buffer, int modfilelen,
|
|||
if (header.version != DKM2_VERSION)
|
||||
{
|
||||
/* has same frame structure */
|
||||
dmdxheader.framesize = header.framesize;
|
||||
if (header.framesize < (
|
||||
sizeof(daliasframe_t) + (header.num_xyz - 1) * sizeof(dtrivertx_t)))
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: model %s has incorrect framesize",
|
||||
__func__, mod_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dmdxheader.framesize = sizeof(daliasframe_t) - sizeof(dtrivertx_t);
|
||||
dmdxheader.framesize += header.num_xyz * sizeof(dtrivertx_t);
|
||||
if (header.framesize < (
|
||||
sizeof(daliasframe_t) + (header.num_xyz - 1) * (sizeof(int) + sizeof(byte))))
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: model %s has incorrect framesize",
|
||||
__func__, mod_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
dmdxheader.framesize = sizeof(daliasxframe_t) - sizeof(dxtrivertx_t);
|
||||
dmdxheader.framesize += header.num_xyz * sizeof(dxtrivertx_t);
|
||||
|
||||
dmdxheader.num_meshes = 1;
|
||||
dmdxheader.num_skins = header.num_skins;
|
||||
dmdxheader.num_xyz = header.num_xyz;
|
||||
|
@ -1135,7 +1214,7 @@ Mod_LoadModel_DKM(const char *mod_name, const void *buffer, int modfilelen,
|
|||
if (header.version == DKM1_VERSION)
|
||||
{
|
||||
Mod_LoadFrames_MD2(pheader, (byte *)buffer + header.ofs_frames,
|
||||
header.translate);
|
||||
header.framesize, header.translate);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ float *shadedots = r_avertexnormal_dots[0];
|
|||
|
||||
static void
|
||||
R_DrawAliasDrawCommands(entity_t *currententity, int *order, int *order_end,
|
||||
float alpha, dtrivertx_t *verts)
|
||||
float alpha, dxtrivertx_t *verts)
|
||||
{
|
||||
#ifdef _MSC_VER // workaround for lack of VLAs (=> our workaround uses alloca() which is bad in loops)
|
||||
int maxCount = 0;
|
||||
|
@ -177,8 +177,8 @@ R_DrawAliasDrawCommands(entity_t *currententity, int *order, int *order_end,
|
|||
static void
|
||||
R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp)
|
||||
{
|
||||
daliasframe_t *frame, *oldframe;
|
||||
dtrivertx_t *v, *ov, *verts;
|
||||
daliasxframe_t *frame, *oldframe;
|
||||
dxtrivertx_t *v, *ov, *verts;
|
||||
int *order;
|
||||
float frontlerp;
|
||||
float alpha;
|
||||
|
@ -192,11 +192,11 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp)
|
|||
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE |
|
||||
RF_SHELL_HALF_DAM));
|
||||
|
||||
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
frame = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ currententity->frame * paliashdr->framesize);
|
||||
verts = v = frame->verts;
|
||||
|
||||
oldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
oldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ currententity->oldframe * paliashdr->framesize);
|
||||
ov = oldframe->verts;
|
||||
|
||||
|
@ -390,7 +390,7 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
|
|||
dmdx_t *paliashdr;
|
||||
vec3_t vectors[3];
|
||||
vec3_t thismins, oldmins, thismaxs, oldmaxs;
|
||||
daliasframe_t *pframe, *poldframe;
|
||||
daliasxframe_t *pframe, *poldframe;
|
||||
vec3_t angles;
|
||||
|
||||
paliashdr = (dmdx_t *)currentmodel->extradata;
|
||||
|
@ -415,10 +415,10 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
|
|||
e->oldframe = 0;
|
||||
}
|
||||
|
||||
pframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
pframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
e->frame * paliashdr->framesize);
|
||||
|
||||
poldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
poldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
e->oldframe * paliashdr->framesize);
|
||||
|
||||
/* compute axially aligned mins and maxs */
|
||||
|
@ -427,7 +427,7 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
mins[i] = pframe->translate[i];
|
||||
maxs[i] = mins[i] + pframe->scale[i] * 255;
|
||||
maxs[i] = mins[i] + pframe->scale[i] * 0xFFFF;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -435,10 +435,10 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
thismins[i] = pframe->translate[i];
|
||||
thismaxs[i] = thismins[i] + pframe->scale[i] * 255;
|
||||
thismaxs[i] = thismins[i] + pframe->scale[i] * 0xFFFF;
|
||||
|
||||
oldmins[i] = poldframe->translate[i];
|
||||
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 255;
|
||||
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 0xFFFF;
|
||||
|
||||
if (thismins[i] < oldmins[i])
|
||||
{
|
||||
|
|
|
@ -70,7 +70,7 @@ GL3_ShutdownMeshes(void)
|
|||
static void
|
||||
DrawAliasFrameLerpCommands(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight,
|
||||
int *order, int *order_end, float* shadedots, float alpha, qboolean colorOnly,
|
||||
dtrivertx_t *verts)
|
||||
dxtrivertx_t *verts)
|
||||
{
|
||||
// all the triangle fans and triangle strips of this model will be converted to
|
||||
// just triangles: the vertices stay the same and are batched in vtxBuf,
|
||||
|
@ -218,8 +218,8 @@ DrawAliasFrameLerpCommands(dmdx_t *paliashdr, entity_t* entity, vec3_t shadeligh
|
|||
static void
|
||||
DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
|
||||
{
|
||||
daliasframe_t *frame, *oldframe;
|
||||
dtrivertx_t *v, *ov, *verts;
|
||||
daliasxframe_t *frame, *oldframe;
|
||||
dxtrivertx_t *v, *ov, *verts;
|
||||
int *order;
|
||||
float alpha;
|
||||
vec3_t move, delta, vectors[3];
|
||||
|
@ -239,11 +239,11 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
|
|||
float* shadedots = r_avertexnormal_dots[((int)(entity->angles[1] *
|
||||
(SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];
|
||||
|
||||
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
frame = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ entity->frame * paliashdr->framesize);
|
||||
verts = v = frame->verts;
|
||||
|
||||
oldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
oldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ entity->oldframe * paliashdr->framesize);
|
||||
ov = oldframe->verts;
|
||||
|
||||
|
@ -434,18 +434,18 @@ DrawAliasShadow(gl3_shadowinfo_t* shadowInfo)
|
|||
|
||||
// all in this scope is to set s_lerped
|
||||
{
|
||||
daliasframe_t *frame, *oldframe;
|
||||
dtrivertx_t *v, *ov, *verts;
|
||||
daliasxframe_t *frame, *oldframe;
|
||||
dxtrivertx_t *v, *ov, *verts;
|
||||
float backlerp = entity->backlerp;
|
||||
float frontlerp = 1.0f - backlerp;
|
||||
vec3_t move, delta, vectors[3];
|
||||
vec3_t frontv, backv;
|
||||
|
||||
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
frame = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ entity->frame * paliashdr->framesize);
|
||||
verts = v = frame->verts;
|
||||
|
||||
oldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
oldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ entity->oldframe * paliashdr->framesize);
|
||||
ov = oldframe->verts;
|
||||
|
||||
|
@ -497,7 +497,7 @@ CullAliasModel(vec3_t bbox[8], entity_t *e)
|
|||
dmdx_t *paliashdr;
|
||||
vec3_t vectors[3];
|
||||
vec3_t thismins, oldmins, thismaxs, oldmaxs;
|
||||
daliasframe_t *pframe, *poldframe;
|
||||
daliasxframe_t *pframe, *poldframe;
|
||||
vec3_t angles;
|
||||
|
||||
gl3model_t* model = e->model;
|
||||
|
@ -518,10 +518,10 @@ CullAliasModel(vec3_t bbox[8], entity_t *e)
|
|||
e->oldframe = 0;
|
||||
}
|
||||
|
||||
pframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
pframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
e->frame * paliashdr->framesize);
|
||||
|
||||
poldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
poldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
e->oldframe * paliashdr->framesize);
|
||||
|
||||
/* compute axially aligned mins and maxs */
|
||||
|
@ -530,7 +530,7 @@ CullAliasModel(vec3_t bbox[8], entity_t *e)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
mins[i] = pframe->translate[i];
|
||||
maxs[i] = mins[i] + pframe->scale[i] * 255;
|
||||
maxs[i] = mins[i] + pframe->scale[i] * 0xFFFF;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -538,10 +538,10 @@ CullAliasModel(vec3_t bbox[8], entity_t *e)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
thismins[i] = pframe->translate[i];
|
||||
thismaxs[i] = thismins[i] + pframe->scale[i] * 255;
|
||||
thismaxs[i] = thismins[i] + pframe->scale[i] * 0xFFFF;
|
||||
|
||||
oldmins[i] = poldframe->translate[i];
|
||||
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 255;
|
||||
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 0xFFFF;
|
||||
|
||||
if (thismins[i] < oldmins[i])
|
||||
{
|
||||
|
|
|
@ -75,8 +75,8 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
|
|||
{
|
||||
GLenum type;
|
||||
float l;
|
||||
daliasframe_t *frame, *oldframe;
|
||||
dtrivertx_t *v, *ov, *verts;
|
||||
daliasxframe_t *frame, *oldframe;
|
||||
dxtrivertx_t *v, *ov, *verts;
|
||||
int *order;
|
||||
int count;
|
||||
float alpha;
|
||||
|
@ -96,11 +96,11 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight)
|
|||
float* shadedots = r_avertexnormal_dots[((int)(entity->angles[1] *
|
||||
(SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];
|
||||
|
||||
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
frame = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ entity->frame * paliashdr->framesize);
|
||||
verts = v = frame->verts;
|
||||
|
||||
oldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
oldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ entity->oldframe * paliashdr->framesize);
|
||||
ov = oldframe->verts;
|
||||
|
||||
|
@ -305,19 +305,19 @@ DrawAliasShadow(gl4_shadowinfo_t* shadowInfo)
|
|||
|
||||
// all in this scope is to set s_lerped
|
||||
{
|
||||
daliasframe_t *frame, *oldframe;
|
||||
dtrivertx_t *v, *ov, *verts;
|
||||
daliasxframe_t *frame, *oldframe;
|
||||
dxtrivertx_t *v, *ov, *verts;
|
||||
float backlerp = entity->backlerp;
|
||||
float frontlerp = 1.0f - backlerp;
|
||||
vec3_t move, delta, vectors[3];
|
||||
vec3_t frontv, backv;
|
||||
int i;
|
||||
|
||||
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
frame = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ entity->frame * paliashdr->framesize);
|
||||
verts = v = frame->verts;
|
||||
|
||||
oldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
oldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ entity->oldframe * paliashdr->framesize);
|
||||
ov = oldframe->verts;
|
||||
|
||||
|
@ -457,7 +457,7 @@ CullAliasModel(vec3_t bbox[8], entity_t *e)
|
|||
dmdx_t *paliashdr;
|
||||
vec3_t vectors[3];
|
||||
vec3_t thismins, oldmins, thismaxs, oldmaxs;
|
||||
daliasframe_t *pframe, *poldframe;
|
||||
daliasxframe_t *pframe, *poldframe;
|
||||
vec3_t angles;
|
||||
|
||||
gl4model_t* model = e->model;
|
||||
|
@ -478,10 +478,10 @@ CullAliasModel(vec3_t bbox[8], entity_t *e)
|
|||
e->oldframe = 0;
|
||||
}
|
||||
|
||||
pframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
pframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
e->frame * paliashdr->framesize);
|
||||
|
||||
poldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
poldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
e->oldframe * paliashdr->framesize);
|
||||
|
||||
/* compute axially aligned mins and maxs */
|
||||
|
@ -490,7 +490,7 @@ CullAliasModel(vec3_t bbox[8], entity_t *e)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
mins[i] = pframe->translate[i];
|
||||
maxs[i] = mins[i] + pframe->scale[i] * 255;
|
||||
maxs[i] = mins[i] + pframe->scale[i] * 0xFFFF;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -498,10 +498,10 @@ CullAliasModel(vec3_t bbox[8], entity_t *e)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
thismins[i] = pframe->translate[i];
|
||||
thismaxs[i] = thismins[i] + pframe->scale[i] * 255;
|
||||
thismaxs[i] = thismins[i] + pframe->scale[i] * 0xFFFF;
|
||||
|
||||
oldmins[i] = poldframe->translate[i];
|
||||
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 255;
|
||||
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 0xFFFF;
|
||||
|
||||
if (thismins[i] < oldmins[i])
|
||||
{
|
||||
|
|
|
@ -377,8 +377,8 @@ extern void R_SubdivideSurface(int *surfedges, mvertex_t *vertexes, medge_t *edg
|
|||
msurface_t *fa);
|
||||
|
||||
/* Mesh logic */
|
||||
extern void R_LerpVerts(qboolean powerUpEffect, int nverts, dtrivertx_t *v, dtrivertx_t *ov,
|
||||
dtrivertx_t *verts, float *lerp, const float move[3],
|
||||
extern void R_LerpVerts(qboolean powerUpEffect, int nverts, dxtrivertx_t *v, dxtrivertx_t *ov,
|
||||
dxtrivertx_t *verts, float *lerp, const float move[3],
|
||||
const float frontv[3], const float backv[3]);
|
||||
|
||||
/* Lights logic */
|
||||
|
|
|
@ -42,7 +42,7 @@ int r_aliasblendcolor;
|
|||
static vec3_t r_shadelight;
|
||||
|
||||
|
||||
static daliasframe_t *r_thisframe, *r_lastframe;
|
||||
static daliasxframe_t *r_thisframe, *r_lastframe;
|
||||
static dmdx_t *s_pmdl;
|
||||
|
||||
static float aliastransform[3][4];
|
||||
|
@ -61,7 +61,7 @@ static const float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
|||
|
||||
|
||||
static void R_AliasTransformVector(const vec3_t in, vec3_t out, const float xf[3][4]);
|
||||
static void R_AliasTransformFinalVerts(const entity_t *currententity, int numpoints, finalvert_t *fv, dtrivertx_t *oldv, dtrivertx_t *newv );
|
||||
static void R_AliasTransformFinalVerts(const entity_t *currententity, int numpoints, finalvert_t *fv, dxtrivertx_t *oldv, dxtrivertx_t *newv );
|
||||
|
||||
void R_AliasProjectAndClipTestFinalVert(finalvert_t *fv);
|
||||
|
||||
|
@ -83,7 +83,7 @@ R_AliasCheckBBox
|
|||
** Checks a specific alias frame bounding box
|
||||
*/
|
||||
static unsigned long
|
||||
R_AliasCheckFrameBBox( daliasframe_t *frame, float worldxf[3][4] )
|
||||
R_AliasCheckFrameBBox( daliasxframe_t *frame, float worldxf[3][4] )
|
||||
{
|
||||
// FIXME: should this really be using long and not int32_t or sth?
|
||||
unsigned long aggregate_and_clipcode = ~0U,
|
||||
|
@ -395,7 +395,7 @@ R_AliasTransformFinalVerts
|
|||
================
|
||||
*/
|
||||
static void
|
||||
R_AliasTransformFinalVerts(const entity_t *currententity, int numpoints, finalvert_t *fv, dtrivertx_t *oldv, dtrivertx_t *newv )
|
||||
R_AliasTransformFinalVerts(const entity_t *currententity, int numpoints, finalvert_t *fv, dxtrivertx_t *oldv, dxtrivertx_t *newv )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -663,10 +663,10 @@ R_AliasSetupFrames(const entity_t *currententity, const model_t *currentmodel, d
|
|||
lastframe = 0;
|
||||
}
|
||||
|
||||
r_thisframe = (daliasframe_t *)((byte *)pmdl + pmdl->ofs_frames
|
||||
r_thisframe = (daliasxframe_t *)((byte *)pmdl + pmdl->ofs_frames
|
||||
+ thisframe * pmdl->framesize);
|
||||
|
||||
r_lastframe = (daliasframe_t *)((byte *)pmdl + pmdl->ofs_frames
|
||||
r_lastframe = (daliasxframe_t *)((byte *)pmdl + pmdl->ofs_frames
|
||||
+ lastframe * pmdl->framesize);
|
||||
}
|
||||
|
||||
|
|
|
@ -427,7 +427,7 @@ D_CacheSurface
|
|||
================
|
||||
*/
|
||||
surfcache_t *
|
||||
D_CacheSurface (const entity_t *currententity, msurface_t *surface, int miplevel)
|
||||
D_CacheSurface(const entity_t *currententity, msurface_t *surface, int miplevel)
|
||||
{
|
||||
surfcache_t *cache;
|
||||
float surfscale;
|
||||
|
@ -457,7 +457,7 @@ D_CacheSurface (const entity_t *currententity, msurface_t *surface, int miplevel
|
|||
//
|
||||
// determine shape of surface
|
||||
//
|
||||
surfscale = 1.0 / (1<<miplevel);
|
||||
surfscale = 1.0 / (1 << miplevel);
|
||||
r_drawsurf.surfmip = miplevel;
|
||||
r_drawsurf.surfwidth = surface->extents[0] >> miplevel;
|
||||
r_drawsurf.rowbytes = r_drawsurf.surfwidth;
|
||||
|
|
|
@ -217,7 +217,7 @@ void Mesh_Free (void)
|
|||
static void
|
||||
Vk_DrawAliasFrameLerpCommands (entity_t *currententity, int *order, int *order_end,
|
||||
float alpha, image_t *skin, float *modelMatrix, int leftHandOffset, int translucentIdx,
|
||||
dtrivertx_t *verts)
|
||||
dxtrivertx_t *verts)
|
||||
{
|
||||
int vertCounts[2] = { 0, 0 };
|
||||
int pipeCounters[2] = { 0, 0 };
|
||||
|
@ -417,8 +417,8 @@ static void
|
|||
Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp, image_t *skin,
|
||||
float *modelMatrix, int leftHandOffset, int translucentIdx)
|
||||
{
|
||||
daliasframe_t *frame, *oldframe;
|
||||
dtrivertx_t *v, *ov, *verts;
|
||||
daliasxframe_t *frame, *oldframe;
|
||||
dxtrivertx_t *v, *ov, *verts;
|
||||
int *order;
|
||||
float frontlerp;
|
||||
float alpha;
|
||||
|
@ -432,11 +432,11 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp
|
|||
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE |
|
||||
RF_SHELL_HALF_DAM));
|
||||
|
||||
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
frame = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ currententity->frame * paliashdr->framesize);
|
||||
verts = v = frame->verts;
|
||||
|
||||
oldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
oldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
|
||||
+ currententity->oldframe * paliashdr->framesize);
|
||||
ov = oldframe->verts;
|
||||
|
||||
|
@ -599,7 +599,7 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
|
|||
dmdx_t *paliashdr;
|
||||
vec3_t vectors[3];
|
||||
vec3_t thismins, oldmins, thismaxs, oldmaxs;
|
||||
daliasframe_t *pframe, *poldframe;
|
||||
daliasxframe_t *pframe, *poldframe;
|
||||
vec3_t angles;
|
||||
|
||||
paliashdr = (dmdx_t *)currentmodel->extradata;
|
||||
|
@ -624,10 +624,10 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
|
|||
e->oldframe = 0;
|
||||
}
|
||||
|
||||
pframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
pframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
e->frame * paliashdr->framesize);
|
||||
|
||||
poldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
poldframe = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames +
|
||||
e->oldframe * paliashdr->framesize);
|
||||
|
||||
/* compute axially aligned mins and maxs */
|
||||
|
@ -636,7 +636,7 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
mins[i] = pframe->translate[i];
|
||||
maxs[i] = mins[i] + pframe->scale[i] * 255;
|
||||
maxs[i] = mins[i] + pframe->scale[i] * 0xFFFF;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -644,10 +644,10 @@ R_CullAliasModel(const model_t *currentmodel, vec3_t bbox[8], entity_t *e)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
thismins[i] = pframe->translate[i];
|
||||
thismaxs[i] = thismins[i] + pframe->scale[i] * 255;
|
||||
thismaxs[i] = thismins[i] + pframe->scale[i] * 0xFFFF;
|
||||
|
||||
oldmins[i] = poldframe->translate[i];
|
||||
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 255;
|
||||
oldmaxs[i] = oldmins[i] + poldframe->scale[i] * 0xFFFF;
|
||||
|
||||
if (thismins[i] < oldmins[i])
|
||||
{
|
||||
|
|
|
@ -245,6 +245,19 @@ typedef struct dkm_header_s
|
|||
#define IDMD5HEADER (('V' << 24) + ('5' << 16) + ('D' << 8) + 'M')
|
||||
|
||||
/* Internal model render format */
|
||||
typedef struct
|
||||
{
|
||||
unsigned short v[3]; /* scaled short to fit in frame mins/maxs */
|
||||
byte lightnormalindex;
|
||||
} dxtrivertx_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float scale[3]; /* multiply short verts by this */
|
||||
float translate[3]; /* then add this */
|
||||
char name[16]; /* frame name from grabbing */
|
||||
dxtrivertx_t verts[1]; /* variable sized */
|
||||
} daliasxframe_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue