Converted bullet's TravelCM (i.e. in cm) into Travel (i.e. in m).

This commit is contained in:
hiker 2015-07-09 00:06:19 +10:00
parent aa7bf607bf
commit 3b9e85af0b
9 changed files with 27 additions and 27 deletions

View File

@ -386,11 +386,11 @@
<!-- Suspension related values. stiffness: kart's suspension stiffness.
rest: Length of suspension when at rest.
travel-cm: maximum movement of suspension - in cm!!
travel: maximum movement of suspension!!
exp-string-response: dampen the suspension spring reaction
exponentially.
max-force: Maximum suspension force -->
<suspension stiffness="140" rest="0.3" travel-cm="29"
<suspension stiffness="140" rest="0.3" travel="29"
exp-spring-response="false" max-force="12000"/>
<!-- Wheel related parameters: damping-relaxation/compression: for

View File

@ -77,7 +77,7 @@ btWheelInfo& btRaycastVehicle::addWheel( const btVector3& connectionPointCS, con
ci.m_wheelsDampingRelaxation = tuning.m_suspensionDamping;
ci.m_frictionSlip = tuning.m_frictionSlip;
ci.m_bIsFrontWheel = isFrontWheel;
ci.m_maxSuspensionTravelCm = tuning.m_maxSuspensionTravelCm;
ci.m_maxSuspensionTravel = tuning.m_maxSuspensionTravel;
ci.m_maxSuspensionForce = tuning.m_maxSuspensionForce;
m_wheelInfo.push_back( btWheelInfo(ci));
@ -203,8 +203,8 @@ btScalar btRaycastVehicle::rayCast(btWheelInfo& wheel)
wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelsRadius;
//clamp on max suspension travel
btScalar minSuspensionLength = wheel.getSuspensionRestLength() - wheel.m_maxSuspensionTravelCm*btScalar(0.01);
btScalar maxSuspensionLength = wheel.getSuspensionRestLength()+ wheel.m_maxSuspensionTravelCm*btScalar(0.01);
btScalar minSuspensionLength = wheel.getSuspensionRestLength() - wheel.m_maxSuspensionTravel;
btScalar maxSuspensionLength = wheel.getSuspensionRestLength()+ wheel.m_maxSuspensionTravel;
if (wheel.m_raycastInfo.m_suspensionLength < minSuspensionLength)
{
wheel.m_raycastInfo.m_suspensionLength = minSuspensionLength;

View File

@ -43,7 +43,7 @@ public:
:m_suspensionStiffness(btScalar(5.88)),
m_suspensionCompression(btScalar(0.83)),
m_suspensionDamping(btScalar(0.88)),
m_maxSuspensionTravelCm(btScalar(500.)),
m_maxSuspensionTravel(btScalar(5.)),
m_frictionSlip(btScalar(10.5)),
m_maxSuspensionForce(btScalar(6000.))
{
@ -51,7 +51,7 @@ public:
btScalar m_suspensionStiffness;
btScalar m_suspensionCompression;
btScalar m_suspensionDamping;
btScalar m_maxSuspensionTravelCm;
btScalar m_maxSuspensionTravel;
btScalar m_frictionSlip;
btScalar m_maxSuspensionForce;

View File

@ -22,7 +22,7 @@ struct btWheelInfoConstructionInfo
btVector3 m_wheelDirectionCS;
btVector3 m_wheelAxleCS;
btScalar m_suspensionRestLength;
btScalar m_maxSuspensionTravelCm;
btScalar m_maxSuspensionTravel;
btScalar m_wheelRadius;
btScalar m_suspensionStiffness;
@ -59,7 +59,7 @@ struct btWheelInfo
btVector3 m_wheelDirectionCS;//const
btVector3 m_wheelAxleCS; // const or modified by steering
btScalar m_suspensionRestLength1;//const
btScalar m_maxSuspensionTravelCm;
btScalar m_maxSuspensionTravel;
btScalar getSuspensionRestLength() const;
btScalar m_wheelsRadius;//const
btScalar m_suspensionStiffness;//const
@ -87,7 +87,7 @@ struct btWheelInfo
{
m_suspensionRestLength1 = ci.m_suspensionRestLength;
m_maxSuspensionTravelCm = ci.m_maxSuspensionTravelCm;
m_maxSuspensionTravel = ci.m_maxSuspensionTravel;
m_wheelsRadius = ci.m_wheelRadius;
m_suspensionStiffness = ci.m_suspensionStiffness;

View File

@ -690,8 +690,8 @@ void Kart::createPhysics()
btVector3 wheel_axle(-1.0f, 0.0f, 0.0f);
btKart::btVehicleTuning tuning;
tuning.m_maxSuspensionTravelCm =
m_kart_properties->getSuspensionTravelCM();
tuning.m_maxSuspensionTravel =
m_kart_properties->getSuspensionTravel();
tuning.m_maxSuspensionForce =
m_kart_properties->getMaxSuspensionForce();
@ -2132,11 +2132,11 @@ void Kart::updatePhysics(float dt)
// Only apply if near ground instead of purely based on speed avoiding
// the "parachute on top" look.
const Vec3 &v = m_body->getLinearVelocity();
if(/*isNearGround() &&*/ v.getY() < - m_kart_properties->getSuspensionTravelCM()*0.01f*60)
if(/*isNearGround() &&*/ v.getY() < - m_kart_properties->getSuspensionTravel()*60)
{
Vec3 v_clamped = v;
// clamp the speed to 99% of the maxium falling speed.
v_clamped.setY(-m_kart_properties->getSuspensionTravelCM()*0.01f*60 * 0.99f);
v_clamped.setY(-m_kart_properties->getSuspensionTravel()*60 * 0.99f);
//m_body->setLinearVelocity(v_clamped);
}

View File

@ -74,7 +74,7 @@ KartProperties::KartProperties(const std::string &filename)
m_chassis_angular_damping = m_suspension_rest =
m_max_speed_reverse_ratio = m_rescue_vert_offset =
m_collision_terrain_impulse = m_collision_impulse = m_restitution =
m_collision_impulse_time = m_suspension_travel_cm =
m_collision_impulse_time = m_suspension_travel =
m_track_connection_accel = m_rubber_band_max_length =
m_rubber_band_force = m_rubber_band_duration =
m_rubber_band_speed_increase = m_rubber_band_fade_out_time =
@ -283,9 +283,9 @@ void KartProperties::load(const std::string &filename, const std::string &node)
// Default: center at the very bottom of the kart.
// If the kart is 'too high', its height will be changed in
// kart.cpp, the same adjustment needs to be made here.
if (m_kart_model->getHeight() > m_kart_model->getLength()*0.6f)
// if (m_kart_model->getHeight() > m_kart_model->getLength()*0.6f)
m_gravity_center_shift.setY(m_kart_model->getLength()*0.6f*0.5f);
else
// else
m_gravity_center_shift.setY(m_kart_model->getHeight()*0.5f);
m_gravity_center_shift.setZ(0);
@ -363,7 +363,7 @@ void KartProperties::getAllData(const XMLNode * root)
{
suspension_node->get("stiffness", &m_suspension_stiffness);
suspension_node->get("rest", &m_suspension_rest );
suspension_node->get("travel-cm", &m_suspension_travel_cm);
suspension_node->get("travel", &m_suspension_travel );
suspension_node->get("exp-spring-response", &m_exp_spring_response );
suspension_node->get("max-force", &m_max_suspension_force);
}
@ -700,7 +700,7 @@ void KartProperties::checkAllSet(const std::string &filename)
CHECK_NEG(m_brake_time_increase, "engine brake-time-increase" );
CHECK_NEG(m_suspension_stiffness, "suspension stiffness" );
CHECK_NEG(m_suspension_rest, "suspension rest" );
CHECK_NEG(m_suspension_travel_cm, "suspension travel-cm" );
CHECK_NEG(m_suspension_travel, "suspension travel" );
CHECK_NEG(m_max_suspension_force, "suspension max-force" );
CHECK_NEG(m_collision_impulse, "collision impulse" );
CHECK_NEG(m_collision_impulse_time, "collision impulse-time" );

View File

@ -324,7 +324,7 @@ private:
bool m_exp_spring_response;
float m_suspension_rest;
float m_suspension_travel_cm;
float m_suspension_travel;
public:
/** STK can add an impulse to push karts away from the track in case
@ -685,7 +685,7 @@ public:
// ------------------------------------------------------------------------
/** Returns the amount the suspension can extend. */
float getSuspensionTravelCM () const {return m_suspension_travel_cm; }
float getSuspensionTravel () const {return m_suspension_travel; }
// ------------------------------------------------------------------------
/** Returns if the spring should be exponentially dampened. */

View File

@ -83,7 +83,7 @@ btWheelInfo& btKart::addWheel(const btVector3& connectionPointCS,
ci.m_wheelsDampingCompression = tuning.m_suspensionCompression;
ci.m_wheelsDampingRelaxation = tuning.m_suspensionDamping;
ci.m_frictionSlip = tuning.m_frictionSlip;
ci.m_maxSuspensionTravelCm = tuning.m_maxSuspensionTravelCm;
ci.m_maxSuspensionTravel = tuning.m_maxSuspensionTravel;
ci.m_maxSuspensionForce = tuning.m_maxSuspensionForce;
m_wheelInfo.push_back( btWheelInfo(ci));
@ -236,7 +236,7 @@ btScalar btKart::rayCast(unsigned int index)
updateWheelTransformsWS( wheel,false);
btScalar max_susp_len = wheel.getSuspensionRestLength()+wheel.m_wheelsRadius
+ wheel.m_maxSuspensionTravelCm*0.01f;
+ wheel.m_maxSuspensionTravel;
// Do a slightly longer raycast to see if the kart might soon hit the
// ground and some 'cushioning' is needed to avoid that the chassis
@ -270,9 +270,9 @@ btScalar btKart::rayCast(unsigned int index)
//clamp on max suspension travel
btScalar minSuspensionLength = wheel.getSuspensionRestLength()
- wheel.m_maxSuspensionTravelCm*btScalar(0.01);
- wheel.m_maxSuspensionTravel;
btScalar maxSuspensionLength = wheel.getSuspensionRestLength()
+ wheel.m_maxSuspensionTravelCm*btScalar(0.01);
+ wheel.m_maxSuspensionTravel;
if (wheel.m_raycastInfo.m_suspensionLength < minSuspensionLength)
{
wheel.m_raycastInfo.m_suspensionLength = minSuspensionLength;

View File

@ -37,7 +37,7 @@ public:
:m_suspensionStiffness(btScalar(5.88)),
m_suspensionCompression(btScalar(0.83)),
m_suspensionDamping(btScalar(0.88)),
m_maxSuspensionTravelCm(btScalar(500.)),
m_maxSuspensionTravel(btScalar(5.)),
m_frictionSlip(btScalar(10.5)),
m_maxSuspensionForce(btScalar(6000.))
{
@ -46,7 +46,7 @@ public:
btScalar m_suspensionStiffness;
btScalar m_suspensionCompression;
btScalar m_suspensionDamping;
btScalar m_maxSuspensionTravelCm;
btScalar m_maxSuspensionTravel;
btScalar m_frictionSlip;
btScalar m_maxSuspensionForce;