set_globalpos(), updates both integer (globalposx/y/z) and float (fglobalposx/y/z) representations of the current camera view position. Storing the float representation pre-converted saves us from the delay incurred on ARM when converting an integer and transferring it to the FPU, though this delay is mostly negated already by using the hardfp ABI.

git-svn-id: https://svn.eduke32.com/eduke32@4667 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2014-10-25 03:32:26 +00:00
parent 5897c844d2
commit c8ea7baf72
5 changed files with 40 additions and 38 deletions

View file

@ -187,7 +187,7 @@ 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 fcosglobalang, fsinglobalang;
extern float fxdim, fydim, fxdimen, fydimen, fviewingrange;
extern char ptempbuf[MAXWALLSB<<1];

View file

@ -2270,6 +2270,7 @@ static int32_t xsi[8], ysi[8], horizycent;
static int32_t *horizlookup=0, *horizlookup2=0;
int32_t globalposx, globalposy, globalposz, globalhoriz;
float fglobalposx, fglobalposy, fglobalposz;
int16_t globalang, globalcursectnum;
int32_t globalpal, cosglobalang, singlobalang;
static int32_t globalblend;
@ -9100,7 +9101,7 @@ int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz,
beforedrawrooms = 0;
indrawroomsandmasks = 1;
globalposx = daposx; globalposy = daposy; globalposz = daposz;
set_globalpos(daposx, daposy, daposz);
set_globalang(daang);
global100horiz = dahoriz;
@ -9718,8 +9719,8 @@ killsprite:
for (jj=0; jj<numpts; jj++)
{
spr.x = xx[jj];
spr.y = yy[jj];
spr.x = (float)xx[jj];
spr.y = (float)yy[jj];
if (!sameside(&maskeq, &spr, &pos)) // behind the maskwall,
if ((sameside(&p1eq, &middle, &spr) && // inside the 'cone',
@ -9917,8 +9918,9 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
globalpolytype = 0;
if ((globalorientation&64) == 0)
{
globalposx = dax; globalx1 = bakgxvect; globaly1 = bakgyvect;
globalposy = day; globalx2 = bakgxvect; globaly2 = bakgyvect;
set_globalpos(dax, day, globalposz);
globalx1 = bakgxvect; globaly1 = bakgyvect;
globalx2 = bakgxvect; globaly2 = bakgyvect;
}
else
{
@ -9929,14 +9931,14 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
globalx1 = mulscale10(dmulscale10(ox,bakgxvect,oy,bakgyvect),i);
globaly1 = mulscale10(dmulscale10(ox,bakgyvect,-oy,bakgxvect),i);
ox = (bakx1>>4)-(xdim<<7); oy = (baky1>>4)-(ydim<<7);
globalposx = dmulscale28(-oy,globalx1,-ox,globaly1);
globalposy = dmulscale28(-ox,globalx1,oy,globaly1);
globalposx = dmulscale28(-oy, globalx1, -ox, globaly1);
globalposy = dmulscale28(-ox, globalx1, oy, globaly1);
globalx2 = -globalx1;
globaly2 = -globaly1;
daslope = sector[s].floorheinum;
i = nsqrtasm(daslope*daslope+16777216);
globalposy = mulscale12(globalposy,i);
set_globalpos(globalposx, mulscale12(globalposy,i), globalposz);
globalx2 = mulscale12(globalx2,i);
globaly2 = mulscale12(globaly2,i);
}
@ -9957,9 +9959,9 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
asm2 = (globalx2<<globalyshift);
globalx1 <<= globalxshift;
globaly2 <<= globalyshift;
globalposx = ((int64_t)globalposx<<(20+globalxshift))+(((uint32_t)sec->floorxpanning)<<24);
globalposy = ((int64_t)globalposy<<(20+globalyshift))-(((uint32_t)sec->floorypanning)<<24);
set_globalpos(((int64_t) globalposx<<(20+globalxshift))+(((uint32_t) sec->floorxpanning)<<24),
((int64_t) globalposy<<(20+globalyshift))-(((uint32_t) sec->floorypanning)<<24),
globalposz);
fillpolygon(npoints);
}
@ -10083,6 +10085,8 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
asm1 = (globaly1<<2); globalx1 <<= 2; globalposx <<= (20+2);
asm2 = (globalx2<<2); globaly2 <<= 2; globalposy <<= (20+2);
set_globalpos(globalposx, globalposy, globalposz);
// so polymost can get the translucency. ignored in software mode:
globalorientation = ((spr->cstat&2)<<7) | ((spr->cstat&512)>>2);
fillpolygon(npoints);

View file

@ -37,6 +37,7 @@ extern spritetype *tspriteptr[MAXSPRITESONSCREEN + 1];
extern int32_t xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen;
extern intptr_t frameoffset;
extern int32_t globalposx, globalposy, globalposz, globalhoriz;
extern float fglobalposx, fglobalposy, fglobalposz;
extern int16_t globalang, globalcursectnum;
extern int32_t globalpal, cosglobalang, singlobalang;
extern int32_t cosviewingrangeglobalang, sinviewingrangeglobalang;
@ -226,4 +227,12 @@ static inline const int8_t *getpsky(int32_t picnum, int32_t *dapyscale, int32_t
return multipsky[j].tileofs;
}
static inline void set_globalpos(int32_t x, int32_t y, int32_t z)
{
globalposx = x, fglobalposx = (float)x;
globalposy = y, fglobalposy = (float)y;
globalposz = z, fglobalposz = (float)z;
}
#endif /* ENGINE_PRIV_H */

View file

@ -2009,9 +2009,7 @@ static void polymer_displayrooms(const int16_t dacursectnum)
pz = (int32_t)(-coeff*mirrorlist[i].plane->plane[2]*2 + pz);
// map back from polymer to build
globalposx = -pz;
globalposy = px;
globalposz = -py * 16;
set_globalpos(-pz, px, -py * 16);
mirrors[depth++] = mirrorlist[i];
polymer_displayrooms(mirrorlist[i].sectnum);
@ -2020,9 +2018,7 @@ static void polymer_displayrooms(const int16_t dacursectnum)
cursectormasks = localsectormasks;
cursectormaskcount = localsectormaskcount;
globalposx = gx;
globalposy = gy;
globalposz = gz;
set_globalpos(gx, gy, gz);
bglDisable(GL_CLIP_PLANE0);
SWITCH_CULL_DIRECTION;
@ -5781,9 +5777,7 @@ static void polymer_prepareshadows(void)
bglEnable(GL_POLYGON_OFFSET_FILL);
bglPolygonOffset(5, SHADOW_DEPTH_OFFSET);
globalposx = prlights[i].x;
globalposy = prlights[i].y;
globalposz = prlights[i].z;
set_globalpos(prlights[i].x, prlights[i].y, prlights[i].z);
// build globals used by rotatesprite
viewangle = prlights[i].angle;
@ -5817,9 +5811,7 @@ static void polymer_prepareshadows(void)
k++;
}
globalposx = gx;
globalposy = gy;
globalposz = gz;
set_globalpos(gx, gy, gz);
viewangle = oviewangle;
set_globalang(oglobalang);

View file

@ -128,7 +128,7 @@ float gtang = 0.f;
static double guo, gux, guy; //Screen-based texture mapping parameters
static double gvo, gvx, gvy;
static double gdo, gdx, gdy;
float fcosglobalang, fsinglobalang, fglobalposx, fglobalposy, fglobalposz;
float fcosglobalang, fsinglobalang;
float fxdim, fydim, fxdimen, fydimen, fviewingrange;
static int32_t preview_mouseaim=0; // when 1, displays a CROSSHAIR tsprite at the _real_ aimed position
@ -272,7 +272,7 @@ void gltexinvalidatetype(int32_t type)
int32_t j;
pthtyp *pth;
for (j=GLTEXCACHEADSIZ-1; j>=0; j--)
for (j=0; j<=GLTEXCACHEADSIZ-1; j++)
{
for (pth=texcache.list[j]; pth; pth=pth->next)
{
@ -317,7 +317,7 @@ void gltexapplyprops(void)
gltexfiltermode = clamp(gltexfiltermode, 0, NUMGLFILTERMODES-1);
for (i=GLTEXCACHEADSIZ-1; i>=0; i--)
for (i=0; i<=GLTEXCACHEADSIZ-1; i++)
{
for (pth=texcache.list[i]; pth; pth=pth->next)
{
@ -365,11 +365,11 @@ void polymost_glreset()
int32_t i;
pthtyp *pth, *next;
for (i=MAXPALOOKUPS-1; i>=0; i--)
for (i=0; i<=MAXPALOOKUPS-1; i++)
{
fogtable[i<<2] = palookupfog[i].r / 63.f;
fogtable[(i<<2)+1] = palookupfog[i].g / 63.f;
fogtable[(i<<2)+2] = palookupfog[i].b / 63.f;
fogtable[i<<2] = palookupfog[i].r * (1.f/63.f);
fogtable[(i<<2)+1] = palookupfog[i].g * (1.f/63.f);
fogtable[(i<<2)+2] = palookupfog[i].b * (1.f/63.f);
fogtable[(i<<2)+3] = 0;
}
@ -384,7 +384,7 @@ void polymost_glreset()
}
else
{
for (i=GLTEXCACHEADSIZ-1; i>=0; i--)
for (i=0; i<=GLTEXCACHEADSIZ-1; i++)
{
for (pth=texcache.list[i]; pth;)
{
@ -2520,7 +2520,7 @@ static void polymost_drawalls(int32_t bunch)
dd[0] = fxdimen*.0000001f; //Adjust sky depth based on screen size!
t = (float)((1<<(picsiz[globalpicnum]&15))<<dapskybits);
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;
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;
//Hack to draw black rectangle below sky when looking down...
@ -2819,11 +2819,11 @@ static void polymost_drawalls(int32_t bunch)
else domost(x1,cy1,x0,cy0);
if (r_parallaxskypanning)
vv[0] += dd[0]*(float)sec->ceilingypanning*(float)i/256.f;
vv[0] += dd[0]*(float)sec->ceilingypanning*(float)i*(1.f/256.f);
gdx = 0; gdy = 0; gdo = dd[0];
gux = gdo *
(t * (float) ((uint64_t)(xdimscale * yxaspect) * viewingrange)) / (16384.0*65536.0*65536.0*5.0*1024.0);
(t * (float) ((uint64_t)(xdimscale * yxaspect) * viewingrange)) * (1.f/(16384.0*65536.0*65536.0*5.0*1024.0));
guy = 0; //guo calculated later
gvx = 0; gvy = vv[1]; gvo = vv[0];
@ -3442,9 +3442,6 @@ void polymost_drawrooms()
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*fviewingrange)*(5.f/(65536.f*262144.f));