Camera Component, Editor Viewport Widget refactoring.

- Handle changing of active camera entirely inside CameraComponentController
- Remove a LOT of legacy Cry things related to cameras
- Add a CameraSystemComponent to handle ActiveCameraRequestBus and CameraSystemRequestBus

Signed-off-by: Yuriy Toporovskyy <toporovskyy.y@gmail.com>
This commit is contained in:
Yuriy Toporovskyy
2021-08-04 10:39:57 -04:00
parent 6d2765ef42
commit 73fee0c57e
47 changed files with 1126 additions and 6046 deletions
+58 -56
View File
@@ -57,77 +57,79 @@ void CView::Release()
//------------------------------------------------------------------------
void CView::Update(float frameTime, bool isActive)
{
//FIXME:some cameras may need to be updated always
if (!isActive)
{
return;
}
(void)(frameTime, isActive);
AZ_ErrorOnce("CryLegacy", false, "CryLegacy view system no longer available (CView::Update)");
////FIXME:some cameras may need to be updated always
//if (!isActive)
//{
// return;
//}
if (m_azEntity)
{
m_viewParams.SaveLast();
//if (m_azEntity)
//{
// m_viewParams.SaveLast();
CCamera* pSysCam = &m_pSystem->GetViewCamera();
// CCamera* pSysCam = &m_pSystem->GetViewCamera();
//process screen shaking
ProcessShaking(frameTime);
// //process screen shaking
// ProcessShaking(frameTime);
//FIXME:to let the updateView implementation use the correct shakeVector
m_viewParams.currentShakeShift = m_viewParams.rotation * m_viewParams.currentShakeShift;
// //FIXME:to let the updateView implementation use the correct shakeVector
// m_viewParams.currentShakeShift = m_viewParams.rotation * m_viewParams.currentShakeShift;
m_viewParams.frameTime = frameTime;
//update view position/rotation
if (m_azEntity != nullptr)
{
auto entityTransform = m_azEntity->GetTransform();
if (entityTransform != nullptr)
{
AZ::Transform transform = entityTransform->GetWorldTM();
m_viewParams.position = AZVec3ToLYVec3(transform.GetTranslation());
m_viewParams.rotation = AZQuaternionToLYQuaternion(transform.GetRotation());
}
}
// m_viewParams.frameTime = frameTime;
// //update view position/rotation
// if (m_azEntity != nullptr)
// {
// auto entityTransform = m_azEntity->GetTransform();
// if (entityTransform != nullptr)
// {
// AZ::Transform transform = entityTransform->GetWorldTM();
// m_viewParams.position = AZVec3ToLYVec3(transform.GetTranslation());
// m_viewParams.rotation = AZQuaternionToLYQuaternion(transform.GetRotation());
// }
// }
ApplyFrameAdditiveAngles(m_viewParams.rotation);
// ApplyFrameAdditiveAngles(m_viewParams.rotation);
const float fNearZ = gEnv->pSystem->GetIViewSystem()->GetDefaultZNear();
// const float fNearZ = gEnv->pSystem->GetIViewSystem()->GetDefaultZNear();
//see if the view have to use a custom near clipping plane
const float nearPlane = (m_viewParams.nearplane >= CAMERA_MIN_NEAR) ? (m_viewParams.nearplane) : fNearZ;
const float farPlane = (m_viewParams.farplane > 0.f) ? m_viewParams.farplane : DEFAULT_FAR;
float fov = (m_viewParams.fov < 0.001f) ? DEFAULT_FOV : m_viewParams.fov;
// //see if the view have to use a custom near clipping plane
// const float nearPlane = (m_viewParams.nearplane >= CAMERA_MIN_NEAR) ? (m_viewParams.nearplane) : fNearZ;
// const float farPlane = (m_viewParams.farplane > 0.f) ? m_viewParams.farplane : DEFAULT_FAR;
// float fov = (m_viewParams.fov < 0.001f) ? DEFAULT_FOV : m_viewParams.fov;
m_camera.SetFrustum(pSysCam->GetViewSurfaceX(), pSysCam->GetViewSurfaceZ(), fov, nearPlane, farPlane, pSysCam->GetPixelAspectRatio());
// m_camera.SetFrustum(pSysCam->GetViewSurfaceX(), pSysCam->GetViewSurfaceZ(), fov, nearPlane, farPlane, pSysCam->GetPixelAspectRatio());
//apply shake & set the view matrix
m_viewParams.rotation *= m_viewParams.currentShakeQuat;
m_viewParams.rotation.NormalizeSafe();
m_viewParams.position += m_viewParams.currentShakeShift;
// //apply shake & set the view matrix
// m_viewParams.rotation *= m_viewParams.currentShakeQuat;
// m_viewParams.rotation.NormalizeSafe();
// m_viewParams.position += m_viewParams.currentShakeShift;
// Blending between cameras needs to happen after Camera space rendering calculations have been applied
// so that the m_viewParams.position is in World Space again
m_viewParams.UpdateBlending(frameTime);
// // Blending between cameras needs to happen after Camera space rendering calculations have been applied
// // so that the m_viewParams.position is in World Space again
// m_viewParams.UpdateBlending(frameTime);
// [VR] specific
// Add HMD's pose tracking on top of current camera pose
// Each game-title can decide whether to keep this functionality here or (most likely)
// move it somewhere else.
// // [VR] specific
// // Add HMD's pose tracking on top of current camera pose
// // Each game-title can decide whether to keep this functionality here or (most likely)
// // move it somewhere else.
Quat q = m_viewParams.rotation;
Vec3 pos = m_viewParams.position;
Vec3 p = Vec3(ZERO);
// Quat q = m_viewParams.rotation;
// Vec3 pos = m_viewParams.position;
// Vec3 p = Vec3(ZERO);
Matrix34 viewMtx(q);
viewMtx.SetTranslation(pos + p);
m_camera.SetMatrix(viewMtx);
// Matrix34 viewMtx(q);
// viewMtx.SetTranslation(pos + p);
// m_camera.SetMatrix(viewMtx);
m_camera.SetEntityRotation(m_viewParams.rotation);
m_camera.SetEntityPos(pos);
}
else
{
m_linkedTo = AZ::EntityId(0);
}
// m_camera.SetEntityRotation(m_viewParams.rotation);
// m_camera.SetEntityPos(pos);
//}
//else
//{
// m_linkedTo = AZ::EntityId(0);
//}
}
//-----------------------------------------------------------------------