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
69 69
70int ParticleSystem::addEmitter() {70int 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
96void ParticleSystem::emitNow(int e) {95void 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
103void ParticleSystem::createParticle(int e, glm::vec3 velocity) {106void 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) {