Remove diffx/y/z from polywaypoint_t, since they're always 0 anyway
This commit is contained in:
parent
aa16bd22f9
commit
b561ee7921
|
@ -1573,7 +1573,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
||||||
{
|
{
|
||||||
mobj_t *target = NULL;
|
mobj_t *target = NULL;
|
||||||
mobj_t *waypoint = NULL;
|
mobj_t *waypoint = NULL;
|
||||||
fixed_t adjustx, adjusty, adjustz;
|
fixed_t pox, poy, poz;
|
||||||
fixed_t momx, momy, momz, dist;
|
fixed_t momx, momy, momz, dist;
|
||||||
INT32 start;
|
INT32 start;
|
||||||
polyobj_t *po = Polyobj_GetForNum(th->polyObjNum);
|
polyobj_t *po = Polyobj_GetForNum(th->polyObjNum);
|
||||||
|
@ -1602,32 +1602,31 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compensate for position offset
|
pox = po->centerPt.x;
|
||||||
adjustx = po->centerPt.x + th->diffx;
|
poy = po->centerPt.y;
|
||||||
adjusty = po->centerPt.y + th->diffy;
|
poz = (po->lines[0]->backsector->floorheight + po->lines[0]->backsector->ceilingheight)/2;
|
||||||
adjustz = po->lines[0]->backsector->floorheight + (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2 + th->diffz;
|
|
||||||
|
|
||||||
dist = P_AproxDistance(P_AproxDistance(target->x - adjustx, target->y - adjusty), target->z - adjustz);
|
dist = P_AproxDistance(P_AproxDistance(target->x - pox, target->y - poy), target->z - poz);
|
||||||
|
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
dist = 1;
|
dist = 1;
|
||||||
|
|
||||||
momx = FixedMul(FixedDiv(target->x - adjustx, dist), (th->speed));
|
momx = FixedMul(FixedDiv(target->x - pox, dist), th->speed);
|
||||||
momy = FixedMul(FixedDiv(target->y - adjusty, dist), (th->speed));
|
momy = FixedMul(FixedDiv(target->y - poy, dist), th->speed);
|
||||||
momz = FixedMul(FixedDiv(target->z - adjustz, dist), (th->speed));
|
momz = FixedMul(FixedDiv(target->z - poz, dist), th->speed);
|
||||||
|
|
||||||
// Calculate the distance between the polyobject and the waypoint
|
// Calculate the distance between the polyobject and the waypoint
|
||||||
// 'dist' already equals this.
|
// 'dist' already equals this.
|
||||||
|
|
||||||
// Will the polyobject be FURTHER away if the momx/momy/momz is added to
|
// Will the polyobject be FURTHER away if the momx/momy/momz is added to
|
||||||
// its current coordinates, or closer? (shift down to fracunits to avoid approximation errors)
|
// its current coordinates, or closer? (shift down to fracunits to avoid approximation errors)
|
||||||
if (dist>>FRACBITS <= P_AproxDistance(P_AproxDistance(target->x - adjustx - momx, target->y - adjusty - momy), target->z - adjustz - momz)>>FRACBITS)
|
if (dist>>FRACBITS <= P_AproxDistance(P_AproxDistance(target->x - pox - momx, target->y - poy - momy), target->z - poz - momz)>>FRACBITS)
|
||||||
{
|
{
|
||||||
// If further away, set XYZ of polyobject to waypoint location
|
// If further away, set XYZ of polyobject to waypoint location
|
||||||
fixed_t amtx, amty, amtz;
|
fixed_t amtx, amty, amtz;
|
||||||
fixed_t diffz;
|
fixed_t diffz;
|
||||||
amtx = (target->x - th->diffx) - po->centerPt.x;
|
amtx = target->x - po->centerPt.x;
|
||||||
amty = (target->y - th->diffy) - po->centerPt.y;
|
amty = target->y - po->centerPt.y;
|
||||||
Polyobj_moveXY(po, amtx, amty, true);
|
Polyobj_moveXY(po, amtx, amty, true);
|
||||||
// TODO: use T_MovePlane
|
// TODO: use T_MovePlane
|
||||||
amtz = (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2;
|
amtz = (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2;
|
||||||
|
@ -1694,14 +1693,14 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
||||||
|
|
||||||
// calculate MOMX/MOMY/MOMZ for next waypoint
|
// calculate MOMX/MOMY/MOMZ for next waypoint
|
||||||
// change slope
|
// change slope
|
||||||
dist = P_AproxDistance(P_AproxDistance(target->x - adjustx, target->y - adjusty), target->z - adjustz);
|
dist = P_AproxDistance(P_AproxDistance(target->x - pox, target->y - poy), target->z - poz);
|
||||||
|
|
||||||
if (dist < 1)
|
if (dist < 1)
|
||||||
dist = 1;
|
dist = 1;
|
||||||
|
|
||||||
momx = FixedMul(FixedDiv(target->x - adjustx, dist), (th->speed));
|
momx = FixedMul(FixedDiv(target->x - pox, dist), th->speed);
|
||||||
momy = FixedMul(FixedDiv(target->y - adjusty, dist), (th->speed));
|
momy = FixedMul(FixedDiv(target->y - poy, dist), th->speed);
|
||||||
momz = FixedMul(FixedDiv(target->z - adjustz, dist), (th->speed));
|
momz = FixedMul(FixedDiv(target->z - poz, dist), th->speed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2215,12 +2214,6 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
|
||||||
if (!last)
|
if (!last)
|
||||||
last = first;
|
last = first;
|
||||||
|
|
||||||
// Set diffx, diffy, diffz
|
|
||||||
// Put these at 0 for now...might not be needed after all.
|
|
||||||
th->diffx = 0;//first->x - po->centerPt.x;
|
|
||||||
th->diffy = 0;//first->y - po->centerPt.y;
|
|
||||||
th->diffz = 0;//first->z - (po->lines[0]->backsector->floorheight + (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2);
|
|
||||||
|
|
||||||
if (last->x == po->centerPt.x
|
if (last->x == po->centerPt.x
|
||||||
&& last->y == po->centerPt.y
|
&& last->y == po->centerPt.y
|
||||||
&& last->z == (po->lines[0]->backsector->floorheight + (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2))
|
&& last->z == (po->lines[0]->backsector->floorheight + (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2))
|
||||||
|
|
|
@ -154,11 +154,6 @@ typedef struct polywaypoint_s
|
||||||
UINT8 continuous; // continuously move - used with COMEBACK or WRAP
|
UINT8 continuous; // continuously move - used with COMEBACK or WRAP
|
||||||
UINT8 stophere; // Will stop after it reaches the next waypoint
|
UINT8 stophere; // Will stop after it reaches the next waypoint
|
||||||
|
|
||||||
// Difference between location of PO and location of waypoint (offset)
|
|
||||||
fixed_t diffx;
|
|
||||||
fixed_t diffy;
|
|
||||||
fixed_t diffz;
|
|
||||||
|
|
||||||
mobj_t *target; // next waypoint mobj
|
mobj_t *target; // next waypoint mobj
|
||||||
} polywaypoint_t;
|
} polywaypoint_t;
|
||||||
|
|
||||||
|
|
|
@ -2023,9 +2023,6 @@ static void SavePolywaypointThinker(const thinker_t *th, UINT8 type)
|
||||||
WRITEUINT8(save_p, ht->wrap);
|
WRITEUINT8(save_p, ht->wrap);
|
||||||
WRITEUINT8(save_p, ht->continuous);
|
WRITEUINT8(save_p, ht->continuous);
|
||||||
WRITEUINT8(save_p, ht->stophere);
|
WRITEUINT8(save_p, ht->stophere);
|
||||||
WRITEFIXED(save_p, ht->diffx);
|
|
||||||
WRITEFIXED(save_p, ht->diffy);
|
|
||||||
WRITEFIXED(save_p, ht->diffz);
|
|
||||||
WRITEUINT32(save_p, SaveMobjnum(ht->target));
|
WRITEUINT32(save_p, SaveMobjnum(ht->target));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3168,9 +3165,6 @@ static inline thinker_t* LoadPolywaypointThinker(actionf_p1 thinker)
|
||||||
ht->wrap = READUINT8(save_p);
|
ht->wrap = READUINT8(save_p);
|
||||||
ht->continuous = READUINT8(save_p);
|
ht->continuous = READUINT8(save_p);
|
||||||
ht->stophere = READUINT8(save_p);
|
ht->stophere = READUINT8(save_p);
|
||||||
ht->diffx = READFIXED(save_p);
|
|
||||||
ht->diffy = READFIXED(save_p);
|
|
||||||
ht->diffz = READFIXED(save_p);
|
|
||||||
ht->target = LoadMobj(READUINT32(save_p));
|
ht->target = LoadMobj(READUINT32(save_p));
|
||||||
return &ht->thinker;
|
return &ht->thinker;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue