Merge remote-tracking branch 'origin' into MultiplayerComponents
This commit is contained in:
@@ -36,8 +36,8 @@ namespace LegacyLevelSystem
|
||||
//------------------------------------------------------------------------
|
||||
static void LoadLevel(const AZ::ConsoleCommandContainer& arguments)
|
||||
{
|
||||
AZ_Error("SpawnableLevelSystem", arguments.empty(), "LoadLevel requires a level file name to be provided.");
|
||||
AZ_Error("SpawnableLevelSystem", arguments.size() > 1, "LoadLevel requires a single level file name to be provided.");
|
||||
AZ_Error("SpawnableLevelSystem", !arguments.empty(), "LoadLevel requires a level file name to be provided.");
|
||||
AZ_Error("SpawnableLevelSystem", arguments.size() == 1, "LoadLevel requires a single level file name to be provided.");
|
||||
|
||||
if (!arguments.empty() && gEnv->pSystem && gEnv->pSystem->GetILevelSystem() && !gEnv->IsEditor())
|
||||
{
|
||||
|
||||
@@ -864,11 +864,6 @@ bool CSystem::InitShine([[maybe_unused]] const SSystemInitParams& initParams)
|
||||
|
||||
EBUS_EVENT(UiSystemBus, InitializeSystem);
|
||||
|
||||
if (!m_env.pLyShine)
|
||||
{
|
||||
AZ_Error(AZ_TRACE_SYSTEM_WINDOW, false, "LYShine System did not initialize correctly. Please check that the LyShine gem is enabled for this project in *_dependencies.cmake.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2022,8 +2017,8 @@ void CSystem::CreateSystemVars()
|
||||
REGISTER_CVAR2("sys_streaming_in_blocks", &g_cvars.sys_streaming_in_blocks, 1, VF_NULL,
|
||||
"Streaming of large files happens in blocks");
|
||||
|
||||
#if (defined(WIN32) || defined(WIN64)) && !defined(_RELEASE)
|
||||
REGISTER_CVAR2("sys_float_exceptions", &g_cvars.sys_float_exceptions, 3, 0, "Use or not use floating point exceptions.");
|
||||
#if (defined(WIN32) || defined(WIN64)) && defined(_DEBUG)
|
||||
REGISTER_CVAR2("sys_float_exceptions", &g_cvars.sys_float_exceptions, 2, 0, "Use or not use floating point exceptions.");
|
||||
#else // Float exceptions by default disabled for console builds.
|
||||
REGISTER_CVAR2("sys_float_exceptions", &g_cvars.sys_float_exceptions, 0, 0, "Use or not use floating point exceptions.");
|
||||
#endif
|
||||
|
||||
@@ -77,6 +77,27 @@
|
||||
#endif // defined(AZ_ENABLE_DEBUG_TOOLS)
|
||||
|
||||
#include <AzCore/Module/Environment.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
static void PrintEntityName(const AZ::ConsoleCommandContainer& arguments)
|
||||
{
|
||||
if (arguments.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto entityIdStr = AZStd::string(arguments.front());
|
||||
const auto entityIdValue = AZStd::stoull(entityIdStr);
|
||||
|
||||
AZStd::string entityName;
|
||||
AZ::ComponentApplicationBus::BroadcastResult(
|
||||
entityName, &AZ::ComponentApplicationBus::Events::GetEntityName, AZ::EntityId(entityIdValue));
|
||||
|
||||
AZ_Printf("Entity Debug", "EntityId: %" PRIu64 ", Entity Name: %s", entityIdValue, entityName.c_str());
|
||||
}
|
||||
|
||||
AZ_CONSOLEFREEFUNC(
|
||||
PrintEntityName, AZ::ConsoleFunctorFlags::Null, "Parameter: EntityId value, Prints the name of the entity to the console");
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -1260,7 +1281,7 @@ namespace AZ
|
||||
// So auto load is turned off if option "AutoLoad" key is bool that is false
|
||||
if (valueName == "AutoLoad" && !value)
|
||||
{
|
||||
// Strip off the AutoLoead entry from the path
|
||||
// Strip off the AutoLoad entry from the path
|
||||
auto autoLoadKey = AZ::StringFunc::TokenizeLast(path, "/");
|
||||
if (!autoLoadKey)
|
||||
{
|
||||
@@ -1330,7 +1351,7 @@ namespace AZ
|
||||
{
|
||||
auto CompareDynamicModuleDescriptor = [&dynamicLibraryPath](const DynamicModuleDescriptor& entry)
|
||||
{
|
||||
return entry.m_dynamicLibraryPath.contains(dynamicLibraryPath);
|
||||
return AZ::IO::PathView(entry.m_dynamicLibraryPath).Stem() == AZ::IO::PathView(dynamicLibraryPath).Stem();
|
||||
};
|
||||
if (auto moduleIter = AZStd::find_if(gemModules.begin(), gemModules.end(), CompareDynamicModuleDescriptor);
|
||||
moduleIter == gemModules.end())
|
||||
|
||||
@@ -219,18 +219,11 @@ namespace AZ
|
||||
|
||||
//! Scale modifiers
|
||||
//! @{
|
||||
//! Set local scale of the transform.
|
||||
//! @param scale The new scale to set.
|
||||
virtual void SetLocalScale([[maybe_unused]] const AZ::Vector3& scale) {}
|
||||
|
||||
//! Get the scale value in local space.
|
||||
//! @deprecated GetLocalScale is deprecated, and is left only to allow migration of legacy vector scale.
|
||||
//! Get the legacy vector 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 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) {}
|
||||
|
||||
|
||||
@@ -95,6 +95,12 @@ namespace AZ::IO
|
||||
constexpr int Compare(AZStd::string_view pathString) const noexcept;
|
||||
constexpr int Compare(const value_type* pathString) const noexcept;
|
||||
|
||||
// Extension for fixed strings
|
||||
//! extension: fixed string types with MaxPathLength capacity
|
||||
//! Returns a new instance of an AZStd::fixed_string with capacity of MaxPathLength
|
||||
//! made from the internal string
|
||||
constexpr AZStd::fixed_string<MaxPathLength> FixedMaxPathString() const noexcept;
|
||||
|
||||
// decomposition
|
||||
//! Given a windows path of "C:\O3DE\foo\bar\name.txt" and a posix path of
|
||||
//! "/O3DE/foo/bar/name.txt"
|
||||
|
||||
@@ -915,6 +915,11 @@ namespace AZ::IO
|
||||
return compare_string_view(path);
|
||||
}
|
||||
|
||||
constexpr AZStd::fixed_string<MaxPathLength> PathView::FixedMaxPathString() const noexcept
|
||||
{
|
||||
return AZStd::fixed_string<MaxPathLength>(m_path.begin(), m_path.end());
|
||||
}
|
||||
|
||||
// decomposition
|
||||
constexpr auto PathView::RootName() const -> PathView
|
||||
{
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace AZ
|
||||
// the min and max of each part and sum them to get the min and max co-ordinate of the transformed box. For a given new axis,
|
||||
// the coefficients for what proportion of each original axis is rotated onto that new axis are the same as the components we
|
||||
// would get by performing the inverse rotation on the new axis, so we need to take the conjugate to get the inverse rotation.
|
||||
axisCoeffs = transform.GetScale() * (transform.GetRotation().GetConjugate().TransformVector(axis));
|
||||
axisCoeffs = transform.GetUniformScale() * (transform.GetRotation().GetConjugate().TransformVector(axis));
|
||||
a = axisCoeffs * m_min;
|
||||
b = axisCoeffs * m_max;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace AZ
|
||||
return Obb::CreateFromPositionRotationAndHalfLengths(
|
||||
transform.TransformPoint(obb.GetPosition()),
|
||||
transform.GetRotation() * obb.GetRotation(),
|
||||
transform.GetScale() * obb.GetHalfLengths()
|
||||
transform.GetUniformScale() * obb.GetHalfLengths()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,8 +130,8 @@ namespace AZ
|
||||
const Transform* transform = reinterpret_cast<const Transform*>(classPtr);
|
||||
float data[NumFloats];
|
||||
transform->GetRotation().StoreToFloat4(data);
|
||||
transform->GetScale().StoreToFloat3(&data[4]);
|
||||
transform->GetTranslation().StoreToFloat3(&data[7]);
|
||||
data[4] = transform->GetUniformScale();
|
||||
transform->GetTranslation().StoreToFloat3(&data[5]);
|
||||
|
||||
for (int i = 0; i < NumFloats; i++)
|
||||
{
|
||||
@@ -159,8 +159,8 @@ namespace AZ
|
||||
|
||||
size_t TransformSerializer::TextToData(const char* text, unsigned int textVersion, IO::GenericStream& stream, bool isDataBigEndian)
|
||||
{
|
||||
const size_t dataBufferSize = AZStd::max(NumFloatsVersion0, NumFloats);
|
||||
const size_t numElements = textVersion < 1 ? NumFloatsVersion0 : NumFloats;
|
||||
const size_t dataBufferSize = AZStd::max(AZStd::max(NumFloatsVersion1, NumFloatsVersion0), NumFloats);
|
||||
const size_t numElements = textVersion < 1 ? NumFloatsVersion0 : (textVersion == 1 ? NumFloatsVersion1 : NumFloats);
|
||||
|
||||
size_t nextNumberIndex = 0;
|
||||
AZStd::array<float, dataBufferSize> data;
|
||||
@@ -201,7 +201,34 @@ namespace AZ
|
||||
return true;
|
||||
}
|
||||
|
||||
// otherwise load as a separate rotation, scale and translation
|
||||
// version 1 had a quaternion rotation, vector3 scale and vector3 translation
|
||||
else if (version == 1)
|
||||
{
|
||||
float data[NumFloatsVersion1];
|
||||
if (stream.GetLength() < sizeof(data))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stream.Read(sizeof(data), reinterpret_cast<void*>(data));
|
||||
|
||||
for (unsigned int i = 0; i < AZ_ARRAY_SIZE(data); ++i)
|
||||
{
|
||||
AZ_SERIALIZE_SWAP_ENDIAN(data[i], isDataBigEndian);
|
||||
}
|
||||
|
||||
Quaternion rotation = Quaternion::CreateFromFloat4(data);
|
||||
Vector3 vectorScale = Vector3::CreateFromFloat3(&data[4]);
|
||||
Vector3 translation = Vector3::CreateFromFloat3(&data[7]);
|
||||
|
||||
float uniformScale = vectorScale.GetMaxElement();
|
||||
|
||||
*reinterpret_cast<Transform*>(classPtr) =
|
||||
Transform::CreateFromQuaternionAndTranslation(rotation, translation) * Transform::CreateUniformScale(uniformScale);
|
||||
return true;
|
||||
}
|
||||
|
||||
// otherwise load as a quaternion rotation, float scale and vector3 translation
|
||||
float data[NumFloats];
|
||||
if (stream.GetLength() < sizeof(data))
|
||||
{
|
||||
@@ -216,11 +243,11 @@ namespace AZ
|
||||
}
|
||||
|
||||
Quaternion rotation = Quaternion::CreateFromFloat4(data);
|
||||
Vector3 scale = Vector3::CreateFromFloat3(&data[4]);
|
||||
Vector3 translation = Vector3::CreateFromFloat3(&data[7]);
|
||||
float scale = data[4];
|
||||
Vector3 translation = Vector3::CreateFromFloat3(&data[5]);
|
||||
|
||||
*reinterpret_cast<Transform*>(classPtr) =
|
||||
Transform::CreateFromQuaternionAndTranslation(rotation, translation) * Transform::CreateScale(scale);
|
||||
Transform::CreateFromQuaternionAndTranslation(rotation, translation) * Transform::CreateUniformScale(scale);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -237,7 +264,7 @@ namespace AZ
|
||||
if (serializeContext)
|
||||
{
|
||||
serializeContext->Class<Transform>()
|
||||
->Version(1)
|
||||
->Version(2)
|
||||
->Serializer<TransformSerializer>();
|
||||
}
|
||||
|
||||
@@ -250,7 +277,7 @@ namespace AZ
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
|
||||
Attribute(Script::Attributes::Storage, Script::Attributes::StorageType::Value)->
|
||||
Attribute(Script::Attributes::GenericConstructorOverride, &Internal::TransformDefaultConstructor)->
|
||||
Constructor<const Vector3&, const Quaternion&, const Vector3&>()->
|
||||
Constructor<const Vector3&, const Quaternion&, float>()->
|
||||
Method("GetBasis", &Transform::GetBasis)->
|
||||
Method("GetBasisX", &Transform::GetBasisX)->
|
||||
Method("GetBasisY", &Transform::GetBasisY)->
|
||||
@@ -283,15 +310,10 @@ namespace AZ
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
|
||||
Method("GetRotation", &Transform::GetRotation)->
|
||||
Method<void (Transform::*)(const Quaternion&)>("SetRotation", &Transform::SetRotation)->
|
||||
Method("GetScale", &Transform::GetScale)->
|
||||
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)->
|
||||
@@ -310,7 +332,6 @@ namespace AZ
|
||||
Method("CreateFromQuaternionAndTranslation", &Transform::CreateFromQuaternionAndTranslation)->
|
||||
Method("CreateFromMatrix3x3", &Transform::CreateFromMatrix3x3)->
|
||||
Method("CreateFromMatrix3x3AndTranslation", &Transform::CreateFromMatrix3x3AndTranslation)->
|
||||
Method("CreateScale", &Transform::CreateScale)->
|
||||
Method("CreateUniformScale", &Transform::CreateUniformScale)->
|
||||
Method("CreateTranslation", &Transform::CreateTranslation)->
|
||||
Method("ConstructFromValuesNumeric", &Internal::ConstructTransformFromValues);
|
||||
@@ -321,7 +342,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
Matrix3x3 tmp = value;
|
||||
result.m_scale = tmp.ExtractScale();
|
||||
result.m_scale = tmp.ExtractScale().GetMaxElement();
|
||||
result.m_rotation = Quaternion::CreateFromMatrix3x3(tmp);
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
@@ -331,7 +352,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
Matrix3x3 tmp = value;
|
||||
result.m_scale = tmp.ExtractScale();
|
||||
result.m_scale = tmp.ExtractScale().GetMaxElement();
|
||||
result.m_rotation = Quaternion::CreateFromMatrix3x3(tmp);
|
||||
result.m_translation = p;
|
||||
return result;
|
||||
@@ -341,7 +362,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
Matrix3x4 tmp = value;
|
||||
result.m_scale = tmp.ExtractScale();
|
||||
result.m_scale = tmp.ExtractScale().GetMaxElement();
|
||||
result.m_rotation = Quaternion::CreateFromMatrix3x4(tmp);
|
||||
result.m_translation = value.GetTranslation();
|
||||
return result;
|
||||
|
||||
@@ -25,10 +25,13 @@ namespace AZ
|
||||
: public SerializeContext::IDataSerializer
|
||||
{
|
||||
public:
|
||||
// number of floats in the serialized representation, 4 for rotation, 3 for scale and 3 for translation
|
||||
static constexpr int NumFloats = 10;
|
||||
// number of floats in the serialized representation, 4 for rotation, 1 for scale and 3 for translation
|
||||
static constexpr int NumFloats = 8;
|
||||
|
||||
// number of floats in the old format, which stored a 3x4 matrix
|
||||
// number of floats in version 1, which used 4 for rotation, 3 for scale and 3 for translation
|
||||
static constexpr int NumFloatsVersion1 = 10;
|
||||
|
||||
// number of floats in version 0, which stored a 3x4 matrix
|
||||
static constexpr int NumFloatsVersion0 = 12;
|
||||
|
||||
size_t Save(const void* classPtr, IO::GenericStream& stream, bool isDataBigEndian) override;
|
||||
@@ -45,7 +48,7 @@ namespace AZ
|
||||
static constexpr float MaxTransformScale = 1e9f;
|
||||
//! @}
|
||||
|
||||
//! The basic transformation class, represented using a quaternion rotation, vector scale and vector translation.
|
||||
//! The basic transformation class, represented using a quaternion rotation, float scale and vector translation.
|
||||
//! By design, cannot represent skew transformations.
|
||||
class Transform
|
||||
{
|
||||
@@ -63,7 +66,7 @@ namespace AZ
|
||||
Transform() = default;
|
||||
|
||||
//! Construct a transform from components.
|
||||
Transform(const Vector3& translation, const Quaternion& rotation, const Vector3& scale);
|
||||
Transform(const Vector3& translation, const Quaternion& rotation, float scale);
|
||||
|
||||
//! Creates an identity transform.
|
||||
static Transform CreateIdentity();
|
||||
@@ -82,16 +85,20 @@ namespace AZ
|
||||
static Transform CreateFromQuaternionAndTranslation(const class Quaternion& q, const Vector3& p);
|
||||
|
||||
//! Constructs from a Matrix3x3, translation is set to zero.
|
||||
//! Note that Transform only allows uniform scale, so if the matrix has different scale values along its axes,
|
||||
//! the largest matrix scale value will be used to uniformly scale the Transform.
|
||||
static Transform CreateFromMatrix3x3(const class Matrix3x3& value);
|
||||
|
||||
//! Constructs from a Matrix3x3, translation is set to zero.
|
||||
//! Constructs from a Matrix3x3 and translation Vector3.
|
||||
//! Note that Transform only allows uniform scale, so if the matrix has different scale values along its axes,
|
||||
//! the largest matrix scale value will be used to uniformly scale the Transform.
|
||||
static Transform CreateFromMatrix3x3AndTranslation(const class Matrix3x3& value, const Vector3& p);
|
||||
|
||||
//! Constructs from a Matrix3x4.
|
||||
//! Note that Transform only allows uniform scale, so if the matrix has different scale values along its axes,
|
||||
//! the largest matrix scale value will be used to uniformly scale the Transform.
|
||||
static Transform CreateFromMatrix3x4(const Matrix3x4& value);
|
||||
|
||||
//! 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);
|
||||
|
||||
@@ -122,18 +129,12 @@ namespace AZ
|
||||
const Quaternion& GetRotation() const;
|
||||
void SetRotation(const Quaternion& rotation);
|
||||
|
||||
Vector3 GetScale() const;
|
||||
float GetUniformScale() const;
|
||||
void SetScale(const Vector3& v);
|
||||
void SetUniformScale(const float scale);
|
||||
|
||||
//! Sets the transform's scale to a unit value and returns the previous scale value.
|
||||
Vector3 ExtractScale();
|
||||
|
||||
//! 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;
|
||||
@@ -168,7 +169,7 @@ namespace AZ
|
||||
private:
|
||||
|
||||
Quaternion m_rotation;
|
||||
Vector3 m_scale;
|
||||
float m_scale;
|
||||
Vector3 m_translation;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
AZ_MATH_INLINE Transform::Transform(const Vector3& translation, const Quaternion& rotation, const Vector3& scale)
|
||||
AZ_MATH_INLINE Transform::Transform(const Vector3& translation, const Quaternion& rotation, float scale)
|
||||
: m_translation(translation)
|
||||
, m_rotation(rotation)
|
||||
, m_scale(scale)
|
||||
@@ -25,7 +25,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = Quaternion::CreateIdentity();
|
||||
result.m_scale = Vector3::CreateOne();
|
||||
result.m_scale = 1.0f;
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = q;
|
||||
result.m_scale = Vector3::CreateOne();
|
||||
result.m_scale = 1.0f;
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
}
|
||||
@@ -58,26 +58,16 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = q;
|
||||
result.m_scale = Vector3::CreateOne();
|
||||
result.m_scale = 1.0f;
|
||||
result.m_translation = p;
|
||||
return result;
|
||||
}
|
||||
|
||||
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;
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Transform Transform::CreateUniformScale(float scale)
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = Quaternion::CreateIdentity();
|
||||
result.m_scale = Vector3(scale);
|
||||
result.m_scale = scale;
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
}
|
||||
@@ -86,7 +76,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = Quaternion::CreateIdentity();
|
||||
result.m_scale = Vector3::CreateOne();
|
||||
result.m_scale = 1.0f;
|
||||
result.m_translation = translation;
|
||||
return result;
|
||||
}
|
||||
@@ -114,17 +104,17 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE Vector3 Transform::GetBasisX() const
|
||||
{
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisX(m_scale.GetX()));
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisX(m_scale));
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Vector3 Transform::GetBasisY() const
|
||||
{
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisY(m_scale.GetY()));
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisY(m_scale));
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Vector3 Transform::GetBasisZ() const
|
||||
{
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisZ(m_scale.GetZ()));
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisZ(m_scale));
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::GetBasisAndTranslation(Vector3* basisX, Vector3* basisY, Vector3* basisZ, Vector3* pos) const
|
||||
@@ -160,49 +150,23 @@ namespace AZ
|
||||
m_rotation = rotation;
|
||||
}
|
||||
|
||||
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;
|
||||
return m_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;
|
||||
m_scale = scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE float Transform::ExtractUniformScale()
|
||||
{
|
||||
const float scale = m_scale.GetMaxElement();
|
||||
m_scale = Vector3::CreateOne();
|
||||
const float scale = m_scale;
|
||||
m_scale = 1.0f;
|
||||
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;
|
||||
@@ -240,10 +204,9 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE Transform Transform::GetInverse() const
|
||||
{
|
||||
// note - need to be careful about how to calculate inverse when there is non-uniform scale
|
||||
Transform out;
|
||||
out.m_rotation = m_rotation.GetConjugate();
|
||||
out.m_scale = m_scale.GetReciprocal();
|
||||
out.m_scale = 1.0f / m_scale;
|
||||
out.m_translation = -out.m_scale * (out.m_rotation.TransformVector(m_translation));
|
||||
return out;
|
||||
}
|
||||
@@ -255,27 +218,27 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE bool Transform::IsOrthogonal(float tolerance) const
|
||||
{
|
||||
return m_scale.IsClose(Vector3::CreateOne(), tolerance);
|
||||
return AZ::IsClose(m_scale, 1.0f, tolerance);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Transform Transform::GetOrthogonalized() const
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = m_rotation;
|
||||
result.m_scale = Vector3::CreateOne();
|
||||
result.m_scale = 1.0f;
|
||||
result.m_translation = m_translation;
|
||||
return result;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::Orthogonalize()
|
||||
{
|
||||
m_scale = Vector3::CreateOne();
|
||||
m_scale = 1.0f;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE bool Transform::IsClose(const Transform& rhs, float tolerance) const
|
||||
{
|
||||
return m_rotation.IsClose(rhs.m_rotation, tolerance)
|
||||
&& m_scale.IsClose(rhs.m_scale, tolerance)
|
||||
&& AZ::IsClose(m_scale, rhs.m_scale, tolerance)
|
||||
&& m_translation.IsClose(rhs.m_translation, tolerance);
|
||||
}
|
||||
|
||||
@@ -304,21 +267,21 @@ namespace AZ
|
||||
AZ_MATH_INLINE void Transform::SetFromEulerDegrees(const Vector3& eulerDegrees)
|
||||
{
|
||||
m_translation = Vector3::CreateZero();
|
||||
m_scale = Vector3::CreateOne();
|
||||
m_scale = 1.0f;
|
||||
m_rotation.SetFromEulerDegrees(eulerDegrees);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::SetFromEulerRadians(const Vector3& eulerRadians)
|
||||
{
|
||||
m_translation = Vector3::CreateZero();
|
||||
m_scale = Vector3::CreateOne();
|
||||
m_scale = 1.0f;
|
||||
m_rotation.SetFromEulerRadians(eulerRadians);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE bool Transform::IsFinite() const
|
||||
{
|
||||
return m_rotation.IsFinite()
|
||||
&& m_scale.IsFinite()
|
||||
&& AZ::IsFiniteFloat(m_scale)
|
||||
&& m_translation.IsFinite();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace AZ
|
||||
|
||||
result.Combine(loadResult);
|
||||
|
||||
transformInstance->SetScale(AZ::Vector3(scale));
|
||||
transformInstance->SetUniformScale(scale);
|
||||
}
|
||||
|
||||
return context.Report(
|
||||
|
||||
@@ -512,7 +512,7 @@ namespace AZ
|
||||
// Load DLLs specified in the application descriptor
|
||||
for (const auto& moduleDescriptor : modules)
|
||||
{
|
||||
// For each module that is loaded, attempt to set the module's folder as a path for dependent module resolution
|
||||
// For each module that is loaded, attempt to set the module's folder as a path for dependent module resolution
|
||||
moduleSearchPathHelper.SetModuleSearchPath(moduleDescriptor);
|
||||
|
||||
LoadModuleOutcome result = LoadDynamicModule(moduleDescriptor.m_dynamicLibraryPath.c_str(), lastStepToPerform, maintainReferences);
|
||||
|
||||
@@ -123,6 +123,7 @@ namespace AZ
|
||||
|
||||
const static AZ::Crc32 NameLabelOverride = AZ_CRC("NameLabelOverride", 0x9ff79cab);
|
||||
const static AZ::Crc32 AssetPickerTitle = AZ_CRC_CE("AssetPickerTitle");
|
||||
const static AZ::Crc32 HideProductFilesInAssetPicker = AZ_CRC_CE("HideProductFilesInAssetPicker");
|
||||
const static AZ::Crc32 ChildNameLabelOverride = AZ_CRC("ChildNameLabelOverride", 0x73dd2909);
|
||||
//! Container attribute that is used to override labels for its elements given the index of the element
|
||||
const static AZ::Crc32 IndexedChildNameLabelOverride = AZ_CRC("IndexedChildNameLabelOverride", 0x5f313ac2);
|
||||
|
||||
@@ -88,6 +88,35 @@ namespace AZ::Internal
|
||||
m_enginePaths.emplace_back(EngineInfo{AZ::IO::FixedMaxPath{value}.LexicallyNormal(), {}});
|
||||
}
|
||||
|
||||
AZ::SettingsRegistryInterface::VisitResponse Traverse(
|
||||
[[maybe_unused]] AZStd::string_view path, AZStd::string_view valueName,
|
||||
AZ::SettingsRegistryInterface::VisitAction action, AZ::SettingsRegistryInterface::Type type) override
|
||||
{
|
||||
auto response = AZ::SettingsRegistryInterface::VisitResponse::Continue;
|
||||
if (action == AZ::SettingsRegistryInterface::VisitAction::Begin)
|
||||
{
|
||||
if (type == AZ::SettingsRegistryInterface::Type::Array)
|
||||
{
|
||||
if (valueName.compare("engines") != 0)
|
||||
{
|
||||
response = AZ::SettingsRegistryInterface::VisitResponse::Skip;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (action == AZ::SettingsRegistryInterface::VisitAction::Value)
|
||||
{
|
||||
if (type == AZ::SettingsRegistryInterface::Type::String)
|
||||
{
|
||||
if (valueName.compare("path") != 0)
|
||||
{
|
||||
response = AZ::SettingsRegistryInterface::VisitResponse::Skip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
AZStd::vector<EngineInfo> m_enginePaths{};
|
||||
};
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace AZ
|
||||
return os
|
||||
<< "translation: " << transform.GetTranslation()
|
||||
<< " rotation: " << transform.GetRotation()
|
||||
<< " scale: " << transform.GetScale();
|
||||
<< " scale: " << transform.GetUniformScale();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Color& color)
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace JsonSerializationTests
|
||||
AZStd::shared_ptr<AZ::Transform> CreateFullySetInstance() override
|
||||
{
|
||||
return AZStd::make_shared<AZ::Transform>(
|
||||
AZ::Vector3(1.0f, 2.0f, 3.0f), AZ::Quaternion(0.25f, 0.5f, 0.75f, 1.0f), AZ::Vector3(9.0f));
|
||||
AZ::Vector3(1.0f, 2.0f, 3.0f), AZ::Quaternion(0.25f, 0.5f, 0.75f, 1.0f), 9.0f);
|
||||
}
|
||||
|
||||
AZStd::string_view GetJsonForFullySetInstance() override
|
||||
@@ -95,7 +95,7 @@ namespace JsonSerializationTests
|
||||
AZ::Transform expectedTransform(
|
||||
AZ::Vector3(2.25f, 3.5f, 4.75f),
|
||||
AZ::Quaternion(0.25f, 0.5f, 0.75f, 1.0f),
|
||||
AZ::Vector3(5.5f));
|
||||
5.5f);
|
||||
|
||||
rapidjson::Document json;
|
||||
json.Parse(R"({ "Translation": [ 2.25, 3.5, 4.75 ], "Rotation": [ 0.25, 0.5, 0.75, 1.0 ], "Scale": 5.5 })");
|
||||
|
||||
@@ -406,21 +406,10 @@ namespace AzFramework
|
||||
return m_localTM.GetRotation();
|
||||
}
|
||||
|
||||
void TransformComponent::SetLocalScale(const AZ::Vector3& scale)
|
||||
{
|
||||
AZ::Transform newLocalTM = m_localTM;
|
||||
newLocalTM.SetScale(scale);
|
||||
SetLocalTM(newLocalTM);
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformComponent::GetLocalScale()
|
||||
{
|
||||
return m_localTM.GetScale();
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformComponent::GetWorldScale()
|
||||
{
|
||||
return m_worldTM.GetScale();
|
||||
AZ_WarningOnce("TransformComponent", false, "GetLocalScale is deprecated, please use GetLocalUniformScale instead");
|
||||
return AZ::Vector3(m_localTM.GetUniformScale());
|
||||
}
|
||||
|
||||
void TransformComponent::SetLocalUniformScale(float scale)
|
||||
@@ -756,11 +745,11 @@ namespace AzFramework
|
||||
->Event("GetLocalRotationQuaternion", &AZ::TransformBus::Events::GetLocalRotationQuaternion)
|
||||
->Attribute("Rotation", AZ::Edit::Attributes::PropertyRotation)
|
||||
->VirtualProperty("Rotation", "GetLocalRotationQuaternion", "SetLocalRotationQuaternion")
|
||||
->Event("SetLocalScale", &AZ::TransformBus::Events::SetLocalScale)
|
||||
->Event("GetLocalScale", &AZ::TransformBus::Events::GetLocalScale)
|
||||
->Attribute("Scale", AZ::Edit::Attributes::PropertyScale)
|
||||
->VirtualProperty("Scale", "GetLocalScale", "SetLocalScale")
|
||||
->Event("GetWorldScale", &AZ::TransformBus::Events::GetWorldScale)
|
||||
->Event("SetLocalUniformScale", &AZ::TransformBus::Events::SetLocalUniformScale)
|
||||
->Event("GetLocalUniformScale", &AZ::TransformBus::Events::GetLocalUniformScale)
|
||||
->VirtualProperty("Uniform Scale", "GetLocalUniformScale", "SetLocalUniformScale")
|
||||
->Event("GetChildren", &AZ::TransformBus::Events::GetChildren)
|
||||
->Event("GetAllDescendants", &AZ::TransformBus::Events::GetAllDescendants)
|
||||
->Event("GetEntityAndAllDescendants", &AZ::TransformBus::Events::GetEntityAndAllDescendants)
|
||||
|
||||
@@ -128,9 +128,7 @@ namespace AzFramework
|
||||
AZ::Quaternion GetLocalRotationQuaternion() override;
|
||||
|
||||
// Scale Modifiers
|
||||
void SetLocalScale(const AZ::Vector3& scale) override;
|
||||
AZ::Vector3 GetLocalScale() override;
|
||||
AZ::Vector3 GetWorldScale() override;
|
||||
|
||||
void SetLocalUniformScale(float scale) override;
|
||||
float GetLocalUniformScale() override;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace AzFramework
|
||||
AZ::Matrix3x4 m_transform = AZ::Matrix3x4::Identity(); //!< Transform to apply to text quads
|
||||
bool m_monospace = false; //!< disable character proportional spacing
|
||||
bool m_depthTest = false; //!< Test character against the depth buffer
|
||||
bool m_virtual800x600ScreenSize = true; //!< Text placement and size are scaled relative to a virtual 800x600 resolution
|
||||
bool m_virtual800x600ScreenSize = false; //!< Text placement and size are scaled relative to a virtual 800x600 resolution
|
||||
bool m_scaleWithWindow = false; //!< Font gets bigger as the window gets bigger
|
||||
bool m_multiline = true; //!< text respects ascii newline characters
|
||||
};
|
||||
|
||||
@@ -259,11 +259,18 @@ namespace Physics
|
||||
|
||||
if (success)
|
||||
{
|
||||
success = success && dataElement.RemoveElementByName(AZ_CRC("MaterialId", 0x9360e002));
|
||||
dataElement.RemoveElementByName(AZ_CRC("MaterialId", 0x9360e002));
|
||||
success = success && (dataElement.FindElement(AZ_CRC("MaterialId", 0x9360e002)) < 0);
|
||||
success = success && dataElement.AddElementWithData(context, "MaterialIds", AZStd::vector<Physics::MaterialId> { materialId });
|
||||
}
|
||||
}
|
||||
|
||||
if (success && dataElement.GetVersion() <= 2)
|
||||
{
|
||||
dataElement.RemoveElementByName(AZ_CRC_CE("Material"));
|
||||
success = success && (dataElement.FindElement(AZ_CRC_CE("Material")) < 0);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
} // namespace ClassConverters
|
||||
|
||||
@@ -58,9 +58,18 @@ namespace AzPhysics
|
||||
//! When triggered will send the handle to the old Scene (after this call, the Handle will be invalid).
|
||||
using OnSceneRemovedEvent = AZ::Event<AzPhysics::SceneHandle>;
|
||||
|
||||
//! Event that triggers when the default material library changes.
|
||||
//! Event that triggers when the material library changes.
|
||||
//! When triggered the event will send the Asset Id of the new material library.
|
||||
using OnDefaultMaterialLibraryChangedEvent = AZ::Event<const AZ::Data::AssetId&>;
|
||||
using OnMaterialLibraryChangedEvent = AZ::Event<const AZ::Data::AssetId&>;
|
||||
|
||||
enum class MaterialLibraryLoadErrorType : uint8_t
|
||||
{
|
||||
InvalidId,
|
||||
ErrorLoading
|
||||
};
|
||||
|
||||
//! Event that triggers when the default material library has loaded with errors.
|
||||
using OnMaterialLibraryLoadErrorEvent = AZ::Event<MaterialLibraryLoadErrorType>;
|
||||
|
||||
//! Event that triggers when the default scene configuration changes.
|
||||
//! When triggered the event will send the new default scene configuration.
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <AzCore/std/containers/variant.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/limits.h>
|
||||
#include <AzFramework/Physics/Common/PhysicsSimulatedBodyEvents.h>
|
||||
#include <AzFramework/Physics/Common/PhysicsSceneQueries.h>
|
||||
#include <AzFramework/Physics/Common/PhysicsTypes.h>
|
||||
@@ -68,6 +69,22 @@ namespace AzPhysics
|
||||
return m_customUserData;
|
||||
}
|
||||
|
||||
//! Helper functions for setting frame ID.
|
||||
//! @param frameId Optionally set frame ID for the systems moving the actors back in time.
|
||||
void SetFrameId(uint32_t frameId)
|
||||
{
|
||||
m_frameId = frameId;
|
||||
}
|
||||
|
||||
//! Helper functions for getting the set frame ID.
|
||||
//! @return Will return the frame ID.
|
||||
uint32_t GetFrameId() const
|
||||
{
|
||||
return m_frameId;
|
||||
}
|
||||
|
||||
static constexpr uint32_t UndefinedFrameId = AZStd::numeric_limits<uint32_t>::max();
|
||||
|
||||
//! Perform a ray cast on this Simulated Body.
|
||||
//! @param request The request to make.
|
||||
//! @return Returns the closest hit, if any, against this simulated body.
|
||||
@@ -126,6 +143,7 @@ namespace AzPhysics
|
||||
SimulatedBodyEvents::OnTriggerExit m_triggerExitEvent;
|
||||
|
||||
void* m_customUserData = nullptr;
|
||||
uint32_t m_frameId = UndefinedFrameId;
|
||||
|
||||
// helpers for reflecting to behavior context
|
||||
SimulatedBodyEvents::OnCollisionBegin* GetOnCollisionBeginEvent();
|
||||
|
||||
+5
-1
@@ -39,6 +39,8 @@ namespace AzPhysics
|
||||
->Field("ShapecastBufferSize", &SystemConfiguration::m_shapecastBufferSize)
|
||||
->Field("OverlapBufferSize", &SystemConfiguration::m_overlapBufferSize)
|
||||
->Field("CollisionConfig", &SystemConfiguration::m_collisionConfig)
|
||||
->Field("DefaultMaterial", &SystemConfiguration::m_defaultMaterialConfiguration)
|
||||
->Field("MaterialLibrary", &SystemConfiguration::m_materialLibraryAsset)
|
||||
;
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
@@ -79,7 +81,9 @@ namespace AzPhysics
|
||||
m_overlapBufferSize == other.m_overlapBufferSize &&
|
||||
AZ::IsClose(m_maxTimestep, other.m_maxTimestep) &&
|
||||
AZ::IsClose(m_fixedTimestep, other.m_fixedTimestep) &&
|
||||
m_collisionConfig == other.m_collisionConfig
|
||||
m_collisionConfig == other.m_collisionConfig &&
|
||||
m_defaultMaterialConfiguration == other.m_defaultMaterialConfiguration &&
|
||||
m_materialLibraryAsset == other.m_materialLibraryAsset
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <AzFramework/Physics/Configuration/CollisionConfiguration.h>
|
||||
#include <AzFramework/Physics/Material.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -45,6 +46,9 @@ namespace AzPhysics
|
||||
//! Each Physics Scene uses this as a base and will override as needed.
|
||||
CollisionConfiguration m_collisionConfig;
|
||||
|
||||
Physics::MaterialConfiguration m_defaultMaterialConfiguration; //!< Default material parameters for the project.
|
||||
AZ::Data::Asset<Physics::MaterialLibraryAsset> m_materialLibraryAsset = AZ::Data::AssetLoadBehavior::NoLoad; //!< Material Library exposed by the system component SystemBus API.
|
||||
|
||||
//! Controls whether the Physics System will self register to the TickBus and call StartSimulation / FinishSimulation on each Scene.
|
||||
//! Disable this to manually control Physics Scene simulation logic.
|
||||
bool m_autoManageSimulationUpdate = true;
|
||||
|
||||
@@ -49,10 +49,7 @@ namespace Physics
|
||||
{
|
||||
materialSelection->SetMaterialSlots(Physics::MaterialSelection::SlotsArray());
|
||||
}
|
||||
if (materialSelection->IsDefaultMaterialLibraryAsset())
|
||||
{
|
||||
materialSelection->SyncSelectionToMaterialLibrary();
|
||||
}
|
||||
materialSelection->SyncSelectionToMaterialLibrary();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -122,6 +119,24 @@ namespace Physics
|
||||
}
|
||||
}
|
||||
|
||||
bool MaterialConfiguration::operator==(const MaterialConfiguration& other) const
|
||||
{
|
||||
return m_surfaceType == other.m_surfaceType &&
|
||||
AZ::IsClose(m_dynamicFriction, other.m_dynamicFriction) &&
|
||||
AZ::IsClose(m_staticFriction, other.m_staticFriction) &&
|
||||
AZ::IsClose(m_restitution, other.m_restitution) &&
|
||||
AZ::IsClose(m_density, other.m_density) &&
|
||||
m_restitutionCombine == other.m_restitutionCombine &&
|
||||
m_frictionCombine == other.m_frictionCombine &&
|
||||
m_debugColor == other.m_debugColor
|
||||
;
|
||||
}
|
||||
|
||||
bool MaterialConfiguration::operator!=(const MaterialConfiguration& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
AZ::Color MaterialConfiguration::GenerateDebugColor(const char* materialName)
|
||||
{
|
||||
static const AZ::Color colors[] =
|
||||
@@ -191,51 +206,25 @@ namespace Physics
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void MaterialLibraryAssetReflectionWrapper::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
|
||||
if (serializeContext)
|
||||
{
|
||||
serializeContext->Class<Physics::MaterialLibraryAssetReflectionWrapper>()
|
||||
->Version(1)
|
||||
->Field("Asset", &MaterialLibraryAssetReflectionWrapper::m_asset)
|
||||
;
|
||||
|
||||
AZ::EditContext* editContext = serializeContext->GetEditContext();
|
||||
if (editContext)
|
||||
{
|
||||
editContext->Class<Physics::MaterialLibraryAssetReflectionWrapper>("", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialLibraryAssetReflectionWrapper::m_asset, "Physics Material Library", "Physics Material Library")
|
||||
->Attribute("EditButton", "")
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
void DefaultMaterialLibraryAssetReflectionWrapper::Reflect(AZ::ReflectContext* context)
|
||||
void MaterialInfoReflectionWrapper::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
|
||||
if (serializeContext)
|
||||
{
|
||||
serializeContext->Class<Physics::DefaultMaterialLibraryAssetReflectionWrapper>()
|
||||
serializeContext->Class<Physics::MaterialInfoReflectionWrapper>()
|
||||
->Version(1)
|
||||
->Field("Asset", &DefaultMaterialLibraryAssetReflectionWrapper::m_asset)
|
||||
->Field("DefaultMaterial", &MaterialInfoReflectionWrapper::m_defaultMaterialConfiguration)
|
||||
->Field("Asset", &MaterialInfoReflectionWrapper::m_materialLibraryAsset)
|
||||
;
|
||||
|
||||
AZ::EditContext* editContext = serializeContext->GetEditContext();
|
||||
if (editContext)
|
||||
{
|
||||
editContext->Class<Physics::DefaultMaterialLibraryAssetReflectionWrapper>("", "")
|
||||
editContext->Class<Physics::MaterialInfoReflectionWrapper>("Physics Materials", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &DefaultMaterialLibraryAssetReflectionWrapper::m_asset, "Default Physics Material Library", "Library to use by default")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialInfoReflectionWrapper::m_defaultMaterialConfiguration, "Default Physics Material", "Material used by default")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialInfoReflectionWrapper::m_materialLibraryAsset, "Physics Material Library", "Library to use for the project")
|
||||
->Attribute(AZ::Edit::Attributes::AllowClearAsset, false)
|
||||
->Attribute("EditButton", "")
|
||||
;
|
||||
@@ -269,6 +258,17 @@ namespace Physics
|
||||
}
|
||||
}
|
||||
|
||||
bool MaterialFromAssetConfiguration::operator==(const MaterialFromAssetConfiguration& other) const
|
||||
{
|
||||
return m_configuration == other.m_configuration &&
|
||||
m_id == other.m_id;
|
||||
}
|
||||
|
||||
bool MaterialFromAssetConfiguration::operator!=(const MaterialFromAssetConfiguration& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool MaterialLibraryAsset::GetDataForMaterialId(const MaterialId& materialId, MaterialFromAssetConfiguration& configuration) const
|
||||
@@ -370,9 +370,8 @@ namespace Physics
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<Physics::MaterialSelection>()
|
||||
->Version(2, &ClassConverters::MaterialSelectionConverter)
|
||||
->Version(3, &ClassConverters::MaterialSelectionConverter)
|
||||
->EventHandler<MaterialSelectionEventHandler>()
|
||||
->Field("Material", &MaterialSelection::m_materialLibrary)
|
||||
->Field("MaterialIds", &MaterialSelection::m_materialIdsAssignedToSlots)
|
||||
;
|
||||
|
||||
@@ -381,14 +380,8 @@ namespace Physics
|
||||
editContext->Class<Physics::MaterialSelection>("Physics Material", "Select physics material library and which materials to use for the object")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialSelection::m_materialLibrary, "Library", "Physics material library to use for this object")
|
||||
->Attribute(AZ::Edit::Attributes::ContainerCanBeModified, true)
|
||||
->Attribute("EditButton", "")
|
||||
->Attribute("EditDescription", "Open in Asset Editor")
|
||||
->Attribute(AZ::Edit::Attributes::DefaultAsset, &MaterialSelection::GetDefaultMaterialLibraryId)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &MaterialSelection::OnMaterialLibraryChanged)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialSelection::m_materialIdsAssignedToSlots, "Mesh Surfaces", "Specify which Physics Material to use for each element of this object")
|
||||
->ElementAttribute(Attributes::MaterialLibraryAssetId, &MaterialSelection::GetMaterialLibraryAssetId)
|
||||
->ElementAttribute(Attributes::MaterialLibraryAssetId, &MaterialSelection::GetMaterialLibraryId)
|
||||
->Attribute(AZ::Edit::Attributes::IndexedChildNameLabelOverride, &MaterialSelection::GetMaterialSlotLabel)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->ElementAttribute(AZ::Edit::Attributes::ReadOnly, &MaterialSelection::AreMaterialSlotsReadOnly)
|
||||
@@ -398,12 +391,6 @@ namespace Physics
|
||||
}
|
||||
}
|
||||
|
||||
AZ::u32 MaterialSelection::OnMaterialLibraryChanged()
|
||||
{
|
||||
SyncSelectionToMaterialLibrary();
|
||||
return AZ::Edit::PropertyRefreshLevels::EntireTree;
|
||||
}
|
||||
|
||||
AZStd::string MaterialSelection::GetMaterialSlotLabel(int index)
|
||||
{
|
||||
if (index < m_materialSlots.size())
|
||||
@@ -425,28 +412,9 @@ namespace Physics
|
||||
}
|
||||
}
|
||||
|
||||
AZ::Data::AssetId MaterialSelection::GetMaterialLibraryAssetId() const
|
||||
void MaterialSelection::OnMaterialLibraryChanged([[maybe_unused]] const AZ::Data::AssetId& defaultMaterialLibraryId)
|
||||
{
|
||||
return GetMaterialLibraryAsset().GetId();
|
||||
}
|
||||
|
||||
const Physics::MaterialLibraryAsset* MaterialSelection::GetMaterialLibraryAssetData() const
|
||||
{
|
||||
return GetMaterialLibraryAsset().Get();
|
||||
}
|
||||
|
||||
const AZStd::string& MaterialSelection::GetMaterialLibraryAssetHint() const
|
||||
{
|
||||
return m_materialLibrary.GetHint();
|
||||
}
|
||||
|
||||
void MaterialSelection::OnDefaultMaterialLibraryChanged(const AZ::Data::AssetId& defaultMaterialLibraryId)
|
||||
{
|
||||
AZ_UNUSED(defaultMaterialLibraryId);
|
||||
if (IsDefaultMaterialLibraryAsset())
|
||||
{
|
||||
OnMaterialLibraryChanged();
|
||||
}
|
||||
SyncSelectionToMaterialLibrary();
|
||||
}
|
||||
|
||||
void MaterialSelection::SetSlotsReadOnly(bool readOnly)
|
||||
@@ -454,45 +422,6 @@ namespace Physics
|
||||
m_slotsReadOnly = readOnly;
|
||||
}
|
||||
|
||||
bool MaterialSelection::IsMaterialLibraryValid() const
|
||||
{
|
||||
if (GetMaterialLibraryAssetId().IsValid())
|
||||
{
|
||||
auto materialAsset = LoadAsset();
|
||||
const auto& materialsData = materialAsset.Get()->GetMaterialsData();
|
||||
|
||||
if (materialsData.size() != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MaterialSelection::GetMaterialConfiguration(Physics::MaterialFromAssetConfiguration& configuration, const Physics::MaterialId& materialId) const
|
||||
{
|
||||
if (IsMaterialLibraryValid())
|
||||
{
|
||||
auto materialAsset = LoadAsset();
|
||||
if (materialAsset.Get())
|
||||
{
|
||||
return materialAsset.Get()->GetDataForMaterialId(materialId, configuration);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MaterialSelection::SetMaterialLibrary(const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
m_materialLibrary = AZ::Data::AssetManager::Instance().GetAsset<Physics::MaterialLibraryAsset>(assetId, m_materialLibrary.GetAutoLoadBehavior());
|
||||
m_materialLibrary.BlockUntilLoadComplete();
|
||||
}
|
||||
|
||||
void MaterialSelection::ResetToDefaultMaterialLibrary()
|
||||
{
|
||||
m_materialLibrary = {};
|
||||
}
|
||||
|
||||
void MaterialSelection::SetMaterialSlots(const SlotsArray& slots)
|
||||
{
|
||||
if (slots.empty())
|
||||
@@ -533,74 +462,45 @@ namespace Physics
|
||||
m_materialIdsAssignedToSlots[slotIndex] = materialId;
|
||||
}
|
||||
|
||||
AZ::Data::Asset<Physics::MaterialLibraryAsset> MaterialSelection::LoadAsset() const
|
||||
{
|
||||
AZ::Data::Asset<MaterialLibraryAsset> asset = AZ::Data::AssetManager::Instance()
|
||||
.GetAsset<Physics::MaterialLibraryAsset>(GetMaterialLibraryAssetId(), AZ::Data::AssetLoadBehavior::Default);
|
||||
|
||||
asset.BlockUntilLoadComplete();
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
void MaterialSelection::SyncSelectionToMaterialLibrary()
|
||||
{
|
||||
if (GetMaterialLibraryAssetId().IsValid())
|
||||
auto* materialLibrary = GetMaterialLibrary().Get();
|
||||
if (!materialLibrary)
|
||||
{
|
||||
auto materialLibraryAsset = AZ::Data::AssetManager::Instance().GetAsset<Physics::MaterialLibraryAsset>(GetMaterialLibraryAssetId(), AZ::Data::AssetLoadBehavior::Default);
|
||||
return;
|
||||
}
|
||||
|
||||
materialLibraryAsset.BlockUntilLoadComplete();
|
||||
|
||||
// We try to check whether existing selection matches any materials in the newly assigned library and do one of the following:
|
||||
// 1. If previous MaterialId is invalid for this material library, and it is not the Default material, we set it to the Default material from the library.
|
||||
// 2. If it's valid, or it is the Default material, we don't change it (useful when user accidentally re-assigns the same library: previous selection won't go away).
|
||||
|
||||
if (materialLibraryAsset.Get())
|
||||
for (Physics::MaterialId& materialId : m_materialIdsAssignedToSlots)
|
||||
{
|
||||
// Leave nulls (default) unchanged.
|
||||
if (materialId.IsNull())
|
||||
{
|
||||
for (Physics::MaterialId& materialId : m_materialIdsAssignedToSlots)
|
||||
{
|
||||
if (!materialLibraryAsset.Get()->HasDataForMaterialId(materialId)
|
||||
&& !materialId.IsNull()) // Null materialId is the Default material.
|
||||
{
|
||||
materialId = MaterialId();
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
||||
// If the material id is not present in the library anymore, set it to default
|
||||
if (!materialLibrary->HasDataForMaterialId(materialId))
|
||||
{
|
||||
AZ_Warning("PhysX", false, "MaterialSelection: invalid material library");
|
||||
materialId = MaterialId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const AZ::Data::Asset<Physics::MaterialLibraryAsset>& MaterialSelection::GetMaterialLibraryAsset() const
|
||||
{
|
||||
if (IsDefaultMaterialLibraryAsset())
|
||||
{
|
||||
const AZ::Data::Asset<Physics::MaterialLibraryAsset>& defaultMaterialLibrary = GetDefaultMaterialLibrary();
|
||||
return defaultMaterialLibrary;
|
||||
}
|
||||
|
||||
return m_materialLibrary;
|
||||
}
|
||||
|
||||
bool MaterialSelection::IsDefaultMaterialLibraryAsset() const
|
||||
{
|
||||
return !m_materialLibrary.GetId().IsValid();
|
||||
}
|
||||
|
||||
const AZ::Data::Asset<Physics::MaterialLibraryAsset>& MaterialSelection::GetDefaultMaterialLibrary()
|
||||
const AZ::Data::Asset<Physics::MaterialLibraryAsset>& MaterialSelection::GetMaterialLibrary()
|
||||
{
|
||||
if (auto* physicsSystem = AZ::Interface<AzPhysics::SystemInterface>::Get())
|
||||
{
|
||||
return physicsSystem->GetDefaultMaterialLibrary();
|
||||
if (const auto* physicsConfiguration = physicsSystem->GetConfiguration())
|
||||
{
|
||||
return physicsConfiguration->m_materialLibraryAsset;
|
||||
}
|
||||
}
|
||||
return s_invalidMaterialLibrary;
|
||||
}
|
||||
|
||||
const AZ::Data::AssetId& MaterialSelection::GetDefaultMaterialLibraryId()
|
||||
const AZ::Data::AssetId& MaterialSelection::GetMaterialLibraryId()
|
||||
{
|
||||
return GetDefaultMaterialLibrary().GetId();
|
||||
return GetMaterialLibrary().GetId();
|
||||
}
|
||||
|
||||
bool MaterialSelection::AreMaterialSlotsReadOnly() const
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace Physics
|
||||
/// =========================
|
||||
/// This is the interface to the wrapper around native material type (such as PxMaterial in PhysX gem)
|
||||
/// that stores extra metadata, like Surface Type name.
|
||||
/// To see more details about PhysX implementation please refer to PhysX::Material class
|
||||
///
|
||||
/// Usage example
|
||||
/// -------------------------
|
||||
@@ -37,14 +36,7 @@ namespace Physics
|
||||
///
|
||||
/// Physics::MaterialConfiguration materialProperties;
|
||||
/// AZStd::shared_ptr<Physics::Material> newMaterial = AZ::Interface<Physics::System>::Get()->CreateMaterial(materialProperties);
|
||||
///
|
||||
/// To get PxMaterial use GetNativePointer function
|
||||
///
|
||||
/// physx::PxMaterial* material = static_cast<physx::PxMaterial*>(newMaterial->GetNativePointer());
|
||||
///
|
||||
/// You can use retrieved PxMaterial pointer on its own, provided you increment its reference count.
|
||||
/// If this class goes out of scope, the PxMaterial pointer will be valid, but its userData
|
||||
/// will be cleaned up to point to nullptr.
|
||||
///
|
||||
class Material
|
||||
{
|
||||
public:
|
||||
@@ -63,9 +55,9 @@ namespace Physics
|
||||
|
||||
/// Returns AZ::Crc32 of the surface name.
|
||||
virtual AZ::Crc32 GetSurfaceType() const = 0;
|
||||
virtual void SetSurfaceType(AZ::Crc32 surfaceType) = 0;
|
||||
|
||||
virtual const AZStd::string& GetSurfaceTypeName() const = 0;
|
||||
virtual void SetSurfaceTypeName(const AZStd::string& surfaceTypeName) = 0;
|
||||
|
||||
virtual float GetDynamicFriction() const = 0;
|
||||
virtual void SetDynamicFriction(float dynamicFriction) = 0;
|
||||
@@ -85,6 +77,9 @@ namespace Physics
|
||||
virtual float GetDensity() const = 0;
|
||||
virtual void SetDensity(float density) = 0;
|
||||
|
||||
virtual AZ::Color GetDebugColor() const = 0;
|
||||
virtual void SetDebugColor(const AZ::Color& debugColor) = 0;
|
||||
|
||||
/// If the name of this material matches the name of one of the CrySurface types, it will return its CrySurface Id.\n
|
||||
/// If there's no match it will return default CrySurface Id.\n
|
||||
/// CrySurface types are defined in libs/materialeffects/surfacetypes.xml
|
||||
@@ -122,6 +117,10 @@ namespace Physics
|
||||
Material::CombineMode m_frictionCombine = Material::CombineMode::Average;
|
||||
|
||||
AZ::Color m_debugColor = AZ::Colors::White;
|
||||
|
||||
bool operator==(const MaterialConfiguration& other) const;
|
||||
bool operator!=(const MaterialConfiguration& other) const;
|
||||
|
||||
private:
|
||||
static bool VersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement);
|
||||
static AZ::Color GenerateDebugColor(const char* materialName);
|
||||
@@ -147,6 +146,7 @@ namespace Physics
|
||||
static MaterialId FromUUID(const AZ::Uuid& uuid);
|
||||
bool IsNull() const { return m_id.IsNull(); }
|
||||
bool operator==(const MaterialId& other) const { return m_id == other.m_id; }
|
||||
bool operator!=(const MaterialId& other) const { return !(*this == other); }
|
||||
const AZ::Uuid& GetUuid() const { return m_id; }
|
||||
|
||||
private:
|
||||
@@ -166,6 +166,9 @@ namespace Physics
|
||||
|
||||
MaterialConfiguration m_configuration;
|
||||
MaterialId m_id;
|
||||
|
||||
bool operator==(const MaterialFromAssetConfiguration& other) const;
|
||||
bool operator!=(const MaterialFromAssetConfiguration& other) const;
|
||||
};
|
||||
|
||||
/// An asset that holds a list of materials to be edited and assigned in Open 3D Engine Editor
|
||||
@@ -222,40 +225,27 @@ namespace Physics
|
||||
AZStd::vector<MaterialFromAssetConfiguration> m_materialLibrary;
|
||||
};
|
||||
|
||||
/// The class is used to expose a MaterialLibraryAsset to Edit Context
|
||||
/// The class is used to expose a default material and material library asset to Edit Context
|
||||
/// =======================================================================
|
||||
///
|
||||
/// Since AZ::Data::Asset doesn't reflect the data to EditContext
|
||||
/// we have to have a wrapper doing it.
|
||||
class MaterialLibraryAssetReflectionWrapper
|
||||
class MaterialInfoReflectionWrapper
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(MaterialLibraryAssetReflectionWrapper, AZ::SystemAllocator, 0);
|
||||
AZ_TYPE_INFO(Physics::MaterialLibraryAssetReflectionWrapper, "{3D2EF5DF-EFD0-47EB-B88F-3E6FE1FEE5B0}");
|
||||
AZ_CLASS_ALLOCATOR(MaterialInfoReflectionWrapper, AZ::SystemAllocator, 0);
|
||||
AZ_TYPE_INFO(Physics::MaterialInfoReflectionWrapper, "{02AB8CBC-D35B-4E0F-89BA-A96D94DAD4F9}");
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
AZ::Data::Asset<Physics::MaterialLibraryAsset> m_asset =
|
||||
Physics::MaterialConfiguration m_defaultMaterialConfiguration;
|
||||
AZ::Data::Asset<Physics::MaterialLibraryAsset> m_materialLibraryAsset =
|
||||
AZ::Data::AssetLoadBehavior::NoLoad;
|
||||
};
|
||||
|
||||
/// Customized material library for use as default material library
|
||||
class DefaultMaterialLibraryAssetReflectionWrapper : public Physics::MaterialLibraryAssetReflectionWrapper
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(MaterialLibraryAssetReflectionWrapper, AZ::SystemAllocator, 0);
|
||||
AZ_TYPE_INFO(Physics::DefaultMaterialLibraryAssetReflectionWrapper, "{02AB8CBC-D35B-4E0F-89BA-A96D94DAD4F9}");
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
AZ::Data::Asset<Physics::MaterialLibraryAsset> m_asset =
|
||||
AZ::Data::AssetLoadBehavior::NoLoad;
|
||||
};
|
||||
|
||||
/// The class is used to store a MaterialLibraryAsset and a vector of MaterialIds selected from the library
|
||||
/// The class is used to store a vector of MaterialIds selected from the library
|
||||
/// =======================================================================
|
||||
///
|
||||
/// This class is used to store a reference to the library asset and user's
|
||||
/// selection of the materials from this library.\n
|
||||
/// It also reflects UI controls for assigning MaterialLibraryAsset and selecting a material from it.
|
||||
/// This class is used to store the user's selection of the materials from this library.
|
||||
/// You can reflect this class in EditorContext to provide UI for selecting materials
|
||||
/// on any custom component or QWidget.
|
||||
class MaterialSelection
|
||||
@@ -269,27 +259,6 @@ namespace Physics
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
/// Returns whether MaterialLibraryAsset assigned to this selection exists and valid. Attempts to load
|
||||
/// the library if it's not loaded yet.
|
||||
/// @return true if MaterialLibraryAsset has a valid AssetId, loaded and isn't empty
|
||||
bool IsMaterialLibraryValid() const;
|
||||
|
||||
/// Looks up MaterialLibraryAsset for MaterialFromAssetConfiguration with MaterialId that is stored intrenally.
|
||||
/// @param configuration contains material data if there is a material selected by user
|
||||
/// and if it exists in the MaterialLibraryAsset
|
||||
/// @param materialId MaterialId to retrieve MaterialFromAssetConfiguration for
|
||||
/// @return true if lookup was successful.
|
||||
bool GetMaterialConfiguration(Physics::MaterialFromAssetConfiguration& configuration, const Physics::MaterialId& materialId) const;
|
||||
|
||||
/// Sets and loads MaterialLibraryAsset with specified AssetId.
|
||||
/// It is used to construct MaterialSelection at runtime.
|
||||
/// It is not a typical use case and mostly needed to convert legacy entities and auto-generate material libraries
|
||||
/// @param assetId AssetId to create MaterialLibraryAsset with
|
||||
void SetMaterialLibrary(const AZ::Data::AssetId& assetId);
|
||||
|
||||
/// Sets the material library to none, this will cause to use the project-wide default material library
|
||||
void ResetToDefaultMaterialLibrary();
|
||||
|
||||
/// Sets an array of material slots to pick MaterialIds for. Having multiple slots is required for assigning multiple materials on a mesh
|
||||
/// or heightfield object. SlotsArray can be empty and in this case Default slot will be created.
|
||||
/// @param slots Array of names for slots. Can be empty, in this case Default slot will be created
|
||||
@@ -298,48 +267,34 @@ namespace Physics
|
||||
/// Returns a list of MaterialId that were assigned for each corresponding slot.
|
||||
const AZStd::vector<Physics::MaterialId>& GetMaterialIdsAssignedToSlots() const;
|
||||
|
||||
/// Sets the MaterialId from MaterialLibraryAsset as the selected material at a specific slotIndex.
|
||||
/// @param materialId MaterialId that user selected from the MaterialLibraryAsset
|
||||
/// @param slotIndex index of the slot to set MaterialId for
|
||||
/// Sets the MaterialId as the selected material at a specific slotIndex.
|
||||
/// @param materialId MaterialId that user selected
|
||||
/// @param slotIndex Index of the slot to set the MaterialId
|
||||
void SetMaterialId(const Physics::MaterialId& materialId, int slotIndex = 0);
|
||||
|
||||
/// Returns the material library asset id.
|
||||
AZ::Data::AssetId GetMaterialLibraryAssetId() const;
|
||||
|
||||
/// Returns the material id assigned to this selection at a specific slotIndex.
|
||||
/// @param slotIndex index of the slot to retrieve MaterialId for
|
||||
/// @param slotIndex Index of the slot to retrieve the MaterialId
|
||||
Physics::MaterialId GetMaterialId(int slotIndex = 0) const;
|
||||
|
||||
/// Returns the material library asset.
|
||||
const Physics::MaterialLibraryAsset* GetMaterialLibraryAssetData() const;
|
||||
|
||||
/// Returns the material library asset hint(UI display string)
|
||||
const AZStd::string& GetMaterialLibraryAssetHint() const;
|
||||
|
||||
/// Called when the material library has changed
|
||||
void OnDefaultMaterialLibraryChanged(const AZ::Data::AssetId& defaultMaterialLibraryId);
|
||||
void OnMaterialLibraryChanged(const AZ::Data::AssetId& defaultMaterialLibraryId);
|
||||
|
||||
/// Set if the material slots are editable in the edit context
|
||||
void SetSlotsReadOnly(bool readOnly);
|
||||
|
||||
private:
|
||||
AZ::Data::Asset<Physics::MaterialLibraryAsset> m_materialLibrary { AZ::Data::AssetLoadBehavior::NoLoad };
|
||||
AZStd::vector<Physics::MaterialId> m_materialIdsAssignedToSlots;
|
||||
SlotsArray m_materialSlots;
|
||||
bool m_slotsReadOnly = false;
|
||||
|
||||
const AZ::Data::Asset<Physics::MaterialLibraryAsset>& GetMaterialLibraryAsset() const;
|
||||
AZ::Data::Asset<Physics::MaterialLibraryAsset> LoadAsset() const;
|
||||
bool IsDefaultMaterialLibraryAsset() const;
|
||||
void SyncSelectionToMaterialLibrary();
|
||||
|
||||
static const AZ::Data::Asset<Physics::MaterialLibraryAsset>& GetDefaultMaterialLibrary();
|
||||
static const AZ::Data::AssetId& GetDefaultMaterialLibraryId();
|
||||
static const AZ::Data::Asset<Physics::MaterialLibraryAsset>& GetMaterialLibrary();
|
||||
static const AZ::Data::AssetId& GetMaterialLibraryId();
|
||||
|
||||
bool AreMaterialSlotsReadOnly() const;
|
||||
|
||||
// EditorContext callbacks
|
||||
AZ::u32 OnMaterialLibraryChanged();
|
||||
AZStd::string GetMaterialSlotLabel(int index);
|
||||
};
|
||||
|
||||
|
||||
@@ -25,21 +25,26 @@ namespace Physics
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; // Implemented by sole owner of materials, e.g. class MaterialManager in PhysX gem.
|
||||
|
||||
/// Get default material
|
||||
/// Get default material.
|
||||
virtual AZStd::shared_ptr<Physics::Material> GetGenericDefaultMaterial() = 0;
|
||||
|
||||
/// Returns weak pointers to physics materials.
|
||||
/// Connect to PhysicsMaterialNotifications::MaterialsReleased to be informed when material pointers are deleted by owner.
|
||||
virtual void GetMaterials(const MaterialSelection& materialSelection
|
||||
, AZStd::vector<AZStd::weak_ptr<Physics::Material>>& outMaterials) = 0;
|
||||
, AZStd::vector<AZStd::shared_ptr<Physics::Material>>& outMaterials) = 0;
|
||||
|
||||
/// Returns a weak pointer to physics material with the given id.
|
||||
virtual AZStd::shared_ptr<Physics::Material> GetMaterialById(Physics::MaterialId id) = 0;
|
||||
|
||||
/// Returns a weak pointer to physics material with the given name.
|
||||
virtual AZStd::weak_ptr<Physics::Material> GetMaterialByName(const AZStd::string& name) = 0;
|
||||
virtual AZStd::shared_ptr<Physics::Material> GetMaterialByName(const AZStd::string& name) = 0;
|
||||
|
||||
/// Returns index of the first selected material in MaterialSelection's material library.
|
||||
/// A MaterialSelection can contain multiple material selections.
|
||||
/// Returned index is 0-based where 0 is the Default material, and materials from the material library are 1 and onwards.
|
||||
virtual AZ::u32 GetFirstSelectedMaterialIndex(const MaterialSelection& materialSelection) = 0;
|
||||
/// Updates the material selection from the physics asset or sets it to default if there's no asset provided.
|
||||
/// @param shapeConfiguration The shape information that contains the physics asset.
|
||||
/// @param materialSelection The material selection to update.
|
||||
virtual void UpdateMaterialSelectionFromPhysicsAsset(
|
||||
const ShapeConfiguration& shapeConfiguration,
|
||||
MaterialSelection& materialSelection) = 0;
|
||||
};
|
||||
using PhysicsMaterialRequestBus = AZ::EBus<PhysicsMaterialRequests>;
|
||||
|
||||
|
||||
@@ -130,13 +130,6 @@ namespace AzPhysics
|
||||
//! @param forceReinitialization Flag to force a reinitialization of the physics system. Default false.
|
||||
virtual void UpdateConfiguration(const SystemConfiguration* newConfig, bool forceReinitialization = false) = 0;
|
||||
|
||||
//! Update the default material library.
|
||||
//! @param materialLibrary The new material library asset to use.
|
||||
virtual void UpdateDefaultMaterialLibrary(const AZ::Data::Asset<Physics::MaterialLibraryAsset>& materialLibrary) = 0;
|
||||
|
||||
//! Accessor to get the current Material Library. This is also available in the PhysXSystemConfiguration.
|
||||
virtual const AZ::Data::Asset<Physics::MaterialLibraryAsset>& GetDefaultMaterialLibrary() const = 0;
|
||||
|
||||
//! Update the current default scene configuration.
|
||||
//! This is the configuration used to to create scenes without a custom configuration.
|
||||
//! @param sceneConfiguration The new configuration to apply.
|
||||
@@ -169,9 +162,12 @@ namespace AzPhysics
|
||||
//! Register to receive notifications when the SystemConfiguration changes.
|
||||
//! @param handler The handler to receive the event.
|
||||
void RegisterSystemConfigurationChangedEvent(SystemEvents::OnConfigurationChangedEvent::Handler& handler) { handler.Connect(m_configChangeEvent); }
|
||||
//! Register a handler to receive an event when the default material library changes.
|
||||
//! Register a handler to receive an event when the material library changes.
|
||||
//! @param handler The handler to receive the event.
|
||||
void RegisterOnDefaultMaterialLibraryChangedEventHandler(SystemEvents::OnDefaultMaterialLibraryChangedEvent::Handler& handler) { handler.Connect(m_onDefaultMaterialLibraryChangedEvent); }
|
||||
void RegisterOnMaterialLibraryChangedEventHandler(SystemEvents::OnMaterialLibraryChangedEvent::Handler& handler) { handler.Connect(m_onMaterialLibraryChangedEvent); }
|
||||
//! Register a handler to receive an event when the material library fails to load on startup.
|
||||
//! @param handler The handler to receive the event.
|
||||
void RegisterOnMaterialLibraryLoadErrorEventHandler(SystemEvents::OnMaterialLibraryLoadErrorEvent::Handler& handler) { handler.Connect(m_onMaterialLibraryLoadErrorEvent); }
|
||||
//! Register a handler to receive an event when the default SceneConfiguration changes.
|
||||
//! @param handler The handler to receive the event.
|
||||
void RegisterOnDefaultSceneConfigurationChangedEventHandler(SystemEvents::OnDefaultSceneConfigurationChangedEvent::Handler& handler) { handler.Connect(m_onDefaultSceneConfigurationChangedEvent); }
|
||||
@@ -185,7 +181,8 @@ namespace AzPhysics
|
||||
SystemEvents::OnSceneAddedEvent m_sceneAddedEvent;
|
||||
SystemEvents::OnSceneRemovedEvent m_sceneRemovedEvent;
|
||||
SystemEvents::OnConfigurationChangedEvent m_configChangeEvent;
|
||||
SystemEvents::OnDefaultMaterialLibraryChangedEvent m_onDefaultMaterialLibraryChangedEvent;
|
||||
SystemEvents::OnMaterialLibraryChangedEvent m_onMaterialLibraryChangedEvent;
|
||||
SystemEvents::OnMaterialLibraryLoadErrorEvent m_onMaterialLibraryLoadErrorEvent;
|
||||
SystemEvents::OnDefaultSceneConfigurationChangedEvent m_onDefaultSceneConfigurationChangedEvent;
|
||||
};
|
||||
} // namespace AzPhysics
|
||||
|
||||
@@ -17,6 +17,21 @@
|
||||
|
||||
namespace Physics
|
||||
{
|
||||
namespace Internal
|
||||
{
|
||||
bool ShapeConfigurationVersionConverter(
|
||||
[[maybe_unused]] AZ::SerializeContext& context,
|
||||
AZ::SerializeContext::DataElementNode& classElement)
|
||||
{
|
||||
if (classElement.GetVersion() <= 1)
|
||||
{
|
||||
classElement.RemoveElementByName(AZ_CRC_CE("UseMaterialsFromAsset"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeConfiguration::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
@@ -166,10 +181,9 @@ namespace Physics
|
||||
->RegisterGenericType<AZStd::shared_ptr<PhysicsAssetShapeConfiguration>>();
|
||||
|
||||
serializeContext->Class<PhysicsAssetShapeConfiguration, ShapeConfiguration>()
|
||||
->Version(1)
|
||||
->Version(2, &Internal::ShapeConfigurationVersionConverter)
|
||||
->Field("PhysicsAsset", &PhysicsAssetShapeConfiguration::m_asset)
|
||||
->Field("AssetScale", &PhysicsAssetShapeConfiguration::m_assetScale)
|
||||
->Field("UseMaterialsFromAsset", &PhysicsAssetShapeConfiguration::m_useMaterialsFromAsset)
|
||||
->Field("SubdivisionLevel", &PhysicsAssetShapeConfiguration::m_subdivisionLevel)
|
||||
;
|
||||
|
||||
@@ -182,7 +196,6 @@ namespace Physics
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &PhysicsAssetShapeConfiguration::m_assetScale, "Asset Scale", "The scale of the asset shape")
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
|
||||
->Attribute(AZ::Edit::Attributes::Step, 0.01f)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &PhysicsAssetShapeConfiguration::m_useMaterialsFromAsset, "Physics Materials from Mesh", "Auto-set physics materials using Mesh's material surfaces names")
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace Physics
|
||||
|
||||
AZ::Data::Asset<AZ::Data::AssetData> m_asset{ AZ::Data::AssetLoadBehavior::PreLoad };
|
||||
AZ::Vector3 m_assetScale = AZ::Vector3::CreateOne();
|
||||
bool m_useMaterialsFromAsset = true;
|
||||
bool m_useMaterialsFromAsset = false; // Not reflected or exposed to the user until there is a way to auto-match mesh's materials with physics materials
|
||||
AZ::u8 m_subdivisionLevel = 4; ///< The level of subdivision if a primitive shape is replaced with a convex mesh due to scaling.
|
||||
};
|
||||
|
||||
|
||||
@@ -142,24 +142,12 @@ namespace Physics
|
||||
|
||||
virtual AZStd::shared_ptr<Shape> CreateShape(const ColliderConfiguration& colliderConfiguration, const ShapeConfiguration& configuration) = 0;
|
||||
|
||||
virtual AZStd::shared_ptr<Material> CreateMaterial(const Physics::MaterialConfiguration& materialConfiguration) = 0;
|
||||
|
||||
/// Releases the mesh object created by the physics backend.
|
||||
/// @param nativeMeshObject Pointer to the mesh object.
|
||||
virtual void ReleaseNativeMeshObject(void* nativeMeshObject) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Physics Materials
|
||||
|
||||
virtual AZStd::shared_ptr<Material> CreateMaterial(const Physics::MaterialConfiguration& materialConfiguration) = 0;
|
||||
virtual AZStd::shared_ptr<Material> GetDefaultMaterial() = 0;
|
||||
virtual AZStd::vector<AZStd::shared_ptr<Material>> CreateMaterialsFromLibrary(const Physics::MaterialSelection& materialSelection) = 0;
|
||||
|
||||
|
||||
/// Updates the collider material selection from the physics asset or sets it to default if there's no asset provided.
|
||||
/// @param shapeConfiguration The shape information
|
||||
/// @param colliderConfiguration The collider information
|
||||
virtual bool UpdateMaterialSelection(const Physics::ShapeConfiguration& shapeConfiguration,
|
||||
Physics::ColliderConfiguration& colliderConfiguration) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Joints
|
||||
|
||||
|
||||
@@ -119,8 +119,7 @@ namespace Physics
|
||||
AzPhysics::SceneConfiguration::Reflect(context);
|
||||
MaterialConfiguration::Reflect(context);
|
||||
MaterialLibraryAsset::Reflect(context);
|
||||
MaterialLibraryAssetReflectionWrapper::Reflect(context);
|
||||
DefaultMaterialLibraryAssetReflectionWrapper::Reflect(context);
|
||||
MaterialInfoReflectionWrapper::Reflect(context);
|
||||
JointLimitConfiguration::Reflect(context);
|
||||
AzPhysics::SimulatedBodyConfiguration::Reflect(context);
|
||||
AzPhysics::RigidBodyConfiguration::Reflect(context);
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace AzFramework::ProjectManager
|
||||
projectJsonPath.c_str());
|
||||
}
|
||||
|
||||
if (LaunchProjectManager(engineRootPath))
|
||||
if (LaunchProjectManager())
|
||||
{
|
||||
AZ_TracePrintf("ProjectManager", "Project Manager launched successfully, requesting exit.");
|
||||
return ProjectPathCheckResult::ProjectManagerLaunched;
|
||||
@@ -87,7 +87,7 @@ namespace AzFramework::ProjectManager
|
||||
return ProjectPathCheckResult::ProjectManagerLaunchFailed;
|
||||
}
|
||||
|
||||
bool LaunchProjectManager([[maybe_unused]] const AZ::IO::FixedMaxPath& engineRootPath)
|
||||
bool LaunchProjectManager(const AZStd::string& commandLineArgs)
|
||||
{
|
||||
bool launchSuccess = false;
|
||||
#if (AZ_TRAIT_AZFRAMEWORK_USE_PROJECT_MANAGER)
|
||||
@@ -109,7 +109,7 @@ namespace AzFramework::ProjectManager
|
||||
}
|
||||
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
processLaunchInfo.m_commandlineParameters = executablePath.String();
|
||||
processLaunchInfo.m_commandlineParameters = executablePath.String() + commandLineArgs;
|
||||
launchSuccess = AzFramework::ProcessLauncher::LaunchUnwatchedProcess(processLaunchInfo);
|
||||
}
|
||||
if (ownsSystemAllocator)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/IO/Path/Path_fwd.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
namespace AzFramework::ProjectManager
|
||||
{
|
||||
@@ -21,8 +22,16 @@ namespace AzFramework::ProjectManager
|
||||
ProjectManagerLaunched = 0,
|
||||
ProjectPathFound = 1
|
||||
};
|
||||
// Check for a project name, if not found, attempts to launch project manager and returns false
|
||||
|
||||
//! Check for a project name, if not found, attempts to launch project manager and returns false
|
||||
//! @param argc the number of arguments in argv
|
||||
//! @param argv arguments provided to this executable
|
||||
//! @return a ProjectPathCheckResult
|
||||
ProjectPathCheckResult CheckProjectPathProvided(const int argc, char* argv[]);
|
||||
// Attempt to Launch the project manager. Requires locating the engine root, project manager script, and python.
|
||||
bool LaunchProjectManager(const AZ::IO::FixedMaxPath& engineRootPath);
|
||||
|
||||
//! Attempt to Launch the project manager, assuming the o3de executable exists in same folder as
|
||||
//! current executable. Requires the o3de cli and python.
|
||||
//! @param commandLineArgs additional command line arguments to provide to the project manager
|
||||
//! @return true on success, false if failed to find or launch the executable
|
||||
bool LaunchProjectManager(const AZStd::string& commandLineArgs = "");
|
||||
} // AzFramework::ProjectManager
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzFramework/Entity/EntityContextBus.h>
|
||||
#include <AzFramework/Render/GeometryIntersectionStructures.h>
|
||||
|
||||
namespace AzFramework
|
||||
@@ -35,12 +36,12 @@ namespace AzFramework
|
||||
AzFramework::EntityContextId m_contextId;
|
||||
};
|
||||
|
||||
//! Interface for intersection requests, implement this interface for making your component
|
||||
//! render geometry intersectable.
|
||||
//! Interface for intersection requests.
|
||||
//! Implement this interface to make your component 'intersectable'.
|
||||
class IntersectionRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
//! Policy for notifying the Intersector bus of entities connected/disconnected to this ebus
|
||||
//! Policy for notifying the Intersector bus of entities connected/disconnected to this EBus
|
||||
//! so it updates the internal data of the entities
|
||||
template<class Bus>
|
||||
struct IntersectionRequestsConnectionPolicy
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
namespace AzFramework
|
||||
@@ -49,13 +50,17 @@ namespace AzFramework
|
||||
class ISessionHandlingClientRequests
|
||||
{
|
||||
public:
|
||||
// Handle the player join session process
|
||||
AZ_RTTI(ISessionHandlingClientRequests, "{41DE6BD3-72BC-4443-BFF9-5B1B9396657A}");
|
||||
ISessionHandlingClientRequests() = default;
|
||||
virtual ~ISessionHandlingClientRequests() = default;
|
||||
|
||||
// Request the player join session
|
||||
// @param sessionConnectionConfig The required properties to handle the player join session process
|
||||
// @return The result of player join session process
|
||||
virtual bool HandlePlayerJoinSession(const SessionConnectionConfig& sessionConnectionConfig) = 0;
|
||||
virtual bool RequestPlayerJoinSession(const SessionConnectionConfig& sessionConnectionConfig) = 0;
|
||||
|
||||
// Handle the player leave session process
|
||||
virtual void HandlePlayerLeaveSession() = 0;
|
||||
// Request the connected player leave session
|
||||
virtual void RequestPlayerLeaveSession() = 0;
|
||||
};
|
||||
|
||||
//! ISessionHandlingServerRequests
|
||||
@@ -63,6 +68,10 @@ namespace AzFramework
|
||||
class ISessionHandlingServerRequests
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ISessionHandlingServerRequests, "{4F0C17BA-F470-4242-A8CB-EC7EA805257C}");
|
||||
ISessionHandlingServerRequests() = default;
|
||||
virtual ~ISessionHandlingServerRequests() = default;
|
||||
|
||||
// Handle the destroy session process
|
||||
virtual void HandleDestroySession() = 0;
|
||||
|
||||
@@ -74,5 +83,10 @@ namespace AzFramework
|
||||
// Handle the player leave session process
|
||||
// @param playerConnectionConfig The required properties to handle the player leave session process
|
||||
virtual void HandlePlayerLeaveSession(const PlayerConnectionConfig& playerConnectionConfig) = 0;
|
||||
|
||||
// Retrieves the file location of a pem-encoded TLS certificate
|
||||
// @return If successful, returns the file location of TLS certificate file; if not successful, returns
|
||||
// empty string.
|
||||
virtual AZStd::string GetSessionCertificate() = 0;
|
||||
};
|
||||
} // namespace AzFramework
|
||||
|
||||
@@ -167,6 +167,9 @@ namespace AzFramework
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
// Safeguard handler for multi-threaded use case
|
||||
using MutexType = AZStd::recursive_mutex;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace AzFramework
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
// Safeguard handler for multi-threaded use case
|
||||
using MutexType = AZStd::recursive_mutex;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
|
||||
@@ -21,22 +21,6 @@ namespace AzFramework
|
||||
{
|
||||
}
|
||||
|
||||
Spawnable::Spawnable(Spawnable&& other)
|
||||
: m_entities(AZStd::move(other.m_entities))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Spawnable& Spawnable::operator=(Spawnable&& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
m_entities = AZStd::move(other.m_entities);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const Spawnable::EntityList& Spawnable::GetEntities() const
|
||||
{
|
||||
return m_entities;
|
||||
|
||||
@@ -41,11 +41,11 @@ namespace AzFramework
|
||||
Spawnable() = default;
|
||||
explicit Spawnable(const AZ::Data::AssetId& id, AssetStatus status = AssetStatus::NotLoaded);
|
||||
Spawnable(const Spawnable& rhs) = delete;
|
||||
Spawnable(Spawnable&& other);
|
||||
Spawnable(Spawnable&& other) = delete;
|
||||
~Spawnable() override = default;
|
||||
|
||||
Spawnable& operator=(const Spawnable& rhs) = delete;
|
||||
Spawnable& operator=(Spawnable&& other);
|
||||
Spawnable& operator=(Spawnable&& other) = delete;
|
||||
|
||||
const EntityList& GetEntities() const;
|
||||
EntityList& GetEntities();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Casting/lossy_cast.h>
|
||||
#include <AzCore/Serialization/Utils.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzFramework/Spawnable/Spawnable.h>
|
||||
@@ -88,4 +89,10 @@ namespace AzFramework
|
||||
{
|
||||
extensions.push_back(Spawnable::FileExtension);
|
||||
}
|
||||
|
||||
uint32_t SpawnableAssetHandler::BuildSubId(AZStd::string_view id)
|
||||
{
|
||||
AZ::Uuid subIdHash = AZ::Uuid::CreateData(id.data(), id.size());
|
||||
return azlossy_caster(subIdHash.GetHash());
|
||||
}
|
||||
} // namespace AzFramework
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace AzFramework
|
||||
const char* GetGroup() const override;
|
||||
const char* GetBrowserIcon() const override;
|
||||
void GetAssetTypeExtensions(AZStd::vector<AZStd::string>& extensions) override;
|
||||
static uint32_t BuildSubId(AZStd::string_view id);
|
||||
|
||||
protected:
|
||||
LoadResult LoadAssetData(
|
||||
|
||||
@@ -38,19 +38,20 @@ namespace AzFramework
|
||||
void SpawnableEntitiesContainer::SpawnAllEntities()
|
||||
{
|
||||
AZ_Assert(m_threadData, "Calling SpawnAllEntities on a Spawnable container that's not set.");
|
||||
SpawnableEntitiesInterface::Get()->SpawnAllEntities(m_threadData->m_spawnedEntitiesTicket);
|
||||
SpawnableEntitiesInterface::Get()->SpawnAllEntities(m_threadData->m_spawnedEntitiesTicket, SpawnablePriority_Default);
|
||||
}
|
||||
|
||||
void SpawnableEntitiesContainer::SpawnEntities(AZStd::vector<size_t> entityIndices)
|
||||
{
|
||||
AZ_Assert(m_threadData, "Calling SpawnEntities on a Spawnable container that's not set.");
|
||||
SpawnableEntitiesInterface::Get()->SpawnEntities(m_threadData->m_spawnedEntitiesTicket, AZStd::move(entityIndices));
|
||||
SpawnableEntitiesInterface::Get()->SpawnEntities(
|
||||
m_threadData->m_spawnedEntitiesTicket, SpawnablePriority_Default, AZStd::move(entityIndices));
|
||||
}
|
||||
|
||||
void SpawnableEntitiesContainer::DespawnAllEntities()
|
||||
{
|
||||
AZ_Assert(m_threadData, "Calling DespawnEntities on a Spawnable container that's not set.");
|
||||
SpawnableEntitiesInterface::Get()->DespawnAllEntities(m_threadData->m_spawnedEntitiesTicket);
|
||||
SpawnableEntitiesInterface::Get()->DespawnAllEntities(m_threadData->m_spawnedEntitiesTicket, SpawnablePriority_Default);
|
||||
}
|
||||
|
||||
void SpawnableEntitiesContainer::Reset(AZ::Data::Asset<Spawnable> spawnable)
|
||||
@@ -66,8 +67,10 @@ namespace AzFramework
|
||||
m_monitor.Disconnect();
|
||||
m_monitor.m_threadData.reset();
|
||||
|
||||
SpawnableEntitiesInterface::Get()->Barrier(m_threadData->m_spawnedEntitiesTicket,
|
||||
[threadData = m_threadData](EntitySpawnTicket&) mutable
|
||||
SpawnableEntitiesInterface::Get()->Barrier(
|
||||
m_threadData->m_spawnedEntitiesTicket,
|
||||
SpawnablePriority_Default,
|
||||
[threadData = m_threadData](EntitySpawnTicket::Id) mutable
|
||||
{
|
||||
threadData.reset();
|
||||
});
|
||||
@@ -83,8 +86,10 @@ namespace AzFramework
|
||||
void SpawnableEntitiesContainer::Alert(AlertCallback callback)
|
||||
{
|
||||
AZ_Assert(m_threadData, "Calling DespawnEntities on a Spawnable container that's not set.");
|
||||
SpawnableEntitiesInterface::Get()->Barrier(m_threadData->m_spawnedEntitiesTicket,
|
||||
[generation = m_threadData->m_generation, callback = AZStd::move(callback)](EntitySpawnTicket&)
|
||||
SpawnableEntitiesInterface::Get()->Barrier(
|
||||
m_threadData->m_spawnedEntitiesTicket,
|
||||
SpawnablePriority_Default,
|
||||
[generation = m_threadData->m_generation, callback = AZStd::move(callback)](EntitySpawnTicket::Id)
|
||||
{
|
||||
callback(generation);
|
||||
});
|
||||
@@ -110,6 +115,7 @@ namespace AzFramework
|
||||
AZ_Assert(m_threadData, "SpawnableEntitiesContainer is monitoring a spawnable, but doesn't have the associated data.");
|
||||
|
||||
AZ_TracePrintf("Spawnables", "Reloading spawnable '%s'.\n", replacementAsset.GetHint().c_str());
|
||||
SpawnableEntitiesInterface::Get()->ReloadSpawnable(m_threadData->m_spawnedEntitiesTicket, AZStd::move(replacementAsset));
|
||||
SpawnableEntitiesInterface::Get()->ReloadSpawnable(
|
||||
m_threadData->m_spawnedEntitiesTicket, SpawnablePriority_Default, AZStd::move(replacementAsset));
|
||||
}
|
||||
} // namespace AzFramework
|
||||
|
||||
@@ -239,7 +239,9 @@ namespace AzFramework
|
||||
{
|
||||
auto manager = SpawnableEntitiesInterface::Get();
|
||||
AZ_Assert(manager, "Attempting to create an entity spawn ticket while the SpawnableEntitiesInterface has no implementation.");
|
||||
m_payload = manager->CreateTicket(AZStd::move(spawnable));
|
||||
AZStd::pair<EntitySpawnTicket::Id, void*> result = manager->CreateTicket(AZStd::move(spawnable));
|
||||
m_id = result.first;
|
||||
m_payload = result.second;
|
||||
}
|
||||
|
||||
EntitySpawnTicket::~EntitySpawnTicket()
|
||||
@@ -250,6 +252,7 @@ namespace AzFramework
|
||||
AZ_Assert(manager, "Attempting to destroy an entity spawn ticket while the SpawnableEntitiesInterface has no implementation.");
|
||||
manager->DestroyTicket(m_payload);
|
||||
m_payload = nullptr;
|
||||
m_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,12 +266,20 @@ namespace AzFramework
|
||||
AZ_Assert(manager, "Attempting to destroy an entity spawn ticket while the SpawnableEntitiesInterface has no implementation.");
|
||||
manager->DestroyTicket(m_payload);
|
||||
}
|
||||
m_id = rhs.m_id;
|
||||
rhs.m_id = 0;
|
||||
|
||||
m_payload = rhs.m_payload;
|
||||
rhs.m_payload = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto EntitySpawnTicket::GetId() const -> Id
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
bool EntitySpawnTicket::IsValid() const
|
||||
{
|
||||
return m_payload != nullptr;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/RTTI/TypeSafeIntegral.h>
|
||||
#include <AzCore/std/functional.h>
|
||||
#include <AzFramework/Spawnable/Spawnable.h>
|
||||
|
||||
@@ -24,6 +25,14 @@ namespace AZ
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
AZ_TYPE_SAFE_INTEGRAL(SpawnablePriority, uint8_t);
|
||||
|
||||
inline static constexpr SpawnablePriority SpawnablePriority_Highest { 0 };
|
||||
inline static constexpr SpawnablePriority SpawnablePriority_High { 32 };
|
||||
inline static constexpr SpawnablePriority SpawnablePriority_Default { 128 };
|
||||
inline static constexpr SpawnablePriority SpawnablePriority_Low { 192 };
|
||||
inline static constexpr SpawnablePriority SpawnablePriority_Lowest { 255 };
|
||||
|
||||
class SpawnableEntityContainerView
|
||||
{
|
||||
public:
|
||||
@@ -124,16 +133,18 @@ namespace AzFramework
|
||||
SpawnableIndexEntityIterator m_end;
|
||||
};
|
||||
|
||||
//! Requests to the SpawnableEntitiesInterface require a ticket with a valid spawnable that be used as a template. A ticket can
|
||||
//! be reused for multiple calls on the same spawnable and is safe to use by multiple threads at the same time. Entities created
|
||||
//! Requests to the SpawnableEntitiesInterface require a ticket with a valid spawnable that is used as a template. A ticket can
|
||||
//! be reused for multiple calls on the same spawnable and is safe to be used by multiple threads at the same time. Entities created
|
||||
//! from the spawnable may be tracked by the ticket and so using the same ticket is needed to despawn the exact entities created
|
||||
//! by a call so spawn entities. The life cycle of the spawned entities is tied to the ticket and all entities spawned using a
|
||||
//! by a call to spawn entities. The life cycle of the spawned entities is tied to the ticket and all entities spawned using a
|
||||
//! ticket will be despawned when it's deleted.
|
||||
class EntitySpawnTicket
|
||||
{
|
||||
public:
|
||||
friend class SpawnableEntitiesDefinition;
|
||||
|
||||
using Id = uint64_t;
|
||||
|
||||
EntitySpawnTicket() = default;
|
||||
EntitySpawnTicket(const EntitySpawnTicket&) = delete;
|
||||
EntitySpawnTicket(EntitySpawnTicket&& rhs);
|
||||
@@ -143,26 +154,37 @@ namespace AzFramework
|
||||
EntitySpawnTicket& operator=(const EntitySpawnTicket&) = delete;
|
||||
EntitySpawnTicket& operator=(EntitySpawnTicket&& rhs);
|
||||
|
||||
Id GetId() const;
|
||||
bool IsValid() const;
|
||||
|
||||
private:
|
||||
void* m_payload{ nullptr };
|
||||
Id m_id { 0 }; //!< An id that uniquely identifies a ticket.
|
||||
};
|
||||
|
||||
using EntitySpawnCallback = AZStd::function<void(EntitySpawnTicket&, SpawnableConstEntityContainerView)>;
|
||||
using EntityPreInsertionCallback = AZStd::function<void(EntitySpawnTicket&, SpawnableEntityContainerView)>;
|
||||
using EntityDespawnCallback = AZStd::function<void(EntitySpawnTicket&)>;
|
||||
using ReloadSpawnableCallback = AZStd::function<void(EntitySpawnTicket&, SpawnableConstEntityContainerView)>;
|
||||
using ListEntitiesCallback = AZStd::function<void(EntitySpawnTicket&, SpawnableConstEntityContainerView)>;
|
||||
using ListIndicesEntitiesCallback = AZStd::function<void(EntitySpawnTicket&, SpawnableConstIndexEntityContainerView)>;
|
||||
using ClaimEntitiesCallback = AZStd::function<void(EntitySpawnTicket&, SpawnableEntityContainerView)>;
|
||||
using BarrierCallback = AZStd::function<void(EntitySpawnTicket&)>;
|
||||
using EntitySpawnCallback = AZStd::function<void(EntitySpawnTicket::Id, SpawnableConstEntityContainerView)>;
|
||||
using EntityPreInsertionCallback = AZStd::function<void(EntitySpawnTicket::Id, SpawnableEntityContainerView)>;
|
||||
using EntityDespawnCallback = AZStd::function<void(EntitySpawnTicket::Id)>;
|
||||
using ReloadSpawnableCallback = AZStd::function<void(EntitySpawnTicket::Id, SpawnableConstEntityContainerView)>;
|
||||
using ListEntitiesCallback = AZStd::function<void(EntitySpawnTicket::Id, SpawnableConstEntityContainerView)>;
|
||||
using ListIndicesEntitiesCallback = AZStd::function<void(EntitySpawnTicket::Id, SpawnableConstIndexEntityContainerView)>;
|
||||
using ClaimEntitiesCallback = AZStd::function<void(EntitySpawnTicket::Id, SpawnableEntityContainerView)>;
|
||||
using BarrierCallback = AZStd::function<void(EntitySpawnTicket::Id)>;
|
||||
|
||||
//! Interface definition to (de)spawn entities from a spawnable into the game world.
|
||||
//!
|
||||
//! While the callbacks of the individual calls are being processed they will block processing any other request. Callbacks can be
|
||||
//! issued from threads other than the one that issued the call, including the main thread.
|
||||
//!
|
||||
//! Calls on the same ticket are guaranteed to be executed in the order they are issued. Note that when issuing requests from
|
||||
//! multiple threads on the same ticket the order in which the requests are assigned to the ticket is not guaranteed.
|
||||
//!
|
||||
//! Most calls have a priority with values that range from 0 (highest priority) to 255 (lowest priority). The implementation of this
|
||||
//! interface may choose to use priority lanes which doesn't guarantee that higher priority requests happen before lower priority
|
||||
//! requests if they don't pass the priority lane threshold. Priority lanes and their thresholds are implementation specific and may
|
||||
//! differ between platforms. Note that if a call happened on a ticket with lower priority followed by a one with a higher priority
|
||||
//! the first lower priority call will still need to complete before the second higher priority call can be executed and the priority
|
||||
//! of the first call will not be updated.
|
||||
class SpawnableEntitiesDefinition
|
||||
{
|
||||
public:
|
||||
@@ -173,40 +195,48 @@ namespace AzFramework
|
||||
virtual ~SpawnableEntitiesDefinition() = default;
|
||||
|
||||
//! Spawn instances of all entities in the spawnable.
|
||||
//! @param spawnable The Spawnable asset that will be used to create entity instances from.
|
||||
//! @param ticket Stores the results of the call. Use this ticket to spawn additional entities or to despawn them.
|
||||
//! @param priority The priority at which this call will be executed.
|
||||
//! @param completionCallback Optional callback that's called when spawning entities has completed. This can be called from
|
||||
//! a different thread than the one that made the function call. The returned list of entities contains all the newly
|
||||
//! created entities.
|
||||
virtual void SpawnAllEntities(EntitySpawnTicket& ticket, EntityPreInsertionCallback preInsertionCallback = {},
|
||||
virtual void SpawnAllEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, EntityPreInsertionCallback preInsertionCallback = {},
|
||||
EntitySpawnCallback completionCallback = {}) = 0;
|
||||
//! Spawn instances of some entities in the spawnable.
|
||||
//! @param ticket Stores the results of the call. Use this ticket to spawn additional entities or to despawn them.
|
||||
//! @param priority The priority at which this call will be executed.
|
||||
//! @param entityIndices The indices into the template entities stored in the spawnable that will be used to spawn entities from.
|
||||
//! @param completionCallback Optional callback that's called when spawning entities has completed. This can be called from
|
||||
//! a different thread than the one that made this function call. The returned list of entities contains all the newly
|
||||
//! created entities.
|
||||
virtual void SpawnEntities(EntitySpawnTicket& ticket, AZStd::vector<size_t> entityIndices,
|
||||
virtual void SpawnEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, AZStd::vector<size_t> entityIndices,
|
||||
EntityPreInsertionCallback preInsertionCallback = {}, EntitySpawnCallback completionCallback = {}) = 0;
|
||||
//! Removes all entities in the provided list from the environment.
|
||||
//! @param ticket The ticket previously used to spawn entities with.
|
||||
//! @param priority The priority at which this call will be executed.
|
||||
//! @param completionCallback Optional callback that's called when despawning entities has completed. This can be called from
|
||||
//! a different thread than the one that made this function call.
|
||||
virtual void DespawnAllEntities(EntitySpawnTicket& ticket, EntityDespawnCallback completionCallback = {}) = 0;
|
||||
virtual void DespawnAllEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, EntityDespawnCallback completionCallback = {}) = 0;
|
||||
|
||||
//! Removes all entities in the provided list from the environment and reconstructs the entities from the provided spawnable.
|
||||
//! @param ticket Stores the results of the call. Use this ticket to spawn additional entities or to despawn them.
|
||||
//! @param ticket Holds the information on the entities to reload.
|
||||
//! @param priority The priority at which this call will be executed.
|
||||
//! @param spawnable The spawnable that will replace the existing spawnable. Both need to have the same asset id.
|
||||
//! @param completionCallback Optional callback that's called when the entities have been reloaded. This can be called from
|
||||
//! a different thread than the one that made this function call. The returned list of entities contains all the replacement
|
||||
//! entities.
|
||||
virtual void ReloadSpawnable(EntitySpawnTicket& ticket, AZ::Data::Asset<Spawnable> spawnable,
|
||||
virtual void ReloadSpawnable(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, AZ::Data::Asset<Spawnable> spawnable,
|
||||
ReloadSpawnableCallback completionCallback = {}) = 0;
|
||||
|
||||
//! List all entities that are spawned using this ticket.
|
||||
//! @param ticket Only the entities associated with this ticket will be listed.
|
||||
//! @param priority The priority at which this call will be executed.
|
||||
//! @param listCallback Required callback that will be called to list the entities on.
|
||||
virtual void ListEntities(EntitySpawnTicket& ticket, ListEntitiesCallback listCallback) = 0;
|
||||
virtual void ListEntities(EntitySpawnTicket& ticket, SpawnablePriority priority, ListEntitiesCallback listCallback) = 0;
|
||||
//! List all entities that are spawned using this ticket with their spawnable index.
|
||||
//! Spawnables contain a flat list of entities, which are used as templates to spawn entities from. For every spawned entity
|
||||
//! the index of the entity in the spawnable that was used as a template is stored. This version of ListEntities will return
|
||||
@@ -214,17 +244,23 @@ namespace AzFramework
|
||||
//! the same index may appear multiple times as there are no restriction on how many instance of a specific entity can be
|
||||
//! created.
|
||||
//! @param ticket Only the entities associated with this ticket will be listed.
|
||||
//! @param priority The priority at which this call will be executed.
|
||||
//! @param listCallback Required callback that will be called to list the entities and indices on.
|
||||
virtual void ListIndicesAndEntities(EntitySpawnTicket& ticket, ListIndicesEntitiesCallback listCallback) = 0;
|
||||
virtual void ListIndicesAndEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, ListIndicesEntitiesCallback listCallback) = 0;
|
||||
//! Claim all entities that are spawned using this ticket. Ownership of the entities is transferred from the ticket to the
|
||||
//! caller through the callback. After this call the ticket will have no entities associated with it. The caller of
|
||||
//! this function will need to manage the entities after this call.
|
||||
//! @param ticket Only the entities associated with this ticket will be released.
|
||||
//! @param priority The priority at which this call will be executed.
|
||||
//! @param listCallback Required callback that will be called to transfer the entities through.
|
||||
virtual void ClaimEntities(EntitySpawnTicket& ticket, ClaimEntitiesCallback listCallback) = 0;
|
||||
virtual void ClaimEntities(EntitySpawnTicket& ticket, SpawnablePriority priority, ClaimEntitiesCallback listCallback) = 0;
|
||||
|
||||
//! Blocks until all operations made on the provided ticket before the barrier call have completed.
|
||||
virtual void Barrier(EntitySpawnTicket& ticket, BarrierCallback completionCallback) = 0;
|
||||
//! @param ticket The ticket to monitor.
|
||||
//! @param priority The priority at which this call will be executed.
|
||||
//! @param completionCallback Required callback that will be called as soon as the barrier has been reached.
|
||||
virtual void Barrier(EntitySpawnTicket& ticket, SpawnablePriority priority, BarrierCallback completionCallback) = 0;
|
||||
|
||||
//! Register a handler for OnSpawned events.
|
||||
virtual void AddOnSpawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler) = 0;
|
||||
@@ -233,7 +269,7 @@ namespace AzFramework
|
||||
virtual void AddOnDespawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler) = 0;
|
||||
|
||||
protected:
|
||||
[[nodiscard]] virtual void* CreateTicket(AZ::Data::Asset<Spawnable>&& spawnable) = 0;
|
||||
[[nodiscard]] virtual AZStd::pair<EntitySpawnTicket::Id, void*> CreateTicket(AZ::Data::Asset<Spawnable>&& spawnable) = 0;
|
||||
virtual void DestroyTicket(void* ticket) = 0;
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Serialization/IdUtils.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzCore/std/parallel/scoped_lock.h>
|
||||
#include <AzCore/std/smart_ptr/make_shared.h>
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
@@ -22,128 +24,122 @@
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
void SpawnableEntitiesManager::SpawnAllEntities(EntitySpawnTicket& ticket, EntityPreInsertionCallback preInsertionCallback,
|
||||
template<typename T>
|
||||
void SpawnableEntitiesManager::QueueRequest(EntitySpawnTicket& ticket, SpawnablePriority priority, T&& request)
|
||||
{
|
||||
request.m_ticket = &GetTicketPayload<Ticket>(ticket);
|
||||
Queue& queue = priority <= m_highPriorityThreshold ? m_highPriorityQueue : m_regularPriorityQueue;
|
||||
{
|
||||
AZStd::scoped_lock queueLock(queue.m_pendingRequestMutex);
|
||||
request.m_requestId = GetTicketPayload<Ticket>(ticket).m_nextRequestId++;
|
||||
queue.m_pendingRequest.push(AZStd::move(request));
|
||||
}
|
||||
}
|
||||
|
||||
SpawnableEntitiesManager::SpawnableEntitiesManager()
|
||||
{
|
||||
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
|
||||
{
|
||||
AZ::u64 value = aznumeric_caster(m_highPriorityThreshold);
|
||||
settingsRegistry->Get(value, "/O3DE/AzFramework/Spawnables/HighPriorityThreshold");
|
||||
m_highPriorityThreshold = aznumeric_cast<SpawnablePriority>(AZStd::clamp(value, 0llu, 255llu));
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnableEntitiesManager::SpawnAllEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, EntityPreInsertionCallback preInsertionCallback,
|
||||
EntitySpawnCallback completionCallback)
|
||||
{
|
||||
AZ_Assert(ticket.IsValid(), "Ticket provided to SpawnAllEntities hasn't been initialized.");
|
||||
|
||||
SpawnAllEntitiesCommand queueEntry;
|
||||
queueEntry.m_ticket = &ticket;
|
||||
queueEntry.m_ticketId = ticket.GetId();
|
||||
queueEntry.m_completionCallback = AZStd::move(completionCallback);
|
||||
queueEntry.m_preInsertionCallback = AZStd::move(preInsertionCallback);
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
queueEntry.m_ticketId = GetTicketPayload<Ticket>(ticket).m_nextTicketId++;
|
||||
m_pendingRequestQueue.push(AZStd::move(queueEntry));
|
||||
}
|
||||
QueueRequest(ticket, priority, AZStd::move(queueEntry));
|
||||
}
|
||||
|
||||
void SpawnableEntitiesManager::SpawnEntities(
|
||||
EntitySpawnTicket& ticket, AZStd::vector<size_t> entityIndices,
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, AZStd::vector<size_t> entityIndices,
|
||||
EntityPreInsertionCallback preInsertionCallback, EntitySpawnCallback completionCallback)
|
||||
{
|
||||
AZ_Assert(ticket.IsValid(), "Ticket provided to SpawnEntities hasn't been initialized.");
|
||||
|
||||
SpawnEntitiesCommand queueEntry;
|
||||
queueEntry.m_ticket = &ticket;
|
||||
queueEntry.m_ticketId = ticket.GetId();
|
||||
queueEntry.m_entityIndices = AZStd::move(entityIndices);
|
||||
queueEntry.m_completionCallback = AZStd::move(completionCallback);
|
||||
queueEntry.m_preInsertionCallback = AZStd::move(preInsertionCallback);
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
queueEntry.m_ticketId = GetTicketPayload<Ticket>(ticket).m_nextTicketId++;
|
||||
m_pendingRequestQueue.push(AZStd::move(queueEntry));
|
||||
}
|
||||
QueueRequest(ticket, priority, AZStd::move(queueEntry));
|
||||
}
|
||||
|
||||
void SpawnableEntitiesManager::DespawnAllEntities(EntitySpawnTicket& ticket, EntityDespawnCallback completionCallback)
|
||||
void SpawnableEntitiesManager::DespawnAllEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, EntityDespawnCallback completionCallback)
|
||||
{
|
||||
AZ_Assert(ticket.IsValid(), "Ticket provided to DespawnAllEntities hasn't been initialized.");
|
||||
|
||||
DespawnAllEntitiesCommand queueEntry;
|
||||
queueEntry.m_ticket = &ticket;
|
||||
queueEntry.m_ticketId = ticket.GetId();
|
||||
queueEntry.m_completionCallback = AZStd::move(completionCallback);
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
queueEntry.m_ticketId = GetTicketPayload<Ticket>(ticket).m_nextTicketId++;
|
||||
m_pendingRequestQueue.push(AZStd::move(queueEntry));
|
||||
}
|
||||
QueueRequest(ticket, priority, AZStd::move(queueEntry));
|
||||
}
|
||||
|
||||
void SpawnableEntitiesManager::ReloadSpawnable(EntitySpawnTicket& ticket, AZ::Data::Asset<Spawnable> spawnable,
|
||||
void SpawnableEntitiesManager::ReloadSpawnable(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, AZ::Data::Asset<Spawnable> spawnable,
|
||||
ReloadSpawnableCallback completionCallback)
|
||||
{
|
||||
AZ_Assert(ticket.IsValid(), "Ticket provided to ReloadSpawnable hasn't been initialized.");
|
||||
|
||||
ReloadSpawnableCommand queueEntry;
|
||||
queueEntry.m_ticket = &ticket;
|
||||
queueEntry.m_ticketId = ticket.GetId();
|
||||
queueEntry.m_spawnable = AZStd::move(spawnable);
|
||||
queueEntry.m_completionCallback = AZStd::move(completionCallback);
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
queueEntry.m_ticketId = GetTicketPayload<Ticket>(ticket).m_nextTicketId++;
|
||||
m_pendingRequestQueue.push(AZStd::move(queueEntry));
|
||||
}
|
||||
QueueRequest(ticket, priority, AZStd::move(queueEntry));
|
||||
}
|
||||
|
||||
void SpawnableEntitiesManager::ListEntities(EntitySpawnTicket& ticket, ListEntitiesCallback listCallback)
|
||||
void SpawnableEntitiesManager::ListEntities(EntitySpawnTicket& ticket, SpawnablePriority priority, ListEntitiesCallback listCallback)
|
||||
{
|
||||
AZ_Assert(listCallback, "ListEntities called on spawnable entities without a valid callback to use.");
|
||||
AZ_Assert(ticket.IsValid(), "Ticket provided to ListEntities hasn't been initialized.");
|
||||
|
||||
ListEntitiesCommand queueEntry;
|
||||
queueEntry.m_ticket = &ticket;
|
||||
queueEntry.m_ticketId = ticket.GetId();
|
||||
queueEntry.m_listCallback = AZStd::move(listCallback);
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
queueEntry.m_ticketId = GetTicketPayload<Ticket>(ticket).m_nextTicketId++;
|
||||
m_pendingRequestQueue.push(AZStd::move(queueEntry));
|
||||
}
|
||||
QueueRequest(ticket, priority, AZStd::move(queueEntry));
|
||||
}
|
||||
|
||||
void SpawnableEntitiesManager::ListIndicesAndEntities(EntitySpawnTicket& ticket, ListIndicesEntitiesCallback listCallback)
|
||||
void SpawnableEntitiesManager::ListIndicesAndEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, ListIndicesEntitiesCallback listCallback)
|
||||
{
|
||||
AZ_Assert(listCallback, "ListEntities called on spawnable entities without a valid callback to use.");
|
||||
AZ_Assert(ticket.IsValid(), "Ticket provided to ListEntities hasn't been initialized.");
|
||||
|
||||
ListIndicesEntitiesCommand queueEntry;
|
||||
queueEntry.m_ticket = &ticket;
|
||||
queueEntry.m_ticketId = ticket.GetId();
|
||||
queueEntry.m_listCallback = AZStd::move(listCallback);
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
queueEntry.m_ticketId = GetTicketPayload<Ticket>(ticket).m_nextTicketId++;
|
||||
m_pendingRequestQueue.push(AZStd::move(queueEntry));
|
||||
}
|
||||
QueueRequest(ticket, priority, AZStd::move(queueEntry));
|
||||
}
|
||||
|
||||
void SpawnableEntitiesManager::ClaimEntities(EntitySpawnTicket& ticket, ClaimEntitiesCallback listCallback)
|
||||
void SpawnableEntitiesManager::ClaimEntities(EntitySpawnTicket& ticket, SpawnablePriority priority, ClaimEntitiesCallback listCallback)
|
||||
{
|
||||
AZ_Assert(listCallback, "ClaimEntities called on spawnable entities without a valid callback to use.");
|
||||
AZ_Assert(ticket.IsValid(), "Ticket provided to ClaimEntities hasn't been initialized.");
|
||||
|
||||
ClaimEntitiesCommand queueEntry;
|
||||
queueEntry.m_ticket = &ticket;
|
||||
queueEntry.m_ticketId = ticket.GetId();
|
||||
queueEntry.m_listCallback = AZStd::move(listCallback);
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
queueEntry.m_ticketId = GetTicketPayload<Ticket>(ticket).m_nextTicketId++;
|
||||
m_pendingRequestQueue.push(AZStd::move(queueEntry));
|
||||
}
|
||||
QueueRequest(ticket, priority, AZStd::move(queueEntry));
|
||||
}
|
||||
|
||||
void SpawnableEntitiesManager::Barrier(EntitySpawnTicket& ticket, BarrierCallback completionCallback)
|
||||
void SpawnableEntitiesManager::Barrier(EntitySpawnTicket& ticket, SpawnablePriority priority, BarrierCallback completionCallback)
|
||||
{
|
||||
AZ_Assert(completionCallback, "Barrier on spawnable entities called without a valid callback to use.");
|
||||
AZ_Assert(ticket.IsValid(), "Ticket provided to Barrier hasn't been initialized.");
|
||||
|
||||
BarrierCommand queueEntry;
|
||||
queueEntry.m_ticket = &ticket;
|
||||
queueEntry.m_ticketId = ticket.GetId();
|
||||
queueEntry.m_completionCallback = AZStd::move(completionCallback);
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
queueEntry.m_ticketId = GetTicketPayload<Ticket>(ticket).m_nextTicketId++;
|
||||
m_pendingRequestQueue.push(AZStd::move(queueEntry));
|
||||
}
|
||||
QueueRequest(ticket, priority, AZStd::move(queueEntry));
|
||||
}
|
||||
|
||||
void SpawnableEntitiesManager::AddOnSpawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler)
|
||||
@@ -156,34 +152,54 @@ namespace AzFramework
|
||||
handler.Connect(m_onDespawnedEvent);
|
||||
}
|
||||
|
||||
auto SpawnableEntitiesManager::ProcessQueue() -> CommandQueueStatus
|
||||
auto SpawnableEntitiesManager::ProcessQueue(CommandQueuePriority priority) -> CommandQueueStatus
|
||||
{
|
||||
CommandQueueStatus result = CommandQueueStatus::NoCommandsLeft;
|
||||
if ((priority & CommandQueuePriority::High) == CommandQueuePriority::High)
|
||||
{
|
||||
if (ProcessQueue(m_highPriorityQueue) == CommandQueueStatus::HasCommandsLeft)
|
||||
{
|
||||
result = CommandQueueStatus::HasCommandsLeft;
|
||||
}
|
||||
}
|
||||
if ((priority & CommandQueuePriority::Regular) == CommandQueuePriority::Regular)
|
||||
{
|
||||
if (ProcessQueue(m_regularPriorityQueue) == CommandQueueStatus::HasCommandsLeft)
|
||||
{
|
||||
result = CommandQueueStatus::HasCommandsLeft;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
auto SpawnableEntitiesManager::ProcessQueue(Queue& queue) -> CommandQueueStatus
|
||||
{
|
||||
AZStd::queue<Requests> pendingRequestQueue;
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
m_pendingRequestQueue.swap(pendingRequestQueue);
|
||||
AZStd::scoped_lock queueLock(queue.m_pendingRequestMutex);
|
||||
queue.m_pendingRequest.swap(pendingRequestQueue);
|
||||
}
|
||||
|
||||
if (!pendingRequestQueue.empty() || !m_delayedQueue.empty())
|
||||
if (!pendingRequestQueue.empty() || !queue.m_delayed.empty())
|
||||
{
|
||||
AZ::SerializeContext* serializeContext = nullptr;
|
||||
AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationBus::Events::GetSerializeContext);
|
||||
AZ_Assert(serializeContext, "Failed to retrieve serialization context.");
|
||||
|
||||
// Only process the requests that are currently in this queue, not the ones that could be re-added if they still can't complete.
|
||||
size_t delayedSize = m_delayedQueue.size();
|
||||
size_t delayedSize = queue.m_delayed.size();
|
||||
for (size_t i = 0; i < delayedSize; ++i)
|
||||
{
|
||||
Requests& request = m_delayedQueue.front();
|
||||
Requests& request = queue.m_delayed.front();
|
||||
bool result = AZStd::visit([this, serializeContext](auto&& args) -> bool
|
||||
{
|
||||
return ProcessRequest(args, *serializeContext);
|
||||
}, request);
|
||||
if (!result)
|
||||
{
|
||||
m_delayedQueue.emplace_back(AZStd::move(request));
|
||||
queue.m_delayed.emplace_back(AZStd::move(request));
|
||||
}
|
||||
m_delayedQueue.pop_front();
|
||||
queue.m_delayed.pop_front();
|
||||
}
|
||||
|
||||
do
|
||||
@@ -197,7 +213,7 @@ namespace AzFramework
|
||||
}, request);
|
||||
if (!result)
|
||||
{
|
||||
m_delayedQueue.emplace_back(AZStd::move(request));
|
||||
queue.m_delayed.emplace_back(AZStd::move(request));
|
||||
}
|
||||
pendingRequestQueue.pop();
|
||||
}
|
||||
@@ -205,20 +221,22 @@ namespace AzFramework
|
||||
// Spawning entities can result in more entities being queued to spawn. Repeat spawning until the queue is
|
||||
// empty to avoid a chain of entity spawning getting dragged out over multiple frames.
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
m_pendingRequestQueue.swap(pendingRequestQueue);
|
||||
AZStd::scoped_lock queueLock(queue.m_pendingRequestMutex);
|
||||
queue.m_pendingRequest.swap(pendingRequestQueue);
|
||||
}
|
||||
} while (!pendingRequestQueue.empty());
|
||||
}
|
||||
|
||||
return m_delayedQueue.empty() ? CommandQueueStatus::NoCommandLeft : CommandQueueStatus::HasCommandsLeft;
|
||||
return queue.m_delayed.empty() ? CommandQueueStatus::NoCommandsLeft : CommandQueueStatus::HasCommandsLeft;
|
||||
}
|
||||
|
||||
void* SpawnableEntitiesManager::CreateTicket(AZ::Data::Asset<Spawnable>&& spawnable)
|
||||
AZStd::pair<uint64_t, void*> SpawnableEntitiesManager::CreateTicket(AZ::Data::Asset<Spawnable>&& spawnable)
|
||||
{
|
||||
static AZStd::atomic_uint64_t idCounter { 1 };
|
||||
|
||||
auto result = aznew Ticket();
|
||||
result->m_spawnable = AZStd::move(spawnable);
|
||||
return result;
|
||||
return AZStd::make_pair<EntitySpawnTicket::Id, void*>(idCounter++, result);
|
||||
}
|
||||
|
||||
void SpawnableEntitiesManager::DestroyTicket(void* ticket)
|
||||
@@ -226,9 +244,9 @@ namespace AzFramework
|
||||
DestroyTicketCommand queueEntry;
|
||||
queueEntry.m_ticket = reinterpret_cast<Ticket*>(ticket);
|
||||
{
|
||||
AZStd::scoped_lock queueLock(m_pendingRequestQueueMutex);
|
||||
queueEntry.m_ticketId = reinterpret_cast<Ticket*>(ticket)->m_nextTicketId++;
|
||||
m_pendingRequestQueue.push(AZStd::move(queueEntry));
|
||||
AZStd::scoped_lock queueLock(m_regularPriorityQueue.m_pendingRequestMutex);
|
||||
queueEntry.m_requestId = reinterpret_cast<Ticket*>(ticket)->m_nextRequestId++;
|
||||
m_regularPriorityQueue.m_pendingRequest.push(AZStd::move(queueEntry));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,8 +269,8 @@ namespace AzFramework
|
||||
|
||||
bool SpawnableEntitiesManager::ProcessRequest(SpawnAllEntitiesCommand& request, AZ::SerializeContext& serializeContext)
|
||||
{
|
||||
Ticket& ticket = GetTicketPayload<Ticket>(*request.m_ticket);
|
||||
if (ticket.m_spawnable.IsReady() && request.m_ticketId == ticket.m_currentTicketId)
|
||||
Ticket& ticket = *request.m_ticket;
|
||||
if (ticket.m_spawnable.IsReady() && request.m_requestId == ticket.m_currentRequestId)
|
||||
{
|
||||
AZStd::vector<AZ::Entity*>& spawnedEntities = ticket.m_spawnedEntities;
|
||||
AZStd::vector<size_t>& spawnedEntityIndices = ticket.m_spawnedEntityIndices;
|
||||
@@ -300,7 +318,7 @@ namespace AzFramework
|
||||
// Let other systems know about newly spawned entities for any pre-processing before adding to the scene/game context.
|
||||
if (request.m_preInsertionCallback)
|
||||
{
|
||||
request.m_preInsertionCallback(*request.m_ticket, SpawnableEntityContainerView(
|
||||
request.m_preInsertionCallback(request.m_ticketId, SpawnableEntityContainerView(
|
||||
ticket.m_spawnedEntities.begin() + spawnedEntitiesInitialCount, ticket.m_spawnedEntities.end()));
|
||||
}
|
||||
|
||||
@@ -314,13 +332,13 @@ namespace AzFramework
|
||||
// Let other systems know about newly spawned entities for any post-processing after adding to the scene/game context.
|
||||
if (request.m_completionCallback)
|
||||
{
|
||||
request.m_completionCallback(*request.m_ticket, SpawnableConstEntityContainerView(
|
||||
request.m_completionCallback(request.m_ticketId, SpawnableConstEntityContainerView(
|
||||
ticket.m_spawnedEntities.begin() + spawnedEntitiesInitialCount, ticket.m_spawnedEntities.end()));
|
||||
}
|
||||
|
||||
m_onSpawnedEvent.Signal(ticket.m_spawnable);
|
||||
|
||||
ticket.m_currentTicketId++;
|
||||
ticket.m_currentRequestId++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -331,8 +349,8 @@ namespace AzFramework
|
||||
|
||||
bool SpawnableEntitiesManager::ProcessRequest(SpawnEntitiesCommand& request, AZ::SerializeContext& serializeContext)
|
||||
{
|
||||
Ticket& ticket = GetTicketPayload<Ticket>(*request.m_ticket);
|
||||
if (ticket.m_spawnable.IsReady() && request.m_ticketId == ticket.m_currentTicketId)
|
||||
Ticket& ticket = *request.m_ticket;
|
||||
if (ticket.m_spawnable.IsReady() && request.m_requestId == ticket.m_currentRequestId)
|
||||
{
|
||||
AZStd::vector<AZ::Entity*>& spawnedEntities = ticket.m_spawnedEntities;
|
||||
AZStd::vector<size_t>& spawnedEntityIndices = ticket.m_spawnedEntityIndices;
|
||||
@@ -367,9 +385,7 @@ namespace AzFramework
|
||||
// Let other systems know about newly spawned entities for any pre-processing before adding to the scene/game context.
|
||||
if (request.m_preInsertionCallback)
|
||||
{
|
||||
request.m_preInsertionCallback(
|
||||
*request.m_ticket,
|
||||
SpawnableEntityContainerView(
|
||||
request.m_preInsertionCallback(request.m_ticketId, SpawnableEntityContainerView(
|
||||
ticket.m_spawnedEntities.begin() + spawnedEntitiesInitialCount, ticket.m_spawnedEntities.end()));
|
||||
}
|
||||
|
||||
@@ -382,13 +398,13 @@ namespace AzFramework
|
||||
|
||||
if (request.m_completionCallback)
|
||||
{
|
||||
request.m_completionCallback(*request.m_ticket, SpawnableConstEntityContainerView(
|
||||
request.m_completionCallback(request.m_ticketId, SpawnableConstEntityContainerView(
|
||||
ticket.m_spawnedEntities.begin() + spawnedEntitiesInitialCount, ticket.m_spawnedEntities.end()));
|
||||
}
|
||||
|
||||
m_onSpawnedEvent.Signal(ticket.m_spawnable);
|
||||
|
||||
ticket.m_currentTicketId++;
|
||||
ticket.m_currentRequestId++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -400,8 +416,8 @@ namespace AzFramework
|
||||
bool SpawnableEntitiesManager::ProcessRequest(DespawnAllEntitiesCommand& request,
|
||||
[[maybe_unused]] AZ::SerializeContext& serializeContext)
|
||||
{
|
||||
Ticket& ticket = GetTicketPayload<Ticket>(*request.m_ticket);
|
||||
if (request.m_ticketId == ticket.m_currentTicketId)
|
||||
Ticket& ticket = *request.m_ticket;
|
||||
if (request.m_requestId == ticket.m_currentRequestId)
|
||||
{
|
||||
for (AZ::Entity* entity : ticket.m_spawnedEntities)
|
||||
{
|
||||
@@ -417,12 +433,12 @@ namespace AzFramework
|
||||
|
||||
if (request.m_completionCallback)
|
||||
{
|
||||
request.m_completionCallback(*request.m_ticket);
|
||||
request.m_completionCallback(request.m_ticketId);
|
||||
}
|
||||
|
||||
m_onDespawnedEvent.Signal(ticket.m_spawnable);
|
||||
|
||||
ticket.m_currentTicketId++;
|
||||
ticket.m_currentRequestId++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -433,11 +449,11 @@ namespace AzFramework
|
||||
|
||||
bool SpawnableEntitiesManager::ProcessRequest(ReloadSpawnableCommand& request, AZ::SerializeContext& serializeContext)
|
||||
{
|
||||
Ticket& ticket = GetTicketPayload<Ticket>(*request.m_ticket);
|
||||
Ticket& ticket = *request.m_ticket;
|
||||
AZ_Assert(ticket.m_spawnable.GetId() == request.m_spawnable.GetId(),
|
||||
"Spawnable is being reloaded, but the provided spawnable has a different asset id. "
|
||||
"This will likely result in unexpected entities being created.");
|
||||
if (ticket.m_spawnable.IsReady() && request.m_ticketId == ticket.m_currentTicketId)
|
||||
if (ticket.m_spawnable.IsReady() && request.m_requestId == ticket.m_currentRequestId)
|
||||
{
|
||||
// Delete the original entities.
|
||||
for (AZ::Entity* entity : ticket.m_spawnedEntities)
|
||||
@@ -493,11 +509,11 @@ namespace AzFramework
|
||||
|
||||
if (request.m_completionCallback)
|
||||
{
|
||||
request.m_completionCallback(*request.m_ticket, SpawnableConstEntityContainerView(
|
||||
request.m_completionCallback(request.m_ticketId, SpawnableConstEntityContainerView(
|
||||
ticket.m_spawnedEntities.begin(), ticket.m_spawnedEntities.end()));
|
||||
}
|
||||
|
||||
ticket.m_currentTicketId++;
|
||||
ticket.m_currentRequestId++;
|
||||
|
||||
m_onSpawnedEvent.Signal(ticket.m_spawnable);
|
||||
|
||||
@@ -511,12 +527,12 @@ namespace AzFramework
|
||||
|
||||
bool SpawnableEntitiesManager::ProcessRequest(ListEntitiesCommand& request, [[maybe_unused]] AZ::SerializeContext& serializeContext)
|
||||
{
|
||||
Ticket& ticket = GetTicketPayload<Ticket>(*request.m_ticket);
|
||||
if (request.m_ticketId == ticket.m_currentTicketId)
|
||||
Ticket& ticket = *request.m_ticket;
|
||||
if (request.m_requestId == ticket.m_currentRequestId)
|
||||
{
|
||||
request.m_listCallback(*request.m_ticket, SpawnableConstEntityContainerView(
|
||||
request.m_listCallback(request.m_ticketId, SpawnableConstEntityContainerView(
|
||||
ticket.m_spawnedEntities.begin(), ticket.m_spawnedEntities.end()));
|
||||
ticket.m_currentTicketId++;
|
||||
ticket.m_currentRequestId++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -527,17 +543,15 @@ namespace AzFramework
|
||||
|
||||
bool SpawnableEntitiesManager::ProcessRequest(ListIndicesEntitiesCommand& request, [[maybe_unused]] AZ::SerializeContext& serializeContext)
|
||||
{
|
||||
Ticket& ticket = GetTicketPayload<Ticket>(*request.m_ticket);
|
||||
if (request.m_ticketId == ticket.m_currentTicketId)
|
||||
Ticket& ticket = *request.m_ticket;
|
||||
if (request.m_requestId == ticket.m_currentRequestId)
|
||||
{
|
||||
AZ_Assert(
|
||||
ticket.m_spawnedEntities.size() == ticket.m_spawnedEntityIndices.size(),
|
||||
"Entities and indices on spawnable ticket have gone out of sync.");
|
||||
request.m_listCallback(
|
||||
*request.m_ticket,
|
||||
SpawnableConstIndexEntityContainerView(
|
||||
request.m_listCallback(request.m_ticketId, SpawnableConstIndexEntityContainerView(
|
||||
ticket.m_spawnedEntities.begin(), ticket.m_spawnedEntityIndices.begin(), ticket.m_spawnedEntities.size()));
|
||||
ticket.m_currentTicketId++;
|
||||
ticket.m_currentRequestId++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -548,16 +562,16 @@ namespace AzFramework
|
||||
|
||||
bool SpawnableEntitiesManager::ProcessRequest(ClaimEntitiesCommand& request, [[maybe_unused]] AZ::SerializeContext& serializeContext)
|
||||
{
|
||||
Ticket& ticket = GetTicketPayload<Ticket>(*request.m_ticket);
|
||||
if (request.m_ticketId == ticket.m_currentTicketId)
|
||||
Ticket& ticket = *request.m_ticket;
|
||||
if (request.m_requestId == ticket.m_currentRequestId)
|
||||
{
|
||||
request.m_listCallback(*request.m_ticket, SpawnableEntityContainerView(
|
||||
request.m_listCallback(request.m_ticketId, SpawnableEntityContainerView(
|
||||
ticket.m_spawnedEntities.begin(), ticket.m_spawnedEntities.end()));
|
||||
|
||||
ticket.m_spawnedEntities.clear();
|
||||
ticket.m_spawnedEntityIndices.clear();
|
||||
|
||||
ticket.m_currentTicketId++;
|
||||
ticket.m_currentRequestId++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -568,15 +582,15 @@ namespace AzFramework
|
||||
|
||||
bool SpawnableEntitiesManager::ProcessRequest(BarrierCommand& request, [[maybe_unused]] AZ::SerializeContext& serializeContext)
|
||||
{
|
||||
Ticket& ticket = GetTicketPayload<Ticket>(*request.m_ticket);
|
||||
if (request.m_ticketId == ticket.m_currentTicketId)
|
||||
Ticket& ticket = *request.m_ticket;
|
||||
if (request.m_requestId == ticket.m_currentRequestId)
|
||||
{
|
||||
if (request.m_completionCallback)
|
||||
{
|
||||
request.m_completionCallback(*request.m_ticket);
|
||||
request.m_completionCallback(request.m_ticketId);
|
||||
}
|
||||
|
||||
ticket.m_currentTicketId++;
|
||||
ticket.m_currentRequestId++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -587,7 +601,7 @@ namespace AzFramework
|
||||
|
||||
bool SpawnableEntitiesManager::ProcessRequest(DestroyTicketCommand& request, [[maybe_unused]] AZ::SerializeContext& serializeContext)
|
||||
{
|
||||
if (request.m_ticketId == request.m_ticket->m_currentTicketId)
|
||||
if (request.m_requestId == request.m_ticket->m_currentRequestId)
|
||||
{
|
||||
for (AZ::Entity* entity : request.m_ticket->m_spawnedEntities)
|
||||
{
|
||||
@@ -606,24 +620,4 @@ namespace AzFramework
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool SpawnableEntitiesManager::IsEqualTicket(const EntitySpawnTicket* lhs, const EntitySpawnTicket* rhs)
|
||||
{
|
||||
return GetTicketPayload<Ticket>(lhs) == GetTicketPayload<Ticket>(rhs);
|
||||
}
|
||||
|
||||
bool SpawnableEntitiesManager::IsEqualTicket(const Ticket* lhs, const EntitySpawnTicket* rhs)
|
||||
{
|
||||
return lhs == GetTicketPayload<Ticket>(rhs);
|
||||
}
|
||||
|
||||
bool SpawnableEntitiesManager::IsEqualTicket(const EntitySpawnTicket* lhs, const Ticket* rhs)
|
||||
{
|
||||
return GetTicketPayload<Ticket>(lhs) == rhs;
|
||||
}
|
||||
|
||||
bool SpawnableEntitiesManager::IsEqualTicket(const Ticket* lhs, const Ticket* rhs)
|
||||
{
|
||||
return lhs = rhs;
|
||||
}
|
||||
} // namespace AzFramework
|
||||
|
||||
@@ -29,8 +29,6 @@ namespace AZ
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
using EntityIdMap = AZStd::unordered_map<AZ::EntityId, AZ::EntityId>;
|
||||
|
||||
class SpawnableEntitiesManager
|
||||
: public SpawnableEntitiesInterface::Registrar
|
||||
{
|
||||
@@ -38,31 +36,47 @@ namespace AzFramework
|
||||
AZ_RTTI(AzFramework::SpawnableEntitiesManager, "{6E14333F-128C-464C-94CA-A63B05A5E51C}");
|
||||
AZ_CLASS_ALLOCATOR(SpawnableEntitiesManager, AZ::SystemAllocator, 0);
|
||||
|
||||
using EntityIdMap = AZStd::unordered_map<AZ::EntityId, AZ::EntityId>;
|
||||
|
||||
enum class CommandQueueStatus : bool
|
||||
{
|
||||
HasCommandsLeft,
|
||||
NoCommandLeft
|
||||
NoCommandsLeft
|
||||
};
|
||||
|
||||
enum class CommandQueuePriority
|
||||
{
|
||||
High = 1 << 0,
|
||||
Regular = 1 << 1
|
||||
};
|
||||
|
||||
SpawnableEntitiesManager();
|
||||
~SpawnableEntitiesManager() override = default;
|
||||
|
||||
//
|
||||
// The following functions are thread safe
|
||||
//
|
||||
|
||||
void SpawnAllEntities(EntitySpawnTicket& ticket, EntityPreInsertionCallback preInsertionCallback = {}, EntitySpawnCallback completionCallback = {}) override;
|
||||
void SpawnEntities(EntitySpawnTicket& ticket, AZStd::vector<size_t> entityIndices, EntityPreInsertionCallback preInsertionCallback = {},
|
||||
void SpawnAllEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, EntityPreInsertionCallback preInsertionCallback = {},
|
||||
EntitySpawnCallback completionCallback = {}) override;
|
||||
void DespawnAllEntities(EntitySpawnTicket& ticket, EntityDespawnCallback completionCallback = {}) override;
|
||||
void SpawnEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, AZStd::vector<size_t> entityIndices,
|
||||
EntityPreInsertionCallback preInsertionCallback = {},
|
||||
EntitySpawnCallback completionCallback = {}) override;
|
||||
void DespawnAllEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, EntityDespawnCallback completionCallback = {}) override;
|
||||
|
||||
void ReloadSpawnable(EntitySpawnTicket& ticket, AZ::Data::Asset<Spawnable> spawnable,
|
||||
void ReloadSpawnable(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, AZ::Data::Asset<Spawnable> spawnable,
|
||||
ReloadSpawnableCallback completionCallback = {}) override;
|
||||
|
||||
void ListEntities(EntitySpawnTicket& ticket, ListEntitiesCallback listCallback) override;
|
||||
void ListIndicesAndEntities(EntitySpawnTicket& ticket, ListIndicesEntitiesCallback listCallback) override;
|
||||
void ClaimEntities(EntitySpawnTicket& ticket, ClaimEntitiesCallback listCallback) override;
|
||||
void ListEntities(EntitySpawnTicket& ticket, SpawnablePriority priority, ListEntitiesCallback listCallback) override;
|
||||
void ListIndicesAndEntities(
|
||||
EntitySpawnTicket& ticket, SpawnablePriority priority, ListIndicesEntitiesCallback listCallback) override;
|
||||
void ClaimEntities(EntitySpawnTicket& ticket, SpawnablePriority priority, ClaimEntitiesCallback listCallback) override;
|
||||
|
||||
void Barrier(EntitySpawnTicket& spawnInfo, BarrierCallback completionCallback) override;
|
||||
void Barrier(EntitySpawnTicket& spawnInfo, SpawnablePriority priority, BarrierCallback completionCallback) override;
|
||||
|
||||
void AddOnSpawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler) override;
|
||||
void AddOnDespawnedHandler(AZ::Event<AZ::Data::Asset<Spawnable>>::Handler& handler) override;
|
||||
@@ -71,13 +85,9 @@ namespace AzFramework
|
||||
// The following function is thread safe but intended to be run from the main thread.
|
||||
//
|
||||
|
||||
CommandQueueStatus ProcessQueue();
|
||||
CommandQueueStatus ProcessQueue(CommandQueuePriority priority);
|
||||
|
||||
protected:
|
||||
void* CreateTicket(AZ::Data::Asset<Spawnable>&& spawnable) override;
|
||||
void DestroyTicket(void* ticket) override;
|
||||
|
||||
private:
|
||||
struct Ticket
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR(Ticket, AZ::ThreadPoolAllocator, 0);
|
||||
@@ -86,8 +96,8 @@ namespace AzFramework
|
||||
AZStd::vector<AZ::Entity*> m_spawnedEntities;
|
||||
AZStd::vector<size_t> m_spawnedEntityIndices;
|
||||
AZ::Data::Asset<Spawnable> m_spawnable;
|
||||
uint32_t m_nextTicketId{ 0 }; //!< Next id for this ticket.
|
||||
uint32_t m_currentTicketId{ 0 }; //!< The id for the command that should be executed.
|
||||
uint32_t m_nextRequestId{ 0 }; //!< Next id for this ticket.
|
||||
uint32_t m_currentRequestId { 0 }; //!< The id for the command that should be executed.
|
||||
bool m_loadAll{ true };
|
||||
};
|
||||
|
||||
@@ -95,64 +105,86 @@ namespace AzFramework
|
||||
{
|
||||
EntitySpawnCallback m_completionCallback;
|
||||
EntityPreInsertionCallback m_preInsertionCallback;
|
||||
EntitySpawnTicket* m_ticket;
|
||||
uint32_t m_ticketId;
|
||||
Ticket* m_ticket;
|
||||
EntitySpawnTicket::Id m_ticketId;
|
||||
uint32_t m_requestId;
|
||||
};
|
||||
struct SpawnEntitiesCommand
|
||||
{
|
||||
AZStd::vector<size_t> m_entityIndices;
|
||||
EntitySpawnCallback m_completionCallback;
|
||||
EntityPreInsertionCallback m_preInsertionCallback;
|
||||
EntitySpawnTicket* m_ticket;
|
||||
uint32_t m_ticketId;
|
||||
Ticket* m_ticket;
|
||||
EntitySpawnTicket::Id m_ticketId;
|
||||
uint32_t m_requestId;
|
||||
};
|
||||
struct DespawnAllEntitiesCommand
|
||||
{
|
||||
EntityDespawnCallback m_completionCallback;
|
||||
EntitySpawnTicket* m_ticket;
|
||||
uint32_t m_ticketId;
|
||||
Ticket* m_ticket;
|
||||
EntitySpawnTicket::Id m_ticketId;
|
||||
uint32_t m_requestId;
|
||||
};
|
||||
struct ReloadSpawnableCommand
|
||||
{
|
||||
AZ::Data::Asset<Spawnable> m_spawnable;
|
||||
ReloadSpawnableCallback m_completionCallback;
|
||||
EntitySpawnTicket* m_ticket;
|
||||
uint32_t m_ticketId;
|
||||
Ticket* m_ticket;
|
||||
EntitySpawnTicket::Id m_ticketId;
|
||||
uint32_t m_requestId;
|
||||
};
|
||||
struct ListEntitiesCommand
|
||||
{
|
||||
ListEntitiesCallback m_listCallback;
|
||||
EntitySpawnTicket* m_ticket;
|
||||
uint32_t m_ticketId;
|
||||
Ticket* m_ticket;
|
||||
EntitySpawnTicket::Id m_ticketId;
|
||||
uint32_t m_requestId;
|
||||
};
|
||||
struct ListIndicesEntitiesCommand
|
||||
{
|
||||
ListIndicesEntitiesCallback m_listCallback;
|
||||
EntitySpawnTicket* m_ticket;
|
||||
uint32_t m_ticketId;
|
||||
Ticket* m_ticket;
|
||||
EntitySpawnTicket::Id m_ticketId;
|
||||
uint32_t m_requestId;
|
||||
};
|
||||
struct ClaimEntitiesCommand
|
||||
{
|
||||
ClaimEntitiesCallback m_listCallback;
|
||||
EntitySpawnTicket* m_ticket;
|
||||
uint32_t m_ticketId;
|
||||
Ticket* m_ticket;
|
||||
EntitySpawnTicket::Id m_ticketId;
|
||||
uint32_t m_requestId;
|
||||
};
|
||||
struct BarrierCommand
|
||||
{
|
||||
BarrierCallback m_completionCallback;
|
||||
EntitySpawnTicket* m_ticket;
|
||||
uint32_t m_ticketId;
|
||||
Ticket* m_ticket;
|
||||
EntitySpawnTicket::Id m_ticketId;
|
||||
uint32_t m_requestId;
|
||||
};
|
||||
struct DestroyTicketCommand
|
||||
{
|
||||
Ticket* m_ticket;
|
||||
uint32_t m_ticketId;
|
||||
uint32_t m_requestId;
|
||||
};
|
||||
|
||||
using Requests = AZStd::variant<
|
||||
SpawnAllEntitiesCommand, SpawnEntitiesCommand, DespawnAllEntitiesCommand, ReloadSpawnableCommand, ListEntitiesCommand,
|
||||
ListIndicesEntitiesCommand, ClaimEntitiesCommand, BarrierCommand, DestroyTicketCommand>;
|
||||
|
||||
struct Queue
|
||||
{
|
||||
AZStd::deque<Requests> m_delayed; //!< Requests that were processed before, but couldn't be completed.
|
||||
AZStd::queue<Requests> m_pendingRequest; //!< Requests waiting to be processed for the first time.
|
||||
AZStd::mutex m_pendingRequestMutex;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void QueueRequest(EntitySpawnTicket& ticket, SpawnablePriority priority, T&& request);
|
||||
AZStd::pair<EntitySpawnTicket::Id, void*> CreateTicket(AZ::Data::Asset<Spawnable>&& spawnable) override;
|
||||
void DestroyTicket(void* ticket) override;
|
||||
|
||||
CommandQueueStatus ProcessQueue(Queue& queue);
|
||||
|
||||
AZ::Entity* SpawnSingleEntity(const AZ::Entity& entityTemplate,
|
||||
AZ::SerializeContext& serializeContext);
|
||||
|
||||
@@ -169,16 +201,18 @@ namespace AzFramework
|
||||
bool ProcessRequest(BarrierCommand& request, AZ::SerializeContext& serializeContext);
|
||||
bool ProcessRequest(DestroyTicketCommand& request, AZ::SerializeContext& serializeContext);
|
||||
|
||||
[[nodiscard]] static bool IsEqualTicket(const EntitySpawnTicket* lhs, const EntitySpawnTicket* rhs);
|
||||
[[nodiscard]] static bool IsEqualTicket(const Ticket* lhs, const EntitySpawnTicket* rhs);
|
||||
[[nodiscard]] static bool IsEqualTicket(const EntitySpawnTicket* lhs, const Ticket* rhs);
|
||||
[[nodiscard]] static bool IsEqualTicket(const Ticket* lhs, const Ticket* rhs);
|
||||
|
||||
AZStd::deque<Requests> m_delayedQueue; //!< Requests that were processed before, but couldn't be completed.
|
||||
AZStd::queue<Requests> m_pendingRequestQueue;
|
||||
AZStd::mutex m_pendingRequestQueueMutex;
|
||||
Queue m_highPriorityQueue;
|
||||
Queue m_regularPriorityQueue;
|
||||
|
||||
AZ::Event<AZ::Data::Asset<Spawnable>> m_onSpawnedEvent;
|
||||
AZ::Event<AZ::Data::Asset<Spawnable>> m_onDespawnedEvent;
|
||||
|
||||
//! The threshold used to determine if a request goes in the regular (if bigger than the value) or high priority queue (if smaller
|
||||
//! or equal to this value). The starting value of 64 is chosen as it's between default values SpawnablePriority_High and
|
||||
//! SpawnablePriority_Default which gives users a bit of room to fine tune the priorities as this value can be configured
|
||||
//! through the Settings Registry under the key "/O3DE/AzFramework/Spawnables/HighPriorityThreshold".
|
||||
SpawnablePriority m_highPriorityThreshold { 64 };
|
||||
};
|
||||
|
||||
AZ_DEFINE_ENUM_BITWISE_OPERATORS(AzFramework::SpawnableEntitiesManager::CommandQueuePriority);
|
||||
} // namespace AzFramework
|
||||
|
||||
@@ -48,10 +48,23 @@ namespace AzFramework
|
||||
|
||||
void SpawnableSystemComponent::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/)
|
||||
{
|
||||
m_entitiesManager.ProcessQueue();
|
||||
m_entitiesManager.ProcessQueue(
|
||||
SpawnableEntitiesManager::CommandQueuePriority::High | SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
RootSpawnableNotificationBus::ExecuteQueuedEvents();
|
||||
}
|
||||
|
||||
int SpawnableSystemComponent::GetTickOrder()
|
||||
{
|
||||
return AZ::ComponentTickBus::TICK_GAME;
|
||||
}
|
||||
|
||||
void SpawnableSystemComponent::OnSystemTick()
|
||||
{
|
||||
// Handle only high priority spawning events such as those created from network. These need to happen even if the client
|
||||
// doesn't have focus to avoid time-out issues for instance.
|
||||
m_entitiesManager.ProcessQueue(SpawnableEntitiesManager::CommandQueuePriority::High);
|
||||
}
|
||||
|
||||
void SpawnableSystemComponent::OnCatalogLoaded([[maybe_unused]] const char* catalogFile)
|
||||
{
|
||||
if (!m_catalogAvailable)
|
||||
@@ -168,7 +181,8 @@ namespace AzFramework
|
||||
SpawnableEntitiesManager::CommandQueueStatus queueStatus;
|
||||
do
|
||||
{
|
||||
queueStatus = m_entitiesManager.ProcessQueue();
|
||||
queueStatus = m_entitiesManager.ProcessQueue(
|
||||
SpawnableEntitiesManager::CommandQueuePriority::High | SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
} while (queueStatus == SpawnableEntitiesManager::CommandQueueStatus::HasCommandsLeft);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace AzFramework
|
||||
class SpawnableSystemComponent
|
||||
: public AZ::Component
|
||||
, public AZ::TickBus::Handler
|
||||
, public AZ::SystemTickBus::Handler
|
||||
, public AssetCatalogEventBus::Handler
|
||||
, public RootSpawnableInterface::Registrar
|
||||
, public RootSpawnableNotificationBus::Handler
|
||||
@@ -58,6 +59,13 @@ namespace AzFramework
|
||||
//
|
||||
|
||||
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
|
||||
int GetTickOrder() override;
|
||||
|
||||
//
|
||||
// SystemTickBus
|
||||
//
|
||||
|
||||
void OnSystemTick() override;
|
||||
|
||||
//
|
||||
// AssetCatalogEventBus
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace AzFramework
|
||||
AZ_CVAR(float, ed_cameraSystemOrbitDollyScrollSpeed, 0.02f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(float, ed_cameraSystemOrbitDollyCursorSpeed, 0.01f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(float, ed_cameraSystemScrollTranslateSpeed, 0.02f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(float, ed_cameraSystemMinOrbitDistance, 6.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(float, ed_cameraSystemMinOrbitDistance, 10.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(float, ed_cameraSystemMaxOrbitDistance, 50.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(float, ed_cameraSystemLookSmoothness, 5.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(float, ed_cameraSystemTranslateSmoothness, 5.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
@@ -37,7 +37,6 @@ namespace AzFramework
|
||||
AZ_CVAR(float, ed_cameraSystemPanSpeed, 0.01f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(bool, ed_cameraSystemPanInvertX, true, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(bool, ed_cameraSystemPanInvertY, true, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
AZ_CVAR(float, ed_cameraSystemLookDeadzone, 2.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
|
||||
AZ_CVAR(
|
||||
AZ::CVarFixedString, ed_cameraSystemTranslateForwardKey, "keyboard_key_alphanumeric_W", nullptr, AZ::ConsoleFunctorFlags::Null, "");
|
||||
@@ -144,7 +143,7 @@ namespace AzFramework
|
||||
z = AZStd::atan2(-orientation.GetElement(1, 2), orientation.GetElement(1, 1));
|
||||
}
|
||||
|
||||
return {x, y, z};
|
||||
return { x, y, z };
|
||||
}
|
||||
|
||||
void UpdateCameraFromTransform(Camera& camera, const AZ::Transform& transform)
|
||||
@@ -179,7 +178,7 @@ namespace AzFramework
|
||||
{
|
||||
const auto nextCamera = m_cameras.StepCamera(targetCamera, m_motionDelta, m_scrollDelta, deltaTime);
|
||||
|
||||
m_motionDelta = ScreenVector{0, 0};
|
||||
m_motionDelta = ScreenVector{ 0, 0 };
|
||||
m_scrollDelta = 0.0f;
|
||||
|
||||
return nextCamera;
|
||||
@@ -213,7 +212,10 @@ namespace AzFramework
|
||||
auto& cameraInput = m_idleCameraInputs[i];
|
||||
const bool canBegin = cameraInput->Beginning() &&
|
||||
AZStd::all_of(m_activeCameraInputs.cbegin(), m_activeCameraInputs.cend(),
|
||||
[](const auto& input) { return !input->Exclusive(); }) &&
|
||||
[](const auto& input)
|
||||
{
|
||||
return !input->Exclusive();
|
||||
}) &&
|
||||
(!cameraInput->Exclusive() || (cameraInput->Exclusive() && m_activeCameraInputs.empty()));
|
||||
|
||||
if (canBegin)
|
||||
@@ -231,7 +233,8 @@ namespace AzFramework
|
||||
|
||||
const Camera nextCamera = AZStd::accumulate(
|
||||
AZStd::begin(m_activeCameraInputs), AZStd::end(m_activeCameraInputs), targetCamera,
|
||||
[cursorDelta, scrollDelta, deltaTime](Camera acc, auto& camera) {
|
||||
[cursorDelta, scrollDelta, deltaTime](Camera acc, auto& camera)
|
||||
{
|
||||
acc = camera->StepCamera(acc, cursorDelta, scrollDelta, deltaTime);
|
||||
return acc;
|
||||
});
|
||||
@@ -284,7 +287,8 @@ namespace AzFramework
|
||||
|
||||
bool RotateCameraInput::HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, [[maybe_unused]] float scrollDelta)
|
||||
{
|
||||
const ClickDetector::ClickEvent clickEvent = [&event, this] {
|
||||
const ClickDetector::ClickEvent clickEvent = [&event, this]
|
||||
{
|
||||
if (const auto& input = AZStd::get_if<DiscreteInputEvent>(&event))
|
||||
{
|
||||
if (input->m_channelId == m_rotateChannelId)
|
||||
@@ -330,7 +334,10 @@ namespace AzFramework
|
||||
nextCamera.m_pitch -= float(cursorDelta.m_y) * ed_cameraSystemRotateSpeed;
|
||||
nextCamera.m_yaw -= float(cursorDelta.m_x) * ed_cameraSystemRotateSpeed;
|
||||
|
||||
const auto clampRotation = [](const float angle) { return AZStd::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); };
|
||||
const auto clampRotation = [](const float angle)
|
||||
{
|
||||
return AZStd::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi);
|
||||
};
|
||||
|
||||
nextCamera.m_yaw = clampRotation(nextCamera.m_yaw);
|
||||
// clamp pitch to be +-90 degrees
|
||||
@@ -377,9 +384,10 @@ namespace AzFramework
|
||||
const auto deltaPanX = float(cursorDelta.m_x) * panAxes.m_horizontalAxis * ed_cameraSystemPanSpeed;
|
||||
const auto deltaPanY = float(cursorDelta.m_y) * panAxes.m_verticalAxis * ed_cameraSystemPanSpeed;
|
||||
|
||||
const auto inv = [](const bool invert) {
|
||||
constexpr float Dir[] = {1.0f, -1.0f};
|
||||
return Dir[static_cast<int>(invert)];
|
||||
const auto inv = [](const bool invert)
|
||||
{
|
||||
constexpr float Dir[] = { 1.0f, -1.0f };
|
||||
return Dir[aznumeric_cast<int>(invert)];
|
||||
};
|
||||
|
||||
nextCamera.m_lookAt += deltaPanX * inv(ed_cameraSystemPanInvertX);
|
||||
@@ -475,7 +483,8 @@ namespace AzFramework
|
||||
const auto axisY = translationBasis.GetBasisY();
|
||||
const auto axisZ = translationBasis.GetBasisZ();
|
||||
|
||||
const float speed = [boost = m_boost]() {
|
||||
const float speed = [boost = m_boost]()
|
||||
{
|
||||
return ed_cameraSystemTranslateSpeed * (boost ? ed_cameraSystemBoostMultiplier : 1.0f);
|
||||
}();
|
||||
|
||||
@@ -555,10 +564,12 @@ namespace AzFramework
|
||||
|
||||
if (Beginning())
|
||||
{
|
||||
const auto hasLookAt = [&nextCamera, &targetCamera, &lookAtFn = m_lookAtFn] {
|
||||
const auto hasLookAt = [&nextCamera, &targetCamera, &lookAtFn = m_lookAtFn]
|
||||
{
|
||||
if (lookAtFn)
|
||||
{
|
||||
if (const auto lookAt = lookAtFn())
|
||||
// pass through the camera's position and look vector for use in the lookAt function
|
||||
if (const auto lookAt = lookAtFn(targetCamera.Translation(), targetCamera.Rotation().GetBasisY()))
|
||||
{
|
||||
auto transform = AZ::Transform::CreateLookAt(targetCamera.m_lookAt, *lookAt);
|
||||
nextCamera.m_lookDist = -lookAt->GetDistance(targetCamera.m_lookAt);
|
||||
@@ -692,14 +703,20 @@ namespace AzFramework
|
||||
|
||||
Camera SmoothCamera(const Camera& currentCamera, const Camera& targetCamera, const float deltaTime)
|
||||
{
|
||||
const auto clamp_rotation = [](const float angle) { return AZStd::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); };
|
||||
const auto clamp_rotation = [](const float angle)
|
||||
{
|
||||
return AZStd::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi);
|
||||
};
|
||||
|
||||
// keep yaw in 0 - 360 range
|
||||
float targetYaw = clamp_rotation(targetCamera.m_yaw);
|
||||
const float currentYaw = clamp_rotation(currentCamera.m_yaw);
|
||||
|
||||
// return the sign of the float input (-1, 0, 1)
|
||||
const auto sign = [](const float value) { return aznumeric_cast<float>((0.0f < value) - (value < 0.0f)); };
|
||||
const auto sign = [](const float value)
|
||||
{
|
||||
return aznumeric_cast<float>((0.0f < value) - (value < 0.0f));
|
||||
};
|
||||
|
||||
// ensure smooth transition when moving across 0 - 360 boundary
|
||||
const float yawDelta = targetYaw - currentYaw;
|
||||
@@ -727,26 +744,28 @@ namespace AzFramework
|
||||
const auto& inputChannelId = inputChannel.GetInputChannelId();
|
||||
const auto& inputDeviceId = inputChannel.GetInputDevice().GetInputDeviceId();
|
||||
|
||||
const bool wasMouseButton =
|
||||
AZStd::any_of(InputDeviceMouse::Button::All.begin(), InputDeviceMouse::Button::All.end(), [inputChannelId](const auto& button) {
|
||||
const bool wasMouseButton = AZStd::any_of(
|
||||
InputDeviceMouse::Button::All.begin(), InputDeviceMouse::Button::All.end(),
|
||||
[inputChannelId](const auto& button)
|
||||
{
|
||||
return button == inputChannelId;
|
||||
});
|
||||
|
||||
if (inputChannelId == InputDeviceMouse::Movement::X)
|
||||
{
|
||||
return HorizontalMotionEvent{(int)inputChannel.GetValue()};
|
||||
return HorizontalMotionEvent{ aznumeric_cast<int>(inputChannel.GetValue()) };
|
||||
}
|
||||
else if (inputChannelId == InputDeviceMouse::Movement::Y)
|
||||
{
|
||||
return VerticalMotionEvent{(int)inputChannel.GetValue()};
|
||||
return VerticalMotionEvent{ aznumeric_cast<int>(inputChannel.GetValue()) };
|
||||
}
|
||||
else if (inputChannelId == InputDeviceMouse::Movement::Z)
|
||||
{
|
||||
return ScrollEvent{inputChannel.GetValue()};
|
||||
return ScrollEvent{ inputChannel.GetValue() };
|
||||
}
|
||||
else if (wasMouseButton || InputDeviceKeyboard::IsKeyboardDevice(inputDeviceId))
|
||||
{
|
||||
return DiscreteInputEvent{inputChannelId, inputChannel.GetState()};
|
||||
return DiscreteInputEvent{ inputChannelId, inputChannel.GetState() };
|
||||
}
|
||||
|
||||
return AZStd::monostate{};
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace AzFramework
|
||||
AZ::Vector3 m_lookAt = AZ::Vector3::CreateZero(); //!< Position of camera when m_lookDist is zero,
|
||||
//!< or position of m_lookAt when m_lookDist is greater
|
||||
//!< than zero.
|
||||
float m_yaw{0.0};
|
||||
float m_pitch{0.0};
|
||||
float m_lookDist{0.0}; //!< Zero gives first person free look, otherwise orbit about m_lookAt
|
||||
float m_yaw{ 0.0 };
|
||||
float m_pitch{ 0.0 };
|
||||
float m_lookDist{ 0.0 }; //!< Zero gives first person free look, otherwise orbit about m_lookAt
|
||||
|
||||
//! View camera transform (v in MVP).
|
||||
AZ::Transform View() const;
|
||||
@@ -195,7 +195,11 @@ namespace AzFramework
|
||||
inline bool Cameras::Exclusive() const
|
||||
{
|
||||
return AZStd::any_of(
|
||||
m_activeCameraInputs.begin(), m_activeCameraInputs.end(), [](const auto& cameraInput) { return cameraInput->Exclusive(); });
|
||||
m_activeCameraInputs.begin(), m_activeCameraInputs.end(),
|
||||
[](const auto& cameraInput)
|
||||
{
|
||||
return cameraInput->Exclusive();
|
||||
});
|
||||
}
|
||||
|
||||
//! Responsible for updating a series of cameras given various inputs.
|
||||
@@ -209,7 +213,7 @@ namespace AzFramework
|
||||
|
||||
private:
|
||||
ScreenVector m_motionDelta; //!< The delta used for look/orbit/pan (rotation + translation) - two dimensional.
|
||||
float m_scrollDelta = 0.0f; //!< The delta used for dolly/movement (translation) - one dimensional.
|
||||
float m_scrollDelta = 0.0f; //!< The delta used for dolly/movement (translation) - one dimensional.
|
||||
};
|
||||
|
||||
class RotateCameraInput : public CameraInput
|
||||
@@ -237,7 +241,7 @@ namespace AzFramework
|
||||
inline PanAxes LookPan(const Camera& camera)
|
||||
{
|
||||
const AZ::Matrix3x3 orientation = camera.Rotation();
|
||||
return {orientation.GetBasisX(), orientation.GetBasisZ()};
|
||||
return { orientation.GetBasisX(), orientation.GetBasisZ() };
|
||||
}
|
||||
|
||||
inline PanAxes OrbitPan(const Camera& camera)
|
||||
@@ -245,12 +249,13 @@ namespace AzFramework
|
||||
const AZ::Matrix3x3 orientation = camera.Rotation();
|
||||
|
||||
const auto basisX = orientation.GetBasisX();
|
||||
const auto basisY = [&orientation] {
|
||||
const auto basisY = [&orientation]
|
||||
{
|
||||
const auto forward = orientation.GetBasisY();
|
||||
return AZ::Vector3(forward.GetX(), forward.GetY(), 0.0f).GetNormalized();
|
||||
}();
|
||||
|
||||
return {basisX, basisY};
|
||||
return { basisX, basisY };
|
||||
}
|
||||
|
||||
class PanCameraInput : public CameraInput
|
||||
@@ -285,7 +290,8 @@ namespace AzFramework
|
||||
const AZ::Matrix3x3 orientation = camera.Rotation();
|
||||
|
||||
const auto basisX = orientation.GetBasisX();
|
||||
const auto basisY = [&orientation] {
|
||||
const auto basisY = [&orientation]
|
||||
{
|
||||
const auto forward = orientation.GetBasisY();
|
||||
return AZ::Vector3(forward.GetX(), forward.GetY(), 0.0f).GetNormalized();
|
||||
}();
|
||||
@@ -398,7 +404,7 @@ namespace AzFramework
|
||||
class OrbitCameraInput : public CameraInput
|
||||
{
|
||||
public:
|
||||
using LookAtFn = AZStd::function<AZStd::optional<AZ::Vector3>()>;
|
||||
using LookAtFn = AZStd::function<AZStd::optional<AZ::Vector3>(const AZ::Vector3& position, const AZ::Vector3& direction)>;
|
||||
|
||||
// CameraInput overrides ...
|
||||
bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override;
|
||||
|
||||
+2
-1
@@ -35,7 +35,8 @@ namespace AzFramework::AssetSystem::Platform
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
|
||||
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor";
|
||||
assetProcessorPath =
|
||||
AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_TRAIT_OS_PLATFORM_NAME / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor";
|
||||
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
|
||||
+2
-1
@@ -34,7 +34,8 @@ namespace AzFramework::AssetSystem::Platform
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
|
||||
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.app";
|
||||
assetProcessorPath =
|
||||
AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_TRAIT_OS_PLATFORM_NAME / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.app";
|
||||
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
|
||||
+2
-1
@@ -71,7 +71,8 @@ namespace AzFramework::AssetSystem::Platform
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
|
||||
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.exe";
|
||||
assetProcessorPath =
|
||||
AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_TRAIT_OS_PLATFORM_NAME / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.exe";
|
||||
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ QMenu::right-arrow
|
||||
|
||||
QMenu::icon
|
||||
{
|
||||
right: 8px;
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
QMenu::indicator:checked
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M11.0708 0.87087L11.0708 0.87074C10.4286 0.371024 9.61107 0.13517 8.79265 0.213464C7.97422 0.291757 7.21961 0.678004 6.6897 1.28985L5.76756 2.36366C5.63378 2.51944 5.56909 2.72055 5.58771 2.92273C5.60634 3.12492 5.70675 3.31163 5.86686 3.44178C6.02698 3.57194 6.23368 3.63488 6.44149 3.61676C6.6493 3.59864 6.8412 3.50094 6.97498 3.34516L7.89716 2.27122C8.03184 2.11488 8.19736 1.98639 8.38395 1.89334C8.57053 1.8003 8.7744 1.74459 8.98349 1.7295C9.19258 1.71442 9.40266 1.74027 9.60131 1.80552C9.79996 1.87078 9.98315 1.97411 10.1401 2.10942C10.4422 2.38256 10.6244 2.75851 10.6488 3.15904C10.6732 3.55957 10.5379 3.95383 10.2711 4.25978L8.35381 6.49309L8.33616 6.51209C8.23375 6.62767 8.11374 6.72729 7.98031 6.80749C7.67189 6.99364 7.30661 7.06983 6.94686 7.02305C6.58711 6.97626 6.25522 6.8094 6.00789 6.55097C5.86556 6.40288 5.66865 6.31578 5.46039 6.30879C5.25213 6.30179 5.04952 6.37546 4.89703 6.51365C4.74453 6.65183 4.65462 6.84323 4.64701 7.04584C4.6394 7.24845 4.71472 7.44572 4.85645 7.59436C5.21222 7.96578 5.65746 8.24515 6.15198 8.40726C6.6465 8.56937 7.17473 8.60911 7.68898 8.52289C7.84983 8.49539 8.00828 8.45599 8.16298 8.40505C8.70939 8.22568 9.19408 7.90261 9.56335 7.47165L11.4758 5.24457C11.7478 4.92529 11.9523 4.55683 12.0773 4.16038C12.2024 3.76394 12.2457 3.34735 12.2046 2.93457C12.1671 2.53429 12.0475 2.1454 11.8527 1.79092C11.658 1.43644 11.3921 1.12358 11.0708 0.87087Z" fill="white"/>
|
||||
<path d="M5.40958 9.14055L4.58546 10.1003C4.32342 10.4101 3.94867 10.6097 3.53919 10.6576C3.12972 10.7054 2.71706 10.5977 2.3871 10.357C2.22234 10.2309 2.08525 10.0738 1.98392 9.89526C1.8826 9.71668 1.81911 9.52014 1.79719 9.31727C1.77528 9.1144 1.79539 8.90932 1.85634 8.71414C1.91729 8.51896 2.01784 8.33765 2.15204 8.18093L4.10231 5.90975L4.11666 5.89415C4.21908 5.77861 4.3391 5.67903 4.47254 5.59887C4.75216 5.42921 5.07976 5.34988 5.4085 5.37222C5.73725 5.39457 6.05033 5.51745 6.30299 5.72329C6.3635 5.77246 6.42015 5.82595 6.47246 5.88333C6.54738 5.9658 6.63971 6.03156 6.74316 6.07611C6.84661 6.12066 6.95872 6.14295 7.07184 6.14146C7.18361 6.13992 7.29372 6.11492 7.39465 6.06817C7.49558 6.02143 7.58495 5.95403 7.65666 5.8706L7.66607 5.85958C7.78641 5.72083 7.85132 5.54454 7.8489 5.36301C7.84647 5.18148 7.77687 5.00689 7.65286 4.87124C7.35341 4.54132 6.98422 4.27825 6.57057 4.10003C6.15692 3.92182 5.70858 3.83266 5.25623 3.83866C4.80388 3.84467 4.35821 3.94569 3.94971 4.13482C3.54122 4.32395 3.17954 4.59672 2.88945 4.93446L0.944626 7.19943C0.420065 7.81564 0.163643 8.60683 0.230025 9.40433C0.296406 10.2018 0.68034 10.9426 1.29998 11.4686C1.61272 11.7312 1.97644 11.9301 2.3696 12.0535C2.76277 12.1769 3.17738 12.2223 3.5889 12.187C3.687 12.1793 3.78434 12.1672 3.88093 12.1507C4.62877 12.0232 5.30663 11.6437 5.79562 11.0786L6.617 10.1221C6.75077 9.96628 6.81547 9.76517 6.79684 9.56299C6.77822 9.3608 6.6778 9.17409 6.51769 9.04394C6.35758 8.91378 6.15088 8.85084 5.94306 8.86896C5.73525 8.88708 5.54335 8.98477 5.40957 9.14055H5.40958Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -13,5 +13,6 @@
|
||||
<qresource prefix="/Notifications">
|
||||
<file alias="checkmark.svg">Notifications/checkmark.svg</file>
|
||||
<file alias="download.svg">Notifications/download.svg</file>
|
||||
<file alias="link.svg">Notifications/link.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -39,4 +39,3 @@
|
||||
#define AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_EDITOR_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_METRICS_TESTS true
|
||||
|
||||
#define AZ_TRAIT_DISABLE_ASSET_JOB_PARALLEL_TESTS true
|
||||
|
||||
@@ -483,6 +483,8 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
m_dirty = false;
|
||||
|
||||
AddRecentPath(targetFilePath);
|
||||
|
||||
SetStatusText(Status::assetCreated);
|
||||
|
||||
+18
-11
@@ -57,7 +57,6 @@ namespace AzToolsFramework
|
||||
"Couldn't get prefab loader interface, it's a requirement for PrefabEntityOwnership system to work");
|
||||
|
||||
m_rootInstance = AZStd::unique_ptr<Prefab::Instance>(m_prefabSystemComponent->CreatePrefab({}, {}, "NewLevel.prefab"));
|
||||
|
||||
m_sliceOwnershipService.BusConnect(m_entityContextId);
|
||||
m_sliceOwnershipService.m_shouldAssertForLegacySlicesUsage = m_shouldAssertForLegacySlicesUsage;
|
||||
m_editorSliceOwnershipService.BusConnect();
|
||||
@@ -91,14 +90,17 @@ namespace AzToolsFramework
|
||||
|
||||
void PrefabEditorEntityOwnershipService::Reset()
|
||||
{
|
||||
Prefab::TemplateId templateId = m_rootInstance->GetTemplateId();
|
||||
if (templateId != Prefab::InvalidTemplateId)
|
||||
if (m_rootInstance)
|
||||
{
|
||||
m_rootInstance->SetTemplateId(Prefab::InvalidTemplateId);
|
||||
m_prefabSystemComponent->RemoveTemplate(templateId);
|
||||
Prefab::TemplateId templateId = m_rootInstance->GetTemplateId();
|
||||
if (templateId != Prefab::InvalidTemplateId)
|
||||
{
|
||||
m_rootInstance->SetTemplateId(Prefab::InvalidTemplateId);
|
||||
m_prefabSystemComponent->RemoveTemplate(templateId);
|
||||
}
|
||||
m_rootInstance->Reset();
|
||||
m_rootInstance->SetContainerEntityName("Level");
|
||||
}
|
||||
m_rootInstance->Reset();
|
||||
m_rootInstance->SetContainerEntityName("Level");
|
||||
|
||||
AzFramework::EntityOwnershipServiceNotificationBus::Event(
|
||||
m_entityContextId, &AzFramework::EntityOwnershipServiceNotificationBus::Events::OnEntityOwnershipServiceReset);
|
||||
@@ -202,7 +204,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
m_rootInstance->SetTemplateId(templateId);
|
||||
m_rootInstance->SetTemplateSourcePath(m_loaderInterface->GetRelativePathToProject(filename));
|
||||
m_rootInstance->SetTemplateSourcePath(m_loaderInterface->GenerateRelativePath(filename));
|
||||
m_rootInstance->SetContainerEntityName("Level");
|
||||
m_prefabSystemComponent->PropagateTemplateChanges(templateId);
|
||||
|
||||
@@ -220,7 +222,7 @@ namespace AzToolsFramework
|
||||
|
||||
bool PrefabEditorEntityOwnershipService::SaveToStream(AZ::IO::GenericStream& stream, AZStd::string_view filename)
|
||||
{
|
||||
AZ::IO::Path relativePath = m_loaderInterface->GetRelativePathToProject(filename);
|
||||
AZ::IO::Path relativePath = m_loaderInterface->GenerateRelativePath(filename);
|
||||
AzToolsFramework::Prefab::TemplateId templateId = m_prefabSystemComponent->GetTemplateIdFromFilePath(relativePath);
|
||||
|
||||
m_rootInstance->SetTemplateSourcePath(relativePath);
|
||||
@@ -267,7 +269,7 @@ namespace AzToolsFramework
|
||||
|
||||
void PrefabEditorEntityOwnershipService::CreateNewLevelPrefab(AZStd::string_view filename, const AZStd::string& templateFilename)
|
||||
{
|
||||
AZ::IO::Path relativePath = m_loaderInterface->GetRelativePathToProject(filename);
|
||||
AZ::IO::Path relativePath = m_loaderInterface->GenerateRelativePath(filename);
|
||||
AzToolsFramework::Prefab::TemplateId templateId = m_prefabSystemComponent->GetTemplateIdFromFilePath(relativePath);
|
||||
|
||||
m_rootInstance->SetTemplateSourcePath(relativePath);
|
||||
@@ -378,7 +380,12 @@ namespace AzToolsFramework
|
||||
Prefab::InstanceOptionalReference PrefabEditorEntityOwnershipService::GetRootPrefabInstance()
|
||||
{
|
||||
AZ_Assert(m_rootInstance, "A valid root prefab instance couldn't be found in PrefabEditorEntityOwnershipService.");
|
||||
return *m_rootInstance;
|
||||
if (m_rootInstance)
|
||||
{
|
||||
return *m_rootInstance;
|
||||
}
|
||||
|
||||
return AZStd::nullopt;
|
||||
}
|
||||
|
||||
const AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>& PrefabEditorEntityOwnershipService::GetPlayInEditorAssetData()
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace AzToolsFramework
|
||||
AZ::Transform result;
|
||||
result.SetRotation(m_space.GetRotation() * localTransform.GetRotation());
|
||||
result.SetTranslation(m_space.TransformPoint(m_nonUniformScale * localTransform.GetTranslation()));
|
||||
result.SetScale(m_space.GetScale() * localTransform.GetUniformScale());
|
||||
result.SetUniformScale(m_space.GetUniformScale() * localTransform.GetUniformScale());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ namespace AzToolsFramework
|
||||
"PrefabLoaderInterface could not be found. It is required to load Prefab Instances");
|
||||
|
||||
// Make sure we have a relative path
|
||||
instance->m_templateSourcePath = loaderInterface->GetRelativePathToProject(instance->m_templateSourcePath);
|
||||
instance->m_templateSourcePath = loaderInterface->GenerateRelativePath(instance->m_templateSourcePath);
|
||||
|
||||
TemplateId templateId = prefabSystemComponentInterface->GetTemplateIdFromFilePath(instance->GetTemplateSourcePath());
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
|
||||
#include <AzFramework/Asset/AssetSystemBus.h>
|
||||
#include <AzFramework/FileFunc/FileFunc.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
|
||||
@@ -112,7 +114,7 @@ namespace AzToolsFramework
|
||||
return InvalidTemplateId;
|
||||
}
|
||||
|
||||
AZ::IO::Path relativePath = GetRelativePathToProject(originPath);
|
||||
AZ::IO::Path relativePath = GenerateRelativePath(originPath);
|
||||
|
||||
// Cyclical dependency detected if the prefab file is already part of the progressed
|
||||
// file path set.
|
||||
@@ -301,6 +303,45 @@ namespace AzToolsFramework
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrefabLoader::SaveTemplateToFile(TemplateId templateId, AZ::IO::PathView absolutePath)
|
||||
{
|
||||
AZ_Assert(absolutePath.IsAbsolute(), "SaveTemplateToFile requires an absolute path for saving the initial prefab file.");
|
||||
|
||||
const auto& domAndFilepath = StoreTemplateIntoFileFormat(templateId);
|
||||
if (!domAndFilepath)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify that the absolute path provided to this matches the relative path saved in the template.
|
||||
// Otherwise, the saved prefab won't be able to be loaded.
|
||||
auto relativePath = GenerateRelativePath(absolutePath);
|
||||
if (relativePath != domAndFilepath->second)
|
||||
{
|
||||
AZ_Error(
|
||||
"Prefab", false,
|
||||
"PrefabLoader::SaveTemplateToFile - "
|
||||
"Failed to save template '%s' to location '%.*s'."
|
||||
"Error: Relative path '%.*s' for location didn't match template name.",
|
||||
domAndFilepath->second.c_str(), AZ_STRING_ARG(absolutePath.Native()), AZ_STRING_ARG(relativePath.Native()));
|
||||
return false;
|
||||
}
|
||||
|
||||
auto outcome = AzFramework::FileFunc::WriteJsonFile(domAndFilepath->first, absolutePath);
|
||||
if (!outcome.IsSuccess())
|
||||
{
|
||||
AZ_Error(
|
||||
"Prefab", false,
|
||||
"PrefabLoader::SaveTemplateToFile - "
|
||||
"Failed to save template '%s' to location '%.*s'."
|
||||
"Error: %s",
|
||||
domAndFilepath->second.c_str(), AZ_STRING_ARG(absolutePath.Native()), outcome.GetError().c_str());
|
||||
return false;
|
||||
}
|
||||
m_prefabSystemComponentInterface->SetTemplateDirtyFlag(templateId, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrefabLoader::SaveTemplateToString(TemplateId templateId, AZStd::string& output)
|
||||
{
|
||||
const auto& domAndFilepath = StoreTemplateIntoFileFormat(templateId);
|
||||
@@ -385,21 +426,100 @@ namespace AzToolsFramework
|
||||
AZ::IO::Path pathWithOSSeparator = AZ::IO::Path(path).MakePreferred();
|
||||
if (pathWithOSSeparator.IsAbsolute())
|
||||
{
|
||||
// If an absolute path was passed in, just return it as-is.
|
||||
return path;
|
||||
}
|
||||
|
||||
return AZ::IO::Path(m_projectPathWithOsSeparator).Append(pathWithOSSeparator);
|
||||
// A relative path was passed in, so try to turn it back into an absolute path.
|
||||
|
||||
AZ::IO::Path fullPath;
|
||||
|
||||
bool pathFound = false;
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
AZStd::string rootFolder;
|
||||
AZStd::string inputPath(path.Native());
|
||||
|
||||
// Given an input path that's expected to exist, try to look it up.
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
pathFound, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath,
|
||||
inputPath.c_str(), assetInfo, rootFolder);
|
||||
|
||||
if (pathFound)
|
||||
{
|
||||
// The asset system provided us with a valid root folder and relative path, so return it.
|
||||
fullPath = AZ::IO::Path(rootFolder) / assetInfo.m_relativePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If for some reason the Asset system couldn't provide a relative path, provide some fallback logic.
|
||||
|
||||
// Check to see if the AssetProcessor is ready. If it *is* and we didn't get a path, print an error then follow
|
||||
// the fallback logic. If it's *not* ready, we're probably either extremely early in a tool startup flow or inside
|
||||
// a unit test, so just execute the fallback logic without an error.
|
||||
[[maybe_unused]] bool assetProcessorReady = false;
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
assetProcessorReady, &AzFramework::AssetSystemRequestBus::Events::AssetProcessorIsReady);
|
||||
|
||||
AZ_Error(
|
||||
"Prefab", !assetProcessorReady, "Full source path for '%.*s' could not be determined. Using fallback logic.",
|
||||
AZ_STRING_ARG(path.Native()));
|
||||
|
||||
// If a relative path was passed in, make it relative to the project root.
|
||||
fullPath = AZ::IO::Path(m_projectPathWithOsSeparator).Append(pathWithOSSeparator);
|
||||
}
|
||||
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
AZ::IO::Path PrefabLoader::GetRelativePathToProject(AZ::IO::PathView path)
|
||||
AZ::IO::Path PrefabLoader::GenerateRelativePath(AZ::IO::PathView path)
|
||||
{
|
||||
AZ::IO::Path pathWithOSSeparator = AZ::IO::Path(path.Native()).MakePreferred();
|
||||
if (!pathWithOSSeparator.IsAbsolute())
|
||||
bool pathFound = false;
|
||||
|
||||
AZStd::string relativePath;
|
||||
AZStd::string rootFolder;
|
||||
AZ::IO::Path finalPath;
|
||||
|
||||
// The asset system allows for paths to be relative to multiple root folders, using a priority system.
|
||||
// This request will make the input path relative to the most appropriate, highest-priority root folder.
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
pathFound, &AzToolsFramework::AssetSystemRequestBus::Events::GenerateRelativeSourcePath, path.Native(),
|
||||
relativePath, rootFolder);
|
||||
|
||||
if (pathFound && !relativePath.empty())
|
||||
{
|
||||
return path;
|
||||
// A relative path was generated successfully, so return it.
|
||||
finalPath = relativePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If for some reason the Asset system couldn't provide a relative path, provide some fallback logic.
|
||||
|
||||
// Check to see if the AssetProcessor is ready. If it *is* and we didn't get a path, print an error then follow
|
||||
// the fallback logic. If it's *not* ready, we're probably either extremely early in a tool startup flow or inside
|
||||
// a unit test, so just execute the fallback logic without an error.
|
||||
[[maybe_unused]] bool assetProcessorReady = false;
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
assetProcessorReady, &AzFramework::AssetSystemRequestBus::Events::AssetProcessorIsReady);
|
||||
|
||||
AZ_Error("Prefab", !assetProcessorReady,
|
||||
"Relative source path for '%.*s' could not be determined. Using project path as relative root.",
|
||||
AZ_STRING_ARG(path.Native()));
|
||||
|
||||
AZ::IO::Path pathWithOSSeparator = AZ::IO::Path(path.Native()).MakePreferred();
|
||||
|
||||
if (pathWithOSSeparator.IsAbsolute())
|
||||
{
|
||||
// If an absolute path was passed in, make it relative to the project path.
|
||||
finalPath = AZ::IO::Path(path.Native(), '/').MakePreferred().LexicallyRelative(m_projectPathWithSlashSeparator);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If a relative path was passed in, just return it.
|
||||
finalPath = path;
|
||||
}
|
||||
}
|
||||
|
||||
return AZ::IO::Path(path.Native(), '/').MakePreferred().LexicallyRelative(m_projectPathWithSlashSeparator);
|
||||
return finalPath;
|
||||
}
|
||||
|
||||
AZ::IO::Path PrefabLoaderInterface::GeneratePath()
|
||||
|
||||
@@ -72,6 +72,16 @@ namespace AzToolsFramework
|
||||
*/
|
||||
bool SaveTemplate(TemplateId templateId) override;
|
||||
|
||||
/**
|
||||
* Saves a Prefab Template to the provided absolute source path, which needs to match the relative path in the template.
|
||||
* Converts Prefab Template form into .prefab form by collapsing nested Template info
|
||||
* into a source path and patches.
|
||||
* @param templateId Id of the template to be saved
|
||||
* @param absolutePath Absolute path to save the file to
|
||||
* @return bool on whether the operation succeeded or not
|
||||
*/
|
||||
bool SaveTemplateToFile(TemplateId templateId, AZ::IO::PathView absolutePath) override;
|
||||
|
||||
/**
|
||||
* Saves a Prefab Template into the provided output string.
|
||||
* Converts Prefab Template form into .prefab form by collapsing nested Template info
|
||||
@@ -91,9 +101,11 @@ namespace AzToolsFramework
|
||||
//! The path will always have the correct separator for the current OS
|
||||
AZ::IO::Path GetFullPath(AZ::IO::PathView path) override;
|
||||
|
||||
//! Converts path into a relative path to the project, this will be the paths in .prefab file.
|
||||
//! The path will always have '/' separator.
|
||||
AZ::IO::Path GetRelativePathToProject(AZ::IO::PathView path) override;
|
||||
//! Converts path into a path that's relative to the highest-priority containing folder of all the folders registered
|
||||
//! with the engine.
|
||||
//! This path will be the path that appears in the .prefab file.
|
||||
//! The path will always use the '/' separator.
|
||||
AZ::IO::Path GenerateRelativePath(AZ::IO::PathView path) override;
|
||||
|
||||
//! Returns if the path is a valid path for a prefab
|
||||
static bool IsValidPrefabPath(AZ::IO::PathView path);
|
||||
|
||||
@@ -60,6 +60,16 @@ namespace AzToolsFramework
|
||||
*/
|
||||
virtual bool SaveTemplate(TemplateId templateId) = 0;
|
||||
|
||||
/**
|
||||
* Saves a Prefab Template to the provided absolute source path, which needs to match the relative path in the template.
|
||||
* Converts Prefab Template form into .prefab form by collapsing nested Template info
|
||||
* into a source path and patches.
|
||||
* @param templateId Id of the template to be saved
|
||||
* @param absolutePath Absolute path to save the file to
|
||||
* @return bool on whether the operation succeeded or not
|
||||
*/
|
||||
virtual bool SaveTemplateToFile(TemplateId templateId, AZ::IO::PathView absolutePath) = 0;
|
||||
|
||||
/**
|
||||
* Saves a Prefab Template into the provided output string.
|
||||
* Converts Prefab Template form into .prefab form by collapsing nested Template info
|
||||
@@ -74,9 +84,11 @@ namespace AzToolsFramework
|
||||
//! The path will always have the correct separator for the current OS
|
||||
virtual AZ::IO::Path GetFullPath(AZ::IO::PathView path) = 0;
|
||||
|
||||
//! Converts path into a relative path to the current project, this will be the paths in .prefab file.
|
||||
//! The path will always have '/' separator.
|
||||
virtual AZ::IO::Path GetRelativePathToProject(AZ::IO::PathView path) = 0;
|
||||
//! Converts path into a path that's relative to the highest-priority containing folder of all the folders registered
|
||||
//! with the engine.
|
||||
//! This path will be the path that appears in the .prefab file.
|
||||
//! The path will always use the '/' separator.
|
||||
virtual AZ::IO::Path GenerateRelativePath(AZ::IO::PathView path) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace AzToolsFramework
|
||||
m_prefabUndoCache.Destroy();
|
||||
}
|
||||
|
||||
PrefabOperationResult PrefabPublicHandler::CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath)
|
||||
PrefabOperationResult PrefabPublicHandler::CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView absolutePath)
|
||||
{
|
||||
EntityList inputEntityList, topLevelEntities;
|
||||
AZ::EntityId commonRootEntityId;
|
||||
@@ -76,6 +76,8 @@ namespace AzToolsFramework
|
||||
return findCommonRootOutcome;
|
||||
}
|
||||
|
||||
AZ_Assert(absolutePath.IsAbsolute(), "CreatePrefab requires an absolute path for saving the initial prefab file.");
|
||||
|
||||
InstanceOptionalReference instanceToCreate;
|
||||
{
|
||||
// Initialize Undo Batch object
|
||||
@@ -144,7 +146,8 @@ namespace AzToolsFramework
|
||||
|
||||
// Create the Prefab
|
||||
instanceToCreate = prefabEditorEntityOwnershipInterface->CreatePrefab(
|
||||
entities, AZStd::move(instancePtrs), filePath, commonRootEntityOwningInstance);
|
||||
entities, AZStd::move(instancePtrs), m_prefabLoaderInterface->GenerateRelativePath(absolutePath),
|
||||
commonRootEntityOwningInstance);
|
||||
|
||||
if (!instanceToCreate)
|
||||
{
|
||||
@@ -254,7 +257,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
// Save Template to file
|
||||
m_prefabLoaderInterface->SaveTemplate(instanceToCreate->get().GetTemplateId());
|
||||
m_prefabLoaderInterface->SaveTemplateToFile(instanceToCreate->get().GetTemplateId(), absolutePath);
|
||||
|
||||
return AZ::Success();
|
||||
}
|
||||
@@ -318,7 +321,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
//Detect whether this instantiation would produce a cyclical dependency
|
||||
auto relativePath = m_prefabLoaderInterface->GetRelativePathToProject(filePath);
|
||||
auto relativePath = m_prefabLoaderInterface->GenerateRelativePath(filePath);
|
||||
Prefab::TemplateId templateId = m_prefabSystemComponentInterface->GetTemplateIdFromFilePath(relativePath);
|
||||
|
||||
if (templateId == InvalidTemplateId)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace AzToolsFramework
|
||||
void UnregisterPrefabPublicHandlerInterface();
|
||||
|
||||
// PrefabPublicInterface...
|
||||
PrefabOperationResult CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath) override;
|
||||
PrefabOperationResult CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView absolutePath) override;
|
||||
PrefabOperationResult InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) override;
|
||||
PrefabOperationResult SavePrefab(AZ::IO::Path filePath) override;
|
||||
PrefabEntityResult CreateEntity(AZ::EntityId parentId, const AZ::Vector3& position) override;
|
||||
|
||||
@@ -46,10 +46,10 @@ namespace AzToolsFramework
|
||||
* Create a prefab out of the entities provided, at the path provided.
|
||||
* Automatically detects descendants of entities, and discerns between entities and child instances.
|
||||
* @param entityIds The entities that should form the new prefab (along with their descendants).
|
||||
* @param filePath The path for the new prefab file.
|
||||
* @param filePath The absolute path for the new prefab file.
|
||||
* @return An outcome object; on failure, it comes with an error message detailing the cause of the error.
|
||||
*/
|
||||
virtual PrefabOperationResult CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath) = 0;
|
||||
virtual PrefabOperationResult CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView absolutePath) = 0;
|
||||
|
||||
/**
|
||||
* Instantiate a prefab from a prefab file.
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace AzToolsFramework
|
||||
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume,
|
||||
AZ::IO::PathView filePath, AZStd::unique_ptr<AZ::Entity> containerEntity, bool shouldCreateLinks)
|
||||
{
|
||||
AZ::IO::Path relativeFilePath = m_prefabLoader.GetRelativePathToProject(filePath);
|
||||
AZ::IO::Path relativeFilePath = m_prefabLoader.GenerateRelativePath(filePath);
|
||||
if (GetTemplateIdFromFilePath(relativeFilePath) != InvalidTemplateId)
|
||||
{
|
||||
AZ_Error("Prefab", false,
|
||||
|
||||
+2
-3
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Casting/lossy_cast.h>
|
||||
#include <AzFramework/Spawnable/SpawnableAssetHandler.h>
|
||||
#include <AzToolsFramework/Prefab/Spawnable/ProcesedObjectStore.h>
|
||||
|
||||
namespace AzToolsFramework::Prefab::PrefabConversionUtils
|
||||
@@ -73,8 +73,7 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
|
||||
|
||||
uint32_t ProcessedObjectStore::BuildSubId(AZStd::string_view id)
|
||||
{
|
||||
AZ::Uuid subIdHash = AZ::Uuid::CreateData(id.data(), id.size());
|
||||
return azlossy_caster(subIdHash.GetHash());
|
||||
return AzFramework::SpawnableAssetHandler::BuildSubId(id);
|
||||
}
|
||||
|
||||
const AZStd::string& ProcessedObjectStore::GetId() const
|
||||
|
||||
@@ -24,17 +24,6 @@
|
||||
|
||||
namespace AzToolsFramework::Prefab::SpawnableUtils
|
||||
{
|
||||
|
||||
AzFramework::Spawnable CreateSpawnable(const PrefabDom& prefabDom)
|
||||
{
|
||||
AzFramework::Spawnable spawnable;
|
||||
AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>> referencedAssets;
|
||||
[[maybe_unused]] bool result = CreateSpawnable(spawnable, prefabDom, referencedAssets);
|
||||
AZ_Assert(result,
|
||||
"Failed to Load Prefab Instance from given Prefab DOM while Spawnable creation.");
|
||||
return spawnable;
|
||||
}
|
||||
|
||||
bool CreateSpawnable(AzFramework::Spawnable& spawnable, const PrefabDom& prefabDom)
|
||||
{
|
||||
AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>> referencedAssets;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
namespace AzToolsFramework::Prefab::SpawnableUtils
|
||||
{
|
||||
AzFramework::Spawnable CreateSpawnable(const PrefabDom& prefabDom);
|
||||
bool CreateSpawnable(AzFramework::Spawnable& spawnable, const PrefabDom& prefabDom);
|
||||
bool CreateSpawnable(AzFramework::Spawnable& spawnable, const PrefabDom& prefabDom, AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>& referencedAssets);
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ namespace AzToolsFramework
|
||||
|
||||
AZ::Transform worldFromLocal = AZ::Transform::CreateIdentity();
|
||||
AZ::TransformBus::EventResult(worldFromLocal, m_entityComponentIdPair.GetEntityId(), &AZ::TransformBus::Events::GetWorldTM);
|
||||
worldFromLocal.ExtractScale();
|
||||
worldFromLocal.ExtractUniformScale();
|
||||
m_manipulators = AZStd::make_unique<ScaleManipulators>(worldFromLocal);
|
||||
m_manipulators->Register(g_mainManipulatorManagerId);
|
||||
m_manipulators->SetAxes(AZ::Vector3::CreateAxisX(), AZ::Vector3::CreateAxisY(), AZ::Vector3::CreateAxisZ());
|
||||
|
||||
+36
-27
@@ -32,7 +32,6 @@
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformScalePropertyHandler.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorInspectorComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorPendingCompositionBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
@@ -50,10 +49,10 @@ namespace AzToolsFramework
|
||||
{
|
||||
const AZ::u32 ParentEntityCRC = AZ_CRC("Parent Entity", 0x5b1b276c);
|
||||
|
||||
// Decompose a transform into euler angles in degrees, scale (along basis, any shear will be dropped), and translation.
|
||||
void DecomposeTransform(const AZ::Transform& transform, AZ::Vector3& translation, AZ::Vector3& rotation, AZ::Vector3& scale)
|
||||
// Decompose a transform into euler angles in degrees, uniform scale, and translation.
|
||||
void DecomposeTransform(const AZ::Transform& transform, AZ::Vector3& translation, AZ::Vector3& rotation, float& scale)
|
||||
{
|
||||
scale = transform.GetScale();
|
||||
scale = transform.GetUniformScale();
|
||||
translation = transform.GetTranslation();
|
||||
rotation = transform.GetRotation().GetEulerDegrees();
|
||||
}
|
||||
@@ -120,7 +119,7 @@ namespace AzToolsFramework
|
||||
// Decompose the old slice-relative transform and set it as a our editor transform,
|
||||
// since the entity is now our parent.
|
||||
EditorTransform editorTransform;
|
||||
DecomposeTransform(sliceRelTransform, editorTransform.m_translate, editorTransform.m_rotate, editorTransform.m_scale);
|
||||
DecomposeTransform(sliceRelTransform, editorTransform.m_translate, editorTransform.m_rotate, editorTransform.m_uniformScale);
|
||||
editorTransformElement.Convert<EditorTransform>(context);
|
||||
editorTransformElement.SetData(context, editorTransform);
|
||||
}
|
||||
@@ -170,6 +169,23 @@ namespace AzToolsFramework
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EditorTransformDataConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement)
|
||||
{
|
||||
if (classElement.GetVersion() < 3)
|
||||
{
|
||||
// version 3 replaces vector scale with uniform scale but does not yet delete the legacy scale data
|
||||
// in order to allow for migration
|
||||
AZ::Vector3 vectorScale;
|
||||
if (classElement.FindSubElementAndGetData<AZ::Vector3>(AZ_CRC_CE("Scale"), vectorScale))
|
||||
{
|
||||
const float uniformScale = vectorScale.GetMaxElement();
|
||||
classElement.AddElementWithData(context, "UniformScale", uniformScale);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace Internal
|
||||
|
||||
TransformComponent::TransformComponent()
|
||||
@@ -357,7 +373,7 @@ namespace AzToolsFramework
|
||||
|
||||
AZ::Transform TransformComponent::GetLocalScaleTM() const
|
||||
{
|
||||
return AZ::Transform::CreateUniformScale(m_editorTransform.m_scale.GetMaxElement());
|
||||
return AZ::Transform::CreateUniformScale(m_editorTransform.m_uniformScale);
|
||||
}
|
||||
|
||||
const AZ::Transform& TransformComponent::GetLocalTM()
|
||||
@@ -374,12 +390,13 @@ namespace AzToolsFramework
|
||||
// given a local transform, update local transform.
|
||||
void TransformComponent::SetLocalTM(const AZ::Transform& finalTx)
|
||||
{
|
||||
AZ::Vector3 tx, rot, scale;
|
||||
Internal::DecomposeTransform(finalTx, tx, rot, scale);
|
||||
AZ::Vector3 tx, rot;
|
||||
float uniformScale;
|
||||
Internal::DecomposeTransform(finalTx, tx, rot, uniformScale);
|
||||
|
||||
m_editorTransform.m_translate = tx;
|
||||
m_editorTransform.m_rotate = rot;
|
||||
m_editorTransform.m_scale = scale;
|
||||
m_editorTransform.m_uniformScale = uniformScale;
|
||||
|
||||
TransformChanged();
|
||||
}
|
||||
@@ -599,31 +616,21 @@ namespace AzToolsFramework
|
||||
return result;
|
||||
}
|
||||
|
||||
void TransformComponent::SetLocalScale(const AZ::Vector3& scale)
|
||||
{
|
||||
m_editorTransform.m_scale = scale;
|
||||
TransformChanged();
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformComponent::GetLocalScale()
|
||||
{
|
||||
return m_editorTransform.m_scale;
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformComponent::GetWorldScale()
|
||||
{
|
||||
return GetWorldTM().GetScale();
|
||||
AZ_WarningOnce("TransformComponent", false, "GetLocalScale is deprecated, please use GetLocalUniformScale instead");
|
||||
return m_editorTransform.m_legacyScale;
|
||||
}
|
||||
|
||||
void TransformComponent::SetLocalUniformScale(float scale)
|
||||
{
|
||||
m_editorTransform.m_scale = AZ::Vector3(scale);
|
||||
m_editorTransform.m_uniformScale = scale;
|
||||
TransformChanged();
|
||||
}
|
||||
|
||||
float TransformComponent::GetLocalUniformScale()
|
||||
{
|
||||
return m_editorTransform.m_scale.GetMaxElement();
|
||||
return m_editorTransform.m_uniformScale;
|
||||
}
|
||||
|
||||
float TransformComponent::GetWorldUniformScale()
|
||||
@@ -1141,9 +1148,10 @@ namespace AzToolsFramework
|
||||
serializeContext->Class<EditorTransform>()->
|
||||
Field("Translate", &EditorTransform::m_translate)->
|
||||
Field("Rotate", &EditorTransform::m_rotate)->
|
||||
Field("Scale", &EditorTransform::m_scale)->
|
||||
Field("Scale", &EditorTransform::m_legacyScale)->
|
||||
Field("Locked", &EditorTransform::m_locked)->
|
||||
Version(2);
|
||||
Field("UniformScale", &EditorTransform::m_uniformScale)->
|
||||
Version(3, &Internal::EditorTransformDataConverter);
|
||||
|
||||
serializeContext->Class<Components::TransformComponent, EditorComponentBase>()->
|
||||
Field("Parent Entity", &TransformComponent::m_parentEntityId)->
|
||||
@@ -1202,7 +1210,7 @@ namespace AzToolsFramework
|
||||
Attribute(AZ::Edit::Attributes::Suffix, " deg")->
|
||||
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)->
|
||||
Attribute(AZ::Edit::Attributes::SliceFlags, AZ::Edit::SliceFlags::NotPushableOnSliceRoot)->
|
||||
DataElement(TransformScaleHandler, &EditorTransform::m_scale, "Scale", "Local Scale")->
|
||||
DataElement(AZ::Edit::UIHandlers::Default, &EditorTransform::m_uniformScale, "Uniform Scale", "Local Uniform Scale")->
|
||||
Attribute(AZ::Edit::Attributes::Step, 0.1f)->
|
||||
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)
|
||||
;
|
||||
@@ -1230,7 +1238,8 @@ namespace AzToolsFramework
|
||||
{
|
||||
AzToolsFramework::ScopedUndoBatch undo("Reset transform values");
|
||||
m_editorTransform.m_translate = AZ::Vector3::CreateZero();
|
||||
m_editorTransform.m_scale = AZ::Vector3::CreateOne();
|
||||
m_editorTransform.m_legacyScale = AZ::Vector3::CreateOne();
|
||||
m_editorTransform.m_uniformScale = 1.0f;
|
||||
m_editorTransform.m_rotate = AZ::Vector3::CreateZero();
|
||||
OnTransformChanged();
|
||||
SetDirty();
|
||||
|
||||
@@ -115,9 +115,7 @@ namespace AzToolsFramework
|
||||
AZ::Quaternion GetLocalRotationQuaternion() override;
|
||||
|
||||
// Scale Modifiers
|
||||
void SetLocalScale(const AZ::Vector3& scale) override;
|
||||
AZ::Vector3 GetLocalScale() override;
|
||||
AZ::Vector3 GetWorldScale() override;
|
||||
|
||||
void SetLocalUniformScale(float scale) override;
|
||||
float GetLocalUniformScale() override;
|
||||
|
||||
+6
-4
@@ -30,7 +30,8 @@ namespace AzToolsFramework
|
||||
EditorTransform()
|
||||
{
|
||||
m_translate = AZ::Vector3::CreateZero();
|
||||
m_scale = AZ::Vector3::CreateOne();
|
||||
m_legacyScale = AZ::Vector3::CreateOne();
|
||||
m_uniformScale = 1.0f;
|
||||
m_rotate = AZ::Vector3::CreateZero();
|
||||
m_locked = false;
|
||||
}
|
||||
@@ -40,9 +41,10 @@ namespace AzToolsFramework
|
||||
return EditorTransform();
|
||||
}
|
||||
|
||||
AZ::Vector3 m_translate; //! Translation in engine units (meters)
|
||||
AZ::Vector3 m_scale;
|
||||
AZ::Vector3 m_rotate; //! Rotation in degrees
|
||||
AZ::Vector3 m_translate; //!< Translation in engine units (meters)
|
||||
AZ::Vector3 m_legacyScale; //!< Legacy vector scale value, retained only for migration.
|
||||
float m_uniformScale; //!< Single scale value applied uniformly.
|
||||
AZ::Vector3 m_rotate; //!< Rotation in degrees
|
||||
bool m_locked;
|
||||
};
|
||||
|
||||
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "AzToolsFramework_precompiled.h"
|
||||
#include <ToolsComponents/TransformScalePropertyHandler.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void RegisterTransformScaleHandler()
|
||||
{
|
||||
PropertyTypeRegistrationMessages::Bus::Broadcast(&PropertyTypeRegistrationMessages::RegisterPropertyType, aznew Components::TransformScalePropertyHandler());
|
||||
}
|
||||
|
||||
namespace Components
|
||||
{
|
||||
AZ::u32 TransformScalePropertyHandler::GetHandlerName(void) const
|
||||
{
|
||||
return TransformScaleHandler;
|
||||
}
|
||||
|
||||
QWidget* TransformScalePropertyHandler::CreateGUI(QWidget* parent)
|
||||
{
|
||||
AzQtComponents::DoubleSpinBox* newCtrl = new AzQtComponents::DoubleSpinBox(parent);
|
||||
connect(newCtrl, QOverload<double>::of(&AzQtComponents::DoubleSpinBox::valueChanged), newCtrl, [newCtrl]()
|
||||
{
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestWrite, newCtrl);
|
||||
});
|
||||
|
||||
newCtrl->setMinimum(AZ::MinTransformScale);
|
||||
newCtrl->setMaximum(AZ::MaxTransformScale);
|
||||
|
||||
return newCtrl;
|
||||
}
|
||||
|
||||
void TransformScalePropertyHandler::ConsumeAttribute(AzQtComponents::DoubleSpinBox* GUI, AZ::u32 attrib,
|
||||
AzToolsFramework::PropertyAttributeReader* attrValue, [[maybe_unused]] const char* debugName)
|
||||
{
|
||||
if (attrib == AZ::Edit::Attributes::Suffix)
|
||||
{
|
||||
AZStd::string label;
|
||||
if (attrValue->Read<AZStd::string>(label))
|
||||
{
|
||||
GUI->setSuffix(label.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TransformScalePropertyHandler::WriteGUIValuesIntoProperty([[maybe_unused]] size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
AZ::Vector3& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
const float value = aznumeric_cast<float>(GUI->value());
|
||||
const float currentMaxElement = instance.GetMaxElement();
|
||||
if (currentMaxElement != 0.0f)
|
||||
{
|
||||
instance *= value / currentMaxElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = AZ::Vector3(value);
|
||||
}
|
||||
}
|
||||
|
||||
bool TransformScalePropertyHandler::ReadValuesIntoGUI([[maybe_unused]] size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
const AZ::Vector3& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
QSignalBlocker signalBlocker(GUI);
|
||||
GUI->setValue(instance.GetMaxElement());
|
||||
return true;
|
||||
}
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzQtComponents/Components/Widgets/SpinBox.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#endif
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
static const AZ::Crc32 TransformScaleHandler = AZ_CRC_CE("TransformScale");
|
||||
|
||||
//! Handler to allow the scale field inside the Transform Component to be represented as a single value in
|
||||
//! the editor, but stored internally as a Vector3.
|
||||
//! The purpose for this is to prevent any new entities being created with non-uniform scale on the Transform
|
||||
//! Component, but preserve the data required for migrating any existing entities to use the Non-Uniform Scale
|
||||
//! Component, until all migration work is completed.
|
||||
//! The value shown in the editor will be the maximum value from the scale vector, and changing the value in
|
||||
//! the editor will update the vector so that its maximum value matches the newly edited value, but its
|
||||
//! components retain their existing proportion.
|
||||
//! For example, if the current vector scale is (2, 3, 4), the value in the editor will appear as 4. If the value
|
||||
//! in the editor is updated to 2, then the vector scale will update to (1, 1.5, 2), keeping the same proportion
|
||||
//! between the x, y and z components.
|
||||
class TransformScalePropertyHandler
|
||||
: public QObject
|
||||
, public AzToolsFramework::PropertyHandler<AZ::Vector3, AzQtComponents::DoubleSpinBox>
|
||||
{
|
||||
Q_OBJECT //AUTOMOC
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(TransformScalePropertyHandler, AZ::SystemAllocator, 0);
|
||||
|
||||
AZ::u32 GetHandlerName(void) const override;
|
||||
QWidget* CreateGUI(QWidget* parent) override;
|
||||
void ConsumeAttribute(AzQtComponents::DoubleSpinBox* GUI, AZ::u32 attrib,
|
||||
AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
|
||||
void WriteGUIValuesIntoProperty(size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
AZ::Vector3& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
bool ReadValuesIntoGUI(size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
const AZ::Vector3& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
};
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
+7
-2
@@ -172,7 +172,7 @@ namespace AzToolsFramework
|
||||
|
||||
const int autoExpandDelayMilliseconds = 2500;
|
||||
m_gui->m_objectTree->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_gui->m_objectTree->setEditTriggers(QAbstractItemView::EditKeyPressed);
|
||||
SetDefaultTreeViewEditTriggers();
|
||||
m_gui->m_objectTree->setAutoExpandDelay(autoExpandDelayMilliseconds);
|
||||
m_gui->m_objectTree->setDragEnabled(true);
|
||||
m_gui->m_objectTree->setDropIndicatorShown(true);
|
||||
@@ -850,6 +850,11 @@ namespace AzToolsFramework
|
||||
addAction(m_actionGoToEntitiesInViewport);
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::SetDefaultTreeViewEditTriggers()
|
||||
{
|
||||
m_gui->m_objectTree->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed);
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::OnEntityPickModeStarted()
|
||||
{
|
||||
m_gui->m_objectTree->setDragEnabled(false);
|
||||
@@ -862,7 +867,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
m_gui->m_objectTree->setDragEnabled(true);
|
||||
m_gui->m_objectTree->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_gui->m_objectTree->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
|
||||
SetDefaultTreeViewEditTriggers();
|
||||
m_inObjectPickMode = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -166,6 +166,8 @@ namespace AzToolsFramework
|
||||
// to a given entity
|
||||
void QueueScrollToNewContent(const AZ::EntityId& entityId) override;
|
||||
|
||||
void SetDefaultTreeViewEditTriggers();
|
||||
|
||||
void ScrollToNewContent();
|
||||
bool m_scrollToNewContentQueued;
|
||||
bool m_scrollToSelectedEntity;
|
||||
|
||||
+1
-1
@@ -333,7 +333,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
auto createPrefabOutcome = s_prefabPublicInterface->CreatePrefab(selectedEntities, s_prefabLoaderInterface->GetRelativePathToProject(prefabFilePath.data()));
|
||||
auto createPrefabOutcome = s_prefabPublicInterface->CreatePrefab(selectedEntities, prefabFilePath.data());
|
||||
|
||||
if (!createPrefabOutcome.IsSuccess())
|
||||
{
|
||||
|
||||
+45
-5
@@ -777,6 +777,23 @@ namespace AzToolsFramework
|
||||
selection.SetDefaultDirectory(defaultDirectory);
|
||||
}
|
||||
|
||||
if (m_hideProductFilesInAssetPicker)
|
||||
{
|
||||
FilterConstType displayFilter = selection.GetDisplayFilter();
|
||||
|
||||
EntryTypeFilter* productsFilter = new EntryTypeFilter();
|
||||
productsFilter->SetEntryType(AssetBrowserEntry::AssetEntryType::Product);
|
||||
|
||||
InverseFilter* noProductsFilter = new InverseFilter();
|
||||
noProductsFilter->SetFilter(FilterConstType(productsFilter));
|
||||
|
||||
CompositeFilter* compFilter = new CompositeFilter(CompositeFilter::LogicOperatorType::AND);
|
||||
compFilter->AddFilter(FilterConstType(displayFilter));
|
||||
compFilter->AddFilter(FilterConstType(noProductsFilter));
|
||||
|
||||
selection.SetDisplayFilter(FilterConstType(compFilter));
|
||||
}
|
||||
|
||||
AssetBrowserComponentRequestBus::Broadcast(&AssetBrowserComponentRequests::PickAssets, selection, parentWidget());
|
||||
if (selection.IsValid())
|
||||
{
|
||||
@@ -936,11 +953,16 @@ namespace AzToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
const AZ::Data::AssetId assetID = GetCurrentAssetID();
|
||||
m_currentAssetHint = "";
|
||||
|
||||
if (!m_unnamedType)
|
||||
const AZStd::string& folderPath = GetFolderSelection();
|
||||
if (!folderPath.empty())
|
||||
{
|
||||
m_currentAssetHint = folderPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
const AZ::Data::AssetId assetID = GetCurrentAssetID();
|
||||
m_currentAssetHint = "";
|
||||
|
||||
AZ::Outcome<AssetSystem::JobInfoContainer> jobOutcome = AZ::Failure();
|
||||
AssetSystemJobRequestBus::BroadcastResult(jobOutcome, &AssetSystemJobRequestBus::Events::GetAssetJobsInfoByAssetID, assetID, false, false);
|
||||
|
||||
@@ -954,7 +976,7 @@ namespace AzToolsFramework
|
||||
|
||||
if (!jobs.empty())
|
||||
{
|
||||
// The default behavior is show to the source filename.
|
||||
// The default behavior is to show the source filename.
|
||||
assetPath = jobs[0].m_sourceFile;
|
||||
|
||||
AZStd::string errorLog;
|
||||
@@ -1172,6 +1194,16 @@ namespace AzToolsFramework
|
||||
return m_showProductAssetName;
|
||||
}
|
||||
|
||||
void PropertyAssetCtrl::SetHideProductFilesInAssetPicker(bool hide)
|
||||
{
|
||||
m_hideProductFilesInAssetPicker = hide;
|
||||
}
|
||||
|
||||
bool PropertyAssetCtrl::GetHideProductFilesInAssetPicker() const
|
||||
{
|
||||
return m_hideProductFilesInAssetPicker;
|
||||
}
|
||||
|
||||
void PropertyAssetCtrl::SetShowThumbnail(bool enable)
|
||||
{
|
||||
m_showThumbnail = enable;
|
||||
@@ -1297,6 +1329,14 @@ namespace AzToolsFramework
|
||||
GUI->SetShowProductAssetName(showProductAssetName);
|
||||
}
|
||||
}
|
||||
else if(attrib == AZ::Edit::Attributes::HideProductFilesInAssetPicker)
|
||||
{
|
||||
bool hideProductFilesInAssetPicker = false;
|
||||
if (attrValue->Read<bool>(hideProductFilesInAssetPicker))
|
||||
{
|
||||
GUI->SetHideProductFilesInAssetPicker(hideProductFilesInAssetPicker);
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ::Edit::Attributes::ClearNotify)
|
||||
{
|
||||
PropertyAssetCtrl::ClearCallbackType* func = azdynamic_cast<PropertyAssetCtrl::ClearCallbackType*>(attrValue->GetAttribute());
|
||||
|
||||
+7
@@ -158,6 +158,10 @@ namespace AzToolsFramework
|
||||
//! Assets can be either source or product assets generated from source assets. By default, source assets are shown in the property asset. You can override that with this flag.
|
||||
bool m_showProductAssetName = true;
|
||||
|
||||
//! Assets can be either source or product assets generated from source assets.
|
||||
//! By default the asset picker shows both on an AZ::Asset<> property. You can hide product assets with this flag.
|
||||
bool m_hideProductFilesInAssetPicker = false;
|
||||
|
||||
bool m_showThumbnail = false;
|
||||
bool m_showThumbnailDropDownButton = false;
|
||||
EditCallbackType* m_thumbnailCallback = nullptr;
|
||||
@@ -211,6 +215,9 @@ namespace AzToolsFramework
|
||||
void SetShowProductAssetName(bool enable);
|
||||
bool GetShowProductAssetName() const;
|
||||
|
||||
void SetHideProductFilesInAssetPicker(bool hide);
|
||||
bool GetHideProductFilesInAssetPicker() const;
|
||||
|
||||
void SetShowThumbnail(bool enable);
|
||||
bool GetShowThumbnail() const;
|
||||
void SetShowThumbnailDropDownButton(bool enable);
|
||||
|
||||
-3
@@ -16,7 +16,6 @@
|
||||
#include <AzToolsFramework/ToolsComponents/EditorEntityIdContainer.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyAudioCtrlTypes.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/GenericComboBoxCtrl.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformScalePropertyHandler.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -38,7 +37,6 @@ namespace AzToolsFramework
|
||||
void RegisterButtonPropertyHandlers();
|
||||
void RegisterMultiLineEditHandler();
|
||||
void RegisterCrcHandler();
|
||||
void RegisterTransformScaleHandler();
|
||||
void ReflectPropertyEditor(AZ::ReflectContext* context);
|
||||
|
||||
namespace Components
|
||||
@@ -192,7 +190,6 @@ namespace AzToolsFramework
|
||||
RegisterVectorHandlers();
|
||||
RegisterButtonPropertyHandlers();
|
||||
RegisterMultiLineEditHandler();
|
||||
RegisterTransformScaleHandler();
|
||||
|
||||
// GenericComboBoxHandlers
|
||||
RegisterGenericComboBoxHandler<AZ::Crc32>();
|
||||
|
||||
+11
-1
@@ -2471,7 +2471,17 @@ namespace AzToolsFramework
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
AddAction(
|
||||
m_actions, { QKeySequence(Qt::Key_U) },
|
||||
/*ID_VIEWPORTUI_VISIBLE=*/50040, "Toggle ViewportUI", "Hide/Unhide Viewport UI",
|
||||
[this]()
|
||||
{
|
||||
SetViewportUiClusterVisible(m_transformModeClusterId, !m_viewportUiVisible);
|
||||
SetViewportUiClusterVisible(m_spaceCluster.m_spaceClusterId, !m_viewportUiVisible);
|
||||
m_viewportUiVisible = !m_viewportUiVisible;
|
||||
});
|
||||
|
||||
EditorMenuRequestBus::Broadcast(&EditorMenuRequests::RestoreEditMenuToDefault);
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -306,6 +306,7 @@ namespace AzToolsFramework
|
||||
AzFramework::ClickDetector m_clickDetector; //!< Detect different types of mouse click.
|
||||
AzFramework::CursorState m_cursorState; //!< Track the mouse position and delta movement each frame.
|
||||
SpaceCluster m_spaceCluster; //!< Related viewport ui state for controlling the current reference space.
|
||||
bool m_viewportUiVisible = true; //!< Used to hide/show the viewport ui elements.
|
||||
};
|
||||
|
||||
//! The ETCS (EntityTransformComponentSelection) namespace contains functions and data used exclusively by
|
||||
|
||||
@@ -293,8 +293,6 @@ set(FILES
|
||||
ToolsComponents/TransformComponent.h
|
||||
ToolsComponents/TransformComponent.cpp
|
||||
ToolsComponents/TransformComponentBus.h
|
||||
ToolsComponents/TransformScalePropertyHandler.cpp
|
||||
ToolsComponents/TransformScalePropertyHandler.h
|
||||
ToolsComponents/ScriptEditorComponent.cpp
|
||||
ToolsComponents/ScriptEditorComponent.h
|
||||
ToolsComponents/ToolsAssetCatalogComponent.cpp
|
||||
|
||||
+2
-1
@@ -34,7 +34,8 @@ namespace Benchmark
|
||||
{
|
||||
state.PauseTiming();
|
||||
|
||||
auto spawnable = ::AzToolsFramework::Prefab::SpawnableUtils::CreateSpawnable(prefabDom);
|
||||
AzFramework::Spawnable spawnable;
|
||||
AzToolsFramework::Prefab::SpawnableUtils::CreateSpawnable(spawnable, prefabDom);
|
||||
|
||||
state.ResumeTiming();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ namespace UnitTest
|
||||
|
||||
//Create Spawnable
|
||||
auto& prefabDom = m_prefabSystemComponent->FindTemplateDom(instance->GetTemplateId());
|
||||
auto spawnable = ::AzToolsFramework::Prefab::SpawnableUtils::CreateSpawnable(prefabDom);
|
||||
AzFramework::Spawnable spawnable;
|
||||
AzToolsFramework::Prefab::SpawnableUtils::CreateSpawnable(spawnable, prefabDom);
|
||||
|
||||
EXPECT_EQ(spawnable.GetEntities().size() - 1, normalEntityCount); // 1 for container entity
|
||||
const auto& spawnableEntities = spawnable.GetEntities();
|
||||
@@ -84,7 +85,8 @@ namespace UnitTest
|
||||
|
||||
//Create Spawnable
|
||||
auto& prefabDom = m_prefabSystemComponent->FindTemplateDom(thirdInstance->GetTemplateId());
|
||||
auto spawnable = ::AzToolsFramework::Prefab::SpawnableUtils::CreateSpawnable(prefabDom);
|
||||
AzFramework::Spawnable spawnable;
|
||||
AzToolsFramework::Prefab::SpawnableUtils::CreateSpawnable(spawnable, prefabDom);
|
||||
|
||||
EXPECT_EQ(spawnable.GetEntities().size() - 1, normalEntityCount); // 1 for container entity
|
||||
const auto& spawnableEntities = spawnable.GetEntities();
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ namespace UnitTest
|
||||
|
||||
// Set the new entity's transform to non zero values
|
||||
// This helps validate in comparison tests that the transform values of created entities persist during slice operations
|
||||
entityTransform->SetLocalScale(AZ::Vector3(5, 5, 5));
|
||||
entityTransform->SetLocalUniformScale(5);
|
||||
entityTransform->SetLocalRotation(AZ::Vector3RadToDeg(AZ::Vector3(90, 90, 90)));
|
||||
entityTransform->SetLocalTranslation(AZ::Vector3(100, 100, 100));
|
||||
|
||||
|
||||
@@ -55,7 +55,11 @@ namespace UnitTest
|
||||
delete m_ticket;
|
||||
m_ticket = nullptr;
|
||||
// One more tick on the spawnable entities manager in order to delete the ticket fully.
|
||||
m_manager->ProcessQueue();
|
||||
while (m_manager->ProcessQueue(
|
||||
AzFramework::SpawnableEntitiesManager::CommandQueuePriority::High |
|
||||
AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular) !=
|
||||
AzFramework::SpawnableEntitiesManager::CommandQueueStatus::NoCommandsLeft)
|
||||
;
|
||||
|
||||
delete m_spawnableAsset;
|
||||
m_spawnableAsset = nullptr;
|
||||
@@ -85,6 +89,10 @@ namespace UnitTest
|
||||
TestApplication* m_application { nullptr };
|
||||
};
|
||||
|
||||
//
|
||||
// SpawnAllEntitities
|
||||
//
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, SpawnAllEntities_Call_AllEntitiesSpawned)
|
||||
{
|
||||
static constexpr size_t NumEntities = 4;
|
||||
@@ -92,16 +100,72 @@ namespace UnitTest
|
||||
|
||||
size_t spawnedEntitiesCount = 0;
|
||||
auto callback =
|
||||
[&spawnedEntitiesCount](AzFramework::EntitySpawnTicket&, AzFramework::SpawnableConstEntityContainerView entities)
|
||||
[&spawnedEntitiesCount](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities)
|
||||
{
|
||||
spawnedEntitiesCount += entities.size();
|
||||
};
|
||||
m_manager->SpawnAllEntities(*m_ticket, {}, AZStd::move(callback));
|
||||
m_manager->ProcessQueue();
|
||||
m_manager->SpawnAllEntities(*m_ticket, AzFramework::SpawnablePriority_Default, {}, AZStd::move(callback));
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
|
||||
EXPECT_EQ(NumEntities, spawnedEntitiesCount);
|
||||
}
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, SpawnAllEntities_DeleteTicketBeforeCall_NoCrash)
|
||||
{
|
||||
{
|
||||
AzFramework::EntitySpawnTicket ticket(*m_spawnableAsset);
|
||||
m_manager->SpawnAllEntities(ticket, AzFramework::SpawnablePriority_Default);
|
||||
}
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// SpawnEntities
|
||||
//
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, SpawnEntities_DeleteTicketBeforeCall_NoCrash)
|
||||
{
|
||||
{
|
||||
AzFramework::EntitySpawnTicket ticket(*m_spawnableAsset);
|
||||
m_manager->SpawnEntities(ticket, AzFramework::SpawnablePriority_Default, {});
|
||||
}
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DespawnAllEntities
|
||||
//
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, DespawnAllEntities_DeleteTicketBeforeCall_NoCrash)
|
||||
{
|
||||
{
|
||||
AzFramework::EntitySpawnTicket ticket(*m_spawnableAsset);
|
||||
m_manager->DespawnAllEntities(ticket, AzFramework::SpawnablePriority_Default);
|
||||
}
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ReloadSpawnable
|
||||
//
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, ReloadSpawnable_DeleteTicketBeforeCall_NoCrash)
|
||||
{
|
||||
{
|
||||
AzFramework::EntitySpawnTicket ticket(*m_spawnableAsset);
|
||||
m_manager->ReloadSpawnable(ticket, AzFramework::SpawnablePriority_Default, *m_spawnableAsset);
|
||||
}
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ListEntitities
|
||||
//
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, ListEntities_Call_AllEntitiesAreReported)
|
||||
{
|
||||
static constexpr size_t NumEntities = 4;
|
||||
@@ -110,7 +174,7 @@ namespace UnitTest
|
||||
bool allValidEntityIds = true;
|
||||
size_t spawnedEntitiesCount = 0;
|
||||
auto callback = [&allValidEntityIds, &spawnedEntitiesCount]
|
||||
(AzFramework::EntitySpawnTicket&, AzFramework::SpawnableConstEntityContainerView entities)
|
||||
(AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities)
|
||||
{
|
||||
for (auto&& entity : entities)
|
||||
{
|
||||
@@ -119,14 +183,30 @@ namespace UnitTest
|
||||
spawnedEntitiesCount += entities.size();
|
||||
};
|
||||
|
||||
m_manager->SpawnAllEntities(*m_ticket);
|
||||
m_manager->ListEntities(*m_ticket, AZStd::move(callback));
|
||||
m_manager->ProcessQueue();
|
||||
m_manager->SpawnAllEntities(*m_ticket, AzFramework::SpawnablePriority_Default);
|
||||
m_manager->ListEntities(*m_ticket, AzFramework::SpawnablePriority_Default, AZStd::move(callback));
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
|
||||
EXPECT_TRUE(allValidEntityIds);
|
||||
EXPECT_EQ(NumEntities, spawnedEntitiesCount);
|
||||
}
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, ListEntities_DeleteTicketBeforeCall_NoCrash)
|
||||
{
|
||||
auto callback = [](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView) {};
|
||||
|
||||
{
|
||||
AzFramework::EntitySpawnTicket ticket(*m_spawnableAsset);
|
||||
m_manager->ListEntities(ticket, AzFramework::SpawnablePriority_Default, AZStd::move(callback));
|
||||
}
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ListIndicesAndEntities
|
||||
//
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, ListIndicesAndEntities_Call_AllEntitiesAreReportedAndIncrementByOne)
|
||||
{
|
||||
static constexpr size_t NumEntities = 4;
|
||||
@@ -135,7 +215,7 @@ namespace UnitTest
|
||||
bool allValidEntityIds = true;
|
||||
size_t spawnedEntitiesCount = 0;
|
||||
auto callback = [&allValidEntityIds, &spawnedEntitiesCount]
|
||||
(AzFramework::EntitySpawnTicket&, AzFramework::SpawnableConstIndexEntityContainerView entities)
|
||||
(AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstIndexEntityContainerView entities)
|
||||
{
|
||||
for (auto&& indexEntityPair : entities)
|
||||
{
|
||||
@@ -148,11 +228,121 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
m_manager->SpawnAllEntities(*m_ticket);
|
||||
m_manager->ListIndicesAndEntities(*m_ticket, AZStd::move(callback));
|
||||
m_manager->ProcessQueue();
|
||||
m_manager->SpawnAllEntities(*m_ticket, AzFramework::SpawnablePriority_Default);
|
||||
m_manager->ListIndicesAndEntities(*m_ticket, AzFramework::SpawnablePriority_Default, AZStd::move(callback));
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
|
||||
EXPECT_TRUE(allValidEntityIds);
|
||||
EXPECT_EQ(NumEntities, spawnedEntitiesCount);
|
||||
}
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, ListIndicesAndEntities_DeleteTicketBeforeCall_NoCrash)
|
||||
{
|
||||
auto callback = [](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstIndexEntityContainerView) {};
|
||||
|
||||
{
|
||||
AzFramework::EntitySpawnTicket ticket(*m_spawnableAsset);
|
||||
m_manager->ListIndicesAndEntities(ticket, AzFramework::SpawnablePriority_Default, AZStd::move(callback));
|
||||
}
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ClaimEntities
|
||||
//
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, ClaimEntities_DeleteTicketBeforeCall_NoCrash)
|
||||
{
|
||||
auto callback = [](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableEntityContainerView) {};
|
||||
|
||||
{
|
||||
AzFramework::EntitySpawnTicket ticket(*m_spawnableAsset);
|
||||
m_manager->ClaimEntities(ticket, AzFramework::SpawnablePriority_Default, AZStd::move(callback));
|
||||
}
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Barrier
|
||||
//
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, Barrier_DeleteTicketBeforeCall_NoCrash)
|
||||
{
|
||||
auto callback = [](AzFramework::EntitySpawnTicket::Id) {};
|
||||
|
||||
{
|
||||
AzFramework::EntitySpawnTicket ticket(*m_spawnableAsset);
|
||||
m_manager->Barrier(ticket, AzFramework::SpawnablePriority_Default, AZStd::move(callback));
|
||||
}
|
||||
m_manager->ProcessQueue(AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Misc. - Priority tests
|
||||
//
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, Priority_HighBeforeDefault_HigherPriorityCallHappensBeforeDefaultPriorityEvenWhenQueuedLater)
|
||||
{
|
||||
static constexpr size_t NumEntities = 4;
|
||||
FillSpawnable(NumEntities);
|
||||
|
||||
AzFramework::EntitySpawnTicket highPriorityTicket(*m_spawnableAsset);
|
||||
|
||||
size_t callCounter = 1;
|
||||
size_t highPriorityCallId = 0;
|
||||
size_t defaultPriorityCallId = 0;
|
||||
auto highCallback = [&callCounter, &highPriorityCallId]
|
||||
(AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView)
|
||||
{
|
||||
highPriorityCallId = callCounter++;
|
||||
};
|
||||
auto defaultCallback = [&callCounter, &defaultPriorityCallId]
|
||||
(AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView)
|
||||
{
|
||||
defaultPriorityCallId = callCounter++;
|
||||
};
|
||||
|
||||
m_manager->SpawnAllEntities(*m_ticket, AzFramework::SpawnablePriority_Default, {}, AZStd::move(defaultCallback));
|
||||
m_manager->SpawnAllEntities(highPriorityTicket, AzFramework::SpawnablePriority_High, {}, AZStd::move(highCallback));
|
||||
m_manager->ProcessQueue(
|
||||
AzFramework::SpawnableEntitiesManager::CommandQueuePriority::High |
|
||||
AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
|
||||
EXPECT_LT(highPriorityCallId, defaultPriorityCallId);
|
||||
}
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, Priority_SameTicket_DefaultPriorityCallHappensBeforeHighPriority)
|
||||
{
|
||||
static constexpr size_t NumEntities = 4;
|
||||
FillSpawnable(NumEntities);
|
||||
|
||||
size_t callCounter = 1;
|
||||
size_t highPriorityCallId = 0;
|
||||
size_t defaultPriorityCallId = 0;
|
||||
auto highCallback =
|
||||
[&callCounter, &highPriorityCallId](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView)
|
||||
{
|
||||
highPriorityCallId = callCounter++;
|
||||
};
|
||||
auto defaultCallback =
|
||||
[&callCounter, &defaultPriorityCallId](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView)
|
||||
{
|
||||
defaultPriorityCallId = callCounter++;
|
||||
};
|
||||
|
||||
m_manager->SpawnAllEntities(*m_ticket, AzFramework::SpawnablePriority_Default, {}, AZStd::move(defaultCallback));
|
||||
m_manager->SpawnAllEntities(*m_ticket, AzFramework::SpawnablePriority_High, {}, AZStd::move(highCallback));
|
||||
m_manager->ProcessQueue(
|
||||
AzFramework::SpawnableEntitiesManager::CommandQueuePriority::High |
|
||||
AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
// Run a second time as the high priority task will be pending at this point.
|
||||
m_manager->ProcessQueue(
|
||||
AzFramework::SpawnableEntitiesManager::CommandQueuePriority::High |
|
||||
AzFramework::SpawnableEntitiesManager::CommandQueuePriority::Regular);
|
||||
|
||||
EXPECT_LT(defaultPriorityCallId, highPriorityCallId);
|
||||
}
|
||||
} // namespace UnitTest
|
||||
|
||||
@@ -504,8 +504,8 @@ namespace O3DELauncher
|
||||
const AZStd::string_view buildTargetName = GetBuildTargetName();
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization(*settingsRegistry, buildTargetName);
|
||||
|
||||
AZ_TracePrintf("Launcher", R"(Running project "%.*s.)" "\n"
|
||||
R"(The project name value has been successfully set in the Settings Registry at key "%s/project_name)"
|
||||
AZ_TracePrintf("Launcher", R"(Running project "%.*s")" "\n"
|
||||
R"(The project name has been successfully set in the Settings Registry at key "%s/project_name")"
|
||||
R"( for Launcher target "%.*s")" "\n",
|
||||
aznumeric_cast<int>(launcherProjectName.size()), launcherProjectName.data(),
|
||||
AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey,
|
||||
@@ -659,7 +659,8 @@ namespace O3DELauncher
|
||||
if (gEnv && gEnv->pConsole)
|
||||
{
|
||||
// Execute autoexec.cfg to load the initial level
|
||||
AZ::Interface<AZ::IConsole>::Get()->ExecuteConfigFile("autoexec.cfg");
|
||||
auto autoExecFile = AZ::IO::FixedMaxPath{pathToAssets} / "autoexec.cfg";
|
||||
AZ::Interface<AZ::IConsole>::Get()->ExecuteConfigFile(autoExecFile.Native());
|
||||
|
||||
// Find out if console command file was passed
|
||||
// via --console-command-file=%filename% and execute it
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
#
|
||||
|
||||
set(ICON_FILE ${project_real_path}/Gem/Resources/GameSDK.ico)
|
||||
if(NOT EXISTS ${ICON_FILE})
|
||||
# Try another project-relative path
|
||||
set(ICON_FILE ${project_real_path}/Resources/GameSDK.ico)
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${ICON_FILE})
|
||||
# Try the common LauncherUnified icon instead
|
||||
set(ICON_FILE Resources/GameSDK.ico)
|
||||
|
||||
@@ -179,6 +179,7 @@ function(ly_delayed_generate_static_modules_inl)
|
||||
${launcher_unified_binary_dir}/${project_name}.GameLauncher/Includes/StaticModules.inl
|
||||
)
|
||||
|
||||
ly_target_link_libraries(${project_name}.GameLauncher PRIVATE ${all_game_gem_dependencies})
|
||||
if(PAL_TRAIT_BUILD_SERVER_SUPPORTED)
|
||||
get_property(server_gem_dependencies GLOBAL PROPERTY LY_STATIC_MODULE_PROJECTS_DEPENDENCIES_${project_name}.ServerLauncher)
|
||||
|
||||
@@ -204,6 +205,7 @@ function(ly_delayed_generate_static_modules_inl)
|
||||
${launcher_unified_binary_dir}/${project_name}.ServerLauncher/Includes/StaticModules.inl
|
||||
)
|
||||
|
||||
ly_target_link_libraries(${project_name}.ServerLauncher PRIVATE ${all_server_gem_dependencies})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
@@ -75,14 +75,14 @@
|
||||
<widget class="QSvgWidget" name="m_logo" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>161</width>
|
||||
<height>49</height>
|
||||
<width>175</width>
|
||||
<height>66</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>161</width>
|
||||
<height>49</height>
|
||||
<width>175</width>
|
||||
<height>66</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
@@ -129,6 +129,8 @@ ly_add_target(
|
||||
3rdParty::AWSNativeSDK::Core
|
||||
3rdParty::Qt::Network
|
||||
Legacy::EditorCore
|
||||
RUNTIME_DEPENDENCIES
|
||||
Gem::AtomViewportDisplayInfo
|
||||
)
|
||||
ly_add_source_properties(
|
||||
SOURCES CryEdit.cpp
|
||||
@@ -175,6 +177,11 @@ ly_add_target(
|
||||
Legacy::EditorLib
|
||||
ProjectManager
|
||||
)
|
||||
set_property(SOURCE
|
||||
CryEdit.cpp
|
||||
APPEND PROPERTY
|
||||
COMPILE_DEFINITIONS LY_CMAKE_TARGET="Editor"
|
||||
)
|
||||
ly_add_translations(
|
||||
TARGETS Editor
|
||||
PREFIX Translations
|
||||
@@ -184,15 +191,8 @@ ly_add_translations(
|
||||
)
|
||||
ly_add_dependencies(Editor AssetProcessor)
|
||||
|
||||
if(TARGET Editor)
|
||||
set_property(SOURCE
|
||||
CryEdit.cpp
|
||||
APPEND PROPERTY
|
||||
COMPILE_DEFINITIONS LY_CMAKE_TARGET="Editor"
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Cannot set LY_CMAKE_TARGET define to Editor as the target doesn't exist anymore."
|
||||
" Perhaps it has been renamed")
|
||||
if(LY_FIRST_PROJECT_PATH)
|
||||
set_property(TARGET Editor APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${LY_FIRST_PROJECT_PATH}\"")
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
@@ -244,7 +244,8 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
Legacy::CryCommon
|
||||
AZ::AzToolsFramework
|
||||
Legacy::EditorLib
|
||||
Gem::LmbrCentral
|
||||
RUNTIME_DEPENDENCIES
|
||||
Gem::LmbrCentral
|
||||
)
|
||||
ly_add_googletest(
|
||||
NAME Legacy::EditorLib.Tests
|
||||
|
||||
@@ -421,17 +421,18 @@ QMenu* LevelEditorMenuHandler::CreateFileMenu()
|
||||
fileMenu.AddSeparator();
|
||||
|
||||
// Project Settings
|
||||
auto projectSettingMenu = fileMenu.AddMenu(tr("Project Settings"));
|
||||
fileMenu.AddAction(ID_FILE_PROJECT_MANAGER_SETTINGS);
|
||||
|
||||
// Project Settings Tool
|
||||
// Platform Settings - Project Settings Tool
|
||||
// Shortcut must be set while adding the action otherwise it doesn't work
|
||||
projectSettingMenu.Get()->addAction(
|
||||
fileMenu.Get()->addAction(
|
||||
tr(LyViewPane::ProjectSettingsTool),
|
||||
[]() { QtViewPaneManager::instance()->OpenPane(LyViewPane::ProjectSettingsTool); },
|
||||
tr("Ctrl+Shift+P"));
|
||||
|
||||
projectSettingMenu.AddSeparator();
|
||||
|
||||
fileMenu.AddSeparator();
|
||||
fileMenu.AddAction(ID_FILE_PROJECT_MANAGER_NEW);
|
||||
fileMenu.AddAction(ID_FILE_PROJECT_MANAGER_OPEN);
|
||||
fileMenu.AddSeparator();
|
||||
|
||||
// NEWMENUS: NEEDS IMPLEMENTATION
|
||||
|
||||
@@ -58,6 +58,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include <AzFramework/Components/CameraBus.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
|
||||
#include <AzFramework/ProjectManager/ProjectManager.h>
|
||||
|
||||
// AzToolsFramework
|
||||
#include <AzToolsFramework/Component/EditorComponentAPIBus.h>
|
||||
@@ -280,6 +281,8 @@ BOOL CCryDocManager::DoPromptFileName(QString& fileName, [[maybe_unused]] UINT n
|
||||
[[maybe_unused]] DWORD lFlags, BOOL bOpenFileDialog, [[maybe_unused]] CDocTemplate* pTemplate)
|
||||
{
|
||||
CLevelFileDialog levelFileDialog(bOpenFileDialog);
|
||||
levelFileDialog.show();
|
||||
levelFileDialog.adjustSize();
|
||||
|
||||
if (levelFileDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
@@ -477,6 +480,11 @@ void CCryEditApp::RegisterActionHandlers()
|
||||
|
||||
ON_COMMAND(ID_FILE_SAVE_LEVEL, OnFileSave)
|
||||
ON_COMMAND(ID_FILE_EXPORTOCCLUSIONMESH, OnFileExportOcclusionMesh)
|
||||
|
||||
// Project Manager
|
||||
ON_COMMAND(ID_FILE_PROJECT_MANAGER_SETTINGS, OnOpenProjectManagerSettings)
|
||||
ON_COMMAND(ID_FILE_PROJECT_MANAGER_NEW, OnOpenProjectManagerNew)
|
||||
ON_COMMAND(ID_FILE_PROJECT_MANAGER_OPEN, OnOpenProjectManager)
|
||||
}
|
||||
|
||||
CCryEditApp* CCryEditApp::s_currentInstance = nullptr;
|
||||
@@ -2073,6 +2081,8 @@ void CCryEditApp::OnDocumentationAWSSupport()
|
||||
void CCryEditApp::OnDocumentationFeedback()
|
||||
{
|
||||
FeedbackDialog dialog;
|
||||
dialog.show();
|
||||
dialog.adjustSize();
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
@@ -2854,6 +2864,34 @@ void CCryEditApp::OnPreferences()
|
||||
*/
|
||||
}
|
||||
|
||||
void CCryEditApp::OnOpenProjectManagerSettings()
|
||||
{
|
||||
OpenProjectManager("UpdateProject");
|
||||
}
|
||||
|
||||
void CCryEditApp::OnOpenProjectManagerNew()
|
||||
{
|
||||
OpenProjectManager("CreateProject");
|
||||
}
|
||||
|
||||
void CCryEditApp::OnOpenProjectManager()
|
||||
{
|
||||
OpenProjectManager("Projects");
|
||||
}
|
||||
|
||||
void CCryEditApp::OpenProjectManager(const AZStd::string& screen)
|
||||
{
|
||||
// provide the current project path for in case we want to update the project
|
||||
AZ::IO::FixedMaxPathString projectPath = AZ::Utils::GetProjectPath();
|
||||
const AZStd::string commandLineOptions = AZStd::string::format(" --screen %s --project_path %s", screen.c_str(), projectPath.c_str());
|
||||
bool launchSuccess = AzFramework::ProjectManager::LaunchProjectManager(commandLineOptions);
|
||||
if (!launchSuccess)
|
||||
{
|
||||
QMessageBox::critical(AzToolsFramework::GetActiveWindow(), QObject::tr("Failed to launch O3DE Project Manager"), QObject::tr("Failed to find or start the O3dE Project Manager"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnUndo()
|
||||
{
|
||||
@@ -3313,6 +3351,8 @@ void CCryEditApp::OnCreateSlice()
|
||||
void CCryEditApp::OnOpenLevel()
|
||||
{
|
||||
CLevelFileDialog levelFileDialog(true);
|
||||
levelFileDialog.show();
|
||||
levelFileDialog.adjustSize();
|
||||
|
||||
if (levelFileDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
|
||||
@@ -229,6 +229,9 @@ public:
|
||||
void OnFileResaveSlices();
|
||||
void OnFileEditEditorini();
|
||||
void OnPreferences();
|
||||
void OnOpenProjectManagerSettings();
|
||||
void OnOpenProjectManagerNew();
|
||||
void OnOpenProjectManager();
|
||||
void OnRedo();
|
||||
void OnUpdateRedo(QAction* action);
|
||||
void OnUpdateUndo(QAction* action);
|
||||
@@ -366,6 +369,7 @@ private:
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
friend struct PythonTestOutputHandler;
|
||||
|
||||
void OpenProjectManager(const AZStd::string& screen);
|
||||
void OnWireframe();
|
||||
void OnUpdateWireframe(QAction* action);
|
||||
void OnViewConfigureLayout();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user