---------------------------------------------------------------------------- Launch Debris ----------------------------------------------------------------------------
| 1298 | // Launch Debris |
| 1299 | //---------------------------------------------------------------------------- |
| 1300 | void Explosion::launchDebris( Point3F &axis ) |
| 1301 | { |
| 1302 | GameConnection* conn = GameConnection::getConnectionToServer(); |
| 1303 | if(!conn) |
| 1304 | return; |
| 1305 | |
| 1306 | bool hasDebris = false; |
| 1307 | for( S32 j=0; j<ExplosionData::EC_NUM_DEBRIS_TYPES; j++ ) |
| 1308 | { |
| 1309 | if( mDataBlock->debrisList[j] ) |
| 1310 | { |
| 1311 | hasDebris = true; |
| 1312 | break; |
| 1313 | } |
| 1314 | } |
| 1315 | if( !hasDebris ) |
| 1316 | { |
| 1317 | return; |
| 1318 | } |
| 1319 | |
| 1320 | Point3F axisx; |
| 1321 | if (mFabs(axis.z) < 0.999f) |
| 1322 | mCross(axis, Point3F(0.0f, 0.0f, 1.0f), &axisx); |
| 1323 | else |
| 1324 | mCross(axis, Point3F(0.0f, 1.0f, 0.0f), &axisx); |
| 1325 | axisx.normalize(); |
| 1326 | |
| 1327 | Point3F pos( 0.0f, 0.0f, 0.5f ); |
| 1328 | pos += getPosition(); |
| 1329 | |
| 1330 | |
| 1331 | U32 numDebris = mDataBlock->debrisNum + sgRandom.randI( -mDataBlock->debrisNumVariance, mDataBlock->debrisNumVariance ); |
| 1332 | |
| 1333 | for( S32 i=0; i<numDebris; i++ ) |
| 1334 | { |
| 1335 | |
| 1336 | Point3F launchDir = MathUtils::randomDir( axis, mDataBlock->debrisThetaMin, mDataBlock->debrisThetaMax, |
| 1337 | mDataBlock->debrisPhiMin, mDataBlock->debrisPhiMax ); |
| 1338 | |
| 1339 | F32 debrisVel = mDataBlock->debrisVelocity + mDataBlock->debrisVelocityVariance * sgRandom.randF( -1.0f, 1.0f ); |
| 1340 | |
| 1341 | launchDir *= debrisVel; |
| 1342 | |
| 1343 | Debris *debris = new Debris; |
| 1344 | debris->setSubstitutionData(ss_object, ss_index); |
| 1345 | debris->setDataBlock(mDataBlock->debrisList[0]->cloneAndPerformSubstitutions(ss_object, ss_index)); |
| 1346 | debris->setTransform( getTransform() ); |
| 1347 | debris->init( pos, launchDir ); |
| 1348 | |
| 1349 | if( !debris->registerObject() ) |
| 1350 | { |
| 1351 | Con::warnf( ConsoleLogEntry::General, "Could not register debris for class: %s", mDataBlock->getName() ); |
| 1352 | delete debris; |
| 1353 | debris = NULL; |
| 1354 | } |
| 1355 | } |
| 1356 | } |
| 1357 |
nothing calls this directly
no test coverage detected