Fixed aiming problem: cakes would aim at karts behind the firing kart.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5138 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c420edf1e7
commit
dc21c85128
@ -62,7 +62,7 @@ Cake::Cake (Kart *kart) : Flyable(kart, POWERUP_CAKE)
|
||||
float pitch = kart->getTerrainPitch(heading);
|
||||
|
||||
// Find closest kart in front of the current one
|
||||
const Kart *closest_kart=0;
|
||||
const Kart *closest_kart=NULL;
|
||||
Vec3 direction;
|
||||
float kartDistSquared;
|
||||
getClosestKart(&closest_kart, &kartDistSquared, &direction,
|
||||
|
@ -167,7 +167,7 @@ void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared,
|
||||
btTransform tProjectile = (inFrontOf != NULL ? inFrontOf->getTrans()
|
||||
: getTrans());
|
||||
|
||||
*minDistSquared = -1.0f;
|
||||
*minDistSquared = 999999.9f;
|
||||
*minKart = NULL;
|
||||
|
||||
World *world = World::getWorld();
|
||||
@ -198,11 +198,11 @@ void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared,
|
||||
float s = sqrt(v.length2() * to_target.length2());
|
||||
float c = to_target.dot(v)/s;
|
||||
// Original test was: fabsf(acos(c))>1, which is the same as
|
||||
// fabsf(c)<cos(1)
|
||||
if(fabsf(c)<0.54) continue;
|
||||
// c<cos(1) (acos returns values in [0, pi] anyway)
|
||||
if(c<0.54) continue;
|
||||
}
|
||||
|
||||
if(distance2 < *minDistSquared || *minDistSquared < 0 /* not yet set */)
|
||||
if(distance2 < *minDistSquared)
|
||||
{
|
||||
*minDistSquared = distance2;
|
||||
*minKart = kart;
|
||||
|
Loading…
Reference in New Issue
Block a user