Merging latest development
Signed-off-by: kberg-amzn <karlberg@amazon.com>
This commit is contained in:
@@ -226,9 +226,9 @@ class TestMaterialEditor(object):
|
||||
self, request, workspace, project, launcher_platform, generic_launcher, exe_file_name, cfg_args):
|
||||
"""
|
||||
Tests each valid RHI option (Null RHI excluded) can be launched with the MaterialEditor.
|
||||
Checks for the "Finished loading viewport configurtions." success message post lounch.
|
||||
Checks for the "Finished loading viewport configurations." success message post launch.
|
||||
"""
|
||||
expected_lines = ["Finished loading viewport configurtions."]
|
||||
expected_lines = ["Finished loading viewport configurations."]
|
||||
unexpected_lines = [
|
||||
# "Trace::Assert",
|
||||
# "Trace::Error",
|
||||
@@ -241,7 +241,7 @@ class TestMaterialEditor(object):
|
||||
generic_launcher,
|
||||
editor_script="",
|
||||
run_python="--runpython",
|
||||
timeout=30,
|
||||
timeout=60,
|
||||
expected_lines=expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
halt_on_unexpected=False,
|
||||
|
||||
@@ -25,28 +25,39 @@ import prefab.Prefab_Test_Utils as prefab_test_utils
|
||||
# This is a helper class which contains some of the useful information about a prefab instance.
|
||||
class PrefabInstance:
|
||||
|
||||
def __init__(self, name: str=None, prefab_file_name: str=None, container_entity: EditorEntity=EntityId()):
|
||||
self.name = name
|
||||
def __init__(self, prefab_file_name: str=None, container_entity: EditorEntity=EntityId()):
|
||||
self.prefab_file_name: str = prefab_file_name
|
||||
self.container_entity: EditorEntity = container_entity
|
||||
|
||||
def __eq__(self, other):
|
||||
return other and self.container_entity.id == other.container_entity.id
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.container_entity.id)
|
||||
|
||||
"""
|
||||
See if this instance is valid to be used with other prefab operations.
|
||||
:return: Whether the target instance is valid or not.
|
||||
"""
|
||||
def is_valid() -> bool:
|
||||
return self.container_entity.id.IsValid() and self.name is not None and self.prefab_file_name in Prefab.existing_prefabs
|
||||
return self.container_entity.id.IsValid() and self.prefab_file_name in Prefab.existing_prefabs
|
||||
|
||||
|
||||
"""
|
||||
Reparent this instance to target parent entity.
|
||||
The function will also check pop up dialog ui in editor to see if there's prefab cyclical dependency error while reparenting prefabs.
|
||||
:param parent_entity_id: The id of the entity this instance should be a child of in the transform hierarchy next.
|
||||
"""
|
||||
async def ui_reparent_prefab_instance(self, parent_entity_id: EntityId):
|
||||
container_entity_name = self.container_entity.get_name()
|
||||
current_children_entity_ids_having_prefab_name = prefab_test_utils.get_children_ids_by_name(parent_entity_id, container_entity_name)
|
||||
Report.info(f'current_children_entity_ids_having_prefab_name: {current_children_entity_ids_having_prefab_name}')
|
||||
container_entity_id_before_reparent = self.container_entity.id
|
||||
|
||||
original_parent = EditorEntity(self.container_entity.get_parent_id())
|
||||
original_parent_before_reparent_children_ids = set(original_parent.get_children_ids())
|
||||
|
||||
new_parent = EditorEntity(parent_entity_id)
|
||||
new_parent_before_reparent_children_ids = set(new_parent.get_children_ids())
|
||||
|
||||
pyside_utils.run_soon(lambda: self.container_entity.set_parent_entity(parent_entity_id))
|
||||
pyside_utils.run_soon(lambda: prefab_test_utils.wait_for_propagation())
|
||||
@@ -60,18 +71,23 @@ class PrefabInstance:
|
||||
except pyside_utils.EventLoopTimeoutException:
|
||||
pass
|
||||
|
||||
updated_children_entity_ids_having_prefab_name = prefab_test_utils.get_children_ids_by_name(parent_entity_id, container_entity_name)
|
||||
Report.info(f'updated_children_entity_ids_having_prefab_name: {updated_children_entity_ids_having_prefab_name}')
|
||||
new_child_with_reparented_prefab_name_added = len(updated_children_entity_ids_having_prefab_name) == len(current_children_entity_ids_having_prefab_name) + 1
|
||||
assert new_child_with_reparented_prefab_name_added, "No entity with reparented prefab name become a child of target parent entity"
|
||||
original_parent_after_reparent_children_ids = set(original_parent.get_children_ids())
|
||||
assert len(original_parent_after_reparent_children_ids) == len(original_parent_before_reparent_children_ids) - 1, \
|
||||
"The children count of the Prefab Instance's original parent should be decreased by 1."
|
||||
assert not container_entity_id_before_reparent in original_parent_after_reparent_children_ids, \
|
||||
"This Prefab Instance is still a child entity of its original parent entity."
|
||||
|
||||
new_parent_after_reparent_children_ids = set(new_parent.get_children_ids())
|
||||
assert len(new_parent_after_reparent_children_ids) == len(new_parent_before_reparent_children_ids) + 1, \
|
||||
"The children count of the Prefab Instance's new parent should be increased by 1."
|
||||
|
||||
updated_container_entity_id = set(updated_children_entity_ids_having_prefab_name).difference(current_children_entity_ids_having_prefab_name).pop()
|
||||
updated_container_entity = EditorEntity(updated_container_entity_id)
|
||||
updated_container_entity_parent_id = updated_container_entity.get_parent_id()
|
||||
has_correct_parent = updated_container_entity_parent_id.ToString() == parent_entity_id.ToString()
|
||||
assert has_correct_parent, "Prefab reparented is *not* under the expected parent entity"
|
||||
container_entity_id_after_reparent = set(new_parent_after_reparent_children_ids).difference(new_parent_before_reparent_children_ids).pop()
|
||||
reparented_container_entity = EditorEntity(container_entity_id_after_reparent)
|
||||
reparented_container_entity_parent_id = reparented_container_entity.get_parent_id()
|
||||
has_correct_parent = reparented_container_entity_parent_id.ToString() == parent_entity_id.ToString()
|
||||
assert has_correct_parent, "Prefab Instance reparented is *not* under the expected parent entity"
|
||||
|
||||
self.container_entity = EditorEntity(updated_container_entity_id)
|
||||
self.container_entity = reparented_container_entity
|
||||
|
||||
# This is a helper class which contains some of the useful information about a prefab template.
|
||||
class Prefab:
|
||||
@@ -81,7 +97,7 @@ class Prefab:
|
||||
def __init__(self, file_name: str):
|
||||
self.file_name:str = file_name
|
||||
self.file_path: str = prefab_test_utils.get_prefab_file_path(file_name)
|
||||
self.instances: dict = {}
|
||||
self.instances: set[PrefabInstance] = set()
|
||||
|
||||
"""
|
||||
Check if a prefab is ready to be used to generate its instances.
|
||||
@@ -122,10 +138,10 @@ class Prefab:
|
||||
:param entities: The entities that should form the new prefab (along with their descendants).
|
||||
:param file_name: A unique file name of new prefab.
|
||||
:param prefab_instance_name: A name for the very first instance generated while prefab creation. The default instance name is the same as file_name.
|
||||
:return: An outcome object with an entityId of the new prefab's container entity; on failure, it comes with an error message detailing the cause of the error.
|
||||
:return: Created Prefab object and the very first PrefabInstance object owned by the prefab.
|
||||
"""
|
||||
@classmethod
|
||||
def create_prefab(cls, entities: list[EditorEntity], file_name: str, prefab_instance_name: str=None) -> Prefab:
|
||||
def create_prefab(cls, entities: list[EditorEntity], file_name: str, prefab_instance_name: str=None) -> (Prefab, PrefabInstance):
|
||||
assert not Prefab.is_prefab_loaded(file_name), f"Can't create Prefab '{file_name}' since the prefab already exists"
|
||||
|
||||
new_prefab = Prefab(file_name)
|
||||
@@ -133,18 +149,18 @@ class Prefab:
|
||||
create_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'CreatePrefabInMemory', entity_ids, new_prefab.file_path)
|
||||
assert create_prefab_result.IsSuccess(), f"Prefab operation 'CreatePrefab' failed. Error: {create_prefab_result.GetError()}"
|
||||
|
||||
container_entity = EditorEntity(create_prefab_result.GetValue())
|
||||
container_entity_id = create_prefab_result.GetValue()
|
||||
container_entity = EditorEntity(container_entity_id)
|
||||
|
||||
if prefab_instance_name:
|
||||
container_entity.set_name(prefab_instance_name)
|
||||
else:
|
||||
prefab_instance_name = file_name
|
||||
|
||||
prefab_test_utils.wait_for_propagation()
|
||||
container_entity_id = prefab_test_utils.find_entity_by_unique_name(prefab_instance_name)
|
||||
new_prefab.instances[prefab_instance_name] = PrefabInstance(prefab_instance_name, file_name, EditorEntity(container_entity_id))
|
||||
|
||||
new_prefab_instance = PrefabInstance(file_name, EditorEntity(container_entity_id))
|
||||
new_prefab.instances.add(new_prefab_instance)
|
||||
Prefab.existing_prefabs[file_name] = new_prefab
|
||||
return new_prefab
|
||||
return new_prefab, new_prefab_instance
|
||||
|
||||
"""
|
||||
Remove target prefab instances.
|
||||
@@ -152,22 +168,15 @@ class Prefab:
|
||||
"""
|
||||
@classmethod
|
||||
def remove_prefabs(cls, prefab_instances: list[PrefabInstance]):
|
||||
instances_to_remove_name_counts = Counter()
|
||||
instances_removed_expected_name_counts = Counter()
|
||||
|
||||
entities_to_remove = [prefab_instance.container_entity for prefab_instance in prefab_instances]
|
||||
while entities_to_remove:
|
||||
entity = entities_to_remove.pop(-1)
|
||||
entity_name = entity.get_name()
|
||||
instances_to_remove_name_counts[entity_name] += 1
|
||||
|
||||
entity_ids_to_remove = []
|
||||
entity_id_queue = [prefab_instance.container_entity for prefab_instance in prefab_instances]
|
||||
while entity_id_queue:
|
||||
entity = entity_id_queue.pop(0)
|
||||
children_entity_ids = entity.get_children_ids()
|
||||
for child_entity_id in children_entity_ids:
|
||||
entities_to_remove.append(EditorEntity(child_entity_id))
|
||||
entity_id_queue.append(EditorEntity(child_entity_id))
|
||||
|
||||
for entity_name, entity_count in instances_to_remove_name_counts.items():
|
||||
entities = prefab_test_utils.find_entities_by_name(entity_name)
|
||||
instances_removed_expected_name_counts[entity_name] = len(entities) - entity_count
|
||||
entity_ids_to_remove.append(entity.id)
|
||||
|
||||
container_entity_ids = [prefab_instance.container_entity.id for prefab_instance in prefab_instances]
|
||||
delete_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'DeleteEntitiesAndAllDescendantsInInstance', container_entity_ids)
|
||||
@@ -175,28 +184,24 @@ class Prefab:
|
||||
|
||||
prefab_test_utils.wait_for_propagation()
|
||||
|
||||
prefab_entities_deleted = True
|
||||
for entity_name, expected_entity_count in instances_removed_expected_name_counts.items():
|
||||
actual_entity_count = len(prefab_test_utils.find_entities_by_name(entity_name))
|
||||
if actual_entity_count is not expected_entity_count:
|
||||
prefab_entities_deleted = False
|
||||
break
|
||||
|
||||
assert prefab_entities_deleted, "Not all entities and descendants in target prefabs are deleted."
|
||||
entity_ids_after_delete = set(prefab_test_utils.get_all_entities())
|
||||
for entity_id_removed in entity_ids_to_remove:
|
||||
if entity_id_removed in entity_ids_after_delete:
|
||||
assert prefab_entities_deleted, "Not all entities and descendants in target prefabs are deleted."
|
||||
|
||||
for instance in prefab_instances:
|
||||
instance_deleted_prefab = Prefab.get_prefab(instance.prefab_file_name)
|
||||
instance_deleted_prefab.instances.pop(instance.name)
|
||||
instance_deleted_prefab.instances.remove(instance)
|
||||
instance = PrefabInstance()
|
||||
|
||||
"""
|
||||
Instantiate an instance of this prefab.
|
||||
:param name: A name for newly instantiated prefab instance. The default instance name is the same as this prefab's file name.
|
||||
:param parent_entity: The entity the prefab should be a child of in the transform hierarchy.
|
||||
:param name: A name for newly instantiated prefab instance. The default instance name is the same as this prefab's file name.
|
||||
:param prefab_position: The position in world space the prefab should be instantiated in.
|
||||
:return: An outcome object with an entityId of the new prefab's container entity; on failure, it comes with an error message detailing the cause of the error.
|
||||
:return: Instantiated PrefabInstance object owned by this prefab.
|
||||
"""
|
||||
def instantiate(self, name: str=None, parent_entity: EditorEntity=None, prefab_position: Vector3=Vector3()) -> PrefabInstance:
|
||||
def instantiate(self, parent_entity: EditorEntity=None, name: str=None, prefab_position: Vector3=Vector3()) -> PrefabInstance:
|
||||
parent_entity_id = parent_entity.id if parent_entity is not None else EntityId()
|
||||
|
||||
instantiate_prefab_result = prefab.PrefabPublicRequestBus(
|
||||
@@ -209,13 +214,13 @@ class Prefab:
|
||||
|
||||
if name:
|
||||
container_entity.set_name(name)
|
||||
else:
|
||||
name = self.file_name
|
||||
|
||||
prefab_test_utils.wait_for_propagation()
|
||||
container_entity_id = prefab_test_utils.find_entity_by_unique_name(name)
|
||||
self.instances[name] = PrefabInstance(name, self.file_name, EditorEntity(container_entity_id))
|
||||
|
||||
new_prefab_instance = PrefabInstance(self.file_name, EditorEntity(container_entity_id))
|
||||
assert not new_prefab_instance in self.instances, "This prefab instance is already existed before this instantiation."
|
||||
self.instances.add(new_prefab_instance)
|
||||
|
||||
prefab_test_utils.check_entity_at_position(container_entity_id, prefab_position)
|
||||
|
||||
return container_entity_id
|
||||
return new_prefab_instance
|
||||
|
||||
+1
-2
@@ -22,11 +22,10 @@ def Prefab_BasicWorkflow_CreateAndDeletePrefab():
|
||||
car_prefab_entities = [car_entity]
|
||||
|
||||
# Checks for prefab creation passed or not
|
||||
car_prefab = Prefab.create_prefab(
|
||||
_, car = Prefab.create_prefab(
|
||||
car_prefab_entities, CAR_PREFAB_FILE_NAME)
|
||||
|
||||
# Checks for prefab deletion passed or not
|
||||
car = car_prefab.instances[CAR_PREFAB_FILE_NAME]
|
||||
Prefab.remove_prefabs([car])
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+2
-4
@@ -28,7 +28,7 @@ def Prefab_BasicWorkflow_CreateAndReparentPrefab():
|
||||
car_prefab_entities = [car_entity]
|
||||
|
||||
# Checks for prefab creation passed or not
|
||||
car_prefab = Prefab.create_prefab(
|
||||
_, car = Prefab.create_prefab(
|
||||
car_prefab_entities, CAR_PREFAB_FILE_NAME)
|
||||
|
||||
# Creates another new Entity at the root level
|
||||
@@ -36,12 +36,10 @@ def Prefab_BasicWorkflow_CreateAndReparentPrefab():
|
||||
wheel_prefab_entities = [wheel_entity]
|
||||
|
||||
# Checks for wheel prefab creation passed or not
|
||||
wheel_prefab = Prefab.create_prefab(
|
||||
_, wheel = Prefab.create_prefab(
|
||||
wheel_prefab_entities, WHEEL_PREFAB_FILE_NAME)
|
||||
|
||||
# Checks for prefab reparenting passed or not
|
||||
car = car_prefab.instances[CAR_PREFAB_FILE_NAME]
|
||||
wheel = wheel_prefab.instances[WHEEL_PREFAB_FILE_NAME]
|
||||
await wheel.ui_reparent_prefab_instance(car.container_entity.id)
|
||||
|
||||
run_test()
|
||||
|
||||
@@ -22,11 +22,11 @@ def Prefab_BasicWorkflow_InstantiatePrefab():
|
||||
# Checks for prefab instantiation passed or not
|
||||
test_prefab = Prefab.get_prefab(EXISTING_TEST_PREFAB_FILE_NAME)
|
||||
|
||||
instantiated_test_container_entity_id = test_prefab.instantiate(
|
||||
test_instance = test_prefab.instantiate(
|
||||
prefab_position=INSTANTIATED_TEST_PREFAB_POSITION)
|
||||
|
||||
prefab_test_utils.check_entity_children_count(
|
||||
instantiated_test_container_entity_id,
|
||||
test_instance.container_entity.id,
|
||||
EXPECTED_TEST_PREFAB_CHILDREN_COUNT)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -29,20 +29,8 @@ def find_entities_by_name(entity_name):
|
||||
searchFilter.names = [entity_name]
|
||||
return entity.SearchBus(bus.Broadcast, 'SearchEntities', searchFilter)
|
||||
|
||||
def find_entity_by_unique_name(entity_name):
|
||||
unique_name_entity_found_result = (
|
||||
"Entity with a unique name found",
|
||||
"Entity with a unique name *not* found")
|
||||
|
||||
entities = find_entities_by_name(entity_name)
|
||||
unique_name_entity_found = len(entities) == 1
|
||||
Report.result(unique_name_entity_found_result, unique_name_entity_found)
|
||||
|
||||
if unique_name_entity_found:
|
||||
return entities[0]
|
||||
else:
|
||||
Report.info(f"{len(entities)} entities with name '{entity_name}' found")
|
||||
return EntityId()
|
||||
def get_all_entities():
|
||||
return entity.SearchBus(bus.Broadcast, 'SearchEntities', entity.SearchFilter())
|
||||
|
||||
def check_entity_at_position(entity_id, expected_entity_position):
|
||||
entity_at_expected_position_result = (
|
||||
|
||||
@@ -122,6 +122,7 @@ class TestAutomation(TestAutomationBase):
|
||||
from . import Debugger_HappyPath_TargetMultipleEntities as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
@pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.")
|
||||
def test_EditMenu_Default_UndoRedo(self, request, workspace, editor, launcher_platform, project):
|
||||
from . import EditMenu_Default_UndoRedo as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
@@ -181,6 +182,7 @@ class TestAutomation(TestAutomationBase):
|
||||
from . import NodePalette_SearchText_Deletion as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
@pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.")
|
||||
def test_VariableManager_UnpinVariableType_Works(self, request, workspace, editor, launcher_platform):
|
||||
from . import VariableManager_UnpinVariableType_Works as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
@@ -35,8 +35,6 @@ struct IDisplayViewport
|
||||
*/
|
||||
virtual float GetDistanceToLine(const Vec3& lineP1, const Vec3& lineP2, const QPoint& point) const = 0;
|
||||
|
||||
virtual CBaseObjectsCache* GetVisibleObjectsCache() = 0;
|
||||
|
||||
enum EAxis
|
||||
{
|
||||
AXIS_NONE,
|
||||
|
||||
@@ -33,10 +33,6 @@
|
||||
|
||||
AZ_CVAR_EXTERNED(bool, ed_visibility_logTiming);
|
||||
|
||||
AZ_CVAR(
|
||||
bool, ed_visibility_use, true, nullptr, AZ::ConsoleFunctorFlags::Null,
|
||||
"Enable/disable using the new IVisibilitySystem for Entity visibility determination");
|
||||
|
||||
/*!
|
||||
* Class Description used for object templates.
|
||||
* This description filled from Xml template files.
|
||||
@@ -76,17 +72,6 @@ public:
|
||||
int GameCreationOrder() override { return superType->GameCreationOrder(); };
|
||||
};
|
||||
|
||||
void CBaseObjectsCache::AddObject(CBaseObject* object)
|
||||
{
|
||||
m_objects.push_back(object);
|
||||
if (object->GetType() == OBJTYPE_AZENTITY)
|
||||
{
|
||||
auto componentEntityObject = static_cast<CComponentEntityObject*>(object);
|
||||
m_entityIds.push_back(componentEntityObject->GetAssociatedEntityId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CObjectManager implementation.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -1267,25 +1252,8 @@ void CObjectManager::Display(DisplayContext& dc)
|
||||
UpdateVisibilityList();
|
||||
}
|
||||
|
||||
bool viewIsDirty = dc.settings->IsDisplayHelpers(); // displaying helpers require computing all the bound boxes and things anyway.
|
||||
|
||||
if (!viewIsDirty)
|
||||
if (dc.settings->IsDisplayHelpers())
|
||||
{
|
||||
if (CBaseObjectsCache* cache = dc.view->GetVisibleObjectsCache())
|
||||
{
|
||||
// if the current rendering viewport has an out-of-date cache serial number, it needs to be refreshed too.
|
||||
// views set their cache empty when they indicate they need to force a refresh.
|
||||
if ((cache->GetObjectCount() == 0) || (cache->GetSerialNumber() != m_visibilitySerialNumber))
|
||||
{
|
||||
viewIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (viewIsDirty)
|
||||
{
|
||||
FindDisplayableObjects(dc, true); // this also actually draws the helpers.
|
||||
|
||||
// Also broadcast for anyone else that needs to draw global debug to do so now
|
||||
AzFramework::DebugDisplayEventBus::Broadcast(&AzFramework::DebugDisplayEvents::DrawGlobalDebugInfo);
|
||||
}
|
||||
@@ -1296,94 +1264,14 @@ void CObjectManager::Display(DisplayContext& dc)
|
||||
}
|
||||
}
|
||||
|
||||
void CObjectManager::ForceUpdateVisibleObjectCache(DisplayContext& dc)
|
||||
void CObjectManager::ForceUpdateVisibleObjectCache([[maybe_unused]] DisplayContext& dc)
|
||||
{
|
||||
FindDisplayableObjects(dc, false);
|
||||
AZ_Assert(false, "CObjectManager::ForceUpdateVisibleObjectCache is legacy/deprecated and should not be used.");
|
||||
}
|
||||
|
||||
void CObjectManager::FindDisplayableObjects(DisplayContext& dc, [[maybe_unused]] bool bDisplay)
|
||||
void CObjectManager::FindDisplayableObjects([[maybe_unused]] DisplayContext& dc, [[maybe_unused]] bool bDisplay)
|
||||
{
|
||||
// if the new IVisibilitySystem is being used, do not run this logic
|
||||
if (ed_visibility_use)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AZ_PROFILE_FUNCTION(Editor);
|
||||
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
CBaseObjectsCache* pDispayedViewObjects = dc.view->GetVisibleObjectsCache();
|
||||
if (!pDispayedViewObjects)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pDispayedViewObjects->SetSerialNumber(m_visibilitySerialNumber); // update viewport to be latest serial number
|
||||
|
||||
AABB bbox;
|
||||
bbox.min.zero();
|
||||
bbox.max.zero();
|
||||
|
||||
pDispayedViewObjects->ClearObjects();
|
||||
pDispayedViewObjects->Reserve(static_cast<int>(m_visibleObjects.size()));
|
||||
|
||||
if (dc.flags & DISPLAY_2D)
|
||||
{
|
||||
int numVis = static_cast<int>(m_visibleObjects.size());
|
||||
for (int i = 0; i < numVis; i++)
|
||||
{
|
||||
CBaseObject* obj = m_visibleObjects[i];
|
||||
|
||||
obj->GetBoundBox(bbox);
|
||||
if (dc.box.IsIntersectBox(bbox))
|
||||
{
|
||||
pDispayedViewObjects->AddObject(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CSelectionGroup* pSelection = GetSelection();
|
||||
if (pSelection && pSelection->GetCount() > 1)
|
||||
{
|
||||
AABB mergedAABB;
|
||||
mergedAABB.Reset();
|
||||
for (int i = 0, iCount(pSelection->GetCount()); i < iCount; ++i)
|
||||
{
|
||||
CBaseObject* pObj(pSelection->GetObject(i));
|
||||
if (pObj == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
AABB aabb;
|
||||
pObj->GetBoundBox(aabb);
|
||||
mergedAABB.Add(aabb);
|
||||
}
|
||||
|
||||
pSelection->GetObject(0)->CBaseObject::DrawDimensions(dc, &mergedAABB);
|
||||
}
|
||||
|
||||
int numVis = static_cast<int>(m_visibleObjects.size());
|
||||
for (int i = 0; i < numVis; i++)
|
||||
{
|
||||
CBaseObject* obj = m_visibleObjects[i];
|
||||
|
||||
if (obj)
|
||||
{
|
||||
if ((dc.flags & DISPLAY_SELECTION_HELPERS) || obj->IsSelected())
|
||||
{
|
||||
pDispayedViewObjects->AddObject(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ed_visibility_logTiming && !ed_visibility_use)
|
||||
{
|
||||
auto stop = std::chrono::steady_clock::now();
|
||||
std::chrono::duration<double> diff = stop - start;
|
||||
AZ_Printf("Visibility", "FindDisplayableObjects (old) - Duration: %f", diff);
|
||||
}
|
||||
AZ_Assert(false, "CObjectManager::FindDisplayableObjects is legacy/deprecated and should not be used.");
|
||||
}
|
||||
|
||||
void CObjectManager::BeginEditParams(CBaseObject* obj, int flags)
|
||||
@@ -1630,214 +1518,24 @@ bool CObjectManager::HitTestObject(CBaseObject* obj, HitContext& hc)
|
||||
return (bSelectionHelperHit || obj->HitTest(hc));
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CObjectManager::HitTest(HitContext& hitInfo)
|
||||
bool CObjectManager::HitTest([[maybe_unused]] HitContext& hitInfo)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(Editor);
|
||||
|
||||
hitInfo.object = nullptr;
|
||||
hitInfo.dist = FLT_MAX;
|
||||
hitInfo.axis = 0;
|
||||
hitInfo.manipulatorMode = 0;
|
||||
|
||||
HitContext hcOrg = hitInfo;
|
||||
if (hcOrg.view)
|
||||
{
|
||||
hcOrg.view->GetPerpendicularAxis(nullptr, &hcOrg.b2DViewport);
|
||||
}
|
||||
hcOrg.rayDir = hcOrg.rayDir.GetNormalized();
|
||||
|
||||
HitContext hc = hcOrg;
|
||||
|
||||
float mindist = FLT_MAX;
|
||||
|
||||
if (!hitInfo.bIgnoreAxis && !hc.bUseSelectionHelpers)
|
||||
{
|
||||
// Test gizmos.
|
||||
if (m_gizmoManager->HitTest(hc))
|
||||
{
|
||||
if (hc.axis != 0)
|
||||
{
|
||||
hitInfo.object = hc.object;
|
||||
hitInfo.gizmo = hc.gizmo;
|
||||
hitInfo.axis = hc.axis;
|
||||
hitInfo.manipulatorMode = hc.manipulatorMode;
|
||||
hitInfo.dist = hc.dist;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hitInfo.bOnlyGizmo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only HitTest objects, that where previously Displayed.
|
||||
CBaseObjectsCache* pDispayedViewObjects = hitInfo.view->GetVisibleObjectsCache();
|
||||
|
||||
const bool iconsPrioritized = true; // Force icons to always be prioritized over other things you hit. Can change to be a configurable option in the future.
|
||||
|
||||
CBaseObject* selected = nullptr;
|
||||
const char* name = nullptr;
|
||||
bool iconHit = false;
|
||||
int numVis = pDispayedViewObjects->GetObjectCount();
|
||||
for (int i = 0; i < numVis; i++)
|
||||
{
|
||||
CBaseObject* obj = pDispayedViewObjects->GetObject(i);
|
||||
|
||||
if (obj == hitInfo.pExcludedObject)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (HitTestObject(obj, hc))
|
||||
{
|
||||
if (m_selectCallback && !m_selectCallback->CanSelectObject(obj))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if this object is nearest.
|
||||
if (hc.axis != 0)
|
||||
{
|
||||
hitInfo.object = obj;
|
||||
hitInfo.axis = hc.axis;
|
||||
hitInfo.dist = hc.dist;
|
||||
return true;
|
||||
}
|
||||
|
||||
// When prioritizing icons, we don't allow non-icon hits to beat icon hits
|
||||
if (iconsPrioritized && iconHit && !hc.iconHit)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hc.dist < mindist || (!iconHit && hc.iconHit))
|
||||
{
|
||||
if (hc.iconHit)
|
||||
{
|
||||
iconHit = true;
|
||||
}
|
||||
|
||||
mindist = hc.dist;
|
||||
name = hc.name;
|
||||
selected = obj;
|
||||
}
|
||||
|
||||
// Clear the object pointer if an object was hit, not just if the collision
|
||||
// was closer than any previous. Not all paths from HitTestObject set the object pointer and so you could get
|
||||
// an object from a previous (rejected) result but with collision information about a closer hit.
|
||||
hc.object = nullptr;
|
||||
hc.iconHit = false;
|
||||
|
||||
// If use deep selection
|
||||
if (hitInfo.pDeepSelection)
|
||||
{
|
||||
hitInfo.pDeepSelection->AddObject(hc.dist, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selected)
|
||||
{
|
||||
hitInfo.object = selected;
|
||||
hitInfo.dist = mindist;
|
||||
hitInfo.name = name;
|
||||
hitInfo.iconHit = iconHit;
|
||||
return true;
|
||||
}
|
||||
AZ_Assert(false, "CObjectManager::HitTest is legacy/deprecated and should not be used.");
|
||||
return false;
|
||||
}
|
||||
void CObjectManager::FindObjectsInRect(CViewport* view, const QRect& rect, std::vector<GUID>& guids)
|
||||
|
||||
void CObjectManager::FindObjectsInRect(
|
||||
[[maybe_unused]] CViewport* view, [[maybe_unused]] const QRect& rect, [[maybe_unused]] std::vector<GUID>& guids)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(Editor);
|
||||
|
||||
if (rect.width() < 1 || rect.height() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HitContext hc;
|
||||
hc.view = view;
|
||||
hc.b2DViewport = view->GetType() != ET_ViewportCamera;
|
||||
hc.rect = rect;
|
||||
hc.bUseSelectionHelpers = view->GetAdvancedSelectModeFlag();
|
||||
|
||||
guids.clear();
|
||||
|
||||
CBaseObjectsCache* pDispayedViewObjects = view->GetVisibleObjectsCache();
|
||||
|
||||
int numVis = pDispayedViewObjects->GetObjectCount();
|
||||
for (int i = 0; i < numVis; ++i)
|
||||
{
|
||||
CBaseObject* pObj = pDispayedViewObjects->GetObject(i);
|
||||
|
||||
HitTestObjectAgainstRect(pObj, view, hc, guids);
|
||||
}
|
||||
AZ_Assert(false, "CObjectManager::FindObjectsInRect is legacy/deprecated and should not be used.");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectManager::SelectObjectsInRect(CViewport* view, const QRect& rect, bool bSelect)
|
||||
void CObjectManager::SelectObjectsInRect(
|
||||
[[maybe_unused]] CViewport* view, [[maybe_unused]] const QRect& rect, [[maybe_unused]] bool bSelect)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(Editor);
|
||||
|
||||
// Ignore too small rectangles.
|
||||
if (rect.width() < 1 || rect.height() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CUndo undo("Select Object(s)");
|
||||
|
||||
HitContext hc;
|
||||
hc.view = view;
|
||||
hc.b2DViewport = view->GetType() != ET_ViewportCamera;
|
||||
hc.rect = rect;
|
||||
hc.bUseSelectionHelpers = view->GetAdvancedSelectModeFlag();
|
||||
|
||||
bool isUndoRecording = GetIEditor()->IsUndoRecording();
|
||||
if (isUndoRecording)
|
||||
{
|
||||
m_processingBulkSelect = true;
|
||||
}
|
||||
|
||||
CBaseObjectsCache* displayedViewObjects = view->GetVisibleObjectsCache();
|
||||
int numVis = displayedViewObjects->GetObjectCount();
|
||||
|
||||
// Tracking the previous selection allows proper undo/redo functionality of additional
|
||||
// selections (CTRL + drag select)
|
||||
AZStd::unordered_set<const CBaseObject*> previousSelection;
|
||||
|
||||
for (int i = 0; i < numVis; ++i)
|
||||
{
|
||||
CBaseObject* object = displayedViewObjects->GetObject(i);
|
||||
|
||||
if (object->IsSelected())
|
||||
{
|
||||
previousSelection.insert(object);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This will update m_currSelection
|
||||
SelectObjectInRect(object, view, hc, bSelect);
|
||||
|
||||
// Legacy undo/redo does not go through the Ebus system and must be done individually
|
||||
if (isUndoRecording && object->GetType() != OBJTYPE_AZENTITY)
|
||||
{
|
||||
GetIEditor()->RecordUndo(new CUndoBaseObjectSelect(object, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isUndoRecording && m_currSelection)
|
||||
{
|
||||
// Component Entities can handle undo/redo in bulk due to Ebuses
|
||||
GetIEditor()->RecordUndo(new CUndoBaseObjectBulkSelect(previousSelection, *m_currSelection));
|
||||
}
|
||||
|
||||
m_processingBulkSelect = false;
|
||||
AZ_Assert(false, "CObjectManager::SelectObjectsInRect is legacy/deprecated and should not be used.");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -3011,6 +2709,4 @@ namespace AzToolsFramework
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -52,40 +52,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Array of editor objects.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CBaseObjectsCache
|
||||
{
|
||||
public:
|
||||
int GetObjectCount() const { return static_cast<int>(m_objects.size()); }
|
||||
CBaseObject* GetObject(int nIndex) const { return m_objects[nIndex]; }
|
||||
void AddObject(CBaseObject* object);
|
||||
|
||||
void ClearObjects()
|
||||
{
|
||||
m_objects.clear();
|
||||
m_entityIds.clear();
|
||||
}
|
||||
|
||||
void Reserve(int nCount)
|
||||
{
|
||||
m_objects.reserve(nCount);
|
||||
m_entityIds.reserve(nCount);
|
||||
}
|
||||
|
||||
const AZStd::vector<AZ::EntityId>& GetEntityIdCache() const { return m_entityIds; }
|
||||
|
||||
/// Checksum is used as a dirty flag.
|
||||
unsigned int GetSerialNumber() { return m_serialNumber; }
|
||||
void SetSerialNumber(unsigned int serialNumber) { m_serialNumber = serialNumber; }
|
||||
private:
|
||||
//! List of objects that was displayed at last frame.
|
||||
std::vector<_smart_ptr<CBaseObject> > m_objects;
|
||||
AZStd::vector<AZ::EntityId> m_entityIds;
|
||||
unsigned int m_serialNumber = 0;
|
||||
};
|
||||
|
||||
/*!
|
||||
* CObjectManager is a singleton object that
|
||||
* manages global set of objects in level.
|
||||
|
||||
@@ -173,8 +173,6 @@ QtViewport::QtViewport(QWidget* parent)
|
||||
|
||||
m_bAdvancedSelectMode = false;
|
||||
|
||||
m_pVisibleObjectsCache = new CBaseObjectsCache;
|
||||
|
||||
m_constructionPlane.SetPlane(Vec3_OneZ, Vec3_Zero);
|
||||
m_constructionPlaneAxisX = Vec3_Zero;
|
||||
m_constructionPlaneAxisY = Vec3_Zero;
|
||||
@@ -204,8 +202,6 @@ QtViewport::QtViewport(QWidget* parent)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QtViewport::~QtViewport()
|
||||
{
|
||||
delete m_pVisibleObjectsCache;
|
||||
|
||||
GetIEditor()->GetViewManager()->UnregisterViewport(this);
|
||||
}
|
||||
|
||||
@@ -376,11 +372,6 @@ void QtViewport::OnDeactivate()
|
||||
void QtViewport::ResetContent()
|
||||
{
|
||||
m_pMouseOverObject = nullptr;
|
||||
|
||||
// Need to clear visual object cache.
|
||||
// Right after loading new level, some code(e.g. OnMouseMove) access invalid
|
||||
// previous level object before cache updated.
|
||||
GetVisibleObjectsCache()->ClearObjects();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -398,11 +389,8 @@ void QtViewport::Update()
|
||||
m_viewportUi.Update();
|
||||
|
||||
m_bAdvancedSelectMode = false;
|
||||
bool bSpaceClick = false;
|
||||
{
|
||||
bSpaceClick = CheckVirtualKey(Qt::Key_Space) & !CheckVirtualKey(Qt::Key_Shift) /*& !CheckVirtualKey(Qt::Key_Control)*/;
|
||||
}
|
||||
if (bSpaceClick && hasFocus())
|
||||
|
||||
if (CheckVirtualKey(Qt::Key_Space) && !CheckVirtualKey(Qt::Key_Shift) && hasFocus())
|
||||
{
|
||||
m_bAdvancedSelectMode = true;
|
||||
}
|
||||
|
||||
@@ -491,10 +491,6 @@ public:
|
||||
void ResetCursor() override;
|
||||
void SetSupplementaryCursorStr(const QString& str) override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Return visble objects cache.
|
||||
CBaseObjectsCache* GetVisibleObjectsCache() override { return m_pVisibleObjectsCache; };
|
||||
|
||||
void RegisterRenderListener(IRenderListener* piListener) override;
|
||||
bool UnregisterRenderListener(IRenderListener* piListener) override;
|
||||
bool IsRenderListenerRegistered(IRenderListener* piListener) override;
|
||||
@@ -612,8 +608,6 @@ protected:
|
||||
int m_nLastUpdateFrame;
|
||||
int m_nLastMouseMoveFrame;
|
||||
|
||||
CBaseObjectsCache* m_pVisibleObjectsCache;
|
||||
|
||||
QRect m_rcClient;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
@@ -551,8 +551,6 @@ namespace AZ
|
||||
{
|
||||
PrepareShutDown();
|
||||
|
||||
DispatchEvents();
|
||||
|
||||
// Acquire the asset lock to make sure nobody else is trying to do anything fancy with assets
|
||||
AZStd::scoped_lock<AZStd::recursive_mutex> assetLock(m_assetMutex);
|
||||
|
||||
@@ -575,7 +573,10 @@ namespace AZ
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AzCore);
|
||||
AssetManagerNotificationBus::Broadcast(&AssetManagerNotificationBus::Events::OnAssetEventsDispatchBegin);
|
||||
AssetBus::ExecuteQueuedEvents();
|
||||
while (AssetBus::QueuedEventCount())
|
||||
{
|
||||
AssetBus::ExecuteQueuedEvents();
|
||||
}
|
||||
AssetManagerNotificationBus::Broadcast(&AssetManagerNotificationBus::Events::OnAssetEventsDispatchEnd);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <AzCore/Console/LoggerSystemComponent.h>
|
||||
#include <AzCore/EBus/EventSchedulerSystemComponent.h>
|
||||
#include <AzCore/Task/TaskGraphSystemComponent.h>
|
||||
#include <AzCore/Statistics/StatisticalProfilerProxySystemComponent.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -44,6 +45,10 @@ namespace AZ
|
||||
EventSchedulerSystemComponent::CreateDescriptor(),
|
||||
TaskGraphSystemComponent::CreateDescriptor(),
|
||||
|
||||
#if !defined(_RELEASE)
|
||||
Statistics::StatisticalProfilerProxySystemComponent::CreateDescriptor(),
|
||||
#endif
|
||||
|
||||
#if !defined(AZCORE_EXCLUDE_LUA)
|
||||
ScriptSystemComponent::CreateDescriptor(),
|
||||
#endif // #if !defined(AZCORE_EXCLUDE_LUA)
|
||||
@@ -58,6 +63,10 @@ namespace AZ
|
||||
azrtti_typeid<LoggerSystemComponent>(),
|
||||
azrtti_typeid<EventSchedulerSystemComponent>(),
|
||||
azrtti_typeid<TaskGraphSystemComponent>(),
|
||||
|
||||
#if !defined(_RELEASE)
|
||||
azrtti_typeid<Statistics::StatisticalProfilerProxySystemComponent>(),
|
||||
#endif
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <AzCore/Module/Environment.h>
|
||||
#include <AzCore/Math/Crc.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Statistics/StatisticalProfilerProxy.h>
|
||||
|
||||
AZ_DEFINE_BUDGET(Animation);
|
||||
AZ_DEFINE_BUDGET(Audio);
|
||||
@@ -30,8 +31,7 @@ namespace AZ::Debug
|
||||
};
|
||||
|
||||
Budget::Budget(const char* name)
|
||||
: m_name{ name }
|
||||
, m_crc{ Crc32(name) }
|
||||
: Budget( name, Crc32(name) )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ namespace AZ::Debug
|
||||
, m_crc{ crc }
|
||||
{
|
||||
m_impl = aznew BudgetImpl;
|
||||
if (auto statsProfiler = Interface<Statistics::StatisticalProfilerProxy>::Get(); statsProfiler)
|
||||
{
|
||||
statsProfiler->RegisterProfilerId(m_crc);
|
||||
}
|
||||
}
|
||||
|
||||
Budget::~Budget()
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Debug/Budget.h>
|
||||
#include <AzCore/Statistics/StatisticalProfilerProxy.h>
|
||||
|
||||
#ifdef USE_PIX
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
@@ -44,7 +45,10 @@
|
||||
#define AZ_PROFILE_INTERVAL_START(...)
|
||||
#define AZ_PROFILE_INTERVAL_START_COLORED(...)
|
||||
#define AZ_PROFILE_INTERVAL_END(...)
|
||||
#define AZ_PROFILE_INTERVAL_SCOPED(...)
|
||||
#define AZ_PROFILE_INTERVAL_SCOPED(budget, scopeNameId, ...) \
|
||||
static constexpr AZ::Crc32 AZ_JOIN(blockId, __LINE__)(scopeNameId); \
|
||||
AZ::Statistics::StatisticalProfilerProxy::TimedScope AZ_JOIN(scope, __LINE__)(AZ_CRC_CE(#budget), AZ_JOIN(blockId, __LINE__));
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef AZ_PROFILE_DATAPOINT
|
||||
|
||||
@@ -262,17 +262,17 @@ namespace AZ
|
||||
|
||||
#else // !AZ_ENABLE_TRACING
|
||||
|
||||
#define AZ_Assert(...) AZ_UNUSED(__VA_ARGS__);
|
||||
#define AZ_Error(...) AZ_UNUSED(__VA_ARGS__);
|
||||
#define AZ_ErrorOnce(...) AZ_UNUSED(__VA_ARGS__);
|
||||
#define AZ_Warning(...) AZ_UNUSED(__VA_ARGS__);
|
||||
#define AZ_WarningOnce(...) AZ_UNUSED(__VA_ARGS__);
|
||||
#define AZ_TracePrintf(...) AZ_UNUSED(__VA_ARGS__);
|
||||
#define AZ_TracePrintfOnce(...) AZ_UNUSED(__VA_ARGS__);
|
||||
#define AZ_Assert(...)
|
||||
#define AZ_Error(...)
|
||||
#define AZ_ErrorOnce(...)
|
||||
#define AZ_Warning(...)
|
||||
#define AZ_WarningOnce(...)
|
||||
#define AZ_TracePrintf(...)
|
||||
#define AZ_TracePrintfOnce(...)
|
||||
|
||||
#define AZ_Verify(...) AZ_UNUSED(__VA_ARGS__);
|
||||
#define AZ_VerifyError(...) AZ_UNUSED(__VA_ARGS__);
|
||||
#define AZ_VerifyWarning(...) AZ_UNUSED(__VA_ARGS__);
|
||||
#define AZ_Verify(expression, ...) AZ_UNUSED(expression)
|
||||
#define AZ_VerifyError(window, expression, ...) AZ_UNUSED(expression)
|
||||
#define AZ_VerifyWarning(window, expression, ...) AZ_UNUSED(expression)
|
||||
|
||||
#endif // AZ_ENABLE_TRACING
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* that Open 3D Engine uses to dispatch notifications and receive requests.
|
||||
* EBuses are configurable and support many different use cases.
|
||||
* For more information about %EBuses, see AZ::EBus in this guide and
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* [Event Bus](https://o3de.org/docs/user-guide/engine/ebus/)
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*/
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace AZ
|
||||
* @endcode
|
||||
*
|
||||
* For more information about %EBuses, see EBus in this guide and
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* [Event Bus](https://o3de.org/docs/user-guide/engine/ebus/)
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*/
|
||||
struct EBusTraits
|
||||
@@ -259,8 +259,8 @@ namespace AZ
|
||||
*
|
||||
* EBuses are configurable and support many different use cases.
|
||||
* For more information about EBuses, see
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* and [Components and EBuses: Best Practices ](http://docs.aws.amazon.com/lumberyard/latest/developerguide/component-entity-system-pg-components-ebuses-best-practices.html)
|
||||
* [Event Bus](https://o3de.org/docs/user-guide/engine/ebus/)
|
||||
* and [Components and EBuses: Best Practices ](https://o3de.org/docs/user-guide/components/development/entity-system-pg-components-ebuses-best-practices/)
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*
|
||||
* ## How Components Use EBuses
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Platform
|
||||
SystemFile::SizeType Length(FileHandleType handle, const SystemFile* systemFile);
|
||||
|
||||
bool Exists(const char* fileName);
|
||||
bool IsDirectory(const char* filePath);
|
||||
void FindFiles(const char* filter, SystemFile::FindFileCB cb);
|
||||
AZ::u64 ModificationTime(const char* fileName);
|
||||
SystemFile::SizeType Length(const char* fileName);
|
||||
@@ -235,6 +236,11 @@ bool SystemFile::Exists(const char* fileName)
|
||||
return Platform::Exists(fileName);
|
||||
}
|
||||
|
||||
bool SystemFile::IsDirectory(const char* filePath)
|
||||
{
|
||||
return Platform::IsDirectory(filePath);
|
||||
}
|
||||
|
||||
void SystemFile::FindFiles(const char* filter, FindFileCB cb)
|
||||
{
|
||||
Platform::FindFiles(filter, cb);
|
||||
|
||||
@@ -99,6 +99,8 @@ namespace AZ
|
||||
// Utility functions
|
||||
/// Check if a file or directory exists.
|
||||
static bool Exists(const char* path);
|
||||
/// Check if path is a directory
|
||||
static bool IsDirectory(const char* path);
|
||||
/// FindFiles
|
||||
typedef AZStd::function<bool /* true to continue to enumerate otherwise false */ (const char* /* fileName*/, bool /* true if file, false if folder*/)> FindFileCB;
|
||||
static void FindFiles(const char* filter, FindFileCB cb);
|
||||
|
||||
@@ -180,6 +180,13 @@ namespace AZ
|
||||
bool IsGreaterEqualThan(const Vector2& v) const;
|
||||
//! @}
|
||||
|
||||
//! Floor/Ceil/Round functions, operate on each component individually, result will be a new Vector2.
|
||||
//! @{
|
||||
Vector2 GetFloor() const;
|
||||
Vector2 GetCeil() const;
|
||||
Vector2 GetRound() const; // Ties to even (banker's rounding)
|
||||
//! @}
|
||||
|
||||
//! Min/Max functions, operate on each component individually, result will be a new Vector2.
|
||||
//! @{
|
||||
Vector2 GetMin(const Vector2& v) const;
|
||||
|
||||
@@ -398,6 +398,24 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector2 Vector2::GetFloor() const
|
||||
{
|
||||
return Vector2(Simd::Vec2::Floor(m_value));
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector2 Vector2::GetCeil() const
|
||||
{
|
||||
return Vector2(Simd::Vec2::Ceil(m_value));
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector2 Vector2::GetRound() const
|
||||
{
|
||||
return Vector2(Simd::Vec2::Round(m_value));
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector2 Vector2::GetMin(const Vector2& v) const
|
||||
{
|
||||
#if AZ_TRAIT_USE_PLATFORM_SIMD_SCALAR
|
||||
|
||||
@@ -211,6 +211,13 @@ namespace AZ
|
||||
bool IsGreaterEqualThan(const Vector3& rhs) const;
|
||||
//! @}
|
||||
|
||||
//! Floor/Ceil/Round functions, operate on each component individually, result will be a new Vector3.
|
||||
//! @{
|
||||
Vector3 GetFloor() const;
|
||||
Vector3 GetCeil() const;
|
||||
Vector3 GetRound() const; // Ties to even (banker's rounding)
|
||||
//! @}
|
||||
|
||||
//! Min/Max functions, operate on each component individually, result will be a new Vector3.
|
||||
//! @{
|
||||
Vector3 GetMin(const Vector3& v) const;
|
||||
|
||||
@@ -481,6 +481,24 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector3 Vector3::GetFloor() const
|
||||
{
|
||||
return Vector3(Simd::Vec3::Floor(m_value));
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector3 Vector3::GetCeil() const
|
||||
{
|
||||
return Vector3(Simd::Vec3::Ceil(m_value));
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector3 Vector3::GetRound() const
|
||||
{
|
||||
return Vector3(Simd::Vec3::Round(m_value));
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector3 Vector3::GetMin(const Vector3& v) const
|
||||
{
|
||||
#if AZ_TRAIT_USE_PLATFORM_SIMD_SCALAR
|
||||
|
||||
@@ -189,6 +189,13 @@ namespace AZ
|
||||
bool IsGreaterEqualThan(const Vector4& rhs) const;
|
||||
//! @}
|
||||
|
||||
//! Floor/Ceil/Round functions, operate on each component individually, result will be a new Vector4.
|
||||
//! @{
|
||||
Vector4 GetFloor() const;
|
||||
Vector4 GetCeil() const;
|
||||
Vector4 GetRound() const; // Ties to even (banker's rounding)
|
||||
//! @}
|
||||
|
||||
//! Min/Max functions, operate on each component individually, result will be a new Vector4.
|
||||
//! @{
|
||||
Vector4 GetMin(const Vector4& v) const;
|
||||
|
||||
@@ -464,6 +464,24 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector4 Vector4::GetFloor() const
|
||||
{
|
||||
return Vector4(Simd::Vec4::Floor(m_value));
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector4 Vector4::GetCeil() const
|
||||
{
|
||||
return Vector4(Simd::Vec4::Ceil(m_value));
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector4 Vector4::GetRound() const
|
||||
{
|
||||
return Vector4(Simd::Vec4::Round(m_value));
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector4 Vector4::GetMin(const Vector4& v) const
|
||||
{
|
||||
#if AZ_TRAIT_USE_PLATFORM_SIMD_SCALAR
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "RunningStatisticsManager.h"
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
namespace Statistics
|
||||
{
|
||||
bool RunningStatisticsManager::ContainsStatistic(const AZStd::string& name)
|
||||
{
|
||||
auto iterator = m_statisticsNamesToIndexMap.find(name);
|
||||
return iterator != m_statisticsNamesToIndexMap.end();
|
||||
}
|
||||
|
||||
bool RunningStatisticsManager::AddStatistic(const AZStd::string& name, const AZStd::string& units)
|
||||
{
|
||||
if (ContainsStatistic(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
AddStatisticValidated(name, units);
|
||||
return true;
|
||||
}
|
||||
|
||||
void RunningStatisticsManager::RemoveStatistic(const AZStd::string& name)
|
||||
{
|
||||
auto iterator = m_statisticsNamesToIndexMap.find(name);
|
||||
if (iterator == m_statisticsNamesToIndexMap.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
AZ::u32 itemIndex = iterator->second;
|
||||
m_statistics.erase(m_statistics.begin() + itemIndex);
|
||||
m_statisticsNamesToIndexMap.erase(iterator);
|
||||
//Update the indices in m_statisticsNamesToIndexMap.
|
||||
while (itemIndex < m_statistics.size())
|
||||
{
|
||||
const AZStd::string& statName = m_statistics[itemIndex].GetName();
|
||||
m_statisticsNamesToIndexMap[statName] = itemIndex;
|
||||
++itemIndex;
|
||||
}
|
||||
}
|
||||
|
||||
void RunningStatisticsManager::ResetStatistic(const AZStd::string& name)
|
||||
{
|
||||
NamedRunningStatistic* stat = GetStatistic(name);
|
||||
if (!stat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stat->Reset();
|
||||
}
|
||||
|
||||
void RunningStatisticsManager::ResetAllStatistics()
|
||||
{
|
||||
for (NamedRunningStatistic& stat : m_statistics)
|
||||
{
|
||||
stat.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void RunningStatisticsManager::PushSampleForStatistic(const AZStd::string& name, double value)
|
||||
{
|
||||
NamedRunningStatistic* stat = GetStatistic(name);
|
||||
if (!stat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stat->PushSample(value);
|
||||
}
|
||||
|
||||
NamedRunningStatistic* RunningStatisticsManager::GetStatistic(const AZStd::string& name, AZ::u32* indexOut)
|
||||
{
|
||||
auto iterator = m_statisticsNamesToIndexMap.find(name);
|
||||
if (iterator == m_statisticsNamesToIndexMap.end())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
const AZ::u32 index = iterator->second;
|
||||
if (indexOut)
|
||||
{
|
||||
*indexOut = index;
|
||||
}
|
||||
return &m_statistics[index];
|
||||
}
|
||||
|
||||
const AZStd::vector<NamedRunningStatistic>& RunningStatisticsManager::GetAllStatistics() const
|
||||
{
|
||||
return m_statistics;
|
||||
}
|
||||
|
||||
void RunningStatisticsManager::AddStatisticValidated(const AZStd::string& name, const AZStd::string& units)
|
||||
{
|
||||
m_statistics.emplace_back(NamedRunningStatistic(name, units));
|
||||
const AZ::u32 itemIndex = static_cast<AZ::u32>(m_statistics.size() - 1);
|
||||
m_statisticsNamesToIndexMap[name] = itemIndex;
|
||||
}
|
||||
|
||||
}//namespace Statistics
|
||||
}//namespace AzFramework
|
||||
@@ -8,7 +8,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/BusImpl.h> //Just to get AZ::NullMutex
|
||||
#include <AzCore/std/chrono/types.h>
|
||||
#include <AzCore/Statistics/StatisticsManager.h>
|
||||
#include <AzCore/std/chrono/chrono.h>
|
||||
#include <AzCore/std/parallel/scoped_lock.h>
|
||||
@@ -37,8 +36,7 @@ namespace AZ
|
||||
//! are some things to consider when working with the StatisticalProfilerProxy:
|
||||
//! The StatisticalProfilerProxy OWNS an array of StatisticalProfiler<AZStd::string, AZStd::shared_spin_mutex>.
|
||||
//! You can "manage" one of those StatisticalProfiler by getting a reference to it and
|
||||
//! add Running statistics etc. See The TerrainProfilers mentioned above to see concrete use
|
||||
//! cases on how to work with the StatisticalProfilerProxy.
|
||||
//! add Running statistics etc.
|
||||
template <class StatIdType = AZStd::string, class MutexType = AZ::NullMutex>
|
||||
class StatisticalProfiler
|
||||
{
|
||||
|
||||
@@ -7,28 +7,12 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/chrono/types.h>
|
||||
#include <AzCore/std/parallel/shared_spin_mutex.h>
|
||||
#include <AzCore/std/parallel/scoped_lock.h>
|
||||
#include <AzCore/std/containers/bitset.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Statistics/StatisticalProfiler.h>
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
#include <AzCore/std/parallel/shared_spin_mutex.h>
|
||||
|
||||
|
||||
#if defined(AZ_STATISTICAL_PROFILING_ENABLED)
|
||||
|
||||
#if defined(AZ_PROFILE_SCOPE)
|
||||
#undef AZ_PROFILE_SCOPE
|
||||
#endif // #if defined(AZ_PROFILE_SCOPE)
|
||||
|
||||
#define AZ_PROFILE_SCOPE(profiler, scopeNameId) \
|
||||
static const AZStd::string AZ_JOIN(blockName, __LINE__)(scopeNameId); \
|
||||
AZ::Statistics::StatisticalProfilerProxy::TimedScope AZ_JOIN(scope, __LINE__)(profiler, AZ_JOIN(blockName, __LINE__));
|
||||
|
||||
#endif //#if defined(AZ_STATISTICAL_PROFILING_ENABLED)
|
||||
|
||||
namespace AZ::Statistics
|
||||
{
|
||||
using StatisticalProfilerId = uint32_t;
|
||||
@@ -65,7 +49,7 @@ namespace AZ::Statistics
|
||||
public:
|
||||
AZ_TYPE_INFO(StatisticalProfilerProxy, "{1103D0EB-1C32-4854-B9D9-40A2D65BDBD2}");
|
||||
|
||||
using StatIdType = AZStd::string;
|
||||
using StatIdType = AZ::Crc32;
|
||||
using StatisticalProfilerType = StatisticalProfiler<StatIdType, AZStd::shared_spin_mutex>;
|
||||
|
||||
//! A Convenience class used to measure time performance of scopes of code
|
||||
@@ -94,6 +78,7 @@ namespace AZ::Statistics
|
||||
}
|
||||
m_startTime = AZStd::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
~TimedScope()
|
||||
{
|
||||
if (!m_profilerProxy)
|
||||
@@ -122,7 +107,6 @@ namespace AZ::Statistics
|
||||
|
||||
StatisticalProfilerProxy()
|
||||
{
|
||||
// TODO:BUDGETS Query available budgets at registration time and create an associated profiler per type
|
||||
AZ::Interface<StatisticalProfilerProxy>::Register(this);
|
||||
}
|
||||
|
||||
@@ -135,30 +119,54 @@ namespace AZ::Statistics
|
||||
StatisticalProfilerProxy(StatisticalProfilerProxy&&) = delete;
|
||||
StatisticalProfilerProxy& operator=(StatisticalProfilerProxy&&) = delete;
|
||||
|
||||
void RegisterProfilerId(StatisticalProfilerId id)
|
||||
{
|
||||
m_profilers.try_emplace(id, ProfilerInfo());
|
||||
}
|
||||
|
||||
bool IsProfilerActive(StatisticalProfilerId id) const
|
||||
{
|
||||
return m_activeProfilersFlag[static_cast<AZStd::size_t>(id)];
|
||||
auto iter = m_profilers.find(id);
|
||||
return (iter != m_profilers.end()) ? iter->second.m_enabled : false;
|
||||
}
|
||||
|
||||
StatisticalProfilerType& GetProfiler(StatisticalProfilerId id)
|
||||
{
|
||||
return m_profilers[static_cast<AZStd::size_t>(id)];
|
||||
auto iter = m_profilers.try_emplace(id, ProfilerInfo()).first;
|
||||
return iter->second.m_profiler;
|
||||
}
|
||||
|
||||
void ActivateProfiler(StatisticalProfilerId id, bool activate)
|
||||
void ActivateProfiler(StatisticalProfilerId id, bool activate, bool autoCreate = true)
|
||||
{
|
||||
m_activeProfilersFlag[static_cast<AZStd::size_t>(id)] = activate;
|
||||
if (autoCreate)
|
||||
{
|
||||
auto iter = m_profilers.try_emplace(id, ProfilerInfo()).first;
|
||||
iter->second.m_enabled = activate;
|
||||
}
|
||||
else if (auto iter = m_profilers.find(id); iter != m_profilers.end())
|
||||
{
|
||||
iter->second.m_enabled = activate;
|
||||
}
|
||||
}
|
||||
|
||||
void PushSample(StatisticalProfilerId id, const StatIdType& statId, double value)
|
||||
{
|
||||
m_profilers[static_cast<AZStd::size_t>(id)].PushSample(statId, value);
|
||||
if (auto iter = m_profilers.find(id); iter != m_profilers.end())
|
||||
{
|
||||
iter->second.m_profiler.PushSample(statId, value);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// TODO:BUDGETS the number of bits allocated here must be based on the number of budgets available at profiler registration time
|
||||
AZStd::bitset<128> m_activeProfilersFlag;
|
||||
AZStd::vector<StatisticalProfilerType> m_profilers;
|
||||
struct ProfilerInfo
|
||||
{
|
||||
StatisticalProfilerType m_profiler;
|
||||
bool m_enabled{ false };
|
||||
};
|
||||
|
||||
using ProfilerMap = AZStd::unordered_map<StatisticalProfilerId, ProfilerInfo>;
|
||||
|
||||
ProfilerMap m_profilers;
|
||||
}; // class StatisticalProfilerProxy
|
||||
|
||||
}; // namespace AZ::Statistics
|
||||
|
||||
@@ -368,6 +368,21 @@ namespace Platform
|
||||
return access(fileName, F_OK) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsDirectory(const char* filePath)
|
||||
{
|
||||
if (AZ::Android::Utils::IsApkPath(filePath))
|
||||
{
|
||||
return AZ::Android::APKFileHandler::IsDirectory(AZ::Android::Utils::StripApkPrefix(filePath).c_str());
|
||||
}
|
||||
|
||||
struct stat result;
|
||||
if (stat(filePath, &result) == 0)
|
||||
{
|
||||
return S_ISDIR(result.st_mode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace AZ::IO::Platform
|
||||
|
||||
} // namespace AZ::IO
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace AZ
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (size_t i = tracerPidOffset; i < numRead; ++i)
|
||||
for (size_t i = tracerPidOffset + tracerPidString.length(); i < numRead; ++i)
|
||||
{
|
||||
if (!::isspace(processStatusView[i]))
|
||||
{
|
||||
|
||||
+10
@@ -249,6 +249,16 @@ namespace Platform
|
||||
{
|
||||
return access(fileName, F_OK) == 0;
|
||||
}
|
||||
|
||||
bool IsDirectory(const char* filePath)
|
||||
{
|
||||
struct stat result;
|
||||
if (stat(filePath, &result) == 0)
|
||||
{
|
||||
return S_ISDIR(result.st_mode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace AZ::IO
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
namespace AZ::IO
|
||||
{
|
||||
|
||||
using FixedMaxPathWString = AZStd::fixed_wstring<MaxPathLength>;
|
||||
namespace
|
||||
{
|
||||
//=========================================================================
|
||||
@@ -28,16 +29,9 @@ namespace
|
||||
//=========================================================================
|
||||
DWORD GetAttributes(const char* fileName)
|
||||
{
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
{
|
||||
return GetFileAttributesW(fileNameW);
|
||||
}
|
||||
else
|
||||
{
|
||||
return INVALID_FILE_ATTRIBUTES;
|
||||
}
|
||||
FixedMaxPathWString fileNameW;
|
||||
AZStd::to_wstring(fileNameW, fileName);
|
||||
return GetFileAttributesW(fileNameW.c_str());
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -47,16 +41,9 @@ namespace
|
||||
//=========================================================================
|
||||
BOOL SetAttributes(const char* fileName, DWORD fileAttributes)
|
||||
{
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
{
|
||||
return SetFileAttributesW(fileNameW, fileAttributes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
FixedMaxPathWString fileNameW;
|
||||
AZStd::to_wstring(fileNameW, fileName);
|
||||
return SetFileAttributesW(fileNameW.c_str(), fileAttributes);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -68,9 +55,9 @@ namespace
|
||||
// * GetLastError() on Windows-like platforms
|
||||
// * errno on Unix platforms
|
||||
//=========================================================================
|
||||
bool CreateDirRecursive(wchar_t* dirPath)
|
||||
bool CreateDirRecursive(AZ::IO::FixedMaxPathWString& dirPath)
|
||||
{
|
||||
if (CreateDirectoryW(dirPath, nullptr))
|
||||
if (CreateDirectoryW(dirPath.c_str(), nullptr))
|
||||
{
|
||||
return true; // Created without error
|
||||
}
|
||||
@@ -78,28 +65,24 @@ namespace
|
||||
if (error == ERROR_PATH_NOT_FOUND)
|
||||
{
|
||||
// try to create our parent hierarchy
|
||||
for (size_t i = wcslen(dirPath); i > 0; --i)
|
||||
if (size_t i = dirPath.find_last_of(LR"(/\)"); i != FixedMaxPathWString::npos)
|
||||
{
|
||||
if (dirPath[i] == L'/' || dirPath[i] == L'\\')
|
||||
wchar_t delimiter = dirPath[i];
|
||||
dirPath[i] = 0; // null-terminate at the previous slash
|
||||
const bool ret = CreateDirRecursive(dirPath);
|
||||
dirPath[i] = delimiter; // restore slash
|
||||
if (ret)
|
||||
{
|
||||
wchar_t delimiter = dirPath[i];
|
||||
dirPath[i] = 0; // null-terminate at the previous slash
|
||||
bool ret = CreateDirRecursive(dirPath);
|
||||
dirPath[i] = delimiter; // restore slash
|
||||
if (ret)
|
||||
{
|
||||
// now that our parent is created, try to create again
|
||||
return CreateDirectoryW(dirPath, nullptr) != 0;
|
||||
}
|
||||
return false;
|
||||
// now that our parent is created, try to create again
|
||||
return CreateDirectoryW(dirPath.c_str(), nullptr) != 0;
|
||||
}
|
||||
}
|
||||
// if we reach here then there was no parent folder to create, so we failed for other reasons
|
||||
}
|
||||
else if (error == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
DWORD attributes = GetFileAttributesW(dirPath);
|
||||
return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
DWORD attributes = GetFileAttributesW(dirPath.c_str());
|
||||
return attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -152,13 +135,10 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
CreatePath(m_fileName.c_str());
|
||||
}
|
||||
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
AZ::IO::FixedMaxPathWString fileNameW;
|
||||
AZStd::to_wstring(fileNameW, m_fileName);
|
||||
m_handle = INVALID_HANDLE_VALUE;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, m_fileName.c_str(), AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
{
|
||||
m_handle = CreateFileW(fileNameW, dwDesiredAccess, dwShareMode, 0, dwCreationDisposition, dwFlagsAndAttributes, 0);
|
||||
}
|
||||
m_handle = CreateFileW(fileNameW.c_str(), dwDesiredAccess, dwShareMode, 0, dwCreationDisposition, dwFlagsAndAttributes, 0);
|
||||
|
||||
if (m_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -350,6 +330,12 @@ namespace Platform
|
||||
return GetAttributes(fileName) != INVALID_FILE_ATTRIBUTES;
|
||||
}
|
||||
|
||||
bool IsDirectory(const char* filePath)
|
||||
{
|
||||
DWORD attributes = GetAttributes(filePath);
|
||||
return attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
|
||||
|
||||
void FindFiles(const char* filter, SystemFile::FindFileCB cb)
|
||||
{
|
||||
@@ -357,35 +343,26 @@ namespace Platform
|
||||
HANDLE hFile;
|
||||
int lastError;
|
||||
|
||||
wchar_t filterW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
AZ::IO::FixedMaxPathWString filterW;
|
||||
AZStd::to_wstring(filterW, filter);
|
||||
hFile = INVALID_HANDLE_VALUE;
|
||||
if (mbstowcs_s(&numCharsConverted, filterW, filter, AZ_ARRAY_SIZE(filterW) - 1) == 0)
|
||||
{
|
||||
hFile = FindFirstFile(filterW, &fd);
|
||||
}
|
||||
hFile = FindFirstFileW(filterW.c_str(), &fd);
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
const char* fileName;
|
||||
|
||||
char fileNameA[AZ_MAX_PATH_LEN];
|
||||
fileName = NULL;
|
||||
if (wcstombs_s(&numCharsConverted, fileNameA, fd.cFileName, AZ_ARRAY_SIZE(fileNameA) - 1) == 0)
|
||||
{
|
||||
fileName = fileNameA;
|
||||
}
|
||||
AZ::IO::FixedMaxPathString fileNameUtf8;
|
||||
AZStd::to_string(fileNameUtf8, fd.cFileName);
|
||||
fileName = fileNameUtf8.c_str();
|
||||
|
||||
cb(fileName, (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0);
|
||||
|
||||
// List all the other files in the directory.
|
||||
while (FindNextFileW(hFile, &fd) != 0)
|
||||
{
|
||||
fileName = NULL;
|
||||
if (wcstombs_s(&numCharsConverted, fileNameA, fd.cFileName, AZ_ARRAY_SIZE(fileNameA) - 1) == 0)
|
||||
{
|
||||
fileName = fileNameA;
|
||||
}
|
||||
AZStd::to_string(fileNameUtf8, fd.cFileName);
|
||||
fileName = fileNameUtf8.c_str();
|
||||
|
||||
cb(fileName, (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0);
|
||||
}
|
||||
@@ -411,12 +388,9 @@ namespace Platform
|
||||
{
|
||||
HANDLE handle = nullptr;
|
||||
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
{
|
||||
handle = CreateFileW(fileNameW, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
}
|
||||
AZ::IO::FixedMaxPathWString fileNameW;
|
||||
AZStd::to_wstring(fileNameW, fileName);
|
||||
handle = CreateFileW(fileNameW.c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -448,12 +422,9 @@ namespace Platform
|
||||
WIN32_FILE_ATTRIBUTE_DATA data = { 0 };
|
||||
BOOL result = FALSE;
|
||||
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
{
|
||||
result = GetFileAttributesExW(fileNameW, GetFileExInfoStandard, &data);
|
||||
}
|
||||
AZ::IO::FixedMaxPathWString fileNameW;
|
||||
AZStd::to_wstring(fileNameW, fileName);
|
||||
result = GetFileAttributesExW(fileNameW.c_str(), GetFileExInfoStandard, &data);
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -473,18 +444,11 @@ namespace Platform
|
||||
|
||||
bool Delete(const char* fileName)
|
||||
{
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
{
|
||||
if (DeleteFileW(fileNameW) == 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, fileName, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
AZ::IO::FixedMaxPathWString fileNameW;
|
||||
AZStd::to_wstring(fileNameW, fileName);
|
||||
if (DeleteFileW(fileNameW.c_str()) == 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, fileName, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -493,20 +457,13 @@ namespace Platform
|
||||
|
||||
bool Rename(const char* sourceFileName, const char* targetFileName, bool overwrite)
|
||||
{
|
||||
wchar_t sourceFileNameW[AZ_MAX_PATH_LEN];
|
||||
wchar_t targetFileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, sourceFileNameW, sourceFileName, AZ_ARRAY_SIZE(sourceFileNameW) - 1) == 0 &&
|
||||
mbstowcs_s(&numCharsConverted, targetFileNameW, targetFileName, AZ_ARRAY_SIZE(targetFileNameW) - 1) == 0)
|
||||
{
|
||||
if (MoveFileExW(sourceFileNameW, targetFileNameW, overwrite ? MOVEFILE_REPLACE_EXISTING : 0) == 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, sourceFileName, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
AZ::IO::FixedMaxPathWString sourceFileNameW;
|
||||
AZStd::to_wstring(sourceFileNameW, sourceFileName);
|
||||
AZ::IO::FixedMaxPathWString targetFileNameW;
|
||||
AZStd::to_wstring(targetFileNameW, targetFileName);
|
||||
if (MoveFileExW(sourceFileNameW.c_str(), targetFileNameW.c_str(), overwrite ? MOVEFILE_REPLACE_EXISTING : 0) == 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, sourceFileName, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -543,17 +500,14 @@ namespace Platform
|
||||
{
|
||||
if (dirName)
|
||||
{
|
||||
wchar_t dirPath[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, dirPath, dirName, AZ_ARRAY_SIZE(dirPath) - 1) == 0)
|
||||
AZ::IO::FixedMaxPathWString dirNameW;
|
||||
AZStd::to_wstring(dirNameW, dirName);
|
||||
bool success = CreateDirRecursive(dirNameW);
|
||||
if (!success)
|
||||
{
|
||||
bool success = CreateDirRecursive(dirPath);
|
||||
if (!success)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, dirName, (int)GetLastError());
|
||||
}
|
||||
return success;
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, dirName, (int)GetLastError());
|
||||
}
|
||||
return success;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -562,12 +516,9 @@ namespace Platform
|
||||
{
|
||||
if (dirName)
|
||||
{
|
||||
wchar_t dirNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, dirNameW, dirName, AZ_ARRAY_SIZE(dirNameW) - 1) == 0)
|
||||
{
|
||||
return RemoveDirectory(dirNameW) != 0;
|
||||
}
|
||||
AZ::IO::FixedMaxPathWString dirNameW;
|
||||
AZStd::to_wstring(dirNameW, dirName);
|
||||
return RemoveDirectory(dirNameW.c_str()) != 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
constexpr AZ::u32 ProfilerProxyGroup = AZ_CRC_CE("StatisticalProfilerProxyTests");
|
||||
|
||||
class StatisticalProfilerTest
|
||||
: public AllocatorsFixture
|
||||
{
|
||||
@@ -98,10 +100,10 @@ namespace UnitTest
|
||||
|
||||
AZ::Statistics::StatisticalProfiler<AZ::Crc32> profiler;
|
||||
|
||||
const AZ::Crc32 statIdPerformance = AZ_CRC("PerformanceResult", 0xc1f29a10);
|
||||
constexpr AZ::Crc32 statIdPerformance = AZ_CRC_CE("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Crc32 statIdBlock = AZ_CRC("Block", 0x831b9722);
|
||||
constexpr AZ::Crc32 statIdBlock = AZ_CRC_CE("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
@@ -175,10 +177,10 @@ namespace UnitTest
|
||||
|
||||
AZ::Statistics::StatisticalProfiler<AZ::Crc32, AZStd::shared_spin_mutex> profiler;
|
||||
|
||||
const AZ::Crc32 statIdPerformance = AZ_CRC("PerformanceResult", 0xc1f29a10);
|
||||
constexpr AZ::Crc32 statIdPerformance = AZ_CRC_CE("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Crc32 statIdBlock = AZ_CRC("Block", 0x831b9722);
|
||||
constexpr AZ::Crc32 statIdBlock = AZ_CRC_CE("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
@@ -317,26 +319,26 @@ namespace UnitTest
|
||||
AZ::Statistics::StatisticalProfilerProxy::TimedScope::ClearCachedProxy();
|
||||
AZ::Statistics::StatisticalProfilerProxy profilerProxy;
|
||||
AZ::Statistics::StatisticalProfilerProxy* proxy = AZ::Interface<AZ::Statistics::StatisticalProfilerProxy>::Get();
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(AZ::Debug::ProfileCategory::Terrain);
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(ProfilerProxyGroup);
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdPerformance = "PerformanceResult";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdPerformance("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdBlock = "Block";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdBlock("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdBlock, statNameBlock, "us") != nullptr);
|
||||
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, true);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, true);
|
||||
|
||||
const int iter_count = 10;
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, statIdPerformance)
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, statIdPerformance)
|
||||
int counter = 0;
|
||||
for (int i = 0; i < iter_count; i++)
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, statIdBlock)
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, statIdBlock)
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@@ -348,7 +350,7 @@ namespace UnitTest
|
||||
EXPECT_EQ(profiler.GetStatistic(statIdBlock)->GetNumSamples(), iter_count);
|
||||
|
||||
//Clean Up
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, false);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, false);
|
||||
|
||||
#undef CODE_PROFILER_PROXY_PUSH_TIME
|
||||
|
||||
@@ -362,12 +364,12 @@ namespace UnitTest
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread1("simple_thread1");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread1_loop("simple_thread1_loop");
|
||||
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread1);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread1);
|
||||
|
||||
static int counter = 0;
|
||||
for (int i = 0; i < loop_cnt; i++)
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread1_loop);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread1_loop);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@@ -377,12 +379,12 @@ namespace UnitTest
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread2("simple_thread2");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread2_loop("simple_thread2_loop");
|
||||
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread2);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread2);
|
||||
|
||||
static int counter = 0;
|
||||
for (int i = 0; i < loop_cnt; i++)
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread2_loop);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread2_loop);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@@ -392,12 +394,13 @@ namespace UnitTest
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread3("simple_thread3");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType simple_thread3_loop("simple_thread3_loop");
|
||||
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread3);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread3);
|
||||
|
||||
static int counter = 0;
|
||||
for (int i = 0; i < loop_cnt; i++)
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, simple_thread3_loop);
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, simple_thread3_loop);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,21 +411,21 @@ namespace UnitTest
|
||||
AZ::Statistics::StatisticalProfilerProxy::TimedScope::ClearCachedProxy();
|
||||
AZ::Statistics::StatisticalProfilerProxy profilerProxy;
|
||||
AZ::Statistics::StatisticalProfilerProxy* proxy = AZ::Interface<AZ::Statistics::StatisticalProfilerProxy>::Get();
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(AZ::Debug::ProfileCategory::Terrain);
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(ProfilerProxyGroup);
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1 = "simple_thread1";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1("simple_thread1");
|
||||
const AZStd::string statNameThread1("simple_thread1");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1Loop = "simple_thread1_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1Loop("simple_thread1_loop");
|
||||
const AZStd::string statNameThread1Loop("simple_thread1_loop");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2 = "simple_thread2";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2("simple_thread2");
|
||||
const AZStd::string statNameThread2("simple_thread2");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2Loop = "simple_thread2_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2Loop("simple_thread2_loop");
|
||||
const AZStd::string statNameThread2Loop("simple_thread2_loop");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3 = "simple_thread3";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3("simple_thread3");
|
||||
const AZStd::string statNameThread3("simple_thread3");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3Loop = "simple_thread3_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3Loop("simple_thread3_loop");
|
||||
const AZStd::string statNameThread3Loop("simple_thread3_loop");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread1, statNameThread1, "us"));
|
||||
@@ -432,7 +435,7 @@ namespace UnitTest
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread3, statNameThread3, "us"));
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread3Loop, statNameThread3Loop, "us"));
|
||||
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, true);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, true);
|
||||
|
||||
//Let's kickoff the threads to see how much contention affects the profiler's performance.
|
||||
const int iter_count = 10;
|
||||
@@ -459,7 +462,7 @@ namespace UnitTest
|
||||
EXPECT_EQ(profiler.GetStatistic(statIdThread3Loop)->GetNumSamples(), iter_count);
|
||||
|
||||
//Clean Up
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, false);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, false);
|
||||
}
|
||||
|
||||
/** Trace message handler to track messages during tests
|
||||
@@ -566,10 +569,10 @@ namespace UnitTest
|
||||
|
||||
AZ::Statistics::StatisticalProfiler<AZ::Crc32> profiler;
|
||||
|
||||
const AZ::Crc32 statIdPerformance = AZ_CRC("PerformanceResult", 0xc1f29a10);
|
||||
constexpr AZ::Crc32 statIdPerformance = AZ_CRC_CE("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Crc32 statIdBlock = AZ_CRC("Block", 0x831b9722);
|
||||
constexpr AZ::Crc32 statIdBlock = AZ_CRC_CE("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
@@ -647,10 +650,10 @@ namespace UnitTest
|
||||
|
||||
AZ::Statistics::StatisticalProfiler<AZ::Crc32, AZStd::shared_spin_mutex> profiler;
|
||||
|
||||
const AZ::Crc32 statIdPerformance = AZ_CRC("PerformanceResult", 0xc1f29a10);
|
||||
constexpr AZ::Crc32 statIdPerformance = AZ_CRC_CE("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Crc32 statIdBlock = AZ_CRC("Block", 0x831b9722);
|
||||
constexpr AZ::Crc32 statIdBlock = AZ_CRC_CE("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
@@ -745,26 +748,26 @@ namespace UnitTest
|
||||
AZ::Statistics::StatisticalProfilerProxy::TimedScope::ClearCachedProxy();
|
||||
AZ::Statistics::StatisticalProfilerProxy profilerProxy;
|
||||
AZ::Statistics::StatisticalProfilerProxy* proxy = AZ::Interface<AZ::Statistics::StatisticalProfilerProxy>::Get();
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(AZ::Debug::ProfileCategory::Terrain);
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(ProfilerProxyGroup);
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdPerformance = "PerformanceResult";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdPerformance("PerformanceResult");
|
||||
const AZStd::string statNamePerformance("PerformanceResult");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdBlock = "Block";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdBlock("Block");
|
||||
const AZStd::string statNameBlock("Block");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdPerformance, statNamePerformance, "us") != nullptr);
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdBlock, statNameBlock, "us") != nullptr);
|
||||
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, true);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, true);
|
||||
|
||||
const int iter_count = 1000000;
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, statIdPerformance)
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, statIdPerformance)
|
||||
int counter = 0;
|
||||
for (int i = 0; i < iter_count; i++)
|
||||
{
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(AZ::Debug::ProfileCategory::Terrain, statIdBlock)
|
||||
CODE_PROFILER_PROXY_PUSH_TIME(ProfilerProxyGroup, statIdBlock)
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@@ -778,7 +781,7 @@ namespace UnitTest
|
||||
profiler.LogAndResetStats("StatisticalProfilerProxy");
|
||||
|
||||
//Clean Up
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, false);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, false);
|
||||
}
|
||||
|
||||
#undef CODE_PROFILER_PROXY_PUSH_TIME
|
||||
@@ -788,21 +791,21 @@ namespace UnitTest
|
||||
AZ::Statistics::StatisticalProfilerProxy::TimedScope::ClearCachedProxy();
|
||||
AZ::Statistics::StatisticalProfilerProxy profilerProxy;
|
||||
AZ::Statistics::StatisticalProfilerProxy* proxy = AZ::Interface<AZ::Statistics::StatisticalProfilerProxy>::Get();
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(AZ::Debug::ProfileCategory::Terrain);
|
||||
AZ::Statistics::StatisticalProfilerProxy::StatisticalProfilerType& profiler = proxy->GetProfiler(ProfilerProxyGroup);
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1 = "simple_thread1";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1("simple_thread1");
|
||||
const AZStd::string statNameThread1("simple_thread1");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1Loop = "simple_thread1_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread1Loop("simple_thread1_loop");
|
||||
const AZStd::string statNameThread1Loop("simple_thread1_loop");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2 = "simple_thread2";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2("simple_thread2");
|
||||
const AZStd::string statNameThread2("simple_thread2");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2Loop = "simple_thread2_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread2Loop("simple_thread2_loop");
|
||||
const AZStd::string statNameThread2Loop("simple_thread2_loop");
|
||||
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3 = "simple_thread3";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3("simple_thread3");
|
||||
const AZStd::string statNameThread3("simple_thread3");
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3Loop = "simple_thread3_loop";
|
||||
const AZ::Statistics::StatisticalProfilerProxy::StatIdType statIdThread3Loop("simple_thread3_loop");
|
||||
const AZStd::string statNameThread3Loop("simple_thread3_loop");
|
||||
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread1, statNameThread1, "us"));
|
||||
@@ -812,7 +815,7 @@ namespace UnitTest
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread3, statNameThread3, "us"));
|
||||
ASSERT_TRUE(profiler.GetStatsManager().AddStatistic(statIdThread3Loop, statNameThread3Loop, "us"));
|
||||
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, true);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, true);
|
||||
|
||||
//Let's kickoff the threads to see how much contention affects the profiler's performance.
|
||||
const int iter_count = 1000000;
|
||||
@@ -841,7 +844,7 @@ namespace UnitTest
|
||||
profiler.LogAndResetStats("3_Threads_StatisticalProfilerProxy");
|
||||
|
||||
//Clean Up
|
||||
proxy->ActivateProfiler(AZ::Debug::ProfileCategory::Terrain, false);
|
||||
proxy->ActivateProfiler(ProfilerProxyGroup, false);
|
||||
}
|
||||
|
||||
}//namespace UnitTest
|
||||
|
||||
@@ -61,6 +61,7 @@ set(FILES
|
||||
Slice.cpp
|
||||
State.cpp
|
||||
Statistics.cpp
|
||||
StatisticalProfiler.cpp
|
||||
StreamerTests.cpp
|
||||
StringFunc.cpp
|
||||
SystemFile.cpp
|
||||
|
||||
@@ -281,6 +281,14 @@ namespace AZ
|
||||
return SystemFile::Exists(resolvedPath);
|
||||
}
|
||||
|
||||
bool LocalFileIO::IsDirectory(const char* filePath)
|
||||
{
|
||||
char resolvedPath[AZ_MAX_PATH_LEN];
|
||||
ResolvePath(filePath, resolvedPath, AZ_MAX_PATH_LEN);
|
||||
|
||||
return SystemFile::IsDirectory(resolvedPath);
|
||||
}
|
||||
|
||||
void LocalFileIO::CheckInvalidWrite([[maybe_unused]] const char* path)
|
||||
{
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
|
||||
@@ -40,26 +40,6 @@ namespace AZ
|
||||
{
|
||||
namespace IO
|
||||
{
|
||||
bool LocalFileIO::IsDirectory(const char* filePath)
|
||||
{
|
||||
ANDROID_IO_PROFILE_SECTION_ARGS("IsDir:%s", filePath);
|
||||
|
||||
char resolvedPath[AZ_MAX_PATH_LEN];
|
||||
ResolvePath(filePath, resolvedPath, AZ_MAX_PATH_LEN);
|
||||
|
||||
if (AZ::Android::Utils::IsApkPath(resolvedPath))
|
||||
{
|
||||
return AZ::Android::APKFileHandler::IsDirectory(AZ::Android::Utils::StripApkPrefix(resolvedPath).c_str());
|
||||
}
|
||||
|
||||
struct stat result;
|
||||
if (stat(resolvedPath, &result) == 0)
|
||||
{
|
||||
return S_ISDIR(result.st_mode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Result LocalFileIO::Copy(const char* sourceFilePath, const char* destinationFilePath)
|
||||
{
|
||||
char resolvedSourcePath[AZ_MAX_PATH_LEN];
|
||||
|
||||
-13
@@ -17,19 +17,6 @@ namespace AZ
|
||||
{
|
||||
namespace IO
|
||||
{
|
||||
bool LocalFileIO::IsDirectory(const char* filePath)
|
||||
{
|
||||
char resolvedPath[AZ_MAX_PATH_LEN] = {0};
|
||||
ResolvePath(filePath, resolvedPath, AZ_MAX_PATH_LEN);
|
||||
|
||||
struct stat result;
|
||||
if (stat(resolvedPath, &result) == 0)
|
||||
{
|
||||
return S_ISDIR(result.st_mode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Result LocalFileIO::Copy(const char* sourceFilePath, const char* destinationFilePath)
|
||||
{
|
||||
char resolvedSourceFilePath[AZ_MAX_PATH_LEN] = {0};
|
||||
|
||||
-16
@@ -15,22 +15,6 @@ namespace AZ
|
||||
{
|
||||
namespace IO
|
||||
{
|
||||
bool LocalFileIO::IsDirectory(const char* filePath)
|
||||
{
|
||||
char resolvedPath[AZ_MAX_PATH_LEN];
|
||||
ResolvePath(filePath, resolvedPath, AZ_MAX_PATH_LEN);
|
||||
|
||||
wchar_t resolvedPathW[AZ_MAX_PATH_LEN];
|
||||
AZStd::to_wstring(resolvedPathW, AZ_MAX_PATH_LEN, resolvedPath);
|
||||
DWORD fileAttributes = GetFileAttributesW(resolvedPathW);
|
||||
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
|
||||
Result LocalFileIO::FindFiles(const char* filePath, const char* filter, FindFilesCallbackType callback)
|
||||
{
|
||||
char resolvedPath[AZ_MAX_PATH_LEN];
|
||||
|
||||
+2
@@ -239,6 +239,8 @@ namespace AzFramework
|
||||
RAWINPUT* rawInput = (RAWINPUT*)rawInputBytes;
|
||||
AzFramework::RawInputNotificationBusWindows::Broadcast(
|
||||
&AzFramework::RawInputNotificationBusWindows::Events::OnRawInputEvent, *rawInput);
|
||||
|
||||
delete [] rawInputBytes;
|
||||
break;
|
||||
}
|
||||
case WM_CHAR:
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzFramework/IO/FileOperations.h>
|
||||
#include <time.h>
|
||||
#include <AzTest/Utils.h>
|
||||
@@ -30,21 +29,6 @@ using namespace AZ;
|
||||
using namespace AZ::IO;
|
||||
using namespace AZ::Debug;
|
||||
|
||||
namespace PathUtil
|
||||
{
|
||||
AZStd::string AddSlash(const AZStd::string& path)
|
||||
{
|
||||
if (path.empty() || path[path.length() - 1] == '/')
|
||||
{
|
||||
return path;
|
||||
}
|
||||
if (path[path.length() - 1] == '\\')
|
||||
{
|
||||
return path.substr(0, path.length() - 1) + "/";
|
||||
}
|
||||
return path + "/";
|
||||
}
|
||||
}
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
@@ -161,15 +145,16 @@ namespace UnitTest
|
||||
: public ScopedAllocatorSetupFixture
|
||||
{
|
||||
public:
|
||||
AZStd::string m_root;
|
||||
AZStd::string folderName;
|
||||
AZStd::string deepFolder;
|
||||
AZStd::string extraFolder;
|
||||
AZ::Test::ScopedAutoTempDirectory m_tempDir;
|
||||
AZ::IO::Path m_root;
|
||||
AZ::IO::Path m_folderName;
|
||||
AZ::IO::Path m_deepFolder;
|
||||
AZ::IO::Path m_extraFolder;
|
||||
|
||||
AZStd::string fileRoot;
|
||||
AZStd::string file01Name;
|
||||
AZStd::string file02Name;
|
||||
AZStd::string file03Name;
|
||||
AZ::IO::Path m_fileRoot;
|
||||
AZ::IO::Path m_file01Name;
|
||||
AZ::IO::Path m_file02Name;
|
||||
AZ::IO::Path m_file03Name;
|
||||
int m_randomFolderKey = 0;
|
||||
|
||||
FolderFixture()
|
||||
@@ -179,43 +164,13 @@ namespace UnitTest
|
||||
|
||||
void ChooseRandomFolder()
|
||||
{
|
||||
char currentDir[AZ_MAX_PATH_LEN];
|
||||
AZ::Utils::GetExecutableDirectory(currentDir, AZ_MAX_PATH_LEN);
|
||||
|
||||
folderName = currentDir;
|
||||
folderName.append("/temp");
|
||||
m_root = folderName;
|
||||
if (folderName.size() > 0)
|
||||
{
|
||||
folderName = PathUtil::AddSlash(folderName);
|
||||
}
|
||||
|
||||
AZStd::string tempName = AZStd::string::format("tmp%08x", m_randomFolderKey);
|
||||
folderName.append(tempName.c_str());
|
||||
folderName = PathUtil::AddSlash(folderName);
|
||||
AZStd::replace(folderName.begin(), folderName.end(), '\\', '/');
|
||||
|
||||
// Make sure the drive letter is capitalized
|
||||
if (folderName.size() > 2)
|
||||
{
|
||||
if (folderName[1] == ':')
|
||||
{
|
||||
folderName[0] = static_cast<char>(toupper(folderName[0]));
|
||||
}
|
||||
}
|
||||
|
||||
deepFolder = folderName;
|
||||
deepFolder.append("test");
|
||||
|
||||
deepFolder = PathUtil::AddSlash(deepFolder);
|
||||
deepFolder.append("subdir");
|
||||
|
||||
extraFolder = deepFolder;
|
||||
extraFolder = PathUtil::AddSlash(extraFolder);
|
||||
extraFolder.append("subdir2");
|
||||
m_root = m_tempDir.GetDirectory();
|
||||
m_folderName = m_root / AZStd::string::format("tmp%08x", m_randomFolderKey);
|
||||
m_deepFolder = m_folderName / "test" / "subdir";
|
||||
m_extraFolder = m_deepFolder / "subdir2";
|
||||
|
||||
// make a couple files there, and in the root:
|
||||
fileRoot = PathUtil::AddSlash(extraFolder);
|
||||
m_fileRoot = m_extraFolder;
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
@@ -229,37 +184,33 @@ namespace UnitTest
|
||||
{
|
||||
ChooseRandomFolder();
|
||||
++m_randomFolderKey;
|
||||
} while (local.IsDirectory(fileRoot.c_str()));
|
||||
} while (local.IsDirectory(m_fileRoot.c_str()));
|
||||
|
||||
file01Name = fileRoot + "file01.txt";
|
||||
file02Name = fileRoot + "file02.asdf";
|
||||
file03Name = fileRoot + "test123.wha";
|
||||
m_file01Name = m_fileRoot / "file01.txt";
|
||||
m_file02Name = m_fileRoot / "file02.asdf";
|
||||
m_file03Name = m_fileRoot / "test123.wha";
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
if ((!folderName.empty())&&(strstr(folderName.c_str(), "/temp") != nullptr))
|
||||
{
|
||||
// cleanup!
|
||||
LocalFileIO local;
|
||||
local.DestroyPath(folderName.c_str());
|
||||
}
|
||||
}
|
||||
void CreateTestFiles()
|
||||
{
|
||||
constexpr auto openMode = SystemFile::OpenMode::SF_OPEN_WRITE_ONLY
|
||||
| SystemFile::OpenMode::SF_OPEN_CREATE
|
||||
| SystemFile::OpenMode::SF_OPEN_CREATE_NEW;
|
||||
constexpr AZStd::string_view testContent("this is just a test");
|
||||
|
||||
LocalFileIO local;
|
||||
AZ_TEST_ASSERT(local.CreatePath(fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(local.IsDirectory(fileRoot.c_str()));
|
||||
for (const AZStd::string& filename : { file01Name, file02Name, file03Name })
|
||||
AZ_TEST_ASSERT(local.CreatePath(m_fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(local.IsDirectory(m_fileRoot.c_str()));
|
||||
for (const AZ::IO::Path& filename : { m_file01Name, m_file02Name, m_file03Name })
|
||||
{
|
||||
#ifdef AZ_COMPILER_MSVC
|
||||
FILE* tempFile;
|
||||
fopen_s(&tempFile, filename.c_str(), "wb");
|
||||
#else
|
||||
FILE* tempFile = fopen(filename.c_str(), "wb");
|
||||
#endif
|
||||
fwrite("this is just a test", 1, 19, tempFile);
|
||||
fclose(tempFile);
|
||||
SystemFile tempFile;
|
||||
tempFile.Open(filename.c_str(), openMode);
|
||||
|
||||
tempFile.Write(testContent.data(), testContent.size());
|
||||
tempFile.Close();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -272,28 +223,23 @@ namespace UnitTest
|
||||
{
|
||||
LocalFileIO local;
|
||||
|
||||
AZ_TEST_ASSERT(!local.Exists(folderName.c_str()));
|
||||
AZ_TEST_ASSERT(!local.Exists(m_folderName.c_str()));
|
||||
|
||||
AZStd::string longPathCreateTest = folderName;
|
||||
longPathCreateTest.append("one");
|
||||
longPathCreateTest = PathUtil::AddSlash(longPathCreateTest);
|
||||
longPathCreateTest.append("two");
|
||||
longPathCreateTest = PathUtil::AddSlash(longPathCreateTest);
|
||||
longPathCreateTest.append("three");
|
||||
AZ::IO::Path longPathCreateTest = m_folderName / "one" / "two" / "three";
|
||||
|
||||
AZ_TEST_ASSERT(!local.Exists(longPathCreateTest.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsDirectory(longPathCreateTest.c_str()));
|
||||
AZ_TEST_ASSERT(local.CreatePath(longPathCreateTest.c_str()));
|
||||
AZ_TEST_ASSERT(local.IsDirectory(longPathCreateTest.c_str()));
|
||||
|
||||
AZ_TEST_ASSERT(!local.Exists(deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsDirectory(deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(local.CreatePath(deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(local.IsDirectory(deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(!local.Exists(m_deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsDirectory(m_deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(local.CreatePath(m_deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(local.IsDirectory(m_deepFolder.c_str()));
|
||||
|
||||
AZ_TEST_ASSERT(local.Exists(deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(local.CreatePath(deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(m_deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(local.CreatePath(m_deepFolder.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(m_deepFolder.c_str()));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -310,16 +256,19 @@ namespace UnitTest
|
||||
{
|
||||
LocalFileIO local;
|
||||
|
||||
AZ_TEST_ASSERT(!local.Exists(fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsDirectory(fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(local.CreatePath(fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(local.IsDirectory(fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(!local.Exists(m_fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsDirectory(m_fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(local.CreatePath(m_fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(local.IsDirectory(m_fileRoot.c_str()));
|
||||
|
||||
FILE* tempFile = nullptr;
|
||||
azfopen(&tempFile, file01Name.c_str(), "wb");
|
||||
|
||||
fwrite("this is just a test", 1, 19, tempFile);
|
||||
fclose(tempFile);
|
||||
constexpr auto openMode = SystemFile::OpenMode::SF_OPEN_WRITE_ONLY
|
||||
| SystemFile::OpenMode::SF_OPEN_CREATE
|
||||
| SystemFile::OpenMode::SF_OPEN_CREATE_NEW;
|
||||
SystemFile tempFile;
|
||||
tempFile.Open(m_file01Name.c_str(), openMode);
|
||||
constexpr AZStd::string_view testContent("this is just a test");
|
||||
tempFile.Write(testContent.data(), testContent.size());
|
||||
tempFile.Close();
|
||||
|
||||
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
|
||||
AZ_TEST_ASSERT(!local.Open("", AZ::IO::OpenMode::ModeWrite, fileHandle));
|
||||
@@ -327,12 +276,12 @@ namespace UnitTest
|
||||
|
||||
// test size without opening:
|
||||
AZ::u64 fs = 0;
|
||||
AZ_TEST_ASSERT(local.Size(file01Name.c_str(), fs));
|
||||
AZ_TEST_ASSERT(local.Size(m_file01Name.c_str(), fs));
|
||||
AZ_TEST_ASSERT(fs == 19);
|
||||
|
||||
fileHandle = AZ::IO::InvalidHandle;
|
||||
|
||||
AZ::u64 modTimeA = local.ModificationTime(file01Name.c_str());
|
||||
AZ::u64 modTimeA = local.ModificationTime(m_file01Name.c_str());
|
||||
AZ_TEST_ASSERT(modTimeA != 0);
|
||||
|
||||
// test invalid handle ops:
|
||||
@@ -344,14 +293,14 @@ namespace UnitTest
|
||||
AZ_TEST_ASSERT(!local.Read(fileHandle, nullptr, 0, false));
|
||||
AZ_TEST_ASSERT(!local.Tell(fileHandle, fs));
|
||||
|
||||
AZ_TEST_ASSERT(!local.Exists((file01Name + "notexist").c_str()));
|
||||
AZ_TEST_ASSERT(!local.Exists((m_file01Name.Native() + "notexist").c_str()));
|
||||
|
||||
AZ_TEST_ASSERT(local.Exists(file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsReadOnly(file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsDirectory(file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(m_file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsReadOnly(m_file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsDirectory(m_file01Name.c_str()));
|
||||
|
||||
// test reads and seeks.
|
||||
AZ_TEST_ASSERT(local.Open(file01Name.c_str(), AZ::IO::OpenMode::ModeRead, fileHandle));
|
||||
AZ_TEST_ASSERT(local.Open(m_file01Name.c_str(), AZ::IO::OpenMode::ModeRead, fileHandle));
|
||||
AZ_TEST_ASSERT(fileHandle != AZ::IO::InvalidHandle);
|
||||
|
||||
// use this again later...
|
||||
@@ -368,7 +317,7 @@ namespace UnitTest
|
||||
|
||||
// test size without opening, after its already open:
|
||||
fs = 0;
|
||||
AZ_TEST_ASSERT(local.Size(file01Name.c_str(), fs));
|
||||
AZ_TEST_ASSERT(local.Size(m_file01Name.c_str(), fs));
|
||||
AZ_TEST_ASSERT(fs == 19);
|
||||
|
||||
AZ::u64 offs = 0;
|
||||
@@ -442,22 +391,22 @@ namespace UnitTest
|
||||
#if AZ_TRAIT_AZFRAMEWORKTEST_PERFORM_CHMOD_TEST
|
||||
|
||||
#if AZ_TRAIT_USE_WINDOWS_FILE_API
|
||||
_chmod(file01Name.c_str(), _S_IREAD);
|
||||
_chmod(m_file01Name.c_str(), _S_IREAD);
|
||||
#else
|
||||
chmod(file01Name.c_str(), S_IRUSR | S_IRGRP | S_IROTH);
|
||||
chmod(m_file01Name.c_str(), S_IRUSR | S_IRGRP | S_IROTH);
|
||||
#endif
|
||||
|
||||
AZ_TEST_ASSERT(local.IsReadOnly(file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.IsReadOnly(m_file01Name.c_str()));
|
||||
|
||||
#if AZ_TRAIT_USE_WINDOWS_FILE_API
|
||||
_chmod(file01Name.c_str(), _S_IREAD | _S_IWRITE);
|
||||
_chmod(m_file01Name.c_str(), _S_IREAD | _S_IWRITE);
|
||||
#else
|
||||
chmod(file01Name.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
chmod(m_file01Name.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
AZ_TEST_ASSERT(!local.IsReadOnly(file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsReadOnly(m_file01Name.c_str()));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -474,14 +423,14 @@ namespace UnitTest
|
||||
{
|
||||
LocalFileIO local;
|
||||
|
||||
AZ_TEST_ASSERT(local.CreatePath(fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(local.IsDirectory(fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(local.CreatePath(m_fileRoot.c_str()));
|
||||
AZ_TEST_ASSERT(local.IsDirectory(m_fileRoot.c_str()));
|
||||
{
|
||||
#ifdef AZ_COMPILER_MSVC
|
||||
FILE* tempFile;
|
||||
fopen_s(&tempFile, file01Name.c_str(), "wb");
|
||||
fopen_s(&tempFile, m_file01Name.c_str(), "wb");
|
||||
#else
|
||||
FILE* tempFile = fopen(file01Name.c_str(), "wb");
|
||||
FILE* tempFile = fopen(m_file01Name.c_str(), "wb");
|
||||
#endif
|
||||
fwrite("this is just a test", 1, 19, tempFile);
|
||||
fclose(tempFile);
|
||||
@@ -489,47 +438,47 @@ namespace UnitTest
|
||||
|
||||
// make sure attributes are copied (such as modtime) even if they're copied:
|
||||
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(1500));
|
||||
AZ_TEST_ASSERT(local.Copy(file01Name.c_str(), file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Copy(m_file01Name.c_str(), m_file02Name.c_str()));
|
||||
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(1500));
|
||||
AZ_TEST_ASSERT(local.Copy(file01Name.c_str(), file03Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Copy(m_file01Name.c_str(), m_file03Name.c_str()));
|
||||
|
||||
AZ_TEST_ASSERT(local.Exists(file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(file03Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.DestroyPath(file01Name.c_str())); // you may not destroy files.
|
||||
AZ_TEST_ASSERT(!local.DestroyPath(file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.DestroyPath(file03Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(file03Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(m_file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(m_file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(m_file03Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.DestroyPath(m_file01Name.c_str())); // you may not destroy files.
|
||||
AZ_TEST_ASSERT(!local.DestroyPath(m_file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.DestroyPath(m_file03Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(m_file01Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(m_file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Exists(m_file03Name.c_str()));
|
||||
|
||||
AZ::u64 f1s = 0;
|
||||
AZ::u64 f2s = 0;
|
||||
AZ::u64 f3s = 0;
|
||||
AZ_TEST_ASSERT(local.Size(file01Name.c_str(), f1s));
|
||||
AZ_TEST_ASSERT(local.Size(file02Name.c_str(), f2s));
|
||||
AZ_TEST_ASSERT(local.Size(file03Name.c_str(), f3s));
|
||||
AZ_TEST_ASSERT(local.Size(m_file01Name.c_str(), f1s));
|
||||
AZ_TEST_ASSERT(local.Size(m_file02Name.c_str(), f2s));
|
||||
AZ_TEST_ASSERT(local.Size(m_file03Name.c_str(), f3s));
|
||||
AZ_TEST_ASSERT(f1s == f2s);
|
||||
AZ_TEST_ASSERT(f1s == f3s);
|
||||
|
||||
// Copying over top other files is allowed
|
||||
|
||||
SystemFile file;
|
||||
EXPECT_TRUE(file.Open(file01Name.c_str(), SystemFile::SF_OPEN_WRITE_ONLY));
|
||||
EXPECT_TRUE(file.Open(m_file01Name.c_str(), SystemFile::SF_OPEN_WRITE_ONLY));
|
||||
file.Write("this is just a test that is longer", 34);
|
||||
file.Close();
|
||||
|
||||
// make sure attributes are copied (such as modtime) even if they're copied:
|
||||
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(1500));
|
||||
|
||||
EXPECT_TRUE(local.Copy(file01Name.c_str(), file02Name.c_str()));
|
||||
EXPECT_TRUE(local.Copy(m_file01Name.c_str(), m_file02Name.c_str()));
|
||||
|
||||
f1s = 0;
|
||||
f2s = 0;
|
||||
f3s = 0;
|
||||
EXPECT_TRUE(local.Size(file01Name.c_str(), f1s));
|
||||
EXPECT_TRUE(local.Size(file02Name.c_str(), f2s));
|
||||
EXPECT_TRUE(local.Size(file03Name.c_str(), f3s));
|
||||
EXPECT_TRUE(local.Size(m_file01Name.c_str(), f1s));
|
||||
EXPECT_TRUE(local.Size(m_file02Name.c_str(), f2s));
|
||||
EXPECT_TRUE(local.Size(m_file03Name.c_str(), f3s));
|
||||
EXPECT_EQ(f1s, f2s);
|
||||
EXPECT_NE(f1s, f3s);
|
||||
}
|
||||
@@ -552,37 +501,37 @@ namespace UnitTest
|
||||
|
||||
AZ::u64 modTimeC = 0;
|
||||
AZ::u64 modTimeD = 0;
|
||||
modTimeC = local.ModificationTime(file02Name.c_str());
|
||||
modTimeD = local.ModificationTime(file03Name.c_str());
|
||||
modTimeC = local.ModificationTime(m_file02Name.c_str());
|
||||
modTimeD = local.ModificationTime(m_file03Name.c_str());
|
||||
|
||||
// make sure modtimes are in ascending order (at least)
|
||||
AZ_TEST_ASSERT(modTimeD >= modTimeC);
|
||||
|
||||
// now touch some of the files. This is also how we test append mode, and write mode.
|
||||
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
|
||||
AZ_TEST_ASSERT(local.Open(file02Name.c_str(), AZ::IO::OpenMode::ModeAppend | AZ::IO::OpenMode::ModeBinary, fileHandle));
|
||||
AZ_TEST_ASSERT(local.Open(m_file02Name.c_str(), AZ::IO::OpenMode::ModeAppend | AZ::IO::OpenMode::ModeBinary, fileHandle));
|
||||
AZ_TEST_ASSERT(fileHandle != AZ::IO::InvalidHandle);
|
||||
AZ_TEST_ASSERT(local.Write(fileHandle, "more", 4));
|
||||
AZ_TEST_ASSERT(local.Close(fileHandle));
|
||||
|
||||
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(1500));
|
||||
// No-append-mode
|
||||
AZ_TEST_ASSERT(local.Open(file03Name.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary, fileHandle));
|
||||
AZ_TEST_ASSERT(local.Open(m_file03Name.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary, fileHandle));
|
||||
AZ_TEST_ASSERT(fileHandle != AZ::IO::InvalidHandle);
|
||||
AZ_TEST_ASSERT(local.Write(fileHandle, "more", 4));
|
||||
AZ_TEST_ASSERT(local.Close(fileHandle));
|
||||
|
||||
modTimeC = local.ModificationTime(file02Name.c_str());
|
||||
modTimeD = local.ModificationTime(file03Name.c_str());
|
||||
modTimeC = local.ModificationTime(m_file02Name.c_str());
|
||||
modTimeD = local.ModificationTime(m_file03Name.c_str());
|
||||
|
||||
AZ_TEST_ASSERT(modTimeD > modTimeC);
|
||||
|
||||
AZ::u64 f1s = 0;
|
||||
AZ::u64 f2s = 0;
|
||||
AZ::u64 f3s = 0;
|
||||
AZ_TEST_ASSERT(local.Size(file01Name.c_str(), f1s));
|
||||
AZ_TEST_ASSERT(local.Size(file02Name.c_str(), f2s));
|
||||
AZ_TEST_ASSERT(local.Size(file03Name.c_str(), f3s));
|
||||
AZ_TEST_ASSERT(local.Size(m_file01Name.c_str(), f1s));
|
||||
AZ_TEST_ASSERT(local.Size(m_file02Name.c_str(), f2s));
|
||||
AZ_TEST_ASSERT(local.Size(m_file03Name.c_str(), f3s));
|
||||
AZ_TEST_ASSERT(f2s == f1s + 4);
|
||||
AZ_TEST_ASSERT(f3s == 4);
|
||||
}
|
||||
@@ -603,8 +552,8 @@ namespace UnitTest
|
||||
|
||||
CreateTestFiles();
|
||||
|
||||
AZStd::vector<AZStd::string> resultFiles;
|
||||
bool foundOK = local.FindFiles(fileRoot.c_str(), "*",
|
||||
AZStd::vector<AZ::IO::Path> resultFiles;
|
||||
bool foundOK = local.FindFiles(m_fileRoot.c_str(), "*",
|
||||
[&](const char* filePath) -> bool
|
||||
{
|
||||
resultFiles.push_back(filePath);
|
||||
@@ -616,7 +565,7 @@ namespace UnitTest
|
||||
|
||||
resultFiles.clear();
|
||||
|
||||
foundOK = local.FindFiles(fileRoot.c_str(), "*",
|
||||
foundOK = local.FindFiles(m_fileRoot.c_str(), "*",
|
||||
[&](const char* filePath) -> bool
|
||||
{
|
||||
resultFiles.push_back(filePath);
|
||||
@@ -627,7 +576,7 @@ namespace UnitTest
|
||||
AZ_TEST_ASSERT(resultFiles.size() == 3);
|
||||
|
||||
// note: following tests accumulate more files without clearing resultfiles.
|
||||
foundOK = local.FindFiles(fileRoot.c_str(), "*.txt",
|
||||
foundOK = local.FindFiles(m_fileRoot.c_str(), "*.txt",
|
||||
[&](const char* filePath) -> bool
|
||||
{
|
||||
resultFiles.push_back(filePath);
|
||||
@@ -637,7 +586,7 @@ namespace UnitTest
|
||||
AZ_TEST_ASSERT(foundOK);
|
||||
AZ_TEST_ASSERT(resultFiles.size() == 4);
|
||||
|
||||
foundOK = local.FindFiles(fileRoot.c_str(), "file*.asdf",
|
||||
foundOK = local.FindFiles(m_fileRoot.c_str(), "file*.asdf",
|
||||
[&](const char* filePath) -> bool
|
||||
{
|
||||
resultFiles.push_back(filePath);
|
||||
@@ -647,7 +596,7 @@ namespace UnitTest
|
||||
AZ_TEST_ASSERT(foundOK);
|
||||
AZ_TEST_ASSERT(resultFiles.size() == 5);
|
||||
|
||||
foundOK = local.FindFiles(fileRoot.c_str(), "asaf.asdf",
|
||||
foundOK = local.FindFiles(m_fileRoot.c_str(), "asaf.asdf",
|
||||
[&](const char* filePath) -> bool
|
||||
{
|
||||
resultFiles.push_back(filePath);
|
||||
@@ -660,7 +609,7 @@ namespace UnitTest
|
||||
resultFiles.clear();
|
||||
|
||||
// test to make sure directories show up:
|
||||
foundOK = local.FindFiles(deepFolder.c_str(), "*",
|
||||
foundOK = local.FindFiles(m_deepFolder.c_str(), "*",
|
||||
[&](const char* filePath) -> bool
|
||||
{
|
||||
resultFiles.push_back(filePath);
|
||||
@@ -668,11 +617,11 @@ namespace UnitTest
|
||||
});
|
||||
|
||||
// canonicalize the name in the same way that find does.
|
||||
//AZStd::replace() extraFolder.replace('\\', '/'); FIXME PPATEL
|
||||
//AZStd::replace() m_extraFolder.replace('\\', '/'); FIXME PPATEL
|
||||
|
||||
AZ_TEST_ASSERT(foundOK);
|
||||
AZ_TEST_ASSERT(resultFiles.size() == 1);
|
||||
AZ_TEST_ASSERT(resultFiles[0] == extraFolder);
|
||||
AZ_TEST_ASSERT(resultFiles[0] == m_extraFolder);
|
||||
resultFiles.clear();
|
||||
foundOK = local.FindFiles("o:137787621!@#$%^&&**())_+[])_", "asaf.asdf",
|
||||
[&](const char* filePath) -> bool
|
||||
@@ -684,13 +633,13 @@ namespace UnitTest
|
||||
AZ_TEST_ASSERT(!foundOK);
|
||||
AZ_TEST_ASSERT(resultFiles.size() == 0);
|
||||
|
||||
AZStd::string file04Name = fileRoot + "test.wha";
|
||||
AZ::IO::Path file04Name = m_fileRoot / "test.wha";
|
||||
// test rename
|
||||
AZ_TEST_ASSERT(local.Rename(file03Name.c_str(), file04Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.Rename(file03Name.c_str(), file04Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Rename(m_file03Name.c_str(), file04Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.Rename(m_file03Name.c_str(), file04Name.c_str()));
|
||||
AZ_TEST_ASSERT(local.Rename(file04Name.c_str(), file04Name.c_str())); // this is valid and ok
|
||||
AZ_TEST_ASSERT(local.Exists(file04Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.Exists(file03Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.Exists(m_file03Name.c_str()));
|
||||
AZ_TEST_ASSERT(!local.IsDirectory(file04Name.c_str()));
|
||||
|
||||
AZ::u64 f3s = 0;
|
||||
@@ -698,8 +647,8 @@ namespace UnitTest
|
||||
AZ_TEST_ASSERT(f3s == 19);
|
||||
|
||||
// deep destroy directory:
|
||||
AZ_TEST_ASSERT(local.DestroyPath(folderName.c_str()));
|
||||
AZ_TEST_ASSERT(!local.Exists(folderName.c_str()));
|
||||
AZ_TEST_ASSERT(local.DestroyPath(m_folderName.c_str()));
|
||||
AZ_TEST_ASSERT(!local.Exists(m_folderName.c_str()));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -715,7 +664,7 @@ namespace UnitTest
|
||||
AZ::IO::LocalFileIO local;
|
||||
|
||||
// test aliases
|
||||
local.SetAlias("@test@", folderName.c_str());
|
||||
local.SetAlias("@test@", m_folderName.c_str());
|
||||
const char* testDest1 = local.GetAlias("@test@");
|
||||
AZ_TEST_ASSERT(testDest1 != nullptr);
|
||||
const char* testDest2 = local.GetAlias("@NOPE@");
|
||||
@@ -725,18 +674,18 @@ namespace UnitTest
|
||||
|
||||
// test resolving
|
||||
const char* aliasTestPath = "@test@\\some\\path\\somefile.txt";
|
||||
char aliasResolvedPath[AZ_MAX_PATH_LEN];
|
||||
bool resolveDidWork = local.ResolvePath(aliasTestPath, aliasResolvedPath, AZ_MAX_PATH_LEN);
|
||||
char aliasResolvedPath[AZ::IO::MaxPathLength];
|
||||
bool resolveDidWork = local.ResolvePath(aliasTestPath, aliasResolvedPath, AZ::IO::MaxPathLength);
|
||||
AZ_TEST_ASSERT(resolveDidWork);
|
||||
AZStd::string expectedResolvedPath = folderName + "some/path/somefile.txt";
|
||||
AZ::IO::Path expectedResolvedPath = m_folderName / "some/path/somefile.txt";
|
||||
AZ_TEST_ASSERT(aliasResolvedPath == expectedResolvedPath);
|
||||
|
||||
// more resolve path tests with invalid inputs
|
||||
const char* testPath = nullptr;
|
||||
char* testResolvedPath = nullptr;
|
||||
resolveDidWork = local.ResolvePath(testPath, aliasResolvedPath, AZ_MAX_PATH_LEN);
|
||||
resolveDidWork = local.ResolvePath(testPath, aliasResolvedPath, AZ::IO::MaxPathLength);
|
||||
AZ_TEST_ASSERT(!resolveDidWork);
|
||||
resolveDidWork = local.ResolvePath(aliasTestPath, testResolvedPath, AZ_MAX_PATH_LEN);
|
||||
resolveDidWork = local.ResolvePath(aliasTestPath, testResolvedPath, AZ::IO::MaxPathLength);
|
||||
AZ_TEST_ASSERT(!resolveDidWork);
|
||||
resolveDidWork = local.ResolvePath(aliasTestPath, aliasResolvedPath, 0);
|
||||
AZ_TEST_ASSERT(!resolveDidWork);
|
||||
@@ -751,7 +700,7 @@ namespace UnitTest
|
||||
|
||||
// Test that sending in a too small output path fails,
|
||||
// if the output buffer is too small to hold the resolved path
|
||||
size_t SMALLER_THAN_FINAL_RESOLVED_PATH = expectedResolvedPath.length() - 1;
|
||||
size_t SMALLER_THAN_FINAL_RESOLVED_PATH = expectedResolvedPath.Native().length() - 1;
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
resolveDidWork = local.ResolvePath(aliasTestPath, aliasResolvedPath, SMALLER_THAN_FINAL_RESOLVED_PATH);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
|
||||
@@ -766,22 +715,23 @@ namespace UnitTest
|
||||
TEST_F(AliasTest, ResolvePath_PathViewOverload_Succeeds)
|
||||
{
|
||||
AZ::IO::LocalFileIO local;
|
||||
local.SetAlias("@test@", folderName.c_str());
|
||||
local.SetAlias("@test@", m_folderName.c_str());
|
||||
AZ::IO::PathView aliasTestPath = "@test@\\some\\path\\somefile.txt";
|
||||
AZ::IO::FixedMaxPath aliasResolvedPath;
|
||||
ASSERT_TRUE(local.ResolvePath(aliasResolvedPath, aliasTestPath));
|
||||
const auto expectedResolvedPath = AZ::IO::FixedMaxPathString::format("%ssome/path/somefile.txt", folderName.c_str());
|
||||
EXPECT_STREQ(expectedResolvedPath.c_str(), aliasResolvedPath.c_str());
|
||||
AZ::IO::Path expectedResolvedPath = m_folderName / "some" / "path" / "somefile.txt";
|
||||
|
||||
EXPECT_EQ(expectedResolvedPath, aliasResolvedPath);
|
||||
|
||||
AZStd::optional<AZ::IO::FixedMaxPath> optionalResolvedPath = local.ResolvePath(aliasTestPath);
|
||||
ASSERT_TRUE(optionalResolvedPath);
|
||||
EXPECT_STREQ(expectedResolvedPath.c_str(), optionalResolvedPath->c_str());
|
||||
EXPECT_EQ(expectedResolvedPath, optionalResolvedPath.value());
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, ResolvePath_PathViewOverloadWithEmptyPath_Fails)
|
||||
{
|
||||
AZ::IO::LocalFileIO local;
|
||||
local.SetAlias("@test@", folderName.c_str());
|
||||
local.SetAlias("@test@", m_folderName.c_str());
|
||||
AZ::IO::FixedMaxPath aliasResolvedPath;
|
||||
EXPECT_FALSE(local.ResolvePath(aliasResolvedPath, {}));
|
||||
}
|
||||
@@ -860,24 +810,23 @@ namespace UnitTest
|
||||
{
|
||||
LocalFileIO localFileIO;
|
||||
AZ::IO::FileIOBase::SetInstance(&localFileIO);
|
||||
AZStd::string path;
|
||||
AzFramework::StringFunc::Path::GetFullPath(file01Name.c_str(), path);
|
||||
AZ::IO::Path path = m_file01Name.ParentPath();
|
||||
AZ_TEST_ASSERT(localFileIO.CreatePath(path.c_str()));
|
||||
AzFramework::StringFunc::Path::GetFullPath(file02Name.c_str(), path);
|
||||
path = m_file01Name.ParentPath();
|
||||
AZ_TEST_ASSERT(localFileIO.CreatePath(path.c_str()));
|
||||
|
||||
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
|
||||
localFileIO.Open(file01Name.c_str(), OpenMode::ModeWrite | OpenMode::ModeText, fileHandle);
|
||||
localFileIO.Open(m_file01Name.c_str(), OpenMode::ModeWrite | OpenMode::ModeText, fileHandle);
|
||||
localFileIO.Write(fileHandle, "DummyFile", 9);
|
||||
localFileIO.Close(fileHandle);
|
||||
|
||||
AZ::IO::HandleType fileHandle1 = AZ::IO::InvalidHandle;
|
||||
localFileIO.Open(file02Name.c_str(), OpenMode::ModeWrite | OpenMode::ModeText, fileHandle1);
|
||||
localFileIO.Open(m_file02Name.c_str(), OpenMode::ModeWrite | OpenMode::ModeText, fileHandle1);
|
||||
localFileIO.Write(fileHandle1, "TestFile", 8);
|
||||
localFileIO.Close(fileHandle1);
|
||||
|
||||
fileHandle1 = AZ::IO::InvalidHandle;
|
||||
localFileIO.Open(file02Name.c_str(), OpenMode::ModeRead | OpenMode::ModeText, fileHandle1);
|
||||
localFileIO.Open(m_file02Name.c_str(), OpenMode::ModeRead | OpenMode::ModeText, fileHandle1);
|
||||
static const size_t testStringLen = 256;
|
||||
char testString[testStringLen] = { 0 };
|
||||
localFileIO.Read(fileHandle1, testString, testStringLen);
|
||||
@@ -885,50 +834,50 @@ namespace UnitTest
|
||||
AZ_TEST_ASSERT(strncmp(testString, "TestFile", 8) == 0);
|
||||
|
||||
// try swapping files when none of the files are in use
|
||||
AZ_TEST_ASSERT(AZ::IO::SmartMove(file01Name.c_str(), file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(AZ::IO::SmartMove(m_file01Name.c_str(), m_file02Name.c_str()));
|
||||
|
||||
fileHandle1 = AZ::IO::InvalidHandle;
|
||||
localFileIO.Open(file02Name.c_str(), OpenMode::ModeRead | OpenMode::ModeText, fileHandle1);
|
||||
localFileIO.Open(m_file02Name.c_str(), OpenMode::ModeRead | OpenMode::ModeText, fileHandle1);
|
||||
testString[0] = '\0';
|
||||
localFileIO.Read(fileHandle1, testString, testStringLen);
|
||||
localFileIO.Close(fileHandle1);
|
||||
AZ_TEST_ASSERT(strncmp(testString, "DummyFile", 9) == 0);
|
||||
|
||||
//try swapping files when source file is not present, this should fail
|
||||
AZ_TEST_ASSERT(!AZ::IO::SmartMove(file01Name.c_str(), file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(!AZ::IO::SmartMove(m_file01Name.c_str(), m_file02Name.c_str()));
|
||||
|
||||
fileHandle = AZ::IO::InvalidHandle;
|
||||
localFileIO.Open(file01Name.c_str(), OpenMode::ModeWrite | OpenMode::ModeText, fileHandle);
|
||||
localFileIO.Open(m_file01Name.c_str(), OpenMode::ModeWrite | OpenMode::ModeText, fileHandle);
|
||||
localFileIO.Write(fileHandle, "TestFile", 8);
|
||||
localFileIO.Close(fileHandle);
|
||||
|
||||
#if AZ_TRAIT_AZFRAMEWORKTEST_MOVE_WHILE_OPEN
|
||||
fileHandle1 = AZ::IO::InvalidHandle;
|
||||
localFileIO.Open(file02Name.c_str(), OpenMode::ModeRead | OpenMode::ModeText, fileHandle1);
|
||||
localFileIO.Open(m_file02Name.c_str(), OpenMode::ModeRead | OpenMode::ModeText, fileHandle1);
|
||||
testString[0] = '\0';
|
||||
localFileIO.Read(fileHandle1, testString, testStringLen);
|
||||
|
||||
// try swapping files when the destination file is open for read only,
|
||||
// since window is unable to move files that are open for read, this will fail.
|
||||
AZ_TEST_ASSERT(!AZ::IO::SmartMove(file01Name.c_str(), file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(!AZ::IO::SmartMove(m_file01Name.c_str(), m_file02Name.c_str()));
|
||||
localFileIO.Close(fileHandle1);
|
||||
#endif
|
||||
fileHandle = AZ::IO::InvalidHandle;
|
||||
localFileIO.Open(file01Name.c_str(), OpenMode::ModeRead | OpenMode::ModeText, fileHandle);
|
||||
localFileIO.Open(m_file01Name.c_str(), OpenMode::ModeRead | OpenMode::ModeText, fileHandle);
|
||||
|
||||
// try swapping files when the source file is open for read only
|
||||
AZ_TEST_ASSERT(AZ::IO::SmartMove(file01Name.c_str(), file02Name.c_str()));
|
||||
AZ_TEST_ASSERT(AZ::IO::SmartMove(m_file01Name.c_str(), m_file02Name.c_str()));
|
||||
localFileIO.Close(fileHandle);
|
||||
|
||||
fileHandle1 = AZ::IO::InvalidHandle;
|
||||
localFileIO.Open(file02Name.c_str(), OpenMode::ModeRead | OpenMode::ModeText, fileHandle1);
|
||||
localFileIO.Open(m_file02Name.c_str(), OpenMode::ModeRead | OpenMode::ModeText, fileHandle1);
|
||||
testString[0] = '\0';
|
||||
localFileIO.Read(fileHandle1, testString, testStringLen);
|
||||
AZ_TEST_ASSERT(strncmp(testString, "TestFile", 8) == 0);
|
||||
localFileIO.Close(fileHandle1);
|
||||
|
||||
localFileIO.Remove(file01Name.c_str());
|
||||
localFileIO.Remove(file02Name.c_str());
|
||||
localFileIO.Remove(m_file01Name.c_str());
|
||||
localFileIO.Remove(m_file02Name.c_str());
|
||||
localFileIO.DestroyPath(m_root.c_str());
|
||||
|
||||
AZ::IO::FileIOBase::SetInstance(nullptr);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include <ostream>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
|
||||
namespace AZ::IO
|
||||
{
|
||||
void PrintTo(const AZ::IO::PathView& path, ::std::ostream* os)
|
||||
{
|
||||
*os << "path: " << AZ::IO::Path(path.Native(), AZ::IO::PosixPathSeparator).MakePreferred().c_str();
|
||||
}
|
||||
|
||||
void PrintTo(const AZ::IO::Path& path, ::std::ostream* os)
|
||||
{
|
||||
*os << "path: " << AZ::IO::Path(path.Native(), AZ::IO::PosixPathSeparator).MakePreferred().c_str();
|
||||
}
|
||||
|
||||
void PrintTo(const AZ::IO::FixedMaxPath& path, ::std::ostream* os)
|
||||
{
|
||||
*os << "path: " << AZ::IO::FixedMaxPath(path.Native(), AZ::IO::PosixPathSeparator).MakePreferred().c_str();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <iosfwd>
|
||||
#include <AzCore/IO/Path/Path_fwd.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
template<class Element, class Traits, class Allocator>
|
||||
class basic_string;
|
||||
|
||||
template <class Element, class Traits>
|
||||
class basic_string_view;
|
||||
|
||||
template <class Element, size_t MaxElementCount, class Traits>
|
||||
class basic_fixed_string;
|
||||
|
||||
template<class Element, class Traits, class Allocator>
|
||||
void PrintTo(const AZStd::basic_string<Element, Traits, Allocator>& value, ::std::ostream* os);
|
||||
template<class Element, class Traits>
|
||||
void PrintTo(const AZStd::basic_string_view<Element, Traits>& value, ::std::ostream* os);
|
||||
template <class Element, size_t MaxElementCount, class Traits>
|
||||
void PrintTo(const AZStd::basic_fixed_string<Element, MaxElementCount, Traits>& value, ::std::ostream* os);
|
||||
}
|
||||
|
||||
namespace AZ::IO
|
||||
{
|
||||
// Add Googletest printers for the AZ::IO::Path classes
|
||||
void PrintTo(const AZ::IO::PathView& path, ::std::ostream* os);
|
||||
void PrintTo(const AZ::IO::Path& path, ::std::ostream* os);
|
||||
void PrintTo(const AZ::IO::FixedMaxPath& path, ::std::ostream* os);
|
||||
}
|
||||
|
||||
#include <AzTest/Printers.inl>
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <ostream>
|
||||
#include <string_view>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
template<class Element, class Traits, class Allocator>
|
||||
void PrintTo(const AZStd::basic_string<Element, Traits, Allocator>& value, ::std::ostream* os)
|
||||
{
|
||||
*os << value.c_str();
|
||||
}
|
||||
|
||||
template<class Element, class Traits>
|
||||
void PrintTo(const AZStd::basic_string_view<Element, Traits>& value, ::std::ostream* os)
|
||||
{
|
||||
*os << ::std::string_view(value.data(), value.size());
|
||||
}
|
||||
|
||||
template <class Element, size_t MaxElementCount, class Traits>
|
||||
void PrintTo(const AZStd::basic_fixed_string<Element, MaxElementCount, Traits>& value, ::std::ostream* os)
|
||||
{
|
||||
*os << value.c_str();
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/Outcome/Outcome.h>
|
||||
#include <AzTest/Printers.h>
|
||||
namespace AZ
|
||||
{
|
||||
namespace Test
|
||||
|
||||
@@ -11,6 +11,9 @@ set(FILES
|
||||
AzTest.cpp
|
||||
ColorizedOutput.cpp
|
||||
Platform.h
|
||||
Printers.h
|
||||
Printers.inl
|
||||
Printers.cpp
|
||||
Utils.h
|
||||
Utils.cpp
|
||||
GemTestEnvironment.cpp
|
||||
|
||||
+9
-9
@@ -22,22 +22,22 @@ namespace AzToolsFramework
|
||||
|
||||
virtual ~ViewportEditorModeTrackerInterface() = default;
|
||||
|
||||
//! Activates the specified editor mode for the specified viewport.
|
||||
//! Activates the specified editor mode for the specified viewport editor mode tracker.
|
||||
virtual AZ::Outcome<void, AZStd::string> ActivateMode(
|
||||
const ViewportEditorModeInfo& viewportEditorModeInfo, ViewportEditorMode mode) = 0;
|
||||
const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo, ViewportEditorMode mode) = 0;
|
||||
|
||||
//! Deactivates the specified editor mode for the specified viewport.
|
||||
//! Deactivates the specified editor mode for the specified viewport editor mode tracker.
|
||||
virtual AZ::Outcome<void, AZStd::string> DeactivateMode(
|
||||
const ViewportEditorModeInfo& viewportEditorModeInfo, ViewportEditorMode mode) = 0;
|
||||
const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo, ViewportEditorMode mode) = 0;
|
||||
|
||||
//! Attempts to retrieve the editor mode state for the specified viewport, otherwise returns nullptr.
|
||||
virtual const ViewportEditorModesInterface* GetViewportEditorModes(const ViewportEditorModeInfo& viewportEditorModeInfo) const = 0;
|
||||
//! Attempts to retrieve the editor mode state for the specified viewport editor mode tracker, otherwise returns nullptr.
|
||||
virtual const ViewportEditorModesInterface* GetViewportEditorModes(const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo) const = 0;
|
||||
|
||||
//! Returns the number of viewports currently being tracked.
|
||||
//! Returns the number of viewport editor mode trackers.
|
||||
virtual size_t GetTrackedViewportCount() const = 0;
|
||||
|
||||
//! Returns true if the specified viewport is being tracked, otherwise false.
|
||||
virtual bool IsViewportModeTracked(const ViewportEditorModeInfo& viewportEditorModeInfo) const = 0;
|
||||
//! Returns true if viewport editor modes are being tracked for the specified od, otherwise false.
|
||||
virtual bool IsViewportModeTracked(const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo) const = 0;
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
|
||||
+6
-6
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/Event.h>
|
||||
#include <AzFramework/Viewport/ViewportId.h>
|
||||
#include <AzFramework/Entity/EntityContextBus.h>
|
||||
#include <AzToolsFramework/ViewportUi/ViewportUiRequestBus.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
@@ -23,11 +23,11 @@ namespace AzToolsFramework
|
||||
Pick
|
||||
};
|
||||
|
||||
//! Viewport identifier and other relevant viewport data.
|
||||
struct ViewportEditorModeInfo
|
||||
//! Viewport editor mode tracker identifier and other relevant data.
|
||||
struct ViewportEditorModeTrackerInfo
|
||||
{
|
||||
using IdType = AzFramework::ViewportId;
|
||||
IdType m_id = ViewportUi::DefaultViewportId; //!< The unique identifier for a given viewport.
|
||||
using IdType = AzFramework::EntityContextId;
|
||||
IdType m_id = AzFramework::EntityContextId::CreateNull(); //!< The unique identifier for a given viewport editor mode tracker.
|
||||
};
|
||||
|
||||
//! Interface for the editor modes of a given viewport.
|
||||
@@ -49,7 +49,7 @@ namespace AzToolsFramework
|
||||
// EBusTraits overrides
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = ViewportEditorModeInfo::IdType;
|
||||
using BusIdType = ViewportEditorModeTrackerInfo::IdType;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Notifies subscribers of the a given viewport to the activation of the specified editor mode.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
constexpr const char s_traceName[] = "ArchiveComponent";
|
||||
[[maybe_unused]] constexpr const char s_traceName[] = "ArchiveComponent";
|
||||
constexpr AZ::u32 s_compressionMethod = AZ::IO::INestedArchive::METHOD_DEFLATE;
|
||||
constexpr AZ::s32 s_compressionLevel = AZ::IO::INestedArchive::LEVEL_NORMAL;
|
||||
constexpr CompressionCodec::Codec s_compressionCodec = CompressionCodec::Codec::ZLIB;
|
||||
|
||||
+1
-1
@@ -290,7 +290,7 @@ namespace AzToolsFramework
|
||||
absoluteIconPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / TreeIconPathOneChild;
|
||||
break;
|
||||
}
|
||||
bool pixmapLoadedSuccess = pixmap.load(absoluteIconPath.c_str());
|
||||
[[maybe_unused]] bool pixmapLoadedSuccess = pixmap.load(absoluteIconPath.c_str());
|
||||
AZ_Assert(pixmapLoadedSuccess, "Error loading Branch Icons in SearchEntryDelegate");
|
||||
|
||||
m_branchIcons[static_cast<EntryBranchType>(branchType)] = pixmap;
|
||||
|
||||
+2
-2
@@ -218,7 +218,7 @@ namespace AzToolsFramework
|
||||
// this call to activate the component mode editor state should eventually replace the bus call in
|
||||
// ComponentModeCollection::BeginComponentMode() to EditorComponentModeNotifications::EnteredComponentMode
|
||||
// such that all of the notifications for activating/deactivating the different editor modes are in a central location
|
||||
m_viewportEditorModeTracker->ActivateMode({ /* DefaultViewportId */ }, ViewportEditorMode::Component);
|
||||
m_viewportEditorModeTracker->ActivateMode({ GetEntityContextId() }, ViewportEditorMode::Component);
|
||||
|
||||
// enable actions for the first/primary ComponentMode
|
||||
// note: if multiple ComponentModes are activated at the same time, actions
|
||||
@@ -296,7 +296,7 @@ namespace AzToolsFramework
|
||||
// this call to deactivate the component mode editor state should eventually replace the bus call in
|
||||
// ComponentModeCollection::EndComponentMode() to EditorComponentModeNotifications::LeftComponentMode
|
||||
// such that all of the notifications for activating/deactivating the different editor modes are in a central location
|
||||
m_viewportEditorModeTracker->DeactivateMode({ /* DefaultViewportId */ }, ViewportEditorMode::Component);
|
||||
m_viewportEditorModeTracker->DeactivateMode({ GetEntityContextId() }, ViewportEditorMode::Component);
|
||||
|
||||
// clear stored modes and builders for this ComponentMode
|
||||
// TLDR: avoid 'use after free' error
|
||||
|
||||
+21
-17
@@ -18,8 +18,9 @@
|
||||
#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/Instance/InstanceEntityIdMapper.h>
|
||||
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabLoader.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
|
||||
@@ -317,17 +318,18 @@ namespace AzToolsFramework
|
||||
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Prefab::Instance>>&& nestedPrefabInstances,
|
||||
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder)
|
||||
{
|
||||
AZStd::unique_ptr<Prefab::Instance> createdPrefabInstance =
|
||||
m_prefabSystemComponent->CreatePrefab(entities, AZStd::move(nestedPrefabInstances), filePath, nullptr, false);
|
||||
if (!instanceToParentUnder)
|
||||
{
|
||||
instanceToParentUnder = *m_rootInstance;
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<Prefab::Instance> createdPrefabInstance = m_prefabSystemComponent->CreatePrefab(
|
||||
entities, AZStd::move(nestedPrefabInstances), filePath, nullptr, instanceToParentUnder, false);
|
||||
|
||||
if (createdPrefabInstance)
|
||||
{
|
||||
if (!instanceToParentUnder)
|
||||
{
|
||||
instanceToParentUnder = *m_rootInstance;
|
||||
}
|
||||
|
||||
Prefab::Instance& addedInstance = instanceToParentUnder->get().AddInstance(AZStd::move(createdPrefabInstance));
|
||||
Prefab::Instance& addedInstance = instanceToParentUnder->get().AddInstance(
|
||||
AZStd::move(createdPrefabInstance));
|
||||
AZ::Entity* containerEntity = addedInstance.m_containerEntity.get();
|
||||
containerEntity->AddComponent(aznew Prefab::EditorPrefabComponent());
|
||||
HandleEntitiesAdded({containerEntity});
|
||||
@@ -341,16 +343,18 @@ namespace AzToolsFramework
|
||||
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)
|
||||
{
|
||||
if (!instanceToParentUnder)
|
||||
{
|
||||
instanceToParentUnder = *m_rootInstance;
|
||||
}
|
||||
instanceToParentUnder = *m_rootInstance;
|
||||
}
|
||||
|
||||
Prefab::Instance& addedInstance = instanceToParentUnder->get().AddInstance(AZStd::move(createdPrefabInstance));
|
||||
AZStd::unique_ptr<Prefab::Instance> instantiatedPrefabInstance =
|
||||
m_prefabSystemComponent->InstantiatePrefab(filePath, instanceToParentUnder);
|
||||
|
||||
if (instantiatedPrefabInstance)
|
||||
{
|
||||
Prefab::Instance& addedInstance = instanceToParentUnder->get().AddInstance(
|
||||
AZStd::move(instantiatedPrefabInstance));
|
||||
HandleEntitiesAdded({addedInstance.m_containerEntity.get()});
|
||||
return addedInstance;
|
||||
}
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerInterface.h>
|
||||
#include <AzToolsFramework/FocusMode/FocusModeNotificationBus.h>
|
||||
#include <AzToolsFramework/FocusMode/FocusModeSystemComponent.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerInterface.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -79,11 +79,11 @@ namespace AzToolsFramework
|
||||
{
|
||||
if (!m_focusRoot.IsValid() && entityId.IsValid())
|
||||
{
|
||||
tracker->ActivateMode({ /* DefaultViewportId */ }, ViewportEditorMode::Focus);
|
||||
tracker->ActivateMode({ GetEntityContextId() }, ViewportEditorMode::Focus);
|
||||
}
|
||||
else if (m_focusRoot.IsValid() && !entityId.IsValid())
|
||||
{
|
||||
tracker->DeactivateMode({ /* DefaultViewportId */ }, ViewportEditorMode::Focus);
|
||||
tracker->DeactivateMode({ GetEntityContextId() }, ViewportEditorMode::Focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
#include <AzToolsFramework/Prefab/Instance/Instance.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
|
||||
#include <AzToolsFramework/Prefab/Instance/InstanceEntityIdMapper.h>
|
||||
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
|
||||
#include <AzToolsFramework/Prefab/Instance/TemplateInstanceMapperInterface.h>
|
||||
|
||||
@@ -28,24 +29,52 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
Instance::Instance(AZStd::unique_ptr<AZ::Entity> containerEntity)
|
||||
: Instance(AZStd::move(containerEntity), AZStd::nullopt, GenerateInstanceAlias())
|
||||
{
|
||||
m_instanceEntityMapper = AZ::Interface<InstanceEntityMapperInterface>::Get();
|
||||
}
|
||||
|
||||
Instance::Instance(InstanceOptionalReference parent)
|
||||
: Instance(nullptr, parent, GenerateInstanceAlias())
|
||||
{
|
||||
}
|
||||
|
||||
Instance::Instance(InstanceAlias alias)
|
||||
: Instance(nullptr, AZStd::nullopt, AZStd::move(alias))
|
||||
{
|
||||
}
|
||||
|
||||
Instance::Instance(AZStd::unique_ptr<AZ::Entity> containerEntity, InstanceOptionalReference parent)
|
||||
: Instance(AZStd::move(containerEntity), parent, GenerateInstanceAlias())
|
||||
{
|
||||
}
|
||||
|
||||
Instance::Instance(AZStd::unique_ptr<AZ::Entity> containerEntity, InstanceOptionalReference parent, InstanceAlias alias)
|
||||
: m_parent(parent.has_value() ? &parent->get() : nullptr)
|
||||
, m_alias(AZStd::move(alias))
|
||||
, m_containerEntity(containerEntity ? AZStd::move(containerEntity) : AZStd::make_unique<AZ::Entity>())
|
||||
, m_instanceEntityMapper(AZ::Interface<InstanceEntityMapperInterface>::Get())
|
||||
, m_templateInstanceMapper(AZ::Interface<TemplateInstanceMapperInterface>::Get())
|
||||
{
|
||||
AZ_Assert(m_instanceEntityMapper,
|
||||
"Instance Entity Mapper Interface could not be found. "
|
||||
"It is a requirement for the Prefab Instance class. "
|
||||
"Check that it is being correctly initialized.");
|
||||
|
||||
m_templateInstanceMapper = AZ::Interface<TemplateInstanceMapperInterface>::Get();
|
||||
|
||||
AZ_Assert(m_templateInstanceMapper,
|
||||
"Template Instance Mapper Interface could not be found. "
|
||||
"It is a requirement for the Prefab Instance class. "
|
||||
"Check that it is being correctly initialized.");
|
||||
|
||||
m_alias = GenerateInstanceAlias();
|
||||
m_containerEntity = containerEntity ? AZStd::move(containerEntity)
|
||||
: AZStd::make_unique<AZ::Entity>();
|
||||
if (parent)
|
||||
{
|
||||
AliasPath absoluteInstancePath = m_parent->GetAbsoluteInstanceAliasPath();
|
||||
absoluteInstancePath.Append(m_alias);
|
||||
absoluteInstancePath.Append(PrefabDomUtils::ContainerEntityName);
|
||||
|
||||
AZ::EntityId newContainerEntityId = InstanceEntityIdMapper::GenerateEntityIdForAliasPath(absoluteInstancePath);
|
||||
m_containerEntity->SetId(newContainerEntityId);
|
||||
}
|
||||
|
||||
RegisterEntity(m_containerEntity->GetId(), PrefabDomUtils::ContainerEntityName);
|
||||
}
|
||||
|
||||
@@ -69,12 +98,12 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
const TemplateId& Instance::GetTemplateId() const
|
||||
TemplateId Instance::GetTemplateId() const
|
||||
{
|
||||
return m_templateId;
|
||||
}
|
||||
|
||||
void Instance::SetTemplateId(const TemplateId& templateId)
|
||||
void Instance::SetTemplateId(TemplateId templateId)
|
||||
{
|
||||
// If we aren't changing the template Id, there's no need to unregister / re-register
|
||||
if (templateId == m_templateId)
|
||||
@@ -295,20 +324,21 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
Instance& Instance::AddInstance(AZStd::unique_ptr<Instance> instance)
|
||||
{
|
||||
InstanceAlias newInstanceAlias = GenerateInstanceAlias();
|
||||
return AddInstance(AZStd::move(instance), newInstanceAlias);
|
||||
}
|
||||
|
||||
Instance& Instance::AddInstance(AZStd::unique_ptr<Instance> instance, InstanceAlias newInstanceAlias)
|
||||
{
|
||||
AZ_Assert(instance.get(), "instance argument is nullptr");
|
||||
|
||||
if (instance->GetInstanceAlias().empty())
|
||||
{
|
||||
instance->m_alias = GenerateInstanceAlias();
|
||||
}
|
||||
|
||||
AZ_Assert(
|
||||
m_nestedInstances.find(newInstanceAlias) == m_nestedInstances.end(),
|
||||
m_nestedInstances.find(instance->GetInstanceAlias()) == m_nestedInstances.end(),
|
||||
"InstanceAlias' unique id collision, this should never happen.");
|
||||
|
||||
instance->m_parent = this;
|
||||
instance->m_alias = newInstanceAlias;
|
||||
return *(m_nestedInstances[newInstanceAlias] = std::move(instance));
|
||||
auto& alias = instance->GetInstanceAlias();
|
||||
return *(m_nestedInstances[alias] = AZStd::move(instance));
|
||||
}
|
||||
|
||||
void Instance::DetachNestedInstances(const AZStd::function<void(AZStd::unique_ptr<Instance>)>& callback)
|
||||
|
||||
@@ -65,6 +65,9 @@ namespace AzToolsFramework
|
||||
|
||||
Instance();
|
||||
explicit Instance(AZStd::unique_ptr<AZ::Entity> containerEntity);
|
||||
explicit Instance(InstanceOptionalReference parent);
|
||||
explicit Instance(AZStd::unique_ptr<AZ::Entity> containerEntity, InstanceOptionalReference parent);
|
||||
explicit Instance(InstanceAlias alias);
|
||||
virtual ~Instance();
|
||||
|
||||
Instance(const Instance& rhs) = delete;
|
||||
@@ -72,8 +75,8 @@ namespace AzToolsFramework
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
const TemplateId& GetTemplateId() const;
|
||||
void SetTemplateId(const TemplateId& templateId);
|
||||
TemplateId GetTemplateId() const;
|
||||
void SetTemplateId(TemplateId templateId);
|
||||
|
||||
const AZ::IO::Path& GetTemplateSourcePath() const;
|
||||
void SetTemplateSourcePath(AZ::IO::PathView sourcePath);
|
||||
@@ -97,7 +100,6 @@ namespace AzToolsFramework
|
||||
void Reset();
|
||||
|
||||
Instance& AddInstance(AZStd::unique_ptr<Instance> instance);
|
||||
Instance& AddInstance(AZStd::unique_ptr<Instance> instance, InstanceAlias instanceAlias);
|
||||
AZStd::unique_ptr<Instance> DetachNestedInstance(const InstanceAlias& instanceAlias);
|
||||
void DetachNestedInstances(const AZStd::function<void(AZStd::unique_ptr<Instance>)>& callback);
|
||||
|
||||
@@ -184,6 +186,8 @@ namespace AzToolsFramework
|
||||
private:
|
||||
static constexpr const char s_aliasPathSeparator = '/';
|
||||
|
||||
Instance(AZStd::unique_ptr<AZ::Entity> containerEntity, InstanceOptionalReference parent, InstanceAlias alias);
|
||||
|
||||
void ClearEntities();
|
||||
|
||||
void RemoveEntities(const AZStd::function<bool(const AZStd::unique_ptr<AZ::Entity>&)>& filter);
|
||||
|
||||
+2
-1
@@ -46,10 +46,11 @@ namespace AzToolsFramework
|
||||
//! Updates the template links (updating instances) for the given template and triggers propagation on its instances.
|
||||
//! @param providedPatch The patch to apply to the template.
|
||||
//! @param templateId The id of the template to update.
|
||||
//! @param immediate An optional flag whether to apply the patch immediately (needed for Undo/Redos) or wait until next system tick.
|
||||
//! @param instanceToExclude An optional reference to an instance of the template being updated that should not be refreshes as part of propagation.
|
||||
//! Defaults to nullopt, which means that all instances will be refreshed.
|
||||
//! @return True if the template was patched correctly, false if the operation failed.
|
||||
virtual bool PatchTemplate(PrefabDomValue& providedPatch, TemplateId templateId, InstanceOptionalReference instanceToExclude = AZStd::nullopt) = 0;
|
||||
virtual bool PatchTemplate(PrefabDomValue& providedPatch, TemplateId templateId, bool immediate = false, InstanceOptionalReference instanceToExclude = AZStd::nullopt) = 0;
|
||||
|
||||
virtual void ApplyPatchesToInstance(const AZ::EntityId& entityId, PrefabDom& patches, const Instance& instanceToAddPatches) = 0;
|
||||
|
||||
|
||||
+2
-2
@@ -156,7 +156,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
bool InstanceToTemplatePropagator::PatchTemplate(PrefabDomValue& providedPatch, TemplateId templateId, InstanceOptionalReference instanceToExclude)
|
||||
bool InstanceToTemplatePropagator::PatchTemplate(PrefabDomValue& providedPatch, TemplateId templateId, bool immediate, InstanceOptionalReference instanceToExclude)
|
||||
{
|
||||
PrefabDom& templateDomReference = m_prefabSystemComponentInterface->FindTemplateDom(templateId);
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace AzToolsFramework
|
||||
(result.GetOutcome() != AZ::JsonSerializationResult::Outcomes::PartialSkip),
|
||||
"Some of the patches were not successfully applied.");
|
||||
m_prefabSystemComponentInterface->SetTemplateDirtyFlag(templateId, true);
|
||||
m_prefabSystemComponentInterface->PropagateTemplateChanges(templateId, instanceToExclude);
|
||||
m_prefabSystemComponentInterface->PropagateTemplateChanges(templateId, immediate, instanceToExclude);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ namespace AzToolsFramework
|
||||
|
||||
InstanceOptionalReference GetTopMostInstanceInHierarchy(AZ::EntityId entityId) override;
|
||||
|
||||
bool PatchTemplate(PrefabDomValue& providedPatch, TemplateId templateId, InstanceOptionalReference instanceToExclude = AZStd::nullopt) override;
|
||||
bool PatchTemplate(PrefabDomValue& providedPatch, TemplateId templateId, bool immediate = false, InstanceOptionalReference instanceToExclude = AZStd::nullopt) override;
|
||||
|
||||
void ApplyPatchesToInstance(const AZ::EntityId& entityId, PrefabDom& patches, const Instance& instanceToAddPatches) override;
|
||||
|
||||
|
||||
+6
-1
@@ -52,7 +52,7 @@ namespace AzToolsFramework
|
||||
AZ::Interface<InstanceUpdateExecutorInterface>::Unregister(this);
|
||||
}
|
||||
|
||||
void InstanceUpdateExecutor::AddTemplateInstancesToQueue(TemplateId instanceTemplateId, InstanceOptionalReference instanceToExclude)
|
||||
void InstanceUpdateExecutor::AddTemplateInstancesToQueue(TemplateId instanceTemplateId, bool immediate, InstanceOptionalReference instanceToExclude)
|
||||
{
|
||||
auto findInstancesResult =
|
||||
m_templateInstanceMapperInterface->FindInstancesOwnedByTemplate(instanceTemplateId);
|
||||
@@ -79,6 +79,11 @@ namespace AzToolsFramework
|
||||
m_instancesUpdateQueue.emplace_back(instance);
|
||||
}
|
||||
}
|
||||
|
||||
if (immediate)
|
||||
{
|
||||
UpdateTemplateInstancesInQueue();
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceUpdateExecutor::RemoveTemplateInstanceFromQueue(const Instance* instance)
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ namespace AzToolsFramework
|
||||
|
||||
explicit InstanceUpdateExecutor(int instanceCountToUpdateInBatch = 0);
|
||||
|
||||
void AddTemplateInstancesToQueue(TemplateId instanceTemplateId, InstanceOptionalReference instanceToExclude = AZStd::nullopt) override;
|
||||
void AddTemplateInstancesToQueue(TemplateId instanceTemplateId, bool immediate = false, InstanceOptionalReference instanceToExclude = AZStd::nullopt) override;
|
||||
bool UpdateTemplateInstancesInQueue() override;
|
||||
virtual void RemoveTemplateInstanceFromQueue(const Instance* instance) override;
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ namespace AzToolsFramework
|
||||
virtual ~InstanceUpdateExecutorInterface() = default;
|
||||
|
||||
// Add all Instances of Template with given Id into a queue for updating them later.
|
||||
virtual void AddTemplateInstancesToQueue(TemplateId instanceTemplateId, InstanceOptionalReference instanceToExclude = AZStd::nullopt) = 0;
|
||||
virtual void AddTemplateInstancesToQueue(TemplateId instanceTemplateId, bool immediate = false, InstanceOptionalReference instanceToExclude = AZStd::nullopt) = 0;
|
||||
|
||||
// Update Instances in the waiting queue.
|
||||
virtual bool UpdateTemplateInstancesInQueue() = 0;
|
||||
|
||||
+4
-4
@@ -27,7 +27,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
|
||||
bool TemplateInstanceMapper::RegisterTemplate(const TemplateId& templateId)
|
||||
bool TemplateInstanceMapper::RegisterTemplate(TemplateId templateId)
|
||||
{
|
||||
const bool result = m_templateIdToInstancesMap.emplace(templateId, InstanceSet()).second;
|
||||
AZ_Assert(result,
|
||||
@@ -39,7 +39,7 @@ namespace AzToolsFramework
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TemplateInstanceMapper::UnregisterTemplate(const TemplateId& templateId)
|
||||
bool TemplateInstanceMapper::UnregisterTemplate(TemplateId templateId)
|
||||
{
|
||||
const bool result = m_templateIdToInstancesMap.erase(templateId) != 0;
|
||||
AZ_Assert(result,
|
||||
@@ -53,7 +53,7 @@ namespace AzToolsFramework
|
||||
|
||||
bool TemplateInstanceMapper::RegisterInstanceToTemplate(Instance& instance)
|
||||
{
|
||||
const TemplateId& templateId = instance.GetTemplateId();
|
||||
TemplateId templateId = instance.GetTemplateId();
|
||||
if (templateId == InvalidTemplateId)
|
||||
{
|
||||
return false;
|
||||
@@ -79,7 +79,7 @@ namespace AzToolsFramework
|
||||
found->second.erase(&instance) != 0;
|
||||
}
|
||||
|
||||
InstanceSetConstReference TemplateInstanceMapper::FindInstancesOwnedByTemplate(const TemplateId& templateId) const
|
||||
InstanceSetConstReference TemplateInstanceMapper::FindInstancesOwnedByTemplate(TemplateId templateId) const
|
||||
{
|
||||
auto found = m_templateIdToInstancesMap.find(templateId);
|
||||
|
||||
|
||||
+3
-3
@@ -26,10 +26,10 @@ namespace AzToolsFramework
|
||||
TemplateInstanceMapper();
|
||||
~TemplateInstanceMapper() override;
|
||||
|
||||
InstanceSetConstReference FindInstancesOwnedByTemplate(const TemplateId& templateId) const override;
|
||||
InstanceSetConstReference FindInstancesOwnedByTemplate(TemplateId templateId) const override;
|
||||
|
||||
bool RegisterTemplate(const TemplateId& templateId);
|
||||
bool UnregisterTemplate(const TemplateId& templateId);
|
||||
bool RegisterTemplate(TemplateId templateId);
|
||||
bool UnregisterTemplate(TemplateId templateId);
|
||||
|
||||
protected:
|
||||
bool RegisterInstanceToTemplate(Instance& instance) override;
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ namespace AzToolsFramework
|
||||
AZ_RTTI(TemplateInstanceMapperInterface, "{5DCCCDAA-3441-4266-9670-B349386E0129}");
|
||||
|
||||
virtual ~TemplateInstanceMapperInterface() = default;
|
||||
virtual InstanceSetConstReference FindInstancesOwnedByTemplate(const TemplateId& templateId) const = 0;
|
||||
virtual InstanceSetConstReference FindInstancesOwnedByTemplate(TemplateId templateId) const = 0;
|
||||
|
||||
protected:
|
||||
// Only the Instance class is allowed to register and unregister Instances.
|
||||
|
||||
@@ -122,12 +122,12 @@ namespace AzToolsFramework
|
||||
!m_instanceName.empty();
|
||||
}
|
||||
|
||||
const TemplateId& Link::GetSourceTemplateId() const
|
||||
TemplateId Link::GetSourceTemplateId() const
|
||||
{
|
||||
return m_sourceTemplateId;
|
||||
}
|
||||
|
||||
const TemplateId& Link::GetTargetTemplateId() const
|
||||
TemplateId Link::GetTargetTemplateId() const
|
||||
{
|
||||
return m_targetTemplateId;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace AzToolsFramework
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
const TemplateId& GetSourceTemplateId() const;
|
||||
const TemplateId& GetTargetTemplateId() const;
|
||||
TemplateId GetSourceTemplateId() const;
|
||||
TemplateId GetTargetTemplateId() const;
|
||||
|
||||
LinkId GetId() const;
|
||||
|
||||
|
||||
@@ -1041,7 +1041,7 @@ namespace AzToolsFramework
|
||||
PrefabUndoInstance* command = aznew PrefabUndoInstance("Entity/Instance duplication");
|
||||
command->SetParent(undoBatch.GetUndoBatch());
|
||||
command->Capture(instanceDomBefore, instanceDomAfter, commonOwningInstance->get().GetTemplateId());
|
||||
command->Redo();
|
||||
command->RedoBatched();
|
||||
|
||||
DuplicateNestedInstancesInInstance(commonOwningInstance->get(),
|
||||
instances, instanceDomAfter, duplicatedEntityAndInstanceIds, newInstanceAliasToOldInstanceMap);
|
||||
|
||||
@@ -92,7 +92,17 @@ namespace AzToolsFramework
|
||||
|
||||
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::PathView filePath, AZStd::unique_ptr<AZ::Entity> containerEntity, InstanceOptionalReference parent,
|
||||
bool shouldCreateLinks)
|
||||
{
|
||||
AZStd::unique_ptr<Instance> newInstance = AZStd::make_unique<Instance>(AZStd::move(containerEntity), parent);
|
||||
CreatePrefab(entities, AZStd::move(instancesToConsume), filePath, newInstance, shouldCreateLinks);
|
||||
return newInstance;
|
||||
}
|
||||
|
||||
void PrefabSystemComponent::CreatePrefab(
|
||||
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume,
|
||||
AZ::IO::PathView filePath, AZStd::unique_ptr<Instance>& newInstance, bool shouldCreateLinks)
|
||||
{
|
||||
AZ::IO::Path relativeFilePath = m_prefabLoader.GenerateRelativePath(filePath);
|
||||
if (GetTemplateIdFromFilePath(relativeFilePath) != InvalidTemplateId)
|
||||
@@ -101,11 +111,9 @@ namespace AzToolsFramework
|
||||
"Filepath %s has already been registered with the Prefab System Component",
|
||||
relativeFilePath.c_str());
|
||||
|
||||
return nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<Instance> newInstance = AZStd::make_unique<Instance>(AZStd::move(containerEntity));
|
||||
|
||||
for (AZ::Entity* entity : entities)
|
||||
{
|
||||
AZ_Assert(entity, "Prefab - Null entity passed in during Create Prefab");
|
||||
@@ -136,13 +144,11 @@ namespace AzToolsFramework
|
||||
{
|
||||
newInstance->SetTemplateId(newTemplateId);
|
||||
}
|
||||
|
||||
return newInstance;
|
||||
}
|
||||
|
||||
void PrefabSystemComponent::PropagateTemplateChanges(TemplateId templateId, InstanceOptionalReference instanceToExclude)
|
||||
void PrefabSystemComponent::PropagateTemplateChanges(TemplateId templateId, bool immediate, InstanceOptionalReference instanceToExclude)
|
||||
{
|
||||
UpdatePrefabInstances(templateId, instanceToExclude);
|
||||
UpdatePrefabInstances(templateId, immediate, instanceToExclude);
|
||||
|
||||
auto templateIdToLinkIdsIterator = m_templateToLinkIdsMap.find(templateId);
|
||||
if (templateIdToLinkIdsIterator != m_templateToLinkIdsMap.end())
|
||||
@@ -171,9 +177,9 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void PrefabSystemComponent::UpdatePrefabInstances(const TemplateId& templateId, InstanceOptionalReference instanceToExclude)
|
||||
void PrefabSystemComponent::UpdatePrefabInstances(TemplateId templateId, bool immediate, InstanceOptionalReference instanceToExclude)
|
||||
{
|
||||
m_instanceUpdateExecutor.AddTemplateInstancesToQueue(templateId, instanceToExclude);
|
||||
m_instanceUpdateExecutor.AddTemplateInstancesToQueue(templateId, immediate, instanceToExclude);
|
||||
}
|
||||
|
||||
void PrefabSystemComponent::UpdateLinkedInstances(AZStd::queue<LinkIds>& linkIdsQueue)
|
||||
@@ -256,7 +262,8 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(AZ::IO::PathView filePath)
|
||||
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(
|
||||
AZ::IO::PathView filePath, InstanceOptionalReference parent)
|
||||
{
|
||||
// Retrieve the template id for the source prefab filepath
|
||||
Prefab::TemplateId templateId = GetTemplateIdFromFilePath(filePath);
|
||||
@@ -276,10 +283,11 @@ namespace AzToolsFramework
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return InstantiatePrefab(templateId);
|
||||
return InstantiatePrefab(templateId, parent);
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(const TemplateId& templateId)
|
||||
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(
|
||||
TemplateId templateId, InstanceOptionalReference parent)
|
||||
{
|
||||
TemplateReference instantiatingTemplate = FindTemplate(templateId);
|
||||
|
||||
@@ -292,7 +300,7 @@ namespace AzToolsFramework
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto newInstance = AZStd::make_unique<Instance>();
|
||||
auto newInstance = AZStd::make_unique<Instance>(parent);
|
||||
Instance::EntityList newEntities;
|
||||
if (!PrefabDomUtils::LoadInstanceFromPrefabDom(*newInstance, newEntities, instantiatingTemplate->get().GetPrefabDom()))
|
||||
{
|
||||
@@ -354,7 +362,7 @@ namespace AzToolsFramework
|
||||
return newTemplateId;
|
||||
}
|
||||
|
||||
TemplateReference PrefabSystemComponent::FindTemplate(const TemplateId& id)
|
||||
TemplateReference PrefabSystemComponent::FindTemplate(TemplateId id)
|
||||
{
|
||||
auto found = m_templateIdMap.find(id);
|
||||
if (found != m_templateIdMap.end())
|
||||
@@ -466,7 +474,7 @@ namespace AzToolsFramework
|
||||
templateToChange.SetFilePath(filePath);
|
||||
}
|
||||
|
||||
void PrefabSystemComponent::RemoveTemplate(const TemplateId& templateId)
|
||||
void PrefabSystemComponent::RemoveTemplate(TemplateId templateId)
|
||||
{
|
||||
auto findTemplateResult = FindTemplate(templateId);
|
||||
if (!findTemplateResult.has_value())
|
||||
@@ -553,8 +561,8 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
LinkId PrefabSystemComponent::AddLink(
|
||||
const TemplateId& sourceTemplateId,
|
||||
const TemplateId& targetTemplateId,
|
||||
TemplateId sourceTemplateId,
|
||||
TemplateId targetTemplateId,
|
||||
PrefabDomValue::MemberIterator& instanceIterator,
|
||||
InstanceOptionalReference instance)
|
||||
{
|
||||
@@ -571,10 +579,13 @@ namespace AzToolsFramework
|
||||
|
||||
Template& targetTemplate = targetTemplateReference->get();
|
||||
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
Template& sourceTemplate = sourceTemplateReference->get();
|
||||
AZStd::string_view instanceName(instanceIterator->name.GetString(), instanceIterator->name.GetStringLength());
|
||||
|
||||
const AZStd::string& targetTemplateFilePath = targetTemplate.GetFilePath().Native();
|
||||
const AZStd::string& sourceTemplateFilePath = sourceTemplate.GetFilePath().Native();
|
||||
#endif
|
||||
|
||||
LinkId newLinkId = CreateUniqueLinkId();
|
||||
Link newLink(newLinkId);
|
||||
@@ -616,8 +627,8 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
LinkId PrefabSystemComponent::CreateLink(
|
||||
const TemplateId& linkTargetId,
|
||||
const TemplateId& linkSourceId,
|
||||
TemplateId linkTargetId,
|
||||
TemplateId linkSourceId,
|
||||
const InstanceAlias& instanceAlias,
|
||||
const PrefabDomConstReference linkPatches,
|
||||
const LinkId& linkId)
|
||||
@@ -774,7 +785,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
bool PrefabSystemComponent::IsTemplateDirty(const TemplateId& templateId)
|
||||
bool PrefabSystemComponent::IsTemplateDirty(TemplateId templateId)
|
||||
{
|
||||
auto templateRef = FindTemplate(templateId);
|
||||
|
||||
@@ -786,7 +797,7 @@ namespace AzToolsFramework
|
||||
return false;
|
||||
}
|
||||
|
||||
void PrefabSystemComponent::SetTemplateDirtyFlag(const TemplateId& templateId, bool dirty)
|
||||
void PrefabSystemComponent::SetTemplateDirtyFlag(TemplateId templateId, bool dirty)
|
||||
{
|
||||
auto templateRef = FindTemplate(templateId);
|
||||
|
||||
@@ -903,8 +914,10 @@ namespace AzToolsFramework
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
Template& sourceTemplate = sourceTemplateReference->get();
|
||||
Template& targetTemplate = targetTemplateReference->get();
|
||||
#endif
|
||||
|
||||
AZStd::string_view instanceName(instanceIterator->name.GetString(), instanceIterator->name.GetStringLength());
|
||||
|
||||
@@ -914,7 +927,7 @@ namespace AzToolsFramework
|
||||
|
||||
PrefabDomValue& instance = instanceIterator->value;
|
||||
AZ_Assert(instance.IsObject(), "Nested instance DOM provided is not a valid JSON object.");
|
||||
PrefabDomValueReference sourceTemplateName = PrefabDomUtils::FindPrefabDomValue(instance, PrefabDomUtils::SourceName);
|
||||
[[maybe_unused]] PrefabDomValueReference sourceTemplateName = PrefabDomUtils::FindPrefabDomValue(instance, PrefabDomUtils::SourceName);
|
||||
AZ_Assert(sourceTemplateName, "Couldn't find source template name in the DOM of the nested instance while creating a link.");
|
||||
AZ_Assert(sourceTemplateName->get() == sourceTemplate.GetFilePath().c_str(),
|
||||
"The name of the source template in the nested instance DOM does not match the name of the source template already loaded");
|
||||
@@ -940,7 +953,7 @@ namespace AzToolsFramework
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrefabSystemComponent::GenerateLinksForNewTemplate(const TemplateId& newTemplateId, Instance& instance)
|
||||
bool PrefabSystemComponent::GenerateLinksForNewTemplate(TemplateId newTemplateId, Instance& instance)
|
||||
{
|
||||
TemplateReference newTemplateReference = FindTemplate(newTemplateId);
|
||||
if (!newTemplateReference.has_value())
|
||||
@@ -980,7 +993,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
const PrefabDomValue& source = instanceSourceReference->get();
|
||||
const TemplateId& nestedTemplateId = GetTemplateIdFromFilePath(source.GetString());
|
||||
TemplateId nestedTemplateId = GetTemplateIdFromFilePath(source.GetString());
|
||||
if (nestedTemplateId == InvalidTemplateId)
|
||||
{
|
||||
AZ_Error("Prefab", false,
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace AzToolsFramework
|
||||
* @param id A unique id of a Template.
|
||||
* @return Reference of Template if the Template exists.
|
||||
*/
|
||||
TemplateReference FindTemplate(const TemplateId& id) override;
|
||||
TemplateReference FindTemplate(TemplateId id) override;
|
||||
|
||||
/**
|
||||
* Find Link with given Link id from Prefab System Component.
|
||||
@@ -112,7 +112,7 @@ namespace AzToolsFramework
|
||||
* Remove the Template associated with the given id from Prefab System Component.
|
||||
* @param templateId A unique id of a Template.
|
||||
*/
|
||||
void RemoveTemplate(const TemplateId& templateId) override;
|
||||
void RemoveTemplate(TemplateId templateId) override;
|
||||
|
||||
/**
|
||||
* Remove all Templates from the Prefab System Component.
|
||||
@@ -121,17 +121,21 @@ namespace AzToolsFramework
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param filePath The path to the prefab source file containing the template being instantiated.
|
||||
* @param parent Reference of the target instance the instantiated instance will be placed under.
|
||||
* @return A unique_ptr to the newly instantiated instance. Null if operation failed.
|
||||
*/
|
||||
AZStd::unique_ptr<Instance> InstantiatePrefab(AZ::IO::PathView filePath) override;
|
||||
AZStd::unique_ptr<Instance> InstantiatePrefab(
|
||||
AZ::IO::PathView filePath, InstanceOptionalReference parent = AZStd::nullopt) override;
|
||||
|
||||
/**
|
||||
* Generates a new Prefab Instance based on the Template referenced by templateId
|
||||
* @param templateId the id of the template being instantiated.
|
||||
* Generates a new Prefab Instance based on the Template referenced by templateId.
|
||||
* @param templateId The id of the template being instantiated.
|
||||
* @param parent Reference of the target instance the instantiated instance will be placed under.
|
||||
* @return A unique_ptr to the newly instantiated instance. Null if operation failed.
|
||||
*/
|
||||
AZStd::unique_ptr<Instance> InstantiatePrefab(const TemplateId& templateId) override;
|
||||
AZStd::unique_ptr<Instance> InstantiatePrefab(
|
||||
TemplateId templateId, InstanceOptionalReference parent = AZStd::nullopt) override;
|
||||
|
||||
/**
|
||||
* Add a new Link into Prefab System Component and create a unique id for it.
|
||||
@@ -142,8 +146,8 @@ namespace AzToolsFramework
|
||||
* @return A unique id for the new Link.
|
||||
*/
|
||||
LinkId AddLink(
|
||||
const TemplateId& sourceTemplateId,
|
||||
const TemplateId& targetTemplateId,
|
||||
TemplateId sourceTemplateId,
|
||||
TemplateId targetTemplateId,
|
||||
PrefabDomValue::MemberIterator& instanceIterator,
|
||||
InstanceOptionalReference instance) override;
|
||||
|
||||
@@ -157,8 +161,8 @@ namespace AzToolsFramework
|
||||
* @return A unique id for the new Link.
|
||||
*/
|
||||
LinkId CreateLink(
|
||||
const TemplateId& linkTargetId,
|
||||
const TemplateId& linkSourceId,
|
||||
TemplateId linkTargetId,
|
||||
TemplateId linkSourceId,
|
||||
const InstanceAlias& instanceAlias,
|
||||
const PrefabDomConstReference linkPatches,
|
||||
const LinkId& linkId = InvalidLinkId) override;
|
||||
@@ -181,14 +185,14 @@ namespace AzToolsFramework
|
||||
* @param templateId The id of the template to query.
|
||||
* @return The value of the dirty flag on the template.
|
||||
*/
|
||||
bool IsTemplateDirty(const TemplateId& templateId) override;
|
||||
bool IsTemplateDirty(TemplateId templateId) override;
|
||||
|
||||
/**
|
||||
* Sets the dirty flag of the template to the value provided.
|
||||
* @param templateId The id of the template to flag.
|
||||
* @param dirty The new value of the dirty flag.
|
||||
*/
|
||||
void SetTemplateDirtyFlag(const TemplateId& templateId, bool dirty) override;
|
||||
void SetTemplateDirtyFlag(TemplateId templateId, bool dirty) override;
|
||||
|
||||
bool AreDirtyTemplatesPresent(TemplateId rootTemplateId) override;
|
||||
|
||||
@@ -200,20 +204,21 @@ namespace AzToolsFramework
|
||||
|
||||
/**
|
||||
* Builds a new Prefab Template out of entities and instances and returns the first instance comprised of
|
||||
* these entities and instances
|
||||
* @param entities A vector of entities that will be used in the new instance. May be empty
|
||||
* these entities and instances.
|
||||
* @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.
|
||||
* May be empty.
|
||||
* @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 parent Reference of an instance the created instance will be placed under, if given.
|
||||
* @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
|
||||
* @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,
|
||||
bool ShouldCreateLinks = true) override;
|
||||
InstanceOptionalReference parent = AZStd::nullopt, bool shouldCreateLinks = true) override;
|
||||
|
||||
PrefabDom& FindTemplateDom(TemplateId templateId) override;
|
||||
|
||||
@@ -225,18 +230,36 @@ namespace AzToolsFramework
|
||||
*/
|
||||
void UpdatePrefabTemplate(TemplateId templateId, const PrefabDom& updatedDom) override;
|
||||
|
||||
void PropagateTemplateChanges(TemplateId templateId, InstanceOptionalReference instanceToExclude = AZStd::nullopt) override;
|
||||
void PropagateTemplateChanges(TemplateId templateId, bool immediate = false, InstanceOptionalReference instanceToExclude = AZStd::nullopt) override;
|
||||
|
||||
/**
|
||||
* Updates all Instances owned by a Template.
|
||||
*
|
||||
* @param templateId The id of the Template owning Instances to update.
|
||||
* @param immediate An optional flag whether to apply the patch immediately (needed for Undo/Redos) or wait until next system tick.
|
||||
* @param instanceToExclude An optional reference to an instance of the template being updated that should not be refreshes as part of propagation.
|
||||
* Defaults to nullopt, which means that all instances will be refreshed.
|
||||
*/
|
||||
void UpdatePrefabInstances(const TemplateId& templateId, InstanceOptionalReference instanceToExclude = AZStd::nullopt);
|
||||
void UpdatePrefabInstances(TemplateId templateId, bool immediate = false, InstanceOptionalReference instanceToExclude = AZStd::nullopt);
|
||||
|
||||
private:
|
||||
AZ_DISABLE_COPY_MOVE(PrefabSystemComponent);
|
||||
|
||||
/**
|
||||
* Builds a new Prefab Template out of entities and instances and returns the first instance comprised of
|
||||
* these entities and instances.
|
||||
* @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 instance Reference of a pointer to the newly created instance which needs initiation.
|
||||
* @param shouldCreateLinks The flag indicating if links should be created between the templates of the instance
|
||||
* and its nested instances.
|
||||
*/
|
||||
void CreatePrefab(const AZStd::vector<AZ::Entity*>& entities,
|
||||
AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume, AZ::IO::PathView filePath,
|
||||
AZStd::unique_ptr<Instance>& instance, bool shouldCreateLinks);
|
||||
|
||||
/**
|
||||
* Updates all the linked Instances corresponding to the linkIds in the provided queue.
|
||||
* Queue gets populated with more linkId lists as linked instances are updated. Updating stops when the queue is empty.
|
||||
@@ -310,7 +333,7 @@ namespace AzToolsFramework
|
||||
* @param instance The instance that the template was created from. This needs to be editable for inserting linkId into it.
|
||||
* @return bool on whether the operation succeeded
|
||||
*/
|
||||
bool GenerateLinksForNewTemplate(const TemplateId& newTemplateId, Instance& instance);
|
||||
bool GenerateLinksForNewTemplate(TemplateId newTemplateId, Instance& instance);
|
||||
|
||||
/**
|
||||
* Create a unique Template id for newly created Template.
|
||||
|
||||
+13
-10
@@ -29,28 +29,28 @@ namespace AzToolsFramework
|
||||
public:
|
||||
AZ_RTTI(PrefabSystemComponentInterface, "{8E95A029-67F9-4F74-895F-DDBFE29516A0}");
|
||||
|
||||
virtual TemplateReference FindTemplate(const TemplateId& id) = 0;
|
||||
virtual TemplateReference FindTemplate(TemplateId id) = 0;
|
||||
virtual LinkReference FindLink(const LinkId& id) = 0;
|
||||
|
||||
virtual TemplateId AddTemplate(const AZ::IO::Path& filePath, PrefabDom prefabDom) = 0;
|
||||
virtual void UpdateTemplateFilePath(TemplateId templateId, const AZ::IO::PathView& filePath) = 0;
|
||||
virtual void RemoveTemplate(const TemplateId& templateId) = 0;
|
||||
virtual void RemoveTemplate(TemplateId templateId) = 0;
|
||||
virtual void RemoveAllTemplates() = 0;
|
||||
|
||||
virtual LinkId AddLink(const TemplateId& sourceTemplateId, const TemplateId& targetTemplateId,
|
||||
virtual LinkId AddLink(TemplateId sourceTemplateId, TemplateId targetTemplateId,
|
||||
PrefabDomValue::MemberIterator& instanceIterator, InstanceOptionalReference instance) = 0;
|
||||
|
||||
//creates a new Link
|
||||
virtual LinkId CreateLink(
|
||||
const TemplateId& linkTargetId, const TemplateId& linkSourceId, const InstanceAlias& instanceAlias,
|
||||
TemplateId linkTargetId, TemplateId linkSourceId, const InstanceAlias& instanceAlias,
|
||||
const PrefabDomConstReference linkPatches, const LinkId& linkId = InvalidLinkId) = 0;
|
||||
|
||||
virtual void RemoveLink(const LinkId& linkId) = 0;
|
||||
|
||||
virtual TemplateId GetTemplateIdFromFilePath(AZ::IO::PathView filePath) const = 0;
|
||||
|
||||
virtual bool IsTemplateDirty(const TemplateId& templateId) = 0;
|
||||
virtual void SetTemplateDirtyFlag(const TemplateId& templateId, bool dirty) = 0;
|
||||
virtual bool IsTemplateDirty(TemplateId templateId) = 0;
|
||||
virtual void SetTemplateDirtyFlag(TemplateId templateId, bool dirty) = 0;
|
||||
|
||||
//! Recursive function to check if the template is dirty or if any dirty templates are presents in the links of the template.
|
||||
//! @param rootTemplateId The id of the template provided as the beginning template to check the outgoing links.
|
||||
@@ -67,13 +67,16 @@ namespace AzToolsFramework
|
||||
|
||||
virtual PrefabDom& FindTemplateDom(TemplateId templateId) = 0;
|
||||
virtual void UpdatePrefabTemplate(TemplateId templateId, const PrefabDom& updatedDom) = 0;
|
||||
virtual void PropagateTemplateChanges(TemplateId templateId, InstanceOptionalReference instanceToExclude = AZStd::nullopt) = 0;
|
||||
virtual void PropagateTemplateChanges(TemplateId templateId, bool immediate = false, InstanceOptionalReference instanceToExclude = AZStd::nullopt) = 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> InstantiatePrefab(
|
||||
AZ::IO::PathView filePath, InstanceOptionalReference parent = AZStd::nullopt) = 0;
|
||||
virtual AZStd::unique_ptr<Instance> InstantiatePrefab(
|
||||
TemplateId templateId, InstanceOptionalReference parent = AZStd::nullopt) = 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, bool ShouldCreateLinks = true) = 0;
|
||||
AZStd::unique_ptr<AZ::Entity> containerEntity = nullptr, InstanceOptionalReference parent = AZStd::nullopt,
|
||||
bool shouldCreateLinks = true) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace AzToolsFramework
|
||||
void PrefabUndoInstance::Capture(
|
||||
const PrefabDom& initialState,
|
||||
const PrefabDom& endState,
|
||||
const TemplateId& templateId)
|
||||
TemplateId templateId)
|
||||
{
|
||||
m_templateId = templateId;
|
||||
|
||||
@@ -43,10 +43,15 @@ namespace AzToolsFramework
|
||||
|
||||
void PrefabUndoInstance::Undo()
|
||||
{
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_undoPatch, m_templateId);
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_undoPatch, m_templateId, true);
|
||||
}
|
||||
|
||||
void PrefabUndoInstance::Redo()
|
||||
{
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_redoPatch, m_templateId, true);
|
||||
}
|
||||
|
||||
void PrefabUndoInstance::RedoBatched()
|
||||
{
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_redoPatch, m_templateId);
|
||||
}
|
||||
@@ -91,7 +96,7 @@ namespace AzToolsFramework
|
||||
void PrefabUndoEntityUpdate::Undo()
|
||||
{
|
||||
[[maybe_unused]] bool isPatchApplicationSuccessful =
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_undoPatch, m_templateId);
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_undoPatch, m_templateId, true);
|
||||
|
||||
AZ_Error(
|
||||
"Prefab", isPatchApplicationSuccessful,
|
||||
@@ -102,7 +107,7 @@ namespace AzToolsFramework
|
||||
void PrefabUndoEntityUpdate::Redo()
|
||||
{
|
||||
[[maybe_unused]] bool isPatchApplicationSuccessful =
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_redoPatch, m_templateId);
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_redoPatch, m_templateId, true);
|
||||
|
||||
AZ_Error(
|
||||
"Prefab", isPatchApplicationSuccessful,
|
||||
@@ -113,7 +118,7 @@ namespace AzToolsFramework
|
||||
void PrefabUndoEntityUpdate::Redo(InstanceOptionalReference instanceToExclude)
|
||||
{
|
||||
[[maybe_unused]] bool isPatchApplicationSuccessful =
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_redoPatch, m_templateId, instanceToExclude);
|
||||
m_instanceToTemplateInterface->PatchTemplate(m_redoPatch, m_templateId, false, instanceToExclude);
|
||||
|
||||
AZ_Error(
|
||||
"Prefab", isPatchApplicationSuccessful,
|
||||
@@ -136,8 +141,8 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
void PrefabUndoInstanceLink::Capture(
|
||||
const TemplateId& targetId,
|
||||
const TemplateId& sourceId,
|
||||
TemplateId targetId,
|
||||
TemplateId sourceId,
|
||||
const InstanceAlias& instanceAlias,
|
||||
PrefabDom linkPatches,
|
||||
const LinkId linkId)
|
||||
@@ -329,7 +334,7 @@ namespace AzToolsFramework
|
||||
|
||||
//propagate the link changes
|
||||
link->get().UpdateTarget();
|
||||
m_prefabSystemComponentInterface->PropagateTemplateChanges(link->get().GetTargetTemplateId(), instanceToExclude);
|
||||
m_prefabSystemComponentInterface->PropagateTemplateChanges(link->get().GetTargetTemplateId(), false, instanceToExclude);
|
||||
|
||||
//mark as dirty
|
||||
m_prefabSystemComponentInterface->SetTemplateDirtyFlag(link->get().GetTargetTemplateId(), true);
|
||||
|
||||
@@ -49,10 +49,11 @@ namespace AzToolsFramework
|
||||
void Capture(
|
||||
const PrefabDom& initialState,
|
||||
const PrefabDom& endState,
|
||||
const TemplateId& templateId);
|
||||
TemplateId templateId);
|
||||
|
||||
void Undo() override;
|
||||
void Redo() override;
|
||||
void RedoBatched();
|
||||
};
|
||||
|
||||
//! handles entity updates, such as when the values on an entity change
|
||||
@@ -95,8 +96,8 @@ namespace AzToolsFramework
|
||||
|
||||
//capture for add/remove
|
||||
void Capture(
|
||||
const TemplateId& targetId,
|
||||
const TemplateId& sourceId,
|
||||
TemplateId targetId,
|
||||
TemplateId sourceId,
|
||||
const InstanceAlias& instanceAlias,
|
||||
PrefabDom linkPatches = PrefabDom(),
|
||||
const LinkId linkId = InvalidLinkId);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace AzToolsFramework
|
||||
PrefabUndoInstance* state = aznew Prefab::PrefabUndoInstance(undoMessage);
|
||||
state->Capture(instanceDomBeforeUpdate, instanceDomAfterUpdate, instance.GetTemplateId());
|
||||
state->SetParent(undoBatch);
|
||||
state->Redo();
|
||||
state->RedoBatched();
|
||||
}
|
||||
|
||||
LinkId CreateLink(
|
||||
|
||||
+1
-1
@@ -1160,7 +1160,7 @@ namespace AzToolsFramework
|
||||
AZStd::string unsavedPrefabFileName = unsavedPrefabFileLabel->property("FilePath").toString().toUtf8().data();
|
||||
AzToolsFramework::Prefab::TemplateId unsavedPrefabTemplateId =
|
||||
s_prefabSystemComponentInterface->GetTemplateIdFromFilePath(unsavedPrefabFileName.data());
|
||||
bool isTemplateSavedSuccessfully = s_prefabLoaderInterface->SaveTemplate(unsavedPrefabTemplateId);
|
||||
[[maybe_unused]] bool isTemplateSavedSuccessfully = s_prefabLoaderInterface->SaveTemplate(unsavedPrefabTemplateId);
|
||||
AZ_Error("Prefab", isTemplateSavedSuccessfully, "Prefab '%s' could not be saved successfully.", unsavedPrefabFileName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
+3
-10
@@ -1102,10 +1102,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
m_dropDownArrow->hide();
|
||||
}
|
||||
m_indent->changeSize((m_treeDepth * m_treeIndentation) + m_leafIndentation, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
m_leftHandSideLayout->invalidate();
|
||||
m_leftHandSideLayout->update();
|
||||
m_leftHandSideLayout->activate();
|
||||
SetIndentSize(m_treeDepth * m_treeIndentation + m_leafIndentation);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1117,10 +1114,7 @@ namespace AzToolsFramework
|
||||
connect(m_dropDownArrow, &QCheckBox::clicked, this, &PropertyRowWidget::OnClickedExpansionButton);
|
||||
}
|
||||
m_dropDownArrow->show();
|
||||
m_indent->changeSize((m_treeDepth * m_treeIndentation), 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
m_leftHandSideLayout->invalidate();
|
||||
m_leftHandSideLayout->update();
|
||||
m_leftHandSideLayout->activate();
|
||||
SetIndentSize(m_treeDepth * m_treeIndentation);
|
||||
m_dropDownArrow->setChecked(m_expanded);
|
||||
}
|
||||
}
|
||||
@@ -1720,10 +1714,9 @@ namespace AzToolsFramework
|
||||
}
|
||||
else
|
||||
{
|
||||
m_indicatorButton->setVisible(true);
|
||||
|
||||
QPixmap pixmap(imagePath);
|
||||
m_indicatorButton->setIcon(pixmap);
|
||||
m_indicatorButton->setVisible(true);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/PropertyEditor/Resources">
|
||||
<file>blank.png</file>
|
||||
<file>point_hand.png</file>
|
||||
<file>cross-circle-small.png</file>
|
||||
<file>cross-small.png</file>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:81b5fa1f978888c3be8a40fce20455668df2723a77587aeb7039f8bf74bdd0e3
|
||||
size 119
|
||||
+2
-2
@@ -32,14 +32,14 @@ namespace AzToolsFramework
|
||||
|
||||
m_manipulatorManager = AZStd::make_shared<AzToolsFramework::ManipulatorManager>(AzToolsFramework::g_mainManipulatorManagerId);
|
||||
m_transformComponentSelection = AZStd::make_unique<EditorTransformComponentSelection>(entityDataCache);
|
||||
m_viewportEditorModeTracker->ActivateMode({ /* DefaultViewportId */ }, ViewportEditorMode::Default);
|
||||
m_viewportEditorModeTracker->ActivateMode({ GetEntityContextId() }, ViewportEditorMode::Default);
|
||||
}
|
||||
|
||||
EditorDefaultSelection::~EditorDefaultSelection()
|
||||
{
|
||||
ComponentModeFramework::ComponentModeSystemRequestBus::Handler::BusDisconnect();
|
||||
ActionOverrideRequestBus::Handler::BusDisconnect();
|
||||
m_viewportEditorModeTracker->DeactivateMode({ /* DefaultViewportId */ }, ViewportEditorMode::Default);
|
||||
m_viewportEditorModeTracker->DeactivateMode({ GetEntityContextId() }, ViewportEditorMode::Default);
|
||||
}
|
||||
|
||||
void EditorDefaultSelection::SetOverridePhantomWidget(QWidget* phantomOverrideWidget)
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ namespace AzToolsFramework
|
||||
: m_editorHelpers(AZStd::make_unique<EditorHelpers>(entityDataCache))
|
||||
, m_viewportEditorModeTracker(viewportEditorModeTracker)
|
||||
{
|
||||
m_viewportEditorModeTracker->ActivateMode({ /* DefaultViewportId */ }, ViewportEditorMode::Pick);
|
||||
m_viewportEditorModeTracker->ActivateMode({ GetEntityContextId() }, ViewportEditorMode::Pick);
|
||||
}
|
||||
|
||||
EditorPickEntitySelection::~EditorPickEntitySelection()
|
||||
@@ -31,7 +31,7 @@ namespace AzToolsFramework
|
||||
ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetEntityHighlighted, m_hoveredEntityId, false);
|
||||
}
|
||||
|
||||
m_viewportEditorModeTracker->DeactivateMode({ /* DefaultViewportId */ }, ViewportEditorMode::Pick);
|
||||
m_viewportEditorModeTracker->DeactivateMode({ GetEntityContextId() }, ViewportEditorMode::Pick);
|
||||
}
|
||||
|
||||
// note: entityIdUnderCursor is the authoritative entityId we get each frame by querying
|
||||
|
||||
+18
-16
@@ -46,13 +46,14 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
AZ::Outcome<void, AZStd::string> ViewportEditorModeTracker::ActivateMode(
|
||||
const ViewportEditorModeInfo& viewportEditorModeInfo, ViewportEditorMode mode)
|
||||
const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo, ViewportEditorMode mode)
|
||||
{
|
||||
auto& editorModes = m_viewportEditorModesMap[viewportEditorModeInfo.m_id];
|
||||
auto& editorModes = m_viewportEditorModesMap[ViewportEditorModeTrackerInfo.m_id];
|
||||
if (editorModes.IsModeActive(mode))
|
||||
{
|
||||
return AZ::Failure(AZStd::string::format(
|
||||
"Duplicate call to ActivateMode for mode '%u' on id '%i'", static_cast<AZ::u32>(mode), viewportEditorModeInfo.m_id));
|
||||
"Duplicate call to ActivateMode for mode '%u' on id '%s'", static_cast<AZ::u32>(mode),
|
||||
ViewportEditorModeTrackerInfo.m_id.ToString<AZStd::string>().c_str()));
|
||||
}
|
||||
|
||||
if (const auto result = editorModes.ActivateMode(mode);
|
||||
@@ -62,29 +63,30 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
ViewportEditorModeNotificationsBus::Event(
|
||||
viewportEditorModeInfo.m_id, &ViewportEditorModeNotificationsBus::Events::OnEditorModeActivated, editorModes, mode);
|
||||
ViewportEditorModeTrackerInfo.m_id, &ViewportEditorModeNotificationsBus::Events::OnEditorModeActivated, editorModes, mode);
|
||||
|
||||
return AZ::Success();
|
||||
}
|
||||
|
||||
AZ::Outcome<void, AZStd::string> ViewportEditorModeTracker::DeactivateMode(
|
||||
const ViewportEditorModeInfo& viewportEditorModeInfo, ViewportEditorMode mode)
|
||||
const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo, ViewportEditorMode mode)
|
||||
{
|
||||
ViewportEditorModes* editorModes = nullptr;
|
||||
bool modeWasActive = true;
|
||||
if (m_viewportEditorModesMap.count(viewportEditorModeInfo.m_id))
|
||||
if (m_viewportEditorModesMap.count(ViewportEditorModeTrackerInfo.m_id))
|
||||
{
|
||||
editorModes = &m_viewportEditorModesMap.at(viewportEditorModeInfo.m_id);
|
||||
editorModes = &m_viewportEditorModesMap.at(ViewportEditorModeTrackerInfo.m_id);
|
||||
if (!editorModes->IsModeActive(mode))
|
||||
{
|
||||
return AZ::Failure(AZStd::string::format(
|
||||
"Duplicate call to DeactivateMode for mode '%u' on id '%i'", static_cast<AZ::u32>(mode), viewportEditorModeInfo.m_id));
|
||||
"Duplicate call to DeactivateMode for mode '%u' on id '%s'", static_cast<AZ::u32>(mode),
|
||||
ViewportEditorModeTrackerInfo.m_id.ToString<AZStd::string>().c_str()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
modeWasActive = false;
|
||||
editorModes = &m_viewportEditorModesMap[viewportEditorModeInfo.m_id];
|
||||
editorModes = &m_viewportEditorModesMap[ViewportEditorModeTrackerInfo.m_id];
|
||||
}
|
||||
|
||||
if(const auto result = editorModes->DeactivateMode(mode);
|
||||
@@ -94,7 +96,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
ViewportEditorModeNotificationsBus::Event(
|
||||
viewportEditorModeInfo.m_id, &ViewportEditorModeNotificationsBus::Events::OnEditorModeDeactivated, *editorModes, mode);
|
||||
ViewportEditorModeTrackerInfo.m_id, &ViewportEditorModeNotificationsBus::Events::OnEditorModeDeactivated, *editorModes, mode);
|
||||
|
||||
if (modeWasActive)
|
||||
{
|
||||
@@ -103,14 +105,14 @@ namespace AzToolsFramework
|
||||
else
|
||||
{
|
||||
return AZ::Failure(AZStd::string::format(
|
||||
"Call to DeactivateMode for mode '%u' on id '%i' without precursor call to ActivateMode", static_cast<AZ::u32>(mode),
|
||||
viewportEditorModeInfo.m_id));
|
||||
"Call to DeactivateMode for mode '%u' on id '%s' without precursor call to ActivateMode", static_cast<AZ::u32>(mode),
|
||||
ViewportEditorModeTrackerInfo.m_id.ToString<AZStd::string>().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
const ViewportEditorModesInterface* ViewportEditorModeTracker::GetViewportEditorModes(const ViewportEditorModeInfo& viewportEditorModeInfo) const
|
||||
const ViewportEditorModesInterface* ViewportEditorModeTracker::GetViewportEditorModes(const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo) const
|
||||
{
|
||||
if (auto editorModes = m_viewportEditorModesMap.find(viewportEditorModeInfo.m_id);
|
||||
if (auto editorModes = m_viewportEditorModesMap.find(ViewportEditorModeTrackerInfo.m_id);
|
||||
editorModes != m_viewportEditorModesMap.end())
|
||||
{
|
||||
return &editorModes->second;
|
||||
@@ -126,8 +128,8 @@ namespace AzToolsFramework
|
||||
return m_viewportEditorModesMap.size();
|
||||
}
|
||||
|
||||
bool ViewportEditorModeTracker::IsViewportModeTracked(const ViewportEditorModeInfo& viewportEditorModeInfo) const
|
||||
bool ViewportEditorModeTracker::IsViewportModeTracked(const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo) const
|
||||
{
|
||||
return m_viewportEditorModesMap.count(viewportEditorModeInfo.m_id) > 0;
|
||||
return m_viewportEditorModesMap.count(ViewportEditorModeTrackerInfo.m_id) > 0;
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+6
-6
@@ -42,14 +42,14 @@ namespace AzToolsFramework
|
||||
{
|
||||
public:
|
||||
// ViewportEditorModeTrackerInterface overrides ...
|
||||
AZ::Outcome<void, AZStd::string> ActivateMode(const ViewportEditorModeInfo& viewportEditorModeInfo, ViewportEditorMode mode) override;
|
||||
AZ::Outcome<void, AZStd::string> DeactivateMode(const ViewportEditorModeInfo& viewportEditorModeInfo, ViewportEditorMode mode) override;
|
||||
const ViewportEditorModesInterface* GetViewportEditorModes(const ViewportEditorModeInfo& viewportEditorModeInfo) const override;
|
||||
AZ::Outcome<void, AZStd::string> ActivateMode(const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo, ViewportEditorMode mode) override;
|
||||
AZ::Outcome<void, AZStd::string> DeactivateMode(const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo, ViewportEditorMode mode) override;
|
||||
const ViewportEditorModesInterface* GetViewportEditorModes(const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo) const override;
|
||||
size_t GetTrackedViewportCount() const override;
|
||||
bool IsViewportModeTracked(const ViewportEditorModeInfo& viewportEditorModeInfo) const override;
|
||||
bool IsViewportModeTracked(const ViewportEditorModeTrackerInfo& ViewportEditorModeTrackerInfo) const override;
|
||||
|
||||
private:
|
||||
using ViewportEditorModesMap = AZStd::unordered_map<typename ViewportEditorModeInfo::IdType, ViewportEditorModes>;
|
||||
ViewportEditorModesMap m_viewportEditorModesMap; //!< Editor mode state per viewport.
|
||||
using ViewportEditorModesMap = AZStd::unordered_map<typename ViewportEditorModeTrackerInfo::IdType, ViewportEditorModes>;
|
||||
ViewportEditorModesMap m_viewportEditorModesMap; //!< Editor mode states per tracker.
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Benchmark
|
||||
AZStd::unique_ptr<Instance> instance = m_prefabSystemComponent->CreatePrefab(
|
||||
entities
|
||||
, {}
|
||||
, m_pathString);
|
||||
, m_pathString);
|
||||
|
||||
state.PauseTiming();
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Benchmark
|
||||
{
|
||||
nestedInstanceRoot = m_prefabSystemComponent->CreatePrefab(
|
||||
{},
|
||||
MakeInstanceList( AZStd::move(nestedInstanceRoot) ),
|
||||
MakeInstanceList(AZStd::move(nestedInstanceRoot)),
|
||||
m_paths[instanceCounter]);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -36,7 +36,7 @@ namespace Benchmark
|
||||
|
||||
AZStd::unique_ptr<Instance> enclosingInstance = m_prefabSystemComponent->CreatePrefab(
|
||||
{},
|
||||
MakeInstanceList( AZStd::move(nestedInstance) ),
|
||||
MakeInstanceList(AZStd::move(nestedInstance)),
|
||||
enclosingTemplatePath);
|
||||
|
||||
TemplateId templateToInstantiateId = enclosingInstance->GetTemplateId();
|
||||
@@ -99,7 +99,7 @@ namespace Benchmark
|
||||
{
|
||||
currentInstanceRoot = m_prefabSystemComponent->CreatePrefab(
|
||||
{},
|
||||
MakeInstanceList( AZStd::move(currentInstanceRoot) ),
|
||||
MakeInstanceList(AZStd::move(currentInstanceRoot)),
|
||||
m_paths[currentDepth - 1]);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Benchmark
|
||||
{
|
||||
currentInstanceRoot = m_prefabSystemComponent->CreatePrefab(
|
||||
{},
|
||||
MakeInstanceList( AZStd::move(currentInstanceRoot) ),
|
||||
MakeInstanceList(AZStd::move(currentInstanceRoot)),
|
||||
m_paths[currentDepth]);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace Benchmark
|
||||
|
||||
currentInstanceRoot = m_prefabSystemComponent->CreatePrefab(
|
||||
{},
|
||||
MakeInstanceList( AZStd::move(currentInstanceRoot), AZStd::move(extraNestedInstance) ),
|
||||
MakeInstanceList(AZStd::move(currentInstanceRoot), AZStd::move(extraNestedInstance)),
|
||||
m_paths[currentDepth]);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace UnitTest
|
||||
|
||||
// Create a street prefab that nests the car and sportscar instances created above. The container entity will be created as part of the process.
|
||||
AZStd::unique_ptr<AzToolsFramework::Prefab::Instance> streetInstance =
|
||||
m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList( AZStd::move(carInstance), AZStd::move(sportsCarInstance) ), "test/street");
|
||||
m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList(AZStd::move(carInstance), AZStd::move(sportsCarInstance)), "test/street");
|
||||
ASSERT_TRUE(streetInstance);
|
||||
m_instanceMap[StreetEntityName] = streetInstance.get();
|
||||
|
||||
|
||||
+1
-1
@@ -320,7 +320,7 @@ namespace UnitTest
|
||||
Instance& addedInstance = *addedInstancePtr;
|
||||
|
||||
//create a first instance where the instance will be removed
|
||||
AZStd::unique_ptr<Instance> firstInstance = m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList( AZStd::move(addedInstancePtr) ), "test/path");
|
||||
AZStd::unique_ptr<Instance> firstInstance = m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList(AZStd::move(addedInstancePtr)), "test/path");
|
||||
ASSERT_TRUE(firstInstance);
|
||||
|
||||
//get added instance alias
|
||||
|
||||
@@ -44,11 +44,11 @@ namespace UnitTest
|
||||
ASSERT_TRUE(firstInstance);
|
||||
|
||||
AZStd::unique_ptr<AzToolsFramework::Prefab::Instance> secondInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(firstInstance) ), "test/path2");
|
||||
MakeInstanceList(AZStd::move(firstInstance)), "test/path2");
|
||||
ASSERT_TRUE(secondInstance);
|
||||
|
||||
AZStd::unique_ptr<AzToolsFramework::Prefab::Instance> thirdInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(secondInstance) ), "test/path3");
|
||||
MakeInstanceList(AZStd::move(secondInstance)), "test/path3");
|
||||
ASSERT_TRUE(thirdInstance);
|
||||
|
||||
//Instantiate it
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace UnitTest
|
||||
using namespace AzToolsFramework::Prefab;
|
||||
LinkData CreateLinkData(
|
||||
const InstanceData& instanceData,
|
||||
const TemplateId& sourceTemplateId,
|
||||
const TemplateId& targetTemplateId)
|
||||
TemplateId sourceTemplateId,
|
||||
TemplateId targetTemplateId)
|
||||
{
|
||||
LinkData newLinkData;
|
||||
newLinkData.m_instanceData = instanceData;
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace UnitTest
|
||||
{
|
||||
LinkData CreateLinkData(
|
||||
const InstanceData& instanceData,
|
||||
const AzToolsFramework::Prefab::TemplateId& sourceTemplateId,
|
||||
const AzToolsFramework::Prefab::TemplateId& targetTemplateId);
|
||||
AzToolsFramework::Prefab::TemplateId sourceTemplateId,
|
||||
AzToolsFramework::Prefab::TemplateId targetTemplateId);
|
||||
|
||||
InstanceData CreateInstanceDataWithNoPatches(
|
||||
const AZStd::string& name,
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
void ValidateInstances(
|
||||
const TemplateId& templateId,
|
||||
TemplateId templateId,
|
||||
const PrefabDomValue& expectedContent,
|
||||
const PrefabDomPath& contentPath,
|
||||
bool isContentAnInstance,
|
||||
@@ -204,7 +204,7 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
void ValidateEntitiesOfInstances(
|
||||
const AzToolsFramework::Prefab::TemplateId& templateId,
|
||||
AzToolsFramework::Prefab::TemplateId templateId,
|
||||
const AzToolsFramework::Prefab::PrefabDom& expectedPrefabDom,
|
||||
const AZStd::vector<EntityAlias>& entityAliases)
|
||||
{
|
||||
@@ -219,7 +219,7 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
void ValidateNestedInstancesOfInstances(
|
||||
const AzToolsFramework::Prefab::TemplateId& templateId,
|
||||
AzToolsFramework::Prefab::TemplateId templateId,
|
||||
const AzToolsFramework::Prefab::PrefabDom& expectedPrefabDom,
|
||||
const AZStd::vector<InstanceAlias>& nestedInstanceAliases)
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace UnitTest
|
||||
const PrefabDomValue& patches);
|
||||
|
||||
void ValidateInstances(
|
||||
const TemplateId& templateId,
|
||||
TemplateId templateId,
|
||||
const PrefabDomValue& expectedContent,
|
||||
const PrefabDomPath& contentPath,
|
||||
bool isContentAnInstance = false,
|
||||
@@ -147,12 +147,12 @@ namespace UnitTest
|
||||
void ComparePrefabDomValues(PrefabDomValueConstReference valueA, PrefabDomValueConstReference valueB);
|
||||
|
||||
void ValidateEntitiesOfInstances(
|
||||
const AzToolsFramework::Prefab::TemplateId& templateId,
|
||||
AzToolsFramework::Prefab::TemplateId templateId,
|
||||
const AzToolsFramework::Prefab::PrefabDom& expectedPrefabDom,
|
||||
const AZStd::vector<EntityAlias>& entityAliases);
|
||||
|
||||
void ValidateNestedInstancesOfInstances(
|
||||
const AzToolsFramework::Prefab::TemplateId& templateId,
|
||||
AzToolsFramework::Prefab::TemplateId templateId,
|
||||
const AzToolsFramework::Prefab::PrefabDom& expectedPrefabDom,
|
||||
const AZStd::vector<InstanceAlias>& nestedInstanceAliases);
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ namespace UnitTest
|
||||
{
|
||||
//create two prefabs for test
|
||||
//create prefab 1
|
||||
firstInstance = AZStd::move(m_prefabSystemComponent->CreatePrefab({ }, {}, "test/path0"));
|
||||
firstInstance = AZStd::move(m_prefabSystemComponent->CreatePrefab({}, {}, "test/path0"));
|
||||
ASSERT_TRUE(firstInstance);
|
||||
|
||||
//get template id
|
||||
ownerId = firstInstance->GetTemplateId();
|
||||
|
||||
//create prefab 2
|
||||
secondInstance = AZStd::move(m_prefabSystemComponent->CreatePrefab({ }, {}, "test/path1"));
|
||||
secondInstance = AZStd::move(m_prefabSystemComponent->CreatePrefab({}, {}, "test/path1"));
|
||||
ASSERT_TRUE(secondInstance);
|
||||
|
||||
//get template id
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace UnitTest
|
||||
|
||||
// Create an enclosing Template with 0 entities and 1 nested Instance.
|
||||
AZStd::unique_ptr<Instance> nestedInstance1 = m_prefabSystemComponent->InstantiatePrefab(newNestedTemplateId);
|
||||
AZStd::unique_ptr<Instance> newEnclosingInstance = m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList( AZStd::move(nestedInstance1) ), PrefabMockFilePath);
|
||||
AZStd::unique_ptr<Instance> newEnclosingInstance = m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList(AZStd::move(nestedInstance1)), PrefabMockFilePath);
|
||||
TemplateId newEnclosingTemplateId = newEnclosingInstance->GetTemplateId();
|
||||
EXPECT_TRUE(newEnclosingTemplateId != InvalidTemplateId);
|
||||
PrefabDom& newEnclosingTemplateDom = m_prefabSystemComponent->FindTemplateDom(newEnclosingTemplateId);
|
||||
@@ -284,7 +284,7 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<Instance> nestedInstance2 = m_prefabSystemComponent->InstantiatePrefab(newNestedTemplateId);
|
||||
AZStd::unique_ptr<Instance> newEnclosingInstance = m_prefabSystemComponent->CreatePrefab(
|
||||
{},
|
||||
MakeInstanceList( AZStd::move(nestedInstance1), AZStd::move(nestedInstance2) ),
|
||||
MakeInstanceList(AZStd::move(nestedInstance1), AZStd::move(nestedInstance2)),
|
||||
PrefabMockFilePath);
|
||||
TemplateId newEnclosingTemplateId = newEnclosingInstance->GetTemplateId();
|
||||
EXPECT_TRUE(newEnclosingTemplateId != InvalidTemplateId);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
|
||||
AZStd::unique_ptr<Instance> wheel2UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
|
||||
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(wheel1UnderAxle), AZStd::move(wheel2UnderAxle) ), AxlePrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(wheel1UnderAxle), AZStd::move(wheel2UnderAxle)), AxlePrefabMockFilePath);
|
||||
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
|
||||
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
|
||||
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
|
||||
@@ -51,7 +51,7 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<Instance> axle2UnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
|
||||
AZStd::unique_ptr<Instance> spareWheelUnderCar = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
|
||||
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(axle1UnderCar), AZStd::move(axle2UnderCar), AZStd::move(spareWheelUnderCar) ), CarPrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(axle1UnderCar), AZStd::move(axle2UnderCar), AZStd::move(spareWheelUnderCar)), CarPrefabMockFilePath);
|
||||
const TemplateId carTemplateId = carInstance->GetTemplateId();
|
||||
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
|
||||
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(wheelTemplateId);
|
||||
@@ -93,7 +93,7 @@ namespace UnitTest
|
||||
// Create an axle with 0 entities and 1 wheel instance.
|
||||
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
|
||||
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(wheel1UnderAxle) ), AxlePrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(wheel1UnderAxle)), AxlePrefabMockFilePath);
|
||||
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
|
||||
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
|
||||
AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
|
||||
@@ -105,7 +105,7 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<Instance> axle1UnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
|
||||
AZStd::unique_ptr<Instance> axle2UnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
|
||||
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(axle1UnderCar), AZStd::move(axle2UnderCar) ), CarPrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(axle1UnderCar), AZStd::move(axle2UnderCar)), CarPrefabMockFilePath);
|
||||
const TemplateId carTemplateId = carInstance->GetTemplateId();
|
||||
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
|
||||
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
|
||||
@@ -151,7 +151,7 @@ namespace UnitTest
|
||||
// Create an axle with 0 entities and 1 wheel instance.
|
||||
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
|
||||
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(wheel1UnderAxle) ), AxlePrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(wheel1UnderAxle)), AxlePrefabMockFilePath);
|
||||
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
|
||||
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
|
||||
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
|
||||
@@ -159,7 +159,7 @@ namespace UnitTest
|
||||
// Create a car with 0 entities and 1 axle instance.
|
||||
AZStd::unique_ptr<Instance> axleUnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
|
||||
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(axleUnderCar) ), CarPrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(axleUnderCar)), CarPrefabMockFilePath);
|
||||
const TemplateId carTemplateId = carInstance->GetTemplateId();
|
||||
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
|
||||
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
|
||||
@@ -205,7 +205,7 @@ namespace UnitTest
|
||||
// Create an axle with 0 entities and 1 wheel instance.
|
||||
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
|
||||
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(wheel1UnderAxle) ), AxlePrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(wheel1UnderAxle)), AxlePrefabMockFilePath);
|
||||
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
|
||||
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
|
||||
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
|
||||
@@ -213,7 +213,7 @@ namespace UnitTest
|
||||
// Create a car with 0 entities and 1 axle instance.
|
||||
AZStd::unique_ptr<Instance> axleUnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
|
||||
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(axleUnderCar) ), CarPrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(axleUnderCar)), CarPrefabMockFilePath);
|
||||
const TemplateId carTemplateId = carInstance->GetTemplateId();
|
||||
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
|
||||
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
|
||||
@@ -253,7 +253,7 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
|
||||
AZStd::unique_ptr<Instance> wheel2UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
|
||||
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(wheel1UnderAxle), AZStd::move(wheel2UnderAxle) ),
|
||||
MakeInstanceList(AZStd::move(wheel1UnderAxle), AZStd::move(wheel2UnderAxle) ),
|
||||
AxlePrefabMockFilePath);
|
||||
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
|
||||
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
|
||||
@@ -265,7 +265,7 @@ namespace UnitTest
|
||||
// Create a car with 0 entities and 1 axle instance.
|
||||
AZStd::unique_ptr<Instance> axle1UnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
|
||||
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(axle1UnderCar) ), CarPrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(axle1UnderCar)), CarPrefabMockFilePath);
|
||||
const TemplateId carTemplateId = carInstance->GetTemplateId();
|
||||
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
|
||||
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
|
||||
@@ -320,7 +320,7 @@ namespace UnitTest
|
||||
// Create an axle with 0 entities and 1 wheel instance.
|
||||
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
|
||||
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(wheel1UnderAxle) ), AxlePrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(wheel1UnderAxle)), AxlePrefabMockFilePath);
|
||||
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
|
||||
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
|
||||
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
|
||||
@@ -328,7 +328,7 @@ namespace UnitTest
|
||||
// Create a car with 0 entities and 1 axle instance.
|
||||
AZStd::unique_ptr<Instance> axleUnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
|
||||
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(axleUnderCar) ), CarPrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(axleUnderCar)), CarPrefabMockFilePath);
|
||||
const TemplateId carTemplateId = carInstance->GetTemplateId();
|
||||
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
|
||||
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
|
||||
@@ -381,7 +381,7 @@ namespace UnitTest
|
||||
// Create an axle with 0 entities and 1 wheel instance.
|
||||
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
|
||||
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(wheel1UnderAxle) ), AxlePrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(wheel1UnderAxle)), AxlePrefabMockFilePath);
|
||||
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
|
||||
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
|
||||
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
|
||||
@@ -389,7 +389,7 @@ namespace UnitTest
|
||||
// Create a car with 0 entities and 1 axle instance.
|
||||
AZStd::unique_ptr<Instance> axleUnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
|
||||
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(axleUnderCar) ), CarPrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(axleUnderCar)), CarPrefabMockFilePath);
|
||||
const TemplateId carTemplateId = carInstance->GetTemplateId();
|
||||
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
|
||||
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace UnitTest
|
||||
// Create a car with 0 entities and 1 axle instance.
|
||||
AZStd::unique_ptr<Instance> axleUnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
|
||||
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
|
||||
MakeInstanceList( AZStd::move(axleUnderCar) ), CarPrefabMockFilePath);
|
||||
MakeInstanceList(AZStd::move(axleUnderCar)), CarPrefabMockFilePath);
|
||||
const TemplateId carTemplateId = carInstance->GetTemplateId();
|
||||
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
|
||||
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorPickEntitySelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/ViewportEditorModeTracker.h>
|
||||
|
||||
@@ -17,8 +18,8 @@ namespace UnitTest
|
||||
using ViewportEditorMode = AzToolsFramework::ViewportEditorMode;
|
||||
using ViewportEditorModes = AzToolsFramework::ViewportEditorModes;
|
||||
using ViewportEditorModeTracker = AzToolsFramework::ViewportEditorModeTracker;
|
||||
using ViewportEditorModeInfo = AzToolsFramework::ViewportEditorModeInfo;
|
||||
using ViewportId = ViewportEditorModeInfo::IdType;
|
||||
using ViewportEditorModeTrackerInfo = AzToolsFramework::ViewportEditorModeTrackerInfo;
|
||||
using TrackerId = ViewportEditorModeTrackerInfo::IdType;
|
||||
using ViewportEditorModesInterface = AzToolsFramework::ViewportEditorModesInterface;
|
||||
using ViewportEditorModeTrackerInterface = AzToolsFramework::ViewportEditorModeTrackerInterface;
|
||||
|
||||
@@ -113,10 +114,10 @@ namespace UnitTest
|
||||
|
||||
using EditModeTracker = AZStd::unordered_map<ViewportEditorMode, ReceivedEvents>;
|
||||
|
||||
ViewportEditorModeNotificationsBusHandler(ViewportId viewportId)
|
||||
: m_viewportSubscription(viewportId)
|
||||
ViewportEditorModeNotificationsBusHandler(TrackerId id)
|
||||
: m_trackerSubscription(id)
|
||||
{
|
||||
AzToolsFramework::ViewportEditorModeNotificationsBus::Handler::BusConnect(m_viewportSubscription);
|
||||
AzToolsFramework::ViewportEditorModeNotificationsBus::Handler::BusConnect(m_trackerSubscription);
|
||||
}
|
||||
|
||||
~ViewportEditorModeNotificationsBusHandler()
|
||||
@@ -124,11 +125,6 @@ namespace UnitTest
|
||||
AzToolsFramework::ViewportEditorModeNotificationsBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
ViewportId GetViewportSubscription() const
|
||||
{
|
||||
return m_viewportSubscription;
|
||||
}
|
||||
|
||||
const EditModeTracker& GetEditorModes() const
|
||||
{
|
||||
return m_editorModes;
|
||||
@@ -145,7 +141,7 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
private:
|
||||
ViewportId m_viewportSubscription;
|
||||
TrackerId m_trackerSubscription;
|
||||
EditModeTracker m_editorModes;
|
||||
|
||||
};
|
||||
@@ -158,10 +154,14 @@ namespace UnitTest
|
||||
|
||||
void SetUpEditorFixtureImpl() override
|
||||
{
|
||||
m_handlerIds.resize(ViewportEditorModes::NumEditorModes);
|
||||
for (auto mode = 0; mode < ViewportEditorModes::NumEditorModes; mode++)
|
||||
{
|
||||
m_editorModeHandlers[mode] = AZStd::make_unique<ViewportEditorModeNotificationsBusHandler>(mode);
|
||||
// Create a random GUID for each handler and associate that GUID with an index derived from one of the possible editor modes
|
||||
m_handlerIds[mode] = TrackerId::CreateRandom();
|
||||
m_editorModeHandlers[mode] = AZStd::make_unique<ViewportEditorModeNotificationsBusHandler>(m_handlerIds[mode]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TearDownEditorFixtureImpl() override
|
||||
@@ -173,6 +173,7 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
AZStd::array<AZStd::unique_ptr<ViewportEditorModeNotificationsBusHandler>, ViewportEditorModes::NumEditorModes> m_editorModeHandlers;
|
||||
AZStd::vector<TrackerId> m_handlerIds;
|
||||
};
|
||||
|
||||
// Fixture for testing the integration of viewport editor mode state tracker
|
||||
@@ -184,7 +185,8 @@ namespace UnitTest
|
||||
{
|
||||
m_viewportEditorModeTracker = AZ::Interface<ViewportEditorModeTrackerInterface>::Get();
|
||||
ASSERT_NE(m_viewportEditorModeTracker, nullptr);
|
||||
m_viewportEditorModes = m_viewportEditorModeTracker->GetViewportEditorModes({});
|
||||
m_viewportEditorModes = m_viewportEditorModeTracker->GetViewportEditorModes({AzToolsFramework::GetEntityContextId()});
|
||||
ASSERT_NE(m_viewportEditorModes, nullptr);
|
||||
}
|
||||
|
||||
ViewportEditorModeTrackerInterface* m_viewportEditorModeTracker = nullptr;
|
||||
@@ -316,17 +318,17 @@ namespace UnitTest
|
||||
TEST_F(ViewportEditorModeTrackerTestFixture, ActivatingViewportEditorModeForNonExistentIdCreatesViewportEditorModesForThatId)
|
||||
{
|
||||
// Given a viewport not currently being tracked
|
||||
const ViewportId viewportid = 0;
|
||||
EXPECT_FALSE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
EXPECT_EQ(m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid }), nullptr);
|
||||
const TrackerId id = 0;
|
||||
EXPECT_FALSE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
EXPECT_EQ(m_viewportEditorModeTracker.GetViewportEditorModes({ id }), nullptr);
|
||||
|
||||
// When a mode is activated for that viewport
|
||||
const auto editorMode = ViewportEditorMode::Default;
|
||||
m_viewportEditorModeTracker.ActivateMode({ viewportid }, editorMode);
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid });
|
||||
m_viewportEditorModeTracker.ActivateMode({ id }, editorMode);
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ id });
|
||||
|
||||
// Expect that viewport to now be tracked
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
EXPECT_NE(viewportEditorModeState, nullptr);
|
||||
|
||||
// Expect the mode for that viewport to be active
|
||||
@@ -336,23 +338,24 @@ namespace UnitTest
|
||||
TEST_F(ViewportEditorModeTrackerTestFixture, DeactivatingViewportEditorModeForNonExistentIdCreatesViewportEditorModesForThatIdButReturnsError)
|
||||
{
|
||||
// Given a viewport not currently being tracked
|
||||
const ViewportId viewportid = 0;
|
||||
EXPECT_FALSE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
EXPECT_EQ(m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid }), nullptr);
|
||||
const TrackerId id = 0;
|
||||
EXPECT_FALSE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
EXPECT_EQ(m_viewportEditorModeTracker.GetViewportEditorModes({ id }), nullptr);
|
||||
|
||||
// When a mode is deactivated for that viewport
|
||||
const auto editorMode = ViewportEditorMode::Default;
|
||||
const auto expectedErrorMsg = AZStd::string::format(
|
||||
"Call to DeactivateMode for mode '%u' on id '%i' without precursor call to ActivateMode", static_cast<AZ::u32>(editorMode), viewportid);
|
||||
const auto result = m_viewportEditorModeTracker.DeactivateMode({ viewportid }, editorMode);
|
||||
"Call to DeactivateMode for mode '%u' on id '%s' without precursor call to ActivateMode", static_cast<AZ::u32>(editorMode),
|
||||
id.ToString<AZStd::string>().c_str());
|
||||
const auto result = m_viewportEditorModeTracker.DeactivateMode({ id }, editorMode);
|
||||
|
||||
// Expect an error due to no precursor activation of that mode
|
||||
EXPECT_FALSE(result.IsSuccess());
|
||||
EXPECT_EQ(result.GetError(), expectedErrorMsg);
|
||||
|
||||
// Expect that viewport to now be tracked
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid });
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ id });
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
|
||||
// Expect the mode for that viewport to be inactive
|
||||
EXPECT_NE(viewportEditorModeState, nullptr);
|
||||
@@ -361,45 +364,46 @@ namespace UnitTest
|
||||
|
||||
TEST_F(ViewportEditorModeTrackerTestFixture, GettingNonExistentViewportEditorModesForIdReturnsNull)
|
||||
{
|
||||
const ViewportId viewportid = 0;
|
||||
EXPECT_FALSE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
EXPECT_EQ(m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid }), nullptr);
|
||||
const TrackerId id = 0;
|
||||
EXPECT_FALSE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
EXPECT_EQ(m_viewportEditorModeTracker.GetViewportEditorModes({ id }), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ViewportEditorModeTrackerTestFixture, ActivatingViewportEditorModesForExistingIdInThatStateReturnsError)
|
||||
{
|
||||
// Given a viewport not currently tracked
|
||||
const ViewportId viewportid = 0;
|
||||
EXPECT_FALSE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
EXPECT_EQ(m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid }), nullptr);
|
||||
const TrackerId id = 0;
|
||||
EXPECT_FALSE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
EXPECT_EQ(m_viewportEditorModeTracker.GetViewportEditorModes({ id }), nullptr);
|
||||
|
||||
const auto editorMode = ViewportEditorMode::Default;
|
||||
{
|
||||
// When the mode is activated for the viewport
|
||||
const auto result = m_viewportEditorModeTracker.ActivateMode({ viewportid }, editorMode);
|
||||
const auto result = m_viewportEditorModeTracker.ActivateMode({ id }, editorMode);
|
||||
|
||||
// Expect no error as there is no duplicate activation
|
||||
EXPECT_TRUE(result.IsSuccess());
|
||||
|
||||
// Expect the mode to be active for the viewport
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid });
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ id });
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
EXPECT_NE(viewportEditorModeState, nullptr);
|
||||
EXPECT_TRUE(viewportEditorModeState->IsModeActive(editorMode));
|
||||
}
|
||||
{
|
||||
// When the mode is activated again for the viewport
|
||||
const auto result = m_viewportEditorModeTracker.ActivateMode({ viewportid }, editorMode);
|
||||
const auto result = m_viewportEditorModeTracker.ActivateMode({ id }, editorMode);
|
||||
|
||||
// Expect an error for the duplicate activation
|
||||
const auto expectedErrorMsg = AZStd::string::format(
|
||||
"Duplicate call to ActivateMode for mode '%u' on id '%i'", static_cast<AZ::u32>(editorMode), viewportid);
|
||||
"Duplicate call to ActivateMode for mode '%u' on id '%s'", static_cast<AZ::u32>(editorMode),
|
||||
id.ToString<AZStd::string>().c_str());
|
||||
EXPECT_FALSE(result.IsSuccess());
|
||||
EXPECT_EQ(result.GetError(), expectedErrorMsg);
|
||||
|
||||
// Expect the mode to still be active for the viewport
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid });
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ id });
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
EXPECT_NE(viewportEditorModeState, nullptr);
|
||||
EXPECT_TRUE(viewportEditorModeState->IsModeActive(editorMode));
|
||||
}
|
||||
@@ -408,38 +412,39 @@ namespace UnitTest
|
||||
TEST_F(ViewportEditorModeTrackerTestFixture, DeactivatingViewportEditorModesForExistingIdNotInThatStateReturnssError)
|
||||
{
|
||||
// Given a viewport not currently tracked
|
||||
const ViewportId viewportid = 0;
|
||||
EXPECT_FALSE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
EXPECT_EQ(m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid }), nullptr);
|
||||
const TrackerId id = 0;
|
||||
EXPECT_FALSE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
EXPECT_EQ(m_viewportEditorModeTracker.GetViewportEditorModes({ id }), nullptr);
|
||||
|
||||
const auto editorMode = ViewportEditorMode::Default;
|
||||
{
|
||||
// When the mode is activated and then deactivated for the viewport
|
||||
m_viewportEditorModeTracker.ActivateMode({ viewportid }, editorMode);
|
||||
const auto result = m_viewportEditorModeTracker.DeactivateMode({ viewportid }, editorMode);
|
||||
m_viewportEditorModeTracker.ActivateMode({ id }, editorMode);
|
||||
const auto result = m_viewportEditorModeTracker.DeactivateMode({ id }, editorMode);
|
||||
|
||||
// Expect no error as there is no duplicate deactivation
|
||||
EXPECT_TRUE(result.IsSuccess());
|
||||
|
||||
// Expect the mode to be inctive for the viewport
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid });
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ id });
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
EXPECT_NE(viewportEditorModeState, nullptr);
|
||||
EXPECT_FALSE(viewportEditorModeState->IsModeActive(editorMode));
|
||||
}
|
||||
{
|
||||
// When the mode is deactivated again for the viewport
|
||||
const auto result = m_viewportEditorModeTracker.DeactivateMode({ viewportid }, editorMode);
|
||||
const auto result = m_viewportEditorModeTracker.DeactivateMode({ id }, editorMode);
|
||||
|
||||
// Expect an error for the duplicate deactivation
|
||||
const auto expectedErrorMsg = AZStd::string::format(
|
||||
"Duplicate call to DeactivateMode for mode '%u' on id '%i'", static_cast<AZ::u32>(editorMode), viewportid);
|
||||
"Duplicate call to DeactivateMode for mode '%u' on id '%s'", static_cast<AZ::u32>(editorMode),
|
||||
id.ToString<AZStd::string>().c_str());
|
||||
EXPECT_FALSE(result.IsSuccess());
|
||||
EXPECT_EQ(result.GetError(), expectedErrorMsg);
|
||||
|
||||
// Expect the mode to still be inactive for the viewport
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ viewportid });
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ viewportid }));
|
||||
const auto* viewportEditorModeState = m_viewportEditorModeTracker.GetViewportEditorModes({ id });
|
||||
EXPECT_TRUE(m_viewportEditorModeTracker.IsViewportModeTracked({ id }));
|
||||
EXPECT_NE(viewportEditorModeState, nullptr);
|
||||
EXPECT_FALSE(viewportEditorModeState->IsModeActive(editorMode));
|
||||
}
|
||||
@@ -459,9 +464,9 @@ namespace UnitTest
|
||||
// When each editor mode is activated by the state tracker for a specific viewport
|
||||
for (auto mode = 0; mode < ViewportEditorModes::NumEditorModes; mode++)
|
||||
{
|
||||
const ViewportId viewportId = mode;
|
||||
const TrackerId id = m_handlerIds[mode];
|
||||
const ViewportEditorMode editorMode = static_cast<ViewportEditorMode>(mode);
|
||||
m_viewportEditorModeTracker.ActivateMode({ viewportId }, editorMode);
|
||||
m_viewportEditorModeTracker.ActivateMode({ id }, editorMode);
|
||||
}
|
||||
|
||||
for (auto mode = 0; mode < ViewportEditorModes::NumEditorModes; mode++)
|
||||
@@ -491,10 +496,10 @@ namespace UnitTest
|
||||
// When each editor mode is activated deactivated by the state tracker for a specific viewport
|
||||
for (auto mode = 0; mode < ViewportEditorModes::NumEditorModes; mode++)
|
||||
{
|
||||
const ViewportId viewportId = mode;
|
||||
const TrackerId id = m_handlerIds[mode];
|
||||
const ViewportEditorMode editorMode = static_cast<ViewportEditorMode>(mode);
|
||||
m_viewportEditorModeTracker.ActivateMode({ viewportId }, editorMode);
|
||||
m_viewportEditorModeTracker.DeactivateMode({ viewportId }, editorMode);
|
||||
m_viewportEditorModeTracker.ActivateMode({ id }, editorMode);
|
||||
m_viewportEditorModeTracker.DeactivateMode({ id }, editorMode);
|
||||
}
|
||||
|
||||
for (auto mode = 0; mode < ViewportEditorModes::NumEditorModes; mode++)
|
||||
|
||||
@@ -627,8 +627,10 @@ namespace O3DELauncher
|
||||
AZ_TracePrintf("Launcher", "Application is configured for VFS");
|
||||
AZ_TracePrintf("Launcher", "Log and cache files will be written to the Cache directory on your host PC");
|
||||
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
constexpr const char* message = "If your game does not run, check any of the following:\n"
|
||||
"\t- Verify the remote_ip address is correct in bootstrap.cfg";
|
||||
#endif
|
||||
if (mainInfo.m_additionalVfsResolution)
|
||||
{
|
||||
AZ_TracePrintf("Launcher", "%s\n%s", message, mainInfo.m_additionalVfsResolution)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "AssetProcessorManagerTest.h"
|
||||
#include "native/AssetManager/PathDependencyManager.h"
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzToolsFramework/Asset/AssetProcessorMessages.h>
|
||||
#include <AzToolsFramework/ToolsFileUtils/ToolsFileUtils.h>
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
@@ -4130,11 +4131,21 @@ struct LockedFileTest
|
||||
MOCK_METHOD2(SendResponse, size_t (unsigned, const AzFramework::AssetSystem::BaseAssetProcessorMessage&));
|
||||
MOCK_METHOD1(RemoveResponseHandler, void (unsigned));
|
||||
|
||||
size_t Send(unsigned, const AzFramework::AssetSystem::BaseAssetProcessorMessage&) override
|
||||
size_t Send(unsigned, const AzFramework::AssetSystem::BaseAssetProcessorMessage& message) override
|
||||
{
|
||||
if(m_callback)
|
||||
using SourceFileNotificationMessage = AzToolsFramework::AssetSystem::SourceFileNotificationMessage;
|
||||
switch (message.GetMessageType())
|
||||
{
|
||||
m_callback();
|
||||
case SourceFileNotificationMessage::MessageType:
|
||||
if (const auto sourceFileMessage = azrtti_cast<const SourceFileNotificationMessage*>(&message);
|
||||
sourceFileMessage != nullptr && sourceFileMessage->m_type == SourceFileNotificationMessage::NotificationType::FileRemoved
|
||||
&& m_callback)
|
||||
{
|
||||
m_callback();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -164,7 +164,10 @@ namespace AssetUtilsInternal
|
||||
|
||||
AZ::SettingsRegistryMergeUtils::DumperSettings apDumperSettings;
|
||||
apDumperSettings.m_prettifyOutput = true;
|
||||
AZ_PUSH_DISABLE_WARNING(5233, "-Wunknown-warning-option") // Older versions of MSVC toolchain require to pass constexpr in the
|
||||
// capture. Newer versions issue unused warning
|
||||
apDumperSettings.m_includeFilter = [&AssetProcessorUserSettingsRootKey](AZStd::string_view path)
|
||||
AZ_POP_DISABLE_WARNING
|
||||
{
|
||||
// The AssetUtils only updates the following keys in the registry
|
||||
// Dump them all out to the setreg file
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <ProjectUtils.h>
|
||||
#include <ProjectManagerDefs.h>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QDir>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -18,7 +19,10 @@ namespace O3DE::ProjectManager
|
||||
|
||||
AZ::Outcome<QProcessEnvironment, QString> GetCommandLineProcessEnvironment()
|
||||
{
|
||||
return AZ::Success(QProcessEnvironment(QProcessEnvironment::systemEnvironment()));
|
||||
QProcessEnvironment currentEnvironment(QProcessEnvironment::systemEnvironment());
|
||||
currentEnvironment.insert("CC", "clang-12");
|
||||
currentEnvironment.insert("CXX", "clang++-12");
|
||||
return AZ::Success(currentEnvironment);
|
||||
}
|
||||
|
||||
AZ::Outcome<QString, QString> FindSupportedCompilerForPlatform()
|
||||
@@ -27,7 +31,7 @@ namespace O3DE::ProjectManager
|
||||
auto whichCMakeResult = ProjectUtils::ExecuteCommandResult("which", QStringList{ProjectCMakeCommand}, QProcessEnvironment::systemEnvironment());
|
||||
if (!whichCMakeResult.IsSuccess())
|
||||
{
|
||||
return AZ::Failure(QObject::tr("CMake not found. \n\n"
|
||||
return AZ::Failure(QObject::tr("CMake not found. <br><br>"
|
||||
"Make sure that the minimum version of CMake is installed and available from the command prompt. "
|
||||
"Refer to the <a href='https://o3de.org/docs/welcome-guide/setup/requirements/#cmake'>O3DE requirements</a> page for more information."));
|
||||
}
|
||||
@@ -45,10 +49,42 @@ namespace O3DE::ProjectManager
|
||||
return AZ::Success(supportClangCommand);
|
||||
}
|
||||
}
|
||||
return AZ::Failure(QObject::tr("Clang not found. \n\n"
|
||||
return AZ::Failure(QObject::tr("Clang not found. <br><br>"
|
||||
"Make sure that the clang is installed and available from the command prompt. "
|
||||
"Refer to the <a href='https://o3de.org/docs/welcome-guide/setup/requirements/#cmake'>O3DE requirements</a> page for more information."));
|
||||
}
|
||||
|
||||
|
||||
AZ::Outcome<void, QString> OpenCMakeGUI(const QString& projectPath)
|
||||
{
|
||||
AZ::Outcome processEnvResult = GetCommandLineProcessEnvironment();
|
||||
if (!processEnvResult.IsSuccess())
|
||||
{
|
||||
return AZ::Failure(processEnvResult.GetError());
|
||||
}
|
||||
|
||||
QString projectBuildPath = QDir(projectPath).filePath(ProjectBuildPathPostfix);
|
||||
AZ::Outcome projectBuildPathResult = GetProjectBuildPath(projectPath);
|
||||
if (projectBuildPathResult.IsSuccess())
|
||||
{
|
||||
projectBuildPath = projectBuildPathResult.GetValue();
|
||||
}
|
||||
|
||||
QProcess process;
|
||||
process.setProcessEnvironment(processEnvResult.GetValue());
|
||||
|
||||
// if the project build path is relative, it should be relative to the project path
|
||||
process.setWorkingDirectory(projectPath);
|
||||
|
||||
process.setProgram("cmake-gui");
|
||||
process.setArguments({ "-S", projectPath, "-B", projectBuildPath });
|
||||
if(!process.startDetached())
|
||||
{
|
||||
return AZ::Failure(QObject::tr("Failed to start CMake GUI"));
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
}
|
||||
|
||||
} // namespace ProjectUtils
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <ProjectUtils.h>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -61,5 +62,37 @@ namespace O3DE::ProjectManager
|
||||
|
||||
return AZ::Success(xcodeBuilderVersionNumber);
|
||||
}
|
||||
|
||||
AZ::Outcome<void, QString> OpenCMakeGUI(const QString& projectPath)
|
||||
{
|
||||
const QString cmakeHelp = QObject::tr("Please verify you've installed CMake.app from "
|
||||
"<a href=\"https://cmake.org\">cmake.org</a> or, if using HomeBrew, "
|
||||
"have installed it with <pre>brew install --cask cmake</pre>");
|
||||
QString cmakeAppPath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, "CMake.app", QStandardPaths::LocateDirectory);
|
||||
if (cmakeAppPath.isEmpty())
|
||||
{
|
||||
return AZ::Failure(QObject::tr("CMake.app not found.") + cmakeHelp);
|
||||
}
|
||||
|
||||
QString projectBuildPath = QDir(projectPath).filePath(ProjectBuildPathPostfix);
|
||||
AZ::Outcome result = GetProjectBuildPath(projectPath);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
projectBuildPath = result.GetValue();
|
||||
}
|
||||
|
||||
QProcess process;
|
||||
|
||||
// if the project build path is relative, it should be relative to the project path
|
||||
process.setWorkingDirectory(projectPath);
|
||||
process.setProgram("open");
|
||||
process.setArguments({"-a", "CMake", "--args", "-S", projectPath, "-B", projectBuildPath});
|
||||
if(!process.startDetached())
|
||||
{
|
||||
return AZ::Failure(QObject::tr("CMake.app failed to open.") + cmakeHelp);
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
}
|
||||
} // namespace ProjectUtils
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user