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 4f54fb7898
commit 37d81be033
4 changed files with 12 additions and 2 deletions

View File

@ -92,6 +92,7 @@
case (all three normals discarded, the interpolation will just
return the normal of the triangle (i.e. de facto no interpolation),
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
any track/library pbject.
default-moveable-friction: Default friction to be used for any moveable,
@ -99,6 +100,7 @@
-->
<physics smooth-normals="true"
smooth-angle-limit="0.65"
fps="120"
default-track-friction="0.5"
default-moveable-friction="0.5" />

View File

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

View File

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

View File

@ -160,7 +160,8 @@ void Physics::update(float dt)
// of physics step, otherwise the results diverge too much
max_num_steps = 999;
}
m_dynamics_world->stepSimulation(dt, max_num_steps, 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
// inside of this loop, since the same flyables might hit more than one