diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 1b9a6d34d..d1a8d48cd 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -1145,8 +1145,7 @@ FORCE_INLINE int32_t logapproach(int32_t val, int32_t targetval) return (dif>>1) ? val + (dif>>1) : targetval; } -void rotatepoint(int32_t xpivot, int32_t ypivot, int32_t x, int32_t y, - int16_t daang, int32_t *x2, int32_t *y2) ATTRIBUTE((nonnull(6,7))); +void rotatepoint(vec2_t pivot, vec2_t p, int16_t daang, vec2_t *p2) ATTRIBUTE((nonnull(4))); int32_t lastwall(int16_t point); int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction); @@ -1427,6 +1426,8 @@ FORCE_INLINE void pop_nofog(void) #endif } +static vec2_t const zerovec = { 0, 0 }; + #ifdef LUNATIC extern const int32_t engine_main_arrays_are_static; extern const int32_t engine_v8; diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index cc792b380..dbabd6c77 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -1014,7 +1014,7 @@ void editinput(void) int32_t mousz, bstatus; int32_t i, tempint=0; int32_t goalz, xvect, yvect, hiz, loz, oposz; - int32_t dax, day, hihit, lohit, omlook=mlook; + int32_t hihit, lohit, omlook=mlook; // 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 // F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL @@ -1293,27 +1293,27 @@ void editinput(void) { hitdata_t hit; - dax = 16384; - day = divscale14(searchx-(xdim>>1), xdim>>1); - rotatepoint(0,0, dax,day, ang, &dax,&day); + vec2_t da = { 16384, divscale14(searchx-(xdim>>1), xdim>>1) }; + + rotatepoint(zerovec, da, ang, &da); hitscan((const vec3_t *)&pos,cursectnum, //Start position - dax,day,(scale(searchy,200,ydim)-horiz)*2000, //vector of 3D ang + da.x,da.y,(scale(searchy,200,ydim)-horiz)*2000, //vector of 3D ang &hit,CLIPMASK1); if (hit.sect >= 0) { - dax = hit.pos.x; - day = hit.pos.y; + da.x = hit.pos.x; + da.y = hit.pos.y; if (gridlock && grid > 0) { if (AIMING_AT_WALL || AIMING_AT_MASKWALL) hit.pos.z &= 0xfffffc00; else - locktogrid(&dax, &day); + locktogrid(&da.x, &da.y); } - i = insert_sprite_common(hit.sect, dax, day); + i = insert_sprite_common(hit.sect, da.x, da.y); if (i < 0) message("Couldn't insert sprite."); @@ -3145,7 +3145,7 @@ static void draw_square(int32_t dax, int32_t day, int32_t ps, int32_t col) //// Interactive Scaling static struct { int8_t active, rotatep; - int32_t pivx, pivy; // pivot point + vec2_t piv; // pivot point int32_t dragx, dragy; // dragged point int32_t xsc, ysc, ang; } isc; @@ -3154,12 +3154,15 @@ static void isc_transform(int32_t *x, int32_t *y) { if (!isc.rotatep) { - *x = isc.pivx + mulscale16(*x-isc.pivx, isc.xsc); - *y = isc.pivy + mulscale16(*y-isc.pivy, isc.ysc); + *x = isc.piv.x + mulscale16(*x-isc.piv.x, isc.xsc); + *y = isc.piv.y + mulscale16(*y-isc.piv.y, isc.ysc); } else { - rotatepoint(isc.pivx, isc.pivy, *x, *y, isc.ang, x, y); + vec2_t v = { *x, *y }; + rotatepoint(isc.piv, v, isc.ang, &v); + *x = v.x; + *y = v.y; } } @@ -3542,8 +3545,8 @@ void overheadeditor(void) maxy = max(maxy, HLMEMBER(i, y)); } - isc.pivx = (minx+maxx)/2; - isc.pivy = (miny+maxy)/2; + isc.piv.x = (minx+maxx)/2; + isc.piv.y = (miny+maxy)/2; isc.dragx = HLMEMBERX(pointhighlight, x); isc.dragy = HLMEMBERX(pointhighlight, y); @@ -3559,7 +3562,7 @@ void overheadeditor(void) if (bstatus&3) { // drag/rotate the reference point - const int32_t pivx=isc.pivx, pivy=isc.pivy; + const int32_t pivx=isc.piv.x, pivy=isc.piv.y; const int32_t dragx=isc.dragx, dragy=isc.dragy; int32_t mxplc=mousxplc, myplc=mousyplc, xsc=1<<16, ysc=1<<16; @@ -3993,6 +3996,7 @@ void overheadeditor(void) if (highlightsectorcnt > 0) { int32_t smoothRotation = eitherSHIFT, manualAngle = eitherALT; + vec2_t da = { dax, day }; if (manualAngle) { @@ -4008,24 +4012,25 @@ void overheadeditor(void) smoothRotation = 1; } - get_sectors_center(highlightsector, highlightsectorcnt, &dax, &day); + get_sectors_center(highlightsector, highlightsectorcnt, &da.x, &da.y); if (!smoothRotation) { if (gridlock && grid > 0) - locktogrid(&dax, &day); + locktogrid(&da.x, &da.y); tsign *= 512; } + for (i=0; ix *= flipx; wal->y *= flipy; - rotatepoint(0,0, wal->x,wal->y, rotang, &wal->x,&wal->y); + rotatepoint(zerovec, *(vec2_t *)&wal, rotang, (vec2_t *)&wal); } wal->x += curspr->x; @@ -14624,16 +14624,14 @@ void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) // // rotatepoint // -void rotatepoint(int32_t xpivot, int32_t ypivot, int32_t x, int32_t y, int16_t daang, int32_t *x2, int32_t *y2) +void rotatepoint(vec2_t const pivot, vec2_t p, int16_t daang, vec2_t *p2) { - int32_t dacos, dasin; - - dacos = sintable[(daang+2560)&2047]; - dasin = sintable[(daang+2048)&2047]; - x -= xpivot; - y -= ypivot; - *x2 = dmulscale14(x,dacos,-y,dasin) + xpivot; - *y2 = dmulscale14(y,dacos,x,dasin) + ypivot; + int const dacos = sintable[(daang+2560)&2047]; + int const dasin = sintable[(daang+2048)&2047]; + p.x -= pivot.x; + p.y -= pivot.y; + p2->x = dmulscale14(p.x, dacos, -p.y, dasin) + pivot.x; + p2->y = dmulscale14(p.y, dacos, p.x, dasin) + pivot.y; } @@ -16683,11 +16681,13 @@ int32_t scalescreeny(int32_t sy) // return screen coordinates for BUILD coords x and y (relative to current position) void screencoords(int32_t *xres, int32_t *yres, int32_t x, int32_t y, int32_t zoome) { - if (m32_sideview) - rotatepoint(0,0, x,y, m32_sideang, &x,&y); + vec2_t coord = { x, y }; - *xres = mulscale14(x,zoome); - *yres = scalescreeny(mulscale14(y,zoome)); + if (m32_sideview) + rotatepoint(zerovec, coord, m32_sideang, &coord); + + *xres = mulscale14(coord.x, zoome); + *yres = scalescreeny(mulscale14(coord.y, zoome)); } #if 0 @@ -16709,7 +16709,13 @@ int32_t getinvdisplacement(int32_t *dx, int32_t *dy, int32_t dz) return 1; dz = (((int64_t)dz * (int64_t)m32_sidecos)/(int64_t)m32_sidesin)>>4; - rotatepoint(0,0, 0,dz, -m32_sideang, dx,dy); + + vec2_t v[2] = { { 0, dz }, { *dx, *dy } }; + + rotatepoint(zerovec, v[0], -m32_sideang, &v[1]); + + *dx = v[1].x; + *dy = v[1].y; return 0; } @@ -16730,7 +16736,7 @@ void setup_sideview_sincos(void) m32_sidesin = sintable[m32_sideelev&2047]; m32_sidecos = sintable[(m32_sideelev+512)&2047]; - rotatepoint(0,0, m32_viewplane.x,m32_viewplane.y, -m32_sideang, &m32_viewplane.x,&m32_viewplane.y); + rotatepoint(zerovec, *(vec2_t *)&m32_viewplane, -m32_sideang, (vec2_t *)&m32_viewplane); m32_viewplane.x = mulscale14(m32_viewplane.x, m32_sidecos); m32_viewplane.y = mulscale14(m32_viewplane.y, m32_sidecos); m32_viewplane.z = m32_sidesin>>5; diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 1110558f7..f08f30851 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -734,7 +734,7 @@ static int32_t move_rotfixed_sprite(int32_t j, int32_t pivotspr, int32_t daang) A_CheckSpriteTileFlags(sprite[j].picnum, SFLAG_ROTFIXED))) && actor[j].t_data[7] == (ROTFIXSPR_MAGIC | pivotspr)) { - rotatepoint(0, 0, actor[j].t_data[8], actor[j].t_data[9], daang & 2047, &sprite[j].x, &sprite[j].y); + rotatepoint(zerovec, *(vec2_t *)&actor[j].t_data[8], daang & 2047, (vec2_t *)&sprite[j].x); sprite[j].x += sprite[pivotspr].x; sprite[j].y += sprite[pivotspr].y; return 0; @@ -748,7 +748,6 @@ static void A_MoveSector(int i) // T1,T2 and T3 are used for all the sector moving stuff!!! spritetype * const s = &sprite[i]; int j = T2, k = T3; - int32_t tx, ty; s->x += (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14; s->y += (s->xvel * (sintable[s->ang & 2047])) >> 14; @@ -757,8 +756,9 @@ static void A_MoveSector(int i) for (i = sector[s->sectnum].wallptr; i < endwall; i++) { - rotatepoint(0, 0, msx[j], msy[j], k & 2047, &tx, &ty); - dragpoint(i, s->x + tx, s->y + ty, 0); + vec2_t t; + rotatepoint(zerovec, *(vec2_t *)&msx[j], k & 2047, &t); + dragpoint(i, s->x + t.x, s->y + t.y, 0); j++; } @@ -5716,19 +5716,16 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 ps->pos.z += zchange; - rotatepoint(sprite[j].x,sprite[j].y,ps->pos.x,ps->pos.y,(q*l),&m,&x); + vec2_t r; + rotatepoint(*(vec2_t *)&sprite[j],*(vec2_t *)&ps->pos,(q*l),&r); - ps->bobpos.x += m-ps->pos.x; - ps->bobpos.y += x-ps->pos.y; + ps->bobpos.x += r.x-ps->pos.x; + ps->bobpos.y += r.y-ps->pos.y; - ps->pos.x = m; - ps->pos.y = x; + *(vec2_t *)&ps->pos = r; if (sprite[ps->i].extra <= 0) - { - sprite[ps->i].x = m; - sprite[ps->i].y = x; - } + *(vec2_t *)&sprite[ps->i] = r; } } @@ -5751,7 +5748,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 actor[p].bpos.y = sprite[p].y; if (move_rotfixed_sprite(p, j, t[2])) - rotatepoint(sprite[j].x,sprite[j].y,sprite[p].x,sprite[p].y,(q*l),&sprite[p].x,&sprite[p].y); + rotatepoint(*(vec2_t *)&sprite[j], *(vec2_t *)&sprite[p], (q * l), (vec2_t *)&sprite[p].x); } } @@ -5934,7 +5931,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 #endif ) { - rotatepoint(s->x,s->y,ps->pos.x,ps->pos.y,q,&ps->pos.x,&ps->pos.y); + rotatepoint(*(vec2_t *)s, *(vec2_t *)&ps->pos, q, (vec2_t *)&ps->pos); ps->pos.x += m; ps->pos.y += x; @@ -5977,7 +5974,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 } if (move_rotfixed_sprite(j, s-sprite, t[2])) - rotatepoint(s->x,s->y,sprite[j].x,sprite[j].y,q,&sprite[j].x,&sprite[j].y); + rotatepoint(*(vec2_t *)s,*(vec2_t *)&sprite[j],q,(vec2_t *)&sprite[j].x); sprite[j].x+= m; sprite[j].y+= x; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index ba261f70a..4414a4656 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -2995,9 +2995,9 @@ nullquote: Gv_GetManyVars(3, (int32_t *)&vect); - int32_t sectnum = Gv_GetVarX(*insptr++); - int32_t ceilzvar = *insptr++, ceilhitvar = *insptr++, florzvar = *insptr++, florhitvar = *insptr++; - int32_t walldist = Gv_GetVarX(*insptr++), clipmask = Gv_GetVarX(*insptr++); + int const sectnum = Gv_GetVarX(*insptr++); + int const ceilzvar = *insptr++, ceilhitvar = *insptr++, florzvar = *insptr++, florhitvar = *insptr++; + int const walldist = Gv_GetVarX(*insptr++), clipmask = Gv_GetVarX(*insptr++); int32_t ceilz, ceilhit, florz, florhit; if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors)) @@ -3041,7 +3041,7 @@ nullquote: int32_t retvar=*insptr++; vec2_t da; Gv_GetManyVars(2, (int32_t *)&da); - int64_t hypsq = (int64_t)da.x*da.x + (int64_t)da.y*da.y; + int64_t const hypsq = (int64_t)da.x*da.x + (int64_t)da.y*da.y; if (hypsq > (int64_t)INT32_MAX) Gv_SetVarX(retvar, (int32_t)sqrt((double)hypsq)); @@ -3092,14 +3092,14 @@ nullquote: int32_t w, f, c; } vec3dist_t; - int32_t retvar=*insptr++, xvar=*insptr++, yvar=*insptr++; + int const retvar = *insptr++, xvar = *insptr++, yvar = *insptr++; insptr -= 2; vec3_t vec3; Gv_GetManyVars(3, (int32_t *)&vec3); - int32_t sectnumvar=*insptr++; + int const sectnumvar = *insptr++; vec2_t vec2; Gv_GetManyVars(2, (int32_t *)&vec2); @@ -3107,7 +3107,7 @@ nullquote: vec3dist_t dist; Gv_GetManyVars(3, (int32_t *)&dist); - int32_t clipmask = Gv_GetVarX(*insptr++); + int const clipmask = Gv_GetVarX(*insptr++); int16_t sectnum = Gv_GetVarX(sectnumvar); if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors)) @@ -3117,8 +3117,7 @@ nullquote: continue; } - Gv_SetVarX(retvar, clipmovex(&vec3, §num, vec2.x, vec2.y, dist.w, dist.f, dist.c, - clipmask, (tw==CON_CLIPMOVENOSLIDE))); + Gv_SetVarX(retvar, clipmovex(&vec3, §num, vec2.x, vec2.y, dist.w, dist.f, dist.c, clipmask, (tw == CON_CLIPMOVENOSLIDE))); Gv_SetVarX(sectnumvar, sectnum); Gv_SetVarX(xvar, vec3.x); Gv_SetVarX(yvar, vec3.y); @@ -3132,7 +3131,7 @@ nullquote: vec3_t vect; Gv_GetManyVars(3, (int32_t *)&vect); - int32_t sectnum = Gv_GetVarX(*insptr++); + int const sectnum = Gv_GetVarX(*insptr++); vec3_t v; Gv_GetManyVars(3, (int32_t *) &v); @@ -3169,7 +3168,7 @@ nullquote: vec3_t vec2; Gv_GetManyVars(3, (int32_t *) &vec2); - int32_t sect2=Gv_GetVarX(*insptr++), rvar=*insptr++; + int const sect2 = Gv_GetVarX(*insptr++), rvar = *insptr++; if (EDUKE32_PREDICT_FALSE((unsigned)sect1 >= (unsigned)numsectors || (unsigned)sect2 >= (unsigned)numsectors)) { @@ -3192,7 +3191,7 @@ nullquote: vec2_t result; - rotatepoint(point[0].x, point[0].y, point[1].x, point[1].y, angle, &result.x, &result.y); + rotatepoint(point[0], point[1], angle, &result); Gv_SetVarX(x2var, result.x); Gv_SetVarX(y2var, result.y); diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c index 6710e86fb..e0c263bd8 100644 --- a/polymer/eduke32/source/m32exec.c +++ b/polymer/eduke32/source/m32exec.c @@ -1920,14 +1920,15 @@ badindex: case CON_ROTATEPOINT: insptr++; { - int32_t xpivot=Gv_GetVarX(*insptr++), ypivot=Gv_GetVarX(*insptr++); - int32_t x=Gv_GetVarX(*insptr++), y=Gv_GetVarX(*insptr++), daang=Gv_GetVarX(*insptr++); + vec2_t pivot = { Gv_GetVarX(*insptr++), Gv_GetVarX(*insptr++) }; + vec2_t p = { Gv_GetVarX(*insptr++), Gv_GetVarX(*insptr++) } ; + int32_t daang=Gv_GetVarX(*insptr++); int32_t x2var=*insptr++, y2var=*insptr++; - int32_t x2, y2; + vec2_t p2; - rotatepoint(xpivot,ypivot,x,y,daang,&x2,&y2); - Gv_SetVarX(x2var, x2); - Gv_SetVarX(y2var, y2); + rotatepoint(pivot,p,daang,&p2); + Gv_SetVarX(x2var, p2.x); + Gv_SetVarX(y2var, p2.y); continue; }