[ATOM-15538] Material Editor camera zoom speed adjusts to model size
This commit is contained in:
+3
@@ -47,6 +47,9 @@ namespace MaterialEditor
|
||||
//! @param distanceMax furthest camera can be from the target
|
||||
virtual void GetExtents(float& distanceMin, float& distanceMax) const = 0;
|
||||
|
||||
//! Get bounding sphere radius of the active model
|
||||
virtual float GetRadius() const = 0;
|
||||
|
||||
//! Reset camera to default position and rotation
|
||||
virtual void Reset() = 0;
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace MaterialEditor
|
||||
MaterialEditorViewportInputControllerRequestBus::BroadcastResult(
|
||||
m_targetPosition,
|
||||
&MaterialEditorViewportInputControllerRequestBus::Handler::GetTargetPosition);
|
||||
MaterialEditorViewportInputControllerRequestBus::BroadcastResult(
|
||||
m_radius, &MaterialEditorViewportInputControllerRequestBus::Handler::GetRadius);
|
||||
}
|
||||
|
||||
void Behavior::End()
|
||||
@@ -119,7 +121,7 @@ namespace MaterialEditor
|
||||
|
||||
float Behavior::GetSensitivityZ()
|
||||
{
|
||||
return 0.001f;
|
||||
return 0.001f * AZ::GetMax(0.5f, m_radius);
|
||||
}
|
||||
|
||||
AZ::Quaternion Behavior::LookRotation(AZ::Vector3 forward)
|
||||
|
||||
@@ -54,6 +54,8 @@ namespace MaterialEditor
|
||||
float m_y = 0;
|
||||
//! delta scroll wheel accumulated during current frame
|
||||
float m_z = 0;
|
||||
//! Model radius
|
||||
float m_radius = 1.0f;
|
||||
|
||||
AZ::EntityId m_cameraEntityId;
|
||||
AZ::Vector3 m_targetPosition = AZ::Vector3::CreateZero();
|
||||
|
||||
+7
-3
@@ -114,6 +114,11 @@ namespace MaterialEditor
|
||||
distanceMax = m_distanceMax;
|
||||
}
|
||||
|
||||
float MaterialEditorViewportInputController::GetRadius() const
|
||||
{
|
||||
return m_radius;
|
||||
}
|
||||
|
||||
void MaterialEditorViewportInputController::UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event)
|
||||
{
|
||||
if (m_keysChanged)
|
||||
@@ -306,11 +311,10 @@ namespace MaterialEditor
|
||||
if (modelAsset.IsReady())
|
||||
{
|
||||
const AZ::Aabb& aabb = modelAsset->GetAabb();
|
||||
float radius;
|
||||
aabb.GetAsSphere(m_modelCenter, radius);
|
||||
aabb.GetAsSphere(m_modelCenter, m_radius);
|
||||
|
||||
m_distanceMin = 0.5f * AZ::GetMin(AZ::GetMin(aabb.GetExtents().GetX(), aabb.GetExtents().GetY()), aabb.GetExtents().GetZ()) + DepthNear;
|
||||
m_distanceMax = radius * MaxDistanceMultiplier;
|
||||
m_distanceMax = m_radius * MaxDistanceMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -43,6 +43,7 @@ namespace MaterialEditor
|
||||
void SetTargetPosition(const AZ::Vector3& targetPosition) override;
|
||||
float GetDistanceToTarget() const override;
|
||||
void GetExtents(float& distanceMin, float& distanceMax) const override;
|
||||
float GetRadius() const override;
|
||||
void Reset() override;
|
||||
void SetFieldOfView(float value) override;
|
||||
bool IsCameraCentered() const override;
|
||||
@@ -96,6 +97,8 @@ namespace MaterialEditor
|
||||
float m_distanceMin = 1.0f;
|
||||
//! Maximum distance from camera to target
|
||||
float m_distanceMax = 10.0f;
|
||||
//! Model radius
|
||||
float m_radius = 1.0f;
|
||||
//! True if camera is centered on a model
|
||||
bool m_isCameraCentered = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user