1) Fixed incorrect start positions of plunger (getY instead of getZ).

2) Some code cleanup (renamed variables to follow our style, renamed
   Kart::getKartHeading to Kart::getKartTransform).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6731 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-11-25 22:22:41 +00:00
parent 49dd6821a4
commit 16d969fa39
5 changed files with 23 additions and 22 deletions

View File

@ -99,7 +99,7 @@ Cake::Cake (Kart *kart) : Flyable(kart, PowerupManager::POWERUP_CAKE)
m_target = NULL;
// kart is too far to be hit. so throw the projectile in a generic way,
// straight ahead, without trying to hit anything in particular
trans = kart->getKartHeading(pitch);
trans = kart->getKartTransform(pitch);
m_initial_velocity = Vec3(0.0f, up_velocity, m_speed);

View File

@ -156,8 +156,8 @@ void Flyable::createPhysics(float forw_offset, const Vec3 &velocity,
const btTransform* custom_direction)
{
// Get Kart heading direction
btTransform trans = ( custom_direction == NULL ? m_owner->getKartHeading()
: *custom_direction );
btTransform trans = ( !custom_direction ? m_owner->getKartTransform()
: *custom_direction );
// Apply offset
btTransform offset_transform;

View File

@ -57,7 +57,7 @@ Plunger::Plunger(Kart *kart) : Flyable(kart, PowerupManager::POWERUP_PLUNGER)
{
const float gravity = 0.0f;
float y_offset = 0.5f*kart->getKartLength()+0.5f*m_extend.getY();
float forward_offset = 0.5f*kart->getKartLength()+0.5f*m_extend.getZ();
float up_velocity = 0.0f;
float plunger_speed = 2 * m_speed;
@ -67,40 +67,41 @@ Plunger::Plunger(Kart *kart) : Flyable(kart, PowerupManager::POWERUP_PLUNGER)
// find closest kart in front of the current one
const Kart *closest_kart=0;
Vec3 direction;
float kartDistSquared;
getClosestKart(&closest_kart, &kartDistSquared, &direction,
float kart_dist_2;
getClosestKart(&closest_kart, &kart_dist_2, &direction,
kart /* search in front of this kart */, m_reverse_mode);
btTransform trans = kart->getTrans();
btTransform kart_transform = kart->getKartTransform();
btMatrix3x3 kart_rotation = kart_transform.getBasis();
// The current forward vector is rotation*(0,0,1), or:
btVector3 forward(kart_rotation.getColumn(2));
btMatrix3x3 thisKartDirMatrix = kart->getKartHeading().getBasis();
btVector3 thisKartDirVector(thisKartDirMatrix.getColumn(2));
float heading=kart->getHeading();
float pitch = kart->getTerrainPitch(heading);
float heading =kart->getHeading();
float pitch = kart->getTerrainPitch(heading);
// aim at this kart if it's not too far
if(closest_kart != NULL && kartDistSquared < 30*30)
if(closest_kart != NULL && kart_dist_2 < 30*30)
{
float fire_angle = 0.0f;
getLinearKartItemIntersection (kart->getXYZ(), closest_kart,
plunger_speed, gravity, y_offset,
plunger_speed, gravity, forward_offset,
&fire_angle, &up_velocity);
btTransform trans = kart->getTrans();
trans.setRotation(btQuaternion(btVector3(0, 1, 0), fire_angle));
m_initial_velocity = btVector3(0.0f, up_velocity, plunger_speed);
createPhysics(y_offset, m_initial_velocity,
createPhysics(forward_offset, m_initial_velocity,
new btCylinderShape(0.5f*m_extend), gravity,
/* rotates */false , /*turn around*/false, &trans );
}
else
{
trans = kart->getKartHeading();
createPhysics(y_offset, btVector3(pitch, 0.0f, plunger_speed),
new btCylinderShape(0.5f*m_extend), gravity, false /* rotates */, m_reverse_mode, &trans );
createPhysics(forward_offset, btVector3(pitch, 0.0f, plunger_speed),
new btCylinderShape(0.5f*m_extend), gravity,
false /* rotates */, m_reverse_mode, &kart_transform );
}
//adjust height according to terrain

View File

@ -159,7 +159,7 @@ void Kart::setController(Controller *controller)
* otherwise).
* \param customPitch Pitch value to overwrite the terrain pitch.
*/
btTransform Kart::getKartHeading(const float customPitch)
btTransform Kart::getKartTransform(const float customPitch)
{
btTransform trans = getTrans();
@ -170,7 +170,7 @@ btTransform Kart::getKartHeading(const float customPitch)
trans.setBasis(m);
return trans;
} // getKartHeading
} // getKartTransform
// ----------------------------------------------------------------------------
/** Creates the physical representation of this kart. Atm it uses the actual

View File

@ -296,7 +296,7 @@ public:
/** Returns a bullet transform object located at the kart's position
and oriented in the direction the kart is going. Can be useful
e.g. to calculate the starting point and direction of projectiles. */
btTransform getKartHeading (const float customPitch=-1);
btTransform getKartTransform(const float customPitch=-1);
// -------------------------------------------------------------------------
/** Returns the color used for this kart. */
const video::SColor &getColor() const