Merge branch 'stabilization/2106' into Atom/guthadam/ATOM-15748_fixing_material_editor_launch_failure_for_new_projects
This commit is contained in:
@@ -901,7 +901,13 @@ namespace AzToolsFramework
|
||||
return AZ::Failure(AZStd::string("No entities to duplicate."));
|
||||
}
|
||||
|
||||
if (!EntitiesBelongToSameInstance(entityIds))
|
||||
const EntityIdList entityIdsNoLevelInstance = GenerateEntityIdListWithoutLevelInstance(entityIds);
|
||||
if (entityIdsNoLevelInstance.empty())
|
||||
{
|
||||
return AZ::Failure(AZStd::string("No entities to duplicate because only instance selected is the level instance."));
|
||||
}
|
||||
|
||||
if (!EntitiesBelongToSameInstance(entityIdsNoLevelInstance))
|
||||
{
|
||||
return AZ::Failure(AZStd::string("Cannot duplicate multiple entities belonging to different instances with one operation."
|
||||
"Change your selection to contain entities in the same instance."));
|
||||
@@ -909,7 +915,7 @@ namespace AzToolsFramework
|
||||
|
||||
// We've already verified the entities are all owned by the same instance,
|
||||
// so we can just retrieve our instance from the first entity in the list.
|
||||
AZ::EntityId firstEntityIdToDuplicate = entityIds[0];
|
||||
AZ::EntityId firstEntityIdToDuplicate = entityIdsNoLevelInstance[0];
|
||||
InstanceOptionalReference commonOwningInstance = GetOwnerInstanceByEntityId(firstEntityIdToDuplicate);
|
||||
if (!commonOwningInstance.has_value())
|
||||
{
|
||||
@@ -929,7 +935,7 @@ namespace AzToolsFramework
|
||||
|
||||
// This will cull out any entities that have ancestors in the list, since we will end up duplicating
|
||||
// the full nested hierarchy with what is returned from RetrieveAndSortPrefabEntitiesAndInstances
|
||||
AzToolsFramework::EntityIdSet duplicationSet = AzToolsFramework::GetCulledEntityHierarchy(entityIds);
|
||||
AzToolsFramework::EntityIdSet duplicationSet = AzToolsFramework::GetCulledEntityHierarchy(entityIdsNoLevelInstance);
|
||||
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
|
||||
|
||||
@@ -1004,17 +1010,19 @@ namespace AzToolsFramework
|
||||
|
||||
PrefabOperationResult PrefabPublicHandler::DeleteFromInstance(const EntityIdList& entityIds, bool deleteDescendants)
|
||||
{
|
||||
if (entityIds.empty())
|
||||
const EntityIdList entityIdsNoLevelInstance = GenerateEntityIdListWithoutLevelInstance(entityIds);
|
||||
|
||||
if (entityIdsNoLevelInstance.empty())
|
||||
{
|
||||
return AZ::Success();
|
||||
}
|
||||
|
||||
if (!EntitiesBelongToSameInstance(entityIds))
|
||||
if (!EntitiesBelongToSameInstance(entityIdsNoLevelInstance))
|
||||
{
|
||||
return AZ::Failure(AZStd::string("Cannot delete multiple entities belonging to different instances with one operation."));
|
||||
}
|
||||
|
||||
AZ::EntityId firstEntityIdToDelete = entityIds[0];
|
||||
AZ::EntityId firstEntityIdToDelete = entityIdsNoLevelInstance[0];
|
||||
InstanceOptionalReference commonOwningInstance = GetOwnerInstanceByEntityId(firstEntityIdToDelete);
|
||||
|
||||
// If the first entity id is a container entity id, then we need to mark its parent as the common owning instance because you
|
||||
@@ -1025,7 +1033,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
// Retrieve entityList from entityIds
|
||||
EntityList inputEntityList = EntityIdListToEntityList(entityIds);
|
||||
EntityList inputEntityList = EntityIdListToEntityList(entityIdsNoLevelInstance);
|
||||
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
|
||||
|
||||
@@ -1081,7 +1089,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
else
|
||||
{
|
||||
for (AZ::EntityId entityId : entityIds)
|
||||
for (AZ::EntityId entityId : entityIdsNoLevelInstance)
|
||||
{
|
||||
InstanceOptionalReference owningInstance = m_instanceEntityMapperInterface->FindOwningInstance(entityId);
|
||||
// If this is the container entity, it actually represents the instance so get its owner
|
||||
@@ -1437,6 +1445,22 @@ namespace AzToolsFramework
|
||||
return (outEntities.size() + outInstances.size()) > 0;
|
||||
}
|
||||
|
||||
EntityIdList PrefabPublicHandler::GenerateEntityIdListWithoutLevelInstance(
|
||||
const EntityIdList& entityIds) const
|
||||
{
|
||||
EntityIdList outEntityIds;
|
||||
outEntityIds.reserve(entityIds.size()); // Actual size could be smaller.
|
||||
|
||||
for (const AZ::EntityId& entityId : entityIds)
|
||||
{
|
||||
if (!IsLevelInstanceContainerEntity(entityId))
|
||||
{
|
||||
outEntityIds.emplace_back(entityId);
|
||||
}
|
||||
}
|
||||
return outEntityIds;
|
||||
}
|
||||
|
||||
bool PrefabPublicHandler::EntitiesBelongToSameInstance(const EntityIdList& entityIds) const
|
||||
{
|
||||
if (entityIds.size() <= 1)
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace AzToolsFramework
|
||||
PrefabOperationResult DeleteFromInstance(const EntityIdList& entityIds, bool deleteDescendants);
|
||||
bool RetrieveAndSortPrefabEntitiesAndInstances(const EntityList& inputEntities, Instance& commonRootEntityOwningInstance,
|
||||
EntityList& outEntities, AZStd::vector<Instance*>& outInstances) const;
|
||||
EntityIdList GenerateEntityIdListWithoutLevelInstance(const EntityIdList& entityIds) const;
|
||||
|
||||
InstanceOptionalReference GetOwnerInstanceByEntityId(AZ::EntityId entityId) const;
|
||||
bool EntitiesBelongToSameInstance(const EntityIdList& entityIds) const;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <PhysX_precompiled.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/std/smart_ptr/make_shared.h>
|
||||
#include <AzCore/std/parallel/scoped_lock.h>
|
||||
#include <AzFramework/Physics/PhysicsScene.h>
|
||||
#include <AzFramework/Physics/PhysicsSystem.h>
|
||||
#include <AzFramework/Physics/SystemBus.h>
|
||||
@@ -40,6 +41,8 @@ namespace PhysX
|
||||
} // namespace Internal
|
||||
|
||||
// PhysX::Ragdoll
|
||||
/*static*/ AZStd::mutex Ragdoll::m_sceneEventMutex;
|
||||
|
||||
void Ragdoll::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
|
||||
@@ -114,7 +117,10 @@ namespace PhysX
|
||||
|
||||
Ragdoll::~Ragdoll()
|
||||
{
|
||||
m_sceneStartSimHandler.Disconnect();
|
||||
{
|
||||
AZStd::scoped_lock lock(m_sceneEventMutex);
|
||||
m_sceneStartSimHandler.Disconnect();
|
||||
}
|
||||
|
||||
m_nodes.clear(); //the nodes destructor will remove the simulated body from the scene.
|
||||
}
|
||||
@@ -212,7 +218,13 @@ namespace PhysX
|
||||
}
|
||||
}
|
||||
|
||||
sceneInterface->RegisterSceneSimulationStartHandler(m_sceneOwner, m_sceneStartSimHandler);
|
||||
// the handler is also connected in EnableSimulationQueued(),
|
||||
// which will call this function, so if called from that path dont connect here.
|
||||
if (!m_sceneStartSimHandler.IsConnected())
|
||||
{
|
||||
AZStd::scoped_lock lock(m_sceneEventMutex);
|
||||
sceneInterface->RegisterSceneSimulationStartHandler(m_sceneOwner, m_sceneStartSimHandler);
|
||||
}
|
||||
sceneInterface->EnableSimulationOfBody(m_sceneOwner, m_bodyHandle);
|
||||
}
|
||||
|
||||
@@ -225,6 +237,7 @@ namespace PhysX
|
||||
|
||||
if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
|
||||
{
|
||||
AZStd::scoped_lock lock(m_sceneEventMutex);
|
||||
sceneInterface->RegisterSceneSimulationStartHandler(m_sceneOwner, m_sceneStartSimHandler);
|
||||
}
|
||||
|
||||
@@ -244,7 +257,10 @@ namespace PhysX
|
||||
return;
|
||||
}
|
||||
|
||||
m_sceneStartSimHandler.Disconnect();
|
||||
{
|
||||
AZStd::scoped_lock lock(m_sceneEventMutex);
|
||||
m_sceneStartSimHandler.Disconnect();
|
||||
}
|
||||
|
||||
physx::PxScene* pxScene = Internal::GetPxScene(m_sceneOwner);
|
||||
const size_t numNodes = m_nodes.size();
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/parallel/mutex.h>
|
||||
#include <AzFramework/Physics/RagdollPhysicsBus.h>
|
||||
#include <AzFramework/Physics/Ragdoll.h>
|
||||
#include <AzFramework/Physics/Common/PhysicsEvents.h>
|
||||
@@ -84,5 +85,6 @@ namespace PhysX
|
||||
bool m_queuedDisableSimulation = false;
|
||||
|
||||
AzPhysics::SceneEvents::OnSceneSimulationStartHandler m_sceneStartSimHandler;
|
||||
static AZStd::mutex m_sceneEventMutex;
|
||||
};
|
||||
} // namespace PhysX
|
||||
|
||||
Reference in New Issue
Block a user