Make sure sky particles always fall vertically
This commit is contained in:
parent
1fc460ff4e
commit
cfb10dbb1f
src/karts/controller
@ -54,6 +54,8 @@
|
||||
#include "input/gamepad_device.hpp"
|
||||
#include "input/sdl_controller.hpp"
|
||||
|
||||
#include "LinearMath/btTransform.h"
|
||||
|
||||
/** The constructor for a loca player kart, i.e. a player that is playing
|
||||
* on this machine (non-local player would be network clients).
|
||||
* \param kart_name Name of the kart.
|
||||
@ -263,25 +265,23 @@ void LocalPlayerController::update(int ticks)
|
||||
{
|
||||
if (m_controls->getLookBack() || (UserConfigParams::m_reverse_look_threshold > 0 &&
|
||||
m_kart->getSpeed() < -UserConfigParams::m_reverse_look_threshold))
|
||||
{
|
||||
camera->setMode(Camera::CM_REVERSE);
|
||||
if (m_sky_particles_emitter)
|
||||
{
|
||||
m_sky_particles_emitter->setPosition(Vec3(0, 30, -100));
|
||||
m_sky_particles_emitter->setRotation(Vec3(0, 180, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (camera->getMode() == Camera::CM_REVERSE)
|
||||
{
|
||||
camera->setMode(Camera::CM_NORMAL);
|
||||
if (m_sky_particles_emitter)
|
||||
{
|
||||
m_sky_particles_emitter->setPosition(Vec3(0, 30, 100));
|
||||
m_sky_particles_emitter->setRotation(Vec3(0, 0, 0));
|
||||
}
|
||||
}
|
||||
if (m_sky_particles_emitter)
|
||||
{
|
||||
// Need to set it every frame to account for heading changes
|
||||
btTransform local_trans(btQuaternion(Vec3(0, 1, 0), 0),
|
||||
Vec3(0, 30, 100));
|
||||
if (camera->getMode() == Camera::CM_REVERSE)
|
||||
{
|
||||
local_trans = btTransform (btQuaternion(Vec3(0, 1, 0),
|
||||
180.0 * DEGREE_TO_RAD), Vec3(0, 30, -100));
|
||||
}
|
||||
setParticleEmitterPosition(local_trans);
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,6 +300,22 @@ void LocalPlayerController::update(int ticks)
|
||||
}
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void LocalPlayerController::setParticleEmitterPosition(const btTransform& t)
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
btTransform world_trans(btQuaternion(Vec3(0, 1, 0), m_kart->getHeading()),
|
||||
m_kart->getXYZ());
|
||||
world_trans *= t;
|
||||
btTransform inv_kart = m_kart->getTrans().inverse();
|
||||
inv_kart *= world_trans;
|
||||
m_sky_particles_emitter->setPosition(Vec3(inv_kart.getOrigin()));
|
||||
Vec3 rotation;
|
||||
rotation.setHPR(inv_kart.getRotation());
|
||||
m_sky_particles_emitter->setRotation(rotation.toIrrHPR());
|
||||
#endif
|
||||
} // setParticleEmitterPosition
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Displays a penalty warning for player controlled karts. Called from
|
||||
* LocalPlayerKart::update() if necessary.
|
||||
|
@ -28,6 +28,7 @@ class AbstractKart;
|
||||
class ParticleEmitter;
|
||||
class SFXBase;
|
||||
class SFXBuffer;
|
||||
class btTransform;
|
||||
|
||||
/** PlayerKart manages control events from the player and moves
|
||||
* them to the Kart
|
||||
@ -68,6 +69,7 @@ private:
|
||||
void nitroNotFullSound();
|
||||
|
||||
void doCrashHaptics();
|
||||
void setParticleEmitterPosition(const btTransform& t);
|
||||
|
||||
public:
|
||||
LocalPlayerController(AbstractKart *kart,
|
||||
|
Loading…
Reference in New Issue
Block a user