diff --git a/data/stk_config.xml b/data/stk_config.xml index d52105ddd..cdd3d44e8 100644 --- a/data/stk_config.xml +++ b/data/stk_config.xml @@ -548,4 +548,12 @@ --> + + + diff --git a/src/config/stk_config.cpp b/src/config/stk_config.cpp index 8fa3b675f..8c7b90508 100644 --- a/src/config/stk_config.cpp +++ b/src/config/stk_config.cpp @@ -157,6 +157,11 @@ void STKConfig::load(const std::string &filename) CHECK_NEG(m_default_moveable_friction, "physics default-moveable-friction"); CHECK_NEG(m_solver_iterations, "physics: solver-iterations" ); CHECK_NEG(m_solver_split_impulse_thresh,"physics: solver-split-impulse-threshold"); + CHECK_NEG(m_snb_min_adjust_length, "network smoothing: min-adjust-length"); + CHECK_NEG(m_snb_max_adjust_length, "network smoothing: max-adjust-length"); + CHECK_NEG(m_snb_min_adjust_speed, "network smoothing: min-adjust-speed"); + CHECK_NEG(m_snb_max_adjust_time, "network smoothing: max-adjust-time"); + CHECK_NEG(m_snb_adjust_length_threshold, "network smoothing: adjust-length-threshold"); // Square distance to make distance checks cheaper (no sqrt) m_default_kart_properties->checkAllSet(filename); @@ -217,6 +222,9 @@ void STKConfig::init_defaults() m_server_discovery_port = 2757; m_client_port = 2758; m_server_port = 2759; + m_snb_min_adjust_length = m_snb_max_adjust_length = + m_snb_min_adjust_speed = m_snb_max_adjust_time = + m_snb_adjust_length_threshold = UNDEFINED; m_score_increase.clear(); m_leader_intervals.clear(); @@ -492,6 +500,15 @@ void STKConfig::getAllData(const XMLNode * root) m_server_port = (uint16_t)server_port; } + if (const XMLNode *ns = root->getNode("network-smoothing")) + { + ns->get("min-adjust-length", &m_snb_min_adjust_length); + ns->get("max-adjust-length", &m_snb_max_adjust_length); + ns->get("min-adjust-speed", &m_snb_min_adjust_speed); + ns->get("max-adjust-time", &m_snb_max_adjust_time); + ns->get("adjust-length-threshold", &m_snb_adjust_length_threshold); + } + // Get the default KartProperties // ------------------------------ const XMLNode *node = root -> getNode("general-kart-defaults"); diff --git a/src/config/stk_config.hpp b/src/config/stk_config.hpp index 42f9c45c2..184c78824 100644 --- a/src/config/stk_config.hpp +++ b/src/config/stk_config.hpp @@ -206,6 +206,11 @@ public: std::vector m_normal_ttf; std::vector m_digit_ttf; + /** Configurable values used in SmoothNetworkBody class. */ + float m_snb_min_adjust_length, m_snb_max_adjust_length, + m_snb_min_adjust_speed, m_snb_max_adjust_time, + m_snb_adjust_length_threshold; + private: /** True if stk_config has been loaded. This is necessary if the * --stk-config command line parameter has been specified to avoid diff --git a/src/network/smooth_network_body.cpp b/src/network/smooth_network_body.cpp index b55cd1c76..6d6dd4dc9 100644 --- a/src/network/smooth_network_body.cpp +++ b/src/network/smooth_network_body.cpp @@ -17,6 +17,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "network/smooth_network_body.hpp" +#include "config/stk_config.hpp" #include @@ -27,11 +28,11 @@ SmoothNetworkBody::SmoothNetworkBody(bool enable) m_enabled = enable; m_smooth_rotation = true; m_adjust_vertical_offset = true; - m_min_adjust_length = 0.1f; - m_max_adjust_length = 4.0f; - m_min_adjust_speed = 0.3f; - m_max_adjust_time = 2.0f; - m_adjust_length_threshold = 2.0f; + m_min_adjust_length = stk_config->m_snb_min_adjust_length; + m_max_adjust_length = stk_config->m_snb_max_adjust_length; + m_min_adjust_speed = stk_config->m_snb_min_adjust_speed; + m_max_adjust_time = stk_config->m_snb_max_adjust_time; + m_adjust_length_threshold = stk_config->m_snb_adjust_length_threshold; } // SmoothNetworkBody // ----------------------------------------------------------------------------