History

cleaned up some code and added asserts to help track down a crash

Jeffrey Ventrella committed 13 years ago

Commit 903a2481 parent 062ee654 files · +53 −16Browse files

Showing the changes to interface/src/ParticleSystem.cpp (1 of 4 files). Show all

Unified · Split

interface/src/ParticleSystem.cpp+11−8
@@ -69,13 +69,12 @@ ParticleSystem::ParticleSystem() { · 68 unmodified lines
6969
7070 int ParticleSystem::addEmitter() {
7171
72− _numEmitters ++;
73−
74− if (_numEmitters > MAX_EMITTERS) {
75− return -1;
72+ if (_numEmitters < MAX_EMITTERS) {
73+ _numEmitters ++;
74+ return _numEmitters - 1;
7675 }
7776
78− return _numEmitters - 1;
77+ return -1;
7978 }
8079
8180
@@ -95,12 +94,16 @@ void ParticleSystem::simulate(float deltaTime) { · 13 unmodified lines
9594
9695 void ParticleSystem::emitNow(int e) {
9796
98− for (unsigned int p = 0; p < _emitter[e].rate; p++) {
99− createParticle(e, _emitter[e].direction);
97+ assert( e >= 0 );
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);
100103 }
101104 }
102105
103−void ParticleSystem::createParticle(int e, glm::vec3 velocity) {
106+void ParticleSystem::createParticle(int e) {
104107
105108 for (unsigned int p = 0; p < MAX_PARTICLES; p++) {
106109 if (!_particle[p].alive) {