Merge branch 'fix_1704'

This commit is contained in:
Benau 2016-11-18 09:51:34 +08:00
commit f853255204
6 changed files with 50 additions and 30 deletions

View File

@ -427,9 +427,18 @@ int ParticleEmitter::getCreationRate()
*/
void ParticleEmitter::setPosition(const Vec3 &pos)
{
m_node->setPosition(pos.toIrrVector());
m_node->setPosition(pos.toIrrVector());
} // setPosition
//-----------------------------------------------------------------------------
/** Sets the rotation of the particle emitter.
* \param pos The rotation for the particle emitter.
*/
void ParticleEmitter::setRotation(const Vec3 &rot)
{
m_node->setRotation(rot.toIrrVector());
} // setRotation
//-----------------------------------------------------------------------------
void ParticleEmitter::clearParticles()

View File

@ -94,6 +94,7 @@ public:
int getCreationRate();
void setPosition(const Vec3 &pos);
void setRotation(const Vec3 &rot);
const ParticleKind* getParticlesInfo() const { return m_particle_type; }

View File

@ -25,6 +25,8 @@
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/particle_emitter.hpp"
#include "graphics/particle_kind.hpp"
#include "input/input_manager.hpp"
#include "items/attachment.hpp"
#include "items/item.hpp"
@ -39,6 +41,7 @@
#include "network/race_event_manager.hpp"
#include "race/history.hpp"
#include "states_screens/race_gui_base.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"
@ -52,7 +55,7 @@
*/
LocalPlayerController::LocalPlayerController(AbstractKart *kart,
StateManager::ActivePlayer *player)
: PlayerController(kart)
: PlayerController(kart), m_sky_particles_emitter(NULL)
{
m_player = player;
if(player)
@ -67,6 +70,25 @@ LocalPlayerController::LocalPlayerController(AbstractKart *kart,
m_ugh_sound = SFXManager::get()->createSoundSource("ugh");
m_grab_sound = SFXManager::get()->createSoundSource("grab_collectable");
m_full_sound = SFXManager::get()->createSoundSource("energy_bar_full");
// Attach Particle System
Track *track = World::getWorld()->getTrack();
if (UserConfigParams::m_weather_effects &&
track->getSkyParticles() != NULL)
{
track->getSkyParticles()->setBoxSizeXZ(150.0f, 150.0f);
m_sky_particles_emitter =
new ParticleEmitter(track->getSkyParticles(),
core::vector3df(0.0f, 30.0f, 100.0f),
m_kart->getNode(),
true);
// FIXME: in multiplayer mode, this will result in several instances
// of the heightmap being calculated and kept in memory
m_sky_particles_emitter->addHeightMapAffector(track);
}
} // LocalPlayerController
//-----------------------------------------------------------------------------
@ -79,6 +101,8 @@ LocalPlayerController::~LocalPlayerController()
m_ugh_sound ->deleteSFX();
m_grab_sound->deleteSFX();
m_full_sound->deleteSFX();
if (m_sky_particles_emitter)
delete m_sky_particles_emitter;
} // ~LocalPlayerController
//-----------------------------------------------------------------------------
@ -174,11 +198,23 @@ void LocalPlayerController::update(float dt)
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));
}
}
}
}

View File

@ -24,7 +24,7 @@
#include "karts/controller/player_controller.hpp"
class AbstractKart;
class Player;
class ParticleEmitter;
class SFXBase;
/** PlayerKart manages control events from the player and moves
@ -41,6 +41,7 @@ private:
bool m_sound_schedule;
ParticleEmitter* m_sky_particles_emitter;
/** The index of the camera attached to the kart for this controller. The
* camera object is managed in the Camera class, so no need to free it. */

View File

@ -33,7 +33,6 @@
#include "graphics/irr_driver.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/particle_emitter.hpp"
#include "graphics/particle_kind.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "graphics/render_info.hpp"
#include "graphics/shadow.hpp"
@ -137,7 +136,6 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
m_controller = NULL;
m_saved_controller = NULL;
m_flying = false;
m_sky_particles_emitter= NULL;
m_stars_effect = NULL;
m_is_jumping = false;
m_min_nitro_time = 0.0f;
@ -261,7 +259,6 @@ Kart::~Kart()
if(m_previous_terrain_sound) m_previous_terrain_sound->deleteSFX();
if(m_collision_particles) delete m_collision_particles;
if(m_slipstream) delete m_slipstream;
if(m_sky_particles_emitter) delete m_sky_particles_emitter;
if(m_attachment) delete m_attachment;
if(m_stars_effect) delete m_stars_effect;
@ -2536,28 +2533,6 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
m_attachment = new Attachment(this);
createPhysics();
// Attach Particle System
Track *track = World::getWorld()->getTrack();
if (type == RaceManager::KT_PLAYER &&
UserConfigParams::m_weather_effects &&
track->getSkyParticles() != NULL)
{
track->getSkyParticles()->setBoxSizeXZ(150.0f, 150.0f);
m_sky_particles_emitter =
new ParticleEmitter(track->getSkyParticles(),
core::vector3df(0.0f, 30.0f, 100.0f),
getNode(),
true);
// FIXME: in multiplayer mode, this will result in several instances
// of the heightmap being calculated and kept in memory
m_sky_particles_emitter->addHeightMapAffector(track);
}
Vec3 position(0, getKartHeight()*0.35f, -getKartLength()*0.35f);
m_slipstream = new SlipStream(this);
if (m_kart_properties->getSkidEnabled())

View File

@ -178,8 +178,6 @@ protected:
/** The shadow of a kart. */
Shadow *m_shadow;
ParticleEmitter *m_sky_particles_emitter;
/** All particle effects. */
KartGFX *m_kart_gfx;