Mark some emitters as important so that they are never disabled by options, fixes #1808

This commit is contained in:
Marianne Gagnon 2015-02-04 20:13:06 -05:00
parent f4909d7c46
commit ecad7c2996
7 changed files with 44 additions and 24 deletions

View File

@ -288,7 +288,8 @@ public:
ParticleEmitter::ParticleEmitter(const ParticleKind* type,
const Vec3 &position,
scene::ISceneNode* parent,
bool randomize_initial_y)
bool randomize_initial_y,
bool important)
: m_position(position)
{
assert(type != NULL);
@ -300,6 +301,7 @@ ParticleEmitter::ParticleEmitter(const ParticleKind* type,
m_emission_decay_rate = 0;
m_is_glsl = CVS->isGLSL();
m_randomize_initial_y = randomize_initial_y;
m_important = important;
setParticleType(type);

View File

@ -76,6 +76,8 @@ private:
bool m_randomize_initial_y;
bool m_important;
public:
LEAK_CHECK()
@ -83,7 +85,8 @@ public:
ParticleEmitter (const ParticleKind* type,
const Vec3 &position,
scene::ISceneNode* parent = NULL,
bool randomize_initial_y = false);
bool randomize_initial_y = false,
bool important = false);
virtual ~ParticleEmitter();
virtual void update (float dt);
void setCreationRateAbsolute(float fraction);

View File

@ -233,6 +233,8 @@ public:
* skidding related values). */
virtual const Skidding *getSkidding() const = 0;
// ------------------------------------------------------------------------
virtual RaceManager::KartType getType() const = 0;
// ------------------------------------------------------------------------
/** Returns the skidding object for this kart (which can be used to query
* skidding related values), non-const. */
virtual Skidding *getSkidding() = 0;

View File

@ -132,6 +132,7 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
m_fire_clicked = 0;
m_wrongway_counter = 0;
m_nitro_light = NULL;
m_type = RaceManager::KT_AI;
m_view_blocked_by_plunger = 0;
m_has_caught_nolok_bubblegum = false;
@ -178,6 +179,8 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
*/
void Kart::init(RaceManager::KartType type)
{
m_type = type;
// In multiplayer mode, sounds are NOT positional
if (race_manager->getNumLocalPlayers() > 1)
{

View File

@ -217,6 +217,7 @@ private:
SFXBase *m_goo_sound;
SFXBase *m_boing_sound;
float m_time_last_crash;
RaceManager::KartType m_type;
/** To prevent using nitro in too short bursts */
float m_min_nitro_time;
@ -359,6 +360,8 @@ public:
* skidding related values) - non-const. */
virtual Skidding *getSkidding() { return m_skidding; }
// ------------------------------------------------------------------------
virtual RaceManager::KartType getType() const { return m_type; }
// ------------------------------------------------------------------------
/** Returns the bullet vehicle which represents this kart. */
virtual btKart *getVehicle() const {return m_vehicle; }
// ------------------------------------------------------------------------

View File

@ -24,6 +24,8 @@
#include "graphics/particle_kind.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/controller/controller.hpp"
#include "karts/kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/skidding.hpp"
#include "physics/btKart.hpp"
@ -33,12 +35,12 @@
KartGFX::KartGFX(const AbstractKart *kart)
{
if(!UserConfigParams::m_graphical_effects)
{
for(unsigned int i=0; i<KGFX_COUNT; i++)
m_all_emitters.push_back(NULL);
return;
}
//if(!UserConfigParams::m_graphical_effects)
//{
// for(unsigned int i=0; i<KGFX_COUNT; i++)
// m_all_emitters.push_back(NULL);
// return;
//}
m_kart = kart;
@ -64,16 +66,16 @@ KartGFX::KartGFX(const AbstractKart *kart)
// Create all effects. Note that they must be created
// in the order of KartGFXType.
addEffect(KGFX_NITRO1, "nitro.xml", rear_nitro_right);
addEffect(KGFX_NITRO2, "nitro.xml", rear_nitro_left);
addEffect(KGFX_NITROSMOKE1, "nitro-smoke.xml", rear_nitro_left);
addEffect(KGFX_NITROSMOKE2, "nitro-smoke.xml", rear_nitro_right);
addEffect(KGFX_ZIPPER, "zipper_fire.xml", rear_center);
addEffect(KGFX_TERRAIN, "smoke.xml", Vec3(0,0,0));
addEffect(KGFX_SKID1L, "skid1.xml", rear_left);
addEffect(KGFX_SKID1R, "skid1.xml", rear_right);
addEffect(KGFX_SKID2L, "skid2.xml", rear_left);
addEffect(KGFX_SKID2R, "skid2.xml", rear_right);
addEffect(KGFX_NITRO1, "nitro.xml", rear_nitro_right, true);
addEffect(KGFX_NITRO2, "nitro.xml", rear_nitro_left, true);
addEffect(KGFX_NITROSMOKE1, "nitro-smoke.xml", rear_nitro_left, false);
addEffect(KGFX_NITROSMOKE2, "nitro-smoke.xml", rear_nitro_right, false);
addEffect(KGFX_ZIPPER, "zipper_fire.xml", rear_center, true);
addEffect(KGFX_TERRAIN, "smoke.xml", Vec3(0, 0, 0), false);
addEffect(KGFX_SKID1L, "skid1.xml", rear_left, true);
addEffect(KGFX_SKID1R, "skid1.xml", rear_right, true);
addEffect(KGFX_SKID2L, "skid2.xml", rear_left, true);
addEffect(KGFX_SKID2R, "skid2.xml", rear_right, true);
} // KartGFX
// ----------------------------------------------------------------------------
@ -97,8 +99,15 @@ KartGFX::~KartGFX()
* \param position Where on the kart the particles should be emitted.
*/
void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
const Vec3 &position)
const Vec3 &position, bool important)
{
if (!UserConfigParams::m_graphical_effects &&
(!important || m_kart->getType() == RaceManager::KT_AI))
{
m_all_emitters.push_back(NULL);
return;
}
const ParticleKind *kind = NULL;
ParticleEmitter *emitter = NULL;
try
@ -113,9 +122,9 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
else if(type==KGFX_TERRAIN)
// Terrain is NOT a child of the kart, since bullet returns the
// raycast info in world coordinates
emitter = new ParticleEmitter(kind, position);
emitter = new ParticleEmitter(kind, position, NULL, false, important);
else
emitter = new ParticleEmitter(kind, position, m_kart->getNode());
emitter = new ParticleEmitter(kind, position, m_kart->getNode(), false, important);
}
catch (std::runtime_error& e)
{
@ -293,8 +302,6 @@ void KartGFX::updateTerrain(const ParticleKind *pk)
*/
void KartGFX::update(float dt)
{
if(!UserConfigParams::m_graphical_effects) return;
m_wheel_toggle = 1 - m_wheel_toggle;
for(unsigned int i=0; i<m_all_emitters.size(); i++)

View File

@ -70,7 +70,7 @@ private:
int m_wheel_toggle;
void addEffect(KartGFXType type, const std::string &file_name,
const Vec3 &position);
const Vec3 &position, bool important);
public:
KartGFX(const AbstractKart *kart);