Simplify code

This commit is contained in:
Benau
2016-11-18 09:44:30 +08:00
parent ac74304dd7
commit 9eb6ef5bfe
6 changed files with 24 additions and 37 deletions

View File

@@ -158,7 +158,6 @@ ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter,
track_x_len = 0;
track_z_len = 0;
texture = 0;
m_reverse = false;
}
ParticleSystemProxy::~ParticleSystemProxy()
@@ -634,21 +633,3 @@ void ParticleSystemProxy::render() {
draw();
}
}
void ParticleSystemProxy::updateAbsolutePosition()
{
if (Parent && m_reverse)
{
core::vector3df old_rot = RelativeRotation;
core::vector3df old_tran = RelativeTranslation;
RelativeRotation.Y += 180.0f;
RelativeTranslation.Z = -RelativeTranslation.Z;
scene::CParticleSystemSceneNode::updateAbsolutePosition();
RelativeRotation = old_rot;
RelativeTranslation = old_tran;
}
else
{
scene::CParticleSystemSceneNode::updateAbsolutePosition();
}
}

View File

@@ -40,10 +40,9 @@ protected:
float m_color_to[3];
bool m_first_execution;
bool m_randomize_initial_y;
bool m_reverse;
GLuint texture;
/** Previous frame particles emitter source matrix */
core::matrix4 m_previous_frame_matrix;
@@ -107,8 +106,6 @@ public:
const float* getColorTo() const { return m_color_to; }
void setHeightmap(const std::vector<std::vector<float> >&, float, float, float, float);
void setFlip();
void setReverse(bool reverse) { m_reverse = reverse; }
virtual void updateAbsolutePosition();
};
#endif // GPUPARTICLES_H

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,7 +25,6 @@
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/gpu_particles.hpp"
#include "graphics/particle_emitter.hpp"
#include "graphics/particle_kind.hpp"
#include "input/input_manager.hpp"
@@ -56,8 +55,7 @@
*/
LocalPlayerController::LocalPlayerController(AbstractKart *kart,
StateManager::ActivePlayer *player)
: PlayerController(kart), m_sky_particles_emitter(NULL),
m_particle_system_proxy(NULL)
: PlayerController(kart), m_sky_particles_emitter(NULL)
{
m_player = player;
if(player)
@@ -89,8 +87,6 @@ LocalPlayerController::LocalPlayerController(AbstractKart *kart,
// 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);
m_particle_system_proxy = dynamic_cast<ParticleSystemProxy*>
(m_sky_particles_emitter->getNode());
}
} // LocalPlayerController
@@ -202,16 +198,22 @@ void LocalPlayerController::update(float dt)
m_kart->getSpeed() < -UserConfigParams::m_reverse_look_threshold))
{
camera->setMode(Camera::CM_REVERSE);
if (m_particle_system_proxy)
m_particle_system_proxy->setReverse(true);
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_particle_system_proxy)
m_particle_system_proxy->setReverse(false);
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

@@ -25,7 +25,6 @@
class AbstractKart;
class ParticleEmitter;
class ParticleSystemProxy;
class SFXBase;
/** PlayerKart manages control events from the player and moves
@@ -44,8 +43,6 @@ private:
ParticleEmitter* m_sky_particles_emitter;
ParticleSystemProxy* m_particle_system_proxy;
/** 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. */
int m_camera_index;