-------------------------------------------------------------------------------- Description: Main update method called every frame. Here we do all sorts of things: get the position/orientation of the underlying ball and the target ball (if there is any: bombs don't have targets!), update each warheads state and position and calculate the bounding sphere surrounding all warheads on this missile. A
| 109 | // time - current game time |
| 110 | // -------------------------------------------------------------------------------- |
| 111 | void EveMissile::UpdateSyncronous( const EveUpdateContext& updateContext ) |
| 112 | { |
| 113 | EveSpaceObject2::UpdateSyncronous( updateContext ); |
| 114 | Be::Time time = updateContext.GetTime(); |
| 115 | float deltaT = updateContext.GetDeltaT(); |
| 116 | |
| 117 | // get inv ball rotation, is needed for update of each warhead |
| 118 | Matrix invBallRotationMatrix = IdentityMatrix(); |
| 119 | if( m_ballRotation ) |
| 120 | { |
| 121 | Quaternion quat( 0.f, 0.f, 0.f, 1.f ); |
| 122 | // get rotation quaternion of our ball |
| 123 | m_ballRotation->Update( &quat, time ); |
| 124 | // we may need the ball rotation matrix |
| 125 | // inverse it to get inverse! |
| 126 | quat = Inverse( quat ); |
| 127 | // turn it into the matrix we need |
| 128 | invBallRotationMatrix = RotationMatrix( quat ); |
| 129 | } |
| 130 | |
| 131 | // time goes on |
| 132 | m_time += deltaT; |
| 133 | |
| 134 | // get data from destiny |
| 135 | Vector3 myPosition( 0.f, 0.f, 0.f ); |
| 136 | Vector3 myVelocity( 0.f, 0.f, 0.f ); |
| 137 | if( m_ballPosition && m_target ) |
| 138 | { |
| 139 | // Estimate the time to target each frame, this INCLUDES delay and eject time |
| 140 | m_ballPosition->GetValueAt( &myPosition, time ); |
| 141 | m_ballPosition->GetValueDotAt( &myVelocity, time ); |
| 142 | Vector3 targetPositionWS; |
| 143 | m_target->GetDamageLocatorPosition( &targetPositionWS, -1, true ); |
| 144 | |
| 145 | // calc speed |
| 146 | float speed = Length( myVelocity ); |
| 147 | |
| 148 | // is speed of zero is dangerous |
| 149 | if( speed > 0.f ) |
| 150 | { |
| 151 | // update the total alive time based on time already passed and distance / speed of missile ball to target |
| 152 | Vector3 dir( myPosition - targetPositionWS ); |
| 153 | m_estimatedTotalAliveTime = m_time + ( Length( dir ) - m_targetRadius ) / speed; |
| 154 | m_lastValidSpeed = speed; |
| 155 | } |
| 156 | else if( m_lastValidSpeed > 0.f ) |
| 157 | { |
| 158 | // This means the ball has hit the target, but the warhead may still on the way to the target |
| 159 | Vector3 dir( myPosition - targetPositionWS ); |
| 160 | myVelocity = Normalize( dir ); |
| 161 | myVelocity *= m_lastValidSpeed; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | Vector3 worldPos = GetWorldPosition(); |
| 166 | |
| 167 | // update the submissiles aka warheads |
| 168 | for( EveMissileWarheadVector::const_iterator it = m_warheads.begin(); it != m_warheads.end(); ++it ) |
nothing calls this directly
no test coverage detected