Merge branch 'development' of https://github.com/o3de/o3de into GroupToggleSwitch

This commit is contained in:
dtamkin1
2021-07-27 13:28:17 -05:00
122 changed files with 4766 additions and 1274 deletions
@@ -71,7 +71,7 @@ namespace AZ
return &out;
}
Matrix4x4* MakeOrthographicMatrixRH(Matrix4x4& out, float left, float right, float bottom, float top, float nearDist, float farDist)
Matrix4x4* MakeOrthographicMatrixRH(Matrix4x4& out, float left, float right, float bottom, float top, float nearDist, float farDist, bool reverseDepth)
{
AZ_Assert(right > left, "right should be greater than left");
// valid to have matrix invert top/bottom and far/near
@@ -83,6 +83,11 @@ namespace AZ
return nullptr;
}
if (reverseDepth)
{
AZStd::swap(nearDist, farDist);
}
out.SetRow(0, 2.f/(right - left), 0.f, 0.f, - (right + left) / (right - left) );
out.SetRow(1, 0.f, 2.f / (top - bottom), 0.f, - (top + bottom) / (top - bottom) );
out.SetRow(2, 0.f, 0.f, 1 / (nearDist - farDist), nearDist / (nearDist - farDist) );
@@ -57,8 +57,9 @@ namespace AZ
//! @param top The y coordinate of top view-plane
//! @param near Distance to the near view-plane. Must be no less than zero.
//! @param far Distance to the far view-plane. Must be greater than zero.
//! @param reverseDepth Set to true to reverse depth which means near distance maps to 1 and far distance maps to 0.
//! @return Pointer of the output matrix
Matrix4x4* MakeOrthographicMatrixRH(Matrix4x4& out, float left, float right, float bottom, float top, float nearDist, float farDist);
Matrix4x4* MakeOrthographicMatrixRH(Matrix4x4& out, float left, float right, float bottom, float top, float nearDist, float farDist, bool reverseDepth = false);
//! Transforms a position by a matrix. This function can be used with any generic cases which include projection matrices.
Vector3 MatrixTransformPosition(const Matrix4x4& matrix, const Vector3& inPosition);
@@ -120,6 +120,11 @@ namespace AZStd
base_type::insert(*first);
}
}
fixed_unordered_map(const AZStd::initializer_list<value_type>& list, const hasher& hash = hasher(),
const key_eq& keyEqual = key_eq())
: fixed_unordered_map(list.begin(), list.end(), hash, keyEqual)
{
}
AZ_FORCE_INLINE pair_iter_bool insert(const value_type& value)
{
@@ -241,6 +246,12 @@ namespace AZStd
base_type::insert(*first);
}
}
fixed_unordered_multimap(const AZStd::initializer_list<value_type>& list, const hasher& hash = hasher(),
const key_eq& keyEqual = key_eq())
: fixed_unordered_multimap(list.begin(), list.end(), hash, keyEqual)
{
}
AZ_FORCE_INLINE iterator insert(const value_type& value)
{
return base_type::insert_impl(value).first;
+1 -1
View File
@@ -12,7 +12,7 @@
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
ly_get_list_relative_pal_filename(common_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/Common)
if(LY_ENABLE_RAD_TELEMETRY)
if(LY_RAD_TELEMETRY_ENABLED)
set(AZ_CORE_RADTELEMETRY_FILES ${common_dir}/azcore_profile_telemetry_files.cmake)
set(AZ_CORE_RADTELEMETRY_PLATFORM_INCLUDES ${pal_dir}/profile_telemetry_platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
set(AZ_CORE_RADTELEMETRY_INCLUDE_DIRECTORIES ${common_dir})
@@ -12,6 +12,6 @@
# is being avoided to prevent overriding functions declared in other targets platfrom
# specific cmake files
if(LY_ENABLE_RAD_TELEMETRY)
if(LY_RAD_TELEMETRY_ENABLED)
set(LY_COMPILE_DEFINITIONS PUBLIC AZ_PROFILE_TELEMETRY)
endif()
@@ -12,6 +12,6 @@
# is being avoided to prevent overriding functions declared in other targets platfrom
# specific cmake files
if(LY_ENABLE_RAD_TELEMETRY)
if(LY_RAD_TELEMETRY_ENABLED)
set(LY_COMPILE_DEFINITIONS PUBLIC AZ_PROFILE_TELEMETRY)
endif()
@@ -12,6 +12,6 @@
# is being avoided to prevent overriding functions declared in other targets platfrom
# specific cmake files
if(LY_ENABLE_RAD_TELEMETRY)
if(LY_RAD_TELEMETRY_ENABLED)
set(LY_COMPILE_DEFINITIONS PUBLIC AZ_PROFILE_TELEMETRY)
endif()
@@ -6,6 +6,6 @@
#
#
if(LY_ENABLE_RAD_TELEMETRY)
if(LY_RAD_TELEMETRY_ENABLED)
set(LY_COMPILE_DEFINITIONS PUBLIC AZ_PROFILE_TELEMETRY)
endif()
@@ -63,6 +63,13 @@ namespace Camera
//! @return The camera frustum's height
virtual float GetFrustumHeight() = 0;
//! Gets whether or not the camera is using an orthographic projection.
//! @return True if the camera is using an orthographic projection, or false if the camera is using a perspective projection.
virtual bool IsOrthographic() = 0;
//! @return The half width of the orthographic projection, @see SetOrthographicHalfWidth.
virtual float GetOrthographicHalfWidth() = 0;
//! Sets the camera's field of view in degrees between 0 < fov < 180 degrees
//! @param fov The camera frustum's new field of view in degrees
virtual void SetFov(float fov)
@@ -95,6 +102,15 @@ namespace Camera
//! @param height The camera frustum's new height
virtual void SetFrustumHeight(float height) = 0;
//! Sets whether or not the camera should use an orthographic projection in place of a perspective projection.
//! @param orthographic If true, the camera will use an orthographic projection
virtual void SetOrthographic(bool orthographic) = 0;
//! Sets the half-width of the orthographic projection.
//! @params halfWidth Used to calculate the bounds of the projection while in orthographic mode.
//! The height is calculated automatically based on the aspect ratio.
virtual void SetOrthographicHalfWidth(float halfWidth) = 0;
//! Makes the camera the active view
virtual void MakeActiveView() = 0;
+2 -2
View File
@@ -10,7 +10,7 @@
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
ly_get_list_relative_pal_filename(common_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/Common)
set(LY_ENABLE_STATISTICAL_PROFILING OFF CACHE BOOL "Enables statistical profiling when using AZ_PROFILE_SCOPE. If True, it takes effect only if RAD Telemetry is disabled.")
set(LY_STATISTICAL_PROFILING_ENABLED OFF CACHE BOOL "Enables statistical profiling when using AZ_PROFILE_SCOPE. If True, it takes effect only if RAD Telemetry is disabled.")
set(LY_TOUCHBENDING_LAYER_BIT 63 CACHE STRING "Use TouchBending as the collision layer. The TouchBending layer can be a number from 1 to 63 (Default=63).")
ly_add_target(
@@ -38,7 +38,7 @@ ly_add_target(
3rdParty::lz4
)
if(LY_ENABLE_STATISTICAL_PROFILING)
if(LY_STATISTICAL_PROFILING_ENABLED)
ly_add_source_properties(
SOURCES AzFramework/Debug/StatisticalProfilerProxy.h
PROPERTY COMPILE_DEFINITIONS
@@ -9,8 +9,13 @@
#pragma once
#include <AzCore/Interface/Interface.h>
#include <AzCore/EBus/EBus.h>
#if PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
#include <xcb/xcb.h>
#endif // LY_COMPILE_DEFINITIONS
namespace AzFramework
{
class LinuxLifecycleEvents
@@ -25,4 +30,31 @@ namespace AzFramework
using Bus = AZ::EBus<LinuxLifecycleEvents>;
};
#if PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
class LinuxXcbConnectionManager
{
public:
AZ_RTTI(LinuxXcbConnectionManager, "{649951316-3626-4C9D-9DCA-2E7ABF84C0A9}");
virtual ~LinuxXcbConnectionManager() = default;
virtual xcb_connection_t* GetXcbConnection() const = 0;
};
class LinuxXcbConnectionManagerBusTraits
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//////////////////////////////////////////////////////////////////////////
};
using LinuxXcbConnectionManagerBus = AZ::EBus<LinuxXcbConnectionManager, LinuxXcbConnectionManagerBusTraits>;
using LinuxXcbConnectionManagerInterface = AZ::Interface<LinuxXcbConnectionManager>;
#endif // PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
} // namespace AzFramework
@@ -12,6 +12,32 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace AzFramework
{
#if PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
class LinuxXcbConnectionManagerImpl
: public LinuxXcbConnectionManagerBus::Handler
{
public:
LinuxXcbConnectionManagerImpl()
{
m_xcbConnection = xcb_connect(nullptr, nullptr);
AZ_Error("ApplicationLinux", m_xcbConnection != nullptr, "Unable to connect to X11 Server.");
LinuxXcbConnectionManagerBus::Handler::BusConnect();
}
~LinuxXcbConnectionManagerImpl()
{
LinuxXcbConnectionManagerBus::Handler::BusDisconnect();
xcb_disconnect(m_xcbConnection);
}
xcb_connection_t* GetXcbConnection() const override
{
return m_xcbConnection;
}
private:
xcb_connection_t* m_xcbConnection = nullptr;
};
#endif // PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
////////////////////////////////////////////////////////////////////////////////////////////////
class ApplicationLinux
: public Application::Implementation
@@ -27,6 +53,12 @@ namespace AzFramework
// Application::Implementation
void PumpSystemEventLoopOnce() override;
void PumpSystemEventLoopUntilEmpty() override;
private:
#if PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
AZStd::unique_ptr<LinuxXcbConnectionManager> m_xcbConnectionManager;
#endif // PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
};
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -39,11 +71,26 @@ namespace AzFramework
ApplicationLinux::ApplicationLinux()
{
LinuxLifecycleEvents::Bus::Handler::BusConnect();
#if PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
m_xcbConnectionManager = AZStd::make_unique<LinuxXcbConnectionManagerImpl>();
if (LinuxXcbConnectionManagerInterface::Get() == nullptr)
{
LinuxXcbConnectionManagerInterface::Register(m_xcbConnectionManager.get());
}
#endif // PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
}
////////////////////////////////////////////////////////////////////////////////////////////////
ApplicationLinux::~ApplicationLinux()
{
#if PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
if (LinuxXcbConnectionManagerInterface::Get() == m_xcbConnectionManager.get())
{
LinuxXcbConnectionManagerInterface::Unregister(m_xcbConnectionManager.get());
}
m_xcbConnectionManager.reset();
#endif // PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB
LinuxLifecycleEvents::Bus::Handler::BusDisconnect();
}
@@ -5,3 +5,30 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
# Based on the linux window manager trait, perform the appropriate additional build configurations
# Only 'xcb', 'wayland', and 'xlib' are recognized
if (${PAL_TRAIT_LINUX_WINDOW_MANAGER} STREQUAL "xcb")
find_library(XCB_LIBRARY xcb)
set(LY_BUILD_DEPENDENCIES
PRIVATE
${XCB_LIBRARY}
)
set(LY_COMPILE_DEFINITIONS PUBLIC PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB)
elseif(PAL_TRAIT_LINUX_WINDOW_MANAGER STREQUAL "wayland")
set(LY_COMPILE_DEFINITIONS PUBLIC PAL_TRAIT_LINUX_WINDOW_MANAGER_WAYLAND)
elseif(PAL_TRAIT_LINUX_WINDOW_MANAGER STREQUAL "xlib")
set(LY_COMPILE_DEFINITIONS PUBLIC PAL_TRAIT_LINUX_WINDOW_MANAGER_XLIB)
else()
message(FATAL_ERROR, "Linux Window Manager ${PAL_TRAIT_LINUX_WINDOW_MANAGER} is not recognized")
endif()
@@ -43,19 +43,20 @@ namespace AzQtComponents
{
const QChar decimalPoint = locale.decimalPoint();
const QChar zeroDigit = locale.zeroDigit();
const int numToStringDecimals = AZStd::max(numDecimals, 20);
// We want to truncate, not round. toString will round, so we add an extra decimal place to the formatting
// so we can remove the last value
QString retValue = locale.toString(value, 'f', (numDecimals > 0) ? numDecimals + 1 : 0);
// We want to truncate, not round. toString will round, so we add extra decimal places to the formatting
// so we can remove the last values
QString retValue = locale.toString(value, 'f', (numDecimals > 0) ? numToStringDecimals : 0);
// Handle special cases when we have decimals in our value
if (numDecimals > 0)
{
// Truncate the extra digit now, if it's still there
// Truncate the extra digits now, if they're still there
int decimalPointIndex = retValue.lastIndexOf(decimalPoint);
if ((decimalPointIndex > 0) && (retValue.size() - (decimalPointIndex + 1)) == (numDecimals + 1))
if ((decimalPointIndex > 0) && (retValue.size() - (decimalPointIndex + 1)) == numToStringDecimals)
{
retValue.resize(retValue.size() - 1);
retValue.resize(retValue.size() - (numToStringDecimals - numDecimals));
}
// Remove trailing zeros, since the locale conversion won't do
@@ -102,7 +102,7 @@ namespace Camera
using EditorCameraNotificationBus = AZ::EBus<EditorCameraNotifications>;
/**
* This bus is for requesting any camera-view-related changes
* This bus is for requesting any camera-view-related changes or information
*/
class EditorCameraViewRequests : public AZ::ComponentBus
{
@@ -115,6 +115,11 @@ namespace Camera
* Sets this camera as the active view in the scene, otherwise restores the default editor camera if it was already active
*/
virtual void ToggleCameraAsActiveView() = 0;
/**
* Gets the camera state associated with this view.
*/
virtual bool GetCameraState(AzFramework::CameraState& cameraState) = 0;
};
using EditorCameraViewRequestBus = AZ::EBus<EditorCameraViewRequests>;
@@ -77,6 +77,19 @@ namespace UnitTest
m_intSpinBox.reset();
}
QString setupTruncationTest(QString textValue)
{
QString retval;
m_doubleSpinBoxWithLineEdit->setDecimals(7);
m_doubleSpinBoxWithLineEdit->setDisplayDecimals(3);
m_doubleSpinBoxWithLineEdit->setFocus();
m_doubleSpinBoxWithLineEdit->GetLineEdit()->setText(textValue);
m_doubleSpinBoxWithLineEdit->clearFocus();
return m_doubleSpinBoxWithLineEdit->textFromValue(m_doubleSpinBoxWithLineEdit->value());
}
AZStd::unique_ptr<QWidget> m_dummyWidget;
AZStd::unique_ptr<AzQtComponents::SpinBox> m_intSpinBox;
AZStd::unique_ptr<AzQtComponents::DoubleSpinBox> m_doubleSpinBox;
@@ -277,4 +290,34 @@ namespace UnitTest
// test would result in a crash
EXPECT_TRUE(m_intSpinBox.get() == nullptr);
}
TEST_F(SpinBoxFixture, SpinBoxCheckHighValueTruncatesCorrectly)
{
QString value = setupTruncationTest("0.9999999");
EXPECT_TRUE(value == "0.999");
}
TEST_F(SpinBoxFixture, SpinBoxCheckLowValueTruncatesCorrectly)
{
QString value = setupTruncationTest("0.0000001");
EXPECT_TRUE(value == "0.0");
}
TEST_F(SpinBoxFixture, SpinBoxCheckBugValuesTruncatesCorrectly)
{
QString value = setupTruncationTest("0.12395");
EXPECT_TRUE(value == "0.123");
value = setupTruncationTest("0.94496");
EXPECT_TRUE(value == "0.944");
value = setupTruncationTest("0.0009999");
EXPECT_TRUE(value == "0.0");
}
} // namespace UnitTest