Fix bubblegum on upside down track
This commit is contained in:
@@ -487,19 +487,17 @@ void Attachment::update(float dt)
|
||||
Vec3 hit_point;
|
||||
Vec3 normal;
|
||||
const Material* material_hit;
|
||||
Vec3 pos = m_kart->getXYZ();
|
||||
Vec3 to=pos+Vec3(0, -10000, 0);
|
||||
World* world = World::getWorld();
|
||||
world->getTrack()->getTriangleMesh().castRay(pos, to, &hit_point,
|
||||
&material_hit, &normal);
|
||||
world->getTrack()->getTriangleMesh().castRay(m_kart->getXYZ(),
|
||||
m_kart->getTrans().getBasis() * Vec3(0, -10000, 0), &hit_point,
|
||||
&material_hit, &normal);
|
||||
// This can happen if the kart is 'over nothing' when dropping
|
||||
// the bubble gum
|
||||
if(material_hit)
|
||||
{
|
||||
normal.normalize();
|
||||
|
||||
pos.setY(hit_point.getY()-0.05f);
|
||||
|
||||
Vec3 pos = hit_point + m_kart->getTrans().getBasis() * Vec3(0, -0.05f, 0);
|
||||
ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos, normal, m_kart);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,10 +232,9 @@ void Powerup::use()
|
||||
Vec3 hit_point;
|
||||
Vec3 normal;
|
||||
const Material* material_hit;
|
||||
Vec3 pos = m_owner->getXYZ();
|
||||
Vec3 to=pos+Vec3(0, -10000, 0);
|
||||
world->getTrack()->getTriangleMesh().castRay(pos, to, &hit_point,
|
||||
&material_hit, &normal);
|
||||
world->getTrack()->getTriangleMesh().castRay(m_owner->getXYZ(),
|
||||
m_owner->getTrans().getBasis() * Vec3(0, -10000, 0), &hit_point,
|
||||
&material_hit, &normal);
|
||||
// This can happen if the kart is 'over nothing' when dropping
|
||||
// the bubble gum
|
||||
if(!material_hit)
|
||||
@@ -245,8 +244,7 @@ void Powerup::use()
|
||||
Powerup::adjustSound();
|
||||
m_sound_use->play();
|
||||
|
||||
pos.setY(hit_point.getY()-0.05f);
|
||||
|
||||
Vec3 pos = hit_point + m_owner->getTrans().getBasis() * Vec3(0, -0.05f, 0);
|
||||
ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos, normal, m_owner);
|
||||
}
|
||||
else // if the kart is looking forward, use the bubblegum as a shield
|
||||
|
||||
Reference in New Issue
Block a user