mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Additional Polymost cleanup, attempt to fix enemy shadows (they are still not right)
git-svn-id: https://svn.eduke32.com/eduke32@4656 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
06a0350af0
commit
020dc85fd0
4 changed files with 171 additions and 135 deletions
|
@ -187,6 +187,8 @@ extern int32_t globalnoeffect;
|
|||
extern int32_t drawingskybox;
|
||||
extern int32_t hicprecaching;
|
||||
extern float gyxscale, gxyaspect, ghalfx, grhalfxdown10;
|
||||
extern float fcosglobalang, fsinglobalang, fglobalposx, fglobalposy, fglobalposz;
|
||||
extern float fxdim, fydim, fxdimen, fydimen, fviewingrange;
|
||||
|
||||
extern char ptempbuf[MAXWALLSB<<1];
|
||||
|
||||
|
|
|
@ -6607,6 +6607,7 @@ static void drawsprite(int32_t snum)
|
|||
#ifdef USE_OPENGL
|
||||
case REND_POLYMOST:
|
||||
polymost_drawsprite(snum);
|
||||
bglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
bglDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
||||
bglDepthRange(0.0, 1.0); //<- this is more widely supported than glPolygonOffset
|
||||
return;
|
||||
|
@ -9542,8 +9543,8 @@ killsprite:
|
|||
{
|
||||
_point2d pos;
|
||||
|
||||
pos.x = (float)globalposx;
|
||||
pos.y = (float)globalposy;
|
||||
pos.x = fglobalposx;
|
||||
pos.y = fglobalposy;
|
||||
|
||||
// CAUTION: maskwallcnt and spritesortcnt may be zero!
|
||||
// Writing e.g. "while (maskwallcnt--)" is wrong!
|
||||
|
@ -11288,6 +11289,10 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da
|
|||
|
||||
xdim = daxdim; ydim = daydim;
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
fxdim = (float) xdim;
|
||||
fydim = (float) ydim;
|
||||
#endif
|
||||
if (lookups != NULL)
|
||||
Bfree(lookups);
|
||||
|
||||
|
@ -14688,6 +14693,10 @@ void setview(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
|
|||
xdimenrecip = divscale32(1L,xdimen);
|
||||
ydimen = (y2-y1)+1;
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
fxdimen = (float) xdimen;
|
||||
fydimen = (float) ydimen;
|
||||
#endif
|
||||
setaspect_new();
|
||||
|
||||
for (i=0; i<windowx1; i++) { startumost[i] = 1, startdmost[i] = 0; }
|
||||
|
|
|
@ -14,13 +14,12 @@
|
|||
#include "mdsprite.h"
|
||||
#include "cache1d.h"
|
||||
#include "kplib.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
static int32_t curextra=MAXTILES;
|
||||
// nedpool *model_data_pool;
|
||||
// #define MODEL_POOL_SIZE 20971520
|
||||
#define model_data_pool (nedpool *) 0 // take it out of the system pool
|
||||
|
||||
#define MIN_CACHETIME_PRINT 10
|
||||
|
||||
|
@ -1678,7 +1677,7 @@ static int32_t mdtrig_init = 0;
|
|||
static void init_mdtrig_arrays(void)
|
||||
{
|
||||
int32_t i;
|
||||
static const float acc = ((2.f * PI) * (1.f/255.f));
|
||||
static const float acc = ((2.f * (float)PI) * (1.f/255.f));
|
||||
float ang = 0.f;
|
||||
|
||||
for (i=0; i<256; i++)
|
||||
|
@ -1969,11 +1968,11 @@ static int32_t polymost_md3draw(md3model_t *m, const spritetype *tspr)
|
|||
|
||||
//create current&next frame's vertex list from whole list
|
||||
|
||||
f = m->interpol; g = 1-f;
|
||||
f = m->interpol; g = 1.f - f;
|
||||
|
||||
if (m->interpol < 0 || m->interpol > 1 ||
|
||||
m->cframe < 0 || m->cframe >= m->numframes ||
|
||||
m->nframe < 0 || m->nframe >= m->numframes)
|
||||
if (m->interpol < 0.f || m->interpol > 1.f ||
|
||||
(unsigned)m->cframe >= (unsigned)m->numframes ||
|
||||
(unsigned)m->nframe >= (unsigned)m->numframes)
|
||||
{
|
||||
#ifdef DEBUGGINGAIDS
|
||||
OSD_Printf("%s: mdframe oob: c:%d n:%d total:%d interpol:%.02f\n",
|
||||
|
@ -1985,13 +1984,11 @@ static int32_t polymost_md3draw(md3model_t *m, const spritetype *tspr)
|
|||
m->nframe = clamp(m->nframe, 0, m->numframes-1);
|
||||
}
|
||||
|
||||
g = m->scale * g * (1.f/64.f);
|
||||
f = m->scale * f * (1.f/64.f);
|
||||
m0.z = m0.y = m0.x = g = m->scale * g * (1.f/64.f);
|
||||
m1.z = m1.y = m1.x = f = m->scale * f * (1.f/64.f);
|
||||
|
||||
m0.x = g; m0.y = g; m0.z = g;
|
||||
m1.x = f; m1.y = f; m1.z = f;
|
||||
|
||||
a0.x = a0.y = 0; a0.z = m->zadd*m->scale;
|
||||
a0.x = a0.y = 0;
|
||||
a0.z = m->zadd * m->scale;
|
||||
|
||||
// Parkar: Moved up to be able to use k0 for the y-flipping code
|
||||
k0 = (float)tspr->z;
|
||||
|
@ -2028,11 +2025,11 @@ static int32_t polymost_md3draw(md3model_t *m, const spritetype *tspr)
|
|||
|
||||
// Note: These SCREEN_FACTORS will be neutralized in axes offset
|
||||
// calculations below again, but are needed for the base offsets.
|
||||
f = (65536.f*512.f)/((float)xdimen*viewingrange);
|
||||
g = 32.f/((float)xdimen*gxyaspect);
|
||||
f = (65536.f*512.f)/(fxdimen*fviewingrange);
|
||||
g = 32.f/(fxdimen*gxyaspect);
|
||||
m0.y *= f; m1.y *= f; a0.y = (((float)(tspr->x-globalposx))* (1.f/1024.f) + a0.y)*f;
|
||||
m0.x *=-f; m1.x *=-f; a0.x = (((float)(k1 -globalposy))* -(1.f/1024.f) + a0.x)*-f;
|
||||
m0.z *= g; m1.z *= g; a0.z = (((float)(k0 -globalposz))* -(1.f/16384.f) + a0.z)*g;
|
||||
m0.x *=-f; m1.x *=-f; a0.x = ((k1 -fglobalposy) * -(1.f/1024.f) + a0.x)*-f;
|
||||
m0.z *= g; m1.z *= g; a0.z = ((k0 -fglobalposz) * -(1.f/16384.f) + a0.z)*g;
|
||||
|
||||
md3_vox_calcmat_common(tspr, &a0, f, mat);
|
||||
|
||||
|
@ -2052,11 +2049,23 @@ static int32_t polymost_md3draw(md3model_t *m, const spritetype *tspr)
|
|||
// to use Z-buffer hacks to hide overdraw problems with the
|
||||
// flat-tsprite-on-floor shadows.
|
||||
// is this still needed?
|
||||
|
||||
if (tspr->cstat&CSTAT_SPRITE_MDHACK)
|
||||
{
|
||||
bglDepthFunc(GL_LESS);
|
||||
bglDepthRange(-.0001, .9999);
|
||||
#ifdef __arm__ // GL ES has a glDepthRangef and the loss of precision is OK there
|
||||
float f = (float) (tspr->owner + 1) * (FLT_EPSILON * 8.0);
|
||||
if (f != 0.0) f *= 1.f/(float) (sepldist(globalposx - tspr->x, globalposy - tspr->y)>>5);
|
||||
bglDepthFunc(GL_LEQUAL);
|
||||
glDepthRangef(0.f - f, 1.f - f);
|
||||
#else
|
||||
double f = (double) (tspr->owner + 1) * (FLT_EPSILON * 8.0);
|
||||
if (f != 0.0) f *= 1.0/(double) (sepldist(globalposx - tspr->x, globalposy - tspr->y)>>5);
|
||||
bglBlendFunc(GL_SRC_ALPHA, GL_DST_COLOR);
|
||||
bglDepthFunc(GL_LEQUAL);
|
||||
bglDepthRange(0.0 - f, 1.0 - f);
|
||||
#endif
|
||||
}
|
||||
|
||||
bglPushAttrib(GL_POLYGON_BIT);
|
||||
if ((grhalfxdown10x >= 0) ^((globalorientation&8) != 0) ^((globalorientation&4) != 0)) bglFrontFace(GL_CW); else bglFrontFace(GL_CCW);
|
||||
bglEnable(GL_CULL_FACE);
|
||||
|
@ -2105,7 +2114,7 @@ static int32_t polymost_md3draw(md3model_t *m, const spritetype *tspr)
|
|||
// PLAG: Cleaner model rotation code
|
||||
if (sext->pitch || sext->roll)
|
||||
{
|
||||
float f = 1.f/((float)(xdimen*viewingrange)*(m0.x+m1.x)*(2560.f*(1.f/(65536.f*1280.f))));
|
||||
float f = 1.f/(fxdimen * fviewingrange) * (m0.x+m1.x) * (2560.f * (1.f/(65536.f*1280.f)));
|
||||
Bmemset(&a0, 0, sizeof(a0));
|
||||
|
||||
if (sext->xoff)
|
||||
|
@ -2115,7 +2124,7 @@ static int32_t polymost_md3draw(md3model_t *m, const spritetype *tspr)
|
|||
a0.y = (float) sext->yoff * f;
|
||||
|
||||
if ((sext->zoff) && !(tspr->cstat&CSTAT_SPRITE_MDHACK)) // Compare with SCREEN_FACTORS above
|
||||
a0.z = (float)sext->zoff / (655360.f * (m0.z+m1.z) * (gxyaspect*xdimen*(1.f/1280.f)));
|
||||
a0.z = (float)sext->zoff / (655360.f * (m0.z+m1.z) * (gxyaspect*fxdimen*(1.f/1280.f)));
|
||||
|
||||
k0 = (float)sintable[(sext->pitch+512)&2047] * (1.f/16384.f);
|
||||
k1 = (float)sintable[sext->pitch&2047] * (1.f/16384.f);
|
||||
|
@ -2208,87 +2217,95 @@ static int32_t polymost_md3draw(md3model_t *m, const spritetype *tspr)
|
|||
//i = mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,surfi); //hack for testing multiple surfaces per MD3
|
||||
bglBindTexture(GL_TEXTURE_2D, i);
|
||||
|
||||
if (r_detailmapping && !(tspr->cstat&CSTAT_SPRITE_MDHACK))
|
||||
i = mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,DETAILPAL,surfi);
|
||||
else
|
||||
i = 0;
|
||||
|
||||
if (i)
|
||||
if (!(tspr->cstat&CSTAT_SPRITE_MDHACK))
|
||||
{
|
||||
mdskinmap_t *sk;
|
||||
i = r_detailmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, DETAILPAL, surfi) : 0;
|
||||
|
||||
polymost_setupdetailtexture(++texunits, i);
|
||||
|
||||
for (sk = m->skinmap; sk; sk = sk->next)
|
||||
if ((int32_t)sk->palette == DETAILPAL && sk->skinnum == tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum && sk->surfnum == surfi)
|
||||
f = sk->param;
|
||||
|
||||
bglMatrixMode(GL_TEXTURE);
|
||||
bglLoadIdentity();
|
||||
bglScalef(f, f, 1.0f);
|
||||
bglMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
if (r_glowmapping && !(tspr->cstat&CSTAT_SPRITE_MDHACK))
|
||||
{
|
||||
i = mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, GLOWPAL, surfi);
|
||||
if (i)
|
||||
polymost_setupglowtexture(++texunits, i);
|
||||
}
|
||||
|
||||
if (r_vertexarrays && r_vbos)
|
||||
{
|
||||
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexvbos[curvbo]);
|
||||
vbotemp = bglMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
indexhandle = (uint16_t *)vbotemp;
|
||||
}
|
||||
else
|
||||
indexhandle = m->vindexes;
|
||||
|
||||
//PLAG: delayed polygon-level sorted rendering
|
||||
if (m->usesalpha && !(tspr->cstat & CSTAT_SPRITE_MDHACK))
|
||||
{
|
||||
vec3f_t fp, fp1, fp2, vlt0, vlt1, vlt2;
|
||||
|
||||
for (i=s->numtris-1; i>=0; i--)
|
||||
{
|
||||
vlt0 = vertlist[s->tris[i].i[0]];
|
||||
vlt1 = vertlist[s->tris[i].i[1]];
|
||||
vlt2 = vertlist[s->tris[i].i[2]];
|
||||
mdskinmap_t *sk;
|
||||
|
||||
// Matrix multiplication - ugly but clear
|
||||
fp.x = (vlt0.x * mat[0]) + (vlt0.y * mat[4]) + (vlt0.z * mat[8]) + mat[12];
|
||||
fp.y = (vlt0.x * mat[1]) + (vlt0.y * mat[5]) + (vlt0.z * mat[9]) + mat[13];
|
||||
fp.z = (vlt0.x * mat[2]) + (vlt0.y * mat[6]) + (vlt0.z * mat[10]) + mat[14];
|
||||
polymost_setupdetailtexture(++texunits, i);
|
||||
|
||||
fp1.x = (vlt1.x * mat[0]) + (vlt1.y * mat[4]) + (vlt1.z * mat[8]) + mat[12];
|
||||
fp1.y = (vlt1.x * mat[1]) + (vlt1.y * mat[5]) + (vlt1.z * mat[9]) + mat[13];
|
||||
fp1.z = (vlt1.x * mat[2]) + (vlt1.y * mat[6]) + (vlt1.z * mat[10]) + mat[14];
|
||||
for (sk = m->skinmap; sk; sk = sk->next)
|
||||
if ((int32_t) sk->palette == DETAILPAL && sk->skinnum == tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum && sk->surfnum == surfi)
|
||||
f = sk->param;
|
||||
|
||||
fp2.x = (vlt2.x * mat[0]) + (vlt2.y * mat[4]) + (vlt2.z * mat[8]) + mat[12];
|
||||
fp2.y = (vlt2.x * mat[1]) + (vlt2.y * mat[5]) + (vlt2.z * mat[9]) + mat[13];
|
||||
fp2.z = (vlt2.x * mat[2]) + (vlt2.y * mat[6]) + (vlt2.z * mat[10]) + mat[14];
|
||||
|
||||
f = (fp.x * fp.x) + (fp.y * fp.y) + (fp.z * fp.z);
|
||||
|
||||
g = (fp1.x * fp1.x) + (fp1.y * fp1.y) + (fp1.z * fp1.z);
|
||||
if (f > g)
|
||||
f = g;
|
||||
g = (fp2.x * fp2.x) + (fp2.y * fp2.y) + (fp2.z * fp2.z);
|
||||
if (f > g)
|
||||
f = g;
|
||||
|
||||
m->maxdepths[i] = f;
|
||||
m->indexes[i] = i;
|
||||
bglMatrixMode(GL_TEXTURE);
|
||||
bglLoadIdentity();
|
||||
bglScalef(f, f, 1.0f);
|
||||
bglMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
// dichotomic recursive sorting - about 100x less iterations than bubblesort
|
||||
quicksort(m->indexes, m->maxdepths, 0, s->numtris - 1);
|
||||
i = r_glowmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, GLOWPAL, surfi) : 0;
|
||||
|
||||
md3draw_handle_triangles(s, indexhandle, texunits, m);
|
||||
if (i)
|
||||
polymost_setupglowtexture(++texunits, i);
|
||||
|
||||
if (r_vertexarrays && r_vbos)
|
||||
{
|
||||
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexvbos[curvbo]);
|
||||
vbotemp = bglMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
indexhandle = (uint16_t *) vbotemp;
|
||||
}
|
||||
else
|
||||
indexhandle = m->vindexes;
|
||||
|
||||
//PLAG: delayed polygon-level sorted rendering
|
||||
|
||||
if (m->usesalpha)
|
||||
{
|
||||
vec3f_t fp, fp1, fp2, vlt0, vlt1, vlt2;
|
||||
|
||||
for (i=s->numtris-1; i>=0; i--)
|
||||
{
|
||||
vlt0 = vertlist[s->tris[i].i[0]];
|
||||
vlt1 = vertlist[s->tris[i].i[1]];
|
||||
vlt2 = vertlist[s->tris[i].i[2]];
|
||||
|
||||
// Matrix multiplication - ugly but clear
|
||||
fp.x = (vlt0.x * mat[0]) + (vlt0.y * mat[4]) + (vlt0.z * mat[8]) + mat[12];
|
||||
fp.y = (vlt0.x * mat[1]) + (vlt0.y * mat[5]) + (vlt0.z * mat[9]) + mat[13];
|
||||
fp.z = (vlt0.x * mat[2]) + (vlt0.y * mat[6]) + (vlt0.z * mat[10]) + mat[14];
|
||||
|
||||
fp1.x = (vlt1.x * mat[0]) + (vlt1.y * mat[4]) + (vlt1.z * mat[8]) + mat[12];
|
||||
fp1.y = (vlt1.x * mat[1]) + (vlt1.y * mat[5]) + (vlt1.z * mat[9]) + mat[13];
|
||||
fp1.z = (vlt1.x * mat[2]) + (vlt1.y * mat[6]) + (vlt1.z * mat[10]) + mat[14];
|
||||
|
||||
fp2.x = (vlt2.x * mat[0]) + (vlt2.y * mat[4]) + (vlt2.z * mat[8]) + mat[12];
|
||||
fp2.y = (vlt2.x * mat[1]) + (vlt2.y * mat[5]) + (vlt2.z * mat[9]) + mat[13];
|
||||
fp2.z = (vlt2.x * mat[2]) + (vlt2.y * mat[6]) + (vlt2.z * mat[10]) + mat[14];
|
||||
|
||||
f = (fp.x * fp.x) + (fp.y * fp.y) + (fp.z * fp.z);
|
||||
|
||||
g = (fp1.x * fp1.x) + (fp1.y * fp1.y) + (fp1.z * fp1.z);
|
||||
if (f > g)
|
||||
f = g;
|
||||
g = (fp2.x * fp2.x) + (fp2.y * fp2.y) + (fp2.z * fp2.z);
|
||||
if (f > g)
|
||||
f = g;
|
||||
|
||||
m->maxdepths[i] = f;
|
||||
m->indexes[i] = i;
|
||||
}
|
||||
|
||||
// dichotomic recursive sorting - about 100x less iterations than bubblesort
|
||||
quicksort(m->indexes, m->maxdepths, 0, s->numtris - 1);
|
||||
}
|
||||
|
||||
md3draw_handle_triangles(s, indexhandle, texunits, m->usesalpha ? m : NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (r_vertexarrays && r_vbos)
|
||||
{
|
||||
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexvbos[curvbo]);
|
||||
vbotemp = bglMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
indexhandle = (uint16_t *) vbotemp;
|
||||
}
|
||||
else
|
||||
indexhandle = m->vindexes;
|
||||
|
||||
md3draw_handle_triangles(s, indexhandle, texunits, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,8 @@ float gtang = 0.f;
|
|||
static double guo, gux, guy; //Screen-based texture mapping parameters
|
||||
static double gvo, gvx, gvy;
|
||||
static double gdo, gdx, gdy;
|
||||
static float fcosglobalang, fsinglobalang, fglobalposx, fglobalposy;
|
||||
float fcosglobalang, fsinglobalang, fglobalposx, fglobalposy, fglobalposz;
|
||||
float fxdim, fydim, fxdimen, fydimen, fviewingrange;
|
||||
static int32_t preview_mouseaim=0; // when 1, displays a CROSSHAIR tsprite at the _real_ aimed position
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
|
@ -197,7 +198,7 @@ void drawline2d(float x0, float y0, float x1, float y1, char col)
|
|||
uint32_t up16;
|
||||
|
||||
dx = x1-x0; dy = y1-y0; if ((dx == 0) && (dy == 0)) return;
|
||||
fxres = (float)xdimen; fyres = (float)ydimen;
|
||||
fxres = fxdimen; fyres = fydimen;
|
||||
if (x0 >= fxres) { if (x1 >= fxres) return; y0 += (fxres-x0)*dy/dx; x0 = fxres; }
|
||||
else if (x0 < 0) { if (x1 < 0) return; y0 += (0-x0)*dy/dx; x0 = 0; }
|
||||
if (x1 >= fxres) { y1 += (fxres-x1)*dy/dx; x1 = fxres; }
|
||||
|
@ -674,9 +675,9 @@ static void resizeglcheck(void)
|
|||
|
||||
bglMatrixMode(GL_PROJECTION);
|
||||
memset(m,0,sizeof(m));
|
||||
m[0][0] = (float)ydimen / ratio; m[0][2] = 1.f;
|
||||
m[1][1] = (float)xdimen; m[1][2] = 1.f;
|
||||
m[2][2] = 1.f; m[2][3] = (float)ydimen / ratio;
|
||||
m[0][0] = fydimen / ratio; m[0][2] = 1.f;
|
||||
m[1][1] = fxdimen; m[1][2] = 1.f;
|
||||
m[2][2] = 1.f; m[2][3] = fydimen / ratio;
|
||||
m[3][2] =-1.f;
|
||||
bglLoadMatrixf(&m[0][0]);
|
||||
|
||||
|
@ -2068,7 +2069,8 @@ void domost(float x0, float y0, float x1, float y1)
|
|||
|
||||
void polymost_editorfunc(void)
|
||||
{
|
||||
vec3_t v, o, o2;
|
||||
vec3_t v;
|
||||
vec3f_t o, o2;
|
||||
int32_t cz, fz;
|
||||
hitdata_t hit;
|
||||
vec3_t vect;
|
||||
|
@ -2089,9 +2091,9 @@ void polymost_editorfunc(void)
|
|||
o2.z = o.y*gchang + o.z*gshang;
|
||||
|
||||
//Standard Left/right rotation
|
||||
v.x = (int32_t) (o2.x*fcosglobalang - o2.y*fsinglobalang);
|
||||
v.y = (int32_t) (o2.x*fsinglobalang + o2.y*fcosglobalang);
|
||||
v.z = (int32_t) (o2.z*16384.f);
|
||||
v.x = Blrintf (o2.x*fcosglobalang - o2.y*fsinglobalang);
|
||||
v.y = Blrintf (o2.x*fsinglobalang + o2.y*fcosglobalang);
|
||||
v.z = Blrintf (o2.z*16384.f);
|
||||
|
||||
vect.x = globalposx;
|
||||
vect.y = globalposy;
|
||||
|
@ -2515,9 +2517,9 @@ static void polymost_drawalls(int32_t bunch)
|
|||
{
|
||||
// g_nodraw = 1;
|
||||
|
||||
dd[0] = (float)xdimen*.0000001f; //Adjust sky depth based on screen size!
|
||||
dd[0] = fxdimen*.0000001f; //Adjust sky depth based on screen size!
|
||||
t = (float)((1<<(picsiz[globalpicnum]&15))<<dapskybits);
|
||||
vv[1] = dd[0]*((float)xdimscale*(float)viewingrange)/(65536.f*65536.f);
|
||||
vv[1] = dd[0]*((float)xdimscale*fviewingrange) * (1.f/(65536.f*65536.f));
|
||||
vv[0] = dd[0]*((float)((tilesiz[globalpicnum].y>>1)/*+g_psky.yoffs*/)) - vv[1]*ghoriz;
|
||||
i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesiz[globalpicnum].y) i += i;
|
||||
|
||||
|
@ -2550,7 +2552,7 @@ static void polymost_drawalls(int32_t bunch)
|
|||
gvx = 0; gvy = vv[1]; gvo = vv[0];
|
||||
|
||||
i = globalpicnum; r = (fy1-fy0)/(x1-x0); //slope of line
|
||||
oy = ((float)viewingrange)/(ghalfx*256.f); oz = 1.f/oy;
|
||||
oy = fviewingrange/(ghalfx*256.f); oz = 1.f/oy;
|
||||
|
||||
y = ((((int32_t)((x0-ghalfx)*oy))+globalang)>>(11-dapskybits));
|
||||
fx = x0;
|
||||
|
@ -2657,8 +2659,8 @@ static void polymost_drawalls(int32_t bunch)
|
|||
gdx = 0;
|
||||
gdy = gxyaspect*(1.f/4194304.f);
|
||||
gdo = -ghoriz*gdy;
|
||||
gux = (double)ft[3]*((float)viewingrange)*(-1.0/65536.0);
|
||||
gvx = (double)ft[2]*((float)viewingrange)*(-1.0/65536.0);
|
||||
gux = (double)ft[3]*fviewingrange*(-1.0/65536.0);
|
||||
gvx = (double)ft[2]*fviewingrange*(-1.0/65536.0);
|
||||
guy = ft[0]*gdy; gvy = ft[1]*gdy;
|
||||
guo = ft[0]*gdo; gvo = ft[1]*gdo;
|
||||
guo += (ft[2]-gux)*ghalfx;
|
||||
|
@ -2789,9 +2791,9 @@ static void polymost_drawalls(int32_t bunch)
|
|||
// g_nodraw = 1;
|
||||
|
||||
//Render for parallaxtype == 0 / paper-sky
|
||||
dd[0] = (float)xdimen*.0000001f; //Adjust sky depth based on screen size!
|
||||
dd[0] = fxdimen*.0000001f; //Adjust sky depth based on screen size!
|
||||
t = (float)((1<<(picsiz[globalpicnum]&15))<<dapskybits);
|
||||
vv[1] = dd[0]*((float)xdimscale*viewingrange)/(65536.f*65536.f);
|
||||
vv[1] = dd[0]*((float)xdimscale*viewingrange) * (1.f/(65536.f*65536.f));
|
||||
vv[0] = dd[0]*((float)((tilesiz[globalpicnum].y>>1)/*+g_psky.yoffs*/)) - vv[1]*ghoriz;
|
||||
i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesiz[globalpicnum].y) i += i;
|
||||
|
||||
|
@ -2826,7 +2828,7 @@ static void polymost_drawalls(int32_t bunch)
|
|||
gvx = 0; gvy = vv[1]; gvo = vv[0];
|
||||
|
||||
i = globalpicnum; r = (cy1-cy0)/(x1-x0); //slope of line
|
||||
oy = ((float)viewingrange)/(ghalfx*256.f); oz = 1.f/oy;
|
||||
oy = fviewingrange/(ghalfx*256.f); oz = 1.f/oy;
|
||||
|
||||
y = ((((int32_t)((x0-ghalfx)*oy))+globalang)>>(11-dapskybits));
|
||||
fx = x0;
|
||||
|
@ -2935,8 +2937,8 @@ static void polymost_drawalls(int32_t bunch)
|
|||
gdx = 0;
|
||||
gdy = gxyaspect*(-1.f/4194304.f);
|
||||
gdo = -ghoriz*gdy;
|
||||
gux = ft[3]*((float)viewingrange)*(-1.0/65536.0);
|
||||
gvx = ft[2]*((float)viewingrange)*(-1.0/65536.0);
|
||||
gux = ft[3]*fviewingrange*(-1.0/65536.0);
|
||||
gvx = ft[2]*fviewingrange*(-1.0/65536.0);
|
||||
guy = ft[0]*gdy; gvy = ft[1]*gdy;
|
||||
guo = ft[0]*gdo; gvo = ft[1]*gdo;
|
||||
guo += (ft[2]-gux)*ghalfx;
|
||||
|
@ -3000,8 +3002,8 @@ static void polymost_drawalls(int32_t bunch)
|
|||
gdx = 0;
|
||||
gdy = gxyaspect*(1.f/4194304.f);
|
||||
gdo = -ghoriz*gdy;
|
||||
gux = ft[3]*((float)viewingrange)*(-1.0/65536.0);
|
||||
gvx = ft[2]*((float)viewingrange)*(-1.0/65536.0);
|
||||
gux = ft[3]*fviewingrange*(-1.0/65536.0);
|
||||
gvx = ft[2]*fviewingrange*(-1.0/65536.0);
|
||||
guy = ft[0]*gdy; gvy = ft[1]*gdy;
|
||||
guo = ft[0]*gdo; gvo = ft[1]*gdo;
|
||||
guo += (ft[2]-gux)*ghalfx;
|
||||
|
@ -3436,28 +3438,34 @@ void polymost_drawrooms()
|
|||
|
||||
//Polymost supports true look up/down :) Here, we convert horizon to angle.
|
||||
//gchang&gshang are cos&sin of this angle (respectively)
|
||||
fxdim = (float) xdim;
|
||||
fydim = (float) ydim;
|
||||
fxdimen = (float) xdimen;
|
||||
fydimen = (float) ydimen;
|
||||
fglobalposx = (float) globalposx;
|
||||
fglobalposy = (float) globalposy;
|
||||
fglobalposz = (float) globalposz;
|
||||
fviewingrange = (float) viewingrange;
|
||||
gyxscale = ((float)xdimenscale)*(1.0f/131072.f);
|
||||
gxyaspect = ((float)xyaspect*(float)viewingrange)*(5.f/(65536.f*262144.f));
|
||||
gviewxrange = ((float)viewingrange)*((float)xdimen)/(32768.f*1024.f);
|
||||
gxyaspect = ((float)xyaspect*fviewingrange)*(5.f/(65536.f*262144.f));
|
||||
gviewxrange = fviewingrange * fxdimen * (1.f/(32768.f*1024.f));
|
||||
fcosglobalang = (float) cosglobalang;
|
||||
gcosang = fcosglobalang*(1.0f/262144.f);
|
||||
fsinglobalang = (float) singlobalang;
|
||||
gsinang = fsinglobalang*(1.0f/262144.f);
|
||||
gcosang2 = gcosang*((float)viewingrange)*(1.0f/65536.f);
|
||||
gsinang2 = gsinang*((float)viewingrange)*(1.0f/65536.f);
|
||||
ghalfx = (float)halfxdimen;
|
||||
gcosang2 = gcosang * (fviewingrange * (1.0f/65536.f));
|
||||
gsinang2 = gsinang * (fviewingrange * (1.0f/65536.f));
|
||||
ghalfx = fxdimen * .5f;
|
||||
grhalfxdown10 = 1.f/(ghalfx*1024.f);
|
||||
ghoriz = (float)globalhoriz;
|
||||
|
||||
gvisibility = ((float)globalvisibility)*FOGSCALE;
|
||||
|
||||
//global cos/sin height angle
|
||||
r = ((float)(ydimen>>1)-ghoriz);
|
||||
r = fydimen * .5f - ghoriz;
|
||||
gshang = r/Bsqrtf(r*r+ghalfx*ghalfx);
|
||||
gchang = Bsqrtf(1.f-gshang*gshang);
|
||||
ghoriz = (float)(ydimen>>1);
|
||||
ghoriz = fydimen * .5f;
|
||||
|
||||
//global cos/sin tilt angle
|
||||
gctang = cos(gtang);
|
||||
|
@ -3879,7 +3887,7 @@ void polymost_drawsprite(int32_t snum)
|
|||
sx0 = ghalfx*xp0*ryp0 + ghalfx;
|
||||
sy0 = ((float)(tspr->z-globalposz))*gyxscale*ryp0 + ghoriz;
|
||||
|
||||
f = ryp0*(float)xdimen*(1.0f/160.f);
|
||||
f = ryp0*fxdimen*(1.0f/160.f);
|
||||
fx = ((float)tspr->xrepeat)*f;
|
||||
fy = ((float)tspr->yrepeat)*f*((float)yxaspect*(1.0f/65536.f));
|
||||
sx0 -= fx*(float)xoff; if (tsizx&1) sx0 += fx*0.5f;
|
||||
|
@ -4161,8 +4169,8 @@ void polymost_drawsprite(int32_t snum)
|
|||
ft[3] = singlobalang*fx - cosglobalang*fy;
|
||||
ft[0] = ((float)(globalposy-yv))*fy + ((float)(globalposx-xv))*fx;
|
||||
ft[1] = ((float)(globalposx-xv))*fy - ((float)(globalposy-yv))*fx;
|
||||
gux = (float)ft[3]*((float)viewingrange)/(-65536.f*262144.f);
|
||||
gvx = (float)ft[2]*((float)viewingrange)/(-65536.f*262144.f);
|
||||
gux = (float)ft[3]*fviewingrange/(-65536.f*262144.f);
|
||||
gvx = (float)ft[2]*fviewingrange/(-65536.f*262144.f);
|
||||
guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy;
|
||||
guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo;
|
||||
guo += (double)(ft[2]*(1.0f/262144.f)-gux)*ghalfx;
|
||||
|
@ -4328,9 +4336,9 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
|
|||
|
||||
tspr.xrepeat = tspr.yrepeat = 5;
|
||||
|
||||
vec2.x = (float)globalposx + (gcosang*vec1.z - gsinang*vec1.x)*2560.f;
|
||||
vec2.y = (float)globalposy + (gsinang*vec1.z + gcosang*vec1.x)*2560.f;
|
||||
vec2.z = (float)globalposz + (vec1.y*(2560.f*0.8f));
|
||||
vec2.x = fglobalposx + (gcosang*vec1.z - gsinang*vec1.x)*2560.f;
|
||||
vec2.y = fglobalposy + (gsinang*vec1.z + gcosang*vec1.x)*2560.f;
|
||||
vec2.z = fglobalposz + (vec1.y*(2560.f*0.8f));
|
||||
|
||||
Bmemcpy(&tspr.x, &vec2, sizeof(vec3f_t));
|
||||
}
|
||||
|
@ -4367,15 +4375,15 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
|
|||
if (fov != -1)
|
||||
f = 1.f/tanf(((float)fov * 2.56f) * ((.5f * PI) * (1.0f/2048.f)));
|
||||
|
||||
m[0][0] = f*(float) ydimen; m[0][2] = 1.f;
|
||||
m[1][1] = f*(float) xdimen; m[1][2] = 1.f;
|
||||
m[2][2] = 1.f; m[2][3] = (float) ydimen;
|
||||
m[0][0] = f*fydimen; m[0][2] = 1.f;
|
||||
m[1][1] = f*fxdimen; m[1][2] = 1.f;
|
||||
m[2][2] = 1.f; m[2][3] = fydimen;
|
||||
m[3][2] =-1.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m[0][0] = m[2][3] = 1.f;
|
||||
m[1][1] = ((float) xdim)/((float) ydim);
|
||||
m[1][1] = fxdim/fydim;
|
||||
m[2][2] = 1.0001f;
|
||||
m[3][2] = 1-m[2][2];
|
||||
}
|
||||
|
@ -4492,10 +4500,10 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
|||
ogpicnum = globalpicnum; globalpicnum = picnum;
|
||||
ogshade = globalshade; globalshade = dashade;
|
||||
ogpal = globalpal; globalpal = (int32_t)((uint8_t)dapalnum);
|
||||
oghalfx = ghalfx; ghalfx = (float)(xdim>>1);
|
||||
oghalfx = ghalfx; ghalfx = fxdim * .5f;
|
||||
ogrhalfxdown10 = grhalfxdown10; grhalfxdown10 = 1.f/(ghalfx*1024.f);
|
||||
ogrhalfxdown10x = grhalfxdown10x; grhalfxdown10x = grhalfxdown10;
|
||||
oghoriz = ghoriz; ghoriz = (float)(ydim>>1);
|
||||
oghoriz = ghoriz; ghoriz = fydim * .5f;
|
||||
ofoffset = frameoffset; frameoffset = frameplace;
|
||||
ogchang = gchang; gchang = 1.f;
|
||||
ogshang = gshang; gshang = 0.f;
|
||||
|
@ -4508,7 +4516,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
|||
bglViewport(0,0,xdim,ydim); glox1 = -1; //Force fullscreen (glox1=-1 forces it to restore)
|
||||
bglMatrixMode(GL_PROJECTION);
|
||||
memset(m,0,sizeof(m));
|
||||
m[0][0] = m[2][3] = 1.0f; m[1][1] = ((float)xdim)/((float)ydim); m[2][2] = 1.0001f; m[3][2] = 1-m[2][2];
|
||||
m[0][0] = m[2][3] = 1.0f; m[1][1] = fxdim/fydim; m[2][2] = 1.0001f; m[3][2] = 1-m[2][2];
|
||||
bglPushMatrix(); bglLoadMatrixf(&m[0][0]);
|
||||
bglMatrixMode(GL_MODELVIEW);
|
||||
bglPushMatrix();
|
||||
|
@ -4855,8 +4863,8 @@ void polymost_fillpolygon(int32_t npoints)
|
|||
gvx = ((float)asm2)*(1.f/4294967296.f);
|
||||
guy = ((float)globalx1)*(1.f/4294967296.f);
|
||||
gvy = ((float)globaly2)*(-1.f/4294967296.f);
|
||||
guo = (((float) xdim)*gux + ((float) ydim)*guy)*-0.5f + (fglobalposx)*(1.f/4294967296.f);
|
||||
gvo = (((float) xdim)*gvx + ((float) ydim)*gvy)*-0.5f - (fglobalposy)*(1.f/4294967296.f);
|
||||
guo = (fxdim*gux + fydim*guy)*-0.5f + fglobalposx * (1.f/4294967296.f);
|
||||
gvo = (fxdim*gvx + fydim*gvy)*-0.5f - fglobalposy * (1.f/4294967296.f);
|
||||
//Convert int32_t to float (in-place)
|
||||
for (i=npoints-1; i>=0; i--)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue