void ezQtEngineViewWidget::UpdateCameraInterpolation() { if (m_fCameraLerp >= 1.0f) return; const ezTime tNow = ezTime::Now(); const ezTime tDiff = tNow - m_LastCameraUpdate; m_LastCameraUpdate = tNow; m_fCameraLerp += tDiff.GetSeconds() * 2.0f; if (m_fCameraLerp >= 1.0f) m_fCameraLerp = 1.0f; ezCamera& cam = m_pViewConfig->m_Camera; const float fLerpValue = ezMath::Sin(ezAngle::Degree(90.0f * m_fCameraLerp)); ezQuat qRot, qRotFinal; qRot.SetShortestRotation(m_vCameraStartDirection, m_vCameraTargetDirection); qRotFinal.SetSlerp(ezQuat::IdentityQuaternion(), qRot, fLerpValue); const ezVec3 vNewDirection = qRotFinal * m_vCameraStartDirection; const ezVec3 vNewPosition = ezMath::Lerp(m_vCameraStartPosition, m_vCameraTargetPosition, fLerpValue); const float fNewFovOrDim = ezMath::Lerp(m_fCameraStartFovOrDim, m_fCameraTargetFovOrDim, fLerpValue); /// \todo Hard coded up vector cam.LookAt(vNewPosition, vNewPosition + vNewDirection, m_vCameraUp); cam.SetCameraMode(cam.GetCameraMode(), fNewFovOrDim, cam.GetNearPlane(), cam.GetFarPlane()); }
void ezWorld::PostMessage(const ezComponentHandle& receiverComponent, const ezMessage& msg, ezObjectMsgQueueType::Enum queueType, ezTime delay) const { // This method is allowed to be called from multiple threads. QueuedMsgMetaData metaData; metaData.m_uiReceiverComponent = *reinterpret_cast<const ezUInt64*>(&receiverComponent.m_InternalId); EZ_ASSERT_DEBUG((metaData.m_uiReceiverData >> 62) == 0, "Upper 2 bits in component id must not be set"); metaData.m_uiReceiverIsComponent = true; metaData.m_uiRecursive = false; ezRTTIAllocator* pMsgRTTIAllocator = msg.GetDynamicRTTI()->GetAllocator(); if (delay.GetSeconds() > 0.0) { ezMessage* pMsgCopy = pMsgRTTIAllocator->Clone<ezMessage>(&msg, &m_Data.m_Allocator); metaData.m_Due = m_Data.m_Clock.GetAccumulatedTime() + delay; m_Data.m_TimedMessageQueues[queueType].Enqueue(pMsgCopy, metaData); } else { ezMessage* pMsgCopy = pMsgRTTIAllocator->Clone<ezMessage>(&msg, m_Data.m_StackAllocator.GetCurrentAllocator()); m_Data.m_MessageQueues[queueType].Enqueue(pMsgCopy, metaData); } }
ezResult OnScreenLogWriter::Update( ezTime lastFrameDuration ) { if(!m_MessageBuffer.IsEmpty()) { m_fOldestItemFade -= static_cast<float>(lastFrameDuration.GetSeconds() * m_fFadeSpeed); if(m_fOldestItemFade < 0) { m_fOldestItemFade = 1.0f; m_MessageBuffer.PopFront(); } } return EZ_SUCCESS; }
void ezWorld::PostMessage(const ezGameObjectHandle& receiverObject, const ezMessage& msg, ezObjectMsgQueueType::Enum queueType, ezTime delay, bool bRecursive) const { // This method is allowed to be called from multiple threads. QueuedMsgMetaData metaData; metaData.m_uiReceiverObject = receiverObject.m_InternalId.m_Data; metaData.m_uiReceiverIsComponent = false; metaData.m_uiRecursive = bRecursive; ezRTTIAllocator* pMsgRTTIAllocator = msg.GetDynamicRTTI()->GetAllocator(); if (delay.GetSeconds() > 0.0) { ezMessage* pMsgCopy = pMsgRTTIAllocator->Clone<ezMessage>(&msg, &m_Data.m_Allocator); metaData.m_Due = m_Data.m_Clock.GetAccumulatedTime() + delay; m_Data.m_TimedMessageQueues[queueType].Enqueue(pMsgCopy, metaData); } else { ezMessage* pMsgCopy = pMsgRTTIAllocator->Clone<ezMessage>(&msg, m_Data.m_StackAllocator.GetCurrentAllocator()); m_Data.m_MessageQueues[queueType].Enqueue(pMsgCopy, metaData); } }
void SceneEntity::Update(ezTime timeSinceLastUpdate) { float timeSinceLastUpdateSecs = static_cast<float>(timeSinceLastUpdate.GetSeconds()); m_position += m_movementSpeed * timeSinceLastUpdateSecs; m_orientation *= ei::Quaternion(m_rotationSpeed * timeSinceLastUpdateSecs); }