Revert "vec2_t rotatepoint()."

This reverts commit b0eeef385aecf9cea3ec2bd0ee82f59982942ce0.

git-svn-id: https://svn.eduke32.com/eduke32@5154 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2015-04-18 21:49:36 +00:00
parent d320ea6d70
commit 53d2e0939e
6 changed files with 75 additions and 86 deletions

View file

@ -1145,7 +1145,8 @@ FORCE_INLINE int32_t logapproach(int32_t val, int32_t targetval)
return (dif>>1) ? val + (dif>>1) : targetval;
}
void rotatepoint(vec2_t pivot, vec2_t p, int16_t daang, vec2_t *p2) ATTRIBUTE((nonnull(4)));
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)));
int32_t lastwall(int16_t point);
int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction);
@ -1426,8 +1427,6 @@ 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;

View file

@ -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 hihit, lohit, omlook=mlook;
int32_t dax, day, 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;
vec2_t da = { 16384, divscale14(searchx-(xdim>>1), xdim>>1) };
rotatepoint(zerovec, da, ang, &da);
dax = 16384;
day = divscale14(searchx-(xdim>>1), xdim>>1);
rotatepoint(0,0, dax,day, ang, &dax,&day);
hitscan((const vec3_t *)&pos,cursectnum, //Start position
da.x,da.y,(scale(searchy,200,ydim)-horiz)*2000, //vector of 3D ang
dax,day,(scale(searchy,200,ydim)-horiz)*2000, //vector of 3D ang
&hit,CLIPMASK1);
if (hit.sect >= 0)
{
da.x = hit.pos.x;
da.y = hit.pos.y;
dax = hit.pos.x;
day = hit.pos.y;
if (gridlock && grid > 0)
{
if (AIMING_AT_WALL || AIMING_AT_MASKWALL)
hit.pos.z &= 0xfffffc00;
else
locktogrid(&da.x, &da.y);
locktogrid(&dax, &day);
}
i = insert_sprite_common(hit.sect, da.x, da.y);
i = insert_sprite_common(hit.sect, dax, day);
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;
vec2_t piv; // pivot point
int32_t pivx, pivy; // pivot point
int32_t dragx, dragy; // dragged point
int32_t xsc, ysc, ang;
} isc;
@ -3154,15 +3154,12 @@ static void isc_transform(int32_t *x, int32_t *y)
{
if (!isc.rotatep)
{
*x = isc.piv.x + mulscale16(*x-isc.piv.x, isc.xsc);
*y = isc.piv.y + mulscale16(*y-isc.piv.y, isc.ysc);
*x = isc.pivx + mulscale16(*x-isc.pivx, isc.xsc);
*y = isc.pivy + mulscale16(*y-isc.pivy, isc.ysc);
}
else
{
vec2_t v = { *x, *y };
rotatepoint(isc.piv, v, isc.ang, &v);
*x = v.x;
*y = v.y;
rotatepoint(isc.pivx, isc.pivy, *x, *y, isc.ang, x, y);
}
}
@ -3545,8 +3542,8 @@ void overheadeditor(void)
maxy = max(maxy, HLMEMBER(i, y));
}
isc.piv.x = (minx+maxx)/2;
isc.piv.y = (miny+maxy)/2;
isc.pivx = (minx+maxx)/2;
isc.pivy = (miny+maxy)/2;
isc.dragx = HLMEMBERX(pointhighlight, x);
isc.dragy = HLMEMBERX(pointhighlight, y);
@ -3562,7 +3559,7 @@ void overheadeditor(void)
if (bstatus&3)
{
// drag/rotate the reference point
const int32_t pivx=isc.piv.x, pivy=isc.piv.y;
const int32_t pivx=isc.pivx, pivy=isc.pivy;
const int32_t dragx=isc.dragx, dragy=isc.dragy;
int32_t mxplc=mousxplc, myplc=mousyplc, xsc=1<<16, ysc=1<<16;
@ -3996,7 +3993,6 @@ void overheadeditor(void)
if (highlightsectorcnt > 0)
{
int32_t smoothRotation = eitherSHIFT, manualAngle = eitherALT;
vec2_t da = { dax, day };
if (manualAngle)
{
@ -4012,25 +4008,24 @@ void overheadeditor(void)
smoothRotation = 1;
}
get_sectors_center(highlightsector, highlightsectorcnt, &da.x, &da.y);
get_sectors_center(highlightsector, highlightsectorcnt, &dax, &day);
if (!smoothRotation)
{
if (gridlock && grid > 0)
locktogrid(&da.x, &da.y);
locktogrid(&dax, &day);
tsign *= 512;
}
for (i=0; i<highlightsectorcnt; i++)
{
for (WALLS_OF_SECTOR(highlightsector[i], j))
rotatepoint(da, *(vec2_t *)&wall[j], tsign&2047, (vec2_t *)&wall[j].x);
rotatepoint(dax,day, wall[j].x,wall[j].y, tsign&2047, &wall[j].x,&wall[j].y);
for (j=headspritesect[highlightsector[i]]; j != -1; j=nextspritesect[j])
{
rotatepoint(da, *(vec2_t *)&sprite[j], tsign&2047, (vec2_t *)&sprite[j].x);
rotatepoint(dax,day, sprite[j].x,sprite[j].y, tsign&2047, &sprite[j].x,&sprite[j].y);
sprite[j].ang = (sprite[j].ang+tsign)&2047;
}
}
@ -8249,17 +8244,15 @@ void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y)
searchxe -= halfxdim16;
searchye -= midydim16;
vec2_t svec = { searchxe ,searchye };
if (m32_sideview)
{
if (m32_sidesin!=0)
svec.y = divscale14(svec.y, m32_sidesin);
rotatepoint(zerovec, svec, -m32_sideang, &svec);
searchye = divscale14(searchye, m32_sidesin);
rotatepoint(0,0, searchxe,searchye, -m32_sideang, &searchxe,&searchye);
}
*x = pos.x + divscale14(svec.x,zoom);
*y = pos.y + divscale14(svec.y,zoom);
*x = pos.x + divscale14(searchxe,zoom);
*y = pos.y + divscale14(searchye,zoom);
inpclamp(x, -editorgridextent, editorgridextent);
inpclamp(y, -editorgridextent, editorgridextent);

View file

@ -13765,7 +13765,7 @@ static int32_t clipsprite_initindex(int32_t curidx, spritetype *curspr, int32_t
{
wal->x *= flipx;
wal->y *= flipy;
rotatepoint(zerovec, *(vec2_t *)&wal, rotang, (vec2_t *)&wal);
rotatepoint(0,0, wal->x,wal->y, rotang, &wal->x,&wal->y);
}
wal->x += curspr->x;
@ -14624,14 +14624,16 @@ void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum)
//
// rotatepoint
//
void rotatepoint(vec2_t const pivot, vec2_t p, int16_t daang, vec2_t *p2)
void rotatepoint(int32_t xpivot, int32_t ypivot, int32_t x, int32_t y, int16_t daang, int32_t *x2, int32_t *y2)
{
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;
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;
}
@ -16681,13 +16683,11 @@ 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)
{
vec2_t coord = { x, y };
if (m32_sideview)
rotatepoint(zerovec, coord, m32_sideang, &coord);
rotatepoint(0,0, x,y, m32_sideang, &x,&y);
*xres = mulscale14(coord.x, zoome);
*yres = scalescreeny(mulscale14(coord.y, zoome));
*xres = mulscale14(x,zoome);
*yres = scalescreeny(mulscale14(y,zoome));
}
#if 0
@ -16709,13 +16709,7 @@ 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;
vec2_t v[2] = { { 0, dz }, { *dx, *dy } };
rotatepoint(zerovec, v[0], -m32_sideang, &v[1]);
*dx = v[1].x;
*dy = v[1].y;
rotatepoint(0,0, 0,dz, -m32_sideang, dx,dy);
return 0;
}
@ -16736,7 +16730,7 @@ void setup_sideview_sincos(void)
m32_sidesin = sintable[m32_sideelev&2047];
m32_sidecos = sintable[(m32_sideelev+512)&2047];
rotatepoint(zerovec, *(vec2_t *)&m32_viewplane, -m32_sideang, (vec2_t *)&m32_viewplane);
rotatepoint(0,0, m32_viewplane.x,m32_viewplane.y, -m32_sideang, &m32_viewplane.x,&m32_viewplane.y);
m32_viewplane.x = mulscale14(m32_viewplane.x, m32_sidecos);
m32_viewplane.y = mulscale14(m32_viewplane.y, m32_sidecos);
m32_viewplane.z = m32_sidesin>>5;

View file

@ -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(zerovec, *(vec2_t *)&actor[j].t_data[8], daang & 2047, (vec2_t *)&sprite[j].x);
rotatepoint(0, 0, actor[j].t_data[8], actor[j].t_data[9], daang & 2047, &sprite[j].x, &sprite[j].y);
sprite[j].x += sprite[pivotspr].x;
sprite[j].y += sprite[pivotspr].y;
return 0;
@ -748,6 +748,7 @@ 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;
@ -756,9 +757,8 @@ static void A_MoveSector(int i)
for (i = sector[s->sectnum].wallptr; i < endwall; i++)
{
vec2_t t;
rotatepoint(zerovec, *(vec2_t *)&msx[j], k & 2047, &t);
dragpoint(i, s->x + t.x, s->y + t.y, 0);
rotatepoint(0, 0, msx[j], msy[j], k & 2047, &tx, &ty);
dragpoint(i, s->x + tx, s->y + ty, 0);
j++;
}
@ -5716,16 +5716,19 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
ps->pos.z += zchange;
vec2_t r;
rotatepoint(*(vec2_t *)&sprite[j],*(vec2_t *)&ps->pos,(q*l),&r);
rotatepoint(sprite[j].x,sprite[j].y,ps->pos.x,ps->pos.y,(q*l),&m,&x);
ps->bobpos.x += r.x-ps->pos.x;
ps->bobpos.y += r.y-ps->pos.y;
ps->bobpos.x += m-ps->pos.x;
ps->bobpos.y += x-ps->pos.y;
*(vec2_t *)&ps->pos = r;
ps->pos.x = m;
ps->pos.y = x;
if (sprite[ps->i].extra <= 0)
*(vec2_t *)&sprite[ps->i] = r;
{
sprite[ps->i].x = m;
sprite[ps->i].y = x;
}
}
}
@ -5748,7 +5751,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(*(vec2_t *)&sprite[j], *(vec2_t *)&sprite[p], (q * l), (vec2_t *)&sprite[p].x);
rotatepoint(sprite[j].x,sprite[j].y,sprite[p].x,sprite[p].y,(q*l),&sprite[p].x,&sprite[p].y);
}
}
@ -5931,7 +5934,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
#endif
)
{
rotatepoint(*(vec2_t *)s, *(vec2_t *)&ps->pos, q, (vec2_t *)&ps->pos);
rotatepoint(s->x,s->y,ps->pos.x,ps->pos.y,q,&ps->pos.x,&ps->pos.y);
ps->pos.x += m;
ps->pos.y += x;
@ -5974,7 +5977,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
if (move_rotfixed_sprite(j, s-sprite, t[2]))
rotatepoint(*(vec2_t *)s,*(vec2_t *)&sprite[j],q,(vec2_t *)&sprite[j].x);
rotatepoint(s->x,s->y,sprite[j].x,sprite[j].y,q,&sprite[j].x,&sprite[j].y);
sprite[j].x+= m;
sprite[j].y+= x;

View file

@ -2995,9 +2995,9 @@ nullquote:
Gv_GetManyVars(3, (int32_t *)&vect);
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 sectnum = Gv_GetVarX(*insptr++);
int32_t ceilzvar = *insptr++, ceilhitvar = *insptr++, florzvar = *insptr++, florhitvar = *insptr++;
int32_t 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 const hypsq = (int64_t)da.x*da.x + (int64_t)da.y*da.y;
int64_t 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;
int const retvar = *insptr++, xvar = *insptr++, yvar = *insptr++;
int32_t retvar=*insptr++, xvar=*insptr++, yvar=*insptr++;
insptr -= 2;
vec3_t vec3;
Gv_GetManyVars(3, (int32_t *)&vec3);
int const sectnumvar = *insptr++;
int32_t 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);
int const clipmask = Gv_GetVarX(*insptr++);
int32_t clipmask = Gv_GetVarX(*insptr++);
int16_t sectnum = Gv_GetVarX(sectnumvar);
if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors))
@ -3117,7 +3117,8 @@ nullquote:
continue;
}
Gv_SetVarX(retvar, clipmovex(&vec3, &sectnum, vec2.x, vec2.y, dist.w, dist.f, dist.c, clipmask, (tw == CON_CLIPMOVENOSLIDE)));
Gv_SetVarX(retvar, clipmovex(&vec3, &sectnum, 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);
@ -3131,7 +3132,7 @@ nullquote:
vec3_t vect;
Gv_GetManyVars(3, (int32_t *)&vect);
int const sectnum = Gv_GetVarX(*insptr++);
int32_t sectnum = Gv_GetVarX(*insptr++);
vec3_t v;
Gv_GetManyVars(3, (int32_t *) &v);
@ -3168,7 +3169,7 @@ nullquote:
vec3_t vec2;
Gv_GetManyVars(3, (int32_t *) &vec2);
int const sect2 = Gv_GetVarX(*insptr++), rvar = *insptr++;
int32_t sect2=Gv_GetVarX(*insptr++), rvar=*insptr++;
if (EDUKE32_PREDICT_FALSE((unsigned)sect1 >= (unsigned)numsectors || (unsigned)sect2 >= (unsigned)numsectors))
{
@ -3191,7 +3192,7 @@ nullquote:
vec2_t result;
rotatepoint(point[0], point[1], angle, &result);
rotatepoint(point[0].x, point[0].y, point[1].x, point[1].y, angle, &result.x, &result.y);
Gv_SetVarX(x2var, result.x);
Gv_SetVarX(y2var, result.y);

View file

@ -1920,15 +1920,14 @@ badindex:
case CON_ROTATEPOINT:
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 xpivot=Gv_GetVarX(*insptr++), ypivot=Gv_GetVarX(*insptr++);
int32_t x=Gv_GetVarX(*insptr++), y=Gv_GetVarX(*insptr++), daang=Gv_GetVarX(*insptr++);
int32_t x2var=*insptr++, y2var=*insptr++;
vec2_t p2;
int32_t x2, y2;
rotatepoint(pivot,p,daang,&p2);
Gv_SetVarX(x2var, p2.x);
Gv_SetVarX(y2var, p2.y);
rotatepoint(xpivot,ypivot,x,y,daang,&x2,&y2);
Gv_SetVarX(x2var, x2);
Gv_SetVarX(y2var, y2);
continue;
}