mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 12:30:40 +00:00
- floatified clipbox/MultiClip of SW
This commit is contained in:
parent
17b117e86b
commit
d80b39d184
6 changed files with 34 additions and 46 deletions
|
@ -1496,11 +1496,9 @@ struct SECTOR_OBJECT
|
|||
ang, // angle facing
|
||||
ang_moving, // angle the SO is facing
|
||||
clipdist, // cliping distance for operational sector objects
|
||||
clipbox_dist[MAX_CLIPBOX], // mult-clip box variables
|
||||
_clipbox_xoff[MAX_CLIPBOX], // mult-clip box variables
|
||||
_clipbox_yoff[MAX_CLIPBOX], // mult-clip box variables
|
||||
_clipbox_ang[MAX_CLIPBOX], // mult-clip box variables
|
||||
_clipbox_vdist[MAX_CLIPBOX]; // mult-clip box variables
|
||||
clipbox_dist[MAX_CLIPBOX]; // mult-clip box variables (clipdist equivalent)
|
||||
double clipbox_vdist[MAX_CLIPBOX]; // mult-clip box variables
|
||||
DAngle clipbox_ang[MAX_CLIPBOX]; // mult-clip box variables
|
||||
int16_t clipbox_num,
|
||||
ang_tgt, // target angle
|
||||
ang_orig, // original angle
|
||||
|
|
|
@ -39,30 +39,29 @@ BEGIN_SW_NS
|
|||
|
||||
Collision MultiClipMove(PLAYER* pp, int z, int floor_dist)
|
||||
{
|
||||
double zz = z * inttoworld;
|
||||
int i;
|
||||
vec3_t opos[MAX_CLIPBOX], pos[MAX_CLIPBOX];
|
||||
DVector3 opos[MAX_CLIPBOX], pos[MAX_CLIPBOX];
|
||||
SECTOR_OBJECT* sop = pp->sop;
|
||||
short ang;
|
||||
short min_ndx = 0;
|
||||
int min_dist = 999999;
|
||||
int dist;
|
||||
double min_dist = 999999;
|
||||
double dist;
|
||||
|
||||
int ret;
|
||||
Collision min_ret{};
|
||||
|
||||
int xvect,yvect;
|
||||
|
||||
for (i = 0; i < sop->clipbox_num; i++)
|
||||
{
|
||||
// move the box to position instead of using offset- this prevents small rounding errors
|
||||
// allowing you to move through wall
|
||||
ang = NORM_ANGLE(pp->angle.ang.Buildang() + sop->_clipbox_ang[i]);
|
||||
DAngle ang = (pp->angle.ang + sop->clipbox_ang[i]);
|
||||
DVector3 spos(pp->pos, zz);
|
||||
|
||||
vec3_t spos = { pp->int_ppos().X, pp->int_ppos().Y, z };
|
||||
|
||||
xvect = sop->_clipbox_vdist[i] * bcos(ang);
|
||||
yvect = sop->_clipbox_vdist[i] * bsin(ang);
|
||||
DVector2 vect = ang.ToVector() * 1024 * sop->clipbox_vdist[i];
|
||||
Collision coll;
|
||||
|
||||
int xvect = vect.X * 16 * worldtoint; // note: this means clipmove input is Q18.14!
|
||||
int yvect = vect.Y * 16 * worldtoint;
|
||||
clipmove(spos, &pp->cursector, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll, 1);
|
||||
|
||||
if (coll.type != kHitNone)
|
||||
|
@ -71,15 +70,13 @@ Collision MultiClipMove(PLAYER* pp, int z, int floor_dist)
|
|||
min_dist = 0;
|
||||
min_ndx = i;
|
||||
// ox is where it should be
|
||||
opos[i].X = pos[i].X = pp->int_ppos().X + MulScale(sop->_clipbox_vdist[i], bcos(ang), 14);
|
||||
opos[i].Y = pos[i].Y = pp->int_ppos().Y + MulScale(sop->_clipbox_vdist[i], bsin(ang), 14);
|
||||
opos[i].XY() = pp->pos + ang.ToVector() * sop->clipbox_vdist[i];
|
||||
|
||||
// spos.x is where it hit
|
||||
pos[i].X = spos.X;
|
||||
pos[i].Y = spos.Y;
|
||||
pos[i].XY() = spos.XY();
|
||||
|
||||
// see the dist moved
|
||||
dist = ksqrt(SQ(pos[i].X - opos[i].X) + SQ(pos[i].Y - opos[i].Y));
|
||||
dist = (pos[i].XY() - opos[i].XY()).Length();
|
||||
|
||||
// save it off
|
||||
if (dist < min_dist)
|
||||
|
@ -99,7 +96,7 @@ Collision MultiClipMove(PLAYER* pp, int z, int floor_dist)
|
|||
clipmove(pos[i], &pp->cursector, pp->vect.X, pp->vect.Y, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll);
|
||||
|
||||
// save the dist moved
|
||||
dist = ksqrt(SQ(pos[i].X - opos[i].X) + SQ(pos[i].Y - opos[i].Y));
|
||||
dist = (pos[i].XY() - opos[i].XY()).Length();
|
||||
|
||||
if (dist < min_dist)
|
||||
{
|
||||
|
@ -111,33 +108,31 @@ Collision MultiClipMove(PLAYER* pp, int z, int floor_dist)
|
|||
}
|
||||
|
||||
// put posx and y off from offset
|
||||
pp->add_int_ppos_XY({ pos[min_ndx].X - opos[min_ndx].X, pos[min_ndx].Y - opos[min_ndx].Y });
|
||||
pp->pos.XY() += pos[min_ndx].XY() - opos[min_ndx].XY();
|
||||
|
||||
return min_ret;
|
||||
}
|
||||
|
||||
short MultiClipTurn(PLAYER* pp, short new_ang, int z, int floor_dist)
|
||||
short MultiClipTurn(PLAYER* pp, DAngle new_ang, int z, int floor_dist)
|
||||
{
|
||||
double zz = z * inttoworld;
|
||||
int i;
|
||||
SECTOR_OBJECT* sop = pp->sop;
|
||||
int ret;
|
||||
int x,y;
|
||||
short ang;
|
||||
int xvect, yvect;
|
||||
auto cursect = pp->cursector;
|
||||
|
||||
for (i = 0; i < sop->clipbox_num; i++)
|
||||
{
|
||||
ang = NORM_ANGLE(new_ang + sop->_clipbox_ang[i]);
|
||||
DAngle ang = new_ang + sop->clipbox_ang[i];
|
||||
|
||||
vec3_t pos = { pp->int_ppos().X, pp->int_ppos().Y, z };
|
||||
DVector3 spos(pp->pos, zz);
|
||||
|
||||
xvect = sop->_clipbox_vdist[i] * bcos(ang);
|
||||
yvect = sop->_clipbox_vdist[i] * bsin(ang);
|
||||
|
||||
// move the box
|
||||
DVector2 vect = ang.ToVector() * 1024 * sop->clipbox_vdist[i];
|
||||
Collision coll;
|
||||
clipmove(pos, &cursect, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll);
|
||||
|
||||
int xvect = vect.X * 16 * worldtoint; // note: this means clipmove input is Q18.14!
|
||||
int yvect = vect.Y * 16 * worldtoint;
|
||||
clipmove(spos, &cursect, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll);
|
||||
|
||||
ASSERT(cursect);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ BEGIN_SW_NS
|
|||
#define RECT_CLIP 1
|
||||
|
||||
Collision MultiClipMove(PLAYER* pp, int z, int floor_dist);
|
||||
short MultiClipTurn(PLAYER* pp, short new_ang, int z, int floor_dist);
|
||||
short MultiClipTurn(PLAYER* pp, DAngle new_ang, int z, int floor_dist);
|
||||
int RectClipMove(PLAYER* pp, DVector2* qpos);
|
||||
int testpointinquad(const DVector2& pt, const DVector2* quad);
|
||||
//short RectClipTurn(PLAYER* pp, short new_ang, int z, int floor_dist, int *qx, int *qy);
|
||||
|
|
|
@ -1469,7 +1469,7 @@ void DoPlayerTurnVehicle(PLAYER* pp, float avel, int z, int floor_dist)
|
|||
if (avel != 0)
|
||||
{
|
||||
auto sum = pp->angle.ang + DAngle::fromDeg(avel);
|
||||
if (MultiClipTurn(pp, NORM_ANGLE(sum.Buildang()), z, floor_dist))
|
||||
if (MultiClipTurn(pp, sum, z, floor_dist))
|
||||
{
|
||||
pp->angle.ang = sum;
|
||||
pp->actor->set_int_ang(pp->angle.ang.Buildang());
|
||||
|
|
|
@ -684,10 +684,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECT& w,
|
|||
("scale_dist_max", w.scale_dist_max, def->scale_dist_max)
|
||||
("scale_rand_freq", w.scale_rand_freq, def->scale_rand_freq)
|
||||
.Array("clipbox_dist", w.clipbox_dist, def->clipbox_dist, w.clipbox_num)
|
||||
.Array("clipbox_xoff", w._clipbox_xoff, def->_clipbox_xoff, w.clipbox_num)
|
||||
.Array("clipbox_yoff", w._clipbox_yoff, def->_clipbox_yoff, w.clipbox_num)
|
||||
.Array("clipbox_ang", w._clipbox_ang, def->_clipbox_ang, w.clipbox_num)
|
||||
.Array("clipbox_vdist", w._clipbox_vdist, def->_clipbox_vdist, w.clipbox_num)
|
||||
.Array("clipbox_ang", w.clipbox_ang, def->clipbox_ang, w.clipbox_num)
|
||||
.Array("clipbox_vdist", w.clipbox_vdist, def->clipbox_vdist, w.clipbox_num)
|
||||
.Array("scale_point_dist", w.scale_point_dist, def->scale_point_dist, MAX_SO_POINTS)
|
||||
.Array("scale_point_speed", w.scale_point_speed, def->scale_point_speed, MAX_SO_POINTS)
|
||||
("scale_point_base_speed", w.scale_point_base_speed, def->scale_point_base_speed)
|
||||
|
|
|
@ -803,16 +803,13 @@ void SectorObjectSetupBounds(SECTOR_OBJECT* sop)
|
|||
{
|
||||
case SO_CLIP_BOX:
|
||||
{
|
||||
short ang2;
|
||||
sop->clipdist = 0;
|
||||
sop->clipbox_dist[sop->clipbox_num] = itActor->spr.lotag;
|
||||
sop->_clipbox_xoff[sop->clipbox_num] = sop->int_pmid().X - itActor->int_pos().X;
|
||||
sop->_clipbox_yoff[sop->clipbox_num] = sop->int_pmid().Y - itActor->int_pos().Y;
|
||||
|
||||
sop->_clipbox_vdist[sop->clipbox_num] = ksqrt(SQ(sop->int_pmid().X - itActor->int_pos().X) + SQ(sop->int_pmid().Y - itActor->int_pos().Y));
|
||||
sop->clipbox_vdist[sop->clipbox_num] = (sop->pmid.XY() - itActor->spr.pos.XY()).Length();
|
||||
|
||||
ang2 = getangle(itActor->int_pos().X - sop->int_pmid().X, itActor->int_pos().Y - sop->int_pmid().Y);
|
||||
sop->_clipbox_ang[sop->clipbox_num] = getincangle(ang2, sop->ang);
|
||||
auto ang2 = VecToAngle(itActor->spr.pos.XY() - sop->pmid.XY());
|
||||
sop->clipbox_ang[sop->clipbox_num] = deltaangle(ang2, DAngle::fromBuild(sop->ang));
|
||||
|
||||
sop->clipbox_num++;
|
||||
KillActor(itActor);
|
||||
|
|
Loading…
Reference in a new issue