CR feedback

Signed-off-by: rhhong <rhhong@amazon.com>
monroegm-disable-blank-issue-2
rhhong 4 years ago
parent 13781a759f
commit 32833c68c7

@ -181,15 +181,26 @@ namespace EMStudio
ResetEnvironment(); ResetEnvironment();
} }
AZ::Vector3 AnimViewportRenderer::GetCenter() const AZ::Vector3 AnimViewportRenderer::GetCharacterCenter() const
{ {
AZ::Vector3 result = AZ::Vector3::CreateZero(); AZ::Vector3 result = AZ::Vector3::CreateZero();
if (!m_actorEntities.empty()) if (!m_actorEntities.empty())
{ {
// Find the actor instance and calculate the center from aabb.
AZ::Vector3 actorCenter = AZ::Vector3::CreateZero();
EMotionFX::Integration::ActorComponent* actorComponent =
m_actorEntities[0]->FindComponent<EMotionFX::Integration::ActorComponent>();
EMotionFX::ActorInstance* actorInstance = actorComponent->GetActorInstance();
if (actorInstance)
{
actorCenter += actorInstance->GetAabb().GetCenter();
}
// Just return the position of the first entity. // Just return the position of the first entity.
AZ::Transform worldTransform; AZ::Transform worldTransform;
AZ::TransformBus::EventResult(worldTransform, m_actorEntities[0]->GetId(), &AZ::TransformBus::Events::GetWorldTM); AZ::TransformBus::EventResult(worldTransform, m_actorEntities[0]->GetId(), &AZ::TransformBus::Events::GetWorldTM);
result = worldTransform.GetTranslation(); result = worldTransform.GetTranslation();
result += actorCenter;
} }
return result; return result;

@ -50,7 +50,7 @@ namespace EMStudio
void Reinit(); void Reinit();
//! Return the center position of the existing objects. //! Return the center position of the existing objects.
AZ::Vector3 GetCenter() const; AZ::Vector3 GetCharacterCenter() const;
private: private:

@ -126,8 +126,7 @@ namespace EMStudio
void AnimViewportWidget::SetCameraViewMode([[maybe_unused]]CameraViewMode mode) void AnimViewportWidget::SetCameraViewMode([[maybe_unused]]CameraViewMode mode)
{ {
// Set the camera view mode. // Set the camera view mode.
AZ::Vector3 targetPosition = m_renderer->GetCenter(); const AZ::Vector3 targetPosition = m_renderer->GetCharacterCenter();
targetPosition.SetZ(targetPosition.GetY() + TargetCenterOffsetZ);
AZ::Vector3 cameraPosition; AZ::Vector3 cameraPosition;
switch (mode) switch (mode)
{ {

@ -35,7 +35,6 @@ namespace EMStudio
void SetCameraViewMode(CameraViewMode mode); void SetCameraViewMode(CameraViewMode mode);
static constexpr float CameraDistance = 2.0f; static constexpr float CameraDistance = 2.0f;
static constexpr float TargetCenterOffsetZ = 1.0f;
AZStd::unique_ptr<AnimViewportRenderer> m_renderer; AZStd::unique_ptr<AnimViewportRenderer> m_renderer;
AZStd::shared_ptr<AzFramework::RotateCameraInput> m_rotateCamera; AZStd::shared_ptr<AzFramework::RotateCameraInput> m_rotateCamera;

Loading…
Cancel
Save