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

Method ejectShellCasing

Engine/source/T3D/shapeImage.cpp:3360–3401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3358//----------------------------------------------------------------------------
3359
3360void ShapeBase::ejectShellCasing( U32 imageSlot )
3361{
3362 MountedImage& image = mMountedImageList[imageSlot];
3363 ShapeBaseImageData* imageData = image.dataBlock;
3364
3365 if (!imageData->casing)
3366 return;
3367
3368 // Shell casings are client-side only, so use the render transform.
3369 MatrixF ejectTrans;
3370 getRenderImageTransform( imageSlot, imageData->ejectNode[getImageShapeIndex(image)], &ejectTrans );
3371
3372 Point3F ejectDir = imageData->shellExitDir;
3373 ejectDir.normalize();
3374
3375 F32 ejectSpread = mDegToRad( imageData->shellExitVariance );
3376 MatrixF ejectOrient = MathUtils::createOrientFromDir( ejectDir );
3377
3378 Point3F randomDir;
3379 randomDir.x = mSin( gRandGen.randF( -ejectSpread, ejectSpread ) );
3380 randomDir.y = 1.0;
3381 randomDir.z = mSin( gRandGen.randF( -ejectSpread, ejectSpread ) );
3382 randomDir.normalizeSafe();
3383
3384 ejectOrient.mulV( randomDir );
3385
3386 MatrixF imageTrans = getRenderTransform();
3387 imageTrans.mulV( randomDir );
3388
3389 Point3F shellVel = randomDir * imageData->shellVelocity;
3390 Point3F shellPos = ejectTrans.getPosition();
3391
3392
3393 Debris *casing = new Debris;
3394 casing->onNewDataBlock( imageData->casing, false );
3395 casing->setTransform( imageTrans );
3396
3397 if (!casing->registerObject())
3398 delete casing;
3399 else
3400 casing->init( shellPos, shellVel );
3401}
3402
3403void ShapeBase::shakeCamera( U32 imageSlot )
3404{

Callers

nothing calls this directly

Calls 12

mDegToRadFunction · 0.85
createOrientFromDirFunction · 0.85
mSinFunction · 0.85
randFMethod · 0.80
mulVMethod · 0.80
normalizeMethod · 0.45
normalizeSafeMethod · 0.45
getPositionMethod · 0.45
onNewDataBlockMethod · 0.45
setTransformMethod · 0.45
registerObjectMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected