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

Method shakeCamera

Engine/source/T3D/shapeImage.cpp:3403–3455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3401}
3402
3403void ShapeBase::shakeCamera( U32 imageSlot )
3404{
3405 MountedImage& image = mMountedImageList[imageSlot];
3406 ShapeBaseImageData* imageData = image.dataBlock;
3407
3408 if (!imageData->shakeCamera)
3409 return;
3410
3411 // Warning: this logic was duplicated from Explosion.
3412
3413 // first check if explosion is near camera
3414 GameConnection* connection = GameConnection::getConnectionToServer();
3415 ShapeBase *obj = dynamic_cast<ShapeBase*>(connection->getControlObject());
3416
3417 bool applyShake = true;
3418
3419 if (obj)
3420 {
3421 ShapeBase* cObj = obj;
3422 while ((cObj = cObj->getControlObject()) != 0)
3423 {
3424 if (cObj->useObjsEyePoint())
3425 {
3426 applyShake = false;
3427 break;
3428 }
3429 }
3430 }
3431
3432 if (applyShake && obj)
3433 {
3434 VectorF diff;
3435 getMuzzlePoint(imageSlot, &diff);
3436 diff = obj->getPosition() - diff;
3437 F32 dist = diff.len();
3438 if (dist < imageData->camShakeRadius)
3439 {
3440 CameraShake *camShake = new CameraShake;
3441 camShake->setDuration(imageData->camShakeDuration);
3442 camShake->setFrequency(imageData->camShakeFreq);
3443
3444 F32 falloff = dist / imageData->camShakeRadius;
3445 falloff = 1.0f + falloff * 10.0f;
3446 falloff = 1.0f / (falloff * falloff);
3447
3448 VectorF shakeAmp = imageData->camShakeAmp * falloff;
3449 camShake->setAmplitude(shakeAmp);
3450 camShake->setFalloff(imageData->camShakeFalloff);
3451 camShake->init();
3452 gCamFXMgr.addFX(camShake);
3453 }
3454 }
3455}

Callers

nothing calls this directly

Calls 10

setFrequencyMethod · 0.80
setAmplitudeMethod · 0.80
setFalloffMethod · 0.80
addFXMethod · 0.80
getControlObjectMethod · 0.45
useObjsEyePointMethod · 0.45
getPositionMethod · 0.45
lenMethod · 0.45
setDurationMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected