Merge remote-tracking branch 'upstream/development' into camera_and_editor_viewport_widget_improvements

Signed-off-by: Yuriy Toporovskyy <toporovskyy.y@gmail.com>
This commit is contained in:
Yuriy Toporovskyy
2021-08-06 10:32:38 -04:00
425 changed files with 2145 additions and 1758 deletions
@@ -47,7 +47,7 @@ namespace AZ
}
auto stackEntry = AZStd::make_shared<BlockCache>(
cacheSize, blockSize, aznumeric_caster(hardware.m_maxPhysicalSectorSize), false);
cacheSize, aznumeric_cast<AZ::u32>(blockSize), aznumeric_cast<AZ::u32>(hardware.m_maxPhysicalSectorSize), false);
stackEntry->SetNext(AZStd::move(parent));
return stackEntry;
}
@@ -45,7 +45,7 @@ namespace AZ
}
auto stackEntry = AZStd::make_shared<DedicatedCache>(
cacheSize, blockSize, aznumeric_caster(hardware.m_maxPhysicalSectorSize), m_writeOnlyEpilog);
cacheSize, aznumeric_cast<AZ::u32>(blockSize), aznumeric_cast<AZ::u32>(hardware.m_maxPhysicalSectorSize), m_writeOnlyEpilog);
stackEntry->SetNext(AZStd::move(parent));
return stackEntry;
}
+1 -1
View File
@@ -43,7 +43,7 @@ namespace AZ
static Aabb CreateCenterRadius(const Vector3& center, float radius);
//! Creates an AABB which contains the specified points.
static Aabb CreatePoints(const Vector3* pts, int numPts);
static Aabb CreatePoints(const Vector3* pts, size_t numPts);
//! Creates an AABB which contains the specified OBB.
static Aabb CreateFromObb(const Obb& obb);
+2 -2
View File
@@ -60,10 +60,10 @@ namespace AZ
}
AZ_MATH_INLINE Aabb Aabb::CreatePoints(const Vector3* pts, int numPts)
AZ_MATH_INLINE Aabb Aabb::CreatePoints(const Vector3* pts, size_t numPts)
{
Aabb aabb = Aabb::CreateFromPoint(pts[0]);
for (int i = 1; i < numPts; ++i)
for (size_t i = 1; i < numPts; ++i)
{
aabb.AddPoint(pts[i]);
}
@@ -11,6 +11,7 @@
#include <AzCore/Memory/OSAllocator.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/Math/Crc.h>
#include <AzCore/std/parallel/scoped_lock.h>
namespace AZ
{
@@ -75,6 +76,42 @@ namespace AZ
bool operator==(const OSStdAllocator& a, const OSStdAllocator& b) { (void)a; (void)b; return true; }
bool operator!=(const OSStdAllocator& a, const OSStdAllocator& b) { (void)a; (void)b; return false; }
void EnvironmentVariableHolderBase::UnregisterAndDestroy(DestructFunc destruct, bool moduleRelease)
{
const bool releaseByUseCount = (--m_useCount == 0);
// We take over the lock, and release it before potentially destroying/freeing ourselves
{
AZStd::scoped_lock envLockHolder(AZStd::adopt_lock, m_mutex);
const bool releaseByModule = (moduleRelease && !m_canTransferOwnership && m_moduleOwner == AZ::Environment::GetModuleId());
if (!releaseByModule && !releaseByUseCount)
{
return;
}
// if the environment that created us is gone the owner can be null
// which means (assuming intermodule allocator) that the variable is still alive
// but can't be found as it's not part of any environment.
if (m_environmentOwner)
{
m_environmentOwner->RemoveVariable(m_guid);
m_environmentOwner = nullptr;
}
if (m_isConstructed)
{
destruct(this, DestroyTarget::Member); // destruct the value
}
}
// m_mutex is no longer held here, envLockHolder has released it above.
if (releaseByUseCount)
{
// m_mutex is unlocked before this is deleted
Environment::AllocatorInterface* allocator = m_allocator;
// Call child class dtor and clear the memory
destruct(this, DestroyTarget::Self);
allocator->DeAllocate(this);
}
}
// instance of the environment
EnvironmentInterface* EnvironmentInterface::s_environment = nullptr;
@@ -110,7 +147,7 @@ namespace AZ
#ifdef AZ_ENVIRONMENT_VALIDATE_ON_EXIT
AZ_Assert(m_numAttached == 0, "We should not delete an environment while there are %d modules attached! Unload all DLLs first!", m_numAttached);
#endif
for (auto variableIt : m_variableMap)
{
EnvironmentVariableHolderBase* holder = reinterpret_cast<EnvironmentVariableHolderBase*>(variableIt.second);
@@ -200,6 +200,11 @@ namespace AZ
class EnvironmentVariableHolderBase
{
friend class EnvironmentImpl;
protected:
enum class DestroyTarget {
Member,
Self
};
public:
EnvironmentVariableHolderBase(u32 guid, AZ::Internal::EnvironmentInterface* environmentOwner, bool canOwnershipTransfer, Environment::AllocatorInterface* allocator)
: m_environmentOwner(environmentOwner)
@@ -217,12 +222,21 @@ namespace AZ
return m_isConstructed;
}
bool IsOwner() const
{
return m_moduleOwner == Environment::GetModuleId();
}
u32 GetId() const
{
return m_guid;
}
protected:
using DestructFunc = void (*)(EnvironmentVariableHolderBase *, DestroyTarget);
// Assumes the m_mutex is already locked.
// On return m_mutex is in an unlocked state.
void UnregisterAndDestroy(DestructFunc destruct, bool moduleRelease);
AZ::Internal::EnvironmentInterface* m_environmentOwner; ///< Used to know which environment we should use to free the variable if we can't transfer ownership
void* m_moduleOwner; ///< Used when the variable can't transfered across module and we need to destruct the variable when the module is going away
bool m_canTransferOwnership; ///< True if variable can be allocated in one module and freed in other. Usually true for POD types when they share allocator.
@@ -242,41 +256,29 @@ namespace AZ
memset(&m_value, 0, sizeof(T));
}
template <class... Args>
template<class... Args>
void ConstructImpl(const AZStd::false_type& /* AZStd::has_trivial_constructor<T> */, Args&&... args)
{
// Construction of non-trivial types is left up to the type's constructor.
new(&m_value) T(AZStd::forward<Args>(args)...);
}
void DestructImpl(const AZStd::true_type& /* AZStd::is_trivially_destructible<T> */)
static void DestructDispatchNoLock(EnvironmentVariableHolderBase *base, DestroyTarget selfDestruct)
{
// do nothing
}
void DestructImpl(const AZStd::false_type& /* AZStd::is_trivially_destructible<T> */)
{
reinterpret_cast<T*>(&m_value)->~T();
}
// Assumes the lock is already held
void UnregisterAndDestruct()
{
// if the environment that created us is gone the owner can be null
// which means (assuming intermodule allocator) that the variable is still alive
// but can't be found as it's not part of any environment.
if (m_environmentOwner)
auto *self = reinterpret_cast<EnvironmentVariableHolder *>(base);
if (selfDestruct == DestroyTarget::Self)
{
m_environmentOwner->RemoveVariable(m_guid);
m_environmentOwner = nullptr;
self->~EnvironmentVariableHolder();
return;
}
if (m_isConstructed)
AZ_Assert(self->m_isConstructed, "Variable is not constructed. Please check your logic and guard if needed!");
self->m_isConstructed = false;
self->m_moduleOwner = nullptr;
if constexpr(!AZStd::is_trivially_destructible_v<T>)
{
DestructNoLock();
reinterpret_cast<T*>(&self->m_value)->~T();
}
}
public:
EnvironmentVariableHolder(u32 guid, bool isOwnershipTransfer, Environment::AllocatorInterface* allocator)
: EnvironmentVariableHolderBase(guid, Environment::GetInstance(), isOwnershipTransfer, allocator)
@@ -287,12 +289,6 @@ namespace AZ
{
AZ_Assert(!m_isConstructed, "To get the destructor we should have already destructed the variable!");
}
bool IsOwner() const
{
return m_moduleOwner == Environment::GetModuleId();
}
void AddRef()
{
AZStd::lock_guard<AZStd::spin_mutex> lock(m_mutex);
@@ -303,30 +299,8 @@ namespace AZ
void Release()
{
m_mutex.lock();
if (--s_moduleUseCount == 0)
{
if (!m_canTransferOwnership && m_moduleOwner == AZ::Environment::GetModuleId())
{
UnregisterAndDestruct();
}
}
if (--m_useCount == 0)
{
UnregisterAndDestruct();
// unlock before this is deleted
m_mutex.unlock();
Environment::AllocatorInterface* allocator = m_allocator;
// Call dtor and clear the memory
this->~EnvironmentVariableHolder();
allocator->DeAllocate(this);
return;
}
m_mutex.unlock();
const bool moduleRelease = (--s_moduleUseCount == 0);
UnregisterAndDestroy(DestructDispatchNoLock, moduleRelease);
}
void Construct()
@@ -352,18 +326,10 @@ namespace AZ
}
}
void DestructNoLock()
{
AZ_Assert(m_isConstructed, "Variable is not constructed. Please check your logic and guard if needed!");
m_isConstructed = false;
m_moduleOwner = nullptr;
DestructImpl(typename AZStd::is_trivially_destructible<T>::type());
}
void Destruct()
{
AZStd::lock_guard<AZStd::spin_mutex> lock(m_mutex);
DestructNoLock();
DestructDispatchNoLock(this, DestroyTarget::Member);
}
// variable storage
@@ -71,7 +71,7 @@ namespace AZ
if (context.ShouldKeepDefaults() || !defaultValue || (valAsByteStream != *static_cast<const JsonByteStream*>(defaultValue)))
{
const auto base64ByteStream = AZ::StringFunc::Base64::Encode(valAsByteStream.data(), valAsByteStream.size());
outputValue.SetString(base64ByteStream.c_str(), base64ByteStream.size(), context.GetJsonAllocator());
outputValue.SetString(base64ByteStream.c_str(), static_cast<rapidjson::SizeType>(base64ByteStream.size()), context.GetJsonAllocator());
return context.Report(Tasks::WriteValue, Outcomes::Success, "ByteStream successfully stored.");
}
@@ -211,7 +211,7 @@ namespace AZStd
// 20.9.3.2, observer:
constexpr rep count() const { return m_rep; }
// 20.9.3.3, arithmetic:
constexpr duration operator+() const { *this; }
constexpr duration operator+() const { return *this; }
constexpr duration operator-() const { return duration(-m_rep); }
constexpr duration& operator++() { ++m_rep; return *this; }
constexpr duration operator++(int) { return duration(m_rep++); }
@@ -1056,7 +1056,7 @@ namespace AZStd
inline void insert(const iterator& pos, ForwardIterator first, ForwardIterator last, const AZStd::forward_iterator_tag&)
{
size_type size = AZStd::distance(first, last);
AZSTD_CONTAINER_ASSERT(size >= 0, "AZStd::ring_buffer::insert - there are no elements to insert!");
AZSTD_CONTAINER_ASSERT(first > last, "AZStd::ring_buffer::insert - there are no elements to insert!");
if (size == 0)
{
return;
+1 -1
View File
@@ -294,7 +294,7 @@ namespace AZStd
T& m_v;
constexpr addr_impl_ref(T& v)
: m_v(v) {}
constexpr addr_impl_ref& operator=(const addr_impl_ref& v) { m_v = v; }
constexpr addr_impl_ref& operator=(const addr_impl_ref& v) { m_v = v; return *this; }
constexpr operator T& () const { return m_v; }
};
@@ -163,7 +163,11 @@ namespace AzFramework
AZ_TracePrintfOnce("AssetSystemComponent", "Failed to find asset platform, setting 'pc'\n");
outputConnectionSettings.m_assetPlatform = "pc";
}
outputConnectionSettings.m_assetPlatform = assetsPlatform;
else
{
outputConnectionSettings.m_assetPlatform = assetsPlatform;
}
if (outputConnectionSettings.m_assetPlatform.empty())
{
assetsPlatform = AzFramework::OSPlatformToDefaultAssetPlatform(AZ_TRAIT_OS_PLATFORM_CODENAME);
@@ -227,8 +227,10 @@ namespace AzFramework
EntitySpawnTicket::EntitySpawnTicket(EntitySpawnTicket&& rhs)
: m_payload(rhs.m_payload)
, m_id(rhs.m_id)
{
rhs.m_payload = nullptr;
rhs.m_id = 0;
}
EntitySpawnTicket::EntitySpawnTicket(AZ::Data::Asset<Spawnable> spawnable)
@@ -269,7 +269,7 @@ namespace AzFramework
int numEnvironmentVars = 0;
if (processLaunchInfo.m_environmentVariables)
{
const int numEnvironmentVars = processLaunchInfo.m_environmentVariables->size();
numEnvironmentVars = processLaunchInfo.m_environmentVariables->size();
// Adding one more as exec expects the array to have a nullptr as the last element
environmentVariables = new char*[numEnvironmentVars + 1];
for (int i = 0; i < numEnvironmentVars; i++)
@@ -98,7 +98,7 @@ namespace UnitTest
// If an entry is removed from the octree as an unintended side effect of updating an existing entry,
// GetEntryCount can't be relied upon to report the actual entry count.
// So manually count the entries when using the entry count for validation.
uint32_t manualEntryCount = 0;
size_t manualEntryCount = 0;
visScene->EnumerateNoCull([&manualEntryCount](const AzFramework::IVisibilityScene::NodeData& nodeData) { manualEntryCount += nodeData.m_entries.size(); });
EXPECT_EQ(manualEntryCount, expectedEntryCount);
@@ -409,7 +409,7 @@ namespace UnitTest
}
// Expect all the entries to be in the scene
ValidateEntryCountEqualsExpectedCount(m_octreeScene, visEntries.size());
ValidateEntryCountEqualsExpectedCount(m_octreeScene, static_cast<uint32_t>(visEntries.size()));
// Update them, without making any actual changes
for (AzFramework::VisibilityEntry& entry : visEntries)
@@ -418,6 +418,6 @@ namespace UnitTest
}
// Expect all the entries to be in the scene
ValidateEntryCountEqualsExpectedCount(m_octreeScene, visEntries.size());
ValidateEntryCountEqualsExpectedCount(m_octreeScene, static_cast<uint32_t>(visEntries.size()));
}
}
@@ -366,6 +366,24 @@ namespace UnitTest
}
}
TEST_F(SpawnableEntitiesManagerTest, EntitySpawnTicket_Move_Works)
{
AzFramework::EntitySpawnTicket ticket1(*m_spawnableAsset);
AzFramework::EntitySpawnTicket ticket2(*m_spawnableAsset);
const AzFramework::EntitySpawnTicket::Id ticket1Id = ticket1.GetId();
const AzFramework::EntitySpawnTicket::Id ticket2Id = ticket2.GetId();
AzFramework::EntitySpawnTicket ticketMoveConstructor(AZStd::move(ticket1));
EXPECT_TRUE(ticketMoveConstructor.IsValid());
EXPECT_EQ(ticketMoveConstructor.GetId(), ticket1Id);
AzFramework::EntitySpawnTicket ticketMoveOperator;
ticketMoveOperator = AZStd::move(ticket2);
EXPECT_TRUE(ticketMoveOperator.IsValid());
EXPECT_EQ(ticketMoveOperator.GetId(), ticket2Id);
}
TEST_F(SpawnableEntitiesManagerTest, SpawnAllEntities_DeleteTicketBeforeCall_NoCrash)
{
{
@@ -170,7 +170,7 @@ namespace AzNetworking
}
timeoutItem->UpdateTimeoutTime(startTimeMs);
NetworkOutputSerializer serializer(buffer.GetBuffer(), buffer.GetSize());
NetworkOutputSerializer serializer(buffer.GetBuffer(), static_cast<uint32_t>(buffer.GetSize()));
if (m_state == ConnectionState::Connecting)
{
const ConnectResult connectResult = m_networkInterface.GetConnectionListener().ValidateConnect(GetRemoteAddress(), header, serializer);
@@ -198,7 +198,7 @@ namespace AzNetworking
{
TcpPacketEncodingBuffer buffer;
{
NetworkInputSerializer serializer(buffer.GetBuffer(), buffer.GetCapacity());
NetworkInputSerializer serializer(buffer.GetBuffer(), static_cast<uint32_t>(buffer.GetCapacity()));
if (!const_cast<IPacket&>(packet).Serialize(serializer))
{
AZ_Assert(false, "SendReliablePacket: Unable to serialize packet [Type: %d]", packet.GetPacketType());
@@ -272,7 +272,7 @@ namespace AzNetworking
{
TcpPacketHeader header(packetType, aznumeric_cast<uint16_t>(payloadBuffer.GetSize()));
header.SetPacketFlag(PacketFlag::Compressed, shouldCompress);
NetworkInputSerializer serializer(headerBuffer.GetBuffer(), headerBuffer.GetCapacity());
NetworkInputSerializer serializer(headerBuffer.GetBuffer(), static_cast<uint32_t>(headerBuffer.GetCapacity()));
if (!header.Serialize(serializer))
{
return false;
@@ -313,7 +313,7 @@ namespace AzNetworking
m_networkInterface.GetMetrics().m_sendBytesCompressedDelta += (payloadSize - compressionMemBytesUsed);
writeBuffer.Resize(aznumeric_cast<int32_t>(compressionMemBytesUsed));
payloadSize = writeBuffer.GetSize();
payloadSize = static_cast<uint32_t>(writeBuffer.GetSize());
srcData = writeBuffer.GetBuffer();
}
@@ -12,7 +12,7 @@ namespace AzNetworking
{
template <uint32_t SIZE>
inline TcpRingBuffer<SIZE>::TcpRingBuffer()
: m_impl(m_buffer.data(), m_buffer.size())
: m_impl(m_buffer.data(), static_cast<uint32_t>(m_buffer.size()))
{
;
}
@@ -84,7 +84,7 @@ namespace AzNetworking
if (dtlsData.GetSize() > 0)
{
const uint8_t* encryptedData = dtlsData.GetBuffer();
const uint32_t encryptedSize = dtlsData.GetSize();
const uint32_t encryptedSize = static_cast<uint32_t>(dtlsData.GetSize());
BIO_write(m_readBio, encryptedData, encryptedSize);
}
DtlsEndpoint::HandshakeState prevState = m_state;
@@ -196,7 +196,7 @@ namespace AzNetworking
// Need to do this... connection negotiation may have left data in the write bio that we need to send out
if (BIO_ctrl_pending(m_writeBio) > 0)
{
const uint32_t maxBufferSize = outHandshakeData.GetCapacity();
const uint32_t maxBufferSize = static_cast<uint32_t>(outHandshakeData.GetCapacity());
outHandshakeData.Resize(maxBufferSize);
const int32_t dataSize = BIO_read(m_writeBio, outHandshakeData.GetBuffer(), maxBufferSize);
outHandshakeData.Resize(dataSize);
@@ -108,7 +108,7 @@ namespace AzNetworking
return true;
}
totalPacketSize += packetFragments[index]->GetChunkBuffer().GetSize();
totalPacketSize += static_cast<uint32_t>(packetFragments[index]->GetChunkBuffer().GetSize());
}
// We now mark this sequence as delivered, so if by some chance all the individual chunks get redelivered again we don't double deliver the reconstructed packet
@@ -125,7 +125,7 @@ namespace AzNetworking
uint8_t* bufferPointer = buffer.GetBuffer();
for (uint32_t index = 0; index < packetFragments.size(); ++index)
{
const uint32_t chunkSize = packetFragments[index]->GetChunkBuffer().GetSize();
const uint32_t chunkSize = static_cast<uint32_t>(packetFragments[index]->GetChunkBuffer().GetSize());
memcpy(bufferPointer, packetFragments[index]->GetChunkBuffer().GetBuffer(), chunkSize);
bufferPointer += chunkSize;
}
@@ -133,7 +133,7 @@ namespace AzNetworking
// We can erase all the chunks now, packet is completed
m_packetFragments.erase(fragmentSequence);
NetworkOutputSerializer networkSerializer(buffer.GetBuffer(), buffer.GetSize());
NetworkOutputSerializer networkSerializer(buffer.GetBuffer(), static_cast<uint32_t>(buffer.GetSize()));
{
ISerializer& networkISerializer = networkSerializer; // To get the default typeinfo parameters in ISerializer
@@ -249,7 +249,7 @@ namespace AzNetworking
continue;
}
decodedPacketData = m_decompressBuffer.GetBuffer();
decodedPacketSize = m_decompressBuffer.GetSize();
decodedPacketSize = static_cast<int32_t>(m_decompressBuffer.GetSize());
}
GetMetrics().m_recvBytesUncompressed += decodedPacketSize;
@@ -504,7 +504,7 @@ namespace AzNetworking
{
buffer.Resize(buffer.GetCapacity());
NetworkInputSerializer networkSerializer(buffer.GetBuffer(), buffer.GetCapacity());
NetworkInputSerializer networkSerializer(buffer.GetBuffer(), static_cast<uint32_t>(buffer.GetCapacity()));
ISerializer& serializer = networkSerializer; // To get the default typeinfo parameters in ISerializer
if (!header.SerializePacketFlags(serializer))
@@ -527,7 +527,7 @@ namespace AzNetworking
buffer.Resize(serializer.GetSize());
}
uint32_t packetSize = buffer.GetSize();
uint32_t packetSize = static_cast<uint32_t>(buffer.GetSize());
uint8_t* packetData = buffer.GetBuffer();
// If the packet doesn't fit within our MTU (minus potential SSL encryption overhead), break it up
@@ -559,7 +559,7 @@ namespace AzNetworking
UdpPacketEncodingBuffer writeBuffer;
if (m_compressor && shouldCompress)
{
NetworkInputSerializer flagSerializer(writeBuffer.GetBuffer(), writeBuffer.GetCapacity());
NetworkInputSerializer flagSerializer(writeBuffer.GetBuffer(), static_cast<uint32_t>(writeBuffer.GetCapacity()));
ISerializer& serializer = flagSerializer; // To get the default typeinfo parameters in ISerializer
header.SetPacketFlag(PacketFlag::Compressed, true);
@@ -572,7 +572,7 @@ namespace AzNetworking
AZ_Assert(flagSize == 1, "Flag bitfield should serialize to one byte");
// Compress the packet, make sure to offset by the size of the flag which is now serialized
const uint32_t payloadSize = buffer.GetSize() - flagSize;
const uint32_t payloadSize = static_cast<uint32_t>(buffer.GetSize() - flagSize);
uint8_t* payload = buffer.GetBuffer() + flagSize;
const AZStd::size_t maxSizeNeeded = m_compressor->GetMaxCompressedBufferSize(payloadSize);
AZStd::size_t compressionMemBytesUsed = 0;
@@ -588,7 +588,7 @@ namespace AzNetworking
if (compressionMemBytesUsed < payloadSize)
{
writeBuffer.Resize(aznumeric_cast<int32_t>(flagSize + compressionMemBytesUsed));
packetSize = writeBuffer.GetSize();
packetSize = static_cast<uint32_t>(writeBuffer.GetSize());
packetData = writeBuffer.GetBuffer();
// Track byte delta caused by compression
GetMetrics().m_sendBytesCompressedDelta += (packetSize - compressionMemBytesUsed);
@@ -177,7 +177,7 @@ namespace AzNetworking
}
IpAddress address;
const uint32_t bufferHead = receiveBuffer.GetSize();
const uint32_t bufferHead = static_cast<uint32_t>(receiveBuffer.GetSize());
if (bufferHead + MaxUdpTransmissionUnit >= receiveBuffer.GetCapacity())
{
AZLOG_INFO("Receive buffer full, leaving data on the socket. Size exceeded by %d",
@@ -241,7 +241,7 @@ namespace AzNetworking
#ifdef ENABLE_LATENCY_DEBUG
int32_t UdpSocket::SendInternalDeferred(const DeferredData& data) const
{
return SendInternal(data.m_address, data.m_dataBuffer.GetBuffer(), data.m_dataBuffer.GetSize(), data.m_encrypt, *data.m_dtlsEndpoint);
return SendInternal(data.m_address, data.m_dataBuffer.GetBuffer(), static_cast<uint32_t>(data.m_dataBuffer.GetSize()), data.m_encrypt, *data.m_dtlsEndpoint);
}
#endif
}
@@ -98,7 +98,7 @@ namespace AzToolsFramework
SourceControlFileInfo GetSceneSourceControlInfo() override;
bool AreAnyEntitiesSelected() override { return !m_selectedEntities.empty(); }
int GetSelectedEntitiesCount() override { return m_selectedEntities.size(); }
int GetSelectedEntitiesCount() override { return static_cast<int>(m_selectedEntities.size()); }
const EntityIdList& GetSelectedEntities() override { return m_selectedEntities; }
const EntityIdList& GetHighlightedEntities() override { return m_highlightedEntities; }
void SetSelectedEntities(const EntityIdList& selectedEntities) override;
@@ -34,8 +34,6 @@ namespace AzToolsFramework::AssetUtils::Internal
return {};
}
const int pathLen = sourceFolder.length() + 1;
AZ::IO::Path sourceWildcard{ sourceFolder };
@@ -72,15 +72,8 @@ namespace AzToolsFramework
if (m_rootInstance != nullptr)
{
// Need to save off the template id to remove the template after the instance is deleted.
Prefab::TemplateId templateId = m_rootInstance->GetTemplateId();
m_rootInstance.reset();
if (templateId != Prefab::InvalidTemplateId)
{
// Remove the template here so that if we're in a Deactivate/Activate cycle, it can recreate the template/rootInstance
// correctly
m_prefabSystemComponent->RemoveTemplate(templateId);
}
m_prefabSystemComponent->RemoveAllTemplates();
}
}
@@ -95,7 +88,7 @@ namespace AzToolsFramework
if (templateId != Prefab::InvalidTemplateId)
{
m_rootInstance->SetTemplateId(Prefab::InvalidTemplateId);
m_prefabSystemComponent->RemoveTemplate(templateId);
m_prefabSystemComponent->RemoveAllTemplates();
}
m_rootInstance->SetContainerEntityName("Level");
}
@@ -164,7 +164,7 @@ namespace AzToolsFramework
AZStd::string path = prefix + pathIter->value.GetString();
pathIter->value.SetString(path.c_str(), path.length(), providedPatch.GetAllocator());
pathIter->value.SetString(path.c_str(), static_cast<rapidjson::SizeType>(path.length()), providedPatch.GetAllocator());
}
}
@@ -97,7 +97,7 @@ namespace AzToolsFramework
m_updatingTemplateInstancesInQueue = true;
const int instanceCountToUpdateInBatch =
m_instanceCountToUpdateInBatch == 0 ? m_instancesUpdateQueue.size() : m_instanceCountToUpdateInBatch;
m_instanceCountToUpdateInBatch == 0 ? static_cast<int>(m_instancesUpdateQueue.size()) : m_instanceCountToUpdateInBatch;
TemplateId currentTemplateId = InvalidTemplateId;
TemplateReference currentTemplateReference = AZStd::nullopt;
@@ -1458,7 +1458,7 @@ namespace AzToolsFramework
if (&owningInstance->get() == &commonRootEntityOwningInstance)
{
// If it's the same instance, we can add this entity to the new instance entities.
int priorEntitiesSize = entities.size();
size_t priorEntitiesSize = entities.size();
entities.insert(entity);
@@ -1645,7 +1645,7 @@ namespace AzToolsFramework
entityDomAfter.Parse(newEntityDomString.toUtf8().constData());
// Add the new Entity DOM to the Entities member of the instance
rapidjson::Value aliasName(newEntityAlias.c_str(), newEntityAlias.length(), domToAddDuplicatedEntitiesUnder.GetAllocator());
rapidjson::Value aliasName(newEntityAlias.c_str(), static_cast<rapidjson::SizeType>(newEntityAlias.length()), domToAddDuplicatedEntitiesUnder.GetAllocator());
entitiesIter->value.AddMember(AZStd::move(aliasName), entityDomAfter, domToAddDuplicatedEntitiesUnder.GetAllocator());
}
@@ -1717,7 +1717,7 @@ namespace AzToolsFramework
nestedInstanceDomAfter.Parse(newInstanceDomString.toUtf8().constData());
// Add the new Instance DOM to the Instances member of the instance
rapidjson::Value aliasName(newInstanceAlias.c_str(), newInstanceAlias.length(), domToAddDuplicatedInstancesUnder.GetAllocator());
rapidjson::Value aliasName(newInstanceAlias.c_str(), static_cast<rapidjson::SizeType>(newInstanceAlias.length()), domToAddDuplicatedInstancesUnder.GetAllocator());
instancesIter->value.AddMember(AZStd::move(aliasName), nestedInstanceDomAfter, domToAddDuplicatedInstancesUnder.GetAllocator());
}
@@ -251,7 +251,7 @@ namespace AzToolsFramework
{
EditorPythonConsoleInterface::GlobalFunctionCollection globalFunctionCollection;
editorPythonConsoleInterface->GetGlobalFunctionList(globalFunctionCollection);
m_items.reserve(globalFunctionCollection.size());
m_items.reserve(static_cast<int>(globalFunctionCollection.size()));
for (const EditorPythonConsoleInterface::GlobalFunction& globalFunction : globalFunctionCollection)
{
Item item;
@@ -247,7 +247,7 @@ namespace AzToolsFramework
if (highlightTextIndex >= 0)
{
const QString BACKGROUND_COLOR{ "#707070" };
label.insert(highlightTextIndex + m_filterString.length(), "</span>");
label.insert(highlightTextIndex + static_cast<int>(m_filterString.length()), "</span>");
label.insert(highlightTextIndex, "<span style=\"background-color: " + BACKGROUND_COLOR + "\">");
}
} while(highlightTextIndex > 0);
@@ -2643,22 +2643,22 @@ namespace AzToolsFramework
m_gui->m_statusComboBox->setItalic(false);
if (allActive)
{
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[StatusTypeToIndex(StatusType::StatusStartActive)]);
m_gui->m_statusComboBox->setCurrentIndex(StatusTypeToIndex(StatusType::StatusStartActive));
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[static_cast<int>(StatusTypeToIndex(StatusType::StatusStartActive))]);
m_gui->m_statusComboBox->setCurrentIndex(static_cast<int>(StatusTypeToIndex(StatusType::StatusStartActive)));
m_comboItems[StatusTypeToIndex(StatusType::StatusStartActive)]->setCheckState(Qt::Checked);
}
else
if (allInactive)
{
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[StatusTypeToIndex(StatusType::StatusStartInactive)]);
m_gui->m_statusComboBox->setCurrentIndex(StatusTypeToIndex(StatusType::StatusStartInactive));
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[static_cast<int>(StatusTypeToIndex(StatusType::StatusStartInactive))]);
m_gui->m_statusComboBox->setCurrentIndex(static_cast<int>(StatusTypeToIndex(StatusType::StatusStartInactive)));
m_comboItems[StatusTypeToIndex(StatusType::StatusStartInactive)]->setCheckState(Qt::Checked);
}
else
if (allEditorOnly)
{
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[StatusTypeToIndex(StatusType::StatusEditorOnly)]);
m_gui->m_statusComboBox->setCurrentIndex(StatusTypeToIndex(StatusType::StatusEditorOnly));
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[static_cast<int>(StatusTypeToIndex(StatusType::StatusEditorOnly))]);
m_gui->m_statusComboBox->setCurrentIndex(static_cast<int>(StatusTypeToIndex(StatusType::StatusEditorOnly)));
m_comboItems[StatusTypeToIndex(StatusType::StatusEditorOnly)]->setCheckState(Qt::Checked);
}
else // Some marked active, some not
@@ -50,11 +50,19 @@ namespace AzToolsFramework
AzFramework::ViewportDebugDisplayEventBus::Handler::BusConnect(GetEntityContextId());
}
m_entityDataCache = AZStd::make_unique<EditorVisibleEntityDataCache>();
// temporarily disconnect from EditorInteractionSystemViewportSelectionRequestBus in case during the creation of
// m_interactionRequests (see interactionRequestsBuilder below) an event is propagated to the handler, if this happens then
// m_interactionRequests will be null as it will not have finished being created yet so we ensure no events are forwarded to it
EditorInteractionSystemViewportSelectionRequestBus::Handler::BusDisconnect();
m_interactionRequests.reset(); // BusConnect/Disconnect in constructor/destructor,
// so have to reset before assigning the new one
m_interactionRequests = interactionRequestsBuilder(m_entityDataCache.get());
{
m_entityDataCache = AZStd::make_unique<EditorVisibleEntityDataCache>();
m_interactionRequests.reset(); // BusConnect/Disconnect in constructor/destructor,
// so have to reset before assigning the new one
m_interactionRequests = interactionRequestsBuilder(m_entityDataCache.get());
}
EditorInteractionSystemViewportSelectionRequestBus::Handler::BusConnect(GetEntityContextId());
}
void EditorInteractionSystemComponent::SetDefaultHandler()
@@ -380,7 +380,6 @@ namespace AzToolsFramework::ViewportUi::Internal
}
PrepareWidgetForViewportUi(widget);
m_renderOverlay->setFocus();
}
void ViewportUiDisplay::SetUiOverlayContentsAnchored(QPointer<QWidget> widget, const Qt::Alignment alignment)
@@ -392,7 +391,6 @@ namespace AzToolsFramework::ViewportUi::Internal
PrepareWidgetForViewportUi(widget);
m_uiOverlayLayout.AddAnchoredWidget(widget, alignment);
m_renderOverlay->setFocus();
}
void ViewportUiDisplay::UpdateUiOverlayGeometry()
@@ -110,8 +110,8 @@ namespace Benchmark
void BM_Prefab::SetUpMockValidatorForReadPrefab()
{
int pathCount = m_paths.size();
for (int number = 0; number < pathCount; ++number)
const size_t pathCount = m_paths.size();
for (size_t number = 0; number < pathCount; ++number)
{
m_mockIOActionValidator->ReadPrefabDom(
m_paths[number], UnitTest::PrefabTestDomUtils::CreatePrefabDom());
@@ -245,7 +245,9 @@ namespace UnitTest
m_instanceToTemplateInterface->GenerateDomForInstance(instanceDomBeforeUpdate, *firstInstance);
//remove instance from instance
firstInstance->DetachNestedInstance(addedAlias);
AZStd::unique_ptr<Instance> detachedInstance = firstInstance->DetachNestedInstance(addedAlias);
ASSERT_TRUE(detachedInstance != nullptr);
m_prefabSystemComponent->RemoveLink(detachedInstance->GetLinkId());
//create document with after change snapshot
PrefabDom instanceDomAfterUpdate;
@@ -38,7 +38,7 @@ namespace UnitTest
const EntityAlias& entityAlias)
{
return GetPrefabDomEntitiesPath()
.Append(entityAlias.c_str(), entityAlias.length());
.Append(entityAlias.c_str(), static_cast<rapidjson::SizeType>(entityAlias.length()));
};
inline PrefabDomPath GetPrefabDomEntityNamePath(
@@ -62,7 +62,7 @@ namespace UnitTest
inline PrefabDomPath GetPrefabDomInstancePath(
const InstanceAlias& instanceAlias)
{
return GetPrefabDomInstancesPath().Append(instanceAlias.c_str(), instanceAlias.length());
return GetPrefabDomInstancesPath().Append(instanceAlias.c_str(), static_cast<rapidjson::SizeType>(instanceAlias.length()));
};
inline PrefabDomPath GetPrefabDomInstancePath(
@@ -309,6 +309,7 @@ namespace UnitTest
// and use the updated enclosing Instance to update the PrefabDom of Template.
AZStd::unique_ptr<Instance> detachedInstance = newEnclosingInstance->DetachNestedInstance(nestedInstanceAliases.front());
ASSERT_TRUE(detachedInstance);
m_prefabSystemComponent->RemoveLink(detachedInstance->GetLinkId());
PrefabDom updatedTemplateDom;
ASSERT_TRUE(PrefabDomUtils::StoreInstanceInPrefabDom(*newEnclosingInstance, updatedTemplateDom));
@@ -274,6 +274,7 @@ namespace UnitTest
InstanceAlias aliasOfWheelInstanceToRetain = wheelInstanceAliasesUnderAxle.front();
AZStd::unique_ptr<Instance> detachedInstance = axleInstance->DetachNestedInstance(wheelInstanceAliasesUnderAxle.back());
ASSERT_TRUE(detachedInstance);
m_prefabSystemComponent->RemoveLink(detachedInstance->GetLinkId());
PrefabDom updatedAxleInstanceDom;
ASSERT_TRUE(PrefabDomUtils::StoreInstanceInPrefabDom(*axleInstance, updatedAxleInstanceDom));
m_prefabSystemComponent->UpdatePrefabTemplate(axleTemplateId, updatedAxleInstanceDom);