Skip to content

Commit

Permalink
Merge branch 'arrival_warp_distance' of github.com:Goober5000/fs2open…
Browse files Browse the repository at this point in the history
….github.com into arrival_warp_distance
  • Loading branch information
Goober5000 committed Oct 15, 2023
2 parents 32b79fe + 6833286 commit 222b10f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions code/physics/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define WEAPON_SHAKE_TIME 500 // ms (0.5 sec) viewer shake time after hit by weapon (implemented via afterburner shake)

const float SUPERCAP_WARP_T_CONST = 0.651f; // special warp time constant (lose 99 % of excess speed in 3 sec)
const float SUPERCAP_WARP_EXCESS_SPD_THRESHOLD = 5.0f; // more than this many m/s faster than the ship's max speed and we use the above damp constant instead

void update_reduced_damp_timestamp( physics_info *pi, float impulse );
float velocity_ramp (float v_in, float v_goal, float time_const, float t);
Expand Down Expand Up @@ -346,7 +347,7 @@ void physics_sim_vel(vec3d * position, physics_info * pi, matrix *orient, vec3d*
vec3d grav_vel = vmd_zero_vector;
int special_warp_in = FALSE;
float excess = local_v_in.xyz.z - pi->max_vel.xyz.z;
if (excess > 5 && (pi->flags & PF_SUPERCAP_WARP_IN)) {
if (excess > SUPERCAP_WARP_EXCESS_SPD_THRESHOLD && (pi->flags & PF_SUPERCAP_WARP_IN)) {
special_warp_in = TRUE;
float exp_factor = float(exp(-sim_time / SUPERCAP_WARP_T_CONST));
local_v_out.xyz.z = pi->max_vel.xyz.z + excess * exp_factor;
Expand All @@ -367,7 +368,7 @@ void physics_sim_vel(vec3d * position, physics_info * pi, matrix *orient, vec3d*
}

// maybe turn off special warp in flag
if ((pi->flags & PF_SUPERCAP_WARP_IN) && (excess < 5)) {
if ((pi->flags & PF_SUPERCAP_WARP_IN) && (excess < SUPERCAP_WARP_EXCESS_SPD_THRESHOLD)) {
pi->flags &= ~(PF_SUPERCAP_WARP_IN);
}

Expand Down
1 change: 1 addition & 0 deletions code/physics/physics.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#define PF_BALLISTIC (1 << 18) // Asteroth - not moving 'under its own power', simplified physics calculations

extern const float SUPERCAP_WARP_T_CONST;
extern const float SUPERCAP_WARP_EXCESS_SPD_THRESHOLD;

//information for physics sim for an object
typedef struct physics_info {
Expand Down
4 changes: 2 additions & 2 deletions code/ship/shipfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3753,8 +3753,8 @@ float shipfx_calculate_arrival_warp_distance(object *objp)
float decel_time_const = objp->phys_info.forward_decel_time_const;
if (Ship_info[Ships[objp->instance].ship_info_index].flags[Ship::Info_Flags::Supercap]) {
// super cap style warpins are annoying, one time constant while above their max speed, a different one while slowing down from there
float supercap_slowdown_dist = (warping_speed - (objp->phys_info.max_vel.xyz.z + 5.0f)) * SUPERCAP_WARP_T_CONST;
float regular_slowdown_dist = (objp->phys_info.max_vel.xyz.z + 5.0f) * decel_time_const;
float supercap_slowdown_dist = (warping_speed - (objp->phys_info.max_vel.xyz.z + SUPERCAP_WARP_EXCESS_SPD_THRESHOLD)) * SUPERCAP_WARP_T_CONST;
float regular_slowdown_dist = (objp->phys_info.max_vel.xyz.z + SUPERCAP_WARP_EXCESS_SPD_THRESHOLD) * decel_time_const;

return warping_dist + supercap_slowdown_dist + regular_slowdown_dist;
} else {
Expand Down

0 comments on commit 222b10f

Please sign in to comment.