Merge branch 'development' into cmake/SPEC-7484

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Editor/ConfigGroup.cpp
#	Code/Editor/ControlMRU.cpp
#	Code/Editor/CryEdit.cpp
#	Code/Editor/CryEdit.h
#	Code/Editor/IEditorImpl.cpp
#	Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameController.cpp
This commit is contained in:
Esteban Papp
2021-08-10 09:23:34 -07:00
1040 changed files with 29662 additions and 44251 deletions
@@ -44,6 +44,22 @@ namespace AZ
return &out;
}
void SetPerspectiveMatrixFOV(Matrix4x4& out, float fovY, float aspectRatio)
{
float sinFov, cosFov;
SinCos(0.5f * fovY, sinFov, cosFov);
float yScale = cosFov / sinFov; //cot(fovY/2)
float xScale = yScale / aspectRatio;
out.SetElement(0, 0, xScale);
out.SetElement(1, 1, yScale);
}
float GetPerspectiveMatrixFOV(const Matrix4x4& m)
{
return 2.0 * AZStd::atan(1.0f / m.GetElement(1, 1));
}
Matrix4x4* MakeFrustumMatrixRH(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");
@@ -64,4 +64,8 @@ namespace AZ
//! 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);
void SetPerspectiveMatrixFOV(Matrix4x4& out, float fovY, float aspectRatio);
float GetPerspectiveMatrixFOV(const Matrix4x4& m);
} // namespace AZ
@@ -27,11 +27,10 @@ namespace AZ
struct AllocationInfo
{
size_t m_byteSize{};
unsigned int m_alignment{};
const char* m_name{};
const char* m_fileName{};
int m_lineNum{};
unsigned int m_alignment{};
void* m_namesBlock{}; ///< Memory block if m_name and m_fileName have been allocated specifically for this allocation record
size_t m_namesBlockSize{};
@@ -41,7 +40,7 @@ namespace AZ
};
// We use OSAllocator which uses system calls to allocate memory, they are not recorded or tracked!
typedef AZStd::unordered_map<void*, AllocationInfo, AZStd::hash<void*>, AZStd::equal_to<void*>, OSStdAllocator> AllocationRecordsType;
using AllocationRecordsType = AZStd::unordered_map<void*, AllocationInfo, AZStd::hash<void*>, AZStd::equal_to<void*>, OSStdAllocator>;
/**
* Records enumeration callback
@@ -50,7 +49,7 @@ namespace AZ
* \param unsigned char number of stack records/levels, if AllocationInfo::m_stackFrames != NULL.
* \returns true if you want to continue traverse of the records and false if you want to stop.
*/
typedef AZStd::function<bool (void*, const AllocationInfo&, unsigned char)> AllocationInfoCBType;
using AllocationInfoCBType = AZStd::function<bool (void*, const AllocationInfo&, unsigned char)>;
/**
* Example of records enumeration callback.
*/
@@ -28,6 +28,7 @@ namespace AZ::SettingsRegistryMergeUtils
inline static constexpr char FilePathsRootKey[] = "/Amazon/AzCore/Runtime/FilePaths";
inline static constexpr char FilePathKey_BinaryFolder[] = "/Amazon/AzCore/Runtime/FilePaths/BinaryFolder";
inline static constexpr char FilePathKey_EngineRootFolder[] = "/Amazon/AzCore/Runtime/FilePaths/EngineRootFolder";
inline static constexpr char FilePathKey_InstalledBinaryFolder[] = "/Amazon/AzCore/Runtime/FilePaths/InstalledBinariesFolder";
//! Stores the absolute path to root of a project's cache. No asset platform in this path, this is where the asset database file lives.
//! i.e. <ProjectPath>/Cache
+11 -101
View File
@@ -21,7 +21,18 @@ namespace AZStd
{
// alias std::pointer_traits into the AZStd::namespace
using std::pointer_traits;
//! Bring the names of uninitialized_default_construct and
//! uninitialized_default_construct_n into the AZStd namespace
using std::uninitialized_default_construct;
using std::uninitialized_default_construct_n;
//! uninitialized_value_construct and uninitialized_value_construct_n
//! are now brought into scope of the AZStd namespace
using std::uninitialized_value_construct;
using std::uninitialized_value_construct_n;
}
namespace AZStd::Internal
{
template <typename T, typename = void>
@@ -223,107 +234,6 @@ namespace AZStd
}
}
namespace AZStd
{
//! C++20 implementation of uninitialized_default_construct
//! Initializes objects by default-initialization via placement new
//! Ex. `new(declval<void*>()) T` - Notice no parenthesis after T
//! This performs default initialization instead of value initialization
//! Default initialization performs the following actions
//! # If T is a class type it considers constructors which can be invoked
//! with an empty argument list. The selected constructor is invoked
//! to provide the initial value of the object
//! # If T is an array type, then default initialization is performed
//! on each array element
//! # Otherwise nothing is done and objects with automatic storage duration(i.e scope)
//! are initialized with indeterminate values
//! For example given the following struct
//! struct Foo
//! {
//! int mint;
//! double bubble;
//! };
//! Invoking uninitialized_default_construct(FooPtr, FooPtr + 1)
//! Will default initialize the FooPtr object (Foo has an implicitly-defined default constructor)
//! The values of mint and bubble are indeterminate
template <typename ForwardIt>
constexpr auto uninitialized_default_construct(ForwardIt first, ForwardIt last)
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, void>
{
for (; first != last; ++first)
{
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type;
}
}
// C++20 implementation of uninitialized_default_construct_n
// Constructs "n" objects starting at first via default-initialization
template <typename ForwardIt, typename Size>
constexpr auto uninitialized_default_construct_n(ForwardIt first, Size numElements)
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, ForwardIt>
{
for (; numElements > 0; ++first, --numElements)
{
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type;
}
return first;
}
}
namespace AZStd
{
//! C++20 implementation of uninitialized_value_construct
//! Initializes objects by value-initialization via placement new
//! Ex. `new(declval<void*>()) T()` - Notice parenthesis are here after T
//! value-initialization of an object performs different rules depending
//! on the type of T
//! Value initialization performs the following actions
//! # If T is a class type with no default constructor or with a user-provided
//! constructor or a deleted default constructor, then default-initialization
//! is performed
//! # If T is a class type with a default constructor that is neither
//! user-provided nor deleted(i.e a class with an implicitly-defined or defaulted
//! default constructor), then the object is zero-initialized and then it is
//! default-initialized if it has a non-trivial default constructor
//! # If T is an array type, then value initialization is performed
//! on each array element
//! # Otherwise the object is zero-initialized
//! (i.e sets arithmetic and enum objects to 0, bool objects to false, pointers to nullptr)
//! For example given the following struct
//! struct Foo
//! {
//! int mint;
//! double bubble;
//! };
//! Invoking uninitialized_default_construct(FooPtr, FooPtr + 1)
//! Will value-initialize the FooPtr object.
//! The Foo has an implicitly-defined default constructor.
//! For aggregates such as int and double this will perform zero-initialization
//! which will set their values to 0
//! Therefore The values of mint will be 0 and and bubble 0.0
template <typename ForwardIt>
constexpr auto uninitialized_value_construct(ForwardIt first, ForwardIt last)
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, void>
{
for (; first != last; ++first)
{
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type();
}
}
// C++20 implementation of uninitialized_default_construct_n
// Constructs "n" objects starting at the first via by value-initialization
template <typename ForwardIt, typename Size>
constexpr auto uninitialized_value_construct_n(ForwardIt first, Size numElements)
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, ForwardIt>
{
for (; numElements > 0; ++first, --numElements)
{
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type();
}
return first;
}
}
namespace AZStd::Internal
{
@@ -25,29 +25,7 @@ namespace AZStd
AZStd::sys_time_t GetTimeNowTicks()
{
AZStd::sys_time_t timeNow;
struct timespec ts;
clock_serv_t cclock;
mach_timespec_t mts;
kern_return_t ret = host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
if (ret == KERN_SUCCESS)
{
ret = clock_get_time(cclock, &mts);
if (ret == KERN_SUCCESS)
{
ts.tv_sec = mts.tv_sec;
ts.tv_nsec = mts.tv_nsec;
}
else
{
AZ_Assert(false, "clock_get_time error: %d\n", ret);
}
mach_port_deallocate(mach_task_self(), cclock);
}
else
{
AZ_Assert(false, "clock_get_time error: %d\n", ret);
}
timeNow = ts.tv_sec * GetTimeTicksPerSecond() + ts.tv_nsec;
timeNow = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
return timeNow;
}
@@ -62,29 +40,7 @@ namespace AZStd
AZStd::sys_time_t GetTimeNowSecond()
{
AZStd::sys_time_t timeNowSecond;
struct timespec ts;
clock_serv_t cclock;
mach_timespec_t mts;
kern_return_t ret = host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
if (ret == KERN_SUCCESS)
{
ret = clock_get_time(cclock, &mts);
if (ret == KERN_SUCCESS)
{
ts.tv_sec = mts.tv_sec;
ts.tv_nsec = mts.tv_nsec;
}
else
{
AZ_Assert(false, "clock_get_time error: %d\n", ret);
}
mach_port_deallocate(mach_task_self(), cclock);
}
else
{
AZ_Assert(false, "clock_get_time error: %d\n", ret);
}
timeNowSecond = ts.tv_sec;
timeNowSecond = GetTimeNowTicks()/GetTimeTicksPerSecond();
return timeNowSecond;
}
@@ -134,4 +134,48 @@ namespace UnitTest
EXPECT_FLOAT_EQ(4.0f, resultAddress->m_floatValue);
AZStd::destroy_at(resultAddress);
}
TEST(CreateDestroy, UninitializedDefaultConstruct_IsAbleToConstructMultipleElements_Succeeds)
{
struct RefWrapper
{
RefWrapper()
{}
int m_intValue{ 2 };
};
constexpr size_t ArraySize = 2;
AZStd::aligned_storage_for_t<RefWrapper> testArray[ArraySize];
RefWrapper(&uninitializedAddress)[2] = reinterpret_cast<RefWrapper(&)[2]>(testArray);
AZStd::uninitialized_default_construct(AZStd::begin(uninitializedAddress), AZStd::end(uninitializedAddress));
EXPECT_EQ(2, uninitializedAddress[0].m_intValue);
EXPECT_EQ(2, uninitializedAddress[1].m_intValue);
// Reset uninitializedAddress to Debug pattern
memset(uninitializedAddress, 0xCD, ArraySize * sizeof(RefWrapper));
AZStd::uninitialized_default_construct_n(AZStd::data(uninitializedAddress), AZStd::size(uninitializedAddress));
EXPECT_EQ(2, uninitializedAddress[0].m_intValue);
EXPECT_EQ(2, uninitializedAddress[1].m_intValue);
}
TEST(CreateDestroy, UninitializedValueConstruct_IsAbleToConstructMultipleElements_Succeeds)
{
struct RefWrapper
{
int m_intValue;
};
constexpr size_t ArraySize = 2;
AZStd::aligned_storage_for_t<RefWrapper> testArray[ArraySize];
RefWrapper(&uninitializedAddress)[2] = reinterpret_cast<RefWrapper(&)[2]>(testArray);
AZStd::uninitialized_value_construct(AZStd::begin(uninitializedAddress), AZStd::end(uninitializedAddress));
EXPECT_EQ(0, uninitializedAddress[0].m_intValue);
EXPECT_EQ(0, uninitializedAddress[1].m_intValue);
// Reset uninitializedAddress to Debug pattern
memset(uninitializedAddress, 0xCD, ArraySize * sizeof(RefWrapper));
AZStd::uninitialized_value_construct_n(AZStd::data(uninitializedAddress), AZStd::size(uninitializedAddress));
EXPECT_EQ(0, uninitializedAddress[0].m_intValue);
EXPECT_EQ(0, uninitializedAddress[1].m_intValue);
}
}
@@ -114,6 +114,9 @@ namespace Camera
//! Makes the camera the active view
virtual void MakeActiveView() = 0;
//! Check if this camera is the active render camera
virtual bool IsActiveView() = 0;
//! Get the camera frustum's aggregate configuration
virtual Configuration GetCameraConfiguration()
{
@@ -24,7 +24,9 @@
#include <sys/ioctl.h>
#include <sys/resource.h> // for iopolicy
#include <time.h>
#include <unistd.h>
extern char **environ;
namespace AzFramework
{
@@ -45,7 +47,7 @@ namespace AzFramework
// result == 0 means child PID is still running, nothing to check
if (result == -1)
{
AZ_TracePrintf("ProcessWatcher", "IsChildProcessDone could not determine child process status (waitpid errno %d). assuming process either failed to launch or terminated unexpectedly\n", errno);
AZ_TracePrintf("ProcessWatcher", "IsChildProcessDone could not determine child process status (waitpid errno %d(%s)). assuming process either failed to launch or terminated unexpectedly\n", errno, strerror(errno));
exitCode = 0;
}
else if (result == childProcessId)
@@ -274,28 +276,27 @@ namespace AzFramework
azstrcat(commandAndArgs[i], token.size(), token.c_str());
}
commandAndArgs[commandTokens.size()] = nullptr;
char** environmentVariables = nullptr;
int numEnvironmentVars = 0;
constexpr int MaxEnvVariables = 128;
using EnvironmentVariableContainer = AZStd::fixed_vector<char*, MaxEnvVariables>;
EnvironmentVariableContainer environmentVariables;
for (char **env = ::environ; *env; env++)
{
environmentVariables.push_back(*env);
}
if (processLaunchInfo.m_environmentVariables)
{
const int numEnvironmentVars = processLaunchInfo.m_environmentVariables->size();
// Adding one more as exec expects the array to have a nullptr as the last element
environmentVariables = new char*[numEnvironmentVars + 1];
for (int i = 0; i < numEnvironmentVars; i++)
for (AZStd::string& processLaunchEnv : *processLaunchInfo.m_environmentVariables)
{
const AZStd::string& envVarString = processLaunchInfo.m_environmentVariables->at(i);
environmentVariables[i] = new char[envVarString.size() + 1];
environmentVariables[i][0] = '\0';
azstrcat(environmentVariables[i], envVarString.size(), envVarString.c_str());
environmentVariables.push_back(processLaunchEnv.data());
}
environmentVariables[numEnvironmentVars] = NULL;
}
environmentVariables.push_back(nullptr);
pid_t child_pid = fork();
if (IsIdChildProcess(child_pid))
{
ExecuteCommandAsChild(commandAndArgs, environmentVariables, processLaunchInfo, processData.m_startupInfo);
ExecuteCommandAsChild(commandAndArgs, environmentVariables.data(), processLaunchInfo, processData.m_startupInfo);
}
processData.m_childProcessId = child_pid;
@@ -303,15 +304,6 @@ namespace AzFramework
// Close these handles as they are only to be used by the child process
processData.m_startupInfo.CloseAllHandles();
if (processLaunchInfo.m_environmentVariables)
{
for (int i = 0; i < numEnvironmentVars; i++)
{
delete [] environmentVariables[i];
}
delete [] environmentVariables;
}
for (int i = 0; i < commandTokens.size(); i++)
{
delete [] commandAndArgs[i];
@@ -8,6 +8,7 @@
#include <../Common/WinAPI/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard_WinAPI.h>
#include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
#include <AzCore/Module/Environment.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace
@@ -29,7 +30,7 @@ namespace AzFramework
{
////////////////////////////////////////////////////////////////////////////////////////////
//! Count of the number instances of this class that have been created
static int s_instanceCount;
static AZ::EnvironmentVariable<int> s_instanceCount;
public:
////////////////////////////////////////////////////////////////////////////////////////////
@@ -106,7 +107,7 @@ namespace AzFramework
}
////////////////////////////////////////////////////////////////////////////////////////////////
int InputDeviceKeyboardWindows::s_instanceCount = 0;
AZ::EnvironmentVariable<int> InputDeviceKeyboardWindows::s_instanceCount = nullptr;
////////////////////////////////////////////////////////////////////////////////////////////////
InputDeviceKeyboardWindows::InputDeviceKeyboardWindows(InputDeviceKeyboard& inputDevice)
@@ -116,8 +117,10 @@ namespace AzFramework
, m_hasFocus(false)
, m_hasTextEntryStarted(false)
{
if (s_instanceCount++ == 0)
if (!s_instanceCount)
{
s_instanceCount = AZ::Environment::CreateVariable<int>("InputDeviceKeyboardInstanceCount", 1);
// Register for raw keyboard input
RAWINPUTDEVICE rawInputDevice;
rawInputDevice.usUsagePage = RAW_INPUT_KEYBOARD_USAGE_PAGE;
@@ -128,6 +131,10 @@ namespace AzFramework
AZ_Assert(result, "Failed to register raw input device: keyboard");
AZ_UNUSED(result);
}
else
{
s_instanceCount.Set(s_instanceCount.Get() + 1);
}
RawInputNotificationBusWindows::Handler::BusConnect();
}
@@ -137,7 +144,8 @@ namespace AzFramework
{
RawInputNotificationBusWindows::Handler::BusDisconnect();
if (--s_instanceCount == 0)
int instanceCount = s_instanceCount.Get();
if (--instanceCount == 0)
{
// Deregister from raw keyboard input
RAWINPUTDEVICE rawInputDevice;
@@ -148,7 +156,13 @@ namespace AzFramework
const BOOL result = RegisterRawInputDevices(&rawInputDevice, 1, sizeof(rawInputDevice));
AZ_Assert(result, "Failed to deregister raw input device: keyboard");
AZ_UNUSED(result);
s_instanceCount.Reset();
}
else
{
s_instanceCount.Set(instanceCount);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -7,6 +7,7 @@
*/
#include <AzCore/PlatformIncl.h>
#include <AzCore/Module/Environment.h>
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
#include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
#include <AzFramework/Input/Buses/Requests/InputSystemCursorRequestBus.h>
@@ -43,7 +44,7 @@ namespace AzFramework
{
////////////////////////////////////////////////////////////////////////////////////////////
//! Count of the number instances of this class that have been created
static int s_instanceCount;
static AZ::EnvironmentVariable<int> s_instanceCount;
public:
////////////////////////////////////////////////////////////////////////////////////////////
@@ -125,7 +126,7 @@ namespace AzFramework
}
////////////////////////////////////////////////////////////////////////////////////////////////
int InputDeviceMouseWindows::s_instanceCount = 0;
AZ::EnvironmentVariable<int> InputDeviceMouseWindows::s_instanceCount = nullptr;
////////////////////////////////////////////////////////////////////////////////////////////////
InputDeviceMouseWindows::InputDeviceMouseWindows(InputDeviceMouse& inputDevice)
@@ -137,18 +138,24 @@ namespace AzFramework
{
memset(&m_lastClientRect, 0, sizeof(m_lastClientRect));
if (s_instanceCount++ == 0)
if (!s_instanceCount)
{
s_instanceCount = AZ::Environment::CreateVariable<int>("InputDeviceMouseInstanceCount", 1);
// Register for raw mouse input
RAWINPUTDEVICE rawInputDevice;
rawInputDevice.usUsagePage = RAW_INPUT_MOUSE_USAGE_PAGE;
rawInputDevice.usUsage = RAW_INPUT_MOUSE_USAGE;
rawInputDevice.dwFlags = 0;
rawInputDevice.hwndTarget = 0;
rawInputDevice.usUsage = RAW_INPUT_MOUSE_USAGE;
rawInputDevice.dwFlags = 0;
rawInputDevice.hwndTarget = 0;
const BOOL result = RegisterRawInputDevices(&rawInputDevice, 1, sizeof(rawInputDevice));
AZ_Assert(result, "Failed to register raw input device: mouse");
AZ_UNUSED(result);
}
else
{
s_instanceCount.Set(s_instanceCount.Get() + 1);
}
RawInputNotificationBusWindows::Handler::BusConnect();
}
@@ -161,7 +168,8 @@ namespace AzFramework
// Cleanup system cursor visibility and constraint
SetSystemCursorState(SystemCursorState::Unknown);
if (--s_instanceCount == 0)
int instanceCount = s_instanceCount.Get();
if (--instanceCount == 0)
{
// Deregister from raw mouse input
RAWINPUTDEVICE rawInputDevice;
@@ -172,6 +180,12 @@ namespace AzFramework
const BOOL result = RegisterRawInputDevices(&rawInputDevice, 1, sizeof(rawInputDevice));
AZ_Assert(result, "Failed to deregister raw input device: mouse");
AZ_UNUSED(result);
s_instanceCount.Reset();
}
else
{
s_instanceCount.Set(instanceCount);
}
}
@@ -186,6 +186,7 @@ namespace AzToolsFramework
}
}
invalidateFilter();
Q_EMIT filterChanged();
}
@@ -205,6 +206,6 @@ namespace AzToolsFramework
}
} // namespace AssetBrowser
} // namespace AzToolsFramework// namespace AssetBrowser
} // namespace AzToolsFramework
#include "AssetBrowser/moc_AssetBrowserFilterModel.cpp"
@@ -134,7 +134,8 @@ namespace AzToolsFramework
{
return 0;
}
//If the column of the parent is one of those we don't want any more rows as children
if (parent.isValid())
{
if ((parent.column() != aznumeric_cast<int>(AssetBrowserEntry::Column::DisplayName)) &&
@@ -90,24 +90,38 @@ namespace AzToolsFramework
const QAbstractItemModel* model, const QModelIndex& parent /*= QModelIndex()*/, int row /*= 0*/)
{
int rows = model ? model->rowCount(parent) : 0;
for (int i = 0; i < rows; ++i)
if (parent == QModelIndex())
{
QModelIndex index = model->index(i, 0, parent);
AssetBrowserEntry* entry = GetAssetEntry(m_filterModel->mapToSource(index));
//We only wanna see the source assets.
if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source)
{
beginInsertRows(parent, row, row);
m_indexMap[row] = index;
endInsertRows();
m_displayedItemsCounter = 0;
}
Q_EMIT dataChanged(index, index);
++row;
for (int currentRow = 0; currentRow < rows; ++currentRow)
{
if (m_displayedItemsCounter < m_numberOfItemsDisplayed)
{
QModelIndex index = model->index(currentRow, 0, parent);
AssetBrowserEntry* entry = GetAssetEntry(m_filterModel->mapToSource(index));
// We only want to see the source assets.
if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source)
{
beginInsertRows(parent, row, row);
m_indexMap[row] = index;
endInsertRows();
Q_EMIT dataChanged(index, index);
++row;
++m_displayedItemsCounter;
}
if (model->hasChildren(index))
{
row = BuildTableModelMap(model, index, row);
}
}
if (model->hasChildren(index))
else
{
row = BuildTableModelMap(model, index, row);
break;
}
}
return row;
@@ -135,6 +149,10 @@ namespace AzToolsFramework
m_indexMap.clear();
endRemoveRows();
}
AzToolsFramework::EditorSettingsAPIBus::BroadcastResult(
m_numberOfItemsDisplayed, &AzToolsFramework::EditorSettingsAPIBus::Handler::GetMaxNumberOfItemsShownInSearchView);
BuildTableModelMap(sourceModel());
emit layoutChanged();
}
@@ -12,6 +12,7 @@
#include <QSortFilterProxyModel>
#include <QPointer>
#endif
#include <Editor/EditorSettingsAPIBus.h>
namespace AzToolsFramework
{
@@ -50,6 +51,8 @@ namespace AzToolsFramework
int BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0);
private:
int m_numberOfItemsDisplayed = 50;
int m_displayedItemsCounter = 0;
QPointer<AssetBrowserFilterModel> m_filterModel;
QMap<int, QModelIndex> m_indexMap;
};
@@ -6,18 +6,10 @@
*
*/
#include <API/EditorAssetSystemAPI.h>
#include <AzCore/std/containers/vector.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserModel.h>
#include <AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntryCache.h>
#include <AzToolsFramework/AssetBrowser/Entries/ProductAssetBrowserEntry.h>
#include <AzToolsFramework/AssetBrowser/Entries/SourceAssetBrowserEntry.h>
#include <AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h>
#include <AzToolsFramework/AssetBrowser/Views/EntryDelegate.h>
@@ -28,9 +20,7 @@ AZ_PUSH_DISABLE_WARNING(
#include <QCoreApplication>
#include <QHeaderView>
#include <QMenu>
#include <QMouseEvent>
#include <QPainter>
#include <QPen>
#include <QTimer>
AZ_POP_DISABLE_WARNING
namespace AzToolsFramework
@@ -9,7 +9,6 @@
#if !defined(Q_MOC_RUN)
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/std/containers/vector.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h>
@@ -55,7 +54,6 @@ namespace AzToolsFramework
void OnAssetBrowserComponentReady() override;
//////////////////////////////////////////////////////////////////////////
Q_SIGNALS:
void selectionChangedSignal(const QItemSelection& selected, const QItemSelection& deselected);
void ClearStringFilter();
@@ -38,6 +38,7 @@ namespace AzToolsFramework
virtual SettingOutcome GetValue(const AZStd::string_view path) = 0;
virtual SettingOutcome SetValue(const AZStd::string_view path, const AZStd::any& value) = 0;
virtual ConsoleColorTheme GetConsoleColorTheme() const = 0;
virtual int GetMaxNumberOfItemsShownInSearchView() const = 0;
};
using EditorSettingsAPIBus = AZ::EBus<EditorSettingsAPIRequests>;
@@ -65,6 +65,35 @@ namespace UnitTest
}
}
bool FocusInteractionWidget::event(QEvent* event)
{
using AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus;
auto eventType = event->type();
switch (eventType)
{
case QEvent::MouseButtonPress:
EditorInteractionSystemViewportSelectionRequestBus::Event(
AzToolsFramework::GetEntityContextId(), &EditorInteractionSystemViewportSelectionRequestBus::Events::SetDefaultHandler);
return true;
case QEvent::FocusIn:
case QEvent::FocusOut:
{
bool handled = false;
AzToolsFramework::ViewportInteraction::MouseInteraction mouseInteraction;
EditorInteractionSystemViewportSelectionRequestBus::EventResult(
handled, AzToolsFramework::GetEntityContextId(),
&EditorInteractionSystemViewportSelectionRequestBus::Events::InternalHandleMouseViewportInteraction,
AzToolsFramework::ViewportInteraction::MouseInteractionEvent(
mouseInteraction, AzToolsFramework::ViewportInteraction::MouseEvent::Down));
return handled;
}
}
return QWidget::event(event);
}
void TestEditorActions::Connect()
{
using AzToolsFramework::GetEntityContextId;
@@ -8,6 +8,7 @@
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Slice/SliceAsset.h>
@@ -31,6 +32,7 @@
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
#include <AzToolsFramework/SourceControl/PerforceConnection.h>
#include <AzToolsFramework/UnitTest/ToolsTestApplication.h>
#endif // !defined(Q_MOC_RUN)
#include <ostream>
@@ -40,7 +42,7 @@ AZ_POP_DISABLE_WARNING
#define AUTO_RESULT_IF_SETTING_TRUE(_settingName, _result) \
{ \
bool settingValue = true; \
bool settingValue = true; \
if (auto* registry = AZ::SettingsRegistry::Get()) \
{ \
registry->Get(settingValue, _settingName); \
@@ -51,23 +53,16 @@ AZ_POP_DISABLE_WARNING
EXPECT_TRUE(_result); \
return; \
} \
}
namespace AZ
{
class Entity;
class EntityId;
} // namespace AZ
}
namespace UnitTest
{
constexpr AZStd::string_view prefabSystemSetting = "/Amazon/Preferences/EnablePrefabSystem";
/// Test widget to store QActions generated by EditorTransformComponentSelection.
class TestWidget
: public QWidget
class TestWidget : public QWidget
{
Q_OBJECT
public:
TestWidget()
: QWidget()
@@ -79,6 +74,15 @@ namespace UnitTest
bool eventFilter(QObject* watched, QEvent* event) override;
};
/// Widget used to trigger a viewport interaction event while a focus change is happening.
class FocusInteractionWidget : public QWidget
{
Q_OBJECT
public:
FocusInteractionWidget(QWidget* parent = nullptr) : QWidget(parent) {}
bool event(QEvent* event) override;
};
/// Stores actions registered for either normal mode (regular viewport) editing and
/// component mode editing.
class TestEditorActions
@@ -50,6 +50,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
ly_add_target(
NAME AzToolsFrameworkTestCommon STATIC
NAMESPACE AZ
AUTOMOC
FILES_CMAKE
AzToolsFramework/aztoolsframeworktestcommon_files.cmake
INCLUDE_DIRECTORIES
@@ -68,6 +69,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
ly_add_target(
NAME AzToolsFramework.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE AZ
AUTOMOC
FILES_CMAKE
Tests/aztoolsframeworktests_files.cmake
INCLUDE_DIRECTORIES
@@ -31,8 +31,10 @@
#include <AzToolsFramework/Viewport/ActionBus.h>
#include <AzToolsFramework/ViewportSelection/EditorDefaultSelection.h>
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
#include <AzToolsFramework/ViewportSelection/EditorPickEntitySelection.h>
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.h>
#include <AzToolsFramework/ViewportSelection/EditorVisibleEntityDataCache.h>
#include <AzToolsFramework/ViewportUi/ViewportUiManager.h>
namespace AZ
{
@@ -188,6 +190,47 @@ namespace UnitTest
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EditorTransformComponentSelection Tests
TEST_F(EditorTransformComponentSelectionFixture, Focus_is_not_changed_while_switching_viewport_interaction_request_instance)
{
// setup a dummy widget and make it the active window to ensure focus in/out events are fired
auto dummyWidget = AZStd::make_unique<QWidget>();
QApplication::setActiveWindow(dummyWidget.get());
// note: it is important to make sure the focus widget is parented to the dummy widget to have focus in/out events fire
auto focusWidget = AZStd::make_unique<UnitTest::FocusInteractionWidget>(dummyWidget.get());
const auto previousFocusWidget = QApplication::focusWidget();
// Given
// setup viewport ui system
AzToolsFramework::ViewportUi::ViewportUiManager viewportUiManager;
viewportUiManager.ConnectViewportUiBus(AzToolsFramework::ViewportUi::DefaultViewportId);
viewportUiManager.InitializeViewportUi(&m_editorActions.m_defaultWidget, focusWidget.get());
// begin EditorPickEntitySelection
using AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus;
EditorInteractionSystemViewportSelectionRequestBus::Event(
AzToolsFramework::GetEntityContextId(), &EditorInteractionSystemViewportSelectionRequestBus::Events::SetHandler,
[](const AzToolsFramework::EditorVisibleEntityDataCache* entityDataCache)
{
return AZStd::make_unique<AzToolsFramework::EditorPickEntitySelection>(entityDataCache);
});
// When
// a mouse event is sent to the focus widget (set to be the render overlay in the viewport ui system)
QTest::mouseClick(focusWidget.get(), Qt::MouseButton::LeftButton);
// Then
// focus should not change
EXPECT_FALSE(focusWidget->hasFocus());
EXPECT_EQ(previousFocusWidget, QApplication::focusWidget());
// clean up
viewportUiManager.DisconnectViewportUiBus();
focusWidget.reset();
dummyWidget.reset();
}
TEST_F(EditorTransformComponentSelectionFixture, ManipulatorOrientationIsResetWhenEntityOrientationIsReset)
{
using AzToolsFramework::EditorTransformComponentSelectionRequestBus;