Merge branch 'main' into hasareej_LYN-2475_viewportui_switcher

This commit is contained in:
hultonha
2021-04-26 11:01:48 +01:00
4394 changed files with 29188 additions and 43395 deletions
@@ -36,4 +36,4 @@ namespace AzToolsFramework
};
using EditorAnimationSystemRequestsBus = AZ::EBus<EditorAnimationSystemRequests>;
}
}
@@ -52,4 +52,4 @@ namespace AzToolsFramework
using EntityCompositionNotificationBus = AZ::EBus<EntityCompositionNotifications>;
}
}
@@ -57,4 +57,4 @@ namespace AzToolsFramework
}
}
#include "Application/moc_Ticker.cpp"
#include "Application/moc_Ticker.cpp"
@@ -55,4 +55,4 @@ namespace AzToolsFramework
float m_timeoutMS;
};
}
}
@@ -165,4 +165,4 @@ namespace AzToolsFramework
AZ::Data::AssetId m_assetId;
};
} // namespace AssetBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -75,4 +75,4 @@ namespace AzToolsFramework
};
} // namespace AssetBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -76,4 +76,4 @@ namespace AzToolsFramework
QString m_title;
};
} // namespace AssetBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -283,4 +283,4 @@ namespace AzToolsFramework
} // namespace AssetBrowser
} // namespace AzToolsFramework
#include "AssetBrowser/Entries/moc_AssetBrowserEntry.cpp"
#include "AssetBrowser/Entries/moc_AssetBrowserEntry.cpp"
@@ -69,4 +69,4 @@ namespace AzToolsFramework
m_absolutePathToFileId.clear();
}
}
}
}
@@ -55,4 +55,4 @@ namespace AzToolsFramework
AZ_DISABLE_COPY_MOVE(FolderAssetBrowserEntry);
};
} // namespace AssetBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -63,4 +63,4 @@ namespace AzToolsFramework
AZ_DISABLE_COPY_MOVE(ProductAssetBrowserEntry);
};
} // namespace AssetBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -95,4 +95,4 @@ namespace AzToolsFramework
bool m_isInitialUpdate = false;
};
} // namespace AssetBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -80,4 +80,4 @@ namespace AzToolsFramework
AZ_DISABLE_COPY_MOVE(SourceAssetBrowserEntry);
};
} // namespace AssetBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -47,4 +47,4 @@ namespace AzToolsFramework
QScopedPointer<Ui::EmptyPreviewerClass> m_ui;
};
} // namespace AssetBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -23,4 +23,4 @@ namespace AzToolsFramework
}
}
#include <AssetBrowser/Previewer/moc_Previewer.cpp>
#include <AssetBrowser/Previewer/moc_Previewer.cpp>
@@ -44,4 +44,4 @@ namespace AzToolsFramework
using PreviewerRequestBus = AZ::EBus<PreviewerRequests>;
} // namespace AssetBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -34,4 +34,4 @@ namespace AzToolsFramework
virtual const QString& GetName() const = 0;
};
} // namespace AssetBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -613,4 +613,4 @@ namespace AzToolsFramework
} // namespace AssetBrowser
} // namespace AzToolsFramework
#include "AssetBrowser/Search/moc_Filter.cpp"
#include "AssetBrowser/Search/moc_Filter.cpp"
@@ -12,4 +12,4 @@
</g>
</g>
</g>
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 948 B

After

Width:  |  Height:  |  Size: 949 B

@@ -8,4 +8,4 @@
<rect id="Icon-Background" x="0" y="0" width="24" height="24"></rect>
<path d="M20.9694824,19.6604004 L16.3757324,15.0666504 C17.4069824,13.7541504 17.9694824,12.1604004 17.9694824,10.4729004 C17.9694824,6.34790039 14.5944824,2.97290039 10.4694824,2.97290039 C6.34448242,2.97290039 2.96948242,6.34790039 2.96948242,10.4729004 C2.96948242,14.5979004 6.34448242,17.9729004 10.4694824,17.9729004 C12.1569824,17.9729004 13.7507324,17.4104004 15.0632324,16.3791504 L19.6569824,20.9729004 L20.9694824,19.6604004 Z M10.4694824,16.0979004 C7.37573242,16.0979004 4.84448242,13.5666504 4.84448242,10.4729004 C4.84448242,7.37915039 7.37573242,4.84790039 10.4694824,4.84790039 C13.5632324,4.84790039 16.0944824,7.37915039 16.0944824,10.4729004 C16.0944824,13.5666504 13.5632324,16.0979004 10.4694824,16.0979004 Z" id="Shape" fill="#E9E9E9" fill-rule="nonzero"></path>
</g>
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -139,8 +139,11 @@ namespace AzToolsFramework
}
else
{
QPixmap pixmap = thumbnail->GetPixmap(size);
painter->drawPixmap(point, pixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
// Scaling and centering pixmap within bounds to preserve aspect ratio
const QPixmap pixmap = thumbnail->GetPixmap(size).scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
const QSize sizeDelta = size - pixmap.size();
const QPoint pointDelta = QPoint(sizeDelta.width() / 2, sizeDelta.height() / 2);
painter->drawPixmap(point + pointDelta, pixmap);
}
return m_iconSize;
}
@@ -25,4 +25,4 @@ namespace AzToolsFramework
AzToolsFrameworkModule();
~AzToolsFrameworkModule() override = default;
};
}
}
@@ -72,4 +72,4 @@ namespace AzToolsFramework
m_componentModeBuilders, m_transition);
}
} // namespace ComponentModeFramework
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -50,4 +50,4 @@ namespace AzToolsFramework
Transition m_transition; ///< Entering/Leaving ComponentMode.
};
} // namespace ComponentModeFramework
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -105,4 +105,4 @@ namespace AzToolsFramework
return PivotHasTranslationOverride(pivotOverride) || PivotHasOrientationOverride(pivotOverride);
}
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -103,4 +103,4 @@ namespace AzToolsFramework
bool PivotHasOrientationOverride(AZ::u8 pivotOverride);
bool PivotHasTransformOverride(AZ::u8 pivotOverride);
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -32,4 +32,4 @@ namespace AzToolsFramework
{
m_boxEdit.UpdateManipulators();
}
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -40,4 +40,4 @@ namespace AzToolsFramework
private:
BoxViewportEdit m_boxEdit;
};
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -183,4 +183,4 @@ namespace AzToolsFramework
} // Debug
} // AzToolsFramework
#endif // AZ_ENABLE_TRACE_CONTEXT
#endif // AZ_ENABLE_TRACE_CONTEXT
@@ -20,4 +20,4 @@ namespace AzToolsFramework
return Print(buffer, size, stack, printUuids, startIndex);
}
} // Debug
} // AzToolsFramework
} // AzToolsFramework
@@ -37,4 +37,4 @@ namespace AzToolsFramework
using EditorEntityContextPickingRequestBus = AZ::EBus<EditorEntityContextPickingRequests>;
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -36,4 +36,4 @@ namespace AzToolsFramework
void OnSliceEntitiesLoaded(const AZStd::vector<AZ::Entity*>& entities) override;
////////////////////////////////////////////////////////////////////////
};
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -25,4 +25,4 @@ namespace AzToolsFramework
virtual void RemoveFromChildrenWithOverrides(const EntityIdList& parentEntityIds, const AZ::EntityId& entityId) = 0;
};
using EditorEntityModelRequestBus = AZ::EBus<EditorEntityModelRequests>;
}
}
@@ -31,11 +31,19 @@ namespace AzToolsFramework
//! /param entities The entities to put under the new prefab.
//! /param nestedPrefabInstances The nested prefab instances to put under the new prefab.
//! /param filePath The filepath corresponding to the prefab file to be created.
//! /param instanceToParentUnder The instance under which the newly created prefab instance is parented under.
//! /param instanceToParentUnder The instance the newly created prefab instance is parented under.
//! /return The optional reference to the prefab created.
virtual Prefab::InstanceOptionalReference CreatePrefab(
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Prefab::Instance>>&& nestedPrefabInstances,
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder = AZStd::nullopt) = 0;
//! Instantiate the prefab file provided.
//! /param filePath The filepath for the prefab file the instance should be created from.
//! /param instanceToParentUnder The instance the newly instantiated prefab instance is parented under.
//! /return The optional reference to the prefab instance.
virtual Prefab::InstanceOptionalReference InstantiatePrefab(
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder = AZStd::nullopt) = 0;
virtual Prefab::InstanceOptionalReference GetRootPrefabInstance() = 0;
virtual bool LoadFromStream(AZ::IO::GenericStream& stream, AZStd::string_view filename) = 0;
@@ -19,6 +19,7 @@
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h>
#include <AzToolsFramework/Prefab/EditorPrefabComponent.h>
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
#include <AzToolsFramework/Prefab/Instance/Instance.h>
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
#include <AzToolsFramework/Prefab/PrefabLoader.h>
@@ -279,7 +280,7 @@ namespace AzToolsFramework
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder)
{
AZStd::unique_ptr<Prefab::Instance> createdPrefabInstance =
m_prefabSystemComponent->CreatePrefab(entities, AZStd::move(nestedPrefabInstances), filePath);
m_prefabSystemComponent->CreatePrefab(entities, AZStd::move(nestedPrefabInstances), filePath, nullptr, false);
if (createdPrefabInstance)
{
@@ -307,6 +308,26 @@ namespace AzToolsFramework
return AZStd::nullopt;
}
Prefab::InstanceOptionalReference PrefabEditorEntityOwnershipService::InstantiatePrefab(
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder)
{
AZStd::unique_ptr<Prefab::Instance> createdPrefabInstance = m_prefabSystemComponent->InstantiatePrefab(filePath);
if (createdPrefabInstance)
{
if (!instanceToParentUnder)
{
instanceToParentUnder = *m_rootInstance;
}
Prefab::Instance& addedInstance = instanceToParentUnder->get().AddInstance(AZStd::move(createdPrefabInstance));
HandleEntitiesAdded({addedInstance.m_containerEntity.get()});
return addedInstance;
}
return AZStd::nullopt;
}
Prefab::InstanceOptionalReference PrefabEditorEntityOwnershipService::GetRootPrefabInstance()
{
AZ_Assert(m_rootInstance, "A valid root prefab instance couldn't be found in PrefabEditorEntityOwnershipService.");
@@ -191,6 +191,9 @@ namespace AzToolsFramework
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Prefab::Instance>>&& nestedPrefabInstances,
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder) override;
Prefab::InstanceOptionalReference InstantiatePrefab(
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder) override;
Prefab::InstanceOptionalReference GetRootPrefabInstance() override;
//////////////////////////////////////////////////////////////////////////
@@ -48,4 +48,4 @@ namespace AzToolsFramework
/// Type to inherit to implement BoxManipulatorRequests
using BoxManipulatorRequestBus = AZ::EBus<BoxManipulatorRequests>;
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -40,4 +40,4 @@ namespace AzToolsFramework
using MaterialBrowserRequestBus = AZ::EBus<MaterialBrowserRequests>;
} // namespace MaterialBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -38,4 +38,4 @@ namespace AzToolsFramework
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
};
} // namespace MaterialBrowser
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -216,4 +216,4 @@ namespace AzToolsFramework
///< intersecting point.
};
} // namespace Picking
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -52,4 +52,4 @@ namespace AzToolsFramework
RegisteredBoundId m_nextBoundId = RegisteredBoundId(1); ///< Next bound id to use when a bound is registered.
};
} // namespace Picking
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -321,7 +321,6 @@ namespace AzToolsFramework
removedNestedInstance = AZStd::move(nestedInstanceIterator->second);
removedNestedInstance->m_parent = nullptr;
removedNestedInstance->m_alias = InstanceAlias();
m_nestedInstances.erase(instanceAlias);
}
@@ -396,6 +395,14 @@ namespace AzToolsFramework
}
}
void Instance::GetNestedInstances(const AZStd::function<void(AZStd::unique_ptr<Instance>&)>& callback)
{
for (auto& [instanceAlias, instance] : m_nestedInstances)
{
callback(instance);
}
}
void Instance::GetEntities(const AZStd::function<bool(AZStd::unique_ptr<AZ::Entity>&)>& callback)
{
for (auto& [entityAlias, entity] : m_entities)
@@ -114,6 +114,7 @@ namespace AzToolsFramework
void GetConstEntities(const AZStd::function<bool(const AZ::Entity&)>& callback);
void GetNestedEntities(const AZStd::function<bool(AZStd::unique_ptr<AZ::Entity>&)>& callback);
void GetEntities(const AZStd::function<bool(AZStd::unique_ptr<AZ::Entity>&)>& callback);
void GetNestedInstances(const AZStd::function<void(AZStd::unique_ptr<Instance>&)>& callback);
/**
* Gets the alias for a given EnitityId in the Instance DOM.
@@ -101,6 +101,10 @@ namespace AzToolsFramework
nestedInstance->GetInstanceAlias(), nestedInstance->GetLinkId(), undoBatch.GetUndoBatch());
}
PrefabUndoHelpers::UpdatePrefabInstance(
commonRootEntityOwningInstance->get(), "Update prefab instance", commonRootInstanceDomBeforeCreate,
undoBatch.GetUndoBatch());
auto prefabEditorEntityOwnershipInterface = AZ::Interface<PrefabEditorEntityOwnershipInterface>::Get();
if (!prefabEditorEntityOwnershipInterface)
{
@@ -118,13 +122,21 @@ namespace AzToolsFramework
"(A null instance is returned)."));
}
PrefabUndoHelpers::UpdatePrefabInstance(
commonRootEntityOwningInstance->get(), "Update prefab instance", commonRootInstanceDomBeforeCreate, undoBatch.GetUndoBatch());
AZ::EntityId containerEntityId = instanceToCreate->get().GetContainerEntityId();
instanceToCreate->get().GetNestedInstances([&](AZStd::unique_ptr<Instance>& nestedInstance) {
AZ_Assert(nestedInstance, "Invalid nested instance found in the new prefab created.");
EntityOptionalReference nestedInstanceContainerEntity = nestedInstance->GetContainerEntity();
AZ_Assert(
nestedInstanceContainerEntity, "Invalid container entity found for the nested instance used in prefab creation.");
CreateLink(
{&nestedInstanceContainerEntity->get()}, *nestedInstance, instanceToCreate->get().GetTemplateId(),
undoBatch.GetUndoBatch(), containerEntityId);
});
CreateLink(
topLevelEntities, instanceToCreate->get(), commonRootEntityOwningInstance->get().GetTemplateId(), undoBatch.GetUndoBatch(),
commonRootEntityId);
AZ::EntityId containerEntityId = instanceToCreate->get().GetContainerEntityId();
// Change top level entities to be parented to the container entity
// Mark them as dirty so this change is correctly applied to the template
@@ -149,6 +161,61 @@ namespace AzToolsFramework
return AZ::Success();
}
PrefabOperationResult PrefabPublicHandler::InstantiatePrefab(
AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position)
{
auto prefabEditorEntityOwnershipInterface = AZ::Interface<PrefabEditorEntityOwnershipInterface>::Get();
if (!prefabEditorEntityOwnershipInterface)
{
return AZ::Failure(AZStd::string("Could not instantiate prefab - internal error "
"(PrefabEditorEntityOwnershipInterface unavailable)."));
}
InstanceOptionalReference instanceToParentUnder;
// Get parent entity and owning instance
if (parent.IsValid())
{
instanceToParentUnder = m_instanceEntityMapperInterface->FindOwningInstance(parent);
}
if (!instanceToParentUnder.has_value())
{
instanceToParentUnder = prefabEditorEntityOwnershipInterface->GetRootPrefabInstance();
parent = instanceToParentUnder->get().GetContainerEntityId();
}
{
// Initialize Undo Batch object
ScopedUndoBatch undoBatch("Instantiate Prefab");
PrefabDom instanceToParentUnderDomBeforeCreate;
m_instanceToTemplateInterface->GenerateDomForInstance(
instanceToParentUnderDomBeforeCreate, instanceToParentUnder->get());
// Instantiate the Prefab
auto instanceToCreate = prefabEditorEntityOwnershipInterface->InstantiatePrefab(filePath, instanceToParentUnder);
if (!instanceToCreate)
{
return AZ::Failure(AZStd::string("Could not instantiate the prefab provided - internal error "
"(A null instance is returned)."));
}
PrefabUndoHelpers::UpdatePrefabInstance(
instanceToParentUnder->get(), "Update prefab instance", instanceToParentUnderDomBeforeCreate, undoBatch.GetUndoBatch());
CreateLink({}, instanceToCreate->get(), instanceToParentUnder->get().GetTemplateId(),
undoBatch.GetUndoBatch(), parent);
AZ::EntityId containerEntityId = instanceToCreate->get().GetContainerEntityId();
// Apply position
AZ::TransformBus::Event(containerEntityId, &AZ::TransformBus::Events::SetWorldTranslation, position);
}
return AZ::Success();
}
PrefabOperationResult PrefabPublicHandler::FindCommonRootOwningInstance(
const AZStd::vector<AZ::EntityId>& entityIds, EntityList& inputEntityList, EntityList& topLevelEntities,
AZ::EntityId& commonRootEntityId, InstanceOptionalReference& commonRootEntityOwningInstance)
@@ -210,34 +277,19 @@ namespace AzToolsFramework
m_instanceToTemplateInterface->GeneratePatch(patch, containerEntityDomBefore, containerEntityDomAfter);
m_instanceToTemplateInterface->AppendEntityAliasToPatchPaths(patch, containerEntityId);
PrefabUndoHelpers::CreateLink(
LinkId linkId = PrefabUndoHelpers::CreateLink(
sourceInstance.GetTemplateId(), targetTemplateId, patch, sourceInstance.GetInstanceAlias(),
undoBatch);
sourceInstance.SetLinkId(linkId);
// Update the cache - this prevents these changes from being stored in the regular undo/redo nodes
m_prefabUndoCache.Store(containerEntityId, AZStd::move(containerEntityDomAfter));
}
PrefabOperationResult PrefabPublicHandler::InstantiatePrefab(AZStd::string_view /*filePath*/, AZ::EntityId /*parent*/, AZ::Vector3 /*position*/)
{
return AZ::Failure(AZStd::string("Prefab - InstantiatePrefab is yet to be implemented."));
}
PrefabOperationResult PrefabPublicHandler::SavePrefab(AZ::IO::Path filePath)
{
auto prefabSystemComponentInterface = AZ::Interface<PrefabSystemComponentInterface>::Get();
if (!prefabSystemComponentInterface)
{
AZ_Assert(
false,
"Prefab - PrefabPublicHandler - "
"Prefab System Component Interface could not be found. "
"Check that it is being correctly initialized.");
return AZ::Failure(
AZStd::string("SavePrefab - Internal error (Prefab System Component Interface could not be found)."));
}
auto templateId = prefabSystemComponentInterface->GetTemplateIdFromFilePath(filePath.c_str());
auto templateId = m_prefabSystemComponentInterface->GetTemplateIdFromFilePath(filePath.c_str());
if (templateId == InvalidTemplateId)
{
@@ -322,9 +374,9 @@ namespace AzToolsFramework
AZ::EntityId entityId, UndoSystem::URSequencePoint* parentUndoBatch)
{
// Create Undo node on entities if they belong to an instance
InstanceOptionalReference instanceOptionalReference = m_instanceEntityMapperInterface->FindOwningInstance(entityId);
InstanceOptionalReference owningInstance = m_instanceEntityMapperInterface->FindOwningInstance(entityId);
if (instanceOptionalReference.has_value())
if (owningInstance.has_value())
{
PrefabDom afterState;
AZ::Entity* entity = GetEntityById(entityId);
@@ -438,26 +490,14 @@ namespace AzToolsFramework
PrefabRequestResult PrefabPublicHandler::HasUnsavedChanges(AZ::IO::Path prefabFilePath) const
{
auto prefabSystemComponentInterface = AZ::Interface<PrefabSystemComponentInterface>::Get();
if (!prefabSystemComponentInterface)
{
AZ_Assert(
false,
"Prefab - PrefabPublicHandler - "
"Prefab System Component Interface could not be found. "
"Check that it is being correctly initialized.");
return AZ::Failure(
AZStd::string("HasUnsavedChanges - Internal error (Prefab System Component Interface could not be found)."));
}
auto templateId = prefabSystemComponentInterface->GetTemplateIdFromFilePath(prefabFilePath.c_str());
auto templateId = m_prefabSystemComponentInterface->GetTemplateIdFromFilePath(prefabFilePath.c_str());
if (templateId == InvalidTemplateId)
{
return AZ::Failure(AZStd::string("HasUnsavedChanges - Path error. Path could be invalid, or the prefab may not be loaded in this level."));
}
return AZ::Success(prefabSystemComponentInterface->IsTemplateDirty(templateId));
return AZ::Success(m_prefabSystemComponentInterface->IsTemplateDirty(templateId));
}
PrefabOperationResult PrefabPublicHandler::DeleteEntitiesInInstance(const EntityIdList& entityIds)
@@ -45,7 +45,7 @@ namespace AzToolsFramework
// PrefabPublicInterface...
PrefabOperationResult CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath) override;
PrefabOperationResult InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, AZ::Vector3 position) 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;
@@ -58,7 +58,7 @@ namespace AzToolsFramework
* @param position The position in world space the prefab should be instantiated in.
* @return An outcome object; on failure, it comes with an error message detailing the cause of the error.
*/
virtual PrefabOperationResult InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, AZ::Vector3 position) = 0;
virtual PrefabOperationResult InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) = 0;
/**
* Saves changes to prefab to disk.
@@ -91,8 +91,9 @@ namespace AzToolsFramework
m_instanceUpdateExecutor.UpdateTemplateInstancesInQueue();
}
AZStd::unique_ptr<Instance> PrefabSystemComponent::CreatePrefab(const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume,
AZ::IO::PathView filePath, AZStd::unique_ptr<AZ::Entity> containerEntity)
AZStd::unique_ptr<Instance> PrefabSystemComponent::CreatePrefab(
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);
if (GetTemplateIdFromFilePath(relativeFilePath) != InvalidTemplateId)
@@ -123,7 +124,7 @@ namespace AzToolsFramework
newInstance->SetTemplateSourcePath(relativeFilePath);
newInstance->SetContainerEntityName(relativeFilePath.Stem().Native());
TemplateId newTemplateId = CreateTemplateFromInstance(*newInstance);
TemplateId newTemplateId = CreateTemplateFromInstance(*newInstance, shouldCreateLinks);
if (newTemplateId == InvalidTemplateId)
{
AZ_Error("Prefab", false,
@@ -260,6 +261,29 @@ namespace AzToolsFramework
}
}
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(AZ::IO::PathView filePath)
{
// Retrieve the template id for the source prefab filepath
Prefab::TemplateId templateId = GetTemplateIdFromFilePath(filePath);
if (templateId == Prefab::InvalidTemplateId)
{
// Load the template from the file
templateId = m_prefabLoader.LoadTemplateFromFile(filePath);
}
if (templateId == Prefab::InvalidTemplateId)
{
AZ_Error("Prefab", false,
"Could not load template from path %s during InstantiatePrefab. Unable to proceed",
filePath);
return nullptr;
}
return InstantiatePrefab(templateId);
}
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(const TemplateId& templateId)
{
TemplateReference instantiatingTemplate = FindTemplate(templateId);
@@ -289,7 +313,7 @@ namespace AzToolsFramework
return newInstance;
}
TemplateId PrefabSystemComponent::CreateTemplateFromInstance(Instance& instance)
TemplateId PrefabSystemComponent::CreateTemplateFromInstance(Instance& instance, bool shouldCreateLinks)
{
// We will register the template to match the path the instance has
const AZ::IO::Path& templateSourcePath = instance.GetTemplateSourcePath();
@@ -323,14 +347,15 @@ namespace AzToolsFramework
return InvalidTemplateId;
}
if (!GenerateLinksForNewTemplate(newTemplateId, instance))
if (shouldCreateLinks)
{
// Clear new template and any links associated with it
RemoveTemplate(newTemplateId);
return InvalidTemplateId;
if (!GenerateLinksForNewTemplate(newTemplateId, instance))
{
// Clear new template and any links associated with it
RemoveTemplate(newTemplateId);
return InvalidTemplateId;
}
}
return newTemplateId;
}
@@ -115,9 +115,16 @@ namespace AzToolsFramework
*/
void RemoveAllTemplates() override;
/**
* Generates a new Prefab Instance based on the Template whose source is stored in filepath.
* @param filePath the path to the prefab source file containing the template being instantiated.
* @return A unique_ptr to the newly instantiated instance. Null if operation failed.
*/
AZStd::unique_ptr<Instance> InstantiatePrefab(AZ::IO::PathView filePath) override;
/**
* Generates a new Prefab Instance based on the Template referenced by templateId
* @param templateId the id of the template being instantiated
* @param templateId the id of the template being instantiated.
* @return A unique_ptr to the newly instantiated instance. Null if operation failed.
*/
AZStd::unique_ptr<Instance> InstantiatePrefab(const TemplateId& templateId) override;
@@ -187,17 +194,22 @@ namespace AzToolsFramework
* @param entities A vector of entities that will be used in the new instance. May be empty
* @param instances A vector of Prefab Instances that will be nested in the new instance, will be consumed and moved.
* May be empty
* @param filePath the path to associate the template of the new instance to
* @param filePath the path to associate the template of the new instance to.
* @param containerEntity The container entity for the prefab to be created. It will be created if a nullptr is provided.
* @param shouldCreateLinks The flag indicating if links should be created between the templates of the instance
* and its nested instances.
* @return A pointer to the newly created instance. nullptr on failure
*/
AZStd::unique_ptr<Instance> CreatePrefab(const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume,
AZ::IO::PathView filePath, AZStd::unique_ptr<AZ::Entity> containerEntity = nullptr) override;
AZStd::unique_ptr<Instance> CreatePrefab(
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume,
AZ::IO::PathView filePath, AZStd::unique_ptr<AZ::Entity> containerEntity = nullptr,
bool ShouldCreateLinks = true) override;
PrefabDom& FindTemplateDom(TemplateId templateId) override;
/**
* Updates a template with the given updated DOM.
*
*
* @param templateId The id of the template to update.
* @param updatedDom The DOM to update the template with.
*/
@@ -260,9 +272,11 @@ namespace AzToolsFramework
/**
* Takes a prefab instance and generates a new Prefab Template
* along with any new Prefab Links representing any of the nested instances present
* @param instance The instance used to generate the new Template
* @param instance The instance used to generate the new Template.
* @param shouldCreateLinks The flag indicating if links should be created between the templates of the instance
* and its nested instances.
*/
TemplateId CreateTemplateFromInstance(Instance& instance);
TemplateId CreateTemplateFromInstance(Instance& instance, bool shouldCreateLinks);
/**
* Connect two templates with given link, and a nested instance value iterator
@@ -58,10 +58,11 @@ namespace AzToolsFramework
virtual void UpdatePrefabTemplate(TemplateId templateId, const PrefabDom& updatedDom) = 0;
virtual void PropagateTemplateChanges(TemplateId templateId) = 0;
virtual AZStd::unique_ptr<Instance> InstantiatePrefab(AZ::IO::PathView filePath) = 0;
virtual AZStd::unique_ptr<Instance> InstantiatePrefab(const TemplateId& templateId) = 0;
virtual AZStd::unique_ptr<Instance> CreatePrefab(const AZStd::vector<AZ::Entity*>& entities,
AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume, AZ::IO::PathView filePath,
AZStd::unique_ptr<AZ::Entity> containerEntity = nullptr) = 0;
AZStd::unique_ptr<AZ::Entity> containerEntity = nullptr, bool ShouldCreateLinks = true) = 0;
};
@@ -33,7 +33,7 @@ namespace AzToolsFramework
state->Redo();
}
void CreateLink(
LinkId CreateLink(
TemplateId sourceTemplateId, TemplateId targetTemplateId, PrefabDomReference patch,
const InstanceAlias& instanceAlias, UndoSystem::URSequencePoint* undoBatch)
{
@@ -41,6 +41,8 @@ namespace AzToolsFramework
linkAddUndo->Capture(targetTemplateId, sourceTemplateId, instanceAlias, patch, InvalidLinkId);
linkAddUndo->SetParent(undoBatch);
linkAddUndo->Redo();
return linkAddUndo->GetLinkId();
}
void RemoveLink(
@@ -21,7 +21,7 @@ namespace AzToolsFramework
void UpdatePrefabInstance(
const Instance& instance, AZStd::string_view undoMessage, const PrefabDom& instanceDomBeforeUpdate,
UndoSystem::URSequencePoint* undoBatch);
void CreateLink(
LinkId CreateLink(
TemplateId sourceTemplateId, TemplateId targetTemplateId, PrefabDomReference patch,
const InstanceAlias& instanceAlias, UndoSystem::URSequencePoint* undoBatch);
void RemoveLink(
@@ -34,4 +34,4 @@ namespace AzToolsFramework
} // namespace AzToolsFramework::Components
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -74,4 +74,4 @@ namespace AzToolsFramework
}
} // namespace Internal
} // namespace SQLite
} // namespace AZFramework
} // namespace AZFramework
@@ -116,4 +116,4 @@ namespace AzToolsFramework
}
}
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -95,4 +95,4 @@ namespace AzToolsFramework
AZ::DataPatch::FlagsMap m_previousDataFlagsMap;
AZ::DataPatch::FlagsMap m_nextDataFlagsMap;
};
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -70,4 +70,4 @@ namespace AzToolsFramework
};
using SliceDependencyBrowserNotificationsBus = AZ::EBus<SliceDependencyBrowserNotifications>;
}
}
@@ -131,4 +131,4 @@ namespace AzToolsFramework
*/
bool GetSliceDependendentsByRelativeAssetPath(const AZStd::string& relativePath, AZStd::vector<AZStd::string>& dependents) const;
};
}
}
@@ -100,4 +100,4 @@ namespace AzToolsFramework
SliceRelationshipNodeSet m_dependents;
SliceRelationshipNodeSet m_dependencies;
};
}
}
@@ -71,20 +71,12 @@ namespace AzToolsFramework
SharedThumbnail thumbnail;
ThumbnailerRequestsBus::BroadcastResult(thumbnail, &ThumbnailerRequests::GetThumbnail, m_key, m_contextName.c_str());
QPainter painter(this);
QPixmap pixmap = thumbnail->GetPixmap();
// preserve thumbnail image's ratio, if the widget is wider than the image, center the image hotizontally
float aspectRatio = aznumeric_cast<float>(pixmap.width()) / pixmap.height();
int originalWidth = width();
int originalHeight = height();
int realHeight = qMin(aznumeric_cast<int>(originalWidth /aspectRatio), originalHeight);
int realWidth = aznumeric_cast<int>(realHeight * aspectRatio);
int x = (originalWidth - realWidth) / 2;
// pixmap needs to be manually scaled to produce smoother result and avoid looking pixelated
// using painter.setRenderHint(QPainter::SmoothPixmapTransform); does not seem to work
// Note: there is a potential issue with pixmap.scaled:
// it is multithreaded (using global threadPool) and blocking until finished.
// A deadlock will happen if global threadPool has no free threads available.
painter.drawPixmap(QPoint(x, 0), pixmap.scaled(realWidth, realHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
// Scaling and centering pixmap within bounds to preserve aspect ratio
const QPixmap pixmap = thumbnail->GetPixmap().scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
const QSize sizeDelta = size() - pixmap.size();
const QPoint pointDelta = QPoint(sizeDelta.width() / 2, sizeDelta.height() / 2);
painter.drawPixmap(pointDelta, pixmap);
}
QWidget::paintEvent(event);
}
@@ -37,4 +37,4 @@ namespace AzToolsFramework
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
};
} // AzToolsFramework
} // AzToolsFramework
@@ -189,4 +189,4 @@ namespace AzToolsFramework
QClipboard* clipboard = QApplication::clipboard();
clipboard->setMimeData(mimeData.release());
}
}
}
@@ -69,4 +69,4 @@ namespace AzToolsFramework
private:
ComponentDataContainer m_components;
};
}
}
@@ -28,4 +28,4 @@ namespace AzToolsFramework
->Field("CurrentAssetID", &AssetReferenceBase::m_currentID);
}
}
}
}
@@ -43,4 +43,4 @@ namespace AzToolsFramework
};
}
#endif
#endif
@@ -26,4 +26,4 @@ namespace AzToolsFramework
};
using EditorDisabledCompositionRequestBus = AZ::EBus<EditorDisabledCompositionRequests>;
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -112,4 +112,4 @@ namespace AzToolsFramework
EditorComponentBase::Deactivate();
}
} // namespace Components
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -49,4 +49,4 @@ namespace AzToolsFramework
AZStd::vector<AZ::Component*> m_disabledComponents;
};
} // namespace Components
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -71,4 +71,4 @@ namespace AzToolsFramework
};
using EditorEntityIconComponentNotificationBus = AZ::EBus<EditorEntityIconComponentNotifications>;
}
}
@@ -103,4 +103,4 @@ namespace AzToolsFramework
bool m_componentOrderIsDirty = true; ///< This flag indicates our stored serialization order data is out of date and must be rebuilt before serialization occurs
};
} // namespace Components
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -50,4 +50,4 @@ namespace AzToolsFramework
};
using EditorInspectorComponentNotificationBus = AZ::EBus<EditorInspectorComponentNotifications>;
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -26,4 +26,4 @@ namespace AzToolsFramework
};
using EditorPendingCompositionRequestBus = AZ::EBus<EditorPendingCompositionRequests>;
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -125,4 +125,4 @@ namespace AzToolsFramework
EditorComponentBase::Deactivate();
}
} // namespace Components
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -49,4 +49,4 @@ namespace AzToolsFramework
AZStd::vector<AZ::Component*> m_pendingComponents;
};
} // namespace Components
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -40,4 +40,4 @@ namespace AzToolsFramework
using EditorSelectionAccentingRequestBus = AZ::EBus<EditorSelectionAccentingRequests>;
} // namespace Components
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -74,4 +74,4 @@ namespace AzToolsFramework
}
} // namespace AzToolsFramework
#endif
#endif
@@ -69,4 +69,4 @@ namespace AzToolsFramework
}
} // namespace AzToolsFramework
#endif
#endif
@@ -23,4 +23,4 @@ namespace AzToolsFramework
bool GetFreeDiskSpace(const QString& path, qint64& outFreeDiskSpace);
}
}
}
@@ -48,4 +48,4 @@ namespace AzToolsFramework
return outFreeDiskSpace >= 0;
}
}
}
}
@@ -32,4 +32,4 @@ namespace AzToolsFramework
};
}
#endif // EDITOR_ENTITY_ID_LIST_CONTAINER_H
#endif // EDITOR_ENTITY_ID_LIST_CONTAINER_H
@@ -35,4 +35,4 @@ namespace AzToolsFramework
}
}
#include "UI/ComponentPalette/moc_ComponentPaletteModel.cpp"
#include "UI/ComponentPalette/moc_ComponentPaletteModel.cpp"
@@ -55,4 +55,4 @@ namespace AzToolsFramework
}
}
#include "UI/ComponentPalette/moc_ComponentPaletteModelFilter.cpp"
#include "UI/ComponentPalette/moc_ComponentPaletteModelFilter.cpp"
@@ -24,4 +24,4 @@ namespace AzToolsFramework
QMenu* parentMenu,
const AzToolsFramework::EntityIdSet& entitySelectionWithFlatHierarchy,
NewLayerFunction newLayerFunction);
}
}
@@ -51,4 +51,4 @@ namespace LegacyFramework
};
}
#endif
#endif
@@ -62,4 +62,4 @@ namespace AzToolsFramework
->Field("m_serializableWindowState", &MainWindowSavedState::m_serializableWindowState);
}
}
}
}
@@ -53,4 +53,4 @@ namespace AzToolsFramework
};
}
#endif
#endif
@@ -94,4 +94,4 @@ namespace AzToolsFramework
return dlg.m_result;
}
}
}
@@ -92,4 +92,4 @@ namespace AzToolsFramework
} // Logging
} // AzToolsFramework
#endif
#endif
@@ -104,4 +104,4 @@ namespace AzToolsFramework
}
}
Q_DECLARE_METATYPE(const AzToolsFramework::Logging::LogLine*);
Q_DECLARE_METATYPE(const AzToolsFramework::Logging::LogLine*);
@@ -115,4 +115,4 @@ namespace AzToolsFramework
} // namespace Logging
} // namespace AzToolsFramework
#include "UI/Logging/moc_LogTableItemDelegate.cpp"
#include "UI/Logging/moc_LogTableItemDelegate.cpp"
@@ -316,4 +316,4 @@ namespace AzToolsFramework
}
} // namespace AzToolsFramework
#include "UI/Logging/moc_LogTableModel.cpp"
#include "UI/Logging/moc_LogTableModel.cpp"
@@ -29,4 +29,4 @@ namespace AzToolsFramework
}
}
#endif
#endif
@@ -56,4 +56,4 @@ namespace AzToolsFramework
} // namespace LogPanel
} // namespace AzToolsFramework
#endif
#endif
@@ -102,4 +102,4 @@ namespace AzToolsFramework
virtual void Clear();
};
} // namespace LogPanel
} // namespace AzToolsFramework
} // namespace AzToolsFramework
@@ -118,4 +118,4 @@ namespace AzToolsFramework
}
}
#include "UI/PropertyEditor/moc_ComponentEditorHeader.cpp"
#include "UI/PropertyEditor/moc_ComponentEditorHeader.cpp"
@@ -58,4 +58,4 @@ namespace AzToolsFramework
slider->setFocusPolicy(Qt::StrongFocus);
slider->setFocusProxy(spinbox);
}
}
}
@@ -43,4 +43,4 @@ namespace AzToolsFramework
void InitializeSliderPropertyWidgets(QSlider*, QAbstractSpinBox*);
}
#endif
#endif
@@ -98,4 +98,4 @@ namespace AzToolsFramework
}
}
#include "UI/PropertyEditor/moc_EntityIdQLabel.cpp"
#include "UI/PropertyEditor/moc_EntityIdQLabel.cpp"
@@ -86,4 +86,4 @@ namespace AzToolsFramework
}
}
#include "UI/PropertyEditor/moc_GrowTextEdit.cpp"
#include "UI/PropertyEditor/moc_GrowTextEdit.cpp"
@@ -53,4 +53,4 @@ namespace AzToolsFramework
};
void RegisterMultiLineEditHandler();
}
}
@@ -347,4 +347,4 @@ namespace AzToolsFramework
}
} // namespace AzToolsFramework
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More