- use ToVector where appropriate

This commit is contained in:
Christoph Oelckers 2022-08-29 22:59:44 +02:00
parent 0c757ff96a
commit cceecb4ab6
9 changed files with 16 additions and 23 deletions

View file

@ -103,8 +103,7 @@ tspritetype* viewInsertTSprite(tspriteArray& tsprites, sectortype* pSector, int
pTSprite->ownerActor = parentTSprite->ownerActor;
pTSprite->angle = parentTSprite->angle;
}
pos.X += gCameraAng.Cos() * 2;
pos.Y += gCameraAng.Sin() * 2;
pos.XY() += gCameraAng.ToVector() * 2;
pTSprite->pos = pos;
return pTSprite;
}

View file

@ -790,8 +790,7 @@ void movecrane(DDukeActor *actor, int crane)
{
auto ang = ps[p].angle.ang;
ps[p].backupxyz();
ps[p].pos.X = actor->spr.pos.X - CRANE_STEP * ang.Cos();
ps[p].pos.Y = actor->spr.pos.Y - CRANE_STEP * ang.Sin();
ps[p].pos.XY() = actor->spr.pos.XY() - CRANE_STEP * ang.ToVector();
ps[p].pos.Z = actor->spr.pos.Z + 2;
SetActor(ps[p].GetActor(), ps[p].pos);
ps[p].setCursector(ps[p].GetActor()->sector());
@ -4244,7 +4243,7 @@ void handle_se26(DDukeActor* actor)
double zvel = actor->spr.zvel * zinttoworld;
actor->spr.xvel = 32;
DVector2 vect = { 2 * actor->spr.angle.Cos(), 2 * actor->spr.angle.Sin() }; // was: (32 * bsin) >> 14
DVector2 vect = 2 * actor->spr.angle.ToVector(); // was: (32 * bsin) >> 14
actor->spr.shade++;
if (actor->spr.shade > 7)

View file

@ -872,7 +872,7 @@ static void movetripbomb(DDukeActor *actor)
actor->spr.angle = actor->temp_angle;
actor->temp_data[3] = actor->int_pos().X; actor->temp_data[4] = actor->int_pos().Y;
actor->spr.pos += actor->temp_angle.ToVector(2);
actor->spr.pos += actor->temp_angle.ToVector() * 2;
actor->spr.pos.Z -= 3;
// Laser fix from EDuke32.
@ -908,7 +908,7 @@ static void movetripbomb(DDukeActor *actor)
}
x -= 1024;
actor->spr.pos += actor->temp_angle.ToVector(64);
actor->spr.pos += actor->temp_angle.ToVector() * 64;
updatesectorneighbor(actor->spr.pos, &curSect, 128);
if (curSect == nullptr)
@ -941,7 +941,7 @@ static void movetripbomb(DDukeActor *actor)
actor->temp_data[3] = actor->int_pos().X;
actor->temp_data[4] = actor->int_pos().Y;
actor->spr.pos += actor->temp_angle.ToVector(2);
actor->spr.pos += actor->temp_angle.ToVector() * 2;
actor->spr.pos.Z -= 3;
SetActor(actor, actor->spr.pos);
@ -2222,8 +2222,7 @@ static void greenslime(DDukeActor *actor)
actor->spr.xrepeat = 20 + bsin(actor->temp_data[1], -13);
actor->spr.yrepeat = 15 + bsin(actor->temp_data[1], -13);
actor->spr.pos.X = ps[p].pos.X + ps[p].angle.ang.Cos() * 8;
actor->spr.pos.Y = ps[p].pos.Y + ps[p].angle.ang.Sin() * 8;
actor->spr.pos.XY() = ps[p].pos.XY() + ps[p].angle.ang.ToVector() * 8;
return;
}

View file

@ -221,8 +221,7 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat
else
{
t->angle = VecToAngle(viewVec - t->pos.XY());
t->pos.X = OwnerAc->spr.pos.X + t->angle.Cos();
t->pos.Y = OwnerAc->spr.pos.Y + t->angle.Sin();
t->pos.XY() = OwnerAc->spr.pos.XY() + t->angle.ToVector();
}
}
break;
@ -597,8 +596,7 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat
{
// Alter the shadow's position so that it appears behind the sprite itself.
auto look = VecToAngle(shadowspr->pos.XY() - ps[screenpeek].pos.XY());
shadowspr->pos.X += look.Cos() * 2;
shadowspr->pos.Y += look.Sin() * 2;
shadowspr->pos.XY() += look.ToVector() * 2;
}
}
}

View file

@ -215,8 +215,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat
else
{
t->angle = VecToAngle(viewVec - t->pos.XY());
t->pos.X = OwnerAc->spr.pos.X + t->angle.Cos();
t->pos.Y = OwnerAc->spr.pos.Y + t->angle.Sin();
t->pos.XY() = OwnerAc->spr.pos.XY() + t->angle.ToVector();
}
}
break;
@ -752,8 +751,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat
{
// Alter the shadow's position so that it appears behind the sprite itself.
auto look = VecToAngle(shadowspr->pos.XY() - ps[screenpeek].pos.XY());
shadowspr->pos.X += look.Cos() * 2;
shadowspr->pos.Y += look.Sin() * 2;
shadowspr->pos.XY() += look.ToVector() * 2;
}
}
}

View file

@ -921,12 +921,12 @@ void checkplayerhurt_d(player_struct* p, const Collision& coll)
p->vel.Y = -p->angle.ang.Sin() * (1 << 22);
S_PlayActorSound(DUKE_LONGTERM_PAIN, p->GetActor());
fi.checkhitwall(p->GetActor(), wal, p->pos + DVector2(p->angle.ang.Cos() * 2, p->angle.ang.Sin() * 2), -1);
fi.checkhitwall(p->GetActor(), wal, p->pos + p->angle.ang.ToVector() * 2, -1);
break;
case BIGFORCE:
p->hurt_delay = 26;
fi.checkhitwall(p->GetActor(), wal, p->pos + DVector2(p->angle.ang.Cos() * 2, p->angle.ang.Sin() * 2), -1);
fi.checkhitwall(p->GetActor(), wal, p->pos + p->angle.ang.ToVector() * 2, -1);
break;
}

View file

@ -1412,7 +1412,7 @@ void checkplayerhurt_r(player_struct* p, const Collision &coll)
{
case BIGFORCE:
p->hurt_delay = 26;
fi.checkhitwall(p->GetActor(), wal, p->pos + DVector2(p->angle.ang.Cos() * 2, p->angle.ang.Sin() * 2), -1);
fi.checkhitwall(p->GetActor(), wal, p->pos + p->angle.ang.ToVector() * 2, -1);
break;
}

View file

@ -447,7 +447,7 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell)
act->spr.pos.Z = actj->spr.pos.Z - gs.playerheight + 3;
}
act->spr.pos.XY() = actj->spr.pos.XY() + ang.ToVector(8);
act->spr.pos.XY() = actj->spr.pos.XY() + ang.ToVector() * 8;
act->spr.shade = -8;

View file

@ -413,7 +413,7 @@ int DoActorDebris(DSWActor* actor)
else
{
// todo: check correctness
DVector2 nvec(ACTORMOVETICS * maptoworld * actor->spr.angle.Cos(), ACTORMOVETICS * maptoworld * actor->spr.angle.Sin());
DVector2 nvec = ACTORMOVETICS * maptoworld * actor->spr.angle.ToVector();
if (!move_debris(actor, nvec))
{