Decode the solver-mode only once instead of at every race start.
This commit is contained in:
parent
2399946301
commit
bca11b98fb
@ -108,11 +108,18 @@
|
||||
this to 1 can reduce bounce.
|
||||
solver-split-impulse-threshold: Penetration threshold for using split
|
||||
impulse (ignored if solver-split-impulse is false).
|
||||
solver-mode: Bullet's solver mode is a bit mask. This field takes two
|
||||
solver-mode: Bullet's solver mode is a bit mask, which can be modified.
|
||||
This entry contains a space-separated list of mode-names to either
|
||||
set or unset in this bit mask. Any name starting with a '-' indicate
|
||||
that the bit is to be set to 0, otherwise the bit will be set.
|
||||
|
||||
This field takes two
|
||||
values: the first value is 'and'ed with bullet's default values
|
||||
(i.e. it can be used to unset bullet defaults), the second value
|
||||
is 'or'ed (i.e. is used to set a bit). A value of -1 for 'and'
|
||||
means to keep all bits.
|
||||
means to keep all bits. The valid names are listed in stk_config.cpp
|
||||
and correspond to the definitions in btContactSolverInfo.h, e.g.:
|
||||
'randomized_order' corresponds to the bit SOLVER_RANDMIZE_ORDER.
|
||||
-->
|
||||
<physics smooth-normals="true"
|
||||
smooth-angle-limit="0.65"
|
||||
|
@ -162,7 +162,6 @@ void STKConfig::load(const std::string &filename)
|
||||
CHECK_NEG(m_physics_fps, "physics fps" );
|
||||
CHECK_NEG(m_default_moveable_friction, "physics default-moveable-friction");
|
||||
CHECK_NEG(m_solver_iterations, "physics: solver-iterations" );
|
||||
CHECK_NEG(m_solver_split_impulse, "physics: solver-split-impulse" );
|
||||
CHECK_NEG(m_network_state_frequeny, "network solver-state-frequency" );
|
||||
CHECK_NEG(m_solver_split_impulse_thresh,"physics: solver-split-impulse-threshold");
|
||||
|
||||
@ -208,6 +207,8 @@ void STKConfig::init_defaults()
|
||||
m_password_reset_url = "";
|
||||
m_network_state_frequeny = -100;
|
||||
m_solver_iterations = -100;
|
||||
m_solver_set_flags = 0;
|
||||
m_solver_reset_flags = 0;
|
||||
m_title_music = NULL;
|
||||
m_solver_split_impulse = false;
|
||||
m_smooth_normals = false;
|
||||
@ -298,7 +299,38 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
physics_node->get("solver-split-impulse", &m_solver_split_impulse );
|
||||
physics_node->get("solver-split-impulse-threshold",
|
||||
&m_solver_split_impulse_thresh);
|
||||
physics_node->get("solver-mode", &m_solver_mode );
|
||||
std::vector<std::string> solver_modes;
|
||||
physics_node->get("solver-mode", &solver_modes );
|
||||
m_solver_set_flags=0, m_solver_reset_flags = 0;
|
||||
int *p;
|
||||
for (auto mode : solver_modes)
|
||||
{
|
||||
std::string s = mode;
|
||||
p = &m_solver_set_flags;
|
||||
if (s[0] == '-')
|
||||
{
|
||||
s.erase(s.begin());
|
||||
p = &m_solver_reset_flags;
|
||||
}
|
||||
s = StringUtils::toLowerCase(s);
|
||||
if (s == "randmize_order" ) *p |= 1;
|
||||
else if (s == "friction_separate" ) *p |= 2;
|
||||
else if (s == "use_warmstarting" ) *p |= 4;
|
||||
else if (s == "use_friction_warmstarting" ) *p |= 8;
|
||||
else if (s == "use_2_friction_directions" ) *p |= 16;
|
||||
else if (s == "enable_friction_direction_caching" ) *p |= 32;
|
||||
else if (s == "disable_velocity_dependent_friction_direction") *p |= 64;
|
||||
else if (s == "cache_friendly" ) *p |= 128;
|
||||
else if (s == "simd" ) *p |= 256;
|
||||
else if (s == "cuda" ) *p |= 512;
|
||||
else
|
||||
{
|
||||
Log::fatal("STK-Config",
|
||||
"Unknown option '%s' for solver-mode - ignored.",
|
||||
s.c_str());
|
||||
}
|
||||
} // for mode in solver_modes
|
||||
|
||||
}
|
||||
|
||||
if (const XMLNode *startup_node= root->getNode("startup"))
|
||||
|
7
src/config/stk_config.hpp
Executable file → Normal file
7
src/config/stk_config.hpp
Executable file → Normal file
@ -115,9 +115,10 @@ public:
|
||||
|
||||
/** Threshold when to use the split impulse approach. */
|
||||
float m_solver_split_impulse_thresh;
|
||||
|
||||
/** */
|
||||
std::vector<std::string> m_solver_mode;
|
||||
|
||||
/** Bit flags to modify the solver mode. Bits set in set_flags are
|
||||
* added to the solver mode, bits set in reset_flags are removed. */
|
||||
int m_solver_set_flags, m_solver_reset_flags;
|
||||
|
||||
int m_max_skidmarks; /**<Maximum number of skid marks/kart. */
|
||||
float m_skid_fadeout_time; /**<Time till skidmarks fade away. */
|
||||
|
@ -82,36 +82,9 @@ void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
|
||||
info.m_splitImpulsePenetrationThreshold =
|
||||
stk_config->m_solver_split_impulse_thresh;
|
||||
|
||||
int set_flags=0, reset_flags = 0;
|
||||
int *p;
|
||||
for(auto mode : stk_config->m_solver_mode)
|
||||
{
|
||||
std::string s = mode;
|
||||
p = &set_flags;
|
||||
if (s[0] == '-')
|
||||
{
|
||||
s.erase(s.begin());
|
||||
p = &reset_flags;
|
||||
}
|
||||
s = StringUtils::toLowerCase(s);
|
||||
if (s=="randmize_order" ) *p |= 1;
|
||||
else if (s=="friction_separate" ) *p |= 2;
|
||||
else if (s=="use_warmstarting" ) *p |= 4;
|
||||
else if (s=="use_friction_warmstarting" ) *p |= 8;
|
||||
else if (s=="use_2_friction_directions" ) *p |= 16;
|
||||
else if (s=="enable_friction_direction_caching" ) *p |= 32;
|
||||
else if (s=="disable_velocity_dependent_friction_direction") *p |= 64;
|
||||
else if (s=="cache_friendly" ) *p |= 128;
|
||||
else if (s=="simd" ) *p |= 256;
|
||||
else if (s=="cuda" ) *p |= 512;
|
||||
else
|
||||
{
|
||||
Log::error("STK-Config",
|
||||
"Unknown option '%s' for solver-mode - ignored.",
|
||||
s.c_str());
|
||||
}
|
||||
}
|
||||
info.m_solverMode = (info.m_solverMode & (~reset_flags)) | set_flags;
|
||||
// Modify the mode according to the bits of the solver mode:
|
||||
info.m_solverMode = (info.m_solverMode & (~stk_config->m_solver_reset_flags))
|
||||
| stk_config->m_solver_set_flags;
|
||||
} // init
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user