From c66ff5939d1cf52607686766ed55bbf2046aa3d1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 20:43:35 +0100 Subject: [PATCH] - floatified AActor::bouncefactor and wallbouncefactor. --- src/actor.h | 8 ++------ src/d_dehacked.cpp | 14 ++++++-------- src/p_map.cpp | 8 ++++---- src/p_mobj.cpp | 8 ++++---- src/thingdef/thingdef_properties.cpp | 8 ++++---- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/actor.h b/src/actor.h index c37adf5e7..b81b726ce 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1240,8 +1240,8 @@ public: // but instead tries to come closer for a melee attack. // This is not the same as meleerange fixed_t maxtargetrange; // any target farther away cannot be attacked - fixed_t bouncefactor; // Strife's grenades use 50%, Hexen's Flechettes 70. - fixed_t wallbouncefactor; // The bounce factor for walls can be different. + double bouncefactor; // Strife's grenades use 50%, Hexen's Flechettes 70. + double wallbouncefactor; // The bounce factor for walls can be different. int bouncecount; // Strife's grenades only bounce twice before exploding double Gravity; // [GRB] Gravity factor fixed_t Friction; @@ -1482,10 +1482,6 @@ public: { return FIXED2DBL(pushfactor); } - double _bouncefactor() const - { - return FIXED2DBL(bouncefactor); - } void SetZ(double newz, bool moving = true) { __pos.z = FLOAT2FIXED(newz); diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index a9188411d..02237944e 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -1141,14 +1141,12 @@ static int PatchThing (int thingy) } // MBF bounce factors depend on flag combos: - enum - { - MBF_BOUNCE_NOGRAVITY = FRACUNIT, // With NOGRAVITY: full momentum - MBF_BOUNCE_FLOATDROPOFF = (FRACUNIT * 85) / 100,// With FLOAT and DROPOFF: 85% - MBF_BOUNCE_FLOAT = (FRACUNIT * 70) / 100,// With FLOAT alone: 70% - MBF_BOUNCE_DEFAULT = (FRACUNIT * 45) / 100,// Without the above flags: 45% - MBF_BOUNCE_WALL = (FRACUNIT * 50) / 100,// Bouncing off walls: 50% - }; + const double MBF_BOUNCE_NOGRAVITY = 1; // With NOGRAVITY: full momentum + const double MBF_BOUNCE_FLOATDROPOFF = 0.85; // With FLOAT and DROPOFF: 85% + const double MBF_BOUNCE_FLOAT = 0.7; // With FLOAT alone: 70% + const double MBF_BOUNCE_DEFAULT = 0.45; // Without the above flags: 45% + const double MBF_BOUNCE_WALL = 0.5; // Bouncing off walls: 50% + info->bouncefactor = ((value[0] & MF_NOGRAVITY) ? MBF_BOUNCE_NOGRAVITY : (value[0] & MF_FLOAT) ? (value[0] & MF_DROPOFF) ? MBF_BOUNCE_FLOATDROPOFF : MBF_BOUNCE_FLOAT : MBF_BOUNCE_DEFAULT); diff --git a/src/p_map.cpp b/src/p_map.cpp index fb341f285..bb4cc08f1 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3296,7 +3296,7 @@ bool FSlide::BounceWall(AActor *mo) deltaangle >>= ANGLETOFINESHIFT; movelen = fixed_t(g_sqrt(double(mo->_f_velx())*mo->_f_velx() + double(mo->_f_vely())*mo->_f_vely())); - movelen = FixedMul(movelen, mo->wallbouncefactor); + movelen = fixed_t(movelen * mo->wallbouncefactor); FBoundingBox box(mo->_f_X(), mo->_f_Y(), mo->_f_radius()); if (box.BoxOnLineSide(line) == -1) @@ -3356,7 +3356,7 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) if (!ontop) { DAngle angle = BlockingMobj->AngleTo(mo) + ((pr_bounce() % 16) - 8); - double speed = mo->VelXYToSpeed() * FIXED2DBL(mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent + double speed = mo->VelXYToSpeed() * mo->wallbouncefactor; // [GZ] was 0.75, using wallbouncefactor seems more consistent mo->Angles.Yaw = ANGLE2DBL(angle); mo->VelFromAngle(speed); mo->PlayBounceSound(true); @@ -3393,13 +3393,13 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) } else { - mo->Vel.Z *= mo->_bouncefactor(); + mo->Vel.Z *= mo->bouncefactor; } } else // Don't run through this for MBF-style bounces { // The reflected velocity keeps only about 70% of its original speed - mo->Vel.Z = (mo->Vel.Z - 2. / dot) * mo->_bouncefactor(); + mo->Vel.Z = (mo->Vel.Z - 2. / dot) * mo->bouncefactor; } mo->PlayBounceSound(true); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 06cd8606c..136f60fe6 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1583,12 +1583,12 @@ bool AActor::FloorBounceMissile (secplane_t &plane) flags &= ~MF_INBOUNCE; return false; } - else Vel.Z *= _bouncefactor(); + else Vel.Z *= bouncefactor; } else // Don't run through this for MBF-style bounces { // The reflected velocity keeps only about 70% of its original speed - Vel = (Vel - plane.Normal() * dot) * _bouncefactor(); + Vel = (Vel - plane.Normal() * dot) * bouncefactor; AngleFromVel(); } @@ -6672,8 +6672,8 @@ void PrintMiscActorInfo(AActor *query) for (flagi = 0; flagi <= 31; flagi++) if (query->flags7 & ActorFlags7::FromInt(1<BounceFlags.GetValue(), FIXED2DBL(query->bouncefactor), - FIXED2DBL(query->wallbouncefactor)); + query->BounceFlags.GetValue(), query->bouncefactor, + query->wallbouncefactor); /*for (flagi = 0; flagi < 31; flagi++) if (query->BounceFlags & 1<bouncefactor = clamp(id, 0, FRACUNIT); + PROP_DOUBLE_PARM(id, 0); + defaults->bouncefactor = clamp(id, 0, 1); } //========================================================================== @@ -1141,8 +1141,8 @@ DEFINE_PROPERTY(bouncefactor, F, Actor) //========================================================================== DEFINE_PROPERTY(wallbouncefactor, F, Actor) { - PROP_FIXED_PARM(id, 0); - defaults->wallbouncefactor = clamp(id, 0, FRACUNIT); + PROP_DOUBLE_PARM(id, 0); + defaults->wallbouncefactor = clamp(id, 0, 1); } //==========================================================================