Voxel fixes from Nuke

git-svn-id: https://svn.eduke32.com/eduke32@7788 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-07-13 03:20:17 +00:00 committed by Christoph Oelckers
parent 4e04e4a096
commit f46db45970
2 changed files with 33 additions and 17 deletions

View file

@ -1013,7 +1013,7 @@ voxmodel_t *loadkvxfrombuf(const char *kvxbuffer, int32_t length)
int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
{
// float clut[6] = {1.02,1.02,0.94,1.06,0.98,0.98};
float f, g, k0;
float f, g, k0, zoff;
if ((intptr_t)m == (intptr_t)(-1)) // hackhackhack
return 0;
@ -1048,7 +1048,14 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
k0 = (float) tspr->z;
f = ((globalorientation&8) && (sprite[tspr->owner].cstat&48)!=0) ? -4.f : 4.f;
k0 -= (tspr->yoffset*tspr->yrepeat)*f*m->bscale;
if (!(tspr->cstat&128)) k0 -= (m->piv.z*tspr->yrepeat)*4.f*m->scale;
zoff = m->siz.z*.5f;
if (!(tspr->cstat&128))
zoff += m->piv.z;
else if ((tspr->cstat&48) != 48)
{
zoff += m->piv.z;
zoff -= m->siz.z*.5f;
}
f = (65536.f*512.f) / ((float)xdimen*viewingrange);
g = 32.f / ((float)xdimen*gxyaspect);
@ -1114,9 +1121,9 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
g = m0.y*f; mat[4] = omat[8]*g; mat[5] = omat[9]*g; mat[6] = omat[10]*g;
g =-m0.z*f; mat[8] = omat[4]*g; mat[9] = omat[5]*g; mat[10] = omat[6]*g;
//
mat[12] -= (m->piv.x*mat[0] + m->piv.y*mat[4] + m->siz.z*.5f*mat[8]);
mat[13] -= (m->piv.x*mat[1] + m->piv.y*mat[5] + m->siz.z*.5f*mat[9]);
mat[14] -= (m->piv.x*mat[2] + m->piv.y*mat[6] + m->siz.z*.5f*mat[10]);
mat[12] -= (m->piv.x*mat[0] + m->piv.y*mat[4] + zoff*mat[8]);
mat[13] -= (m->piv.x*mat[1] + m->piv.y*mat[5] + zoff*mat[9]);
mat[14] -= (m->piv.x*mat[2] + m->piv.y*mat[6] + zoff*mat[10]);
//
glMatrixMode(GL_MODELVIEW); //Let OpenGL (and perhaps hardware :) handle the matrix rotation
mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f;