- eliminated Blood’s RotatePoint function

This commit is contained in:
Christoph Oelckers 2022-09-02 23:53:50 +02:00
parent 0c146e7ccb
commit a69bdb3370
4 changed files with 17 additions and 18 deletions

View file

@ -5231,9 +5231,9 @@ int MoveMissile(DBloodActor* actor)
int nTargetAngle = getangle(-(target->int_pos().Y - actor->int_pos().Y), target->int_pos().X - actor->int_pos().X); // X and Y are swapped here!
int vx = missileInfo[actor->spr.type - kMissileBase].velocity;
int vy = 0;
RotatePoint(&vx, &vy, (nTargetAngle + 1536) & 2047, 0, 0);
actor->set_int_bvel_x(vx);
actor->set_int_bvel_y(vy);
auto rpt = rotatepoint(DVector2(0,0), DVector2(vx, 0), DAngle::fromBuild(nTargetAngle + 1536));
actor->set_int_bvel_x(rpt.X); // we were rotating an int vector here so scale matches.
actor->set_int_bvel_y(rpt.Y);
int dz = target->int_pos().Z - actor->int_pos().Z;
int deltaz = dz / 10;

View file

@ -70,7 +70,6 @@ int CheckLink(int* x, int* y, int* z, sectortype** pSector);
int GetOctant(int x, int y);
void RotateVector(int* dx, int* dy, int nAngle);
void RotatePoint(int* x, int* y, int nAngle, int ox, int oy);
#include "m_fixed.h"

View file

@ -3133,10 +3133,15 @@ void useVelocityChanger(DBloodActor* actor, sectortype* sect, DBloodActor* initi
if (toAng)
{
if (toAng180)
RotatePoint(&pSprite->__int_vel.X, &pSprite->__int_vel.Y, kAng180, pSprite->int_pos().X, pSprite->int_pos().Y);
else
RotatePoint(&pSprite->__int_vel.X, &pSprite->__int_vel.Y, (nAng - vAng) & 2047, pSprite->int_pos().X, pSprite->int_pos().Y);
DAngle angl;
if (toAng180) angl = DAngle180;
else angl = DAngle::fromBuild(nAng - vAng);
auto velv = pSprite->fVel().XY();
auto pt = rotatepoint(pSprite->spr.pos.XY(), velv, angl);
//actor->vel.XY() = pt;
pSprite->set_int_bvel_x(pt.X * worldtoint);
pSprite->set_int_bvel_y(pt.Y * worldtoint);
vAng = getVelocityAngle(pSprite);
@ -3286,8 +3291,11 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor)
// change movement direction according source angle
if (sourceactor->xspr.data3 & kModernTypeFlag2)
{
int vAng = getVelocityAngle(actor);
RotatePoint(&actor->__int_vel.X, &actor->__int_vel.Y, (sourceactor->spr.int_ang() - vAng) & 2047, actor->int_pos().X, actor->int_pos().Y);
auto velv = actor->fVel().XY();
auto pt = rotatepoint(actor->spr.pos.XY(), velv, sourceactor->spr.angle - VecToAngle(velv));
//actor->vel.XY() = pt;
actor->set_int_bvel_x(pt.X * worldtoint);
actor->set_int_bvel_y(pt.Y * worldtoint);
}
if (sourceactor->xspr.data3 & kModernTypeFlag4)

View file

@ -43,12 +43,4 @@ void RotateVector(int* dx, int* dy, int nAngle)
*dy = dmulscale30r(ox, Sin(nAngle), oy, Cos(nAngle));
}
void RotatePoint(int* x, int* y, int nAngle, int ox, int oy)
{
int dx = *x - ox;
int dy = *y - oy;
*x = ox + dmulscale30r(dx, Cos(nAngle), -dy, Sin(nAngle));
*y = oy + dmulscale30r(dx, Sin(nAngle), dy, Cos(nAngle));
}
END_BLD_NS