From 43b7f28d546f153840818d052663eee26094e5c6 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Sun, 18 Nov 2012 22:22:30 +0000 Subject: [PATCH] Added a setting to stk_config.xml to replace normals that are 'too different' from the normal of the triangle with the normal of the triangle for interpolating the normals which are used by the physics. This should make 'smooth normals' more useful for tracks where track and (say) a wall are connected, resulting in incorrect normals for the physics. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11989 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/stk_config.xml | 19 +++++++++++++++++-- src/config/stk_config.cpp | 5 ++++- src/config/stk_config.hpp | 4 ++++ src/physics/triangle_mesh.cpp | 12 +++++++++--- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/data/stk_config.xml b/data/stk_config.xml index ed8cda8f0..56f275afb 100644 --- a/data/stk_config.xml +++ b/data/stk_config.xml @@ -39,8 +39,23 @@ it will be ignored. --> - - + + diff --git a/src/config/stk_config.cpp b/src/config/stk_config.cpp index 28b926cf3..5809a6739 100644 --- a/src/config/stk_config.cpp +++ b/src/config/stk_config.cpp @@ -139,6 +139,7 @@ void STKConfig::load(const std::string &filename) CHECK_NEG(m_replay_delta_angle, "replay delta-angle" ); CHECK_NEG(m_replay_delta_pos2, "replay delta-position" ); CHECK_NEG(m_replay_dt, "replay delta-t" ); + CHECK_NEG(m_smooth_angle_limit, "physics smooth-angle-limit" ); // Square distance to make distance checks cheaper (no sqrt) m_replay_delta_pos2 *= m_replay_delta_pos2; @@ -159,6 +160,7 @@ void STKConfig::init_defaults() m_anvil_time = m_music_credit_time = m_delay_finish_time = m_skid_fadeout_time = m_near_ground = m_item_switch_time = + m_smooth_angle_limit = m_penalty_time = m_explosion_impulse_objects = UNDEFINED; m_bubble_gum_counter = -100; m_max_karts = -100; @@ -241,7 +243,8 @@ void STKConfig::getAllData(const XMLNode * root) if (const XMLNode *physics_node= root->getNode("physics")) { - physics_node->get("smooth-normals", &m_smooth_normals ); + physics_node->get("smooth-normals", &m_smooth_normals ); + physics_node->get("smooth-angle-limit", &m_smooth_angle_limit); } if (const XMLNode *startup_node= root->getNode("startup")) diff --git a/src/config/stk_config.hpp b/src/config/stk_config.hpp index fcbd14343..73ad2a241 100644 --- a/src/config/stk_config.hpp +++ b/src/config/stk_config.hpp @@ -89,6 +89,10 @@ public: a history files. */ bool m_smooth_normals; /**< If normals for raycasts for wheels should be interpolated. */ + /** If the angle between a normal on a vertex and the normal of the + * triangle are more than this value, the physics will use the normal + * of the triangle in smoothing normal. */ + float m_smooth_angle_limit; int m_max_skidmarks; /**stk_config->m_smooth_angle_limit + ? normal : n1 ); + m_normals.push_back( normal.angle(n2)>stk_config->m_smooth_angle_limit + ? normal : n2 ); + m_normals.push_back( normal.angle(n3)>stk_config->m_smooth_angle_limit + ? normal : n3 ); m_mesh.addTriangle(t1, t2, t3); } // addTriangle