MCPcopy Create free account
hub / github.com/carbonengine/trinity / UpdateAsynchronous

Method UpdateAsynchronous

trinity/Eve/Turret/EveTurretFiringFX.cpp:477–569  ·  view source on GitHub ↗

-------------------------------------------------------------------------------- Description: First thing to do iterate through all the stretch effects and see if the time is right to start playing curveSets. If a stretch effect is running, then update both its source and destination positions. Check also if we have just started an effect and return that as boolean information to the caller. SeeAl

Source from the content-addressed store, hash-verified

475// Returns true if the effect has just fired
476// --------------------------------------------------------------------------------
477bool EveTurretFiringFX::UpdateAsynchronous( const EveUpdateContext& updateContext )
478{
479 float deltaT = updateContext.GetDeltaT();
480 bool retVal = false;
481
482 // check all stretch effects and see if we have to start them
483 for( unsigned int i = 0; i < m_stretch.size(); ++i )
484 {
485 if( m_perMuzzleData[i].started )
486 {
487 m_perMuzzleData[i].elapsedTime += deltaT;
488 }
489
490 if( m_perMuzzleData[i].elapsedTime < m_firingDuration || m_isLoopFiring )
491 {
492 auto stretchEffect = m_stretch[i];
493
494 // do not do all calculations if we are not firing -> waste
495 if( m_isFiring )
496 {
497 // cannot start firing effect directly when entering FIRE state, cause they might have a delay...
498 if( !m_perMuzzleData[i].started )
499 {
500
501 if( m_perMuzzleData[i].readyToStart )
502 {
503 // play two parts of the firing effect
504 StartMuzzleEffect( i );
505 m_perMuzzleData[i].currentStartDelay = 0.f;
506 m_perMuzzleData[i].elapsedTime = 0.f;
507 // don't forget to signal the firing event
508 retVal = true;
509 }
510 else
511 {
512 // reduce delay time, maybe we should start?
513 m_perMuzzleData[i].currentStartDelay -= deltaT;
514 }
515
516 if( m_perMuzzleData[i].currentStartDelay <= 0.f )
517 {
518 // start firing effect next frame
519 m_perMuzzleData[i].readyToStart = true;
520 }
521 }
522
523 // update the stretch effect
524 if( m_perMuzzleData[i].started )
525 {
526 // use complete source transform or only 3d sourcepoint?
527 if( m_useMuzzleTransform && ( m_perMuzzleData[i].muzzlePositionBoneID != INVALID_BONE_INDEX ) )
528 {
529 // pass the whole transform to the stretch effect
530 stretchEffect->SetFiringTransform( m_perMuzzleData[i].muzzleTransform, m_endPosition );
531 }
532 else
533 {
534 // extract the point from the transform matrix

Callers 1

UpdateAsyncronousMethod · 0.80

Calls 8

GetDeltaTMethod · 0.80
sizeMethod · 0.80
GetTranslationMethod · 0.80
SetFiringTransformMethod · 0.45
DisplayEndPointsMethod · 0.45
UpdateEffectAsyncMethod · 0.45
UpdateMethod · 0.45
GetTimeMethod · 0.45

Tested by

no test coverage detected