Merge branch 'main' of https://github.com/aws-lumberyard/o3de into Spawnable/ScriptCanvas/Integration
This commit is contained in:
@@ -148,7 +148,7 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
AZ_Assert(false, "Failed to locate the bootstrap.cfg path");
|
||||
AZ_Assert(false, "Failed to locate the engine.json path");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace AZ
|
||||
//! \return The pointer position of the relative asset path
|
||||
AZ::IO::FixedMaxPath StripApkPrefix(const char* filePath);
|
||||
|
||||
//! Searches application storage and the APK for bootstrap.cfg. Will return nullptr
|
||||
//! if bootstrap.cfg is not found.
|
||||
//! Searches application storage and the APK for engine.json. Will return nullptr
|
||||
//! if engine.json is not found.
|
||||
const char* FindAssetsDirectory();
|
||||
|
||||
//! Calls into Java to show the splash screen on the main UI (Java) thread
|
||||
|
||||
@@ -462,8 +462,6 @@ namespace AZ
|
||||
// for the application root.
|
||||
CalculateAppRoot();
|
||||
|
||||
// Merge the bootstrap.cfg file into the Settings Registry as soon as the OSAllocator has been created.
|
||||
SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(*m_settingsRegistry);
|
||||
SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(*m_settingsRegistry, AZ_TRAIT_OS_PLATFORM_CODENAME, {});
|
||||
SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(*m_settingsRegistry, m_commandLine, executeRegDumpCommands);
|
||||
SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*m_settingsRegistry);
|
||||
|
||||
@@ -287,71 +287,28 @@ namespace AZ
|
||||
|
||||
//! Scale modifiers
|
||||
//! @{
|
||||
//! @deprecated Use SetLocalScale()
|
||||
//! Scales the entity along the world's axes. The origin of the axes is the entity's position in the world.
|
||||
//! @param scale A three-dimensional vector that represents the multipliers with which to scale the entity in world space.
|
||||
virtual void SetScale([[maybe_unused]] const AZ::Vector3& scale) {}
|
||||
|
||||
//! @deprecated Use SetLocalScaleX()
|
||||
//! Scales the entity along the world's X axis. The origin of the axis is the entity's position in the world.
|
||||
//! @param scaleX The multiplier by which to scale the entity along the X axis in world space.
|
||||
virtual void SetScaleX([[maybe_unused]] float scaleX) {}
|
||||
|
||||
//! @deprecated Use SetLocalScaleY()
|
||||
//! Scales the entity along the world's Y axis. The origin of the axis is the entity's position in the world.
|
||||
//! @param scaleY The multiplier by which to scale the entity along the Y axis in world space.
|
||||
virtual void SetScaleY([[maybe_unused]] float scaleY) {}
|
||||
|
||||
//! @deprecated Use SetLocalScaleZ()
|
||||
//! Scales the entity along the world's Z axis. The origin of the axis is the entity's position in the world.
|
||||
//! @param scaleZ The multiplier by which to scale the entity along the Z axis in world space.
|
||||
virtual void SetScaleZ([[maybe_unused]] float scaleZ) {}
|
||||
|
||||
//! @deprecated Use GetLocalScale()
|
||||
//! Gets the scale of the entity in world space.
|
||||
//! @return A three-dimensional vector that represents the scale of the entity in world space.
|
||||
virtual AZ::Vector3 GetScale() { return AZ::Vector3(FLT_MAX); }
|
||||
|
||||
//! @deprecated Use GetLocalScale()
|
||||
//! Gets the amount by which an entity is scaled along the world's X axis.
|
||||
//! @return The amount by which an entity is scaled along the X axis in world space.
|
||||
virtual float GetScaleX() { return FLT_MAX; }
|
||||
|
||||
//! @deprecated Use GetLocalScale()
|
||||
//! Gets the amount by which an entity is scaled along the world's Y axis.
|
||||
//! @return The amount by which an entity is scaled along the Y axis in world space.
|
||||
virtual float GetScaleY() { return FLT_MAX; }
|
||||
|
||||
//! @deprecated Use GetLocalScale()
|
||||
//! Gets the amount by which an entity is scaled along the world's Z axis.
|
||||
//! @return The amount by which an entity is scaled along the Z axis in world space.
|
||||
virtual float GetScaleZ() { return FLT_MAX; }
|
||||
|
||||
//! Set local scale of the transform.
|
||||
//! @param scale The new scale to set along three local axes.
|
||||
//! @param scale The new scale to set.
|
||||
virtual void SetLocalScale([[maybe_unused]] const AZ::Vector3& scale) {}
|
||||
|
||||
//! Set local scale of the transform on x-axis.
|
||||
//! @param scaleX The new x-axis scale to set.
|
||||
virtual void SetLocalScaleX([[maybe_unused]] float scaleX) {}
|
||||
|
||||
//! Set local scale of the transform on y-axis.
|
||||
//! @param scaleY The new y-axis scale to set.
|
||||
virtual void SetLocalScaleY([[maybe_unused]] float scaleY) {}
|
||||
|
||||
//! Set local scale of the transform on z-axis.
|
||||
//! @param scaleZ The new z-axis scale to set.
|
||||
virtual void SetLocalScaleZ([[maybe_unused]] float scaleZ) {}
|
||||
|
||||
//! Get the scale value on each axis in local space
|
||||
//! @return The scale value of type Vector3 along each axis in local space.
|
||||
//! Get the scale value in local space.
|
||||
//! @return The scale value in local space.
|
||||
virtual AZ::Vector3 GetLocalScale() { return AZ::Vector3(FLT_MAX); }
|
||||
|
||||
//! Get the scale value on each axis in world space.
|
||||
//! Note the transform will be skewed when it is rotated and has a parent transform scaled, in which
|
||||
//! case the returned world-scale from this function will be inaccurate.
|
||||
//! @return The scale value of type Vector3 along each axis in world space.
|
||||
//! Get the scale value in world space.
|
||||
//! @return The scale value in world space.
|
||||
virtual AZ::Vector3 GetWorldScale() { return AZ::Vector3(FLT_MAX); }
|
||||
|
||||
//! Set the uniform scale value in local space.
|
||||
virtual void SetLocalUniformScale([[maybe_unused]] float scale) {}
|
||||
|
||||
//! Get the uniform scale value in local space.
|
||||
//! @return The uniform scale value in local space.
|
||||
virtual float GetLocalUniformScale() { return FLT_MAX; }
|
||||
|
||||
//! Get the uniform scale value in world space.
|
||||
//! @return The uniform scale value in world space.
|
||||
virtual float GetWorldUniformScale() { return FLT_MAX; }
|
||||
//! @}
|
||||
|
||||
//! Transform hierarchy
|
||||
|
||||
@@ -348,13 +348,20 @@ namespace AZ
|
||||
return result.GetW() >= 0.0f ? result : -result;
|
||||
}
|
||||
|
||||
const Quaternion Quaternion::CreateFromEulerAnglesDegrees(Vector3& anglesInDegrees)
|
||||
const Quaternion Quaternion::CreateFromEulerAnglesDegrees(const Vector3& anglesInDegrees)
|
||||
{
|
||||
Quaternion result;
|
||||
result.SetFromEulerDegrees(anglesInDegrees);
|
||||
return result;
|
||||
}
|
||||
|
||||
const Quaternion Quaternion::CreateFromEulerAnglesRadians(const Vector3& anglesInRadians)
|
||||
{
|
||||
Quaternion result;
|
||||
result.SetFromEulerRadians(anglesInRadians);
|
||||
return result;
|
||||
}
|
||||
|
||||
Quaternion Quaternion::Slerp(const Quaternion& dest, float t) const
|
||||
{
|
||||
const float DestDot = Dot(dest);
|
||||
|
||||
@@ -83,8 +83,11 @@ namespace AZ
|
||||
|
||||
static Quaternion CreateShortestArc(const Vector3& v1, const Vector3& v2);
|
||||
|
||||
/// Creates a quaternion using rotation in degrees about the axes. First rotated about the X axis, followed by the Y axis, then the Z axis.
|
||||
static const Quaternion CreateFromEulerAnglesDegrees(Vector3& anglesInDegrees);
|
||||
//! Creates a quaternion using rotation in degrees about the axes. First rotated about the X axis, followed by the Y axis, then the Z axis.
|
||||
static const Quaternion CreateFromEulerAnglesDegrees(const Vector3& anglesInDegrees);
|
||||
|
||||
//! Creates a quaternion using rotation in radians about the axes. First rotated about the X axis, followed by the Y axis, then the Z axis.
|
||||
static const Quaternion CreateFromEulerAnglesRadians(const Vector3& anglesInRadians);
|
||||
|
||||
//! Stores the vector to an array of 4 floats. The floats need only be 4 byte aligned, 16 byte alignment is not required.
|
||||
void StoreToFloat4(float* values) const;
|
||||
|
||||
@@ -126,17 +126,16 @@ namespace AZ
|
||||
m_offsets.fill(1); // Halton sequences start at index 1.
|
||||
m_increments.fill(1); // By default increment by 1 between each number.
|
||||
}
|
||||
|
||||
//! Returns a Halton sequence in an array of N length
|
||||
template<uint32_t N>
|
||||
AZStd::array<AZStd::array<float, Dimensions>, N> GetHaltonSequence()
|
||||
|
||||
//! Fills a provided container from begin to end with a Halton sequence.
|
||||
//! Entries are expected to be, or implicitly converted to, AZStd::array<float, Dimensions>.
|
||||
template<typename Iterator>
|
||||
void FillHaltonSequence(Iterator begin, Iterator end)
|
||||
{
|
||||
AZStd::array<AZStd::array<float, Dimensions>, N> result;
|
||||
|
||||
AZStd::array<uint32_t, Dimensions> indices = m_offsets;
|
||||
|
||||
// Generator that returns the Halton number for all bases for a single entry.
|
||||
auto f = [&] ()
|
||||
auto f = [&]()
|
||||
{
|
||||
AZStd::array<float, Dimensions> item;
|
||||
for (auto d = 0; d < Dimensions; ++d)
|
||||
@@ -147,12 +146,20 @@ namespace AZ
|
||||
return item;
|
||||
};
|
||||
|
||||
AZStd::generate(result.begin(), result.end(), f);
|
||||
AZStd::generate(begin, end, f);
|
||||
}
|
||||
|
||||
//! Returns a Halton sequence in an array of N length.
|
||||
template<uint32_t N>
|
||||
AZStd::array<AZStd::array<float, Dimensions>, N> GetHaltonSequence()
|
||||
{
|
||||
AZStd::array<AZStd::array<float, Dimensions>, N> result;
|
||||
FillHaltonSequence(result.begin(), result.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
//! Sets the offsets per dimension to start generating a sequence from.
|
||||
//! By default, there is no offset (offset of 0 corresponds to starting at index 1)
|
||||
//! By default, there is no offset (offset of 0 corresponds to starting at index 1).
|
||||
void SetOffsets(AZStd::array<uint32_t, Dimensions> offsets)
|
||||
{
|
||||
m_offsets = offsets;
|
||||
|
||||
@@ -441,10 +441,10 @@ namespace AZ
|
||||
const Transform& worldFromLocal, const Vector3& src, const Vector3& dir, const Spline& spline)
|
||||
{
|
||||
Transform worldFromLocalNormalized = worldFromLocal;
|
||||
const Vector3 scale = worldFromLocalNormalized.ExtractScale();
|
||||
const float scale = worldFromLocalNormalized.ExtractUniformScale();
|
||||
const Transform localFromWorldNormalized = worldFromLocalNormalized.GetInverse();
|
||||
|
||||
const Vector3 localRayOrigin = localFromWorldNormalized.TransformPoint(src) * scale.GetReciprocal();
|
||||
const Vector3 localRayOrigin = localFromWorldNormalized.TransformPoint(src) / scale;
|
||||
const Vector3 localRayDirection = localFromWorldNormalized.TransformVector(dir);
|
||||
return spline.GetNearestAddressRay(localRayOrigin, localRayDirection);
|
||||
}
|
||||
|
||||
@@ -284,10 +284,15 @@ namespace AZ
|
||||
Method("GetRotation", &Transform::GetRotation)->
|
||||
Method<void (Transform::*)(const Quaternion&)>("SetRotation", &Transform::SetRotation)->
|
||||
Method("GetScale", &Transform::GetScale)->
|
||||
Method<void (Transform::*)(const Vector3&)>("SetScale", &Transform::SetScale)->
|
||||
Method("GetUniformScale", &Transform::GetUniformScale)->
|
||||
Method("SetScale", &Transform::SetScale)->
|
||||
Method("SetUniformScale", &Transform::SetUniformScale)->
|
||||
Method("ExtractScale", &Transform::ExtractScale)->
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
|
||||
Method("ExtractUniformScale", &Transform::ExtractUniformScale)->
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
|
||||
Method("MultiplyByScale", &Transform::MultiplyByScale)->
|
||||
Method("MultiplyByUniformScale", &Transform::MultiplyByUniformScale)->
|
||||
Method("GetInverse", &Transform::GetInverse)->
|
||||
Method("Invert", &Transform::Invert)->
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
|
||||
@@ -306,6 +311,7 @@ namespace AZ
|
||||
Method("CreateFromMatrix3x3", &Transform::CreateFromMatrix3x3)->
|
||||
Method("CreateFromMatrix3x3AndTranslation", &Transform::CreateFromMatrix3x3AndTranslation)->
|
||||
Method("CreateScale", &Transform::CreateScale)->
|
||||
Method("CreateUniformScale", &Transform::CreateUniformScale)->
|
||||
Method("CreateTranslation", &Transform::CreateTranslation)->
|
||||
Method("ConstructFromValuesNumeric", &Internal::ConstructTransformFromValues);
|
||||
}
|
||||
|
||||
@@ -89,8 +89,11 @@ namespace AZ
|
||||
|
||||
static Transform CreateFromMatrix3x4(const Matrix3x4& value);
|
||||
|
||||
//! Sets the matrix to be a scale matrix, translation is set to zero.
|
||||
static Transform CreateScale(const Vector3& scale);
|
||||
//! Sets the transform to apply scale only, no rotation or translation.
|
||||
static Transform CreateScale(const AZ::Vector3& scale);
|
||||
|
||||
//! Sets the transform to apply (uniform) scale only, no rotation or translation.
|
||||
static Transform CreateUniformScale(const float scale);
|
||||
|
||||
//! Sets the matrix to be a translation matrix, rotation part is set to identity.
|
||||
static Transform CreateTranslation(const Vector3& translation);
|
||||
@@ -119,13 +122,19 @@ namespace AZ
|
||||
const Quaternion& GetRotation() const;
|
||||
void SetRotation(const Quaternion& rotation);
|
||||
|
||||
const Vector3& GetScale() const;
|
||||
Vector3 GetScale() const;
|
||||
float GetUniformScale() const;
|
||||
void SetScale(const Vector3& v);
|
||||
void SetUniformScale(const float scale);
|
||||
|
||||
//! Sets the transforms scale to a unit value and returns the previous scale value.
|
||||
//! Sets the transform's scale to a unit value and returns the previous scale value.
|
||||
Vector3 ExtractScale();
|
||||
|
||||
void MultiplyByScale(const Vector3& scale);
|
||||
//! Sets the transform's scale to a unit value and returns the previous scale value.
|
||||
float ExtractUniformScale();
|
||||
|
||||
void MultiplyByScale(const AZ::Vector3& scale);
|
||||
void MultiplyByUniformScale(float scale);
|
||||
|
||||
Transform operator*(const Transform& rhs) const;
|
||||
Transform& operator*=(const Transform& rhs);
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE Transform Transform::CreateScale(const Vector3& scale)
|
||||
{
|
||||
AZ_WarningOnce("Transform", false, "CreateScale is deprecated, please use CreateUniformScale instead.");
|
||||
Transform result;
|
||||
result.m_rotation = Quaternion::CreateIdentity();
|
||||
result.m_scale = scale;
|
||||
@@ -72,6 +73,15 @@ namespace AZ
|
||||
return result;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Transform Transform::CreateUniformScale(float scale)
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = Quaternion::CreateIdentity();
|
||||
result.m_scale = Vector3(scale);
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Transform Transform::CreateTranslation(const Vector3& translation)
|
||||
{
|
||||
Transform result;
|
||||
@@ -150,24 +160,50 @@ namespace AZ
|
||||
m_rotation = rotation;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE const Vector3& Transform::GetScale() const
|
||||
AZ_MATH_INLINE Vector3 Transform::GetScale() const
|
||||
{
|
||||
AZ_WarningOnce("Transform", false, "GetScale is deprecated, please use GetUniformScale instead.");
|
||||
return m_scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE float Transform::GetUniformScale() const
|
||||
{
|
||||
return m_scale.GetMaxElement();
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::SetScale(const Vector3& scale)
|
||||
{
|
||||
AZ_WarningOnce("Transform", false, "SetScale is deprecated, please use SetUniformScale instead.");
|
||||
m_scale = scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::SetUniformScale(const float scale)
|
||||
{
|
||||
m_scale = Vector3(scale);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Vector3 Transform::ExtractScale()
|
||||
{
|
||||
AZ_WarningOnce("Transform", false, "ExtractScale is deprecated, please use ExtractUniformScale instead.");
|
||||
const Vector3 scale = m_scale;
|
||||
m_scale = Vector3::CreateOne();
|
||||
return scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE float Transform::ExtractUniformScale()
|
||||
{
|
||||
const float scale = m_scale.GetMaxElement();
|
||||
m_scale = Vector3::CreateOne();
|
||||
return scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::MultiplyByScale(const Vector3& scale)
|
||||
{
|
||||
AZ_WarningOnce("Transform", false, "MultiplyByScale is deprecated, please use MultiplyByUniformScale instead.");
|
||||
m_scale *= scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::MultiplyByUniformScale(float scale)
|
||||
{
|
||||
m_scale *= scale;
|
||||
}
|
||||
@@ -233,7 +269,7 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE void Transform::Orthogonalize()
|
||||
{
|
||||
*this = GetOrthogonalized();
|
||||
m_scale = Vector3::CreateOne();
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE bool Transform::IsClose(const Transform& rhs, float tolerance) const
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace AZ
|
||||
{
|
||||
// Scale is transitioning to a single uniform scale value, but since it's still internally represented as a Vector3,
|
||||
// we need to pick one number to use for load/store operations.
|
||||
float scale = transformInstance->GetScale().GetMaxElement();
|
||||
float scale = transformInstance->GetUniformScale();
|
||||
|
||||
JSR::ResultCode loadResult =
|
||||
ContinueLoadingFromJsonObjectField(&scale, azrtti_typeid<decltype(scale)>(), inputValue, ScaleTag, context);
|
||||
@@ -124,8 +124,8 @@ namespace AZ
|
||||
|
||||
// Scale is transitioning to a single uniform scale value, but since it's still internally represented as a Vector3,
|
||||
// we need to pick one number to use for load/store operations.
|
||||
float scale = transformInstance->GetScale().GetMaxElement();
|
||||
float defaultScale = defaultTransformInstance ? defaultTransformInstance->GetScale().GetMaxElement() : 0.0f;
|
||||
float scale = transformInstance->GetUniformScale();
|
||||
float defaultScale = defaultTransformInstance ? defaultTransformInstance->GetUniformScale() : 0.0f;
|
||||
|
||||
JSR::ResultCode storeResult = ContinueStoringToJsonObjectField(
|
||||
outputValue, ScaleTag, &scale, defaultTransformInstance ? &defaultScale : nullptr, azrtti_typeid<decltype(scale)>(),
|
||||
|
||||
@@ -1020,29 +1020,60 @@ namespace AZ
|
||||
}
|
||||
};
|
||||
|
||||
/// OnDemand reflection for AZStd::set
|
||||
|
||||
template<class t_Key, class t_Hasher, class t_EqualKey, class t_Allocator>
|
||||
class Iterator_VM<AZStd::unordered_set<t_Key, t_Hasher, t_EqualKey, t_Allocator>>
|
||||
{
|
||||
public:
|
||||
using ContainerType = AZStd::unordered_set<t_Key, t_Hasher, t_EqualKey, t_Allocator>;
|
||||
using IteratorType = typename ContainerType::iterator;
|
||||
Iterator_VM(ContainerType& container)
|
||||
: m_iterator(container.begin())
|
||||
, m_end(container.end())
|
||||
{}
|
||||
|
||||
const t_Key& GetKeyUnchecked() const
|
||||
{
|
||||
return *m_iterator;
|
||||
}
|
||||
|
||||
bool IsNotAtEnd() const
|
||||
{
|
||||
return m_iterator != m_end;
|
||||
}
|
||||
|
||||
t_Key& ModValueUnchecked()
|
||||
{
|
||||
return *m_iterator;
|
||||
}
|
||||
|
||||
void Next()
|
||||
{
|
||||
++m_iterator;
|
||||
}
|
||||
|
||||
private:
|
||||
IteratorType m_iterator;
|
||||
IteratorType m_end;
|
||||
};
|
||||
|
||||
/// OnDemand reflection for AZStd::unordered_set
|
||||
template<class Key, class Hasher, class EqualKey, class Allocator>
|
||||
struct OnDemandReflection< AZStd::unordered_set<Key, Hasher, EqualKey, Allocator> >
|
||||
{
|
||||
using ContainerType = AZStd::unordered_set<Key, Hasher, EqualKey, Allocator>;
|
||||
using KeyListType = AZStd::vector<Key, Allocator>;
|
||||
|
||||
static AZ::Outcome<void, void> Erase(ContainerType& thisMap, Key& key)
|
||||
using ValueIteratorType = Iterator_VM<ContainerType>;
|
||||
|
||||
static bool EraseCheck_VM(ContainerType& thisSet, Key& key)
|
||||
{
|
||||
const auto result = thisMap.erase(key);
|
||||
if (result)
|
||||
{
|
||||
return AZ::Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure();
|
||||
}
|
||||
return thisSet.erase(key) != 0;
|
||||
}
|
||||
|
||||
static void Insert(ContainerType& thisSet, Key& key)
|
||||
static ContainerType& ErasePost_VM(ContainerType& thisSet, [[maybe_unused]] Key&)
|
||||
{
|
||||
thisSet.insert(key);
|
||||
return thisSet;
|
||||
}
|
||||
|
||||
static KeyListType GetKeys(ContainerType& thisSet)
|
||||
@@ -1055,6 +1086,17 @@ namespace AZ
|
||||
return keys;
|
||||
}
|
||||
|
||||
static ContainerType& Insert(ContainerType& thisSet, Key& key)
|
||||
{
|
||||
thisSet.insert(key);
|
||||
return thisSet;
|
||||
}
|
||||
|
||||
static ValueIteratorType Iterate_VM(ContainerType& thisContainer)
|
||||
{
|
||||
return ValueIteratorType(thisContainer);
|
||||
}
|
||||
|
||||
static void Swap(ContainerType& thisSet, ContainerType& otherSet)
|
||||
{
|
||||
thisSet.swap(otherSet);
|
||||
@@ -1064,33 +1106,68 @@ namespace AZ
|
||||
{
|
||||
if (BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context))
|
||||
{
|
||||
BranchOnResultInfo emptyBranchInfo;
|
||||
emptyBranchInfo.m_returnResultInBranches = true;
|
||||
emptyBranchInfo.m_trueToolTip = "The container is empty";
|
||||
emptyBranchInfo.m_falseToolTip = "The container is not empty";
|
||||
|
||||
auto ContainsTransparent = [](const ContainerType& containerType, typename ContainerType::key_type& key)->bool
|
||||
{
|
||||
return containerType.contains(key);
|
||||
};
|
||||
|
||||
ExplicitOverloadInfo explicitOverloadInfo;
|
||||
behaviorContext->Class<ContainerType>()
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::ListOnly)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::PrettyName, ScriptCanvasOnDemandReflection::OnDemandPrettyName<ContainerType>::Get(*behaviorContext))
|
||||
->Attribute(AZ::Script::Attributes::ToolTip, ScriptCanvasOnDemandReflection::OnDemandToolTip<ContainerType>::Get(*behaviorContext))
|
||||
->Attribute(AZ::Script::Attributes::Category, ScriptCanvasOnDemandReflection::OnDemandCategoryName<ContainerType>::Get(*behaviorContext))
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::ScriptOwn)
|
||||
->Method("BucketCount", static_cast<typename ContainerType::size_type(ContainerType::*)() const>(&ContainerType::bucket_count))
|
||||
->Method("Erase", &Erase)
|
||||
->Method("Empty", [](ContainerType& thisSet)->bool { return thisSet.empty(); })
|
||||
->Method("Empty", static_cast<bool(ContainerType::*)() const>(&ContainerType::empty), { { { "Container", "The container to check if it is empty", nullptr, {} } } })
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Is Empty", "Containers"))
|
||||
->Attribute(AZ::ScriptCanvasAttributes::BranchOnResult, emptyBranchInfo)
|
||||
->Method("EraseCheck_VM", &EraseCheck_VM)
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
->Method("Erase", &ErasePost_VM)
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Erase", "Containers"))
|
||||
->Attribute(AZ::ScriptCanvasAttributes::CheckedOperation, CheckedOperationInfo("EraseCheck_VM", {}, "Out", "Key Not Found", true))
|
||||
->Attribute(AZ::ScriptCanvasAttributes::OverloadArgumentGroup, AZ::OverloadArgumentGroupInfo({ "ContainerGroup", "" }, { "ContainerGroup" }))
|
||||
->Method("contains", ContainsTransparent)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Has Key", "Containers"))
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Method("Insert", &Insert)
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Insert", "Containers"))
|
||||
->Attribute(AZ::ScriptCanvasAttributes::OverloadArgumentGroup, AZ::OverloadArgumentGroupInfo({ "ContainerGroup", "", "" }, { "ContainerGroup" }))
|
||||
->Method(k_sizeName, [](ContainerType* thisPtr) { return aznumeric_cast<int>(thisPtr->size()); })
|
||||
->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Length)
|
||||
->Method("GetKeys", &GetKeys)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
->Method("GetSize", [](ContainerType& thisPtr) { return aznumeric_cast<int>(thisPtr.size()); })
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Get Size", "Containers"))
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Method("Reserve", static_cast<void(ContainerType::*)(typename ContainerType::size_type)>(&ContainerType::reserve))
|
||||
->Method("Swap", &Swap)
|
||||
->Method("Clear", [](ContainerType& thisContainer)->ContainerType& { thisContainer.clear(); return thisContainer; })
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Clear All Elements", "Containers"))
|
||||
->Attribute(AZ::ScriptCanvasAttributes::OverloadArgumentGroup, AZ::OverloadArgumentGroupInfo({ "ContainerGroup" }, { "ContainerGroup" }))
|
||||
->Method(k_iteratorConstructorName, &Iterate_VM)
|
||||
;
|
||||
|
||||
behaviorContext->Class<ValueIteratorType>()
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::ListOnly)
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::ScriptOwn)
|
||||
->Method(k_iteratorGetKeyName, &ValueIteratorType::GetKeyUnchecked)
|
||||
->Method(k_iteratorModValueName, &ValueIteratorType::ModValueUnchecked)
|
||||
->Method(k_iteratorIsNotAtEndName, &ValueIteratorType::IsNotAtEnd)
|
||||
->Method(k_iteratorNextName, &ValueIteratorType::Next)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <>
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace AZ
|
||||
|
||||
if (HasResult() != overload->HasResult())
|
||||
{
|
||||
AZ_Error("Reflection", false, "Overload failure, all methods must have the same result, or none at all");
|
||||
AZ_Error("Reflection", false, "Overload failure, all methods must have the same result, or none at all: %s", m_name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace AZ
|
||||
|
||||
if (!(methodResult->m_typeId == overloadResult->m_typeId && methodResult->m_traits == overloadResult->m_traits))
|
||||
{
|
||||
AZ_Error("Reflection", false, "Overload failure, all methods must have the same result, or none at all");
|
||||
AZ_Error("Reflection", false, "Overload failure, all methods must have the same result, or none at all: %s", m_name.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -575,7 +575,7 @@ namespace AZ
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error("BehaviorContext", false, "safety check declared for method %s but it was not found in the class");
|
||||
AZ_Error("BehaviorContext", false, "Method: %s, declared safety check: %s, but it was not found in class: %s", method.m_name.c_str(), m_name.c_str(), checkedOperationInfo.m_safetyCheckName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,17 @@ namespace BehaviorContextUtilitiesCPP
|
||||
using argument_type = const BehaviorParameter*;
|
||||
using result_type = size_t;
|
||||
result_type operator()(const argument_type& value) const
|
||||
{
|
||||
result_type result = AZStd::hash<Uuid>()(value->m_typeId);
|
||||
AZStd::hash_combine(result, CleanTraits(value->m_traits));
|
||||
return result;
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
result_type result = AZStd::hash<Uuid>()(value->m_typeId);
|
||||
AZStd::hash_combine(result, CleanTraits(value->m_traits));
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,7 +52,11 @@ namespace BehaviorContextUtilitiesCPP
|
||||
{
|
||||
bool operator()(const BehaviorParameter* left, const BehaviorParameter* right) const
|
||||
{
|
||||
return left->m_typeId == right->m_typeId && CleanTraits(left->m_traits) == CleanTraits(right->m_traits);
|
||||
return (left == nullptr && right == nullptr)
|
||||
|| (left != nullptr
|
||||
&& right != nullptr
|
||||
&& left->m_typeId == right->m_typeId
|
||||
&& CleanTraits(left->m_traits) == CleanTraits(right->m_traits));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -137,7 +148,7 @@ namespace AZ
|
||||
for (size_t argIndex = 0, argSentinel = overload.GetNumArguments(); argIndex < argSentinel; ++argIndex)
|
||||
{
|
||||
auto overloadedArgIter = variance.m_input.find(argIndex);
|
||||
if (overloadedArgIter != variance.m_input.end())
|
||||
if (overloadedArgIter != variance.m_input.end() && overloadedArgIter->second[overloadIndex])
|
||||
{
|
||||
// if this doesn't work try the type name
|
||||
overloadName += ReplaceCppArtifacts(overloadedArgIter->second[overloadIndex]->m_name);
|
||||
@@ -185,16 +196,24 @@ namespace AZ
|
||||
{
|
||||
auto argument = overloads[overloadIndex].first->GetArgument(0);
|
||||
|
||||
const bool isThisPointer
|
||||
= (argument->m_traits & AZ::BehaviorParameter::Traits::TR_THIS_PTR) != 0
|
||||
|| AZ::FindAttribute(AZ::Script::Attributes::TreatAsMemberFunction, overloads[overloadIndex].first->m_attributes);
|
||||
if (argument)
|
||||
{
|
||||
const bool isThisPointer
|
||||
= (argument->m_traits & AZ::BehaviorParameter::Traits::TR_THIS_PTR) != 0
|
||||
|| AZ::FindAttribute(AZ::Script::Attributes::TreatAsMemberFunction, overloads[overloadIndex].first->m_attributes);
|
||||
|
||||
oneArgIsThisPointer = oneArgIsThisPointer || isThisPointer;
|
||||
oneArgIsThisPointer = oneArgIsThisPointer || isThisPointer;
|
||||
}
|
||||
|
||||
types.insert(argument);
|
||||
stripedArgs.emplace_back(argument);
|
||||
}
|
||||
|
||||
if (types.size() == overloads.size())
|
||||
{
|
||||
variance.m_unambiguousInput.insert(0);
|
||||
}
|
||||
|
||||
if (types.size() > 1 && (onThis == VariantOnThis::Yes || !oneArgIsThisPointer))
|
||||
{
|
||||
variance.m_input.insert(AZStd::make_pair(0, stripedArgs));
|
||||
@@ -210,11 +229,15 @@ namespace AZ
|
||||
for (size_t overloadIndex = 0, overloadSentinel = overloads.size(); overloadIndex < overloadSentinel; ++overloadIndex)
|
||||
{
|
||||
auto argument = overloads[overloadIndex].first->GetArgument(argIndex);
|
||||
|
||||
types.insert(argument);
|
||||
stripedArgs.emplace_back(argument);
|
||||
}
|
||||
|
||||
if (types.size() == overloads.size())
|
||||
{
|
||||
variance.m_unambiguousInput.insert(0);
|
||||
}
|
||||
|
||||
if (types.size() > 1)
|
||||
{
|
||||
variance.m_input.insert(AZStd::make_pair(argIndex, stripedArgs));
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace AZ
|
||||
struct OverloadVariance
|
||||
{
|
||||
AZStd::unordered_map<size_t, AZStd::vector<const BehaviorParameter*>> m_input;
|
||||
// the indices of inputs that make selection of overload unambiguous
|
||||
AZStd::unordered_set<size_t> m_unambiguousInput;
|
||||
AZStd::vector<const BehaviorParameter*> m_output;
|
||||
};
|
||||
|
||||
|
||||
@@ -2048,10 +2048,6 @@ LUA_API const Node* lua_getDummyNode()
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Warning("Script", false, "Index %d is not a function!", functionIndex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -2078,7 +2074,6 @@ LUA_API const Node* lua_getDummyNode()
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Warning("Script", lua_isnil(m_nativeContext, -1), "Name %s exists but is not a function!", functionName);
|
||||
lua_pop(m_nativeContext, 1);
|
||||
}
|
||||
|
||||
@@ -5888,7 +5883,6 @@ LUA_API const Node* lua_getDummyNode()
|
||||
else
|
||||
{
|
||||
lua_pop(m_impl->m_lua, 1);
|
||||
AZ_Warning("Script", false, "%s is not a function!", functionName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -5906,7 +5900,6 @@ LUA_API const Node* lua_getDummyNode()
|
||||
else
|
||||
{
|
||||
lua_pop(m_impl->m_lua, 1);
|
||||
AZ_Warning("Script", false, "CacheIndex %d is not a function!", cachedIndex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "AzCore/RTTI/TypeInfo.h"
|
||||
#include <AzCore/Math/UuidSerializer.h>
|
||||
#include <AzCore/RTTI/AttributeReader.h>
|
||||
#include <AzCore/Serialization/Json/CastingHelpers.h>
|
||||
@@ -61,6 +62,13 @@ namespace AZ
|
||||
|
||||
if (classData->m_azRtti && classData->m_azRtti->GetGenericTypeId() != typeId)
|
||||
{
|
||||
if (((classData->m_azRtti->GetTypeTraits() & (AZ::TypeTraits::is_signed | AZ::TypeTraits::is_unsigned)) != AZ::TypeTraits{0}) &&
|
||||
context.GetSerializeContext()->GetUnderlyingTypeId(typeId) == classData->m_typeId)
|
||||
{
|
||||
// This value is from an enum, where a field has been reflected using ClassBuilder::Field, but the enum
|
||||
// type itself has not been reflected using EnumBuilder. Treat it as an enum.
|
||||
return LoadEnum(object, *classData, value, context);
|
||||
}
|
||||
serializer = context.GetRegistrationContext()->GetSerializerForType(classData->m_azRtti->GetGenericTypeId());
|
||||
if (serializer)
|
||||
{
|
||||
@@ -77,21 +85,18 @@ namespace AZ
|
||||
{
|
||||
return LoadEnum(object, *classData, value, context);
|
||||
}
|
||||
else if (classData->m_container)
|
||||
if (classData->m_container)
|
||||
{
|
||||
return context.Report(Tasks::ReadField, Outcomes::Unsupported,
|
||||
"The Json Serializer uses custom serializers to load containers. If this message is encountered "
|
||||
"then a serializer for the target containers is missing, isn't registered or doesn't exist.");
|
||||
}
|
||||
else if (value.IsObject())
|
||||
if (value.IsObject())
|
||||
{
|
||||
return LoadClass(object, *classData, value, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
return context.Report(Tasks::ReadField, Outcomes::Unsupported,
|
||||
AZStd::string::format("Reading into targets of type '%s' is not supported.", classData->m_name));
|
||||
}
|
||||
return context.Report(Tasks::ReadField, Outcomes::Unsupported,
|
||||
AZStd::string::format("Reading into targets of type '%s' is not supported.", classData->m_name));
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonDeserializer::LoadToPointer(void* object, const Uuid& typeId,
|
||||
@@ -233,8 +238,16 @@ namespace AZ
|
||||
AZ::TypeId underlyingTypeId = AZ::TypeId::CreateNull();
|
||||
if (!attributeReader.Read<AZ::TypeId>(underlyingTypeId))
|
||||
{
|
||||
return context.Report(Tasks::RetrieveInfo, Outcomes::Unknown,
|
||||
"Unable to find underlying type of enum in class data.");
|
||||
// for non-reflected enums, the passed-in classData already represents the enum's underlying type
|
||||
if (context.GetSerializeContext()->GetUnderlyingTypeId(classData.m_typeId) == classData.m_typeId)
|
||||
{
|
||||
underlyingTypeId = classData.m_typeId;
|
||||
}
|
||||
else
|
||||
{
|
||||
return context.Report(Tasks::RetrieveInfo, Outcomes::Unknown,
|
||||
"Unable to find underlying type of enum in class data.");
|
||||
}
|
||||
}
|
||||
|
||||
const SerializeContext::ClassData* underlyingClassData = context.GetSerializeContext()->FindClassData(underlyingTypeId);
|
||||
|
||||
@@ -494,13 +494,6 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
return configFileParsed;
|
||||
}
|
||||
|
||||
void MergeSettingsToRegistry_Bootstrap(SettingsRegistryInterface& registry)
|
||||
{
|
||||
ConfigParserSettings parserSettings;
|
||||
parserSettings.m_registryRootPointerPath = BootstrapSettingsRootKey;
|
||||
MergeSettingsToRegistry_ConfigFile(registry, "bootstrap.cfg", parserSettings);
|
||||
}
|
||||
|
||||
void MergeSettingsToRegistry_AddRuntimeFilePaths(SettingsRegistryInterface& registry)
|
||||
{
|
||||
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
|
||||
|
||||
@@ -172,9 +172,6 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
bool MergeSettingsToRegistry_ConfigFile(SettingsRegistryInterface& registry, AZStd::string_view filePath,
|
||||
const ConfigParserSettings& configParserSettings);
|
||||
|
||||
//! Loads bootstrap.cfg into the Settings Registry. This file does not support specializations.
|
||||
void MergeSettingsToRegistry_Bootstrap(SettingsRegistryInterface& registry);
|
||||
|
||||
//! Extracts file path information from the environment and bootstrap to calculate the various file paths and adds those
|
||||
//! to the Settings Registry under the FilePathsRootKey.
|
||||
void MergeSettingsToRegistry_AddRuntimeFilePaths(SettingsRegistryInterface& registry);
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace UnitTest
|
||||
ErrorHandler::ErrorHandler(const char* errorPattern)
|
||||
: m_errorCount(0)
|
||||
, m_warningCount(0)
|
||||
, m_expectedErrorCount(0)
|
||||
, m_expectedWarningCount(0)
|
||||
, m_errorPattern(errorPattern)
|
||||
{
|
||||
AZ::Debug::TraceMessageBus::Handler::BusConnect();
|
||||
@@ -51,6 +53,16 @@ namespace UnitTest
|
||||
return m_warningCount;
|
||||
}
|
||||
|
||||
int ErrorHandler::GetExpectedErrorCount() const
|
||||
{
|
||||
return m_expectedErrorCount;
|
||||
}
|
||||
|
||||
int ErrorHandler::GetExpectedWarningCount() const
|
||||
{
|
||||
return m_expectedWarningCount;
|
||||
}
|
||||
|
||||
bool ErrorHandler::SuppressExpectedErrors([[maybe_unused]] const char* window, const char* message)
|
||||
{
|
||||
return AZStd::string(message).find(m_errorPattern) != AZStd::string::npos;
|
||||
@@ -61,7 +73,9 @@ namespace UnitTest
|
||||
[[maybe_unused]] const char* func, const char* message)
|
||||
{
|
||||
m_errorCount++;
|
||||
return SuppressExpectedErrors(window, message);
|
||||
bool suppress = SuppressExpectedErrors(window, message);
|
||||
m_expectedErrorCount += suppress;
|
||||
return suppress;
|
||||
}
|
||||
|
||||
bool ErrorHandler::OnPreWarning(
|
||||
@@ -69,7 +83,9 @@ namespace UnitTest
|
||||
[[maybe_unused]] const char* func, const char* message)
|
||||
{
|
||||
m_warningCount++;
|
||||
return SuppressExpectedErrors(window, message);
|
||||
bool suppress = SuppressExpectedErrors(window, message);
|
||||
m_expectedWarningCount += suppress;
|
||||
return suppress;
|
||||
}
|
||||
|
||||
bool ErrorHandler::OnPrintf(const char* window, const char* message)
|
||||
|
||||
@@ -30,8 +30,14 @@ namespace UnitTest
|
||||
public:
|
||||
explicit ErrorHandler(const char* errorPattern);
|
||||
~ErrorHandler();
|
||||
//! Returns the total number of errors encountered (including those which match the expected pattern).
|
||||
int GetErrorCount() const;
|
||||
//! Returns the total number of warnings encountered (including those which match the expected pattern).
|
||||
int GetWarningCount() const;
|
||||
//! Returns the number of errors encountered which matched the expected pattern.
|
||||
int GetExpectedErrorCount() const;
|
||||
//! Returns the number of warnings encountered which matched the expected pattern.
|
||||
int GetExpectedWarningCount() const;
|
||||
bool SuppressExpectedErrors(const char* window, const char* message);
|
||||
|
||||
// AZ::Debug::TraceMessageBus
|
||||
@@ -44,6 +50,8 @@ namespace UnitTest
|
||||
AZStd::string m_errorPattern;
|
||||
int m_errorCount;
|
||||
int m_warningCount;
|
||||
int m_expectedErrorCount;
|
||||
int m_expectedWarningCount;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace MathTestData
|
||||
};
|
||||
|
||||
static const AZ::Transform NonOrthogonalTransforms[] = {
|
||||
AZ::Transform::CreateScale(AZ::Vector3(2.4f, 0.3f, 1.7f)),
|
||||
AZ::Transform::CreateRotationX(2.2f) * AZ::Transform::CreateScale(AZ::Vector3(0.2f, 0.8f, 1.4f))
|
||||
AZ::Transform::CreateUniformScale(2.4f),
|
||||
AZ::Transform::CreateRotationX(2.2f) * AZ::Transform::CreateUniformScale(0.8f)
|
||||
};
|
||||
|
||||
static const AZ::Transform OrthogonalTransforms[] = {
|
||||
|
||||
@@ -59,11 +59,11 @@ namespace UnitTest
|
||||
TEST(MATH_Obb, TestScaleTransform)
|
||||
{
|
||||
Obb obb = Obb::CreateFromPositionRotationAndHalfLengths(position, rotation, halfLengths);
|
||||
Vector3 scaleFactors = Vector3(1.0f, 2.0f, 3.0f);
|
||||
Transform transform = Transform::CreateScale(scaleFactors);
|
||||
float scale = 3.0f;
|
||||
Transform transform = Transform::CreateUniformScale(scale);
|
||||
obb = transform * obb;
|
||||
EXPECT_THAT(obb.GetPosition(), IsClose(Vector3(1.0f, 4.0f, 9.0f)));
|
||||
EXPECT_THAT(obb.GetHalfLengths(), IsClose(Vector3(0.5f, 1.0f, 1.5f)));
|
||||
EXPECT_THAT(obb.GetPosition(), IsClose(Vector3(3.0f, 6.0f, 9.0f)));
|
||||
EXPECT_THAT(obb.GetHalfLengths(), IsClose(Vector3(1.5f, 1.5f, 1.5f)));
|
||||
}
|
||||
|
||||
TEST(MATH_Obb, TestSetPosition)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace UnitTest
|
||||
EXPECT_FLOAT_EQ(5981.0f / 15625.0f, GetHaltonNumber(4321, 5));
|
||||
}
|
||||
|
||||
TEST(MATH_Random, HaltonSequence)
|
||||
TEST(MATH_Random, HaltonSequenceStandard)
|
||||
{
|
||||
HaltonSequence<3> sequence({ 2, 3, 5 });
|
||||
auto regularSequence = sequence.GetHaltonSequence<5>();
|
||||
@@ -48,7 +48,11 @@ namespace UnitTest
|
||||
EXPECT_FLOAT_EQ(5.0f / 8.0f, regularSequence[4][0]);
|
||||
EXPECT_FLOAT_EQ(7.0f / 9.0f, regularSequence[4][1]);
|
||||
EXPECT_FLOAT_EQ(1.0f / 25.0f, regularSequence[4][2]);
|
||||
|
||||
}
|
||||
|
||||
TEST(MATH_Random, HaltonSequenceOffsets)
|
||||
{
|
||||
HaltonSequence<3> sequence({ 2, 3, 5 });
|
||||
sequence.SetOffsets({ 1, 2, 3 });
|
||||
auto offsetSequence = sequence.GetHaltonSequence<2>();
|
||||
|
||||
@@ -59,10 +63,15 @@ namespace UnitTest
|
||||
EXPECT_FLOAT_EQ(3.0f / 4.0f, offsetSequence[1][0]);
|
||||
EXPECT_FLOAT_EQ(4.0f / 9.0f, offsetSequence[1][1]);
|
||||
EXPECT_FLOAT_EQ(1.0f / 25.0f, offsetSequence[1][2]);
|
||||
|
||||
}
|
||||
|
||||
TEST(MATH_Random, HaltonSequenceIncrements)
|
||||
{
|
||||
HaltonSequence<3> sequence({ 2, 3, 5 });
|
||||
sequence.SetOffsets({ 1, 2, 3 });
|
||||
sequence.SetIncrements({ 1, 2, 3 });
|
||||
auto incrementedSequence = sequence.GetHaltonSequence<2>();
|
||||
|
||||
|
||||
EXPECT_FLOAT_EQ(1.0f / 4.0f, incrementedSequence[0][0]);
|
||||
EXPECT_FLOAT_EQ(1.0f / 9.0f, incrementedSequence[0][1]);
|
||||
EXPECT_FLOAT_EQ(4.0f / 5.0f, incrementedSequence[0][2]);
|
||||
@@ -71,4 +80,35 @@ namespace UnitTest
|
||||
EXPECT_FLOAT_EQ(7.0f / 9.0f, incrementedSequence[1][1]);
|
||||
EXPECT_FLOAT_EQ(11.0f / 25.0f, incrementedSequence[1][2]);
|
||||
}
|
||||
|
||||
TEST(MATH_Random, FillHaltonSequence)
|
||||
{
|
||||
HaltonSequence<3> sequence({ 2, 3, 5 });
|
||||
auto regularSequence = sequence.GetHaltonSequence<5>();
|
||||
|
||||
struct Point
|
||||
{
|
||||
Point() = default;
|
||||
Point(AZStd::array<float, 3> arr)
|
||||
:x(arr[0])
|
||||
,y(arr[1])
|
||||
,z(arr[2])
|
||||
{}
|
||||
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float z = 0.0f;
|
||||
};
|
||||
|
||||
AZStd::array<Point, 5> ownedContainer;
|
||||
sequence.FillHaltonSequence(ownedContainer.begin(), ownedContainer.end());
|
||||
|
||||
for (size_t i = 0; i < regularSequence.size(); ++i)
|
||||
{
|
||||
EXPECT_FLOAT_EQ(regularSequence[i][0], ownedContainer[i].x);
|
||||
EXPECT_FLOAT_EQ(regularSequence[i][1], ownedContainer[i].y);
|
||||
EXPECT_FLOAT_EQ(regularSequence[i][2], ownedContainer[i].z);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -180,13 +180,13 @@ namespace Benchmark
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_F(BM_MathTransform, CreateScale)(benchmark::State& state)
|
||||
BENCHMARK_F(BM_MathTransform, CreateUniformScale)(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state)
|
||||
{
|
||||
for (auto& testData : m_testDataArray)
|
||||
{
|
||||
AZ::Transform result = AZ::Transform::CreateScale(testData.v3);
|
||||
AZ::Transform result = AZ::Transform::CreateUniformScale(testData.value[0]);
|
||||
benchmark::DoNotOptimize(result);
|
||||
}
|
||||
}
|
||||
@@ -344,39 +344,39 @@ namespace Benchmark
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_F(BM_MathTransform, GetScale)(benchmark::State& state)
|
||||
BENCHMARK_F(BM_MathTransform, GetUniformScale)(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state)
|
||||
{
|
||||
for (auto& testData : m_testDataArray)
|
||||
{
|
||||
AZ::Vector3 result = testData.t1.GetScale();
|
||||
float result = testData.t1.GetUniformScale();
|
||||
benchmark::DoNotOptimize(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_F(BM_MathTransform, SetScale)(benchmark::State& state)
|
||||
BENCHMARK_F(BM_MathTransform, SetUniformScale)(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state)
|
||||
{
|
||||
for (auto& testData : m_testDataArray)
|
||||
{
|
||||
AZ::Transform testTransform = testData.t2;
|
||||
testTransform.SetScale(testData.v3);
|
||||
testTransform.SetUniformScale(testData.value[0]);
|
||||
benchmark::DoNotOptimize(testTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_F(BM_MathTransform, ExtractScale)(benchmark::State& state)
|
||||
BENCHMARK_F(BM_MathTransform, ExtractUniformScale)(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state)
|
||||
{
|
||||
for (auto& testData : m_testDataArray)
|
||||
{
|
||||
AZ::Transform testTransform = testData.t2;
|
||||
AZ::Vector3 result = testTransform.ExtractScale();
|
||||
float result = testTransform.ExtractUniformScale();
|
||||
benchmark::DoNotOptimize(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,37 +159,14 @@ namespace UnitTest
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MATH_Transform, TransformCreateFromQuaternionFixture, ::testing::ValuesIn(MathTestData::UnitQuaternions));
|
||||
|
||||
using TransformCreateFromMatrix3x3Fixture = ::testing::TestWithParam<AZ::Matrix3x3>;
|
||||
|
||||
TEST_P(TransformCreateFromMatrix3x3Fixture, CreateFromMatrix3x3)
|
||||
TEST(MATH_Transform, CreateUniformScale)
|
||||
{
|
||||
const AZ::Matrix3x3 matrix3x3 = GetParam();
|
||||
const AZ::Transform transform = AZ::Transform::CreateFromMatrix3x3(matrix3x3);
|
||||
EXPECT_THAT(transform.GetTranslation(), IsClose(AZ::Vector3::CreateZero()));
|
||||
const AZ::Vector3 vector(2.3f, -0.6, 1.8f);
|
||||
EXPECT_THAT(transform.TransformPoint(vector), IsClose(matrix3x3 * vector));
|
||||
}
|
||||
|
||||
TEST_P(TransformCreateFromMatrix3x3Fixture, CreateFromMatrix3x3AndTranslation)
|
||||
{
|
||||
const AZ::Matrix3x3 matrix3x3 = GetParam();
|
||||
const AZ::Vector3 translation(-2.6f, 1.7f, 0.8f);
|
||||
const AZ::Transform transform = AZ::Transform::CreateFromMatrix3x3AndTranslation(matrix3x3, translation);
|
||||
EXPECT_THAT(transform.GetTranslation(), IsClose(translation));
|
||||
const AZ::Vector3 vector(2.3f, -0.6, 1.8f);
|
||||
EXPECT_THAT(transform.TransformPoint(vector), IsClose(matrix3x3 * vector + translation));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MATH_Transform, TransformCreateFromMatrix3x3Fixture, ::testing::ValuesIn(MathTestData::Matrix3x3s));
|
||||
|
||||
TEST(MATH_Transform, CreateScale)
|
||||
{
|
||||
const AZ::Vector3 scale(1.7f, 0.3f, 2.4f);
|
||||
const AZ::Transform transform = AZ::Transform::CreateScale(scale);
|
||||
const float scale = 1.7f;
|
||||
const AZ::Transform transform = AZ::Transform::CreateUniformScale(scale);
|
||||
const AZ::Vector3 vector(0.2f, -1.6f, 0.4f);
|
||||
EXPECT_THAT(transform.GetTranslation(), IsClose(AZ::Vector3::CreateZero()));
|
||||
const AZ::Vector3 transformedVector = transform.TransformPoint(vector);
|
||||
const AZ::Vector3 expected(0.34f, -0.48f, 0.96f);
|
||||
const AZ::Vector3 expected(0.34f, -2.72f, 0.68f);
|
||||
EXPECT_THAT(transformedVector, IsClose(expected));
|
||||
}
|
||||
|
||||
@@ -237,10 +214,10 @@ namespace UnitTest
|
||||
TEST(MATH_Transform, MultiplyByTransform)
|
||||
{
|
||||
const AZ::Transform transform1 = AZ::Transform::CreateRotationY(0.3f);
|
||||
const AZ::Transform transform2 = AZ::Transform::CreateScale(AZ::Vector3(1.3f, 1.5f, 0.4f));
|
||||
const AZ::Transform transform2 = AZ::Transform::CreateUniformScale(1.3f);
|
||||
const AZ::Transform transform3 = AZ::Transform::CreateFromQuaternionAndTranslation(
|
||||
AZ::Quaternion(0.42f, 0.46f, -0.66f, 0.42f), AZ::Vector3(2.8f, -3.7f, 1.6f));
|
||||
const AZ::Transform transform4 = AZ::Transform::CreateRotationX(-0.7f) * AZ::Transform::CreateScale(AZ::Vector3(0.6f, 1.3f, 0.7f));
|
||||
const AZ::Transform transform4 = AZ::Transform::CreateRotationX(-0.7f) * AZ::Transform::CreateUniformScale(0.6f);
|
||||
AZ::Transform transform5 = transform1;
|
||||
transform5 *= transform4;
|
||||
const AZ::Vector3 vector(1.9f, 2.3f, 0.2f);
|
||||
@@ -254,14 +231,14 @@ namespace UnitTest
|
||||
TEST(MATH_Transform, TranslationCorrectInTransformHierarchy)
|
||||
{
|
||||
AZ::Transform parent = AZ::Transform::CreateRotationZ(AZ::DegToRad(45.0f));
|
||||
parent.SetScale(AZ::Vector3(3.0f, 2.0f, 1.0f));
|
||||
parent.SetUniformScale(3.0f);
|
||||
parent.SetTranslation(AZ::Vector3(0.2f, 0.3f, 0.4f));
|
||||
AZ::Transform child = AZ::Transform::CreateRotationZ(AZ::DegToRad(90.0f));
|
||||
child.SetTranslation(AZ::Vector3(0.5f, 0.6f, 0.7f));
|
||||
const AZ::Transform overallTransform = parent * child;
|
||||
const AZ::Vector3 overallTranslation = overallTransform.GetTranslation();
|
||||
const AZ::Vector3 expectedTranslation(0.412132f, 2.20919f, 1.1f);
|
||||
EXPECT_THAT(overallTranslation, IsClose(AZ::Vector3(0.412132f, 2.20919f, 1.1f)));
|
||||
const AZ::Vector3 expectedTranslation(-0.012132f, 2.633452f, 2.5f);
|
||||
EXPECT_THAT(overallTranslation, IsClose(expectedTranslation));
|
||||
}
|
||||
|
||||
TEST(MATH_Transform, TransformPointVector3)
|
||||
@@ -337,14 +314,14 @@ namespace UnitTest
|
||||
TEST_P(TransformScaleFixture, Scale)
|
||||
{
|
||||
const AZ::Transform orthogonalTransform = GetParam();
|
||||
EXPECT_THAT(orthogonalTransform.GetScale(), IsClose(AZ::Vector3::CreateOne()));
|
||||
EXPECT_NEAR(orthogonalTransform.GetUniformScale(), 1.0f, AZ::Constants::Tolerance);
|
||||
AZ::Transform unscaledTransform = orthogonalTransform;
|
||||
unscaledTransform.ExtractScale();
|
||||
EXPECT_THAT(unscaledTransform.GetScale(), IsClose(AZ::Vector3::CreateOne()));
|
||||
const AZ::Vector3 scale(2.8f, 0.7f, 1.3f);
|
||||
unscaledTransform.ExtractUniformScale();
|
||||
EXPECT_NEAR(unscaledTransform.GetUniformScale(), 1.0f, AZ::Constants::Tolerance);
|
||||
const float scale = 2.8f;
|
||||
AZ::Transform scaledTransform = orthogonalTransform;
|
||||
scaledTransform.MultiplyByScale(scale);
|
||||
EXPECT_THAT(scaledTransform.GetScale(), IsClose(scale));
|
||||
scaledTransform.MultiplyByUniformScale(scale);
|
||||
EXPECT_NEAR(scaledTransform.GetUniformScale(), scale, AZ::Constants::Tolerance);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MATH_Transform, TransformScaleFixture, ::testing::ValuesIn(MathTestData::OrthogonalTransforms));
|
||||
@@ -353,24 +330,11 @@ namespace UnitTest
|
||||
{
|
||||
EXPECT_TRUE(AZ::Transform::CreateIdentity().IsOrthogonal());
|
||||
EXPECT_TRUE(AZ::Transform::CreateRotationZ(0.3f).IsOrthogonal());
|
||||
EXPECT_FALSE(AZ::Transform::CreateScale(AZ::Vector3(0.8f, 0.3f, 1.2f)).IsOrthogonal());
|
||||
EXPECT_FALSE(AZ::Transform::CreateUniformScale(0.8f).IsOrthogonal());
|
||||
EXPECT_TRUE(AZ::Transform::CreateFromQuaternion(AZ::Quaternion(-0.52f, -0.08f, 0.56f, 0.64f)).IsOrthogonal());
|
||||
AZ::Transform transform;
|
||||
transform.SetFromEulerRadians(AZ::Vector3(0.2f, 0.4f, 0.1f));
|
||||
EXPECT_TRUE(transform.IsOrthogonal());
|
||||
|
||||
// want to test each possible way the transform could fail to be orthogonal, which we can do by testing for one
|
||||
// axis, then using a rotation which cycles the axes
|
||||
const AZ::Transform axisCycle = AZ::Transform::CreateFromQuaternion(AZ::Quaternion(0.5f, 0.5f, 0.5f, 0.5f));
|
||||
|
||||
// a transform which is normalized in 2 axes, but not the third
|
||||
AZ::Transform nonOrthogonalTransform1 = AZ::Transform::CreateScale(AZ::Vector3(1.0f, 1.0f, 2.0f));
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
EXPECT_FALSE(nonOrthogonalTransform1.IsOrthogonal());
|
||||
nonOrthogonalTransform1 = axisCycle * nonOrthogonalTransform1;
|
||||
}
|
||||
}
|
||||
|
||||
using TransformSetFromEulerDegreesFixture = ::testing::TestWithParam<AZ::Vector3>;
|
||||
@@ -459,16 +423,17 @@ namespace UnitTest
|
||||
{
|
||||
const char* objectStreamBuffer =
|
||||
R"DELIMITER(<ObjectStream version="3">
|
||||
<Class name="Transform" field="m_data" value="0.79429845 0.8545947 -0.94273965 -0.05367075 0.3899708 0.30828915 1.0097652 -0.31084164 0.56899188 513.7845459 492.5420837 32.0000000" type="{5D9958E9-9F1E-4985-B532-FFFDE75FEDFD}"/>
|
||||
<Class name="Transform" field="m_data" value="0.79429845 0.8545947 -0.94273965 -0.1610121 1.1699124 0.92486745 1.2622065 -0.3885522 0.71123985 513.7845459 492.5420837 32.0000000" type="{5D9958E9-9F1E-4985-B532-FFFDE75FEDFD}"/>
|
||||
</ObjectStream>)DELIMITER";
|
||||
|
||||
AZ::Transform* deserializedTransform = AZ::Utils::LoadObjectFromBuffer<AZ::Transform>(objectStreamBuffer, strlen(objectStreamBuffer) + 1);
|
||||
|
||||
const AZ::Vector3 expectedTranslation(513.7845459f, 492.5420837f, 32.0000000f);
|
||||
const AZ::Vector3 expectedScale(1.5f, 0.5f, 1.2f);
|
||||
const float expectedScale = 1.5f;
|
||||
const AZ::Quaternion expectedRotation(0.2624075f, 0.4405251f, 0.2029076f, 0.8342113f);
|
||||
const AZ::Transform expectedTransform =
|
||||
AZ::Transform::CreateFromQuaternionAndTranslation(expectedRotation, expectedTranslation) * AZ::Transform::CreateScale(expectedScale);
|
||||
AZ::Transform::CreateFromQuaternionAndTranslation(expectedRotation, expectedTranslation) *
|
||||
AZ::Transform::CreateUniformScale(expectedScale);
|
||||
|
||||
EXPECT_TRUE(deserializedTransform->IsClose(expectedTransform));
|
||||
azfree(deserializedTransform);
|
||||
|
||||
@@ -1275,10 +1275,10 @@ namespace UnitTest
|
||||
script->Execute("AZTestAssert(t1:TransformVector(Vector3(1, 0, 0)):IsClose(Vector3(1, 0, 0)))");
|
||||
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 1, 0)):IsClose(Vector3(0, 0.866, 0.5)))");
|
||||
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 0, 1)):IsClose(Vector3(0, -0.5, 0.866)))");
|
||||
script->Execute("t1 = Transform.CreateScale(Vector3(1, 2, 3))");
|
||||
script->Execute("AZTestAssert(t1:TransformVector(Vector3(1, 0, 0)):IsClose(Vector3(1, 0, 0)))");
|
||||
script->Execute("t1 = Transform.CreateUniformScale(2)");
|
||||
script->Execute("AZTestAssert(t1:TransformVector(Vector3(1, 0, 0)):IsClose(Vector3(2, 0, 0)))");
|
||||
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 1, 0)):IsClose(Vector3(0, 2, 0)))");
|
||||
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 0, 1)):IsClose(Vector3(0, 0, 3)))");
|
||||
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 0, 1)):IsClose(Vector3(0, 0, 2)))");
|
||||
script->Execute("t1 = Transform.CreateTranslation(Vector3(1, 2, 3))");
|
||||
script->Execute("AZTestAssert(t1:TransformVector(Vector3(1, 0, 0)):IsClose(Vector3(1, 0, 0)))");
|
||||
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 1, 0)):IsClose(Vector3(0, 1, 0)))");
|
||||
@@ -1341,19 +1341,19 @@ namespace UnitTest
|
||||
script->Execute("AZTestAssert(t3:GetTranslation():IsClose(Vector3(-5.90, 25.415, 19.645), 0.001))");
|
||||
|
||||
////test inverse, should handle non-orthogonal matrices
|
||||
script->Execute("t1 = Transform.CreateRotationX(1) * Transform.CreateScale(Vector3(1, 2, 3))");
|
||||
script->Execute("t1 = Transform.CreateRotationX(1) * Transform.CreateUniformScale(2)");
|
||||
script->Execute("AZTestAssert((t1*t1:GetInverse()):IsClose(Transform.CreateIdentity()))");
|
||||
|
||||
////scale access
|
||||
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(40)) * Transform.CreateScale(Vector3(2, 3, 4))");
|
||||
script->Execute("AZTestAssert(t1:GetScale():IsClose(Vector3(2, 3, 4)))");
|
||||
script->Execute("AZTestAssert(t1:ExtractScale():IsClose(Vector3(2, 3, 4)))");
|
||||
script->Execute("AZTestAssert(t1:GetScale():IsClose(Vector3.CreateOne()))");
|
||||
script->Execute("t1:MultiplyByScale(Vector3(3, 4, 5))");
|
||||
script->Execute("AZTestAssert(t1:GetScale():IsClose(Vector3(3, 4, 5)))");
|
||||
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(40)) * Transform.CreateUniformScale(3)");
|
||||
script->Execute("AZTestAssertFloatClose(t1:GetUniformScale(), 3)");
|
||||
script->Execute("AZTestAssertFloatClose(t1:ExtractUniformScale(), 3)");
|
||||
script->Execute("AZTestAssertFloatClose(t1:GetUniformScale(), 1)");
|
||||
script->Execute("t1:MultiplyByUniformScale(2)");
|
||||
script->Execute("AZTestAssertFloatClose(t1:GetUniformScale(), 2)");
|
||||
|
||||
////orthogonalize
|
||||
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(30)) * Transform.CreateScale(Vector3(2, 3, 4))");
|
||||
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(30)) * Transform.CreateUniformScale(3)");
|
||||
script->Execute("t1:SetTranslation(Vector3(1,2,3))");
|
||||
script->Execute("t2 = t1:GetOrthogonalized()");
|
||||
script->Execute("AZTestAssertFloatClose(t2:GetBasisX():GetLength(), 1)");
|
||||
@@ -1372,7 +1372,7 @@ namespace UnitTest
|
||||
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(30))");
|
||||
script->Execute("t1:SetTranslation(Vector3(1, 2, 3))");
|
||||
script->Execute("AZTestAssert(t1:IsOrthogonal(0.05))");
|
||||
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(30)) * Transform.CreateScale(Vector3(2, 3, 4))");
|
||||
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(30)) * Transform.CreateUniformScale(2)");
|
||||
script->Execute("AZTestAssert( not t1:IsOrthogonal(0.05))");
|
||||
|
||||
////IsClose
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace JsonSerializationTests
|
||||
{
|
||||
using JsonSerializationTestCases = ::testing::Types<
|
||||
// Structures
|
||||
SimpleClass, SimpleInheritence, MultipleInheritence, SimpleNested, SimpleEnumWrapper,
|
||||
SimpleClass, SimpleInheritence, MultipleInheritence, SimpleNested, SimpleEnumWrapper, NonReflectedEnumWrapper,
|
||||
// Pointers
|
||||
SimpleNullPointer, SimpleAssignedPointer, ComplexAssignedPointer, ComplexNullInheritedPointer,
|
||||
ComplexAssignedDifferentInheritedPointer, ComplexAssignedSameInheritedPointer,
|
||||
|
||||
@@ -373,6 +373,57 @@ namespace JsonSerializationTests
|
||||
return MakeInstanceWithoutDefaults(AZStd::move(instance), json);
|
||||
}
|
||||
|
||||
// NonReflectedEnumWrapper
|
||||
bool NonReflectedEnumWrapper::Equals(const NonReflectedEnumWrapper& rhs, bool fullReflection) const
|
||||
{
|
||||
return !fullReflection || (m_enumClass == rhs.m_enumClass && m_rawEnum== rhs.m_rawEnum);
|
||||
}
|
||||
|
||||
void NonReflectedEnumWrapper::Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context, bool fullReflection)
|
||||
{
|
||||
if (fullReflection)
|
||||
{
|
||||
// Note that the enums are not reflected using context->Enum<>
|
||||
|
||||
context->Class<NonReflectedEnumWrapper>()
|
||||
->Field("enumClass", &NonReflectedEnumWrapper::m_enumClass)
|
||||
->Field("rawEnum", &NonReflectedEnumWrapper::m_rawEnum);
|
||||
}
|
||||
}
|
||||
|
||||
InstanceWithSomeDefaults<NonReflectedEnumWrapper> NonReflectedEnumWrapper::GetInstanceWithSomeDefaults()
|
||||
{
|
||||
auto instance = AZStd::make_unique<NonReflectedEnumWrapper>();
|
||||
instance->m_enumClass = NonReflectedEnumWrapper::SimpleEnumClass::Option2;
|
||||
|
||||
const char* strippedDefaults = R"(
|
||||
{
|
||||
"enumClass": 2
|
||||
})";
|
||||
const char* keptDefaults = R"(
|
||||
{
|
||||
"enumClass": 2,
|
||||
"rawEnum": 0
|
||||
})";
|
||||
|
||||
return MakeInstanceWithSomeDefaults(AZStd::move(instance),
|
||||
strippedDefaults, keptDefaults);
|
||||
}
|
||||
|
||||
InstanceWithoutDefaults<NonReflectedEnumWrapper> NonReflectedEnumWrapper::GetInstanceWithoutDefaults()
|
||||
{
|
||||
auto instance = AZStd::make_unique<NonReflectedEnumWrapper>();
|
||||
instance->m_enumClass = NonReflectedEnumWrapper::SimpleEnumClass::Option2;
|
||||
instance->m_rawEnum = NonReflectedEnumWrapper::SimpleRawEnum::RawOption1;
|
||||
|
||||
const char* json = R"(
|
||||
{
|
||||
"enumClass": 2,
|
||||
"rawEnum": 1
|
||||
})";
|
||||
return MakeInstanceWithoutDefaults(AZStd::move(instance), json);
|
||||
}
|
||||
|
||||
// TemplatedClass<int>
|
||||
|
||||
bool TemplatedClass<int>::Equals(const TemplatedClass<int>& rhs, bool fullReflection) const
|
||||
|
||||
@@ -134,6 +134,35 @@ namespace JsonSerializationTests
|
||||
SimpleRawEnum m_rawEnum{};
|
||||
};
|
||||
|
||||
struct NonReflectedEnumWrapper
|
||||
{
|
||||
enum class SimpleEnumClass
|
||||
{
|
||||
Option1 = 1,
|
||||
Option2,
|
||||
};
|
||||
enum SimpleRawEnum
|
||||
{
|
||||
RawOption1 = 1,
|
||||
RawOption2,
|
||||
};
|
||||
AZ_CLASS_ALLOCATOR(NonReflectedEnumWrapper, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(NonReflectedEnumWrapper, "{A80D5B6B-2FD1-46E9-A7A9-44C5E2650526}");
|
||||
|
||||
static constexpr bool SupportsPartialDefaults = true;
|
||||
|
||||
NonReflectedEnumWrapper() = default;
|
||||
virtual ~NonReflectedEnumWrapper() = default;
|
||||
|
||||
bool Equals(const NonReflectedEnumWrapper& rhs, bool fullReflection) const;
|
||||
static void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context, bool fullReflection);
|
||||
static InstanceWithSomeDefaults<NonReflectedEnumWrapper> GetInstanceWithSomeDefaults();
|
||||
static InstanceWithoutDefaults<NonReflectedEnumWrapper> GetInstanceWithoutDefaults();
|
||||
|
||||
SimpleEnumClass m_enumClass{};
|
||||
SimpleRawEnum m_rawEnum{};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct TemplatedClass
|
||||
{
|
||||
@@ -158,5 +187,7 @@ namespace AZ
|
||||
{
|
||||
AZ_TYPE_INFO_SPECIALIZE(JsonSerializationTests::SimpleEnumWrapper::SimpleEnumClass, "{AF6F1964-5B20-4689-BF23-F36B9C9AAE6A}");
|
||||
AZ_TYPE_INFO_SPECIALIZE(JsonSerializationTests::SimpleEnumWrapper::SimpleRawEnum, "{EB24207F-B48F-4D8B-940D-3CD06A371739}");
|
||||
AZ_TYPE_INFO_SPECIALIZE(JsonSerializationTests::NonReflectedEnumWrapper::SimpleEnumClass, "{E80E4A41-B29E-4B7C-B630-3B599172C837}");
|
||||
AZ_TYPE_INFO_SPECIALIZE(JsonSerializationTests::NonReflectedEnumWrapper::SimpleRawEnum, "{C42AF28D-4F84-4540-972A-5B6EEFAB13FF}");
|
||||
AZ_TYPE_INFO_TEMPLATE(JsonSerializationTests::TemplatedClass, "{CA4ADF74-66E7-4D16-B4AC-F71278C60EC7}", AZ_TYPE_INFO_TYPENAME);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace JsonSerializationTests
|
||||
AZ::Transform testTransform = AZ::Transform::CreateIdentity();
|
||||
AZ::Transform expectedTransform =
|
||||
AZ::Transform::CreateFromQuaternion(AZ::Quaternion(0.25f, 0.5f, 0.75f, 1.0f));
|
||||
expectedTransform.SetScale(AZ::Vector3(5.5f));
|
||||
expectedTransform.SetUniformScale(5.5f);
|
||||
|
||||
rapidjson::Document json;
|
||||
json.Parse(R"({ "Rotation": [ 0.25, 0.5, 0.75, 1.0 ], "Scale": 5.5 })");
|
||||
@@ -128,7 +128,7 @@ namespace JsonSerializationTests
|
||||
{
|
||||
AZ::Transform testTransform = AZ::Transform::CreateIdentity();
|
||||
AZ::Transform expectedTransform = AZ::Transform::CreateTranslation(AZ::Vector3(2.25f, 3.5f, 4.75f));
|
||||
expectedTransform.SetScale(AZ::Vector3(5.5f));
|
||||
expectedTransform.SetUniformScale(5.5f);
|
||||
|
||||
rapidjson::Document json;
|
||||
json.Parse(R"({ "Translation": [ 2.25, 3.5, 4.75 ], "Scale": 5.5 })");
|
||||
@@ -189,7 +189,7 @@ namespace JsonSerializationTests
|
||||
TEST_F(JsonTransformSerializerTests, Load_FullySetTransform_ReturnsSuccessWithOnlyScale)
|
||||
{
|
||||
AZ::Transform testTransform = AZ::Transform::CreateIdentity();
|
||||
AZ::Transform expectedTransform = AZ::Transform::CreateScale(AZ::Vector3(5.5f));
|
||||
AZ::Transform expectedTransform = AZ::Transform::CreateUniformScale(5.5f);
|
||||
|
||||
rapidjson::Document json;
|
||||
json.Parse(R"({ "Scale" : 5.5 })");
|
||||
|
||||
Reference in New Issue
Block a user