Merge branch 'main' into ly-as-sdk/LYN-2948

This commit is contained in:
phistere
2021-05-11 10:52:47 -05:00
373 changed files with 1416 additions and 40311 deletions
@@ -189,7 +189,7 @@ namespace AZ
if (!WasLoadSuccess(result.GetOutcome()))
{
// This if is a hack around fault in the JSON serialization system
// Jira: https://jira.agscollab.com/browse/LY-106587
// Jira: LY-106587
if (message != "No part of the string could be interpreted as a uuid.")
{
deserializeError.append(message);
+22 -11
View File
@@ -1,14 +1,14 @@
/*
* 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.
*
*/
* 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.
*
*/
#pragma once
@@ -17,4 +17,15 @@
namespace AZStd
{
using std::abs;
}
using std::acos;
using std::asin;
using std::atan;
using std::atan2;
using std::cos;
using std::exp2;
using std::fmod;
using std::round;
using std::sin;
using std::sqrt;
using std::tan;
} // namespace AZStd
@@ -29,14 +29,14 @@ namespace AzFramework
AZ_CVAR(float, ed_cameraSystemOrbitDollyScrollSpeed, 0.02f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemOrbitDollyCursorSpeed, 0.01f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemScrollTranslateSpeed, 0.02f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemDefaultOrbitDistance, 60.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemMaxOrbitDistance, 100.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemMaxOrbitDistance, 60.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemLookSmoothness, 5.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemTranslateSmoothness, 5.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemRotateSpeed, 0.005f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemPanSpeed, 0.01f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(bool, ed_cameraSystemPanInvertX, true, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(bool, ed_cameraSystemPanInvertY, true, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemLookDeadzone, 2.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(
AZ::CVarFixedString, ed_cameraSystemTranslateForwardKey, "keyboard_key_alphanumeric_W", nullptr, AZ::ConsoleFunctorFlags::Null, "");
@@ -125,22 +125,22 @@ namespace AzFramework
{
if (orientation.GetElement(2, 0) > -1.0f)
{
x = std::atan2(orientation.GetElement(2, 1), orientation.GetElement(2, 2));
y = std::asin(-orientation.GetElement(2, 0));
z = std::atan2(orientation.GetElement(1, 0), orientation.GetElement(0, 0));
x = AZStd::atan2(orientation.GetElement(2, 1), orientation.GetElement(2, 2));
y = AZStd::asin(-orientation.GetElement(2, 0));
z = AZStd::atan2(orientation.GetElement(1, 0), orientation.GetElement(0, 0));
}
else
{
x = 0.0f;
y = AZ::Constants::Pi * 0.5f;
z = -std::atan2(-orientation.GetElement(2, 1), orientation.GetElement(1, 1));
z = -AZStd::atan2(-orientation.GetElement(2, 1), orientation.GetElement(1, 1));
}
}
else
{
x = 0.0f;
y = -AZ::Constants::Pi * 0.5f;
z = std::atan2(-orientation.GetElement(1, 2), orientation.GetElement(1, 1));
z = AZStd::atan2(-orientation.GetElement(1, 2), orientation.GetElement(1, 1));
}
return {x, y, z};
@@ -150,31 +150,35 @@ namespace AzFramework
{
const auto eulerAngles = AzFramework::EulerAngles(AZ::Matrix3x3::CreateFromTransform(transform));
camera.m_lookAt = transform.GetTranslation();
camera.m_pitch = eulerAngles.GetX();
camera.m_yaw = eulerAngles.GetZ();
// note: m_lookDist is negative so we must invert it here
camera.m_lookAt = transform.GetTranslation() + (camera.Rotation().GetBasisY() * -camera.m_lookDist);
}
static ScreenVector CursorDelta(const AZStd::optional<ScreenPoint>& currentPosition, const AZStd::optional<ScreenPoint>& lastPosition)
{
return currentPosition.has_value() && lastPosition.has_value() ? currentPosition.value() - lastPosition.value()
: ScreenVector(0, 0);
}
bool CameraSystem::HandleEvents(const InputEvent& event)
{
if (const auto& cursor_motion = AZStd::get_if<CursorMotionEvent>(&event))
if (const auto& cursor = AZStd::get_if<CursorEvent>(&event))
{
m_currentCursorPosition = cursor_motion->m_position;
m_currentCursorPosition = cursor->m_position;
}
else if (const auto& scroll = AZStd::get_if<ScrollEvent>(&event))
{
m_scrollDelta = scroll->m_delta;
}
return m_cameras.HandleEvents(event);
return m_cameras.HandleEvents(event, CursorDelta(m_currentCursorPosition, m_lastCursorPosition), m_scrollDelta);
}
Camera CameraSystem::StepCamera(const Camera& targetCamera, const float deltaTime)
{
const auto cursorDelta = m_currentCursorPosition.has_value() && m_lastCursorPosition.has_value()
? m_currentCursorPosition.value() - m_lastCursorPosition.value()
: ScreenVector(0, 0);
const auto cursorDelta = CursorDelta(m_currentCursorPosition, m_lastCursorPosition);
if (m_currentCursorPosition.has_value())
{
m_lastCursorPosition = m_currentCursorPosition;
@@ -192,18 +196,18 @@ namespace AzFramework
m_idleCameraInputs.push_back(AZStd::move(cameraInput));
}
bool Cameras::HandleEvents(const InputEvent& event)
bool Cameras::HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta)
{
bool handling = false;
for (auto& cameraInput : m_activeCameraInputs)
{
cameraInput->HandleEvents(event);
cameraInput->HandleEvents(event, cursorDelta, scrollDelta);
handling = !cameraInput->Idle() || handling;
}
for (auto& cameraInput : m_idleCameraInputs)
{
cameraInput->HandleEvents(event);
cameraInput->HandleEvents(event, cursorDelta, scrollDelta);
}
return handling;
@@ -215,8 +219,8 @@ namespace AzFramework
{
auto& cameraInput = m_idleCameraInputs[i];
const bool canBegin = cameraInput->Beginning() &&
std::all_of(m_activeCameraInputs.cbegin(), m_activeCameraInputs.cend(),
[](const auto& input) { return !input->Exclusive(); }) &&
AZStd::all_of(m_activeCameraInputs.cbegin(), m_activeCameraInputs.cend(),
[](const auto& input) { return !input->Exclusive(); }) &&
(!cameraInput->Exclusive() || (cameraInput->Exclusive() && m_activeCameraInputs.empty()));
if (canBegin)
@@ -271,7 +275,7 @@ namespace AzFramework
}
}
void RotateCameraInput::HandleEvents(const InputEvent& event)
void RotateCameraInput::HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, [[maybe_unused]] float scrollDelta)
{
if (const auto& input = AZStd::get_if<DiscreteInputEvent>(&event))
{
@@ -279,14 +283,27 @@ namespace AzFramework
{
if (input->m_state == InputChannel::State::Began)
{
BeginActivation();
m_tryingToBegin = true;
m_moveAccumulator = 0.0f;
}
else if (input->m_state == InputChannel::State::Ended)
{
m_tryingToBegin = false;
EndActivation();
}
}
}
if (m_tryingToBegin)
{
// only allow the action to begin if the mouse has been moved a small amount
m_moveAccumulator += ScreenVectorLength(cursorDelta);
if (m_moveAccumulator > ed_cameraSystemLookDeadzone)
{
BeginActivation();
m_tryingToBegin = false;
}
}
}
Camera RotateCameraInput::StepCamera(
@@ -298,7 +315,7 @@ namespace AzFramework
nextCamera.m_pitch -= float(cursorDelta.m_y) * ed_cameraSystemRotateSpeed;
nextCamera.m_yaw -= float(cursorDelta.m_x) * ed_cameraSystemRotateSpeed;
const auto clampRotation = [](const float angle) { return std::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); };
const auto clampRotation = [](const float angle) { return AZStd::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); };
nextCamera.m_yaw = clampRotation(nextCamera.m_yaw);
// clamp pitch to be +-90 degrees
@@ -307,7 +324,8 @@ namespace AzFramework
return nextCamera;
}
void PanCameraInput::HandleEvents(const InputEvent& event)
void PanCameraInput::HandleEvents(
const InputEvent& event, [[maybe_unused]] const ScreenVector& cursorDelta, [[maybe_unused]] float scrollDelta)
{
if (const auto& input = AZStd::get_if<DiscreteInputEvent>(&event))
{
@@ -382,7 +400,8 @@ namespace AzFramework
return TranslationType::Nil;
}
void TranslateCameraInput::HandleEvents(const InputEvent& event)
void TranslateCameraInput::HandleEvents(
const InputEvent& event, [[maybe_unused]] const ScreenVector& cursorDelta, [[maybe_unused]] float scrollDelta)
{
if (const auto& input = AZStd::get_if<DiscreteInputEvent>(&event))
{
@@ -478,7 +497,7 @@ namespace AzFramework
m_boost = false;
}
void OrbitCameraInput::HandleEvents(const InputEvent& event)
void OrbitCameraInput::HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta)
{
if (const auto* input = AZStd::get_if<DiscreteInputEvent>(&event))
{
@@ -497,7 +516,7 @@ namespace AzFramework
if (Active())
{
m_orbitCameras.HandleEvents(event);
m_orbitCameras.HandleEvents(event, cursorDelta, scrollDelta);
}
}
@@ -509,8 +528,10 @@ namespace AzFramework
if (Beginning())
{
float hit_distance = 0.0f;
if (AZ::Plane::CreateFromNormalAndPoint(AZ::Vector3::CreateAxisZ(), AZ::Vector3::CreateAxisZ(ed_cameraSystemDefaultPlaneHeight))
.CastRay(targetCamera.Translation(), targetCamera.Rotation().GetBasisY(), hit_distance))
AZ::Plane::CreateFromNormalAndPoint(AZ::Vector3::CreateAxisZ(), AZ::Vector3::CreateAxisZ(ed_cameraSystemDefaultPlaneHeight))
.CastRay(targetCamera.Translation(), targetCamera.Rotation().GetBasisY(), hit_distance);
if (hit_distance > 0.0f)
{
hit_distance = AZStd::min<float>(hit_distance, ed_cameraSystemMaxOrbitDistance);
nextCamera.m_lookDist = -hit_distance;
@@ -539,7 +560,8 @@ namespace AzFramework
return nextCamera;
}
void OrbitDollyScrollCameraInput::HandleEvents(const InputEvent& event)
void OrbitDollyScrollCameraInput::HandleEvents(
const InputEvent& event, [[maybe_unused]] const ScreenVector& cursorDelta, [[maybe_unused]] float scrollDelta)
{
if (const auto* scroll = AZStd::get_if<ScrollEvent>(&event))
{
@@ -557,7 +579,8 @@ namespace AzFramework
return nextCamera;
}
void OrbitDollyCursorMoveCameraInput::HandleEvents(const InputEvent& event)
void OrbitDollyCursorMoveCameraInput::HandleEvents(
const InputEvent& event, [[maybe_unused]] const ScreenVector& cursorDelta, [[maybe_unused]] float scrollDelta)
{
if (const auto& input = AZStd::get_if<DiscreteInputEvent>(&event))
{
@@ -584,7 +607,8 @@ namespace AzFramework
return nextCamera;
}
void ScrollTranslationCameraInput::HandleEvents(const InputEvent& event)
void ScrollTranslationCameraInput::HandleEvents(
const InputEvent& event, [[maybe_unused]] const ScreenVector& cursorDelta, [[maybe_unused]] float scrollDelta)
{
if (const auto* scroll = AZStd::get_if<ScrollEvent>(&event))
{
@@ -610,7 +634,7 @@ namespace AzFramework
Camera SmoothCamera(const Camera& currentCamera, const Camera& targetCamera, const float deltaTime)
{
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 AZStd::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); };
// keep yaw in 0 - 360 range
float targetYaw = clamp_rotation(targetCamera.m_yaw);
@@ -621,7 +645,7 @@ namespace AzFramework
// ensure smooth transition when moving across 0 - 360 boundary
const float yawDelta = targetYaw - currentYaw;
if (std::abs(yawDelta) >= AZ::Constants::Pi)
if (AZStd::abs(yawDelta) >= AZ::Constants::Pi)
{
targetYaw -= AZ::Constants::TwoPi * sign(yawDelta);
}
@@ -629,12 +653,12 @@ namespace AzFramework
Camera camera;
// 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
const float lookRate = std::exp2(ed_cameraSystemLookSmoothness);
const float lookT = std::exp2(-lookRate * deltaTime);
const float lookRate = AZStd::exp2(ed_cameraSystemLookSmoothness);
const float lookT = AZStd::exp2(-lookRate * deltaTime);
camera.m_pitch = AZ::Lerp(targetCamera.m_pitch, currentCamera.m_pitch, lookT);
camera.m_yaw = AZ::Lerp(targetYaw, currentYaw, lookT);
const float moveRate = std::exp2(ed_cameraSystemTranslateSmoothness);
const float moveT = std::exp2(-moveRate * deltaTime);
const float moveRate = AZStd::exp2(ed_cameraSystemTranslateSmoothness);
const float moveT = AZStd::exp2(-moveRate * deltaTime);
camera.m_lookDist = AZ::Lerp(targetCamera.m_lookDist, currentCamera.m_lookDist, moveT);
camera.m_lookAt = targetCamera.m_lookAt.Lerp(currentCamera.m_lookAt, moveT);
return camera;
@@ -655,7 +679,7 @@ namespace AzFramework
const auto* position = inputChannel.GetCustomData<AzFramework::InputChannel::PositionData2D>();
AZ_Assert(position, "Expected PositionData2D but found nullptr");
return CursorMotionEvent{ScreenPoint(
return CursorEvent{ScreenPoint(
position->m_normalizedPosition.GetX() * windowSize.m_width, position->m_normalizedPosition.GetY() * windowSize.m_height)};
}
else if (inputChannelId == InputDeviceMouse::Movement::Z)
@@ -70,7 +70,7 @@ namespace AzFramework
void UpdateCameraFromTransform(Camera& camera, const AZ::Transform& transform);
struct CursorMotionEvent
struct CursorEvent
{
ScreenPoint m_position;
};
@@ -86,7 +86,7 @@ namespace AzFramework
InputChannel::State m_state; //!< Channel state. (e.g. Begin/update/end event).
};
using InputEvent = AZStd::variant<AZStd::monostate, CursorMotionEvent, ScrollEvent, DiscreteInputEvent>;
using InputEvent = AZStd::variant<AZStd::monostate, CursorEvent, ScrollEvent, DiscreteInputEvent>;
class CameraInput
{
@@ -147,7 +147,7 @@ namespace AzFramework
ResetImpl();
}
virtual void HandleEvents(const InputEvent& event) = 0;
virtual void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) = 0;
virtual Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) = 0;
virtual bool Exclusive() const
@@ -170,7 +170,7 @@ namespace AzFramework
{
public:
void AddCamera(AZStd::shared_ptr<CameraInput> cameraInput);
bool HandleEvents(const InputEvent& event);
bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta);
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime);
void Reset();
@@ -201,11 +201,13 @@ namespace AzFramework
{
}
void HandleEvents(const InputEvent& event) override;
void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
private:
InputChannelId m_rotateChannelId;
float m_moveAccumulator = 0.0f;
bool m_tryingToBegin = false;
};
struct PanAxes
@@ -243,7 +245,7 @@ namespace AzFramework
, m_panChannelId(panChannelId)
{
}
void HandleEvents(const InputEvent& event) override;
void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
private:
@@ -285,7 +287,7 @@ namespace AzFramework
: m_translationAxesFn(AZStd::move(translationAxesFn))
{
}
void HandleEvents(const InputEvent& event) override;
void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
void ResetImpl() override;
@@ -354,7 +356,7 @@ namespace AzFramework
class OrbitDollyScrollCameraInput : public CameraInput
{
public:
void HandleEvents(const InputEvent& event) override;
void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
};
@@ -364,7 +366,7 @@ namespace AzFramework
explicit OrbitDollyCursorMoveCameraInput(const InputChannelId dollyChannelId)
: m_dollyChannelId(dollyChannelId) {}
void HandleEvents(const InputEvent& event) override;
void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
private:
@@ -374,14 +376,14 @@ namespace AzFramework
class ScrollTranslationCameraInput : public CameraInput
{
public:
void HandleEvents(const InputEvent& event) override;
void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
};
class OrbitCameraInput : public CameraInput
{
public:
void HandleEvents(const InputEvent& event) override;
void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override;
bool Exclusive() const override
{
@@ -134,11 +134,16 @@ namespace AzFramework
return !operator==(lhs, rhs);
}
inline float ScreenVectorLength(const ScreenVector& screenVector)
{
return aznumeric_cast<float>(AZStd::sqrt(screenVector.m_x * screenVector.m_x + screenVector.m_y * screenVector.m_y));
}
inline ScreenPoint ScreenPointFromNDC(const AZ::Vector3& screenNDC, const AZ::Vector2& viewportSize)
{
return ScreenPoint(
aznumeric_caster(std::round(screenNDC.GetX() * viewportSize.GetX())),
aznumeric_caster(std::round((1.0f - screenNDC.GetY()) * viewportSize.GetY())));
aznumeric_caster(AZStd::round(screenNDC.GetX() * viewportSize.GetX())),
aznumeric_caster(AZStd::round((1.0f - screenNDC.GetY()) * viewportSize.GetY())));
}
inline AZ::Vector2 NDCFromScreenPoint(const ScreenPoint& screenPoint, const AZ::Vector2& viewportSize)
@@ -89,7 +89,7 @@ namespace AzToolsFramework
if (!RetrieveAndSortPrefabEntitiesAndInstances(inputEntityList, commonRootEntityOwningInstance->get(), entities, instances))
{
return AZ::Failure(
AZStd::string("Could not create a new prefab out of the entities provided - entities do not share a common root."));
AZStd::string("Could not create a new prefab out of the entities provided - invalid selection."));
}
// When we create a prefab with other prefab instances, we have to remove the existing links between the source and
@@ -140,9 +140,13 @@ namespace AzToolsFramework
// Mark them as dirty so this change is correctly applied to the template
for (AZ::Entity* topLevelEntity : topLevelEntities)
{
m_prefabUndoCache.UpdateCache(topLevelEntity->GetId());
undoBatch.MarkEntityDirty(topLevelEntity->GetId());
AZ::TransformBus::Event(topLevelEntity->GetId(), &AZ::TransformBus::Events::SetParent, containerEntityId);
AZ::EntityId topLevelEntityId = topLevelEntity->GetId();
if (topLevelEntityId.IsValid())
{
m_prefabUndoCache.UpdateCache(topLevelEntityId);
undoBatch.MarkEntityDirty(topLevelEntityId);
AZ::TransformBus::Event(topLevelEntityId, &AZ::TransformBus::Events::SetParent, containerEntityId);
}
}
// Select Container Entity
@@ -237,6 +241,21 @@ namespace AzToolsFramework
// Retrieve entityList from entityIds
inputEntityList = EntityIdListToEntityList(entityIds);
// Remove Level Container Entity if it's part of the list
AZ::EntityId levelEntityId = GetLevelInstanceContainerEntityId();
if (levelEntityId.IsValid())
{
AZ::Entity* levelEntity = GetEntityById(levelEntityId);
if (levelEntity)
{
auto levelEntityIter = AZStd::find(inputEntityList.begin(), inputEntityList.end(), levelEntity);
if (levelEntityIter != inputEntityList.end())
{
inputEntityList.erase(levelEntityIter);
}
}
}
// Find common root and top level entities
bool entitiesHaveCommonRoot = false;
@@ -807,6 +826,11 @@ namespace AzToolsFramework
const EntityList& inputEntities, Instance& commonRootEntityOwningInstance,
EntityList& outEntities, AZStd::vector<AZStd::unique_ptr<Instance>>& outInstances) const
{
if (inputEntities.size() == 0)
{
return false;
}
AZStd::queue<AZ::Entity*> entityQueue;
for (auto inputEntity : inputEntities)
@@ -894,7 +918,7 @@ namespace AzToolsFramework
outInstances.push_back(AZStd::move(commonRootEntityOwningInstance.DetachNestedInstance(instancePtr->GetInstanceAlias())));
}
return true;
return (outEntities.size() + outInstances.size()) > 0;
}
bool PrefabPublicHandler::EntitiesBelongToSameInstance(const EntityIdList& entityIds) const
@@ -1353,7 +1353,7 @@ namespace AzToolsFramework
// Iterate over the entities left in the instance and if none of them have this
// asset entity as its ancestor, then we want to remove it.
// \todo - Investigate ways to make this non-linear time. Tricky since removed entities
// obviously aren't maintained in any maps. (https://jira.agscollab.com/browse/LY-88218)
// obviously aren't maintained in any maps. (LY-88218)
bool foundAsAncestor = false;
for (const AZ::Entity* instanceEntity : instanceEntities)
{
@@ -151,32 +151,36 @@ namespace AzToolsFramework
{
if (!selectedEntities.empty())
{
bool layerInSelection = false;
for (AZ::EntityId entityId : selectedEntities)
// Hide if the only selected entity is the Level Container
if (selectedEntities.size() > 1 || !s_prefabPublicInterface->IsLevelInstanceContainerEntity(selectedEntities[0]))
{
if (!layerInSelection)
{
AzToolsFramework::Layers::EditorLayerComponentRequestBus::EventResult(
layerInSelection, entityId,
&AzToolsFramework::Layers::EditorLayerComponentRequestBus::Events::HasLayer);
bool layerInSelection = false;
if (layerInSelection)
for (AZ::EntityId entityId : selectedEntities)
{
if (!layerInSelection)
{
break;
AzToolsFramework::Layers::EditorLayerComponentRequestBus::EventResult(
layerInSelection, entityId,
&AzToolsFramework::Layers::EditorLayerComponentRequestBus::Events::HasLayer);
if (layerInSelection)
{
break;
}
}
}
}
// Layers can't be in prefabs.
if (!layerInSelection)
{
QAction* createAction = menu->addAction(QObject::tr("Create Prefab..."));
createAction->setToolTip(QObject::tr("Creates a prefab out of the currently selected entities."));
// Layers can't be in prefabs.
if (!layerInSelection)
{
QAction* createAction = menu->addAction(QObject::tr("Create Prefab..."));
createAction->setToolTip(QObject::tr("Creates a prefab out of the currently selected entities."));
QObject::connect(createAction, &QAction::triggered, createAction, [this, selectedEntities] {
ContextMenu_CreatePrefab(selectedEntities);
});
QObject::connect(createAction, &QAction::triggered, createAction, [this, selectedEntities] {
ContextMenu_CreatePrefab(selectedEntities);
});
}
}
}
}
@@ -272,6 +276,15 @@ namespace AzToolsFramework
QWidget* activeWindow = QApplication::activeWindow();
const AZStd::string prefabFilesPath = "@devassets@/Prefabs";
// Remove Level entity if it's part of the list
auto levelContainerIter =
AZStd::find(selectedEntities.begin(), selectedEntities.end(), s_prefabPublicInterface->GetLevelInstanceContainerEntityId());
if (levelContainerIter != selectedEntities.end())
{
selectedEntities.erase(levelContainerIter);
}
// Set default folder for prefabs
AZ::IO::FileIOBase* fileIoBaseInstance = AZ::IO::FileIOBase::GetInstance();
@@ -211,6 +211,15 @@ namespace UnitTest
EXPECT_EQ(screenPoint, ScreenPoint(45, 170));
}
TEST(ViewportScreen, ScreenVectorLengthReturned)
{
using AzFramework::ScreenVector;
EXPECT_NEAR(AzFramework::ScreenVectorLength(ScreenVector(1, 1)), 1.41421f, 0.001f);
EXPECT_NEAR(AzFramework::ScreenVectorLength(ScreenVector(3, 4)), 5.0f, 0.001f);
EXPECT_NEAR(AzFramework::ScreenVectorLength(ScreenVector(12, 15)), 19.20937f, 0.001f);
}
TEST(ViewportScreen, CanGetCameraTransformFromCameraViewAndBack)
{
const auto screenDimensions = AZ::Vector2(1024.0f, 768.0f);
+2 -6
View File
@@ -660,9 +660,7 @@ void Q2DViewport::Draw(DisplayContext& dc)
//////////////////////////////////////////////////////////////////////////
void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
{
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
float gridSize = pGrid->size;
float gridSize = 1.0f;
if (gridSize < 0.00001f)
{
return;
@@ -693,8 +691,6 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
pixelsPerGrid = gridSize * fScale;
while (pixelsPerGrid <= 5 && griditers++ < 20)
{
m_fGridZoom *= pGrid->majorLine;
gridSize = gridSize * pGrid->majorLine;
pixelsPerGrid = gridSize * fScale;
}
}
@@ -743,7 +739,7 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
//////////////////////////////////////////////////////////////////////////
// Draw Major grid lines.
//////////////////////////////////////////////////////////////////////////
gridSize = gridSize * pGrid->majorLine;
gridSize = gridSize * 1.0f;
if (m_bAutoAdjustGrids)
{
@@ -514,7 +514,7 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
/*
* The following block of code is part of the feature "Isolation Mode" and is temporarily
* disabled for 1.10 release.
* Jira: https://jira.agscollab.com/browse/LY-49532
* Jira: LY-49532
// Isolate Selected
QAction* isolateSelectedAction = editMenu->addAction(tr("Isolate Selected"));
@@ -729,9 +729,6 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu()
viewportViewsMenuWrapper.AddAction(ID_WIREFRAME);
viewportViewsMenuWrapper.AddSeparator();
viewportViewsMenuWrapper.AddAction(ID_VIEW_GRIDSETTINGS);
viewportViewsMenuWrapper.AddSeparator();
if (CViewManager::IsMultiViewportEnabled())
{
viewportViewsMenuWrapper.AddAction(ID_VIEW_CONFIGURELAYOUT);
-10
View File
@@ -95,7 +95,6 @@ AZ_POP_DISABLE_WARNING
#include "Core/QtEditorApplication.h"
#include "StringDlg.h"
#include "NewLevelDialog.h"
#include "GridSettingsDialog.h"
#include "LayoutConfigDialog.h"
#include "ViewManager.h"
#include "FileTypeUtils.h"
@@ -400,7 +399,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_WIREFRAME, OnWireframe)
ON_COMMAND(ID_VIEW_GRIDSETTINGS, OnViewGridsettings)
ON_COMMAND(ID_VIEW_CONFIGURELAYOUT, OnViewConfigureLayout)
ON_COMMAND(IDC_SELECTION, OnDummyCommand)
@@ -3459,14 +3457,6 @@ void CCryEditApp::OnUpdateWireframe(QAction* action)
action->setChecked(nWireframe == R_WIREFRAME_MODE);
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnViewGridsettings()
{
CGridSettingsDialog dlg;
dlg.exec();
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnViewConfigureLayout()
{
-1
View File
@@ -366,7 +366,6 @@ private:
void OnWireframe();
void OnUpdateWireframe(QAction* action);
void OnViewGridsettings();
void OnViewConfigureLayout();
// Tag Locations.
+5 -20
View File
@@ -579,23 +579,13 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
view->getAttr(viewerAnglesName.toUtf8().constData(), va);
}
CViewport* pVP = GetIEditor()->GetViewManager()->GetView(i);
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
tm.SetTranslation(vp);
if (pVP)
auto viewportContextManager = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
if (auto viewportContext = viewportContextManager->GetViewportContextById(i))
{
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
tm.SetTranslation(vp);
pVP->SetViewTM(tm);
}
// Load grid.
auto gridName = QString("Grid%1").arg(useOldViewFormat ? "" : QString::number(i));
XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData());
if (gridNode)
{
GetIEditor()->GetViewManager()->GetGrid()->Serialize(gridNode, xmlAr.bLoading);
viewportContext->SetCameraTransform(LYTransformToAZTransform(tm));
}
}
}
@@ -622,11 +612,6 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
auto viewerAnglesName = QString("ViewerAngles%1").arg(i);
view->setAttr(viewerAnglesName.toUtf8().constData(), angles);
}
// Save grid.
auto gridName = QString("Grid%1").arg(i);
XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData());
GetIEditor()->GetViewManager()->GetGrid()->Serialize(gridNode, xmlAr.bLoading);
}
}
}
+5 -2
View File
@@ -453,8 +453,11 @@ void EditorViewportWidget::Update()
}
m_updatingCameraPosition = true;
auto transform = LYTransformToAZTransform(m_Camera.GetMatrix());
m_renderViewport->GetViewportContext()->SetCameraTransform(transform);
if (!ed_useNewCameraSystem)
{
m_renderViewport->GetViewportContext()->SetCameraTransform(LYTransformToAZTransform(m_Camera.GetMatrix()));
}
AZ::Matrix4x4 clipMatrix;
AZ::MakePerspectiveFovMatrixRH(
clipMatrix,
-150
View File
@@ -1,150 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "Grid.h"
// Editor
#include "Settings.h"
#include "Objects/SelectionGroup.h"
//////////////////////////////////////////////////////////////////////////
CGrid::CGrid()
{
scale = 1;
size = 1;
majorLine = 16;
bEnabled = true;
rotationAngles = Ang3(0.0f, 0.0f, 0.0f);
translation = Vec3(0.0f, 0.0f, 0.0f);
bAngleSnapEnabled = true;
angleSnap = 5;
}
//////////////////////////////////////////////////////////////////////////
Vec3 CGrid::Snap(const Vec3& vec) const
{
if (!bEnabled || size < 0.001)
{
return vec;
}
Vec3 snapped;
snapped.x = floor((vec.x / size) / scale + 0.5) * size * scale;
snapped.y = floor((vec.y / size) / scale + 0.5) * size * scale;
snapped.z = floor((vec.z / size) / scale + 0.5) * size * scale;
return snapped;
}
//////////////////////////////////////////////////////////////////////////
Vec3 CGrid::Snap(const Vec3& vec, double fZoom) const
{
if (!bEnabled || size < 0.001f)
{
return vec;
}
Matrix34 tm = GetMatrix();
double zoomscale = scale * fZoom;
Vec3 snapped;
Matrix34 invtm = tm.GetInverted();
snapped = invtm * vec;
snapped.x = floor((snapped.x / size) / zoomscale + 0.5) * size * zoomscale;
snapped.y = floor((snapped.y / size) / zoomscale + 0.5) * size * zoomscale;
snapped.z = floor((snapped.z / size) / zoomscale + 0.5) * size * zoomscale;
snapped = tm * snapped;
return snapped;
}
//////////////////////////////////////////////////////////////////////////
double CGrid::SnapAngle(double angle) const
{
if (!bAngleSnapEnabled)
{
return angle;
}
return floor(angle / angleSnap + 0.5) * angleSnap;
}
//////////////////////////////////////////////////////////////////////////
Ang3 CGrid::SnapAngle(const Ang3& vec) const
{
if (!bAngleSnapEnabled)
{
return vec;
}
Ang3 snapped;
snapped.x = floor(vec.x / angleSnap + 0.5) * angleSnap;
snapped.y = floor(vec.y / angleSnap + 0.5) * angleSnap;
snapped.z = floor(vec.z / angleSnap + 0.5) * angleSnap;
return snapped;
}
//////////////////////////////////////////////////////////////////////////
void CGrid::Serialize(XmlNodeRef& xmlNode, bool bLoading)
{
if (bLoading)
{
// Loading.
xmlNode->getAttr("Size", size);
xmlNode->getAttr("Scale", scale);
xmlNode->getAttr("Enabled", bEnabled);
xmlNode->getAttr("MajorSize", majorLine);
xmlNode->getAttr("AngleSnap", angleSnap);
xmlNode->getAttr("AngleSnapEnabled", bAngleSnapEnabled);
if (size < 0.01)
{
size = 0.01;
}
}
else
{
// Saving.
xmlNode->setAttr("Size", size);
xmlNode->setAttr("Scale", scale);
xmlNode->setAttr("Enabled", bEnabled);
xmlNode->setAttr("MajorSize", majorLine);
xmlNode->setAttr("AngleSnap", angleSnap);
xmlNode->setAttr("AngleSnapEnabled", bAngleSnapEnabled);
}
}
//////////////////////////////////////////////////////////////////////////
Matrix34 CGrid::GetMatrix() const
{
Matrix34 tm;
if (gSettings.snap.bGridUserDefined)
{
Ang3 angles = Ang3(rotationAngles.x * gf_PI / 180.0, rotationAngles.y * gf_PI / 180.0, rotationAngles.z * gf_PI / 180.0);
tm = Matrix33::CreateRotationXYZ(angles);
}
else if (GetIEditor()->GetReferenceCoordSys() == COORDS_LOCAL)
{
tm.SetIdentity();
}
else
{
tm.SetIdentity();
}
return tm;
}
-74
View File
@@ -1,74 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_GRID_H
#define CRYINCLUDE_EDITOR_GRID_H
#pragma once
/** Definition of grid used in 2D viewports.
*/
class SANDBOX_API CGrid
{
public:
//! Resolution of grid, it must be multiply of 2.
double size;
//! Draw major lines every Nth grid line.
int majorLine;
//! True if grid enabled.
bool bEnabled;
//! Meters per grid unit.
double scale;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
Ang3 rotationAngles;
Vec3 translation;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
//! If snap to angle.
bool bAngleSnapEnabled;
double angleSnap;
//////////////////////////////////////////////////////////////////////////
CGrid();
//! Snap vector to this grid.
Vec3 Snap(const Vec3& vec) const;
Vec3 Snap(const Vec3& vec, double fZoom) const;
//! Snap angle to current angle snapping value.
double SnapAngle(double angle) const;
//! Snap angle to current angle snapping value.
Ang3 SnapAngle(const Ang3& angle) const;
//! Enable or disable grid.
void Enable(bool enable) { bEnabled = enable; }
//! Check if grid enabled.
bool IsEnabled() const { return bEnabled; }
//! Enables or disable angle snapping.
void EnableAngleSnap(bool enable) { bAngleSnapEnabled = enable; };
//! Return if snapping of angle is enabled.
bool IsAngleSnapEnabled() const { return bAngleSnapEnabled; };
//! Returns ammount of snapping for angle in degrees.
double GetAngleSnap() const { return angleSnap; };
void Serialize(XmlNodeRef& xmlNode, bool bLoading);
//! Get transformation matrix of gird.
Matrix34 GetMatrix() const;
};
#endif // CRYINCLUDE_EDITOR_GRID_H
-169
View File
@@ -1,169 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "GridSettingsDialog.h"
// Editor
#include "Settings.h"
#include "Objects/SelectionGroup.h"
#include "ViewManager.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <ui_GridSettingsDialog.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
// CGridSettingsDialog dialog
CGridSettingsDialog::CGridSettingsDialog(QWidget* pParent /*=NULL*/)
: QDialog(pParent)
, ui(new Ui::CGridSettingsDialog)
{
ui->setupUi(this);
setWindowTitle(tr("Grid/Snap Settings"));
OnInitDialog();
connect(ui->m_userDefined, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnUserDefined);
connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnGetFromObject);
auto doubleSpinBoxValueChanged = static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged);
connect(ui->m_angleX, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
connect(ui->m_angleY, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
connect(ui->m_angleZ, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
connect(ui->m_gridSize, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
connect(ui->m_gridScale, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
connect(ui->m_CPSize, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
connect(ui->m_displayCP, &QCheckBox::clicked, this, &CGridSettingsDialog::OnValueUpdate);
connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnValueUpdate);
connect(ui->m_buttonBox, &QDialogButtonBox::accepted, this, &CGridSettingsDialog::accept);
connect(ui->m_buttonBox, &QDialogButtonBox::rejected, this, &CGridSettingsDialog::reject);
}
CGridSettingsDialog::~CGridSettingsDialog()
{
}
//////////////////////////////////////////////////////////////////////////
void CGridSettingsDialog::OnInitDialog()
{
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
ui->m_userDefined->setChecked(gSettings.snap.bGridUserDefined);
ui->m_getFromObject->setChecked(gSettings.snap.bGridGetFromSelected);
ui->m_angleX->setValue(pGrid->rotationAngles.x);
ui->m_angleY->setValue(pGrid->rotationAngles.y);
ui->m_angleZ->setValue(pGrid->rotationAngles.z);
ui->m_translationX->setValue(pGrid->translation.x);
ui->m_translationY->setValue(pGrid->translation.y);
ui->m_translationZ->setValue(pGrid->translation.z);
ui->m_gridSize->setValue(pGrid->size);
ui->m_gridScale->setValue(pGrid->scale);
ui->m_snapToGrid->setChecked(pGrid->IsEnabled());
ui->m_angleSnap->setChecked(pGrid->IsAngleSnapEnabled());
ui->m_angleSnapScale->setValue(pGrid->GetAngleSnap());
ui->m_displayCP->setChecked(gSettings.snap.constructPlaneDisplay);
ui->m_CPSize->setValue(gSettings.snap.constructPlaneSize);
ui->m_displaySnapMarker->setChecked(gSettings.snap.markerDisplay);
ui->m_snapMarkerSize->setValue(gSettings.snap.markerSize);
ui->m_snapMarkerColor->SetColor(gSettings.snap.markerColor);
EnableGridPropertyControls(gSettings.snap.bGridUserDefined, gSettings.snap.bGridGetFromSelected);
}
//////////////////////////////////////////////////////////////////////////
void CGridSettingsDialog::accept()
{
UpdateValues();
gSettings.Save();
QDialog::accept();
}
void CGridSettingsDialog::OnBnUserDefined()
{
EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked());
OnValueUpdate();
}
void CGridSettingsDialog::OnBnGetFromObject()
{
EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked());
}
void CGridSettingsDialog::EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject)
{
ui->m_getFromObject->setEnabled(isUserDefined == true);
ui->m_angleX->setEnabled(isUserDefined == true && isGetFromObject == false);
ui->m_angleY->setEnabled(isUserDefined == true && isGetFromObject == false);
ui->m_angleZ->setEnabled(isUserDefined == true && isGetFromObject == false);
ui->m_translationX->setEnabled(isUserDefined == true && isGetFromObject == false);
ui->m_translationY->setEnabled(isUserDefined == true && isGetFromObject == false);
ui->m_translationZ->setEnabled(isUserDefined == true && isGetFromObject == false);
ui->m_getAnglesFromObject->setEnabled(isUserDefined == true && isGetFromObject == false);
ui->m_getTranslationFromObject->setEnabled(isUserDefined == true && isGetFromObject == false);
}
//////////////////////////////////////////////////////////////////////////
void CGridSettingsDialog::UpdateValues()
{
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
pGrid->Enable(ui->m_snapToGrid->isChecked());
pGrid->size = ui->m_gridSize->value();
pGrid->scale = ui->m_gridScale->value();
gSettings.snap.bGridUserDefined = ui->m_userDefined->isChecked();
gSettings.snap.bGridGetFromSelected = ui->m_getFromObject->isChecked();
pGrid->rotationAngles.x = ui->m_angleX->value();
pGrid->rotationAngles.y = ui->m_angleY->value();
pGrid->rotationAngles.z = ui->m_angleZ->value();
pGrid->translation.x = ui->m_translationX->value();
pGrid->translation.y = ui->m_translationY->value();
pGrid->translation.z = ui->m_translationZ->value();
pGrid->bAngleSnapEnabled = ui->m_angleSnap->isChecked();
pGrid->angleSnap = ui->m_angleSnapScale->value();
gSettings.snap.constructPlaneDisplay = ui->m_displayCP->isChecked();
gSettings.snap.constructPlaneSize = ui->m_CPSize->value();
gSettings.snap.markerDisplay = ui->m_displaySnapMarker->isChecked();
gSettings.snap.markerSize = ui->m_snapMarkerSize->value();
gSettings.snap.markerColor = ui->m_snapMarkerColor->Color();
NotificationBus::Broadcast(&Notifications::OnGridValuesUpdated);
}
//////////////////////////////////////////////////////////////////////////
void CGridSettingsDialog::OnValueUpdate()
{
UpdateValues();
GetIEditor()->UpdateViews(eRedrawViewports);
}
#include <moc_GridSettingsDialog.cpp>
-65
View File
@@ -1,65 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
#define CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QDialog>
#include <AzCore/EBus/EBus.h>
#endif
// CGridSettingsDialog dialog
namespace Ui {
class CGridSettingsDialog;
}
class CGridSettingsDialog
: public QDialog
{
Q_OBJECT
public:
class Notifications
: public AZ::EBusTraits
{
public:
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
virtual void OnGridValuesUpdated() {}
};
using NotificationBus = AZ::EBus<Notifications>;
CGridSettingsDialog(QWidget* pParent = nullptr); // standard constructor
virtual ~CGridSettingsDialog();
private slots:
void accept() override;
void OnBnUserDefined();
void OnBnGetFromObject();
void OnValueUpdate();
private:
void EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject);
void OnInitDialog();
void UpdateValues();
QScopedPointer<Ui::CGridSettingsDialog> ui;
};
#endif // CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
-505
View File
@@ -1,505 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CGridSettingsDialog</class>
<widget class="QDialog" name="CGridSettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>307</width>
<height>707</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="group1">
<property name="title">
<string>Grid</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1" colspan="2">
<widget class="QCheckBox" name="m_snapToGrid">
<property name="text">
<string>Snap to Grid</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label1">
<property name="text">
<string>Grid Lines Every:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="m_gridSize">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>0.010000000000000</double>
</property>
<property name="maximum">
<double>1024.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label2">
<property name="text">
<string>units</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label3">
<property name="text">
<string>Units Per Meter:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="m_gridScale">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>0.010000000000000</double>
</property>
<property name="maximum">
<double>1024.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label4">
<property name="text">
<string>meters</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QCheckBox" name="m_userDefined">
<property name="text">
<string>User Defined Grid</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="m_getFromObject">
<property name="text">
<string>Get Angles And Trans. From Selected</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label5">
<property name="text">
<string>Rotation by X:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="m_angleX">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label6">
<property name="text">
<string>degrees</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label7">
<property name="text">
<string>Rotation by Y:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="m_angleY">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label8">
<property name="text">
<string>degrees</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label9">
<property name="text">
<string>Rotation by Z:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="m_angleZ">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label10">
<property name="text">
<string>degrees</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label11">
<property name="text">
<string>Translation by X:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QDoubleSpinBox" name="m_translationX">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label12">
<property name="text">
<string>Translation by Y:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QDoubleSpinBox" name="m_translationY">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label13">
<property name="text">
<string>Translation by Z:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QDoubleSpinBox" name="m_translationZ">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="11" column="0" colspan="3">
<widget class="QPushButton" name="m_getAnglesFromObject">
<property name="text">
<string>Get Angles From Selected</string>
</property>
</widget>
</item>
<item row="12" column="0" colspan="3">
<widget class="QPushButton" name="m_getTranslationFromObject">
<property name="text">
<string>Get Translation From Selected</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="group2">
<property name="title">
<string>Angle Snapping</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="2">
<widget class="QSpinBox" name="m_angleSnapScale">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label14">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>degrees</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QCheckBox" name="m_angleSnap">
<property name="text">
<string>Angle Snap</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label15">
<property name="text">
<string>Angle Snap:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="group3">
<property name="title">
<string>Construction Plane</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2">
<widget class="QLabel" name="label16">
<property name="text">
<string>Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="m_displayCP">
<property name="text">
<string>Display</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="m_CPSize">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<zorder>m_displayCP</zorder>
<zorder>m_CPSize</zorder>
</widget>
</item>
<item>
<widget class="QGroupBox" name="group4">
<property name="title">
<string>Snap Marker</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="m_snapMarkerSize">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="m_displaySnapMarker">
<property name="text">
<string>Display</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="ColorButton" name="m_snapMarkerColor">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label17">
<property name="text">
<string>Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="m_buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ColorButton</class>
<extends>QToolButton</extends>
<header location="global">QtUI/ColorButton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
+4 -55
View File
@@ -66,7 +66,6 @@ AZ_POP_DISABLE_WARNING
#include "AssetImporter/AssetImporterManager/AssetImporterDragAndDropHandler.h"
#include "CryEdit.h"
#include "Controls/ConsoleSCB.h"
#include "Grid.h"
#include "ViewManager.h"
#include "CryEditDoc.h"
#include "ToolBox.h"
@@ -97,7 +96,6 @@ AZ_POP_DISABLE_WARNING
#include "AzAssetBrowser/AzAssetBrowserWindow.h"
#include "AssetEditor/AssetEditorWindow.h"
#include "GridSettingsDialog.h"
#include "ActionManager.h"
// uncomment this to show thumbnail demo widget
@@ -123,12 +121,6 @@ static const char* g_openLocationAttributeName = "OpenLocation"; //Indicates whe
static const char* g_assetImporterName = "AssetImporter";
static const char* g_snapToGridEnabled = "mainwindow/snapGridEnabled";
static const char* g_snapToGridSize = "mainwindow/snapGridSize";
static const char* g_snapAngleEnabled = "mainwindow/snapAngleEnabled";
static const char* g_snapAngle = "mainwindow/snapAngle";
static const char* g_terrainFollow = "mainwindow/terrainFollow";
class CEditorOpenViewCommand
: public _i_reference_target_t
{
@@ -308,10 +300,8 @@ namespace
class SnapToWidget
: public QWidget
, public CGridSettingsDialog::NotificationBus::Handler
{
public:
typedef AZStd::function<void(double)> SetValueCallback;
typedef AZStd::function<double()> GetValueCallback;
@@ -335,12 +325,13 @@ public:
m_spinBox->setEnabled(defaultAction->isChecked());
m_spinBox->setMinimum(1e-2f);
OnGridValuesUpdated();
{
QSignalBlocker signalBlocker(m_spinBox);
m_spinBox->setValue(m_getValueCallback());
}
QObject::connect(m_spinBox, QOverload<double>::of(&AzQtComponents::DoubleSpinBox::valueChanged), this, &SnapToWidget::OnValueChanged);
QObject::connect(defaultAction, &QAction::changed, this, &SnapToWidget::OnActionChanged);
CGridSettingsDialog::NotificationBus::Handler::BusConnect();
}
void SetIcon(QIcon icon)
@@ -348,14 +339,6 @@ public:
m_toolButton->setIcon(icon);
}
void OnGridValuesUpdated() override
{
// Blocking signals to not trigger the valueChanged callback when we set the value on the spin box.
QSignalBlocker signalBlocker(m_spinBox);
double value = m_getValueCallback();
m_spinBox->setValue(value);
}
protected:
void OnValueChanged(double value)
@@ -543,7 +526,6 @@ void MainWindow::Initialize()
RegisterStdViewClasses();
InitCentralWidget();
LoadConfig();
InitActions();
// load toolbars ("shelves") and macros
@@ -673,31 +655,8 @@ void MainWindow::closeEvent(QCloseEvent* event)
QMainWindow::closeEvent(event);
}
void MainWindow::LoadConfig()
{
CGrid* grid = gSettings.pGrid;
Q_ASSERT(grid);
bool terrainValue;
ReadConfigValue(g_snapAngleEnabled, grid->bAngleSnapEnabled);
ReadConfigValue(g_snapAngle, grid->angleSnap);
ReadConfigValue(g_snapToGridEnabled, grid->bEnabled);
ReadConfigValue(g_snapToGridSize, grid->size);
ReadConfigValue(g_terrainFollow, terrainValue);
GetIEditor()->SetTerrainAxisIgnoreObjects(terrainValue);
}
void MainWindow::SaveConfig()
{
CGrid* grid = gSettings.pGrid;
Q_ASSERT(grid);
m_settings.setValue(g_snapAngleEnabled, grid->bAngleSnapEnabled);
m_settings.setValue(g_snapAngle, grid->angleSnap);
m_settings.setValue(g_snapToGridEnabled, grid->bEnabled);
m_settings.setValue(g_snapToGridSize, grid->size);
m_settings.setValue(g_terrainFollow, GetIEditor()->IsTerrainAxisIgnoreObjects());
m_settings.setValue("mainWindowState", saveState());
QtViewPaneManager::instance()->SaveLayout();
if (m_pLayoutWnd)
@@ -941,7 +900,6 @@ void MainWindow::InitActions()
.SetStatusTip(tr("Render in Wireframe Mode."))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateWireframe);
am->AddAction(ID_VIEW_GRIDSETTINGS, tr("Grid Settings..."));
am->AddAction(ID_SWITCHCAMERA_DEFAULTCAMERA, tr("Default Camera")).SetCheckable(true)
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSwitchToDefaultCamera);
am->AddAction(ID_SWITCHCAMERA_SEQUENCECAMERA, tr("Sequence Camera")).SetCheckable(true)
@@ -1479,15 +1437,6 @@ MainStatusBar* MainWindow::StatusBar() const
return static_cast<MainStatusBar*>(statusBar());
}
void MainWindow::OnUpdateSnapToGrid(QAction* action)
{
Q_ASSERT(action->isCheckable());
bool bEnabled = gSettings.pGrid->IsEnabled();
action->setChecked(bEnabled);
action->setText(QObject::tr("Snap To Grid"));
}
KeyboardCustomizationSettings* MainWindow::GetShortcutManager() const
{
return m_keyboardCustomization;
-2
View File
@@ -191,9 +191,7 @@ private:
void InitToolActionHandlers();
void InitToolBars();
void InitStatusBar();
void OnUpdateSnapToGrid(QAction* action);
void OnViewPaneCreated(const QtViewPane* pane);
void LoadConfig();
template <class TValue>
void ReadConfigValue(const QString& key, TValue& value)
@@ -19,6 +19,7 @@
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
#include <AzFramework/Viewport/ScreenGeometry.h>
#include <AzFramework/Viewport/ViewportScreen.h>
#include <AzFramework/Windowing/WindowBus.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h>
@@ -64,17 +65,20 @@ namespace SandboxEditor
}
}
ModernViewportCameraControllerInstance::ModernViewportCameraControllerInstance(const AzFramework::ViewportId viewportId, ModernViewportCameraController* controller)
ModernViewportCameraControllerInstance::ModernViewportCameraControllerInstance(
const AzFramework::ViewportId viewportId, ModernViewportCameraController* controller)
: MultiViewportControllerInstanceInterface<ModernViewportCameraController>(viewportId, controller)
{
controller->SetupCameras(m_cameraSystem.m_cameras);
if (auto viewportContext = RetrieveViewportContext(GetViewportId()))
{
auto handleCameraChange = [this](const AZ::Matrix4x4& matrix) {
UpdateCameraFromTransform(
m_targetCamera,
AZ::Transform::CreateFromMatrix3x3AndTranslation(AZ::Matrix3x3::CreateFromMatrix4x4(matrix), matrix.GetTranslation()));
auto handleCameraChange = [this, viewportContext](const AZ::Matrix4x4&) {
if (!m_updatingTransform)
{
UpdateCameraFromTransform(m_targetCamera, viewportContext->GetCameraTransform());
m_camera = m_targetCamera;
}
};
m_cameraViewMatrixChangeHandler = AZ::RPI::ViewportContext::MatrixChangedEvent::Handler(handleCameraChange);
@@ -124,6 +128,8 @@ namespace SandboxEditor
{
if (auto viewportContext = RetrieveViewportContext(GetViewportId()))
{
m_updatingTransform = true;
if (m_cameraMode == CameraMode::Control)
{
m_targetCamera = m_cameraSystem.StepCamera(m_targetCamera, event.m_deltaTime.count());
@@ -155,6 +161,8 @@ namespace SandboxEditor
viewportContext->SetCameraTransform(current);
}
m_updatingTransform = false;
}
}
@@ -20,14 +20,13 @@
namespace SandboxEditor
{
class ModernViewportCameraControllerInstance;
class ModernViewportCameraController
: public AzFramework::MultiViewportController<ModernViewportCameraControllerInstance>
class ModernViewportCameraController : public AzFramework::MultiViewportController<ModernViewportCameraControllerInstance>
{
public:
using CameraListBuilder = AZStd::function<void(AzFramework::Cameras&)>;
//! Sets the camera list builder callback used to populate new ModernViewportCameraControllerInstances
void SetCameraListBuilderCallback(const CameraListBuilder& builder);
//! Sets up a camera list based on this controller's CameraListBuilderCallback
void SetupCameras(AzFramework::Cameras& cameras);
@@ -35,9 +34,9 @@ namespace SandboxEditor
CameraListBuilder m_cameraListBuilder;
};
class ModernViewportCameraControllerInstance final
: public AzFramework::MultiViewportControllerInstanceInterface<ModernViewportCameraController>
, private AzFramework::ViewportDebugDisplayEventBus::Handler
class ModernViewportCameraControllerInstance final
: public AzFramework::MultiViewportControllerInstanceInterface<ModernViewportCameraController>,
private AzFramework::ViewportDebugDisplayEventBus::Handler
{
public:
explicit ModernViewportCameraControllerInstance(AzFramework::ViewportId viewportId, ModernViewportCameraController* controller);
@@ -65,6 +64,7 @@ namespace SandboxEditor
AZ::Transform m_transformEnd = AZ::Transform::CreateIdentity();
float m_animationT = 0.0f;
CameraMode m_cameraMode = CameraMode::Control;
bool m_updatingTransform = false;
AZ::RPI::ViewportContext::MatrixChangedEvent::Handler m_cameraViewMatrixChangeHandler;
};
+2 -2
View File
@@ -18,7 +18,6 @@
// Editor
#include "Viewport.h"
#include "GizmoManager.h"
#include "Grid.h"
#include "ViewManager.h"
#include "Settings.h"
#include "RenderHelpers/AxisHelper.h"
@@ -244,7 +243,8 @@ Matrix34 CAxisGizmo::GetTransformation(RefCoordSys coordSys, IDisplayViewport* v
break;
case COORDS_USERDEFINED:
{
Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix();
Matrix34 userTM;
userTM.SetIdentity();
userTM.SetTranslation(m_object->GetWorldTM().GetTranslation());
return userTM;
}
@@ -1268,12 +1268,6 @@ int CBaseObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint&
if (event == eMouseWheel)
{
double angle = 1;
if (view->GetViewManager()->GetGrid()->IsAngleSnapEnabled())
{
angle = view->GetViewManager()->GetGrid()->GetAngleSnap();
}
Quat rot = GetRotation();
rot.SetRotationXYZ(Ang3(0, 0, rot.GetRotZ() + DEG2RAD(flags > 0 ? angle * (-1) : angle)));
SetRotation(rot);
@@ -342,7 +342,8 @@ void CSelectionGroup::Rotate(const Matrix34& rotateTM, int referenceCoordSys)
if (referenceCoordSys == COORDS_USERDEFINED)
{
Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix();
Matrix34 userTM;
userTM.SetIdentity();
Matrix34 invUserTM = userTM.GetInvertedFast();
ToOrigin = invUserTM * ToOrigin;
+7 -89
View File
@@ -1985,28 +1985,27 @@ AzFramework::CameraState CRenderViewport::GetCameraState()
bool CRenderViewport::GridSnappingEnabled()
{
return GetViewManager()->GetGrid()->IsEnabled();
return false;
}
float CRenderViewport::GridSize()
{
const CGrid* grid = GetViewManager()->GetGrid();
return grid->scale * grid->size;
return 0.0f;
}
bool CRenderViewport::ShowGrid()
{
return gSettings.viewports.bShowGridGuide;
return false;
}
bool CRenderViewport::AngleSnappingEnabled()
{
return GetViewManager()->GetGrid()->IsAngleSnapEnabled();
return false;
}
float CRenderViewport::AngleStep()
{
return GetViewManager()->GetGrid()->GetAngleSnap();
return 0.0f;
}
AZ::Vector3 CRenderViewport::PickTerrain(const AzFramework::ScreenPoint& point)
@@ -3882,94 +3881,13 @@ void CRenderViewport::ActivateWindowAndSetFocus()
//////////////////////////////////////////////////////////////////////////
void CRenderViewport::RenderConstructionPlane()
{
DisplayContext& dc = m_displayContext;
int prevState = dc.GetState();
dc.DepthWriteOff();
// Draw Construction plane.
CGrid* pGrid = GetViewManager()->GetGrid();
RefCoordSys coordSys = COORDS_WORLD;
Vec3 p = m_constructionMatrix[coordSys].GetTranslation();
Vec3 n = m_constructionPlane.n;
Vec3 u = Vec3(1, 0, 0);
Vec3 v = Vec3(0, 1, 0);
if (gSettings.snap.bGridUserDefined)
{
Ang3 angles = Ang3(pGrid->rotationAngles.x * gf_PI / 180.0, pGrid->rotationAngles.y * gf_PI / 180.0, pGrid->rotationAngles.z * gf_PI / 180.0);
Matrix34 tm = Matrix33::CreateRotationXYZ(angles);
u = tm * u;
v = tm * v;
}
float step = pGrid->scale * pGrid->size;
float size = gSettings.snap.constructPlaneSize;
dc.SetColor(0, 0, 1, 0.1f);
float s = size;
dc.DrawQuad(p - u * s - v * s, p + u * s - v * s, p + u * s + v * s, p - u * s + v * s);
int nSteps = int(size / step);
int i;
// Draw X lines.
dc.SetColor(1, 0, 0.2f, 0.3f);
for (i = -nSteps; i <= nSteps; i++)
{
dc.DrawLine(p - u * size + v * (step * i), p + u * size + v * (step * i));
}
// Draw Y lines.
dc.SetColor(0.2f, 1.0f, 0, 0.3f);
for (i = -nSteps; i <= nSteps; i++)
{
dc.DrawLine(p - v * size + u * (step * i), p + v * size + u * (step * i));
}
// Draw origin lines.
dc.SetLineWidth(2);
//X
dc.SetColor(1, 0, 0);
dc.DrawLine(p - u * s, p + u * s);
//Y
dc.SetColor(0, 1, 0);
dc.DrawLine(p - v * s, p + v * s);
//Z
dc.SetColor(0, 0, 1);
dc.DrawLine(p - n * s, p + n * s);
dc.SetLineWidth(0);
dc.SetState(prevState);
// noop
}
//////////////////////////////////////////////////////////////////////////
void CRenderViewport::RenderSnappingGrid()
{
// First, Check whether we should draw the grid or not.
CGrid* pGrid = GetViewManager()->GetGrid();
if (pGrid->IsEnabled() == false && pGrid->IsAngleSnapEnabled() == false)
{
return;
}
DisplayContext& dc = m_displayContext;
int prevState = dc.GetState();
dc.DepthWriteOff();
dc.SetState(prevState);
// noop
}
//////////////////////////////////////////////////////////////////////////
-1
View File
@@ -79,7 +79,6 @@
#define ID_EDIT_HIDE 32898
#define ID_EDIT_UNHIDEALL 32899
#define ID_RELOAD_TERRAIN 32902
#define ID_VIEW_GRIDSETTINGS 32904
#define ID_VIEW_CONFIGURELAYOUT 32906
#define ID_TOOLS_LOGMEMORYUSAGE 32908
#define ID_TERRAIN_EXPORTBLOCK 32909
-5
View File
@@ -40,8 +40,6 @@
#include <AzQtComponents/Components/Widgets/ToolBar.h>
class CGrid;
struct SGizmoSettings
{
float axisGizmoSize;
@@ -393,9 +391,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
//! Keeps the editor active even if no focus is set
int keepEditorActive;
//! Pointer to currently used grid.
CGrid* pGrid;
SGizmoSettings gizmo;
// Settings of the snapping.
-2
View File
@@ -49,8 +49,6 @@ bool CViewManager::IsMultiViewportEnabled()
//////////////////////////////////////////////////////////////////////
CViewManager::CViewManager()
{
gSettings.pGrid = &m_grid;
m_zoomFactor = 1;
m_origin2D(0, 0, 0);
-6
View File
@@ -20,7 +20,6 @@
#pragma once
#include "Cry_Geo.h"
#include "Grid.h"
#include "Viewport.h"
#include "Include/IViewPane.h"
#include "QtViewPaneManager.h"
@@ -67,10 +66,6 @@ public:
void SetUpdateRegion(const AABB& updateRegion) { m_updateRegion = updateRegion; };
const AABB& GetUpdateRegion() { return m_updateRegion; };
/** Retrieve Grid used for viewes.
*/
CGrid* GetGrid() { return &m_grid; };
/** Get 2D viewports origin.
*/
Vec3 GetOrigin2D() const { return m_origin2D; }
@@ -137,7 +132,6 @@ private:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
AABB m_updateRegion;
CGrid m_grid;
//! Origin of 2d viewports.
Vec3 m_origin2D;
//! Zoom of 2d viewports.
+2 -2
View File
@@ -1182,12 +1182,12 @@ float QtViewport::GetZoomFactor() const
//////////////////////////////////////////////////////////////////////////
Vec3 QtViewport::SnapToGrid(const Vec3& vec)
{
return m_viewManager->GetGrid()->Snap(vec, m_fGridZoom);
return vec;
}
float QtViewport::GetGridStep() const
{
return m_viewManager->GetGrid()->scale * m_viewManager->GetGrid()->size;
return 0.0f;
}
//////////////////////////////////////////////////////////////////////////
@@ -437,9 +437,6 @@ set(FILES
GotoPositionDlg.cpp
GotoPositionDlg.h
GotoPositionDlg.ui
GridSettingsDialog.cpp
GridSettingsDialog.h
GridSettingsDialog.ui
InfoBar.cpp
InfoBar.qrc
InfoBar.h
@@ -835,8 +832,6 @@ set(FILES
WelcomeScreen/WelcomeScreenDialog.qrc
2DViewport.cpp
2DViewport.h
Grid.cpp
Grid.h
LayoutWnd.cpp
LayoutWnd.h
EditorViewportWidget.cpp
@@ -0,0 +1,52 @@
/*
* 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.
*
*/
#include <LinkWidget.h>
#include <QDesktopServices>
#include <QEvent>
#include <QMouseEvent>
#include <QVBoxLayout>
namespace O3DE::ProjectManager
{
LinkLabel::LinkLabel(const QString& text, const QUrl& url, QWidget* parent)
: QLabel(text, parent)
, m_url(url)
{
SetDefaultStyle();
}
void LinkLabel::mousePressEvent([[maybe_unused]] QMouseEvent* event)
{
QDesktopServices::openUrl(m_url);
}
void LinkLabel::enterEvent([[maybe_unused]] QEvent* event)
{
setStyleSheet("font-size: 9pt; color: #94D2FF; text-decoration: underline;");
}
void LinkLabel::leaveEvent([[maybe_unused]] QEvent* event)
{
SetDefaultStyle();
}
void LinkLabel::SetUrl(const QUrl& url)
{
m_url = url;
}
void LinkLabel::SetDefaultStyle()
{
setStyleSheet("font-size: 9pt; color: #94D2FF;");
}
} // namespace O3DE::ProjectManager
@@ -0,0 +1,42 @@
/*
* 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.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <QLabel>
#include <QUrl>
#endif
QT_FORWARD_DECLARE_CLASS(QEvent)
QT_FORWARD_DECLARE_CLASS(QMouseEvent)
QT_FORWARD_DECLARE_CLASS(QWidget)
namespace O3DE::ProjectManager
{
class LinkLabel
: public QLabel
{
public:
LinkLabel(const QString& text, const QUrl& url = {}, QWidget* parent = nullptr);
void SetUrl(const QUrl& url);
private:
void mousePressEvent(QMouseEvent* event) override;
void enterEvent(QEvent* event) override;
void leaveEvent(QEvent* event) override;
void SetDefaultStyle();
private:
QUrl m_url;
};
} // namespace O3DE::ProjectManager
@@ -0,0 +1,98 @@
/*
* 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.
*
*/
#include <TagWidget.h>
#include <QVBoxLayout>
namespace O3DE::ProjectManager
{
TagWidget::TagWidget(const QString& text, QWidget* parent)
: QLabel(text, parent)
{
setFixedHeight(35);
setMargin(5);
setStyleSheet("font-size: 12pt; background-color: #333333; border-radius: 4px;");
}
TagContainerWidget::TagContainerWidget(QWidget* parent)
: QWidget(parent)
{
m_layout = new QVBoxLayout();
m_layout->setAlignment(Qt::AlignTop);
m_layout->setMargin(0);
setLayout(m_layout);
}
void TagContainerWidget::Update(const QStringList& tags)
{
QWidget* parentWidget = qobject_cast<QWidget*>(parent());
int width = 250;
if (parentWidget)
{
width = parentWidget->width();
}
if (m_widget)
{
// Hide the old widget and request deletion.
m_widget->hide();
m_widget->deleteLater();
}
QVBoxLayout* vLayout = new QVBoxLayout();
m_widget = new QWidget(this);
m_widget->setLayout(vLayout);
m_layout->addWidget(m_widget);
vLayout->setAlignment(Qt::AlignTop);
vLayout->setMargin(0);
QHBoxLayout* hLayout = nullptr;
int usedSpaceInRow = 0;
const int numTags = tags.count();
for (int i = 0; i < numTags; ++i)
{
// Create the new tag widget.
TagWidget* tagWidget = new TagWidget(tags[i]);
const int tagWidgetWidth = tagWidget->minimumSizeHint().width();
// Calculate the width we're currently using in the current row. Does the new tag still fit in the current row?
const bool isRowFull = width - usedSpaceInRow - tagWidgetWidth < 0;
if (isRowFull || i == 0)
{
// Add a spacer widget after the last tag widget in a row to push the tag widgets to the left.
if (i > 0)
{
QWidget* spacerWidget = new QWidget();
spacerWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
hLayout->addWidget(spacerWidget);
}
// Add a new row for the current tag widget.
hLayout = new QHBoxLayout();
hLayout->setAlignment(Qt::AlignLeft);
hLayout->setMargin(0);
vLayout->addLayout(hLayout);
// Reset the used space in the row.
usedSpaceInRow = 0;
}
// Calculate the width of the tag widgets including the spacing between them of the current row.
usedSpaceInRow += tagWidgetWidth + hLayout->spacing();
// Add the tag widget to the current row.
hLayout->addWidget(tagWidget);
}
}
} // namespace O3DE::ProjectManager
@@ -0,0 +1,52 @@
/*
* 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.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <QLabel>
#include <QStringList>
#include <QWidget>
#endif
QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
namespace O3DE::ProjectManager
{
// Single tag
class TagWidget
: public QLabel
{
Q_OBJECT // AUTOMOC
public:
explicit TagWidget(const QString& text, QWidget* parent = nullptr);
~TagWidget() = default;
};
// Widget containing multiple tags, automatically wrapping based on the size
class TagContainerWidget
: public QWidget
{
Q_OBJECT // AUTOMOC
public:
explicit TagContainerWidget(QWidget* parent = nullptr);
~TagContainerWidget() = default;
void Update(const QStringList& tags);
private:
QVBoxLayout* m_layout = nullptr;
QWidget* m_widget = nullptr;
};
} // namespace O3DE::ProjectManager
@@ -34,6 +34,10 @@ set(FILES
Source/EngineSettings.h
Source/EngineSettings.cpp
Source/EngineSettings.ui
Source/LinkWidget.h
Source/LinkWidget.cpp
Source/TagWidget.h
Source/TagWidget.cpp
Source/GemCatalog/GemCatalog.h
Source/GemCatalog/GemCatalog.cpp
Source/GemCatalog/GemInfo.h