Merge branch 'main' into SC_migration_branch

This commit is contained in:
balibhan
2021-05-04 15:19:18 +05:30
20 changed files with 219 additions and 83 deletions
@@ -816,7 +816,7 @@ namespace AZ
template<size_t Index> template<size_t Index>
static void ReflectUnpackMethodFold(BehaviorContext::ClassBuilder<ContainerType>& builder) static void ReflectUnpackMethodFold(BehaviorContext::ClassBuilder<ContainerType>& builder)
{ {
AZStd::string methodName = AZStd::string::format("Get%ld", Index); const AZStd::string methodName = AZStd::string::format("Get%zu", Index);
builder->Method(methodName.data(), [](ContainerType& value) { return AZStd::get<Index>(value); }) builder->Method(methodName.data(), [](ContainerType& value) { return AZStd::get<Index>(value); })
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Attribute(AZ::ScriptCanvasAttributes::TupleGetFunctionIndex, Index) ->Attribute(AZ::ScriptCanvasAttributes::TupleGetFunctionIndex, Index)
@@ -137,7 +137,7 @@ namespace AzFramework::ProjectManager
} }
AZ::IO::FixedMaxPath pythonPath = engineRootPath / "python"; AZ::IO::FixedMaxPath pythonPath = engineRootPath / "python";
pythonPath /= AZ_TRAIT_AZFRAMEWORK_PYTHON_SHELL; pythonPath /= AZ_TRAIT_AZFRAMEWORK_PYTHON_SHELL;
auto cmdPath = AZ::IO::FixedMaxPathString::format("%s %s%s --executable_path=%s --parent_pid=%" PRId64, pythonPath.Native().c_str(), auto cmdPath = AZ::IO::FixedMaxPathString::format("%s %s%s --executable_path=%s --parent_pid=%" PRIu32, pythonPath.Native().c_str(),
debugOption.c_str(), (projectManagerPath / projectsScript).c_str(), executablePath.c_str(), AZ::Platform::GetCurrentProcessId()); debugOption.c_str(), (projectManagerPath / projectsScript).c_str(), executablePath.c_str(), AZ::Platform::GetCurrentProcessId());
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo; AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
@@ -12,14 +12,19 @@
#include "CameraInput.h" #include "CameraInput.h"
#include <AzCore/Console/IConsole.h>
#include <AzCore/Math/MathUtils.h> #include <AzCore/Math/MathUtils.h>
#include <AzCore/Math/Plane.h> #include <AzCore/Math/Plane.h>
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h> #include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
#include <AzFramework/Windowing/WindowBus.h> #include <AzFramework/Windowing/WindowBus.h>
AZ_CVAR(
float, ed_newCameraSystemDefaultPlaneHeight, 34.0f, nullptr, AZ::ConsoleFunctorFlags::Null,
"The default height of the ground plane to do intersection tests against when orbiting");
namespace AzFramework namespace AzFramework
{ {
void CameraSystem::HandleEvents(const InputEvent& event) bool CameraSystem::HandleEvents(const InputEvent& event)
{ {
if (const auto& cursor_motion = AZStd::get_if<CursorMotionEvent>(&event)) if (const auto& cursor_motion = AZStd::get_if<CursorMotionEvent>(&event))
{ {
@@ -30,10 +35,10 @@ namespace AzFramework
m_scrollDelta = scroll->m_delta; m_scrollDelta = scroll->m_delta;
} }
m_cameras.HandleEvents(event); return m_cameras.HandleEvents(event);
} }
Camera CameraSystem::StepCamera(const Camera& targetCamera, float deltaTime) Camera CameraSystem::StepCamera(const Camera& targetCamera, const float deltaTime)
{ {
const auto cursorDelta = m_currentCursorPosition.has_value() && m_lastCursorPosition.has_value() const auto cursorDelta = m_currentCursorPosition.has_value() && m_lastCursorPosition.has_value()
? m_currentCursorPosition.value() - m_lastCursorPosition.value() ? m_currentCursorPosition.value() - m_lastCursorPosition.value()
@@ -51,36 +56,41 @@ namespace AzFramework
return nextCamera; return nextCamera;
} }
void Cameras::AddCamera(AZStd::shared_ptr<CameraInput> camera_input) void Cameras::AddCamera(AZStd::shared_ptr<CameraInput> cameraInput)
{ {
m_idleCameraInputs.push_back(AZStd::move(camera_input)); m_idleCameraInputs.push_back(AZStd::move(cameraInput));
} }
void Cameras::HandleEvents(const InputEvent& event) bool Cameras::HandleEvents(const InputEvent& event)
{ {
for (auto& camera_input : m_activeCameraInputs) bool handling = false;
for (auto& cameraInput : m_activeCameraInputs)
{ {
camera_input->HandleEvents(event); cameraInput->HandleEvents(event);
handling = !cameraInput->Idle() || handling;
} }
for (auto& camera_input : m_idleCameraInputs) for (auto& cameraInput : m_idleCameraInputs)
{ {
camera_input->HandleEvents(event); cameraInput->HandleEvents(event);
} }
return handling;
} }
Camera Cameras::StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, const float deltaTime) Camera Cameras::StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, const float deltaTime)
{ {
for (int i = 0; i < m_idleCameraInputs.size();) for (int i = 0; i < m_idleCameraInputs.size();)
{ {
auto& camera_input = m_idleCameraInputs[i]; auto& cameraInput = m_idleCameraInputs[i];
const bool can_begin = camera_input->Beginning() && const bool canBegin = cameraInput->Beginning() &&
std::all_of(m_activeCameraInputs.cbegin(), m_activeCameraInputs.cend(), std::all_of(m_activeCameraInputs.cbegin(), m_activeCameraInputs.cend(),
[](const auto& input) { return !input->Exclusive(); }) && [](const auto& input) { return !input->Exclusive(); }) &&
(!camera_input->Exclusive() || (camera_input->Exclusive() && m_activeCameraInputs.empty())); (!cameraInput->Exclusive() || (cameraInput->Exclusive() && m_activeCameraInputs.empty()));
if (can_begin)
if (canBegin)
{ {
m_activeCameraInputs.push_back(camera_input); m_activeCameraInputs.push_back(cameraInput);
using AZStd::swap; using AZStd::swap;
swap(m_idleCameraInputs[i], m_idleCameraInputs[m_idleCameraInputs.size() - 1]); swap(m_idleCameraInputs[i], m_idleCameraInputs[m_idleCameraInputs.size() - 1]);
m_idleCameraInputs.pop_back(); m_idleCameraInputs.pop_back();
@@ -93,25 +103,25 @@ namespace AzFramework
// accumulate // accumulate
Camera nextCamera = targetCamera; Camera nextCamera = targetCamera;
for (auto& camera_input : m_activeCameraInputs) for (auto& cameraInput : m_activeCameraInputs)
{ {
nextCamera = camera_input->StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime); nextCamera = cameraInput->StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime);
} }
for (int i = 0; i < m_activeCameraInputs.size();) for (int i = 0; i < m_activeCameraInputs.size();)
{ {
auto& camera_input = m_activeCameraInputs[i]; auto& cameraInput = m_activeCameraInputs[i];
if (camera_input->Ending()) if (cameraInput->Ending())
{ {
camera_input->ClearActivation(); cameraInput->ClearActivation();
m_idleCameraInputs.push_back(camera_input); m_idleCameraInputs.push_back(cameraInput);
using AZStd::swap; using AZStd::swap;
swap(m_activeCameraInputs[i], m_activeCameraInputs[m_activeCameraInputs.size() - 1]); swap(m_activeCameraInputs[i], m_activeCameraInputs[m_activeCameraInputs.size() - 1]);
m_activeCameraInputs.pop_back(); m_activeCameraInputs.pop_back();
} }
else else
{ {
camera_input->ContinueActivation(); cameraInput->ContinueActivation();
i++; i++;
} }
} }
@@ -154,14 +164,14 @@ namespace AzFramework
{ {
Camera nextCamera = targetCamera; Camera nextCamera = targetCamera;
nextCamera.m_pitch += float(cursorDelta.m_y) * m_props.m_rotateSpeed; nextCamera.m_pitch -= float(cursorDelta.m_y) * m_props.m_rotateSpeed;
nextCamera.m_yaw += float(cursorDelta.m_x) * m_props.m_rotateSpeed; nextCamera.m_yaw -= float(cursorDelta.m_x) * m_props.m_rotateSpeed;
auto clamp_rotation = [](const float angle) { return std::fmod(angle + AZ::Constants::TwoOverPi, AZ::Constants::TwoOverPi); }; const auto clampRotation = [](const float angle) { return std::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); };
nextCamera.m_yaw = clamp_rotation(nextCamera.m_yaw); nextCamera.m_yaw = clampRotation(nextCamera.m_yaw);
// clamp pitch to be +-90 degrees // clamp pitch to be +-90 degrees
nextCamera.m_pitch = AZ::GetClamp(nextCamera.m_pitch, -AZ::Constants::Pi * 0.5f, AZ::Constants::Pi * 0.5f); nextCamera.m_pitch = AZ::GetClamp(nextCamera.m_pitch, -AZ::Constants::HalfPi, AZ::Constants::HalfPi);
return nextCamera; return nextCamera;
} }
@@ -190,18 +200,18 @@ namespace AzFramework
{ {
Camera nextCamera = targetCamera; Camera nextCamera = targetCamera;
const auto pan_axes = m_panAxesFn(nextCamera); const auto panAxes = m_panAxesFn(nextCamera);
const auto delta_pan_x = float(cursorDelta.m_x) * pan_axes.m_horizontalAxis * m_props.m_panSpeed; const auto deltaPanX = float(cursorDelta.m_x) * panAxes.m_horizontalAxis * m_props.m_panSpeed;
const auto delta_pan_y = float(cursorDelta.m_y) * pan_axes.m_verticalAxis * m_props.m_panSpeed; const auto deltaPanY = float(cursorDelta.m_y) * panAxes.m_verticalAxis * m_props.m_panSpeed;
const auto inv = [](const bool invert) { const auto inv = [](const bool invert) {
constexpr float Dir[] = {1.0f, -1.0f}; constexpr float Dir[] = {1.0f, -1.0f};
return Dir[static_cast<int>(invert)]; return Dir[static_cast<int>(invert)];
}; };
nextCamera.m_lookAt += delta_pan_x * inv(m_props.m_panInvertX); nextCamera.m_lookAt += deltaPanX * inv(m_props.m_panInvertX);
nextCamera.m_lookAt += delta_pan_y * -inv(m_props.m_panInvertY); nextCamera.m_lookAt += deltaPanY * -inv(m_props.m_panInvertY);
return nextCamera; return nextCamera;
} }
@@ -285,10 +295,10 @@ namespace AzFramework
{ {
Camera nextCamera = targetCamera; Camera nextCamera = targetCamera;
const auto translation_basis = m_translationAxesFn(nextCamera); const auto translationBasis = m_translationAxesFn(nextCamera);
const auto axisX = translation_basis.GetBasisX(); const auto axisX = translationBasis.GetBasisX();
const auto axisY = translation_basis.GetBasisY(); const auto axisY = translationBasis.GetBasisY();
const auto axisZ = translation_basis.GetBasisZ(); const auto axisZ = translationBasis.GetBasisZ();
const float speed = [boost = m_boost, props = m_props]() { const float speed = [boost = m_boost, props = m_props]() {
return props.m_translateSpeed * (boost ? props.m_boostMultiplier : 1.0f); return props.m_translateSpeed * (boost ? props.m_boostMultiplier : 1.0f);
@@ -344,10 +354,6 @@ namespace AzFramework
{ {
if (input->m_channelId == InputDeviceKeyboard::Key::ModifierAltL) if (input->m_channelId == InputDeviceKeyboard::Key::ModifierAltL)
{ {
if (input->m_state == InputChannel::State::Updated)
{
goto end;
}
if (input->m_state == InputChannel::State::Began) if (input->m_state == InputChannel::State::Began)
{ {
BeginActivation(); BeginActivation();
@@ -358,7 +364,7 @@ namespace AzFramework
} }
} }
} }
end:
if (Active()) if (Active())
{ {
m_orbitCameras.HandleEvents(event); m_orbitCameras.HandleEvents(event);
@@ -366,16 +372,18 @@ namespace AzFramework
} }
Camera OrbitCameraInput::StepCamera( Camera OrbitCameraInput::StepCamera(
const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, float deltaTime) const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, const float deltaTime)
{ {
Camera nextCamera = targetCamera; Camera nextCamera = targetCamera;
if (Beginning()) if (Beginning())
{ {
float hit_distance = 0.0f; float hit_distance = 0.0f;
if (AZ::Plane::CreateFromNormalAndPoint(AZ::Vector3::CreateAxisZ(), AZ::Vector3::CreateZero()) if (AZ::Plane::CreateFromNormalAndPoint(
.CastRay(targetCamera.Translation(), targetCamera.Rotation().GetBasisY() * m_props.m_maxOrbitDistance, hit_distance)) AZ::Vector3::CreateAxisZ(), AZ::Vector3::CreateAxisZ(ed_newCameraSystemDefaultPlaneHeight))
.CastRay(targetCamera.Translation(), targetCamera.Rotation().GetBasisY(), hit_distance))
{ {
hit_distance = AZStd::min(hit_distance, m_props.m_maxOrbitDistance);
nextCamera.m_lookDist = -hit_distance; nextCamera.m_lookDist = -hit_distance;
nextCamera.m_lookAt = targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * hit_distance; nextCamera.m_lookAt = targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * hit_distance;
} }
@@ -388,7 +396,6 @@ namespace AzFramework
if (Active()) if (Active())
{ {
// todo: need to return nested cameras to idle state when ending
nextCamera = m_orbitCameras.StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime); nextCamera = m_orbitCameras.StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime);
} }
@@ -413,7 +420,7 @@ namespace AzFramework
Camera OrbitDollyScrollCameraInput::StepCamera( Camera OrbitDollyScrollCameraInput::StepCamera(
const Camera& targetCamera, [[maybe_unused]] const ScreenVector& cursorDelta, const float scrollDelta, const Camera& targetCamera, [[maybe_unused]] const ScreenVector& cursorDelta, const float scrollDelta,
[[maybe_unused]] float deltaTime) [[maybe_unused]] const float deltaTime)
{ {
Camera nextCamera = targetCamera; Camera nextCamera = targetCamera;
nextCamera.m_lookDist = AZ::GetMin(nextCamera.m_lookDist + scrollDelta * m_props.m_dollySpeed, 0.0f); nextCamera.m_lookDist = AZ::GetMin(nextCamera.m_lookDist + scrollDelta * m_props.m_dollySpeed, 0.0f);
@@ -457,7 +464,7 @@ namespace AzFramework
} }
Camera ScrollTranslationCameraInput::StepCamera( Camera ScrollTranslationCameraInput::StepCamera(
const Camera& targetCamera, [[maybe_unused]] const ScreenVector& cursorDelta, float scrollDelta, const Camera& targetCamera, [[maybe_unused]] const ScreenVector& cursorDelta, const float scrollDelta,
[[maybe_unused]] const float deltaTime) [[maybe_unused]] const float deltaTime)
{ {
Camera nextCamera = targetCamera; Camera nextCamera = targetCamera;
@@ -477,25 +484,26 @@ namespace AzFramework
const auto clamp_rotation = [](const float angle) { return std::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); }; const auto clamp_rotation = [](const float angle) { return std::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); };
// keep yaw in 0 - 360 range // keep yaw in 0 - 360 range
float target_yaw = clamp_rotation(targetCamera.m_yaw); float targetYaw = clamp_rotation(targetCamera.m_yaw);
const float current_yaw = clamp_rotation(currentCamera.m_yaw); const float currentYaw = clamp_rotation(currentCamera.m_yaw);
auto sign = [](const float value) { return static_cast<float>((0.0f < value) - (value < 0.0f)); }; // return the sign of the float input (-1, 0, 1)
const auto sign = [](const float value) { return aznumeric_cast<float>((0.0f < value) - (value < 0.0f)); };
// ensure smooth transition when moving across 0 - 360 boundary // ensure smooth transition when moving across 0 - 360 boundary
const float yaw_delta = target_yaw - current_yaw; const float yawDelta = targetYaw - currentYaw;
if (std::abs(yaw_delta) >= AZ::Constants::Pi) if (std::abs(yawDelta) >= AZ::Constants::Pi)
{ {
target_yaw -= AZ::Constants::TwoPi * sign(yaw_delta); targetYaw -= AZ::Constants::TwoPi * sign(yawDelta);
} }
Camera camera; Camera camera;
// note: the math for the lerp smoothing implementation for camera rotation and translation was inspired by this excellent // note: the math for the lerp smoothing implementation for camera rotation and translation was inspired by this excellent
// article by Scott Lembcke: https://www.gamasutra.com/blogs/ScottLembcke/20180404/316046/Improved_Lerp_Smoothing.php // article by Scott Lembcke: https://www.gamasutra.com/blogs/ScottLembcke/20180404/316046/Improved_Lerp_Smoothing.php
const float lookRate = std::exp2(props.m_lookSmoothness); const float lookRate = std::exp2(props.m_lookSmoothness);
const float lookT = std::exp2(-lookRate * deltaTime); const float lookT = std::exp2(-lookRate * deltaTime);
camera.m_pitch = AZ::Lerp(targetCamera.m_pitch, currentCamera.m_pitch, lookT); camera.m_pitch = AZ::Lerp(targetCamera.m_pitch, currentCamera.m_pitch, lookT);
camera.m_yaw = AZ::Lerp(target_yaw, current_yaw, lookT); camera.m_yaw = AZ::Lerp(targetYaw, currentYaw, lookT);
const float moveRate = std::exp2(props.m_moveSmoothness); const float moveRate = std::exp2(props.m_moveSmoothness);
const float moveT = std::exp2(-moveRate * deltaTime); const float moveT = std::exp2(-moveRate * deltaTime);
camera.m_lookDist = AZ::Lerp(targetCamera.m_lookDist, currentCamera.m_lookDist, moveT); camera.m_lookDist = AZ::Lerp(targetCamera.m_lookDist, currentCamera.m_lookDist, moveT);
@@ -508,6 +516,11 @@ namespace AzFramework
const auto& inputChannelId = inputChannel.GetInputChannelId(); const auto& inputChannelId = inputChannel.GetInputChannelId();
const auto& inputDeviceId = inputChannel.GetInputDevice().GetInputDeviceId(); const auto& inputDeviceId = inputChannel.GetInputDevice().GetInputDeviceId();
const bool wasMouseButton =
AZStd::any_of(InputDeviceMouse::Button::All.begin(), InputDeviceMouse::Button::All.end(), [inputChannelId](const auto& button) {
return button == inputChannelId;
});
if (inputChannelId == InputDeviceMouse::SystemCursorPosition) if (inputChannelId == InputDeviceMouse::SystemCursorPosition)
{ {
AZ::Vector2 systemCursorPositionNormalized = AZ::Vector2::CreateZero(); AZ::Vector2 systemCursorPositionNormalized = AZ::Vector2::CreateZero();
@@ -521,7 +534,7 @@ namespace AzFramework
{ {
return ScrollEvent{inputChannel.GetValue()}; return ScrollEvent{inputChannel.GetValue()};
} }
else if (InputDeviceMouse::IsMouseDevice(inputDeviceId) || InputDeviceKeyboard::IsKeyboardDevice(inputDeviceId)) else if ((InputDeviceMouse::IsMouseDevice(inputDeviceId) && wasMouseButton) || InputDeviceKeyboard::IsKeyboardDevice(inputDeviceId))
{ {
return DiscreteInputEvent{inputChannelId, inputChannel.GetState()}; return DiscreteInputEvent{inputChannelId, inputChannel.GetState()};
} }
@@ -12,6 +12,7 @@
#pragma once #pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/Math/Matrix3x3.h> #include <AzCore/Math/Matrix3x3.h>
#include <AzCore/Math/Transform.h> #include <AzCore/Math/Transform.h>
#include <AzCore/std/containers/variant.h> #include <AzCore/std/containers/variant.h>
@@ -20,11 +21,28 @@
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h> #include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h> #include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
#include <AzFramework/Viewport/ScreenGeometry.h> #include <AzFramework/Viewport/ScreenGeometry.h>
#include <AzFramework/Viewport/ViewportId.h>
namespace AzFramework namespace AzFramework
{ {
struct WindowSize; struct WindowSize;
// to be moved
class ModernViewportCameraControllerRequests : public AZ::EBusTraits
{
public:
using BusIdType = AzFramework::ViewportId; ///< ViewportId - used to address requests to this EBus.
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
virtual void SetTargetCameraTransform(const AZ::Transform& transform) = 0;
protected:
~ModernViewportCameraControllerRequests() = default;
};
using ModernViewportCameraControllerRequestBus = AZ::EBus<ModernViewportCameraControllerRequests>;
struct Camera struct Camera
{ {
AZ::Vector3 m_lookAt = AZ::Vector3::CreateZero(); //!< Position of camera when m_lookDist is zero, AZ::Vector3 m_lookAt = AZ::Vector3::CreateZero(); //!< Position of camera when m_lookDist is zero,
@@ -51,8 +69,8 @@ namespace AzFramework
inline AZ::Transform Camera::Transform() const inline AZ::Transform Camera::Transform() const
{ {
return AZ::Transform::CreateTranslation(m_lookAt) * AZ::Transform::CreateRotationX(m_pitch) * return AZ::Transform::CreateTranslation(m_lookAt) * AZ::Transform::CreateRotationZ(m_yaw) *
AZ::Transform::CreateRotationZ(m_yaw) * AZ::Transform::CreateTranslation(AZ::Vector3::CreateAxisZ(m_lookDist)); AZ::Transform::CreateRotationX(m_pitch) * AZ::Transform::CreateTranslation(AZ::Vector3::CreateAxisY(m_lookDist));
} }
inline AZ::Matrix3x3 Camera::Rotation() const inline AZ::Matrix3x3 Camera::Rotation() const
@@ -171,7 +189,7 @@ namespace AzFramework
{ {
public: public:
void AddCamera(AZStd::shared_ptr<CameraInput> cameraInput); void AddCamera(AZStd::shared_ptr<CameraInput> cameraInput);
void HandleEvents(const InputEvent& event); bool HandleEvents(const InputEvent& event);
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime); Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime);
void Reset(); void Reset();
@@ -183,7 +201,7 @@ namespace AzFramework
class CameraSystem class CameraSystem
{ {
public: public:
void HandleEvents(const InputEvent& event); bool HandleEvents(const InputEvent& event);
Camera StepCamera(const Camera& targetCamera, float deltaTime); Camera StepCamera(const Camera& targetCamera, float deltaTime);
Cameras m_cameras; Cameras m_cameras;
@@ -308,7 +326,7 @@ namespace AzFramework
enum class TranslationType enum class TranslationType
{ {
// clang-format off // clang-format off
Nil = 0, Nil = 0,
Forward = 1 << 0, Forward = 1 << 0,
Backward = 1 << 1, Backward = 1 << 1,
Left = 1 << 2, Left = 1 << 2,
@@ -369,7 +387,7 @@ namespace AzFramework
struct Props struct Props
{ {
float m_dollySpeed = 0.2f; float m_dollySpeed = 0.02f;
} m_props; } m_props;
}; };
@@ -393,7 +411,7 @@ namespace AzFramework
struct Props struct Props
{ {
float m_translateSpeed = 0.2f; float m_translateSpeed = 0.02f;
} m_props; } m_props;
}; };
@@ -411,7 +429,7 @@ namespace AzFramework
struct Props struct Props
{ {
float m_defaultOrbitDistance = 15.0f; float m_defaultOrbitDistance = 60.0f;
float m_maxOrbitDistance = 100.0f; float m_maxOrbitDistance = 100.0f;
} m_props; } m_props;
}; };
+15 -2
View File
@@ -28,6 +28,11 @@
#include <AzFramework/Archive/IArchive.h> #include <AzFramework/Archive/IArchive.h>
#include <AzFramework/API/ApplicationAPI.h> #include <AzFramework/API/ApplicationAPI.h>
#include <AzFramework/API/AtomActiveInterface.h> #include <AzFramework/API/AtomActiveInterface.h>
#include <AzFramework/Viewport/CameraInput.h>
// Atom
#include <Atom/RPI.Public/ViewportContext.h>
#include <Atom/RPI.Public/ViewportContextBus.h>
// AzToolsFramework // AzToolsFramework
#include <AzToolsFramework/Slice/SliceUtilities.h> #include <AzToolsFramework/Slice/SliceUtilities.h>
@@ -647,13 +652,21 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
CViewport* pVP = GetIEditor()->GetViewManager()->GetView(i); CViewport* pVP = GetIEditor()->GetViewManager()->GetView(i);
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
tm.SetTranslation(vp);
if (pVP) if (pVP)
{ {
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
tm.SetTranslation(vp);
pVP->SetViewTM(tm); pVP->SetViewTM(tm);
} }
if (auto viewportContext = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get()->GetDefaultViewportContext())
{
AzFramework::ModernViewportCameraControllerRequestBus::Event(
viewportContext->GetId(), &AzFramework::ModernViewportCameraControllerRequestBus::Events::SetTargetCameraTransform,
LYTransformToAZTransform(tm));
}
// Load grid. // Load grid.
auto gridName = QString("Grid%1").arg(useOldViewFormat ? "" : QString::number(i)); auto gridName = QString("Grid%1").arg(useOldViewFormat ? "" : QString::number(i));
XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData()); XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData());
+2 -2
View File
@@ -1626,8 +1626,8 @@ void EditorViewportWidget::keyPressEvent(QKeyEvent* event)
QCoreApplication::sendEvent(GetIEditor()->GetEditorMainWindow(), event); QCoreApplication::sendEvent(GetIEditor()->GetEditorMainWindow(), event);
} }
// NOTE: we keep track of keypresses and releases explicitly because the OS/Qt will insert a slight delay between sending // NOTE: we keep track of key presses and releases explicitly because the OS/Qt will insert a slight delay between sending
// keyevents when the key is held down. This is standard, but makes responding to key events for game style input silly // key events when the key is held down. This is standard, but makes responding to key events for game style input silly
// because we want the movement to be butter smooth. // because we want the movement to be butter smooth.
if (!event->isAutoRepeat()) if (!event->isAutoRepeat())
{ {
@@ -14,9 +14,13 @@
#include <Atom/RPI.Public/ViewportContext.h> #include <Atom/RPI.Public/ViewportContext.h>
#include <Atom/RPI.Public/ViewportContextBus.h> #include <Atom/RPI.Public/ViewportContextBus.h>
#include <AzCore/Console/IConsole.h>
#include <AzCore/Interface/Interface.h> #include <AzCore/Interface/Interface.h>
#include <AzFramework/Viewport/ScreenGeometry.h> #include <AzFramework/Viewport/ScreenGeometry.h>
#include <AzFramework/Windowing/WindowBus.h> #include <AzFramework/Windowing/WindowBus.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h>
AZ_CVAR(bool, ed_newCameraSystemDebug, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Enable debug drawing for the new camera system");
namespace SandboxEditor namespace SandboxEditor
{ {
@@ -73,6 +77,15 @@ namespace SandboxEditor
m_camera = m_targetCamera; m_camera = m_targetCamera;
} }
AzFramework::ViewportDebugDisplayEventBus::Handler::BusConnect(AzToolsFramework::GetEntityContextId());
AzFramework::ModernViewportCameraControllerRequestBus::Handler::BusConnect(viewportId);
}
ModernViewportCameraControllerInstance::~ModernViewportCameraControllerInstance()
{
AzFramework::ModernViewportCameraControllerRequestBus::Handler::BusDisconnect();
AzFramework::ViewportDebugDisplayEventBus::Handler::BusDisconnect();
} }
bool ModernViewportCameraControllerInstance::HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) bool ModernViewportCameraControllerInstance::HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event)
@@ -80,8 +93,7 @@ namespace SandboxEditor
AzFramework::WindowSize windowSize; AzFramework::WindowSize windowSize;
AzFramework::WindowRequestBus::EventResult( AzFramework::WindowRequestBus::EventResult(
windowSize, event.m_windowHandle, &AzFramework::WindowRequestBus::Events::GetClientAreaSize); windowSize, event.m_windowHandle, &AzFramework::WindowRequestBus::Events::GetClientAreaSize);
m_cameraSystem.HandleEvents(AzFramework::BuildInputEvent(event.m_inputChannel, windowSize)); return m_cameraSystem.HandleEvents(AzFramework::BuildInputEvent(event.m_inputChannel, windowSize));
return true; // consume event
} }
void ModernViewportCameraControllerInstance::UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event) void ModernViewportCameraControllerInstance::UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event)
@@ -89,9 +101,25 @@ namespace SandboxEditor
if (auto viewportContext = RetrieveViewportContext(GetViewportId())) if (auto viewportContext = RetrieveViewportContext(GetViewportId()))
{ {
m_targetCamera = m_cameraSystem.StepCamera(m_targetCamera, event.m_deltaTime.count()); m_targetCamera = m_cameraSystem.StepCamera(m_targetCamera, event.m_deltaTime.count());
m_camera = AzFramework::SmoothCamera(m_camera, m_targetCamera, m_smoothProps, event.m_deltaTime.count()); m_camera =
AzFramework::SmoothCamera(m_camera, m_targetCamera, m_smoothProps, event.m_deltaTime.count());
viewportContext->SetCameraTransform(m_camera.Transform()); viewportContext->SetCameraTransform(m_camera.Transform());
} }
} }
void ModernViewportCameraControllerInstance::DisplayViewport(
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay)
{
if (ed_newCameraSystemDebug)
{
debugDisplay.SetColor(AZ::Colors::White);
debugDisplay.DrawWireSphere(m_targetCamera.m_lookAt, 0.5f);
}
}
void ModernViewportCameraControllerInstance::SetTargetCameraTransform(const AZ::Transform& transform)
{
m_targetCamera.m_lookAt = transform.GetTranslation();
}
} // namespace SandboxEditor } // namespace SandboxEditor
@@ -12,20 +12,30 @@
#pragma once #pragma once
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <AzFramework/Viewport/CameraInput.h> #include <AzFramework/Viewport/CameraInput.h>
#include <AzFramework/Viewport/MultiViewportController.h> #include <AzFramework/Viewport/MultiViewportController.h>
namespace SandboxEditor namespace SandboxEditor
{ {
class ModernViewportCameraControllerInstance final : public AzFramework::MultiViewportControllerInstanceInterface class ModernViewportCameraControllerInstance final : public AzFramework::MultiViewportControllerInstanceInterface,
private AzFramework::ViewportDebugDisplayEventBus::Handler,
private AzFramework::ModernViewportCameraControllerRequestBus::Handler
{ {
public: public:
explicit ModernViewportCameraControllerInstance(AzFramework::ViewportId viewportId); explicit ModernViewportCameraControllerInstance(AzFramework::ViewportId viewportId);
~ModernViewportCameraControllerInstance();
// MultiViewportControllerInstanceInterface overrides ... // MultiViewportControllerInstanceInterface overrides ...
bool HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) override; bool HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) override;
void UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event) override; void UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event) override;
// AzFramework::ViewportDebugDisplayEventBus overrides ...
void DisplayViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;
// ModernViewportCameraControllerRequestBus overrides ...
void SetTargetCameraTransform(const AZ::Transform& transform) override;
private: private:
AzFramework::Camera m_camera; AzFramework::Camera m_camera;
AzFramework::Camera m_targetCamera; AzFramework::Camera m_targetCamera;
@@ -26,7 +26,7 @@ class CPerforceSourceControl
public: public:
// constructor // constructor
CPerforceSourceControl() = default; CPerforceSourceControl() = default;
~CPerforceSourceControl() = default; virtual ~CPerforceSourceControl() = default;
void Init(); void Init();
@@ -117,7 +117,7 @@ namespace AWSCore
result.m_content.append(AZStd::string::format(Detail::FOOTER_FMT, m_boundary.c_str())); result.m_content.append(AZStd::string::format(Detail::FOOTER_FMT, m_boundary.c_str()));
// Populate the metadata // Populate the metadata
result.m_contentLength = AZStd::string::format("%lu", result.m_content.length()); result.m_contentLength = AZStd::string::format("%zu", result.m_content.length());
result.m_contentType = AZStd::string::format("multipart/form-data; boundary=%s", m_boundary.c_str()); result.m_contentType = AZStd::string::format("multipart/form-data; boundary=%s", m_boundary.c_str());
return result; return result;
+2
View File
@@ -30,6 +30,8 @@ namespace UnitTest
void ShutdownInternal() override; void ShutdownInternal() override;
}; };
class BufferPool;
class Buffer class Buffer
: public AZ::RHI::Buffer : public AZ::RHI::Buffer
{ {
-1
View File
@@ -21,7 +21,6 @@ namespace UnitTest
class Query class Query
: public AZ::RHI::Query : public AZ::RHI::Query
{ {
friend class QueryPool;
public: public:
AZ_CLASS_ALLOCATOR(Query, AZ::SystemAllocator, 0); AZ_CLASS_ALLOCATOR(Query, AZ::SystemAllocator, 0);
@@ -32,7 +32,7 @@ namespace AZ
AZ_Assert(commandList && commandList->IsRecording() == false, "Command list not valid."); AZ_Assert(commandList && commandList->IsRecording() == false, "Command list not valid.");
} }
} }
#endif() #endif
return AZStd::move(m_workRequest); return AZStd::move(m_workRequest);
} }
+2
View File
@@ -36,6 +36,7 @@ ly_add_target(
metastream_shared_files.cmake metastream_shared_files.cmake
${pal_source_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake ${pal_source_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
PLATFORM_INCLUDE_FILES PLATFORM_INCLUDE_FILES
${pal_source_dir}/metastream_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
${common_source_dir}/${PAL_TRAIT_COMPILER_ID}/metastream_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake ${common_source_dir}/${PAL_TRAIT_COMPILER_ID}/metastream_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake
INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES
PRIVATE PRIVATE
@@ -62,6 +63,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
metastream_shared_files.cmake metastream_shared_files.cmake
${pal_source_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake ${pal_source_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
PLATFORM_INCLUDE_FILES PLATFORM_INCLUDE_FILES
${pal_source_dir}/metastream_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
${common_source_dir}/${PAL_TRAIT_COMPILER_ID}/metastream_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake ${common_source_dir}/${PAL_TRAIT_COMPILER_ID}/metastream_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake
INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES
PRIVATE PRIVATE
@@ -0,0 +1,10 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
@@ -11,7 +11,3 @@
# CivetHttpServer.cpp uses a try catch block # CivetHttpServer.cpp uses a try catch block
set(LY_COMPILE_OPTIONS PRIVATE /EHsc) set(LY_COMPILE_OPTIONS PRIVATE /EHsc)
set(LY_BUILD_DEPENDENCIES
PRIVATE
3rdParty::civetweb
)
@@ -0,0 +1,10 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
@@ -0,0 +1,10 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
@@ -0,0 +1,15 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(LY_BUILD_DEPENDENCIES
PRIVATE
3rdParty::civetweb
)
@@ -0,0 +1,10 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#