| 403 | } |
| 404 | |
| 405 | void Tr2InteriorScene::Update( Be::Time realTime, Be::Time simTime ) |
| 406 | { |
| 407 | CCP_STATS_ZONE( __FUNCTION__ ); |
| 408 | |
| 409 | if( simTime == m_lastUpdateTime ) |
| 410 | // NB: Multiple calls on the same 'frame' should be ignored, |
| 411 | // but are not strictly errors, according to Dan Speed. |
| 412 | return; |
| 413 | m_lastUpdateTime = simTime; |
| 414 | |
| 415 | Vector3 dir( XMVectorMultiply( |
| 416 | XMVector3Normalize( m_sunDirection ), |
| 417 | XMVectorReplicate( -1.0f ) ) ); |
| 418 | |
| 419 | m_sunDirectionVar = dir; |
| 420 | m_sunDiffuseColorVar = m_sunDiffuseColor; |
| 421 | m_sunSpecularColorVar = m_sunSpecularColor; |
| 422 | m_ambientColorVar = m_ambientColor; |
| 423 | m_cameraPosVar = Tr2Renderer::GetViewPosition(); |
| 424 | |
| 425 | { |
| 426 | CCP_STATS_ZONE( "UpdateCurves" ); |
| 427 | for( TriCurveSetVector::const_iterator it = m_curveSets.begin(); it != m_curveSets.end(); ++it ) |
| 428 | { |
| 429 | ( *it )->Update( realTime, simTime ); |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | { |
| 434 | CCP_STATS_ZONE( "PendingLoads" ); |
| 435 | // Add any dynamics that have finished loading |
| 436 | std::vector<ITr2InteriorDynamic*> dynamicsToRemove; |
| 437 | for( ssize_t index = 0; index < m_dynamicsPendingLoad.GetSize(); ++index ) |
| 438 | { |
| 439 | // If the add succeeded, remove from the pending load list |
| 440 | if( m_dynamicsPendingLoad[index]->AddToScene( m_apexScene ) ) |
| 441 | { |
| 442 | dynamicsToRemove.push_back( m_dynamicsPendingLoad[index] ); |
| 443 | } |
| 444 | } |
| 445 | for( std::vector<ITr2InteriorDynamic*>::iterator it = dynamicsToRemove.begin(); |
| 446 | it != dynamicsToRemove.end(); |
| 447 | ++it ) |
| 448 | { |
| 449 | ssize_t index = m_dynamicsPendingLoad.FindKey( ( *it ) ); |
| 450 | if( index != -1 ) |
| 451 | { |
| 452 | m_dynamicsPendingLoad.Remove( index ); |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | { |
| 458 | CCP_STATS_ZONE( "PrePhysicsUpdate" ); |
| 459 | // Do the pre-physics update on the dynamics |
| 460 | // Note: this used to happen in the cell pre-physics update, but that can cause double animation ticks |
| 461 | // when a skinned object is intersecting multiple cells (e.g. crossing a portal) |
| 462 | for( PITr2InteriorDynamicVector::iterator it = m_dynamics.begin(); it != m_dynamics.end(); ++it ) |
no test coverage detected