mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-29 07:41:47 +00:00
models: add models normal fix
If model has only zero notmal, update model with normal recalculate.
This commit is contained in:
parent
ec8b792a4b
commit
d3bf7368c4
2 changed files with 20 additions and 3 deletions
|
@ -83,7 +83,7 @@ R_ConvertNormalMDL(byte in_normal, signed char *normal)
|
||||||
const float *norm;
|
const float *norm;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
norm = r_avertexnormals[in_normal];
|
norm = r_avertexnormals[in_normal % NUMVERTEXNORMALS];
|
||||||
|
|
||||||
for (n = 0; n < 3; n ++)
|
for (n = 0; n < 3; n ++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,9 +129,10 @@ Mod_LoadFrames
|
||||||
Load the Quake2 md2 default format frames
|
Load the Quake2 md2 default format frames
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
static void
|
static qboolean
|
||||||
Mod_LoadFrames_MD2(dmdx_t *pheader, byte *src, size_t inframesize, vec3_t translate)
|
Mod_LoadFrames_MD2(dmdx_t *pheader, byte *src, size_t inframesize, vec3_t translate)
|
||||||
{
|
{
|
||||||
|
qboolean normalfix = true;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0 ; i < pheader->num_frames ; i++)
|
for (i=0 ; i < pheader->num_frames ; i++)
|
||||||
|
@ -156,10 +157,19 @@ Mod_LoadFrames_MD2(dmdx_t *pheader, byte *src, size_t inframesize, vec3_t transl
|
||||||
for (j=0; j < pheader->num_xyz; j ++)
|
for (j=0; j < pheader->num_xyz; j ++)
|
||||||
{
|
{
|
||||||
Mod_LoadFrames_VertMD2(poutframe->verts + j, pinframe->verts[j].v);
|
Mod_LoadFrames_VertMD2(poutframe->verts + j, pinframe->verts[j].v);
|
||||||
|
|
||||||
|
if (pinframe->verts[j].lightnormalindex)
|
||||||
|
{
|
||||||
|
/* normal is set? */
|
||||||
|
normalfix = false;
|
||||||
|
}
|
||||||
|
|
||||||
R_ConvertNormalMDL(pinframe->verts[j].lightnormalindex,
|
R_ConvertNormalMDL(pinframe->verts[j].lightnormalindex,
|
||||||
poutframe->verts[j].normal);
|
poutframe->verts[j].normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return normalfix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1847,6 +1857,7 @@ Mod_LoadModel_MD2(const char *mod_name, const void *buffer, int modfilelen,
|
||||||
const dtriangle_t *pintri;
|
const dtriangle_t *pintri;
|
||||||
dmdxmesh_t *mesh_nodes;
|
dmdxmesh_t *mesh_nodes;
|
||||||
const dstvert_t *pinst;
|
const dstvert_t *pinst;
|
||||||
|
qboolean normalfix;
|
||||||
const int *pincmd;
|
const int *pincmd;
|
||||||
dmdl_t pinmodel;
|
dmdl_t pinmodel;
|
||||||
dmdx_t *pheader;
|
dmdx_t *pheader;
|
||||||
|
@ -1988,7 +1999,7 @@ Mod_LoadModel_MD2(const char *mod_name, const void *buffer, int modfilelen,
|
||||||
//
|
//
|
||||||
// load the frames
|
// load the frames
|
||||||
//
|
//
|
||||||
Mod_LoadFrames_MD2(pheader, (byte *)buffer + pinmodel.ofs_frames,
|
normalfix = Mod_LoadFrames_MD2(pheader, (byte *)buffer + pinmodel.ofs_frames,
|
||||||
pinmodel.framesize, translate);
|
pinmodel.framesize, translate);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -2001,6 +2012,12 @@ Mod_LoadModel_MD2(const char *mod_name, const void *buffer, int modfilelen,
|
||||||
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);
|
pheader->num_skins * MAX_SKINNAME);
|
||||||
|
|
||||||
|
if (normalfix)
|
||||||
|
{
|
||||||
|
/* look like normals is zero, lets fix it */
|
||||||
|
Mod_LoadFixNormals(pheader);
|
||||||
|
}
|
||||||
|
|
||||||
Mod_LoadFixImages(mod_name, pheader, false);
|
Mod_LoadFixImages(mod_name, pheader, false);
|
||||||
|
|
||||||
*type = mod_alias;
|
*type = mod_alias;
|
||||||
|
|
Loading…
Reference in a new issue