- Timestamp:
- Oct 29, 2005, 1:14:24 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/lang/base_object.cc
r5439 r5447 52 52 // delete []this->className; 53 53 if (this->objectName) 54 delete[] this->objectName;} 54 delete[] this->objectName; 55 } 55 56 56 57 /** -
trunk/src/lib/particles/particle_engine.cc
r5445 r5447 18 18 #include "particle_engine.h" 19 19 20 #include "particle_system.h" 21 #include "particle_emitter.h" 20 #include "class_list.h" 22 21 23 22 #include "list.h" … … 120 119 } 121 120 122 #include "class_list.h"123 121 /** 124 122 * @brief Connects a ParticleSystem to a ParticleSystem thus emitting Particles. … … 216 214 } 217 215 216 217 /** 218 * removes a Connection between an Emitter and a System 219 * @param connection the connection to remove 220 * 221 * \see bool ParticleEngine::breakConnection(ParticleEmitter* emitter, ParticleSystem* system) 222 */ 223 bool ParticleEngine::breakConnection(ParticleConnection* connection) 224 { 225 this->connectionList->remove(connection); 226 return true; 227 } 228 218 229 /** 219 230 * removes a Connection between an Emitter and a System … … 221 232 * @param system The system of the connection to remove 222 233 * @returns true, if the connection was broken, false if the conntection was not found 223 224 234 * 235 * only if both system and emitter are in the connection the Connection will be broken 225 236 */ 226 237 bool ParticleEngine::breakConnection(ParticleEmitter* emitter, ParticleSystem* system) … … 245 256 /** 246 257 * removes a Connection between an Emitter and a System 247 * @param connection the connection to remove 248 249 \see bool ParticleEngine::breakConnection(ParticleEmitter* emitter, ParticleSystem* system) 250 */ 251 bool ParticleEngine::breakConnection(ParticleConnection* connection) 252 { 253 this->connectionList->remove(connection); 254 return true; 255 } 256 258 * @param emitter The emitter of the connections to remove 259 * @returns the count of connections that were broken, 0 if no conntection was not found 260 */ 261 unsigned int ParticleEngine::breakConnections(ParticleEmitter* emitter) 262 { 263 unsigned int retVal = 0; 264 // look, if we have already added this connection 265 tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator(); 266 ParticleConnection* tmpConnection = tmpConIt->firstElement(); 267 while(tmpConnection) 268 { 269 if (tmpConnection->emitter == emitter) 270 { 271 this->breakConnection(tmpConnection); 272 retVal++; 273 } 274 tmpConnection = tmpConIt->nextElement(); 275 } 276 delete tmpConIt; 277 return retVal; 278 } 279 280 281 /** 282 * removes a Connection between an Emitter and a System 283 * @param system The system of the connections to remove 284 * @returns the count of connections that were broken, 0 if no conntection was not found 285 */ 286 unsigned int ParticleEngine::breakConnections(ParticleSystem* system) 287 { 288 unsigned int retVal = 0; 289 // look, if we have already added this connection 290 tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator(); 291 ParticleConnection* tmpConnection = tmpConIt->firstElement(); 292 while(tmpConnection) 293 { 294 if (tmpConnection->system == system) 295 { 296 this->breakConnection(tmpConnection); 297 retVal++; 298 } 299 tmpConnection = tmpConIt->nextElement(); 300 } 301 delete tmpConIt; 302 return retVal; 303 } 257 304 258 305 /** … … 406 453 407 454 } 455 -
trunk/src/lib/particles/particle_engine.h
r5445 r5447 50 50 bool removeSystem(ParticleSystem* system); 51 51 bool removeEmitter(ParticleEmitter* emitter); 52 bool breakConnection(ParticleConnection* connection); 52 53 bool breakConnection(ParticleEmitter* emitter, ParticleSystem* system); 53 bool breakConnection(ParticleConnection* connection); 54 unsigned int breakConnections(ParticleEmitter* emitter); 55 unsigned int breakConnections(ParticleSystem* system); 54 56 55 57 ParticleSystem* getSystemByNumber(unsigned int number) const; -
trunk/src/story_entities/world.cc
r5429 r5447 129 129 130 130 // delete all the initialized Engines. 131 FastFactory::flushAll(true); 131 132 delete LightManager::getInstance(); 132 133 delete TrackManager::getInstance(); … … 138 139 SoundEngine::getInstance()->flushAllBuffers(); 139 140 SoundEngine::getInstance()->flushAllSources(); 140 FastFactory::flushAll(true);141 141 142 142 -
trunk/src/util/fast_factory.h
r5357 r5447 29 29 */ 30 30 #define CREATE_FAST_FACTORY(CLASS_NAME, CLASS_ID) \ 31 tFastFactory<CLASS_NAME>* global_##CLASS_NAME##_FastFactory = tFastFactory<CLASS_NAME>::getFastFactory(CLASS_ID, #CLASS_NAME) 31 FastFactory* global_##CLASS_NAME##_FastFactory = tFastFactory<CLASS_NAME>::getFastFactory(CLASS_ID, #CLASS_NAME) 32 /** 33 * Creates a FastFactory for a Class' static function named ClassName::fastFactory. 34 * @param CLASS_NAME the name of the Class to create the fast-factory for. 35 * @param CLASS_ID the ID of the class to create the fast-factory for @see "class_id.h" 36 * 37 * notice, that the Class to be called, must implement: 38 * static FastFactory* fastFactory; 39 */ 40 #define CREATE_FAST_FACTORY_STATIC(CLASS_NAME, CLASS_ID) \ 41 FastFactory* CLASS_NAME::fastFactory = tFastFactory<CLASS_NAME>::getFastFactory(CLASS_ID, #CLASS_NAME) 32 42 33 43 //! A struct, that holds Lists of Objects of a certain type. -
trunk/src/world_entities/weapons/projectile.h
r5443 r5447 22 22 23 23 #include "world_entity.h" 24 #include "vector.h" 24 25 class FastFactory; 25 26 26 27 class Projectile : public WorldEntity -
trunk/src/world_entities/weapons/test_bullet.cc
r5446 r5447 18 18 #include "test_bullet.h" 19 19 20 #include "model.h"21 #include "vector.h"22 #include "garbage_collector.h"23 20 #include "fast_factory.h" 24 21 … … 34 31 using namespace std; 35 32 36 CREATE_FAST_FACTORY (TestBullet, CL_TEST_BULLET);33 CREATE_FAST_FACTORY_STATIC(TestBullet, CL_TEST_BULLET); 37 34 38 35 /** … … 51 48 this->lifeSpan = 5; 52 49 53 this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 0.01);50 this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5); 54 51 this->emitter->setParent(this); 55 this->emitter->setEmissionRate(20);56 57 52 this->emitter->setSpread(M_2_PI); 58 53 } … … 67 62 68 63 /* this is normaly done by World.cc by deleting the ParticleEngine */ 64 if (TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1) 65 { 66 if (ClassList::exists(TestBullet::trailParticles, CL_PARTICLE_SYSTEM)) 67 delete TestBullet::trailParticles; 68 TestBullet::trailParticles = NULL; 69 } 69 70 if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1) 70 71 { … … 76 77 } 77 78 79 ParticleSystem* TestBullet::trailParticles = NULL; 78 80 ParticleSystem* TestBullet::explosionParticles = NULL; 79 80 81 81 82 void TestBullet::activate() 82 83 { 83 84 State::getWorldEntityList()->add(this); 85 if (unlikely(TestBullet::trailParticles == NULL)) 86 { 87 TestBullet::trailParticles = new ParticleSystem(1000, PARTICLE_SPRITE); 88 TestBullet::trailParticles->setName("TestBulletTrailParticles"); 89 TestBullet::trailParticles->setLifeSpan(.5, .3); 90 TestBullet::trailParticles->setRadius(0.0, .5); 91 TestBullet::trailParticles->setRadius(0.5, 2.0); 92 TestBullet::trailParticles->setRadius(1.0, 5.0); 93 TestBullet::trailParticles->setColor(0.0, 1,0,0,.7); 94 TestBullet::trailParticles->setColor(0.5, .8,.8,0,.5); 95 TestBullet::trailParticles->setColor(1.0, .7,.7,.7,.0); 96 } 84 97 if (unlikely(TestBullet::explosionParticles == NULL)) 85 98 { 86 ClassList::debug(3, CL_PARTICLE_SYSTEM);87 99 TestBullet::explosionParticles = new ParticleSystem(1000, PARTICLE_SPRITE); 88 TestBullet::explosionParticles->setName("TestBullet TrailParticles");100 TestBullet::explosionParticles->setName("TestBulletExplosionParticles"); 89 101 TestBullet::explosionParticles->setLifeSpan(.5, .3); 90 TestBullet::explosionParticles->setRadius(0.0, .5);91 TestBullet::explosionParticles->setRadius( 0.5, 2.0);92 TestBullet::explosionParticles->setRadius(1.0, 5.0);93 TestBullet::explosionParticles->setColor(0.0, 1,0,0,.7);102 TestBullet::explosionParticles->setRadius(0.0, 10); 103 TestBullet::explosionParticles->setRadius(.5, 20.0); 104 TestBullet::explosionParticles->setRadius(1.0, 3.0); 105 TestBullet::explosionParticles->setColor(0.0, 0,1,0,.7); 94 106 TestBullet::explosionParticles->setColor(0.5, .8,.8,0,.5); 95 TestBullet::explosionParticles->setColor(1.0, .7,.7,.7,.0);107 TestBullet::explosionParticles->setColor(1.0, 1,1,1,.0); 96 108 } 97 109 98 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::explosionParticles); 110 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::trailParticles); 111 112 this->emitter->setEmissionRate(20.0); 113 this->emitter->setEmissionVelocity(10.0); 99 114 } 100 115 … … 102 117 void TestBullet::deactivate() 103 118 { 104 ParticleEngine::getInstance()->breakConnection(this->emitter, TestBullet::explosionParticles); 119 ParticleEngine::getInstance()->breakConnections(this->emitter); 120 this->lifeCycle = 0.0; 105 121 106 GarbageCollector::getInstance()->collect(this); 107 this->lifeCycle = 0.0; 122 // GarbageCollector::getInstance()->collect(this); 123 State::getWorldEntityList()->remove(this); 124 TestBullet::fastFactory->kill(this); 108 125 } 109 126 … … 111 128 void TestBullet::collidesWith(WorldEntity* entity, const Vector& location) 112 129 { 113 130 if (this->hitEntity != entity && entity->isA(CL_NPC)) 131 this->destroy(); 132 this->hitEntity = entity; 114 133 } 115 134 … … 125 144 126 145 this->lifeCycle += time/this->lifeSpan; 127 if( this->lifeCycle >= 1 )146 if( this->lifeCycle >= 1.0) 128 147 { 129 148 PRINTF(5)("FINALIZE==========================\n"); 130 149 PRINTF(5)("current life cycle is: %f\n", this->lifeCycle); 131 150 PRINTF(5)("FINALIZE===========================\n"); 132 // this->finalize(); 151 133 152 this->deactivate(); 134 153 } … … 140 159 void TestBullet::destroy () 141 160 { 142 this->deactivate(); 161 printf("DESTROY TestBullet\n"); 162 this->lifeCycle = .95; 163 ParticleEngine::getInstance()->breakConnection(this->emitter, TestBullet::trailParticles); 164 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::explosionParticles); 143 165 144 145 GarbageCollector::getInstance()->collect(this); 166 this->emitter->setEmissionRate(1000.0); 167 this->emitter->setEmissionVelocity(50.0); 168 // this->deactivate(); 146 169 147 170 } -
trunk/src/world_entities/weapons/test_bullet.h
r5443 r5447 13 13 class ParticleSystem; 14 14 class ParticleEmitter; 15 class FastFactory; 15 16 16 17 class TestBullet : public Projectile … … 33 34 34 35 private: 35 static ParticleSystem* explosionParticles; 36 ParticleEmitter* emitter; 36 static FastFactory* fastFactory; 37 static ParticleSystem* trailParticles; 38 static ParticleSystem* explosionParticles; 39 40 ParticleEmitter* emitter; 41 42 43 WorldEntity* hitEntity; // FIXME TEMPORARY 37 44 38 45 };
Note: See TracChangeset
for help on using the changeset viewer.