Take item on walldriving tracks into account

This commit is contained in:
Benau 2017-02-21 15:06:26 +08:00
parent 3898678e76
commit 02d3bd2c2b

View File

@ -194,10 +194,12 @@ public:
*/
bool hitKart(const Vec3 &xyz, const AbstractKart *kart=NULL) const
{
Vec3 diff = (xyz - m_xyz);
diff.setY(diff.getY() / 2.0f); // don't be too strict if the kart is a bit above the item
return (m_event_handler!=kart || m_deactive_time <=0) &&
diff.length2()<m_distance_2;
if (m_event_handler == kart && m_deactive_time > 0)
return false;
Vec3 lc = quatRotate(m_original_rotation, xyz - m_xyz);
// Don't be too strict if the kart is a bit above the item
lc.setY(lc.getY() / 2.0f);
return lc.length2() < m_distance_2;
} // hitKart
protected:
@ -214,7 +216,7 @@ protected:
const AbstractKart *kart=NULL) const
{
if(m_event_handler==kart && m_deactive_time >0) return false;
Vec3 closest = line.getClosestPoint(m_xyz.toIrrVector());
return hitKart(closest, kart);
} // hitLine