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

Method ejectShellCasing

Engine/source/T3D/shapeImage.cpp:3324–3365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3322//----------------------------------------------------------------------------
3323
3324void ShapeBase::ejectShellCasing( U32 imageSlot )
3325{
3326 MountedImage& image = mMountedImageList[imageSlot];
3327 ShapeBaseImageData* imageData = image.dataBlock;
3328
3329 if (!imageData->casing)
3330 return;
3331
3332 // Shell casings are client-side only, so use the render transform.
3333 MatrixF ejectTrans;
3334 getRenderImageTransform( imageSlot, imageData->ejectNode[getImageShapeIndex(image)], &ejectTrans );
3335
3336 Point3F ejectDir = imageData->shellExitDir;
3337 ejectDir.normalize();
3338
3339 F32 ejectSpread = mDegToRad( imageData->shellExitVariance );
3340 MatrixF ejectOrient = MathUtils::createOrientFromDir( ejectDir );
3341
3342 Point3F randomDir;
3343 randomDir.x = mSin( gRandGen.randF( -ejectSpread, ejectSpread ) );
3344 randomDir.y = 1.0;
3345 randomDir.z = mSin( gRandGen.randF( -ejectSpread, ejectSpread ) );
3346 randomDir.normalizeSafe();
3347
3348 ejectOrient.mulV( randomDir );
3349
3350 MatrixF imageTrans = getRenderTransform();
3351 imageTrans.mulV( randomDir );
3352
3353 Point3F shellVel = randomDir * imageData->shellVelocity;
3354 Point3F shellPos = ejectTrans.getPosition();
3355
3356
3357 Debris *casing = new Debris;
3358 casing->onNewDataBlock( imageData->casing, false );
3359 casing->setTransform( imageTrans );
3360
3361 if (!casing->registerObject())
3362 delete casing;
3363 else
3364 casing->init( shellPos, shellVel );
3365}
3366
3367void ShapeBase::shakeCamera( U32 imageSlot )
3368{

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