mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-21 19:21:44 +00:00
- added some utilities.
This also had to use explicit types in a few places to clear ambiguities.
This commit is contained in:
parent
312ee075d2
commit
fb4da6bbd4
12 changed files with 63 additions and 21 deletions
|
@ -154,6 +154,11 @@ void neartag(const vec3_t& pos, sectortype* sect, int angle, HitInfoBase& result
|
|||
|
||||
int cansee(int x1, int y1, int z1, sectortype* sect1, int x2, int y2, int z2, sectortype* sect2);
|
||||
|
||||
inline int cansee(const DVector3& start, sectortype* sect1, const DVector3& end, sectortype* sect2)
|
||||
{
|
||||
return cansee(start.X * worldtoint, start.Y * worldtoint, start.Z * zworldtoint, sect1, end.X * worldtoint, end.Y * worldtoint, end.Z * zworldtoint, sect2);
|
||||
}
|
||||
|
||||
int32_t try_facespr_intersect(DCoreActor* spr, vec3_t const in,
|
||||
int32_t vx, int32_t vy, int32_t vz,
|
||||
vec3_t * const intp, int32_t strictly_smaller_than_p);
|
||||
|
|
|
@ -87,7 +87,6 @@ inline double bsinf(const double ang, const int shift = 0)
|
|||
return g_sinbam(ang * BAMUNIT) * sinscale(shift);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Build cosine inline functions.
|
||||
|
@ -103,7 +102,6 @@ inline double bcosf(const double ang, const int shift = 0)
|
|||
return g_cosbam(ang * BAMUNIT) * sinscale(shift);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
|
|
@ -524,6 +524,19 @@ inline void SetActorZ(DCoreActor* actor, const vec3_t& newpos)
|
|||
SetActorZ(actor, &newpos);
|
||||
}
|
||||
|
||||
inline void SetActor(DCoreActor* actor, const DVector3& newpos)
|
||||
{
|
||||
vec3_t ipos = { int(newpos.X * worldtoint), int(newpos.Y * worldtoint), int(newpos.Z * zworldtoint) };
|
||||
SetActor(actor, &ipos);
|
||||
}
|
||||
|
||||
inline void SetActorZ(DCoreActor* actor, const DVector3& newpos)
|
||||
{
|
||||
vec3_t ipos = { int(newpos.X * worldtoint), int(newpos.Y * worldtoint), int(newpos.Z * zworldtoint) };
|
||||
SetActorZ(actor, &ipos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline int clipmove(vec3_t& pos, sectortype** const sect, int xvect, int yvect,
|
||||
int const walldist, int const ceildist, int const flordist, unsigned const cliptype, CollisionBase& result, int clipmoveboxtracenum = 3)
|
||||
|
@ -534,6 +547,16 @@ inline int clipmove(vec3_t& pos, sectortype** const sect, int xvect, int yvect,
|
|||
return result.type;
|
||||
}
|
||||
|
||||
inline int clipmove(DVector3& pos, sectortype** const sect, int xvect, int yvect,
|
||||
int const walldist, int const ceildist, int const flordist, unsigned const cliptype, CollisionBase& result, int clipmoveboxtracenum = 3)
|
||||
{
|
||||
auto vect = vec3_t(pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint);
|
||||
int res = clipmove(vect, sect, xvect, yvect, walldist, ceildist, flordist, cliptype, result, clipmoveboxtracenum);
|
||||
pos = { vect.X * inttoworld, vect.Y * inttoworld, vect.Z * zinttoworld };
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
inline int pushmove(vec3_t* const vect, sectortype** const sect, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
|
||||
uint32_t const cliptype, bool clear = true)
|
||||
{
|
||||
|
@ -543,15 +566,21 @@ inline int pushmove(vec3_t* const vect, sectortype** const sect, int32_t const w
|
|||
return res;
|
||||
}
|
||||
|
||||
inline int pushmove(DVector3& pos, sectortype** const sect, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
|
||||
uint32_t const cliptype, bool clear = true)
|
||||
{
|
||||
auto vect = vec3_t(pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint);
|
||||
int sectno = *sect ? sector.IndexOf(*sect) : -1;
|
||||
int res = pushmove_(&vect, §no, walldist, ceildist, flordist, cliptype, clear);
|
||||
pos = { vect.X * inttoworld, vect.Y * inttoworld, vect.Z * zinttoworld };
|
||||
*sect = sectno == -1 ? nullptr : §or[sectno];
|
||||
return res;
|
||||
}
|
||||
|
||||
inline int pushmove(DCoreActor* actor, sectortype** const sect, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
|
||||
uint32_t const cliptype, bool clear = true)
|
||||
{
|
||||
auto vect = actor->int_pos();
|
||||
int sectno = *sect ? sector.IndexOf(*sect) : -1;
|
||||
int res = pushmove_(&vect, §no, walldist, ceildist, flordist, cliptype, clear);
|
||||
actor->set_int_pos(vect);
|
||||
*sect = sectno == -1 ? nullptr : §or[sectno];
|
||||
return res;
|
||||
return pushmove(actor->spr.pos, sect, walldist, ceildist, flordist, cliptype, clear);
|
||||
}
|
||||
|
||||
tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor);
|
||||
|
|
|
@ -25,6 +25,16 @@ struct PlayerHorizon
|
|||
// Prototypes for functions in gameinput.cpp.
|
||||
void applyinput(float const horz, ESyncBits* actions, double const scaleAdjust = 1);
|
||||
void calcviewpitch(vec2_t const pos, binangle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false);
|
||||
void calcviewpitch(const DVector2& pos, binangle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false)
|
||||
{
|
||||
vec2_t ps = { int(pos.X * worldtoint), int(pos.Y * worldtoint) };
|
||||
calcviewpitch(ps, ang, aimmode, canslopetilt, cursectnum, scaleAdjust, climbing);
|
||||
}
|
||||
void calcviewpitch(const DVector3& pos, binangle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false)
|
||||
{
|
||||
vec2_t ps = { int(pos.X * worldtoint), int(pos.Y * worldtoint) };
|
||||
calcviewpitch(ps, ang, aimmode, canslopetilt, cursectnum, scaleAdjust, climbing);
|
||||
}
|
||||
|
||||
// Interpolation helpers.
|
||||
void backup()
|
||||
|
|
|
@ -643,7 +643,7 @@ void movecrane(DDukeActor *actor, int crane)
|
|||
case STAT_STANDABLE:
|
||||
case STAT_PLAYER:
|
||||
actor->spr.ang = getangle(cpt.pole.X - actor->int_pos().X, cpt.pole.Y - actor->int_pos().Y);
|
||||
SetActor(a2, { cpt.pole.X, cpt.pole.Y, a2->int_pos().Z });
|
||||
SetActor(a2, vec3_t( cpt.pole.X, cpt.pole.Y, a2->int_pos().Z ));
|
||||
actor->temp_data[0]++;
|
||||
return;
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ void movecrane(DDukeActor *actor, int crane)
|
|||
actor->temp_data[0] = 0;
|
||||
|
||||
if (cpt.poleactor)
|
||||
SetActor(cpt.poleactor, { actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (34 << 8) });
|
||||
SetActor(cpt.poleactor, vec3_t( actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (34 << 8) ));
|
||||
|
||||
auto Owner = actor->GetOwner();
|
||||
if (Owner != nullptr || actor->IsActiveCrane())
|
||||
|
@ -4187,7 +4187,7 @@ void handle_se20(DDukeActor* actor)
|
|||
ps[p].__int_opos.X = ps[p].player_int_pos().X;
|
||||
ps[p].__int_opos.Y = ps[p].player_int_pos().Y;
|
||||
|
||||
SetActor(ps[p].GetActor(), { ps[p].player_int_pos().X, ps[p].player_int_pos().Y, ps[p].player_int_pos().Z + gs.int_playerheight });
|
||||
SetActor(ps[p].GetActor(), vec3_t( ps[p].player_int_pos().X, ps[p].player_int_pos().Y, ps[p].player_int_pos().Z + gs.int_playerheight ));
|
||||
}
|
||||
|
||||
sc->addfloorxpan(-x / 8.f);
|
||||
|
|
|
@ -1892,7 +1892,7 @@ void movetransports_d(void)
|
|||
ps[p].setCursector(Owner->sector());
|
||||
|
||||
ChangeActorSect(act2, Owner->sector());
|
||||
SetActor(ps[p].GetActor(), { ps[p].player_int_pos().X, ps[p].player_int_pos().Y, ps[p].player_int_pos().Z + gs.int_playerheight });
|
||||
SetActor(ps[p].GetActor(), vec3_t(ps[p].player_int_pos().X, ps[p].player_int_pos().Y, ps[p].player_int_pos().Z + gs.int_playerheight ));
|
||||
|
||||
if ((krand() & 255) < 32)
|
||||
spawn(act2, WATERSPLASH2);
|
||||
|
@ -2514,12 +2514,12 @@ static void flamethrowerflame(DDukeActor *actor)
|
|||
}
|
||||
else if (coll.type == kHitWall)
|
||||
{
|
||||
SetActor(actor, { dax, day, daz });
|
||||
SetActor(actor, vec3_t( dax, day, daz ));
|
||||
fi.checkhitwall(actor, coll.hitWall, actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z, actor->spr.picnum);
|
||||
}
|
||||
else if (coll.type == kHitSector)
|
||||
{
|
||||
SetActor(actor, { dax, day, daz });
|
||||
SetActor(actor, vec3_t(dax, day, daz));
|
||||
if (actor->spr.zvel < 0)
|
||||
fi.checkhitceiling(actor->sector());
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ void moveminecart(void)
|
|||
while (auto a2 = it.Next())
|
||||
{
|
||||
if (badguy(a2))
|
||||
SetActor(a2, { int(cx * worldtoint), int(cy * worldtoint), a2->int_pos().Z });
|
||||
SetActor(a2, DVector3(cx, cy, a2->spr.pos.Z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1912,7 +1912,7 @@ static void rrra_specialstats()
|
|||
}
|
||||
else if (act->spr.extra == 200)
|
||||
{
|
||||
SetActor(act, { act->int_pos().X, act->int_pos().Y, act->sector()->int_floorz() - 10 });
|
||||
SetActor(act, vec3_t( act->int_pos().X, act->int_pos().Y, act->sector()->int_floorz() - 10 ));
|
||||
act->spr.extra = 1;
|
||||
act->spr.picnum = PIG + 11;
|
||||
spawn(act, TRANSPORTERSTAR);
|
||||
|
@ -2835,7 +2835,7 @@ void moveactors_r(void)
|
|||
getglobalz(act);
|
||||
if (sectp->lotag == 1)
|
||||
{
|
||||
SetActor(act, { act->int_pos().X,act->int_pos().Y,act->actor_int_floorz() + (16 << 8) });
|
||||
SetActor(act, vec3_t( act->int_pos().X,act->int_pos().Y,act->actor_int_floorz() + (16 << 8) ));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ static int ccmd_spawn(CCmdFuncPtr parm)
|
|||
if (set & 1) spawned->spr.pal = (uint8_t)pal;
|
||||
if (set & 2) spawned->spr.cstat = ESpriteFlags::FromInt(cstat);
|
||||
if (set & 4) spawned->spr.ang = ang;
|
||||
if (set & 8) SetActor(spawned, { x, y, z });
|
||||
if (set & 8) SetActor(spawned, DVector3( x, y, z ));
|
||||
|
||||
if (spawned->sector() == nullptr)
|
||||
{
|
||||
|
|
|
@ -2229,7 +2229,7 @@ int ParseState::parse(void)
|
|||
g_ac->set_int_pos({ ps[g_p].bobpos.X = ps[g_p].__int_opos.X = ps[g_p].player_int_pos().X, ps[g_p].bobpos.Y = ps[g_p].__int_opos.Y = ps[g_p].player_int_pos().Y, ps[g_p].__int_opos.Z = ps[g_p].__int_pos.Z });
|
||||
g_ac->backuppos();
|
||||
updatesector(ps[g_p].player_int_pos().X, ps[g_p].player_int_pos().Y, &ps[g_p].cursector);
|
||||
SetActor(ps[g_p].GetActor(), { ps[g_p].player_int_pos().X, ps[g_p].player_int_pos().Y, ps[g_p].player_int_pos().Z + gs.int_playerheight });
|
||||
SetActor(ps[g_p].GetActor(), vec3_t( ps[g_p].player_int_pos().X, ps[g_p].player_int_pos().Y, ps[g_p].player_int_pos().Z + gs.int_playerheight ));
|
||||
g_ac->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
|
||||
|
||||
g_ac->spr.shade = -12;
|
||||
|
|
|
@ -3056,7 +3056,7 @@ HORIZONLY:
|
|||
}
|
||||
|
||||
// RBG***
|
||||
SetActor(pact, { p->player_int_pos().X, p->player_int_pos().Y, p->player_int_pos().Z + gs.int_playerheight });
|
||||
SetActor(pact, vec3_t( p->player_int_pos().X, p->player_int_pos().Y, p->player_int_pos().Z + gs.int_playerheight ));
|
||||
|
||||
if (psectlotag < 3)
|
||||
{
|
||||
|
|
|
@ -3898,7 +3898,7 @@ HORIZONLY:
|
|||
}
|
||||
|
||||
// RBG***
|
||||
SetActor(pact, { p->player_int_pos().X, p->player_int_pos().Y, p->player_int_pos().Z + gs.int_playerheight });
|
||||
SetActor(pact, vec3_t( p->player_int_pos().X, p->player_int_pos().Y, p->player_int_pos().Z + gs.int_playerheight ));
|
||||
|
||||
if (psectlotag == 800 && (!isRRRA() || !p->lotag800kill))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue