1) Fixed AIs.
2) Changed steering (m_steer positive is now steering left, negative right). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/switch_coordinate_system@4981 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c849e91221
commit
8dfcd28e44
@ -804,13 +804,13 @@ float DefaultAIController::steerToPoint(const Vec3 &point, float dt)
|
|||||||
const float dx = point.getX() - m_kart->getXYZ().getX();
|
const float dx = point.getX() - m_kart->getXYZ().getX();
|
||||||
const float dz = point.getZ() - m_kart->getXYZ().getZ();
|
const float dz = point.getZ() - m_kart->getXYZ().getZ();
|
||||||
/** Angle from the kart position to the point in world coordinates. */
|
/** Angle from the kart position to the point in world coordinates. */
|
||||||
float theta = -atan2(dx, dz);
|
float theta = atan2(dx, dz);
|
||||||
|
|
||||||
// Angle is the point is relative to the heading - but take the current
|
// Angle is the point is relative to the heading - but take the current
|
||||||
// angular velocity into account, too. The value is multiplied by two
|
// angular velocity into account, too. The value is multiplied by two
|
||||||
// to avoid 'oversteering' - experimentally found.
|
// to avoid 'oversteering' - experimentally found.
|
||||||
float angle_2_point = theta - m_kart->getHeading()
|
float angle_2_point = theta - m_kart->getHeading()
|
||||||
- dt*m_kart->getBody()->getAngularVelocity().getZ()*2.0f;
|
- dt*m_kart->getBody()->getAngularVelocity().getY()*2.0f;
|
||||||
angle_2_point = normalizeAngle(angle_2_point);
|
angle_2_point = normalizeAngle(angle_2_point);
|
||||||
if(fabsf(angle_2_point)<0.1) return 0.0f;
|
if(fabsf(angle_2_point)<0.1) return 0.0f;
|
||||||
|
|
||||||
@ -830,7 +830,7 @@ float DefaultAIController::steerToPoint(const Vec3 &point, float dt)
|
|||||||
float sin_steer_angle = m_kart->getKartProperties()->getWheelBase()/radius;
|
float sin_steer_angle = m_kart->getKartProperties()->getWheelBase()/radius;
|
||||||
#ifdef DEBUG_OUTPUT
|
#ifdef DEBUG_OUTPUT
|
||||||
printf("theta %f a2p %f angularv %f radius %f ssa %f\n",
|
printf("theta %f a2p %f angularv %f radius %f ssa %f\n",
|
||||||
theta, angle_2_point, m_body->getAngularVelocity().getZ(),
|
theta, angle_2_point, m_body->getAngularVelocity().getY(),
|
||||||
radius, sin_steer_angle);
|
radius, sin_steer_angle);
|
||||||
#endif
|
#endif
|
||||||
// Add 0.1 since rouding errors will otherwise result in the kart
|
// Add 0.1 since rouding errors will otherwise result in the kart
|
||||||
|
@ -325,15 +325,15 @@ float EndController::steerToPoint(const Vec3 &point, float dt)
|
|||||||
// No sense steering if we are not driving.
|
// No sense steering if we are not driving.
|
||||||
if(m_kart->getSpeed()==0) return 0.0f;
|
if(m_kart->getSpeed()==0) return 0.0f;
|
||||||
const float dx = point.getX() - m_kart->getXYZ().getX();
|
const float dx = point.getX() - m_kart->getXYZ().getX();
|
||||||
const float dy = point.getY() - m_kart->getXYZ().getY();
|
const float dz = point.getZ() - m_kart->getXYZ().getZ();
|
||||||
/** Angle from the kart position to the point in world coordinates. */
|
/** Angle from the kart position to the point in world coordinates. */
|
||||||
float theta = -atan2(dx, dy);
|
float theta = atan2(dx, dz);
|
||||||
|
|
||||||
// Angle is the point is relative to the heading - but take the current
|
// Angle is the point is relative to the heading - but take the current
|
||||||
// angular velocity into account, too. The value is multiplied by two
|
// angular velocity into account, too. The value is multiplied by two
|
||||||
// to avoid 'oversteering' - experimentally found.
|
// to avoid 'oversteering' - experimentally found.
|
||||||
float angle_2_point = theta - m_kart->getHeading()
|
float angle_2_point = theta - m_kart->getHeading()
|
||||||
- dt*m_kart->getBody()->getAngularVelocity().getZ()*2.0f;
|
- dt*m_kart->getBody()->getAngularVelocity().getY()*2.0f;
|
||||||
angle_2_point = normalizeAngle(angle_2_point);
|
angle_2_point = normalizeAngle(angle_2_point);
|
||||||
if(fabsf(angle_2_point)<0.1) return 0.0f;
|
if(fabsf(angle_2_point)<0.1) return 0.0f;
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ float EndController::steerToPoint(const Vec3 &point, float dt)
|
|||||||
float sin_steer_angle = m_kart->getKartProperties()->getWheelBase()/radius;
|
float sin_steer_angle = m_kart->getKartProperties()->getWheelBase()/radius;
|
||||||
#ifdef DEBUG_OUTPUT
|
#ifdef DEBUG_OUTPUT
|
||||||
printf("theta %f a2p %f angularv %f radius %f ssa %f\n",
|
printf("theta %f a2p %f angularv %f radius %f ssa %f\n",
|
||||||
theta, angle_2_point, m_body->getAngularVelocity().getZ(),
|
theta, angle_2_point, m_body->getAngularVelocity().getY(),
|
||||||
radius, sin_steer_angle);
|
radius, sin_steer_angle);
|
||||||
#endif
|
#endif
|
||||||
// Add 0.1 since rouding errors will otherwise result in the kart
|
// Add 0.1 since rouding errors will otherwise result in the kart
|
||||||
@ -463,7 +463,7 @@ inline float EndController::normalizeAngle(float angle)
|
|||||||
*/
|
*/
|
||||||
int EndController::calcSteps()
|
int EndController::calcSteps()
|
||||||
{
|
{
|
||||||
int steps = int( m_kart->getVelocityLC().getY() / m_kart_length );
|
int steps = int( m_kart->getVelocityLC().getZ() / m_kart_length );
|
||||||
if( steps < m_min_steps ) steps = m_min_steps;
|
if( steps < m_min_steps ) steps = m_min_steps;
|
||||||
|
|
||||||
//Increase the steps depending on the width, if we steering hard,
|
//Increase the steps depending on the width, if we steering hard,
|
||||||
@ -537,7 +537,7 @@ void EndController::findCurve()
|
|||||||
{
|
{
|
||||||
float total_dist = 0.0f;
|
float total_dist = 0.0f;
|
||||||
int i;
|
int i;
|
||||||
for(i = m_track_node; total_dist < m_kart->getVelocityLC().getY();
|
for(i = m_track_node; total_dist < m_kart->getVelocityLC().getZ();
|
||||||
i = m_next_node_index[i])
|
i = m_next_node_index[i])
|
||||||
{
|
{
|
||||||
total_dist += m_quad_graph->getDistanceToNext(i, m_successor_index[i]);
|
total_dist += m_quad_graph->getDistanceToNext(i, m_successor_index[i]);
|
||||||
|
@ -295,7 +295,7 @@ void NewAIController::handleBraking()
|
|||||||
//We may brake if we are about to get out of the road, but only if the
|
//We may brake if we are about to get out of the road, but only if the
|
||||||
//kart is on top of the road, and if we won't slow down below a certain
|
//kart is on top of the road, and if we won't slow down below a certain
|
||||||
//limit.
|
//limit.
|
||||||
if (m_crashes.m_road && m_kart->getVelocityLC().getY() > MIN_SPEED &&
|
if (m_crashes.m_road && m_kart->getVelocityLC().getZ() > MIN_SPEED &&
|
||||||
m_world->isOnRoad(m_kart->getWorldKartId()) )
|
m_world->isOnRoad(m_kart->getWorldKartId()) )
|
||||||
{
|
{
|
||||||
float kart_ang_diff =
|
float kart_ang_diff =
|
||||||
@ -337,7 +337,7 @@ void NewAIController::handleBraking()
|
|||||||
//Brake if the kart's speed is bigger than the speed we need
|
//Brake if the kart's speed is bigger than the speed we need
|
||||||
//to go through the curve at the widest angle, or if the kart
|
//to go through the curve at the widest angle, or if the kart
|
||||||
//is not going straight in relation to the road.
|
//is not going straight in relation to the road.
|
||||||
if(m_kart->getVelocityLC().getY() > m_curve_target_speed ||
|
if(m_kart->getVelocityLC().getZ() > m_curve_target_speed ||
|
||||||
kart_ang_diff > MIN_TRACK_ANGLE )
|
kart_ang_diff > MIN_TRACK_ANGLE )
|
||||||
{
|
{
|
||||||
#ifdef AI_DEBUG
|
#ifdef AI_DEBUG
|
||||||
@ -789,15 +789,15 @@ float NewAIController::steerToPoint(const Vec3 &point, float dt)
|
|||||||
// No sense steering if we are not driving.
|
// No sense steering if we are not driving.
|
||||||
if(m_kart->getSpeed()==0) return 0.0f;
|
if(m_kart->getSpeed()==0) return 0.0f;
|
||||||
const float dx = point.getX() - m_kart->getXYZ().getX();
|
const float dx = point.getX() - m_kart->getXYZ().getX();
|
||||||
const float dy = point.getY() - m_kart->getXYZ().getY();
|
const float dz = point.getZ() - m_kart->getXYZ().getZ();
|
||||||
/** Angle from the kart position to the point in world coordinates. */
|
/** Angle from the kart position to the point in world coordinates. */
|
||||||
float theta = -atan2(dx, dy);
|
float theta = atan2(dx, dz);
|
||||||
|
|
||||||
// Angle is the point is relative to the heading - but take the current
|
// Angle is the point is relative to the heading - but take the current
|
||||||
// angular velocity into account, too. The value is multiplied by two
|
// angular velocity into account, too. The value is multiplied by two
|
||||||
// to avoid 'oversteering' - experimentally found.
|
// to avoid 'oversteering' - experimentally found.
|
||||||
float angle_2_point = theta - m_kart->getHeading()
|
float angle_2_point = theta - m_kart->getHeading()
|
||||||
- dt*m_kart->getBody()->getAngularVelocity().getZ()*2.0f;
|
- dt*m_kart->getBody()->getAngularVelocity().getY()*2.0f;
|
||||||
angle_2_point = normalizeAngle(angle_2_point);
|
angle_2_point = normalizeAngle(angle_2_point);
|
||||||
if(fabsf(angle_2_point)<0.1) return 0.0f;
|
if(fabsf(angle_2_point)<0.1) return 0.0f;
|
||||||
|
|
||||||
@ -817,7 +817,7 @@ float NewAIController::steerToPoint(const Vec3 &point, float dt)
|
|||||||
float sin_steer_angle = m_kart->getKartProperties()->getWheelBase()/radius;
|
float sin_steer_angle = m_kart->getKartProperties()->getWheelBase()/radius;
|
||||||
#ifdef DEBUG_OUTPUT
|
#ifdef DEBUG_OUTPUT
|
||||||
printf("theta %f a2p %f angularv %f radius %f ssa %f\n",
|
printf("theta %f a2p %f angularv %f radius %f ssa %f\n",
|
||||||
theta, angle_2_point, m_body->getAngularVelocity().getZ(),
|
theta, angle_2_point, m_body->getAngularVelocity().getY(),
|
||||||
radius, sin_steer_angle);
|
radius, sin_steer_angle);
|
||||||
#endif
|
#endif
|
||||||
// Add 0.1 since rouding errors will otherwise result in the kart
|
// Add 0.1 since rouding errors will otherwise result in the kart
|
||||||
|
@ -117,17 +117,17 @@ void PlayerController::action(PlayerAction action, int value)
|
|||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case PA_LEFT:
|
case PA_LEFT:
|
||||||
m_steer_val_l = -value;
|
m_steer_val_l = value;
|
||||||
if (value)
|
if (value)
|
||||||
m_steer_val = -value;
|
m_steer_val = value;
|
||||||
else
|
else
|
||||||
m_steer_val = m_steer_val_r;
|
m_steer_val = m_steer_val_r;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PA_RIGHT:
|
case PA_RIGHT:
|
||||||
m_steer_val_r = value;
|
m_steer_val_r = -value;
|
||||||
if (value)
|
if (value)
|
||||||
m_steer_val = value;
|
m_steer_val = -value;
|
||||||
else
|
else
|
||||||
m_steer_val = m_steer_val_l;
|
m_steer_val = m_steer_val_l;
|
||||||
|
|
||||||
|
@ -384,10 +384,6 @@ void Kart::reset()
|
|||||||
m_controller = m_saved_controller;
|
m_controller = m_saved_controller;
|
||||||
m_saved_controller = NULL;
|
m_saved_controller = NULL;
|
||||||
}
|
}
|
||||||
// Reset is also called when the kart is created, at which time
|
|
||||||
// m_controller is not yet defined.
|
|
||||||
if(m_controller)
|
|
||||||
m_controller->reset();
|
|
||||||
m_kart_properties->getKartModel()->setEndAnimation(false);
|
m_kart_properties->getKartModel()->setEndAnimation(false);
|
||||||
m_view_blocked_by_plunger = 0.0;
|
m_view_blocked_by_plunger = 0.0;
|
||||||
m_attachment.clear();
|
m_attachment.clear();
|
||||||
@ -435,6 +431,12 @@ void Kart::reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
TerrainInfo::update(getXYZ());
|
TerrainInfo::update(getXYZ());
|
||||||
|
|
||||||
|
// Reset is also called when the kart is created, at which time
|
||||||
|
// m_controller is not yet defined, so this has to be tested here.
|
||||||
|
if(m_controller)
|
||||||
|
m_controller->reset();
|
||||||
|
|
||||||
} // reset
|
} // reset
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1160,8 +1162,8 @@ void Kart::updatePhysics(float dt)
|
|||||||
}
|
}
|
||||||
float steering = getMaxSteerAngle() * m_controls.m_steer*m_skidding;
|
float steering = getMaxSteerAngle() * m_controls.m_steer*m_skidding;
|
||||||
|
|
||||||
m_vehicle->setSteeringValue(-steering, 0);
|
m_vehicle->setSteeringValue(steering, 0);
|
||||||
m_vehicle->setSteeringValue(-steering, 1);
|
m_vehicle->setSteeringValue(steering, 1);
|
||||||
|
|
||||||
// Only compute the current speed if this is not the client. On a client the
|
// Only compute the current speed if this is not the client. On a client the
|
||||||
// speed is actually received from the server.
|
// speed is actually received from the server.
|
||||||
@ -1369,7 +1371,7 @@ void Kart::updateGraphics(const Vec3& offset_xyz,
|
|||||||
float offset_heading = getSteerPercent()*m_kart_properties->getSkidVisual()
|
float offset_heading = getSteerPercent()*m_kart_properties->getSkidVisual()
|
||||||
* speed_ratio * m_skidding*m_skidding;
|
* speed_ratio * m_skidding*m_skidding;
|
||||||
Moveable::updateGraphics(center_shift,
|
Moveable::updateGraphics(center_shift,
|
||||||
btQuaternion(-offset_heading, 0, 0));
|
btQuaternion(offset_heading, 0, 0));
|
||||||
} // updateGraphics
|
} // updateGraphics
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
@ -265,7 +265,7 @@ void KartModel::update(float rotation, float visual_steer,
|
|||||||
} // for i<4
|
} // for i<4
|
||||||
|
|
||||||
core::vector3df wheel_rear (-rotation, 0, 0);
|
core::vector3df wheel_rear (-rotation, 0, 0);
|
||||||
core::vector3df wheel_steer(0, -visual_steer, 0);
|
core::vector3df wheel_steer(0, visual_steer, 0);
|
||||||
core::vector3df wheel_front = wheel_rear+wheel_steer;
|
core::vector3df wheel_front = wheel_rear+wheel_steer;
|
||||||
|
|
||||||
for(unsigned int i=0; i<4; i++)
|
for(unsigned int i=0; i<4; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user