void RPG_MeshTrailEffectComponent::UpdateHistory(float fAbsTime) { m_historyCount = hkvMath::Min(m_historyCount + 1, m_numSegments); m_historyPos = (m_historyPos + 1) % m_numSegments; VTrailHistoryEntry &entry( m_history[m_historyPos] ); VisObject3D_cl *pObj = (VisObject3D_cl *)GetOwner(); hkvMat3 rotation = pObj->GetRotationMatrix(); const hkvVec3 &vPos(pObj->GetPosition()); entry.m_start = rotation.transformDirection(m_relStart); entry.m_end = rotation.transformDirection(m_relEnd); entry.m_start += vPos; entry.m_end += vPos; entry.m_time = fAbsTime; }
void VFmodManager::RunTick(float fTimeDelta) { if (!IsInitialized()) return; VISION_PROFILE_FUNCTION(PROFILING_FMOD_OVERALL); // profiling scope { VISION_PROFILE_FUNCTION(PROFILING_FMOD_PUREUPDATE); VASSERT(m_pEventSystem!=NULL); // update Fmod listener attributes VisObject3D_cl *pListener = m_pListenerObject ? m_pListenerObject : Vision::Camera.GetMainCamera(); if (!pListener) return; hkvVec3 vCamPos = pListener->GetPosition(); hkvVec3 vDir(pListener->GetObjDir()), vRight(pListener->GetObjDir_Right()), vUp(pListener->GetObjDir_Up()); vUp = -vUp; // compensate for coordinate system m_pEventSystem->set3DListenerAttributes(0, (FMOD_VECTOR *)&vCamPos, NULL, (FMOD_VECTOR *)&vDir, (FMOD_VECTOR *)&vUp); // no speed (yet) // update all sound objects SoundInstances().Update(); // update all events Events().Update(); // update Fmod event system m_fTimeLeftOver += fTimeDelta; if (m_fTimeLeftOver > m_config.fTimeStep) { m_pEventSystem->update(); #ifdef VFMOD_SUPPORTS_NETWORK if (m_config.bUseNetworkSystem) FMOD::NetEventSystem_Update(); #endif m_fTimeLeftOver = hkvMath::mod (m_fTimeLeftOver, m_config.fTimeStep); } } // do not purge sounds/ events in vForge, in order to allow toggling playback via hotspot button if (Vision::Editor.IsInEditor()) return; if (m_bAnyStopped) { VISION_PROFILE_FUNCTION(PROFILING_FMOD_PURGE); // all sounds/ events that have finished playing are removed from handling SoundInstances().PurgeNotPlaying(); Events().PurgeNotPlaying(); m_bAnyStopped = false; // reset any stopped flag } }
void VFmodManager::RunTick(float fTimeDelta) { VISION_PROFILE_FUNCTION(PROFILING_FMOD_OVERALL); if (!IsInitialized()) { if (!IsOutputDevicePresent()) InitDevice(); return; } // profiling scope { VISION_PROFILE_FUNCTION(PROFILING_FMOD_PUREUPDATE); VASSERT(m_pEventSystem!=NULL); // update Fmod listener attributes VisObject3D_cl *pListener = m_pListenerObject; if (pListener == NULL) { // The listener is the main camera. Check for teleportation since the last Fmod update, in // which case we won't use the position difference to calculate the listener speed. VisContextCamera_cl* pCamera = Vision::Camera.GetMainCamera(); VisRenderContext_cl* pContext = VisRenderContext_cl::GetMainRenderContext(); if (pCamera != NULL && pContext != NULL) { if (m_bLastListenerPositionValid && pCamera->GetLastTeleported() > m_iFrameOfLastUpdate) m_bLastListenerPositionValid = false; m_iFrameOfLastUpdate = pContext->GetLastRenderedFrame(); pListener = pCamera; } } if (!pListener) return; hkvVec3 vCamPos = pListener->GetPosition(); hkvVec3 vDir(pListener->GetObjDir()), vRight(pListener->GetObjDir_Right()), vUp(pListener->GetObjDir_Up()); // Determine the camera velocity based on the previous known position hkvVec3 vCamVel(m_bLastListenerPositionValid && (fTimeDelta > 0.f) ? (vCamPos - m_vLastListenerPosition) * (1.f / fTimeDelta) : hkvVec3::ZeroVector()); m_vLastListenerPosition = vCamPos; m_bLastListenerPositionValid = true; vUp = -vUp; // compensate for coordinate system m_pEventSystem->set3DListenerAttributes(0, (FMOD_VECTOR *)&vCamPos, (FMOD_VECTOR *)&vCamVel, (FMOD_VECTOR *)&vDir, (FMOD_VECTOR *)&vUp); // update all sound objects SoundInstances().Update(fTimeDelta); // update all events Events().Update(fTimeDelta); // update Fmod event system m_fTimeLeftOver += fTimeDelta; if (m_fTimeLeftOver > m_config.fTimeStep) { m_pEventSystem->update(); #ifdef VFMOD_SUPPORTS_NETWORK if (m_config.bUseNetworkSystem) FMOD::NetEventSystem_Update(); #endif m_fTimeLeftOver = hkvMath::mod (m_fTimeLeftOver, m_config.fTimeStep); } } // do not purge sounds/ events in vForge, in order to allow toggling playback via hotspot button if (Vision::Editor.IsInEditor()) return; if (m_bAnyStopped) { VISION_PROFILE_FUNCTION(PROFILING_FMOD_PURGE); // all sounds/ events that have finished playing are removed from handling SoundInstances().PurgeNotPlaying(); Events().PurgeNotPlaying(); m_bAnyStopped = false; // reset any stopped flag } }