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,8 +62,8 @@ Cake::Cake (Kart *kart) : Flyable(kart, POWERUP_CAKE)
|
|||||||
float pitch = kart->getTerrainPitch(heading);
|
float pitch = kart->getTerrainPitch(heading);
|
||||||
|
|
||||||
// Find closest kart in front of the current one
|
// Find closest kart in front of the current one
|
||||||
const Kart *closest_kart=0;
|
const Kart *closest_kart=NULL;
|
||||||
Vec3 direction;
|
Vec3 direction;
|
||||||
float kartDistSquared;
|
float kartDistSquared;
|
||||||
getClosestKart(&closest_kart, &kartDistSquared, &direction,
|
getClosestKart(&closest_kart, &kartDistSquared, &direction,
|
||||||
kart /* search in front of this kart */);
|
kart /* search in front of this kart */);
|
||||||
|
@ -167,7 +167,7 @@ void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared,
|
|||||||
btTransform tProjectile = (inFrontOf != NULL ? inFrontOf->getTrans()
|
btTransform tProjectile = (inFrontOf != NULL ? inFrontOf->getTrans()
|
||||||
: getTrans());
|
: getTrans());
|
||||||
|
|
||||||
*minDistSquared = -1.0f;
|
*minDistSquared = 999999.9f;
|
||||||
*minKart = NULL;
|
*minKart = NULL;
|
||||||
|
|
||||||
World *world = World::getWorld();
|
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 s = sqrt(v.length2() * to_target.length2());
|
||||||
float c = to_target.dot(v)/s;
|
float c = to_target.dot(v)/s;
|
||||||
// Original test was: fabsf(acos(c))>1, which is the same as
|
// Original test was: fabsf(acos(c))>1, which is the same as
|
||||||
// fabsf(c)<cos(1)
|
// c<cos(1) (acos returns values in [0, pi] anyway)
|
||||||
if(fabsf(c)<0.54) continue;
|
if(c<0.54) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(distance2 < *minDistSquared || *minDistSquared < 0 /* not yet set */)
|
if(distance2 < *minDistSquared)
|
||||||
{
|
{
|
||||||
*minDistSquared = distance2;
|
*minDistSquared = distance2;
|
||||||
*minKart = kart;
|
*minKart = kart;
|
||||||
|
Loading…
Reference in New Issue
Block a user