Merge branch 'physics-tweaks'

This commit is contained in:
hiker 2017-04-06 00:06:22 +10:00
commit 96bdf77050
19 changed files with 182 additions and 103 deletions

View File

@ -34,7 +34,7 @@
http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7369\&p=25236&hilit=vehicle#p25236
for details.
max-force: Maximum suspension force -->
<suspension stiffness="140" rest="0.3" travel="0.29"
<suspension stiffness="280" rest="0.3" travel="0.29"
exp-spring-response="false" max-force="12000" />
<!-- Values related to stability of the chassis: damping, and reduced
@ -45,6 +45,9 @@
the ground if its off ground. Reduces the affect if a kart loses
contact with the ground (i.e. it then can't steer or accelerate
anymore).
angular-factor: Factor to change angular impulses. X and Z rotations
are damped to avoid that karts in a collision are too easily pushed
into a roll or pitch, which makes them topple over
smooth-flying-impulse: apply a torque impulse to flying kart to keep
them parallel to the ground. -->
<stability roll-influence="0.3"
@ -52,6 +55,7 @@
chassis-angular-damping="0"
downward-impulse-factor="5"
track-connection-accel="2"
angular-factor="0.5 1.0 0.5"
smooth-flying-impulse="250" />
<!-- Turning
@ -120,6 +124,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.0" />
<!-- ********** Visuals ********** -->

View File

@ -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"/>

View File

@ -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"))

View File

@ -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

View File

@ -74,6 +74,8 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(
return TYPE_FLOAT;
case STABILITY_TRACK_CONNECTION_ACCEL:
return TYPE_FLOAT;
case STABILITY_ANGULAR_FACTOR:
return TYPE_FLOAT_VECTOR;
case STABILITY_SMOOTH_FLYING_IMPULSE:
return TYPE_FLOAT;
case TURN_RADIUS:
@ -136,6 +138,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:
@ -302,6 +306,8 @@ std::string AbstractCharacteristic::getName(CharacteristicType type)
return "STABILITY_DOWNWARD_IMPULSE_FACTOR";
case STABILITY_TRACK_CONNECTION_ACCEL:
return "STABILITY_TRACK_CONNECTION_ACCEL";
case STABILITY_ANGULAR_FACTOR:
return "STABILITY_ANGULAR_FACTOR";
case STABILITY_SMOOTH_FLYING_IMPULSE:
return "STABILITY_SMOOTH_FLYING_IMPULSE";
case TURN_RADIUS:
@ -364,6 +370,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:
@ -622,6 +630,18 @@ float AbstractCharacteristic::getStabilityTrackConnectionAccel() const
return result;
} // getStabilityTrackConnectionAccel
// ----------------------------------------------------------------------------
std::vector<float> AbstractCharacteristic::getStabilityAngularFactor() const
{
std::vector<float> result;
bool is_set = false;
process(STABILITY_ANGULAR_FACTOR, &result, &is_set);
if (!is_set)
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
getName(STABILITY_ANGULAR_FACTOR).c_str());
return result;
} // getStabilityAngularFactor
// ----------------------------------------------------------------------------
float AbstractCharacteristic::getStabilitySmoothFlyingImpulse() const
{
@ -994,6 +1014,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
{

View File

@ -84,6 +84,7 @@ public:
STABILITY_CHASSIS_ANGULAR_DAMPING,
STABILITY_DOWNWARD_IMPULSE_FACTOR,
STABILITY_TRACK_CONNECTION_ACCEL,
STABILITY_ANGULAR_FACTOR,
STABILITY_SMOOTH_FLYING_IMPULSE,
// Turn
@ -136,6 +137,9 @@ public:
PARACHUTE_UBOUND_FRACTION,
PARACHUTE_MAX_SPEED,
// Friction
FRICTION_KART_FRICTION,
// Bubblegum
BUBBLEGUM_DURATION,
BUBBLEGUM_SPEED_FRACTION,
@ -266,6 +270,7 @@ public:
float getStabilityChassisAngularDamping() const;
float getStabilityDownwardImpulseFactor() const;
float getStabilityTrackConnectionAccel() const;
std::vector<float> getStabilityAngularFactor() const;
float getStabilitySmoothFlyingImpulse() const;
InterpolationArray getTurnRadius() const;
@ -308,6 +313,8 @@ public:
float getParachuteUboundFraction() const;
float getParachuteMaxSpeed() const;
float getFrictionKartFriction() const;
float getBubblegumDuration() const;
float getBubblegumSpeedFraction() const;
float getBubblegumTorque() const;

View File

@ -174,6 +174,7 @@ void CannonAnimation::update(float dt)
AbstractKartAnimation::update(dt);
return;
}
AbstractKartAnimation::update(dt);
// First compute the current rotation
// ==================================
@ -241,11 +242,14 @@ void CannonAnimation::update(float dt)
// transform it to the global coordinate system
Vec3 horiz_delta = Vec3(0.5f*m_fraction_of_line * f_current_width, 0, 0);
Vec3 rotated_delta = quatRotate(all_heading, m_delta + horiz_delta);
// Determine direction orthogonal to the curve for the sideway movement
// of the kart.
Vec3 sideways = gravity.cross(tangent);
Vec3 rotated_delta = sideways*(0.5f*m_fraction_of_line * f_current_width)
+ quatRotate(all_heading, m_delta);
Vec3 curve_xyz;
m_curve->update(dt, &curve_xyz);
m_kart->setXYZ(curve_xyz+rotated_delta);
AbstractKartAnimation::update(dt);
} // update

View File

@ -668,6 +668,11 @@ void Kart::createPhysics()
trans.setIdentity();
createBody(mass, trans, &m_kart_chassis,
m_kart_properties->getRestitution());
std::vector<float> ang_fact = m_kart_properties->getStabilityAngularFactor();
// The angular factor (with X and Z values <1) helps to keep the kart
// upright, especially in case of a collision.
m_body->setAngularFactor(Vec3(ang_fact[0], ang_fact[1], ang_fact[2]));
m_body->setFriction(m_kart_properties->getFrictionKartFriction());
m_user_pointer.set(this);
m_body->setDamping(m_kart_properties->getStabilityChassisLinearDamping(),
m_kart_properties->getStabilityChassisAngularDamping() );
@ -2043,7 +2048,10 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
impulse *= ( abs_speed<10 ? 10.0f : sqrt(abs_speed) )
* m_kart_properties->getCollisionTerrainImpulse();
m_bounce_back_time = 0.2f;
m_vehicle->setTimedCentralImpulse(0.1f, impulse);
m_bounce_back_time = 0.0f;;
impulse = Vec3(0, 0, 0);
//m_vehicle->setTimedCentralImpulse(0.1f, impulse);
m_vehicle->setTimedCentralImpulse(0.0, impulse);
}
// If there is a quad graph, push the kart towards the previous
// graph node center (we have to use the previous point since the
@ -2455,31 +2463,44 @@ void Kart::updateEnginePowerAndBrakes(float dt)
// ----------------------------------------------------------------------------
/** Handles sliding, i.e. the kart sliding off terrain that is too steep.
* Dynamically determine friction so that the kart looses its traction
* when trying to drive on too steep surfaces. Below angles of 0.25 rad,
* you have full traction; above 0.5 rad angles you have absolutely none;
* inbetween there is a linear change in friction. This is done for each
* wheel individually (since otherwise karts were still able with enough
* speed to drive on walls - one wheel 'on a wall' would not tilt the
* kart chassis enough to trigger sliding, but since that wheel had still
* full friction, give the kart an upwards velocity).
*/
void Kart::updateSliding()
{
// dynamically determine friction so that the kart looses its traction
// when trying to drive on too steep surfaces. Below angles of 0.25 rad,
// you have full traction; above 0.5 rad angles you have absolutely none;
// inbetween there is a linear change in friction
float friction = 1.0f;
bool enable_sliding = false;
// This way the current handling of sliding can be disabled
// for certain material (e.g. the curve in skyline on which otherwise
// karts could not drive).
// We also had a crash reported here, which was caused by not
// having a material here - no idea how this could have happened,
// but this problem is now avoided by testing if there is a material
if (isOnGround() &&
(!getMaterial() || !getMaterial()->highTireAdhesion()))
// Allow the sliding to be disabled per material (for so called
// high adhesion material), which is useful for e.g. banked curves.
// We don't have per-wheel material, so the test for special material
// with high adhesion is done per kart (not per wheel).
const Material * material = getMaterial();
if (material && material->highTireAdhesion())
{
const btMatrix3x3 &m = m_vehicle->getChassisWorldTransform().getBasis();
// To get the angle between up=(0,1,0), we have to do:
// m*(0,1,0) to get the up vector of the kart, then the
// scalar product between this and (0,1,0) - which is m[1][1]:
float distanceFromUp = m[1][1];
for (int i = 0; i < m_vehicle->getNumWheels(); i++)
{
btWheelInfo &wheel = m_vehicle->getWheelInfo(i);
wheel.m_frictionSlip = m_kart_properties->getFrictionSlip();
}
m_vehicle->setSliding(false);
return;
}
// Now test for each wheel if it should be sliding
// -----------------------------------------------
bool enable_sliding = false;
for (int i = 0; i < m_vehicle->getNumWheels(); i++)
{
const btWheelInfo &wheel = m_vehicle->getWheelInfo(i);
if (!wheel.m_raycastInfo.m_isInContact) continue;
const btVector3 &norm = m_vehicle->getWheelInfo(i).m_raycastInfo.m_contactNormalWS;
float distanceFromUp = norm.dot(getNormal());
float friction;
if (distanceFromUp < 0.85f)
{
friction = 0.0f;
@ -2494,13 +2515,8 @@ void Kart::updateSliding()
friction = (distanceFromUp - 0.85f) / 0.5f;
enable_sliding = true;
}
}
for (unsigned int i=0; i<4; i++)
{
btWheelInfo& wheel = m_vehicle->getWheelInfo(i);
wheel.m_frictionSlip = friction*m_kart_properties->getFrictionSlip();
}
m_vehicle->getWheelInfo(i).m_frictionSlip = friction * m_kart_properties->getFrictionSlip();
} // for i < numWheels
m_vehicle->setSliding(enable_sliding);
} // updateSliding

View File

@ -597,6 +597,12 @@ float KartProperties::getStabilityTrackConnectionAccel() const
return m_cached_characteristic->getStabilityTrackConnectionAccel();
} // getStabilityTrackConnectionAccel
// ----------------------------------------------------------------------------
std::vector<float> KartProperties::getStabilityAngularFactor() const
{
return m_cached_characteristic->getStabilityAngularFactor();
} // getStabilityAngularFactor
// ----------------------------------------------------------------------------
float KartProperties::getStabilitySmoothFlyingImpulse() const
{
@ -783,6 +789,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
{

View File

@ -431,6 +431,7 @@ public:
float getStabilityChassisAngularDamping() const;
float getStabilityDownwardImpulseFactor() const;
float getStabilityTrackConnectionAccel() const;
std::vector<float> getStabilityAngularFactor() const;
float getStabilitySmoothFlyingImpulse() const;
InterpolationArray getTurnRadius() const;
@ -473,6 +474,8 @@ public:
float getParachuteUboundFraction() const;
float getParachuteMaxSpeed() const;
float getFrictionKartFriction() const;
float getBubblegumDuration() const;
float getBubblegumSpeedFraction() const;
float getBubblegumTorque() const;

View File

@ -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
// ------------------------

View File

@ -343,6 +343,8 @@ void XmlCharacteristic::load(const XMLNode *node)
&m_values[STABILITY_DOWNWARD_IMPULSE_FACTOR]);
sub_node->get("track-connection-accel",
&m_values[STABILITY_TRACK_CONNECTION_ACCEL]);
sub_node->get("angular-factor",
&m_values[STABILITY_ANGULAR_FACTOR]);
sub_node->get("smooth-flying-impulse",
&m_values[STABILITY_SMOOTH_FLYING_IMPULSE]);
}
@ -447,6 +449,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",

View File

@ -192,7 +192,8 @@ void btKart::resetSuspension()
// ----------------------------------------------------------------------------
void btKart::updateWheelTransformsWS(btWheelInfo& wheel,
bool interpolatedTransform)
bool interpolatedTransform,
float fraction)
{
wheel.m_raycastInfo.m_isInContact = false;
@ -203,7 +204,7 @@ void btKart::updateWheelTransformsWS(btWheelInfo& wheel,
}
wheel.m_raycastInfo.m_hardPointWS =
chassisTrans( wheel.m_chassisConnectionPointCS );
chassisTrans( wheel.m_chassisConnectionPointCS*fraction );
wheel.m_raycastInfo.m_wheelDirectionWS = chassisTrans.getBasis() *
wheel.m_wheelDirectionCS ;
wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.getBasis() *
@ -213,7 +214,7 @@ void btKart::updateWheelTransformsWS(btWheelInfo& wheel,
// ----------------------------------------------------------------------------
/**
*/
btScalar btKart::rayCast(unsigned int index)
btScalar btKart::rayCast(unsigned int index, float fraction)
{
btWheelInfo &wheel = m_wheelInfo[index];
@ -229,7 +230,7 @@ btScalar btKart::rayCast(unsigned int index)
m_chassisBody->getBroadphaseHandle()->m_collisionFilterGroup = 0;
}
updateWheelTransformsWS( wheel,false);
updateWheelTransformsWS( wheel,false, fraction);
btScalar max_susp_len = wheel.getSuspensionRestLength()
+ wheel.m_maxSuspensionTravel;
@ -391,6 +392,16 @@ void btKart::updateVehicle( btScalar step )
rayCast( i);
if(m_wheelInfo[i].m_raycastInfo.m_isInContact)
m_num_wheels_on_ground++;
else
{
// If the original raycast did not hit the ground,
// try a little bit (5%) closer to the centre of the chassis.
// Some tracks have very minor gaps that would otherwise
// trigger odd physical behaviour.
rayCast(i, 0.95f);
if (m_wheelInfo[i].m_raycastInfo.m_isInContact)
m_num_wheels_on_ground++;
}
}
// Test if the kart is falling so fast
@ -464,33 +475,6 @@ void btKart::updateVehicle( btScalar step )
// Give a nicely balanced feeling for rebalancing the kart
m_chassisBody->applyTorqueImpulse(axis * m_kart->getKartProperties()->getStabilitySmoothFlyingImpulse());
}
// Work around: make sure that either both wheels on one axis
// are on ground, or none of them. This avoids the problem of
// the kart suddenly getting additional angular velocity because
// e.g. only one rear wheel is on the ground and then the kart
// rotates very abruptly.
for(int i=0; i<m_wheelInfo.size(); i+=2)
{
if( m_wheelInfo[i ].m_raycastInfo.m_isInContact !=
m_wheelInfo[i+1].m_raycastInfo.m_isInContact)
{
int wheel_air_index = i;
int wheel_ground_index = i+1;
if (m_wheelInfo[i].m_raycastInfo.m_isInContact)
{
wheel_air_index = i+1;
wheel_ground_index = i;
}
btWheelInfo& wheel_air = m_wheelInfo[wheel_air_index];
btWheelInfo& wheel_ground = m_wheelInfo[wheel_ground_index];
wheel_air.m_raycastInfo = wheel_ground.m_raycastInfo;
}
} // for i=0; i<m_wheelInfo.size(); i+=2
// Apply suspension forcen (i.e. upwards force)
// --------------------------------------------
@ -520,28 +504,6 @@ void btKart::updateVehicle( btScalar step )
// ------------------------------------
updateFriction( step);
for (int i=0;i<m_wheelInfo.size();i++)
{
btWheelInfo& wheel = m_wheelInfo[i];
//btVector3 relpos = wheel.m_raycastInfo.m_hardPointWS
// - getRigidBody()->getCenterOfMassPosition();
//btVector3 vel = getRigidBody()->getVelocityInLocalPoint(relpos);
if (wheel.m_raycastInfo.m_isInContact)
{
const btTransform& chassisWorldTransform =
getChassisWorldTransform();
btVector3 fwd (
chassisWorldTransform.getBasis()[0][m_indexForwardAxis],
chassisWorldTransform.getBasis()[1][m_indexForwardAxis],
chassisWorldTransform.getBasis()[2][m_indexForwardAxis]);
btScalar proj = fwd.dot(wheel.m_raycastInfo.m_contactNormalWS);
fwd -= wheel.m_raycastInfo.m_contactNormalWS * proj;
}
}
// If configured, add a force to keep karts on the track
// -----------------------------------------------------
float dif = m_kart->getKartProperties()->getStabilityDownwardImpulseFactor();
@ -669,13 +631,6 @@ void btKart::updateSuspension(btScalar deltaTime)
btScalar length_diff = (susp_length - current_length);
if(m_kart->getKartProperties()->getSuspensionExpSpringResponse())
length_diff *= fabsf(length_diff)/susp_length;
float f = (1.0f + fabsf(length_diff) / susp_length);
// Scale the length diff. This results that in uphill sections, when
// the suspension is more compressed (i.e. length is bigger), more
// force is used, which makes it much less likely for the kart to hit
// the terrain, while when driving on flat terrain (length small),
// there is hardly any difference
length_diff *= f*f;
force = wheel_info.m_suspensionStiffness * length_diff
* wheel_info.m_clippedInvContactDotSuspension;

View File

@ -150,7 +150,7 @@ public:
void reset();
void debugDraw(btIDebugDraw* debugDrawer);
const btTransform& getChassisWorldTransform() const;
btScalar rayCast(unsigned int index);
btScalar rayCast(unsigned int index, float fraction=1.0f);
virtual void updateVehicle(btScalar step);
void resetSuspension();
btScalar getSteeringValue(int wheel) const;
@ -169,7 +169,8 @@ public:
const btWheelInfo& getWheelInfo(int index) const;
btWheelInfo& getWheelInfo(int index);
void updateWheelTransformsWS(btWheelInfo& wheel,
bool interpolatedTransform=true);
bool interpolatedTransform=true,
float fraction = 1.0f);
void setAllBrakes(btScalar brake);
void updateSuspension(btScalar deltaTime);
virtual void updateFriction(btScalar timeStep);

View File

@ -174,10 +174,13 @@ void TriangleMesh::createCollisionShape(bool create_collision_object, const char
* removed and all objects together with the track is converted again into
* a single rigid body. This avoids using irrlicht (or the graphics engine)
* for height of terrain detection).
* @param serializedBhv if non-NULL, the bhv is deserialized instead of
* \param friction Friction to be used for this TriangleMesh.
* \param flags Additional collision flags (default 0).
* \param serializedBhv if non-NULL, the bhv is deserialized instead of
* being calculated on the fly
*/
void TriangleMesh::createPhysicalBody(btCollisionObject::CollisionFlags flags,
void TriangleMesh::createPhysicalBody(float friction,
btCollisionObject::CollisionFlags flags,
const char* serializedBhv)
{
// We need the collision shape, but not the collision object (since
@ -189,6 +192,8 @@ void TriangleMesh::createPhysicalBody(btCollisionObject::CollisionFlags flags,
btRigidBody::btRigidBodyConstructionInfo info(0.0f, m_motion_state,
m_collision_shape);
info.m_restitution = 0.8f;
info.m_friction = friction;
m_body=new btRigidBody(info);
Physics::getInstance()->addBody(m_body);

View File

@ -57,7 +57,8 @@ public:
const btVector3 &n2, const btVector3 &n3,
const Material* m);
void createCollisionShape(bool create_collision_object=true, const char* serialized_bhv=NULL);
void createPhysicalBody(btCollisionObject::CollisionFlags flags=
void createPhysicalBody(float friction,
btCollisionObject::CollisionFlags flags=
(btCollisionObject::CollisionFlags)0,
const char* serializedBhv = NULL);
void removeAll();

View File

@ -480,6 +480,7 @@ void Track::loadTrackInfo()
m_fog_height_start = 0.0f;
m_fog_height_end = 100.0f;
m_gravity = 9.80665f;
m_friction = stk_config->m_default_track_friction;
m_smooth_normals = false;
m_godrays = false;
m_godrays_opacity = 1.0f;
@ -514,6 +515,7 @@ void Track::loadTrackInfo()
getMusicInformation(filenames, m_music);
root->get("screenshot", &m_screenshot);
root->get("gravity", &m_gravity);
root->get("friction", &m_friction);
root->get("soccer", &m_is_soccer);
root->get("arena", &m_is_arena);
root->get("max-arena-players", &m_max_arena_players);
@ -836,7 +838,7 @@ void Track::createPhysicsModel(unsigned int main_track_count)
{
convertTrackToBullet(m_all_nodes[i]);
}
m_track_mesh->createPhysicalBody();
m_track_mesh->createPhysicalBody(m_friction);
m_gfx_effect_mesh->createCollisionShape();
} // createPhysicsModel

View File

@ -104,7 +104,12 @@ private:
unsigned int m_magic_number;
#endif
/* Gravity to be used for this track. */
float m_gravity;
/** Friction to be used for the track. */
float m_friction;
std::string m_ident;
std::string m_screenshot;
bool m_is_day;

View File

@ -28,7 +28,7 @@ import sys
# Each line contains a topic and the attributes of that topic.
# This model is used for the xml file and to access the kart properties in the code.
characteristics = """Suspension: stiffness, rest, travel, expSpringResponse(bool), maxForce
Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse
Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, angularFactor(std::vector<float>/floatVector), smoothFlyingImpulse
Turn: radius(InterpolationArray), timeResetSteer, timeFullSteer(InterpolationArray)
Engine: power, maxSpeed, brakeFactor, brakeTimeIncrease, maxSpeedReverseRatio
Gear: switchRatio(std::vector<float>/floatVector), powerIncrease(std::vector<float>/floatVector)
@ -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():