mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-23 23:50:40 +00:00
KenBuild, SW: rotatepoint
git-svn-id: https://svn.eduke32.com/eduke32@5738 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
8be6da168f
commit
c0b9c3a189
5 changed files with 43 additions and 32 deletions
|
@ -1833,23 +1833,21 @@ void DrawCrosshair(PLAYERp pp)
|
||||||
{
|
{
|
||||||
SPRITEp hp = &sprite[hit_sprite];
|
SPRITEp hp = &sprite[hit_sprite];
|
||||||
USERp hu = User[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
|
// Find the delta coordinates from player to monster that is targeted
|
||||||
dx = hp->x - pp->posx;
|
vec2_t dxy = { hp->x - pp->posx, hp->y - pp->posy };
|
||||||
dy = hp->y - pp->posy;
|
int dz = ((hp->z - (SPRITE_SIZE_Z(hit_sprite)/2)) - pp->posz) >> 4;
|
||||||
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);
|
wdx = windowx1 + ((windowx2-windowx1)/2);
|
||||||
wdy = windowy1 + ((windowy2-windowy1)/2);
|
wdy = windowy1 + ((windowy2-windowy1)/2);
|
||||||
|
|
||||||
x = (dy * wdx << 8) / dx + (wdx << 8);
|
x = (dxy.y * wdx << 8) / dxy.x + (wdx << 8);
|
||||||
y = (dz * wdx << 8) / dx + (wdy << 8);
|
y = (dz * wdx << 8) / dxy.x + (wdy << 8);
|
||||||
|
|
||||||
y -= 100;
|
y -= 100;
|
||||||
y += (pp->horiz*wdx)/160;
|
y += (pp->horiz*wdx)/160;
|
||||||
|
|
|
@ -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)
|
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;
|
SECTOR_OBJECTp sop = pp->sop;
|
||||||
int ret;
|
int ret;
|
||||||
short ang;
|
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);
|
rot_ang = NORM_ANGLE(new_ang + sop->spin_ang - sop->ang_orig);
|
||||||
for (i = 0; i < 4; i++)
|
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
|
// 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]
|
//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
|
// move to new pos
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
qx[i] = x[i];
|
qx[i] = xy[i].x;
|
||||||
qy[i] = y[i];
|
qy[i] = xy[i].y;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,7 @@ int DoRotatorMove(short SpriteNum)
|
||||||
short ndx,w,startwall,endwall;
|
short ndx,w,startwall,endwall;
|
||||||
SPRITEp pivot = NULL;
|
SPRITEp pivot = NULL;
|
||||||
int i, nexti;
|
int i, nexti;
|
||||||
int nx,ny;
|
vec2_t nxy;
|
||||||
int dist,closest;
|
int dist,closest;
|
||||||
SWBOOL kill = FALSE;
|
SWBOOL kill = FALSE;
|
||||||
|
|
||||||
|
@ -408,9 +408,8 @@ int DoRotatorMove(short SpriteNum)
|
||||||
// move points
|
// move points
|
||||||
for (w = startwall, ndx = 0; w <= endwall; w++)
|
for (w = startwall, ndx = 0; w <= endwall; w++)
|
||||||
{
|
{
|
||||||
rotatepoint(pivot->x, pivot->y,
|
vec2_t const orig = { r->origx[ndx], r->origy[ndx] };
|
||||||
r->origx[ndx], r->origy[ndx],
|
rotatepoint(*(vec2_t *)&pivot->x, orig, r->pos, &nxy);
|
||||||
r->pos, &nx, &ny);
|
|
||||||
|
|
||||||
dragpoint(w, nx, ny, 0);
|
dragpoint(w, nx, ny, 0);
|
||||||
ndx++;
|
ndx++;
|
||||||
|
|
|
@ -1659,7 +1659,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
|
||||||
// increment Players delta angle
|
// increment Players delta angle
|
||||||
pp->RevolveDeltaAng = NORM_ANGLE(pp->RevolveDeltaAng + GlobSpeedSO);
|
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!!!!
|
// THIS WAS CAUSING PROLEMS!!!!
|
||||||
// Sectors are still being manipulated so you can end up in a void (-1) sector
|
// 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
|
void
|
||||||
MovePoints(SECTOR_OBJECTp sop, short delta_ang, int nx, int ny)
|
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;
|
short startwall, endwall, save_ang, pnum;
|
||||||
PLAYERp pp;
|
PLAYERp pp;
|
||||||
SECTORp *sectp;
|
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))
|
if (TEST(wp->extra, WALLFX_LOOP_SPIN_4X))
|
||||||
rot_ang = NORM_ANGLE(rot_ang * 4);
|
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))
|
if (wp->extra && TEST(wp->extra, WALLFX_LOOP_OUTER))
|
||||||
{
|
{
|
||||||
dragpoint(k, rx, ry, 0);
|
dragpoint(k, rxy.x, rxy.y, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wp->x = rx;
|
wp->x = rxy.x;
|
||||||
wp->y = ry;
|
wp->y = rxy.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1853,12 +1854,12 @@ PlayerPart:
|
||||||
|
|
||||||
if (TEST(wall[sector[sp->sectnum].wallptr].extra, WALLFX_LOOP_REVERSE_SPIN))
|
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);
|
sp->ang = NORM_ANGLE(sp->ang - delta_ang);
|
||||||
}
|
}
|
||||||
else
|
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);
|
sp->ang = NORM_ANGLE(sp->ang + delta_ang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1868,7 +1869,7 @@ PlayerPart:
|
||||||
if (!TEST(sop->flags, SOBJ_DONT_ROTATE))
|
if (!TEST(sop->flags, SOBJ_DONT_ROTATE))
|
||||||
{
|
{
|
||||||
// NOT part of a sector - independant of any sector
|
// 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);
|
sp->ang = NORM_ANGLE(sp->ang + delta_ang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2041,7 +2041,7 @@ void analyzesprites(int dax, int day)
|
||||||
|
|
||||||
void tagcode(void)
|
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;
|
short startwall, endwall, dasector, p, oldang;
|
||||||
|
|
||||||
for (p=connecthead; p>=0; p=connectpoint2[p])
|
for (p=connecthead; p>=0; p=connectpoint2[p])
|
||||||
|
@ -2165,7 +2165,11 @@ void tagcode(void)
|
||||||
if (swingang[i] == swingangopen[i]) swinganginc[i] = 0;
|
if (swingang[i] == swingangopen[i]) swinganginc[i] = 0;
|
||||||
}
|
}
|
||||||
for (k=1; k<=3; k++)
|
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)
|
if (swinganginc[i] != 0)
|
||||||
{
|
{
|
||||||
|
@ -2197,7 +2201,11 @@ void tagcode(void)
|
||||||
swingang[i] = ((swingang[i]-swinganginc[i])&2047);
|
swingang[i] = ((swingang[i]-swinganginc[i])&2047);
|
||||||
}
|
}
|
||||||
for (k=1; k<=3; k++)
|
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])
|
if (swingang[i] == swingangclosed[i])
|
||||||
{
|
{
|
||||||
wsayfollow("closdoor.wav",4096L+(krand()&511)-256,256L,&swingx[i][0],&swingy[i][0],0);
|
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);
|
revolveang[i] = ((revolveang[i]-(TICSPERFRAME<<2))&2047);
|
||||||
for (k=startwall; k<endwall; k++)
|
for (k=startwall; k<endwall; k++)
|
||||||
{
|
{
|
||||||
rotatepoint(revolvepivotx[i],revolvepivoty[i],revolvex[i][k-startwall],revolvey[i][k-startwall],revolveang[i],&dax,&day);
|
vec2_t const pivot = { revolvepivotx[i], revolvepivoty[i] };
|
||||||
dragpoint(k,dax,day,0);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue