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);
}
}