Showing the changes to interface/src/ParticleSystem.cpp (1 of 4 files). Show all
Unified · Split
| @@ -69,13 +69,12 @@ ParticleSystem::ParticleSystem() { · 68 unmodified lines | |||
| 69 | 69 | ||
| 70 | int ParticleSystem::addEmitter() { | 70 | int ParticleSystem::addEmitter() { |
| 71 | 71 | ||
| 72 | _numEmitters ++; | 72 | if (_numEmitters < MAX_EMITTERS) { |
| 73 | 73 | _numEmitters ++; | |
| 74 | if (_numEmitters > MAX_EMITTERS) { | 74 | return _numEmitters - 1; |
| 75 | return -1; | ||
| 76 | } | 75 | } |
| 77 | 76 | ||
| 78 | return _numEmitters - 1; | 77 | return -1; |
| 79 | } | 78 | } |
| 80 | 79 | ||
| 81 | 80 | ||
| @@ -95,12 +94,16 @@ void ParticleSystem::simulate(float deltaTime) { · 13 unmodified lines | |||
| 95 | 94 | ||
| 96 | void ParticleSystem::emitNow(int e) { | 95 | void ParticleSystem::emitNow(int e) { |
| 97 | 96 | ||
| 98 | for (unsigned int p = 0; p < _emitter[e].rate; p++) { | 97 | assert( e >= 0 ); |
| 99 | createParticle(e, _emitter[e].direction); | 98 | assert( e <= MAX_EMITTERS ); |
| 99 | assert( _emitter[e].rate >= 0 ); | ||
| 100 | |||
| 101 | for (int p = 0; p < _emitter[e].rate; p++) { | ||
| 102 | createParticle(e); | ||
| 100 | } | 103 | } |
| 101 | } | 104 | } |
| 102 | 105 | ||
| 103 | void ParticleSystem::createParticle(int e, glm::vec3 velocity) { | 106 | void ParticleSystem::createParticle(int e) { |
| 104 | 107 | ||
| 105 | for (unsigned int p = 0; p < MAX_PARTICLES; p++) { | 108 | for (unsigned int p = 0; p < MAX_PARTICLES; p++) { |
| 106 | if (!_particle[p].alive) { | 109 | if (!_particle[p].alive) { |