KenBuild, SW: rotatepoint

git-svn-id: https://svn.eduke32.com/eduke32@5738 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2016-05-23 04:46:30 +00:00
parent 8be6da168f
commit c0b9c3a189
5 changed files with 43 additions and 32 deletions

View file

@ -1833,23 +1833,21 @@ void DrawCrosshair(PLAYERp pp)
{
SPRITEp hp = &sprite[hit_sprite];
USERp hu = User[hit_sprite];
int dx,dy,dz;
vec2_t const zero = { 0, 0 };
// Find the delta coordinates from player to monster that is targeted
dx = hp->x - pp->posx;
dy = hp->y - pp->posy;
dz = ((hp->z - (SPRITE_SIZE_Z(hit_sprite)/2)) - pp->posz) >> 4;
vec2_t dxy = { hp->x - pp->posx, hp->y - pp->posy };
int dz = ((hp->z - (SPRITE_SIZE_Z(hit_sprite)/2)) - pp->posz) >> 4;
rotatepoint(0,0,dx,dy,(-pp->pang)&2047,&dx,&dy);
rotatepoint(zero, dxy, (-pp->pang)&2047, &dxy);
if (dx == 0) return;
if (dxy.x == 0) return;
wdx = windowx1 + ((windowx2-windowx1)/2);
wdy = windowy1 + ((windowy2-windowy1)/2);
x = (dy * wdx << 8) / dx + (wdx << 8);
y = (dz * wdx << 8) / dx + (wdy << 8);
x = (dxy.y * wdx << 8) / dxy.x + (wdx << 8);
y = (dz * wdx << 8) / dxy.x + (wdy << 8);
y -= 100;
y += (pp->horiz*wdx)/160;

View file

@ -525,7 +525,8 @@ int testpointinquad(int x, int y, int *qx, int *qy)
short RectClipTurn(PLAYERp pp, short new_ang, int *qx, int *qy, int *ox, int *oy)
{
int i, x[4], y[4];
int i;
vec2_t xy[4];
SECTOR_OBJECTp sop = pp->sop;
int ret;
short ang;
@ -535,9 +536,10 @@ short RectClipTurn(PLAYERp pp, short new_ang, int *qx, int *qy, int *ox, int *oy
rot_ang = NORM_ANGLE(new_ang + sop->spin_ang - sop->ang_orig);
for (i = 0; i < 4; i++)
{
rotatepoint(pp->posx, pp->posy, ox[i], oy[i], rot_ang, &x[i], &y[i]);
vec2_t const p = { ox[i], oy[i] };
rotatepoint(*(vec2_t *)&pp->posx, p, rot_ang, &xy[i]);
// cannot use sop->xmid and ymid because the SO is off the map at this point
//rotatepoint(sop->xmid, sop->ymid, ox[i], oy[i], rot_ang, &x[i], &y[i]);
//rotatepoint(*(vec2_t *)&sop->xmid, p, rot_ang, &xy[i]);
}
//Given the 4 points: x[4], y[4]
@ -546,8 +548,8 @@ short RectClipTurn(PLAYERp pp, short new_ang, int *qx, int *qy, int *ox, int *oy
// move to new pos
for (i = 0; i < 4; i++)
{
qx[i] = x[i];
qy[i] = y[i];
qx[i] = xy[i].x;
qy[i] = xy[i].y;
}
return TRUE;
}

View file

@ -309,7 +309,7 @@ int DoRotatorMove(short SpriteNum)
short ndx,w,startwall,endwall;
SPRITEp pivot = NULL;
int i, nexti;
int nx,ny;
vec2_t nxy;
int dist,closest;
SWBOOL kill = FALSE;
@ -408,9 +408,8 @@ int DoRotatorMove(short SpriteNum)
// move points
for (w = startwall, ndx = 0; w <= endwall; w++)
{
rotatepoint(pivot->x, pivot->y,
r->origx[ndx], r->origy[ndx],
r->pos, &nx, &ny);
vec2_t const orig = { r->origx[ndx], r->origy[ndx] };
rotatepoint(*(vec2_t *)&pivot->x, orig, r->pos, &nxy);
dragpoint(w, nx, ny, 0);
ndx++;

View file

@ -1659,7 +1659,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
// increment Players delta angle
pp->RevolveDeltaAng = NORM_ANGLE(pp->RevolveDeltaAng + GlobSpeedSO);
rotatepoint(sop->xmid, sop->ymid, pp->RevolveX, pp->RevolveY, pp->RevolveDeltaAng, &pp->posx, &pp->posy);
rotatepoint(*(vec2_t *)&sop->xmid, *(vec2_t *)&pp->RevolveX, pp->RevolveDeltaAng, (vec2_t *)&pp->posx);
// THIS WAS CAUSING PROLEMS!!!!
// Sectors are still being manipulated so you can end up in a void (-1) sector
@ -1675,7 +1675,8 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
void
MovePoints(SECTOR_OBJECTp sop, short delta_ang, int nx, int ny)
{
int j, k, c, rx, ry;
int j, k, c;
vec2_t rxy;
short startwall, endwall, save_ang, pnum;
PLAYERp pp;
SECTORp *sectp;
@ -1741,16 +1742,16 @@ MovePoints(SECTOR_OBJECTp sop, short delta_ang, int nx, int ny)
if (TEST(wp->extra, WALLFX_LOOP_SPIN_4X))
rot_ang = NORM_ANGLE(rot_ang * 4);
rotatepoint(sop->xmid, sop->ymid, wp->x, wp->y, rot_ang, &rx, &ry);
rotatepoint(*(vec2_t *)&sop->xmid, *(vec2_t *)&wp->x, rot_ang, &rxy);
if (wp->extra && TEST(wp->extra, WALLFX_LOOP_OUTER))
{
dragpoint(k, rx, ry, 0);
dragpoint(k, rxy.x, rxy.y, 0);
}
else
{
wp->x = rx;
wp->y = ry;
wp->x = rxy.x;
wp->y = rxy.y;
}
}
@ -1853,12 +1854,12 @@ PlayerPart:
if (TEST(wall[sector[sp->sectnum].wallptr].extra, WALLFX_LOOP_REVERSE_SPIN))
{
rotatepoint(sop->xmid, sop->ymid, sp->x, sp->y, -delta_ang, &sp->x, &sp->y);
rotatepoint(*(vec2_t *)&sop->xmid, *(vec2_t *)&sp->x, -delta_ang, (vec2_t *)&sp->x);
sp->ang = NORM_ANGLE(sp->ang - delta_ang);
}
else
{
rotatepoint(sop->xmid, sop->ymid, sp->x, sp->y, delta_ang, &sp->x, &sp->y);
rotatepoint(*(vec2_t *)&sop->xmid, *(vec2_t *)&sp->x, delta_ang, (vec2_t *)&sp->x);
sp->ang = NORM_ANGLE(sp->ang + delta_ang);
}
@ -1868,7 +1869,7 @@ PlayerPart:
if (!TEST(sop->flags, SOBJ_DONT_ROTATE))
{
// NOT part of a sector - independant of any sector
rotatepoint(sop->xmid, sop->ymid, sp->x, sp->y, delta_ang, &sp->x, &sp->y);
rotatepoint(*(vec2_t *)&sop->xmid, *(vec2_t *)&sp->x, delta_ang, (vec2_t *)&sp->x);
sp->ang = NORM_ANGLE(sp->ang + delta_ang);
}

View file

@ -2041,7 +2041,7 @@ void analyzesprites(int dax, int day)
void tagcode(void)
{
int i, /*nexti,*/ j, k, l, s, dax, day, /*daz, dax2, day2,*/ cnt, good;
int i, /*nexti,*/ j, k, l, s, /*daz, dax2, day2,*/ cnt, good;
short startwall, endwall, dasector, p, oldang;
for (p=connecthead; p>=0; p=connectpoint2[p])
@ -2165,7 +2165,11 @@ void tagcode(void)
if (swingang[i] == swingangopen[i]) swinganginc[i] = 0;
}
for (k=1; k<=3; k++)
rotatepoint(swingx[i][0],swingy[i][0],swingx[i][k],swingy[i][k],swingang[i],&wall[swingwall[i][k]].x,&wall[swingwall[i][k]].y);
{
vec2_t const pivot = { swingx[i][0], swingy[i][0] };
vec2_t const p = { swingx[i][k], swingy[i][k] };
rotatepoint(pivot, p, swingang[i], (vec2_t *)&wall[swingwall[i][k]].x);
}
if (swinganginc[i] != 0)
{
@ -2197,7 +2201,11 @@ void tagcode(void)
swingang[i] = ((swingang[i]-swinganginc[i])&2047);
}
for (k=1; k<=3; k++)
rotatepoint(swingx[i][0],swingy[i][0],swingx[i][k],swingy[i][k],swingang[i],&wall[swingwall[i][k]].x,&wall[swingwall[i][k]].y);
{
vec2_t const pivot = { swingx[i][0], swingy[i][0] };
vec2_t const p = { swingx[i][k], swingy[i][k] };
rotatepoint(pivot, p, swingang[i], (vec2_t *)&wall[swingwall[i][k]].x);
}
if (swingang[i] == swingangclosed[i])
{
wsayfollow("closdoor.wav",4096L+(krand()&511)-256,256L,&swingx[i][0],&swingy[i][0],0);
@ -2232,8 +2240,11 @@ void tagcode(void)
revolveang[i] = ((revolveang[i]-(TICSPERFRAME<<2))&2047);
for (k=startwall; k<endwall; k++)
{
rotatepoint(revolvepivotx[i],revolvepivoty[i],revolvex[i][k-startwall],revolvey[i][k-startwall],revolveang[i],&dax,&day);
dragpoint(k,dax,day,0);
vec2_t const pivot = { revolvepivotx[i], revolvepivoty[i] };
vec2_t const p = { revolvex[i][k-startwall], revolvey[i][k-startwall] };
vec2_t daxy;
rotatepoint(pivot, p, revolveang[i], &daxy);
dragpoint(k,daxy.x,daxy.y,0);
}
}