- floatified ScaleRandomPoint

This commit is contained in:
Christoph Oelckers 2022-09-03 22:32:29 +02:00
parent caa41e312d
commit 09104ba6fe
4 changed files with 24 additions and 22 deletions

View file

@ -1952,7 +1952,7 @@ void SOBJ_AlignFloorToPoint(SECTOR_OBJECT* sop, const DVector3& pos); // morph.
void ScaleSectorObject(SECTOR_OBJECT* sop); // morph.c
void MorphTornado(SECTOR_OBJECT* sop); // morph.c
void MorphFloor(SECTOR_OBJECT* sop); // morph.c
void ScaleRandomPoint(SECTOR_OBJECT* sop,short k,short ang,int x,int y,int *dx,int *dy); // morph.c
DVector2 ScaleRandomPoint(SECTOR_OBJECT* sop, short k, DAngle ang, const DVector2& pos); // morph.c
void CopySectorMatch(int match); // copysect.c

View file

@ -251,9 +251,9 @@ void ScaleSectorObject(SECTOR_OBJECT* sop)
}
}
void ScaleRandomPoint(SECTOR_OBJECT* sop, short k, short ang, int x, int y, int *dx, int *dy)
DVector2 ScaleRandomPoint(SECTOR_OBJECT* sop, short k, DAngle ang, const DVector2& pos)
{
int xmul,ymul;
int xmul, ymul;
sop->scale_point_dist[k] += sop->scale_point_speed[k];
if (sop->scale_point_dist[k] > sop->scale_point_dist_max)
@ -273,19 +273,23 @@ void ScaleRandomPoint(SECTOR_OBJECT* sop, short k, short ang, int x, int y, int
}
// change up speed at random
if (RANDOM_P2(1024) < (sop->scale_point_rand_freq/2))
if (RANDOM_P2(1024) < (sop->scale_point_rand_freq / 2))
{
//sop->scale_point_speed[k] = SCALE_POINT_SPEED;
short half = sop->scale_point_base_speed/2;
short quart = sop->scale_point_base_speed/4;
short half = sop->scale_point_base_speed / 2;
short quart = sop->scale_point_base_speed / 4;
sop->scale_point_speed[k] = sop->scale_point_base_speed + (RandomRange(half) - quart);
}
xmul = (sop->scale_point_dist[k] * sop->scale_x_mult)>>8;
ymul = (sop->scale_point_dist[k] * sop->scale_y_mult)>>8;
xmul = (sop->scale_point_dist[k] * sop->scale_x_mult) >> 8;
ymul = (sop->scale_point_dist[k] * sop->scale_y_mult) >> 8;
DVector2 mul(xmul / 16., ymul / 16.);
*dx = x + MulScale(xmul, bcos(ang), 14);
*dy = y + MulScale(ymul, bsin(ang), 14);
DVector2 ret;
ret.X = pos.X + mul.X * ang.Cos();
ret.Y = pos.Y + mul.Y * ang.Sin();
return ret;
}
//

View file

@ -5010,7 +5010,7 @@ void DoPlayerStopOperate(PLAYER* pp)
if (TEST_BOOL1(rsp))
pp->angle.ang = pp->angle.oang = rsp->spr.angle;
else
pp->angle.ang = pp->angle.oang = VecToAngle(pp->sop_remote->int_pmid().X - pp->int_ppos().X, pp->sop_remote->int_pmid().Y - pp->int_ppos().Y);
pp->angle.ang = pp->angle.oang = VecToAngle(pp->sop_remote->pmid.XY() - pp->pos.XY());
}
if (pp->sop_control)

View file

@ -1760,8 +1760,6 @@ PlayerPart:
void RefreshPoints(SECTOR_OBJECT* sop, int nx, int ny, bool dynamic)
{
short wallcount = 0, delta_ang_from_orig;
short ang;
int dx,dy,x,y;
// do scaling
if (dynamic && sop->PreMoveAnimator)
@ -1778,39 +1776,39 @@ void RefreshPoints(SECTOR_OBJECT* sop, int nx, int ny, bool dynamic)
{
if (!(wal.extra && (wal.extra & WALLFX_DONT_MOVE)))
{
dx = x = sop->int_pmid().X - sop->orig[wallcount].X * worldtoint;
dy = y = sop->int_pmid().Y - sop->orig[wallcount].Y * worldtoint;
DVector2 pos = sop->pmid.XY() - sop->orig[wallcount];
DVector2 dpos = pos;
if (dynamic && sop->scale_type)
{
if (!(wal.extra & WALLFX_DONT_SCALE))
{
ang = NORM_ANGLE(getangle(x - sop->int_pmid().X, y - sop->int_pmid().Y));
auto ang = VecToAngle(pos - sop->pmid);
if (sop->scale_type == SO_SCALE_RANDOM_POINT)
{
// was causing memory overwrites
//ScaleRandomPoint(sop, k, ang, x, y, &dx, &dy);
ScaleRandomPoint(sop, wallcount, ang, x, y, &dx, &dy);
dpos = ScaleRandomPoint(sop, wallcount, ang, pos);
}
else
{
int xmul = int(sop->scale_dist * sop->scale_x_mult)>>4;
int ymul = int(sop->scale_dist * sop->scale_y_mult)>>4;
DVector2 mul(xmul / 16., ymul / 16.);
dx = x + MulScale(xmul, bcos(ang), 14);
dy = y + MulScale(ymul, bsin(ang), 14);
dpos.X = pos.X + mul.X * ang.Cos();
dpos.Y = pos.Y + mul.Y * ang.Sin();
}
}
}
if (wal.extra & WALLFX_LOOP_OUTER)
{
dragpoint(&wal, dx, dy);
dragpoint(&wal, dpos);
}
else
{
wal.movexy(dx, dy);
wal.move(dpos);
}
}