mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- floatified SW's sector object morph code.
This commit is contained in:
parent
30104fca50
commit
42246f9a9d
4 changed files with 82 additions and 113 deletions
|
@ -1472,9 +1472,6 @@ struct SECTOR_OBJECT
|
|||
bob_diff, // bobbing difference for the frame
|
||||
floor_loz, // floor low z
|
||||
floor_hiz, // floor hi z
|
||||
_morph_z, // morphing point z
|
||||
_morph_z_min, // morphing point z min
|
||||
_morph_z_max,
|
||||
bob_amt, // bob amount max in z coord
|
||||
// end of must floatify
|
||||
|
||||
|
@ -1486,6 +1483,10 @@ struct SECTOR_OBJECT
|
|||
crush_z,
|
||||
flags;
|
||||
|
||||
double morph_z, // morphing point z
|
||||
morph_z_min, // morphing point z min
|
||||
morph_z_max;
|
||||
|
||||
int16_t xorig[MAX_SO_POINTS], // save the original x & y location of each wall so it can be
|
||||
yorig[MAX_SO_POINTS], // refreshed
|
||||
max_damage, // max damage
|
||||
|
@ -1541,14 +1542,14 @@ struct SECTOR_OBJECT
|
|||
scale_y_mult, // y multiplyer for scaling
|
||||
|
||||
// Used for center point movement
|
||||
_morph_ang, // angle moving from CENTER
|
||||
_morph_speed, // speed of movement
|
||||
_morph_dist_max, // radius boundry
|
||||
morph_rand_freq, // freq of dir change
|
||||
_morph_dist, // dist from CENTER
|
||||
_morph_z_speed, // z speed for morph point
|
||||
_morph_xoff, // save xoff from center
|
||||
_morph_yoff; // save yoff from center
|
||||
morph_rand_freq; // freq of dir change
|
||||
|
||||
DAngle morph_ang; // angle moving from CENTER
|
||||
double morph_speed, // speed of movement
|
||||
morph_dist_max, // radius boundry
|
||||
morph_dist, // dist from CENTER
|
||||
morph_z_speed; // z speed for morph point
|
||||
DVector2 morph_off; // save yoff from center
|
||||
|
||||
//scale_rand_reverse; // random at random interval
|
||||
// limit rotation angle
|
||||
|
|
|
@ -294,80 +294,64 @@ void ScaleRandomPoint(SECTOR_OBJECT* sop, short k, short ang, int x, int y, int
|
|||
|
||||
void MorphTornado(SECTOR_OBJECT* sop)
|
||||
{
|
||||
int mx, my;
|
||||
int ceilz;
|
||||
int florz;
|
||||
sectortype* *sectp;
|
||||
int j;
|
||||
int x,y,sx,sy;
|
||||
|
||||
// z direction
|
||||
ASSERT(sop->op_main_sector != nullptr);
|
||||
sop->_morph_z += Z(sop->_morph_z_speed);
|
||||
sop->morph_z += sop->morph_z_speed;
|
||||
|
||||
// move vector
|
||||
if (sop->morph_wall_point == nullptr)
|
||||
return;
|
||||
|
||||
// place at correct x,y offset from center
|
||||
x = sop->int_pmid().X - sop->_morph_xoff;
|
||||
y = sop->int_pmid().Y - sop->_morph_yoff;
|
||||
|
||||
sx = x;
|
||||
sy = y;
|
||||
DVector2 pos = sop->pmid - sop->morph_off;
|
||||
DVector2 spos = pos;
|
||||
|
||||
// move it from last x,y
|
||||
mx = x + MulScale(sop->_morph_speed, bcos(sop->_morph_ang), 14);
|
||||
my = y + MulScale(sop->_morph_speed, bsin(sop->_morph_ang), 14);
|
||||
DVector2 mpos = pos + sop->morph_ang.ToVector() * sop->morph_speed;
|
||||
|
||||
// bound check radius
|
||||
if (ksqrt(SQ(sop->int_pmid().X - mx) + SQ(sop->int_pmid().Y - my)) > sop->_morph_dist_max + sop->scale_dist)
|
||||
if ((sop->pmid - mpos).Length() > sop->morph_dist_max + sop->scale_dist * zinttoworld)
|
||||
{
|
||||
// find angle
|
||||
sop->_morph_ang = NORM_ANGLE(getangle(mx - sop->int_pmid().X, my - sop->int_pmid().Y));
|
||||
// reverse angle
|
||||
sop->_morph_ang = NORM_ANGLE(sop->_morph_ang + 1024);
|
||||
// find and reverse angle
|
||||
sop->morph_ang = VecToAngle(mpos - sop->pmid) + DAngle180;
|
||||
|
||||
// move back some from last point
|
||||
mx = sx + MulScale(sop->_morph_speed << 1, bcos(sop->_morph_ang), 14);
|
||||
my = sy + MulScale(sop->_morph_speed << 1, bsin(sop->_morph_ang), 14);
|
||||
|
||||
sop->_morph_xoff = sop->int_pmid().X - mx;
|
||||
sop->_morph_yoff = sop->int_pmid().Y - my;
|
||||
mpos = spos + sop->morph_ang.ToVector() * sop->morph_speed * 2;
|
||||
}
|
||||
|
||||
// save x,y back as offset info
|
||||
sop->_morph_xoff = sop->int_pmid().X - mx;
|
||||
sop->_morph_yoff = sop->int_pmid().Y - my;
|
||||
sop->morph_off = sop->pmid - mpos;
|
||||
|
||||
if ((RANDOM_P2(1024<<4)>>4) < sop->morph_rand_freq)
|
||||
sop->_morph_ang = RANDOM_P2(2048);
|
||||
sop->morph_ang = RANDOM_ANGLE();
|
||||
|
||||
// move it x,y
|
||||
dragpoint(sop->morph_wall_point, mx, my);
|
||||
dragpoint(sop->morph_wall_point, mpos);
|
||||
|
||||
// bound the Z
|
||||
ceilz = sop->op_main_sector->int_ceilingz();
|
||||
florz = sop->op_main_sector->int_floorz();
|
||||
double ceilz = sop->op_main_sector->ceilingz;
|
||||
double florz = sop->op_main_sector->floorz;
|
||||
|
||||
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
||||
{
|
||||
if ((*sectp)->hasU() &&
|
||||
((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT))
|
||||
{
|
||||
#define TOR_LOW (florz)
|
||||
if (sop->_morph_z > TOR_LOW)
|
||||
if (sop->morph_z > florz)
|
||||
{
|
||||
sop->_morph_z_speed *= -1;
|
||||
sop->_morph_z = TOR_LOW;
|
||||
sop->morph_z_speed *= -1;
|
||||
sop->morph_z = florz;
|
||||
}
|
||||
else if (sop->_morph_z < ceilz)
|
||||
else if (sop->morph_z < ceilz)
|
||||
{
|
||||
sop->_morph_z_speed *= -1;
|
||||
sop->_morph_z = ceilz;
|
||||
sop->morph_z_speed *= -1;
|
||||
sop->morph_z = ceilz;
|
||||
}
|
||||
|
||||
alignceilslope(*sectp, mx, my, sop->_morph_z);
|
||||
alignceilslope(*sectp, DVector3(mpos, sop->morph_z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -375,71 +359,60 @@ void MorphTornado(SECTOR_OBJECT* sop)
|
|||
// moves center point around and aligns slope
|
||||
void MorphFloor(SECTOR_OBJECT* sop)
|
||||
{
|
||||
int mx, my;
|
||||
int florz;
|
||||
sectortype* *sectp;
|
||||
int j;
|
||||
int x,y;
|
||||
|
||||
// z direction
|
||||
ASSERT(sop->op_main_sector != nullptr);
|
||||
sop->_morph_z -= Z(sop->_morph_z_speed);
|
||||
sop->morph_z -= sop->morph_z_speed;
|
||||
|
||||
// move vector
|
||||
if (sop->morph_wall_point == nullptr)
|
||||
return;
|
||||
|
||||
// place at correct x,y offset from center
|
||||
x = sop->int_pmid().X - sop->_morph_xoff;
|
||||
y = sop->int_pmid().Y - sop->_morph_yoff;
|
||||
auto pos = sop->pmid - sop->morph_off;
|
||||
|
||||
// move it from last x,y
|
||||
mx = x + MulScale(sop->_morph_speed, bcos(sop->_morph_ang), 14);
|
||||
my = y + MulScale(sop->_morph_speed, bsin(sop->_morph_ang), 14);
|
||||
DVector2 mpos = pos + sop->morph_ang.ToVector() * sop->morph_speed;
|
||||
|
||||
// save x,y back as offset info
|
||||
sop->_morph_xoff = sop->int_pmid().X - mx;
|
||||
sop->_morph_yoff = sop->int_pmid().Y - my;
|
||||
sop->morph_off = sop->pmid - mpos;
|
||||
|
||||
// bound check radius
|
||||
if (Distance(sop->int_pmid().X, sop->int_pmid().Y, mx, my) > sop->_morph_dist_max)
|
||||
if ((sop->pmid - mpos).Length() > sop->morph_dist_max)
|
||||
{
|
||||
// go in the other direction
|
||||
//sop->morph_speed *= -1;
|
||||
sop->_morph_ang = NORM_ANGLE(sop->_morph_ang + 1024);
|
||||
sop->morph_ang = sop->morph_ang + DAngle180;
|
||||
|
||||
// back it up and save it off
|
||||
mx = x + MulScale(sop->_morph_speed, bcos(sop->_morph_ang), 14);
|
||||
my = y + MulScale(sop->_morph_speed, bsin(sop->_morph_ang), 14);
|
||||
sop->_morph_xoff = sop->int_pmid().X - mx;
|
||||
sop->_morph_yoff = sop->int_pmid().Y - my;
|
||||
mpos = pos + sop->morph_ang.ToVector() * sop->morph_speed;
|
||||
sop->morph_off = sop->pmid - mpos;
|
||||
|
||||
// turn it all the way around and then do a random -512 to 512 from there
|
||||
//sop->morph_ang = NORM_ANGLE(sop->morph_ang + 1024 + (RANDOM_P2(1024) - 512));
|
||||
}
|
||||
|
||||
if ((RANDOM_P2(1024<<4)>>4) < sop->morph_rand_freq)
|
||||
sop->_morph_ang = RANDOM_P2(2048);
|
||||
sop->morph_ang = RANDOM_ANGLE();
|
||||
|
||||
// move x,y point "just like in build"
|
||||
dragpoint(sop->morph_wall_point, mx, my);
|
||||
dragpoint(sop->morph_wall_point, mpos);
|
||||
|
||||
// bound the Z
|
||||
florz = sop->op_main_sector->int_floorz();
|
||||
double florz = sop->op_main_sector->floorz;
|
||||
|
||||
#define MORPH_FLOOR_ZRANGE Z(300)
|
||||
const double MORPH_FLOOR_ZRANGE = 300;
|
||||
|
||||
if (sop->_morph_z > MORPH_FLOOR_ZRANGE)
|
||||
if (sop->morph_z > MORPH_FLOOR_ZRANGE)
|
||||
{
|
||||
sop->_morph_z = MORPH_FLOOR_ZRANGE;
|
||||
//sop->morph_ang = NORM_ANGLE(sop->morph_ang + 1024);
|
||||
sop->_morph_z_speed *= -1;
|
||||
sop->morph_z = MORPH_FLOOR_ZRANGE;
|
||||
sop->morph_z_speed *= -1;
|
||||
}
|
||||
else if (sop->_morph_z < -MORPH_FLOOR_ZRANGE)
|
||||
else if (sop->morph_z < -MORPH_FLOOR_ZRANGE)
|
||||
{
|
||||
sop->_morph_z = -MORPH_FLOOR_ZRANGE;
|
||||
//sop->morph_ang = NORM_ANGLE(sop->morph_ang + 1024);
|
||||
sop->_morph_z_speed *= -1;
|
||||
sop->morph_z = -MORPH_FLOOR_ZRANGE;
|
||||
sop->morph_z_speed *= -1;
|
||||
}
|
||||
|
||||
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
||||
|
@ -447,7 +420,7 @@ void MorphFloor(SECTOR_OBJECT* sop)
|
|||
if ((*sectp)->hasU() &&
|
||||
((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT))
|
||||
{
|
||||
alignflorslope(*sectp, mx, my, florz + sop->_morph_z);
|
||||
alignflorslope(*sectp, DVector3(mpos, florz + sop->morph_z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -487,33 +460,30 @@ void SpikeFloor(SECTOR_OBJECT* sop)
|
|||
{
|
||||
// z direction
|
||||
ASSERT(sop->op_main_sector != nullptr);
|
||||
sop->_morph_z -= Z(sop->_morph_z_speed);
|
||||
sop->morph_z -= sop->morph_z_speed;
|
||||
|
||||
// move vector
|
||||
if (sop->morph_wall_point == nullptr)
|
||||
return;
|
||||
|
||||
DVector3 pos;
|
||||
|
||||
// place at correct x,y offset from center
|
||||
pos.X = sop->pmid.X - sop->_morph_xoff * inttoworld;
|
||||
pos.Y = sop->pmid.Y - sop->_morph_yoff * inttoworld;
|
||||
auto pos = sop->pmid - sop->morph_off;
|
||||
|
||||
// bound the Z
|
||||
|
||||
#define MORPH_FLOOR_ZRANGE Z(300)
|
||||
const double MORPH_FLOOR_ZRANGE = 300;
|
||||
|
||||
if (sop->_morph_z > MORPH_FLOOR_ZRANGE)
|
||||
if (sop->morph_z > MORPH_FLOOR_ZRANGE)
|
||||
{
|
||||
sop->_morph_z = MORPH_FLOOR_ZRANGE;
|
||||
sop->_morph_z_speed *= -1;
|
||||
sop->morph_z = MORPH_FLOOR_ZRANGE;
|
||||
sop->morph_z_speed *= -1;
|
||||
}
|
||||
else if (sop->_morph_z < -MORPH_FLOOR_ZRANGE)
|
||||
else if (sop->morph_z < -MORPH_FLOOR_ZRANGE)
|
||||
{
|
||||
sop->_morph_z = -MORPH_FLOOR_ZRANGE;
|
||||
sop->_morph_z_speed *= -1;
|
||||
sop->morph_z = -MORPH_FLOOR_ZRANGE;
|
||||
sop->morph_z_speed *= -1;
|
||||
}
|
||||
pos.Z = sop->op_main_sector->floorz + sop->_morph_z * inttoworld;
|
||||
pos.Z = sop->op_main_sector->floorz + sop->morph_z;
|
||||
|
||||
SOBJ_AlignFloorToPoint(sop, pos);
|
||||
}
|
||||
|
|
|
@ -642,9 +642,9 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECT& w,
|
|||
("target_dist", w.target_dist, def->target_dist)
|
||||
("floor_loz", w.floor_loz, def->floor_loz)
|
||||
("floor_hiz", w.floor_hiz, def->floor_hiz)
|
||||
("morph_z", w._morph_z, def->_morph_z)
|
||||
("morph_z_min", w._morph_z_min, def->_morph_z_min)
|
||||
("morph_z_max", w._morph_z_max, def->_morph_z_max)
|
||||
("morph_z", w.morph_z, def->morph_z)
|
||||
("morph_z_min", w.morph_z_min, def->morph_z_min)
|
||||
("morph_z_max", w.morph_z_max, def->morph_z_max)
|
||||
("bob_amt", w.bob_amt, def->bob_amt)
|
||||
("drive_angspeed", w.drive_angspeed, def->drive_angspeed)
|
||||
("drive_angslide", w.drive_angslide, def->drive_angslide)
|
||||
|
@ -698,14 +698,13 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECT& w,
|
|||
("scale_x_mult", w.scale_x_mult, def->scale_x_mult)
|
||||
("scale_y_mult", w.scale_y_mult, def->scale_y_mult)
|
||||
("morph_wall_point", w.morph_wall_point, def->morph_wall_point)
|
||||
("morph_ang", w._morph_ang, def->_morph_ang)
|
||||
("morph_speed", w._morph_speed, def->_morph_speed)
|
||||
("morph_dist_max", w._morph_dist_max, def->_morph_dist_max)
|
||||
("morph_ang", w.morph_ang, def->morph_ang)
|
||||
("morph_speed", w.morph_speed, def->morph_speed)
|
||||
("morph_dist_max", w.morph_dist_max, def->morph_dist_max)
|
||||
("morph_rand_freq", w.morph_rand_freq, def->morph_rand_freq)
|
||||
("morph_dist", w._morph_dist, def->_morph_dist)
|
||||
("morph_z_speed", w._morph_z_speed, def->_morph_z_speed)
|
||||
("morph_xoff", w._morph_xoff, def->_morph_xoff)
|
||||
("morph_yoff", w._morph_yoff, def->_morph_yoff)
|
||||
("morph_dist", w.morph_dist, def->morph_dist)
|
||||
("morph_z_speed", w.morph_z_speed, def->morph_z_speed)
|
||||
("morph_off", w.morph_off, def->morph_off)
|
||||
("limit_ang_center", w.limit_ang_center, def->limit_ang_center)
|
||||
("limit_ang_delta", w.limit_ang_delta, def->limit_ang_delta);
|
||||
|
||||
|
|
|
@ -968,14 +968,13 @@ void SetupSectorObject(sectortype* sectp, short tag)
|
|||
sop->scale_x_mult = 256;
|
||||
sop->scale_y_mult = 256;
|
||||
|
||||
sop->_morph_ang = RANDOM_P2(2048);
|
||||
sop->_morph_z_speed = 20;
|
||||
sop->_morph_speed = 32;
|
||||
sop->_morph_dist_max = 1024;
|
||||
sop->morph_ang = RANDOM_ANGLE();
|
||||
sop->morph_z_speed = 20;
|
||||
sop->morph_speed = 2;
|
||||
sop->morph_dist_max = 64;
|
||||
sop->morph_rand_freq = 64;
|
||||
sop->_morph_dist = 0;
|
||||
sop->_morph_xoff = 0;
|
||||
sop->_morph_yoff = 0;
|
||||
sop->morph_dist = 0;
|
||||
sop->morph_off = { 0,0 };
|
||||
|
||||
sop->PreMoveAnimator = nullptr;
|
||||
sop->PostMoveAnimator = nullptr;
|
||||
|
@ -1084,9 +1083,9 @@ void SetupSectorObject(sectortype* sectp, short tag)
|
|||
// clip
|
||||
sop->clipdist = 2500;
|
||||
// morph point
|
||||
sop->_morph_speed = 16;
|
||||
sop->_morph_z_speed = 6;
|
||||
sop->_morph_dist_max = 1024;
|
||||
sop->morph_speed = 1;
|
||||
sop->morph_z_speed = 6;
|
||||
sop->morph_dist_max = 64;
|
||||
sop->morph_rand_freq = 8;
|
||||
sop->scale_dist_min = -768;
|
||||
KillActor(actor);
|
||||
|
@ -1095,10 +1094,10 @@ void SetupSectorObject(sectortype* sectp, short tag)
|
|||
if (SW_SHAREWARE) break;
|
||||
sop->flags |= (SOBJ_DYNAMIC);
|
||||
sop->scale_type = SO_SCALE_NONE;
|
||||
sop->_morph_speed = 120;
|
||||
sop->_morph_z_speed = 7;
|
||||
sop->morph_speed = 7.5;
|
||||
sop->morph_z_speed = 7;
|
||||
sop->PostMoveAnimator = MorphFloor;
|
||||
sop->_morph_dist_max = 4000;
|
||||
sop->morph_dist_max = 250;
|
||||
sop->morph_rand_freq = 8;
|
||||
KillActor(actor);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue