MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / explode

Method explode

Engine/source/T3D/fx/explosion.cpp:1386–1446  ·  view source on GitHub ↗

---------------------------------------------------------------------------- Explode ----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1384// Explode
1385//----------------------------------------------------------------------------
1386bool Explosion::explode()
1387{
1388 mActive = true;
1389
1390 GameConnection* conn = GameConnection::getConnectionToServer();
1391 if(!conn)
1392 return false;
1393
1394 launchDebris( mInitialNormal );
1395 spawnSubExplosions();
1396
1397 if (bool(mDataBlock->mExplosionShape) && mDataBlock->explosionAnimation != -1) {
1398 mExplosionInstance = new TSShapeInstance(mDataBlock->mExplosionShape, true);
1399
1400 mExplosionThread = mExplosionInstance->addThread();
1401 mExplosionInstance->setSequence(mExplosionThread, mDataBlock->explosionAnimation, 0);
1402 mExplosionInstance->setTimeScale(mExplosionThread, mDataBlock->playSpeed);
1403
1404 mCurrMS = 0;
1405 mEndingMS = U32(mExplosionInstance->getScaledDuration(mExplosionThread) * 1000.0f);
1406
1407 mObjScale.convolve(mDataBlock->explosionScale);
1408 mObjBox = mDataBlock->mExplosionShape->mBounds;
1409 resetWorldBox();
1410 }
1411
1412 SFXProfile* sound_prof = mDataBlock->getSoundProfile();
1413 if (sound_prof)
1414 {
1415 soundProfile_clone = sound_prof->cloneAndPerformSubstitutions(ss_object, ss_index);
1416 SFX->playOnce( soundProfile_clone, &getTransform() );
1417 if (!soundProfile_clone->isTempClone())
1418 soundProfile_clone = 0;
1419 }
1420
1421 if (mDataBlock->particleEmitter) {
1422 mMainEmitter = new ParticleEmitter;
1423 mMainEmitter->setDataBlock(mDataBlock->particleEmitter->cloneAndPerformSubstitutions(ss_object, ss_index));
1424 mMainEmitter->registerObject();
1425
1426 mMainEmitter->emitParticles(getPosition(), mInitialNormal, mDataBlock->particleRadius,
1427 Point3F::Zero, U32(mDataBlock->particleDensity * mFade));
1428 }
1429
1430 for( S32 i=0; i<ExplosionData::EC_NUM_EMITTERS; i++ )
1431 {
1432 if( mDataBlock->emitterList[i] != NULL )
1433 {
1434 ParticleEmitter * pEmitter = new ParticleEmitter;
1435 pEmitter->setDataBlock(mDataBlock->emitterList[i]->cloneAndPerformSubstitutions(ss_object, ss_index));
1436 if( !pEmitter->registerObject() )
1437 {
1438 Con::warnf( ConsoleLogEntry::General, "Could not register emitter for particle of class: %s", mDataBlock->getName() );
1439 SAFE_DELETE(pEmitter);
1440 }
1441 mEmitterList[i] = pEmitter;
1442 }
1443 }

Callers

nothing calls this directly

Calls 15

getPositionFunction · 0.85
getScaledDurationMethod · 0.80
isTempCloneMethod · 0.80
setDataBlockMethod · 0.80
U32Enum · 0.50
warnfFunction · 0.50
addThreadMethod · 0.45
setSequenceMethod · 0.45
setTimeScaleMethod · 0.45
convolveMethod · 0.45
playOnceMethod · 0.45

Tested by

no test coverage detected