Make slipstream work in upside down track
This commit is contained in:
parent
4574686c1d
commit
061f187142
@ -77,7 +77,6 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
|
||||
p[1]=Vec3(-ew*0.5f, 0, -kl*0.5f-length);
|
||||
p[2]=Vec3( ew*0.5f, 0, -kl*0.5f-length);
|
||||
p[3]=Vec3( kw*0.5f, 0, -kl*0.5f );
|
||||
m_slipstream_original_quad = new Quad(p[0], p[1], p[2], p[3]);
|
||||
m_slipstream_quad = new Quad(p[0], p[1], p[2], p[3]);
|
||||
if(UserConfigParams::m_slipstream_debug)
|
||||
{
|
||||
@ -127,7 +126,6 @@ SlipStream::~SlipStream()
|
||||
m_debug_node->drop();
|
||||
m_debug_mesh->drop();
|
||||
}
|
||||
delete m_slipstream_original_quad;
|
||||
delete m_slipstream_quad;
|
||||
|
||||
} // ~SlipStream
|
||||
@ -369,12 +367,6 @@ void SlipStream::update(float dt)
|
||||
|
||||
MovingTexture::update(dt);
|
||||
|
||||
// Update this karts slipstream quad (even for low level AI which don't
|
||||
// use slipstream, since even then player karts can get slipstream,
|
||||
// and so have to compare with the modified slipstream quad.
|
||||
m_slipstream_original_quad->transform(m_kart->getTrans(),
|
||||
m_slipstream_quad);
|
||||
|
||||
if(m_slipstream_mode==SS_USE)
|
||||
{
|
||||
m_slipstream_time -= dt;
|
||||
@ -418,12 +410,13 @@ void SlipStream::update(float dt)
|
||||
m_target_kart->getKartAnimation() ||
|
||||
m_target_kart->isEliminated() ) continue;
|
||||
|
||||
float diff = fabsf(m_target_kart->getXYZ().getY()
|
||||
- m_kart->getXYZ().getY() );
|
||||
// Transform this kart location into target kart point of view
|
||||
Vec3 lc = m_target_kart->getTrans().inverse()(m_kart->getXYZ());
|
||||
|
||||
// If the kart is 'on top' of this kart (e.g. up on a bridge),
|
||||
// don't consider it for slipstreaming.
|
||||
if (fabsf(lc.y()) > 6.0f) continue;
|
||||
|
||||
if(diff>6.0f) continue;
|
||||
// If the kart we are testing against is too slow, no need to test
|
||||
// slipstreaming. Note: We compare the speed of the other kart
|
||||
// against the minimum slipstream speed kart of this kart - not
|
||||
@ -447,7 +440,7 @@ void SlipStream::update(float dt)
|
||||
float l = kp->getSlipstreamLength()
|
||||
+ 0.5f*( m_target_kart->getKartLength()
|
||||
+m_kart->getKartLength() );
|
||||
if(delta.length2_2d() > l*l)
|
||||
if(delta.length2() > l*l)
|
||||
{
|
||||
if(UserConfigParams::m_slipstream_debug &&
|
||||
m_kart->getController()->isLocalPlayerController())
|
||||
@ -457,7 +450,7 @@ void SlipStream::update(float dt)
|
||||
}
|
||||
// Real test: if in slipstream quad of other kart
|
||||
if(m_target_kart->getSlipstream()->m_slipstream_quad
|
||||
->pointInside(m_kart->getXYZ()))
|
||||
->pointInside(lc))
|
||||
{
|
||||
is_sstreaming = true;
|
||||
break;
|
||||
|
@ -66,14 +66,9 @@ private:
|
||||
* 'slipstream credits', or the kart is using accumulated credits. */
|
||||
enum {SS_NONE, SS_COLLECT, SS_USE} m_slipstream_mode;
|
||||
|
||||
/** The quad inside which another kart is considered to be slipstreaming.
|
||||
* This value is current area, i.e. takes the kart position into account. */
|
||||
/** This is slipstream area if the kart is at 0,0,0 without rotation. */
|
||||
Quad *m_slipstream_quad;
|
||||
|
||||
/** This is slipstream area if the kart is at 0,0,0 without rotation. From
|
||||
* this value m_slipstream_area is computed by applying the kart transform. */
|
||||
Quad *m_slipstream_original_quad;
|
||||
|
||||
/** The kart from which this kart gets slipstream. Used by the AI to
|
||||
** overtake the right kart. */
|
||||
AbstractKart* m_target_kart;
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include <S3DVertex.h>
|
||||
#include <triangle3d.h>
|
||||
|
||||
#include "LinearMath/btTransform.h"
|
||||
|
||||
/** Constructor, takes 4 points. */
|
||||
Quad::Quad(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3)
|
||||
{
|
||||
@ -102,24 +100,3 @@ bool Quad::pointInside(const Vec3& p, bool ignore_vertical) const
|
||||
p.sideOfLine2D(m_p[3], m_p[0]) >= 0.0;
|
||||
}
|
||||
} // pointInside
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Transforms a quad by a given transform (i.e. translation+rotation). This
|
||||
* function does not modify this quad, the results are stored in the quad
|
||||
* specified as parameter. These functions are used for slipstreaming to
|
||||
* determine the slipstream area from the original value (kart at 0,0,0 and
|
||||
* no rotation) to the current value.
|
||||
* \param t The transform to apply.
|
||||
* \param result The quad which stores the result.
|
||||
*/
|
||||
void Quad::transform(const btTransform &t, Quad *result) const
|
||||
{
|
||||
result->m_p[0] = t(m_p[0]);
|
||||
result->m_p[1] = t(m_p[1]);
|
||||
result->m_p[2] = t(m_p[2]);
|
||||
result->m_p[3] = t(m_p[3]);
|
||||
result->m_min_height = std::min ( std::min(result->m_p[0].getY(),
|
||||
result->m_p[1].getY()),
|
||||
std::min(result->m_p[2].getY(),
|
||||
result->m_p[3].getY()) );
|
||||
} // transform
|
||||
|
@ -31,8 +31,6 @@ namespace irr
|
||||
}
|
||||
using namespace irr;
|
||||
|
||||
class btTransform;
|
||||
|
||||
/**
|
||||
* \ingroup tracks
|
||||
*/
|
||||
@ -64,8 +62,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
void getVertices(video::S3DVertex *v, const video::SColor &color) const;
|
||||
// ------------------------------------------------------------------------
|
||||
void transform(const btTransform &t, Quad *result) const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the i-th. point of a quad. */
|
||||
const Vec3& operator[](int i) const { return m_p[i]; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user