Made the physics time step size configurable in the config file.

This commit is contained in:
hiker 2018-02-10 17:55:45 +11:00
parent 434a9c5dcc
commit 4d03fbd1fb
4 changed files with 10 additions and 1 deletions

View File

@ -92,6 +92,7 @@
case (all three normals discarded, the interpolation will just case (all three normals discarded, the interpolation will just
return the normal of the triangle (i.e. de facto no interpolation), return the normal of the triangle (i.e. de facto no interpolation),
but it helps making smoothing much more useful without fixing tracks. but it helps making smoothing much more useful without fixing tracks.
fps: The physics timestep size
default-track-friction: Default friction to be used for the track and default-track-friction: Default friction to be used for the track and
any track/library pbject. any track/library pbject.
default-moveable-friction: Default friction to be used for any moveable, default-moveable-friction: Default friction to be used for any moveable,
@ -99,6 +100,7 @@
--> -->
<physics smooth-normals="true" <physics smooth-normals="true"
smooth-angle-limit="0.65" smooth-angle-limit="0.65"
fps="120"
default-track-friction="0.5" default-track-friction="0.5"
default-moveable-friction="0.5" /> default-moveable-friction="0.5" />

View File

@ -139,6 +139,7 @@ void STKConfig::load(const std::string &filename)
CHECK_NEG(m_replay_dt, "replay delta-t" ); CHECK_NEG(m_replay_dt, "replay delta-t" );
CHECK_NEG(m_smooth_angle_limit, "physics smooth-angle-limit" ); CHECK_NEG(m_smooth_angle_limit, "physics smooth-angle-limit" );
CHECK_NEG(m_default_track_friction, "physics default-track-friction"); CHECK_NEG(m_default_track_friction, "physics default-track-friction");
CHECK_NEG(m_physics_fps, "physics fps" );
CHECK_NEG(m_default_moveable_friction, "physics default-moveable-friction"); CHECK_NEG(m_default_moveable_friction, "physics default-moveable-friction");
// Square distance to make distance checks cheaper (no sqrt) // Square distance to make distance checks cheaper (no sqrt)
@ -160,6 +161,7 @@ void STKConfig::init_defaults()
m_smooth_angle_limit = m_penalty_time = m_smooth_angle_limit = m_penalty_time =
m_default_track_friction = m_default_moveable_friction = m_default_track_friction = m_default_moveable_friction =
UNDEFINED; UNDEFINED;
m_physics_fps = -100;
m_bubblegum_counter = -100; m_bubblegum_counter = -100;
m_shield_restrict_weapos = false; m_shield_restrict_weapos = false;
m_max_karts = -100; m_max_karts = -100;
@ -249,6 +251,7 @@ void STKConfig::getAllData(const XMLNode * root)
physics_node->get("default-track-friction", &m_default_track_friction); physics_node->get("default-track-friction", &m_default_track_friction);
physics_node->get("default-moveable-friction", physics_node->get("default-moveable-friction",
&m_default_moveable_friction); &m_default_moveable_friction);
physics_node->get("fps", &m_physics_fps );
} }
if (const XMLNode *startup_node= root->getNode("startup")) if (const XMLNode *startup_node= root->getNode("startup"))

View File

@ -93,6 +93,9 @@ public:
/** Default friction to be used for any moveable, e.g. karts, balls. */ /** Default friction to be used for any moveable, e.g. karts, balls. */
float m_default_moveable_friction; float m_default_moveable_friction;
/** Default FPS rate for physics. */
int m_physics_fps;
int m_max_skidmarks; /**<Maximum number of skid marks/kart. */ int m_max_skidmarks; /**<Maximum number of skid marks/kart. */
float m_skid_fadeout_time; /**<Time till skidmarks fade away. */ float m_skid_fadeout_time; /**<Time till skidmarks fade away. */
float m_near_ground; /**<Determines when a kart is not near float m_near_ground; /**<Determines when a kart is not near

View File

@ -152,7 +152,8 @@ void Physics::update(float dt)
// Maximum of three substeps. This will work for framerate down to // Maximum of three substeps. This will work for framerate down to
// 20 FPS (bullet default frequency is 60 HZ). // 20 FPS (bullet default frequency is 60 HZ).
m_dynamics_world->stepSimulation(dt, 6, 1.0f/120.0f); m_dynamics_world->stepSimulation(dt, max_num_steps,
1.0f / stk_config->m_physics_fps);
// Now handle the actual collision. Note: flyables can not be removed // Now handle the actual collision. Note: flyables can not be removed
// inside of this loop, since the same flyables might hit more than one // inside of this loop, since the same flyables might hit more than one