Support setting of friction for karts, moveable and track in stk_config.xml
and kart_characteristics.xml (for now no changed settings, all are at tbe default of 0.5).
This commit is contained in:
parent
5bbacfc72d
commit
f55c39b3b1
@ -120,6 +120,8 @@
|
||||
<rear-left position="-0.38 0 -0.6" />
|
||||
</wheels>
|
||||
|
||||
<!-- Friction of a kart when e.g. sliding along a wall. -->
|
||||
<friction kart-friction="0.5" />
|
||||
|
||||
<!-- ********** Visuals ********** -->
|
||||
|
||||
|
@ -92,9 +92,15 @@
|
||||
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.
|
||||
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,
|
||||
e.g. karts, bowling balls, ...
|
||||
-->
|
||||
<physics smooth-normals="true"
|
||||
smooth-angle-limit="0.65"/>
|
||||
smooth-angle-limit="0.65"
|
||||
default-track-friction="0.5"
|
||||
default-moveable-friction="0.5" />
|
||||
|
||||
<!-- The title music. -->
|
||||
<music title="main_theme.music"/>
|
||||
|
@ -138,6 +138,8 @@ void STKConfig::load(const std::string &filename)
|
||||
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" );
|
||||
CHECK_NEG(m_default_track_friction, "physics default-track-friction");
|
||||
CHECK_NEG(m_default_moveable_friction, "physics default-moveable-friction");
|
||||
|
||||
// Square distance to make distance checks cheaper (no sqrt)
|
||||
m_replay_delta_pos2 *= m_replay_delta_pos2;
|
||||
@ -156,6 +158,7 @@ void STKConfig::init_defaults()
|
||||
m_delay_finish_time = m_skid_fadeout_time =
|
||||
m_near_ground = m_item_switch_time =
|
||||
m_smooth_angle_limit = m_penalty_time =
|
||||
m_default_track_friction = m_default_moveable_friction =
|
||||
UNDEFINED;
|
||||
m_bubblegum_counter = -100;
|
||||
m_shield_restrict_weapos = false;
|
||||
@ -239,8 +242,11 @@ 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-angle-limit", &m_smooth_angle_limit);
|
||||
physics_node->get("smooth-normals", &m_smooth_normals );
|
||||
physics_node->get("smooth-angle-limit", &m_smooth_angle_limit );
|
||||
physics_node->get("default-track-friction", &m_default_track_friction);
|
||||
physics_node->get("default-moveable-friction",
|
||||
&m_default_moveable_friction);
|
||||
}
|
||||
|
||||
if (const XMLNode *startup_node= root->getNode("startup"))
|
||||
|
@ -85,6 +85,13 @@ public:
|
||||
* triangle are more than this value, the physics will use the normal
|
||||
* of the triangle in smoothing normal. */
|
||||
float m_smooth_angle_limit;
|
||||
|
||||
/** Default friction for the track and any track/library object. */
|
||||
float m_default_track_friction;
|
||||
|
||||
/** Default friction to be used for any moveable, e.g. karts, balls. */
|
||||
float m_default_moveable_friction;
|
||||
|
||||
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
|
||||
|
@ -136,6 +136,8 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(
|
||||
return TYPE_FLOAT;
|
||||
case PARACHUTE_MAX_SPEED:
|
||||
return TYPE_FLOAT;
|
||||
case FRICTION_KART_FRICTION:
|
||||
return TYPE_FLOAT;
|
||||
case BUBBLEGUM_DURATION:
|
||||
return TYPE_FLOAT;
|
||||
case BUBBLEGUM_SPEED_FRACTION:
|
||||
@ -364,6 +366,8 @@ std::string AbstractCharacteristic::getName(CharacteristicType type)
|
||||
return "PARACHUTE_UBOUND_FRACTION";
|
||||
case PARACHUTE_MAX_SPEED:
|
||||
return "PARACHUTE_MAX_SPEED";
|
||||
case FRICTION_KART_FRICTION:
|
||||
return "FRICTION_KART_FRICTION";
|
||||
case BUBBLEGUM_DURATION:
|
||||
return "BUBBLEGUM_DURATION";
|
||||
case BUBBLEGUM_SPEED_FRACTION:
|
||||
@ -994,6 +998,18 @@ float AbstractCharacteristic::getParachuteMaxSpeed() const
|
||||
return result;
|
||||
} // getParachuteMaxSpeed
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float AbstractCharacteristic::getFrictionKartFriction() const
|
||||
{
|
||||
float result;
|
||||
bool is_set = false;
|
||||
process(FRICTION_KART_FRICTION, &result, &is_set);
|
||||
if (!is_set)
|
||||
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
|
||||
getName(FRICTION_KART_FRICTION).c_str());
|
||||
return result;
|
||||
} // getFrictionKartFriction
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float AbstractCharacteristic::getBubblegumDuration() const
|
||||
{
|
||||
|
@ -136,6 +136,9 @@ public:
|
||||
PARACHUTE_UBOUND_FRACTION,
|
||||
PARACHUTE_MAX_SPEED,
|
||||
|
||||
// Friction
|
||||
FRICTION_KART_FRICTION,
|
||||
|
||||
// Bubblegum
|
||||
BUBBLEGUM_DURATION,
|
||||
BUBBLEGUM_SPEED_FRACTION,
|
||||
@ -308,6 +311,8 @@ public:
|
||||
float getParachuteUboundFraction() const;
|
||||
float getParachuteMaxSpeed() const;
|
||||
|
||||
float getFrictionKartFriction() const;
|
||||
|
||||
float getBubblegumDuration() const;
|
||||
float getBubblegumSpeedFraction() const;
|
||||
float getBubblegumTorque() const;
|
||||
|
@ -668,6 +668,7 @@ void Kart::createPhysics()
|
||||
trans.setIdentity();
|
||||
createBody(mass, trans, &m_kart_chassis,
|
||||
m_kart_properties->getRestitution());
|
||||
m_body->setFriction(m_kart_properties->getFrictionKartFriction());
|
||||
m_user_pointer.set(this);
|
||||
m_body->setDamping(m_kart_properties->getStabilityChassisLinearDamping(),
|
||||
m_kart_properties->getStabilityChassisAngularDamping() );
|
||||
|
@ -783,6 +783,12 @@ float KartProperties::getParachuteMaxSpeed() const
|
||||
return m_cached_characteristic->getParachuteMaxSpeed();
|
||||
} // getParachuteMaxSpeed
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getFrictionKartFriction() const
|
||||
{
|
||||
return m_cached_characteristic->getFrictionKartFriction();
|
||||
} // getFrictionKartFriction
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getBubblegumDuration() const
|
||||
{
|
||||
|
@ -473,6 +473,8 @@ public:
|
||||
float getParachuteUboundFraction() const;
|
||||
float getParachuteMaxSpeed() const;
|
||||
|
||||
float getFrictionKartFriction() const;
|
||||
|
||||
float getBubblegumDuration() const;
|
||||
float getBubblegumSpeedFraction() const;
|
||||
float getBubblegumTorque() const;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <math.h>
|
||||
#include "karts/moveable.hpp"
|
||||
|
||||
#include "config/stk_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
@ -170,6 +171,7 @@ void Moveable::createBody(float mass, btTransform& trans,
|
||||
btRigidBody::btRigidBodyConstructionInfo info(mass, m_motion_state,
|
||||
shape, inertia);
|
||||
info.m_restitution = restitution;
|
||||
info.m_friction = stk_config->m_default_moveable_friction;
|
||||
|
||||
// Then create a rigid body
|
||||
// ------------------------
|
||||
|
@ -447,6 +447,12 @@ void XmlCharacteristic::load(const XMLNode *node)
|
||||
&m_values[PARACHUTE_MAX_SPEED]);
|
||||
}
|
||||
|
||||
if (const XMLNode *sub_node = node->getNode("friction"))
|
||||
{
|
||||
sub_node->get("kart-friction",
|
||||
&m_values[FRICTION_KART_FRICTION]);
|
||||
}
|
||||
|
||||
if (const XMLNode *sub_node = node->getNode("bubblegum"))
|
||||
{
|
||||
sub_node->get("duration",
|
||||
|
@ -480,7 +480,7 @@ void Track::loadTrackInfo()
|
||||
m_fog_height_start = 0.0f;
|
||||
m_fog_height_end = 100.0f;
|
||||
m_gravity = 9.80665f;
|
||||
m_friction = 0.5f;
|
||||
m_friction = stk_config->m_default_track_friction;
|
||||
m_smooth_normals = false;
|
||||
m_godrays = false;
|
||||
m_godrays_opacity = 1.0f;
|
||||
|
@ -39,6 +39,7 @@ Jump: animationTime
|
||||
Lean: max, speed
|
||||
Anvil: duration, weight, speedFactor
|
||||
Parachute: friction, duration, durationOther, durationRankMult, durationSpeedMult, lboundFraction, uboundFraction, maxSpeed
|
||||
Friction: kartFriction
|
||||
Bubblegum: duration, speedFraction, torque, fadeInTime, shieldDuration
|
||||
Zipper: duration, force, speedGain, maxSpeedIncrease, fadeOutTime
|
||||
Swatter: duration, distance, squashDuration, squashSlowdown
|
||||
@ -245,7 +246,7 @@ functions = {
|
||||
"getName": (createGetName, "Implement the getName function", "karts/abstract_characteristic.cpp"),
|
||||
"kpdefs": (createKpDefs, "Create the header function definitions for the getters", "karts/kart_properties.hpp"),
|
||||
"kpgetter": (createKpGetter, "Implement the getters", "karts/kart_properties.cpp"),
|
||||
"loadXml": (createLoadXml, "Code to load the characteristics from an xml file", "karts/xml_characteristic.hpp"),
|
||||
"loadXml": (createLoadXml, "Code to load the characteristics from an xml file", "karts/xml_characteristic.cpp"),
|
||||
}
|
||||
|
||||
def main():
|
||||
|
Loading…
x
Reference in New Issue
Block a user