conflict fix
Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
import os, traceback, binascii, sys, json, pathlib, logging
|
||||
import azlmbr.math
|
||||
import azlmbr.bus
|
||||
from scene_helpers import *
|
||||
|
||||
#
|
||||
# SceneAPI Processor
|
||||
#
|
||||
|
||||
def update_manifest(scene):
|
||||
import uuid
|
||||
import azlmbr.scene as sceneApi
|
||||
import azlmbr.scene.graph
|
||||
from scene_api import scene_data as sceneData
|
||||
|
||||
graph = sceneData.SceneGraph(scene.graph)
|
||||
# Get a list of all the mesh nodes, as well as all the nodes
|
||||
mesh_name_list, all_node_paths = get_mesh_node_names(graph)
|
||||
mesh_name_list.sort(key=lambda node: str.casefold(node.get_path()))
|
||||
scene_manifest = sceneData.SceneManifest()
|
||||
|
||||
clean_filename = scene.sourceFilename.replace('.', '_')
|
||||
|
||||
# Compute the filename of the scene file
|
||||
source_basepath = scene.watchFolder
|
||||
source_relative_path = os.path.dirname(os.path.relpath(clean_filename, source_basepath))
|
||||
source_filename_only = os.path.basename(clean_filename)
|
||||
|
||||
created_entities = []
|
||||
previous_entity_id = azlmbr.entity.InvalidEntityId
|
||||
first_mesh = True
|
||||
|
||||
# Make a list of mesh node paths
|
||||
mesh_path_list = list(map(lambda node: node.get_path(), mesh_name_list))
|
||||
|
||||
# Assume the first mesh is the main mesh
|
||||
main_mesh = mesh_name_list[0]
|
||||
mesh_path = main_mesh.get_path()
|
||||
|
||||
# Create a unique mesh group name using the filename + node name
|
||||
mesh_group_name = '{}_{}'.format(source_filename_only, main_mesh.get_name())
|
||||
# Remove forbidden filename characters from the name since this will become a file on disk later
|
||||
mesh_group_name = "".join(char for char in mesh_group_name if char not in "|<>:\"/?*\\")
|
||||
# Add the MeshGroup to the manifest and give it a unique ID
|
||||
mesh_group = scene_manifest.add_mesh_group(mesh_group_name)
|
||||
mesh_group['id'] = '{' + str(uuid.uuid5(uuid.NAMESPACE_DNS, source_filename_only + mesh_path)) + '}'
|
||||
# Set our current node as the only node that is included in this MeshGroup
|
||||
scene_manifest.mesh_group_select_node(mesh_group, mesh_path)
|
||||
|
||||
# Explicitly remove all other nodes to prevent implicit inclusions
|
||||
for node in mesh_path_list:
|
||||
if node != mesh_path:
|
||||
scene_manifest.mesh_group_unselect_node(mesh_group, node)
|
||||
|
||||
# Create a LOD rule
|
||||
lod_rule = scene_manifest.mesh_group_add_lod_rule(mesh_group)
|
||||
|
||||
# Loop all the mesh nodes after the first
|
||||
for x in mesh_path_list[1:]:
|
||||
# Add a new LOD level
|
||||
lod = scene_manifest.lod_rule_add_lod(lod_rule)
|
||||
# Select the current mesh for this LOD level
|
||||
scene_manifest.lod_select_node(lod, x)
|
||||
|
||||
# Unselect every other mesh for this LOD level
|
||||
for y in mesh_path_list:
|
||||
if y != x:
|
||||
scene_manifest.lod_unselect_node(lod, y)
|
||||
|
||||
# Create an editor entity
|
||||
entity_id = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "CreateEditorReadyEntity", mesh_group_name)
|
||||
# Add an EditorMeshComponent to the entity
|
||||
editor_mesh_component = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "GetOrAddComponentByTypeName", entity_id, "AZ::Render::EditorMeshComponent")
|
||||
# Set the ModelAsset assetHint to the relative path of the input asset + the name of the MeshGroup we just created + the azmodel extension
|
||||
# The MeshGroup we created will be output as a product in the asset's path named mesh_group_name.azmodel
|
||||
# The assetHint will be converted to an AssetId later during prefab loading
|
||||
json_update = json.dumps({
|
||||
"Controller": { "Configuration": { "ModelAsset": {
|
||||
"assetHint": os.path.join(source_relative_path, mesh_group_name) + ".azmodel" }}}
|
||||
});
|
||||
# Apply the JSON above to the component we created
|
||||
result = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "UpdateComponentForEntity", entity_id, editor_mesh_component, json_update)
|
||||
|
||||
if not result:
|
||||
raise RuntimeError("UpdateComponentForEntity failed for Mesh component")
|
||||
|
||||
create_prefab(scene_manifest, source_filename_only, [entity_id])
|
||||
|
||||
# Convert the manifest to a JSON string and return it
|
||||
new_manifest = scene_manifest.export()
|
||||
|
||||
return new_manifest
|
||||
|
||||
sceneJobHandler = None
|
||||
|
||||
def on_update_manifest(args):
|
||||
try:
|
||||
scene = args[0]
|
||||
return update_manifest(scene)
|
||||
except RuntimeError as err:
|
||||
print (f'ERROR - {err}')
|
||||
log_exception_traceback()
|
||||
except:
|
||||
log_exception_traceback()
|
||||
|
||||
global sceneJobHandler
|
||||
sceneJobHandler = None
|
||||
|
||||
# try to create SceneAPI handler for processing
|
||||
try:
|
||||
import azlmbr.scene as sceneApi
|
||||
if (sceneJobHandler == None):
|
||||
sceneJobHandler = sceneApi.ScriptBuildingNotificationBusHandler()
|
||||
sceneJobHandler.connect()
|
||||
sceneJobHandler.add_callback('OnUpdateManifest', on_update_manifest)
|
||||
except:
|
||||
sceneJobHandler = None
|
||||
@@ -0,0 +1,95 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
import traceback, logging, json
|
||||
from typing import Tuple, List
|
||||
|
||||
import azlmbr.bus
|
||||
from scene_api import scene_data as sceneData
|
||||
from scene_api.scene_data import SceneGraphName
|
||||
|
||||
|
||||
def log_exception_traceback():
|
||||
"""
|
||||
Outputs an exception stacktrace.
|
||||
"""
|
||||
data = traceback.format_exc()
|
||||
logger = logging.getLogger('python')
|
||||
logger.error(data)
|
||||
|
||||
|
||||
def sanitize_name_for_disk(name: str):
|
||||
"""
|
||||
Removes illegal filename characters from a string.
|
||||
|
||||
:param name: String to clean.
|
||||
:return: Name with illegal characters removed.
|
||||
"""
|
||||
return "".join(char for char in name if char not in "|<>:\"/?*\\")
|
||||
|
||||
|
||||
def get_mesh_node_names(scene_graph: sceneData.SceneGraph) -> Tuple[List[SceneGraphName], List[str]]:
|
||||
"""
|
||||
Returns a tuple of all the mesh nodes as well as all the node paths
|
||||
|
||||
:param scene_graph: Scene graph to search
|
||||
:return: Tuple of [Mesh Nodes, All Node Paths]
|
||||
"""
|
||||
import azlmbr.scene as sceneApi
|
||||
import azlmbr.scene.graph
|
||||
|
||||
mesh_data_list = []
|
||||
node = scene_graph.get_root()
|
||||
children = []
|
||||
paths = []
|
||||
|
||||
while node.IsValid():
|
||||
# store children to process after siblings
|
||||
if scene_graph.has_node_child(node):
|
||||
children.append(scene_graph.get_node_child(node))
|
||||
|
||||
node_name = sceneData.SceneGraphName(scene_graph.get_node_name(node))
|
||||
paths.append(node_name.get_path())
|
||||
|
||||
# store any node that has mesh data content
|
||||
node_content = scene_graph.get_node_content(node)
|
||||
if node_content.CastWithTypeName('MeshData'):
|
||||
if scene_graph.is_node_end_point(node) is False:
|
||||
if len(node_name.get_path()):
|
||||
mesh_data_list.append(sceneData.SceneGraphName(scene_graph.get_node_name(node)))
|
||||
|
||||
# advance to next node
|
||||
if scene_graph.has_node_sibling(node):
|
||||
node = scene_graph.get_node_sibling(node)
|
||||
elif children:
|
||||
node = children.pop()
|
||||
else:
|
||||
node = azlmbr.scene.graph.NodeIndex()
|
||||
|
||||
return mesh_data_list, paths
|
||||
|
||||
|
||||
def create_prefab(scene_manifest: sceneData.SceneManifest, prefab_name: str, entities: list) -> None:
|
||||
prefab_filename = prefab_name + ".prefab"
|
||||
created_template_id = azlmbr.prefab.PrefabSystemScriptingBus(azlmbr.bus.Broadcast, "CreatePrefab", entities,
|
||||
prefab_filename)
|
||||
|
||||
if created_template_id is None or created_template_id == azlmbr.prefab.InvalidTemplateId:
|
||||
raise RuntimeError("CreatePrefab {} failed".format(prefab_filename))
|
||||
|
||||
# Convert the prefab to a JSON string
|
||||
output = azlmbr.prefab.PrefabLoaderScriptingBus(azlmbr.bus.Broadcast, "SaveTemplateToString", created_template_id)
|
||||
|
||||
if output is not None and output.IsSuccess():
|
||||
json_string = output.GetValue()
|
||||
uuid = azlmbr.math.Uuid_CreateRandom().ToString()
|
||||
json_result = json.loads(json_string)
|
||||
# Add a PrefabGroup to the manifest and store the JSON on it
|
||||
scene_manifest.add_prefab_group(prefab_name, uuid, json_result)
|
||||
else:
|
||||
raise RuntimeError(
|
||||
"SaveTemplateToString failed for template id {}, prefab {}".format(created_template_id, prefab_filename))
|
||||
@@ -5,55 +5,16 @@
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
import os, traceback, binascii, sys, json, pathlib
|
||||
import azlmbr.math
|
||||
import azlmbr.bus
|
||||
import azlmbr.math
|
||||
|
||||
from scene_helpers import *
|
||||
|
||||
|
||||
#
|
||||
# SceneAPI Processor
|
||||
#
|
||||
|
||||
|
||||
def log_exception_traceback():
|
||||
exc_type, exc_value, exc_tb = sys.exc_info()
|
||||
data = traceback.format_exception(exc_type, exc_value, exc_tb)
|
||||
print(str(data))
|
||||
|
||||
def get_mesh_node_names(sceneGraph):
|
||||
import azlmbr.scene as sceneApi
|
||||
import azlmbr.scene.graph
|
||||
from scene_api import scene_data as sceneData
|
||||
|
||||
meshDataList = []
|
||||
node = sceneGraph.get_root()
|
||||
children = []
|
||||
paths = []
|
||||
|
||||
while node.IsValid():
|
||||
# store children to process after siblings
|
||||
if sceneGraph.has_node_child(node):
|
||||
children.append(sceneGraph.get_node_child(node))
|
||||
|
||||
nodeName = sceneData.SceneGraphName(sceneGraph.get_node_name(node))
|
||||
paths.append(nodeName.get_path())
|
||||
|
||||
# store any node that has mesh data content
|
||||
nodeContent = sceneGraph.get_node_content(node)
|
||||
if nodeContent.CastWithTypeName('MeshData'):
|
||||
if sceneGraph.is_node_end_point(node) is False:
|
||||
if (len(nodeName.get_path())):
|
||||
meshDataList.append(sceneData.SceneGraphName(sceneGraph.get_node_name(node)))
|
||||
|
||||
# advance to next node
|
||||
if sceneGraph.has_node_sibling(node):
|
||||
node = sceneGraph.get_node_sibling(node)
|
||||
elif children:
|
||||
node = children.pop()
|
||||
else:
|
||||
node = azlmbr.scene.graph.NodeIndex()
|
||||
|
||||
return meshDataList, paths
|
||||
|
||||
def add_material_component(entity_id):
|
||||
# Create an override AZ::Render::EditorMaterialComponent
|
||||
editor_material_component = azlmbr.entity.EntityUtilityBus(
|
||||
@@ -64,24 +25,24 @@ def add_material_component(entity_id):
|
||||
|
||||
# this fills out the material asset to a known product AZMaterial asset relative path
|
||||
json_update = json.dumps({
|
||||
"Controller": { "Configuration": { "materials": [
|
||||
{
|
||||
"Key": {},
|
||||
"Value": { "MaterialAsset":{
|
||||
"assetHint": "materials/basic_grey.azmaterial"
|
||||
}}
|
||||
}]
|
||||
}}
|
||||
});
|
||||
result = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "UpdateComponentForEntity", entity_id, editor_material_component, json_update)
|
||||
"Controller": {"Configuration": {"materials": [
|
||||
{
|
||||
"Key": {},
|
||||
"Value": {"MaterialAsset": {
|
||||
"assetHint": "materials/basic_grey.azmaterial"
|
||||
}}
|
||||
}]
|
||||
}}
|
||||
})
|
||||
result = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "UpdateComponentForEntity", entity_id,
|
||||
editor_material_component, json_update)
|
||||
|
||||
if not result:
|
||||
raise RuntimeError("UpdateComponentForEntity for editor_material_component failed")
|
||||
|
||||
|
||||
def update_manifest(scene):
|
||||
import json
|
||||
import uuid, os
|
||||
import azlmbr.scene as sceneApi
|
||||
import azlmbr.scene.graph
|
||||
from scene_api import scene_data as sceneData
|
||||
|
||||
@@ -89,9 +50,9 @@ def update_manifest(scene):
|
||||
# Get a list of all the mesh nodes, as well as all the nodes
|
||||
mesh_name_list, all_node_paths = get_mesh_node_names(graph)
|
||||
scene_manifest = sceneData.SceneManifest()
|
||||
|
||||
|
||||
clean_filename = scene.sourceFilename.replace('.', '_')
|
||||
|
||||
|
||||
# Compute the filename of the scene file
|
||||
source_basepath = scene.watchFolder
|
||||
source_relative_path = os.path.dirname(os.path.relpath(clean_filename, source_basepath))
|
||||
@@ -108,31 +69,39 @@ def update_manifest(scene):
|
||||
# Create a unique mesh group name using the filename + node name
|
||||
mesh_group_name = '{}_{}'.format(source_filename_only, mesh_name.get_name())
|
||||
# Remove forbidden filename characters from the name since this will become a file on disk later
|
||||
mesh_group_name = "".join(char for char in mesh_group_name if char not in "|<>:\"/?*\\")
|
||||
mesh_group_name = sanitize_name_for_disk(mesh_group_name)
|
||||
# Add the MeshGroup to the manifest and give it a unique ID
|
||||
mesh_group = scene_manifest.add_mesh_group(mesh_group_name)
|
||||
mesh_group['id'] = '{' + str(uuid.uuid5(uuid.NAMESPACE_DNS, source_filename_only + mesh_path)) + '}'
|
||||
# Set our current node as the only node that is included in this MeshGroup
|
||||
scene_manifest.mesh_group_select_node(mesh_group, mesh_path)
|
||||
scene_manifest.mesh_group_add_comment(mesh_group, "Hello World")
|
||||
|
||||
# Explicitly remove all other nodes to prevent implicit inclusions
|
||||
for node in all_node_paths:
|
||||
if node != mesh_path:
|
||||
scene_manifest.mesh_group_unselect_node(mesh_group, node)
|
||||
|
||||
scene_manifest.mesh_group_add_cloth_rule(mesh_group, mesh_path, "Col0", 1, "Col0", 2, "Col0", 2, 3)
|
||||
scene_manifest.mesh_group_add_advanced_mesh_rule(mesh_group, True, False, True, "Col0")
|
||||
scene_manifest.mesh_group_add_skin_rule(mesh_group, 3, 0.002)
|
||||
scene_manifest.mesh_group_add_tangent_rule(mesh_group, 1, 0)
|
||||
|
||||
# Create an editor entity
|
||||
entity_id = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "CreateEditorReadyEntity", mesh_group_name)
|
||||
# Add an EditorMeshComponent to the entity
|
||||
editor_mesh_component = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "GetOrAddComponentByTypeName", entity_id, "AZ::Render::EditorMeshComponent")
|
||||
# Set the ModelAsset assetHint to the relative path of the input asset + the name of the MeshGroup we just created + the azmodel extension
|
||||
# The MeshGroup we created will be output as a product in the asset's path named mesh_group_name.azmodel
|
||||
# The assetHint will be converted to an AssetId later during prefab loading
|
||||
editor_mesh_component = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "GetOrAddComponentByTypeName",
|
||||
entity_id, "AZ::Render::EditorMeshComponent")
|
||||
# Set the ModelAsset assetHint to the relative path of the input asset + the name of the MeshGroup we just
|
||||
# created + the azmodel extension The MeshGroup we created will be output as a product in the asset's path
|
||||
# named mesh_group_name.azmodel The assetHint will be converted to an AssetId later during prefab loading
|
||||
json_update = json.dumps({
|
||||
"Controller": { "Configuration": { "ModelAsset": {
|
||||
"assetHint": os.path.join(source_relative_path, mesh_group_name) + ".azmodel" }}}
|
||||
});
|
||||
"Controller": {"Configuration": {"ModelAsset": {
|
||||
"assetHint": os.path.join(source_relative_path, mesh_group_name) + ".azmodel"}}}
|
||||
})
|
||||
# Apply the JSON above to the component we created
|
||||
result = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "UpdateComponentForEntity", entity_id, editor_mesh_component, json_update)
|
||||
result = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "UpdateComponentForEntity", entity_id,
|
||||
editor_mesh_component, json_update)
|
||||
|
||||
if not result:
|
||||
raise RuntimeError("UpdateComponentForEntity failed for Mesh component")
|
||||
@@ -143,17 +112,19 @@ def update_manifest(scene):
|
||||
add_material_component(entity_id)
|
||||
|
||||
# Get the transform component
|
||||
transform_component = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "GetOrAddComponentByTypeName", entity_id, "27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0")
|
||||
transform_component = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "GetOrAddComponentByTypeName",
|
||||
entity_id, "27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0")
|
||||
|
||||
# Set this entity to be a child of the last entity we created
|
||||
# This is just an example of how to do parenting and isn't necessarily useful to parent everything like this
|
||||
if previous_entity_id is not None:
|
||||
transform_json = json.dumps({
|
||||
"Parent Entity" : previous_entity_id.to_json()
|
||||
});
|
||||
"Parent Entity": previous_entity_id.to_json()
|
||||
})
|
||||
|
||||
# Apply the JSON update
|
||||
result = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "UpdateComponentForEntity", entity_id, transform_component, transform_json)
|
||||
result = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "UpdateComponentForEntity", entity_id,
|
||||
transform_component, transform_json)
|
||||
|
||||
if not result:
|
||||
raise RuntimeError("UpdateComponentForEntity failed for Transform component")
|
||||
@@ -165,37 +136,23 @@ def update_manifest(scene):
|
||||
created_entities.append(entity_id)
|
||||
|
||||
# Create a prefab with all our entities
|
||||
prefab_filename = source_filename_only + ".prefab"
|
||||
created_template_id = azlmbr.prefab.PrefabSystemScriptingBus(azlmbr.bus.Broadcast, "CreatePrefab", created_entities, prefab_filename)
|
||||
|
||||
if created_template_id == azlmbr.prefab.InvalidTemplateId:
|
||||
raise RuntimeError("CreatePrefab {} failed".format(prefab_filename))
|
||||
|
||||
# Convert the prefab to a JSON string
|
||||
output = azlmbr.prefab.PrefabLoaderScriptingBus(azlmbr.bus.Broadcast, "SaveTemplateToString", created_template_id)
|
||||
|
||||
if output.IsSuccess():
|
||||
jsonString = output.GetValue()
|
||||
uuid = azlmbr.math.Uuid_CreateRandom().ToString()
|
||||
jsonResult = json.loads(jsonString)
|
||||
# Add a PrefabGroup to the manifest and store the JSON on it
|
||||
scene_manifest.add_prefab_group(source_filename_only, uuid, jsonResult)
|
||||
else:
|
||||
raise RuntimeError("SaveTemplateToString failed for template id {}, prefab {}".format(created_template_id, prefab_filename))
|
||||
create_prefab(scene_manifest, source_filename_only, created_entities)
|
||||
|
||||
# Convert the manifest to a JSON string and return it
|
||||
new_manifest = scene_manifest.export()
|
||||
|
||||
return new_manifest
|
||||
|
||||
|
||||
sceneJobHandler = None
|
||||
|
||||
|
||||
def on_update_manifest(args):
|
||||
try:
|
||||
scene = args[0]
|
||||
return update_manifest(scene)
|
||||
except RuntimeError as err:
|
||||
print (f'ERROR - {err}')
|
||||
print(f'ERROR - {err}')
|
||||
log_exception_traceback()
|
||||
except:
|
||||
log_exception_traceback()
|
||||
@@ -203,10 +160,12 @@ def on_update_manifest(args):
|
||||
global sceneJobHandler
|
||||
sceneJobHandler = None
|
||||
|
||||
|
||||
# try to create SceneAPI handler for processing
|
||||
try:
|
||||
import azlmbr.scene as sceneApi
|
||||
if (sceneJobHandler == None):
|
||||
|
||||
if sceneJobHandler is None:
|
||||
sceneJobHandler = sceneApi.ScriptBuildingNotificationBusHandler()
|
||||
sceneJobHandler.connect()
|
||||
sceneJobHandler.add_callback('OnUpdateManifest', on_update_manifest)
|
||||
|
||||
@@ -149,11 +149,14 @@ class AtomComponentProperties:
|
||||
def display_mapper(property: str = 'name') -> str:
|
||||
"""
|
||||
Display Mapper component properties.
|
||||
- 'LDR color Grading LUT' is the Low Definition Range (LDR) color grading for Look-up Textures (LUT) which is
|
||||
an Asset.id value corresponding to a lighting asset file.
|
||||
:param property: From the last element of the property tree path. Default 'name' for component name string.
|
||||
:return: Full property path OR component name if no property specified.
|
||||
"""
|
||||
properties = {
|
||||
'name': 'Display Mapper',
|
||||
'LDR color Grading LUT': 'Controller|Configuration|LDR color Grading LUT',
|
||||
}
|
||||
return properties[property]
|
||||
|
||||
@@ -390,7 +393,7 @@ class AtomComponentProperties:
|
||||
'name': 'PostFX Shape Weight Modifier',
|
||||
'requires': [AtomComponentProperties.postfx_layer()],
|
||||
'shapes': ['Axis Aligned Box Shape', 'Box Shape', 'Capsule Shape', 'Compound Shape', 'Cylinder Shape',
|
||||
'Disk Shape', 'Polygon Prism Shape', 'Quad Shape', 'Sphere Shape', 'Vegetation Reference Shape'],
|
||||
'Disk Shape', 'Polygon Prism Shape', 'Quad Shape', 'Sphere Shape', 'Shape Reference'],
|
||||
}
|
||||
return properties[property]
|
||||
|
||||
|
||||
+26
-9
@@ -5,6 +5,7 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
|
||||
class Tests:
|
||||
camera_creation = (
|
||||
"Camera Entity successfully created",
|
||||
@@ -39,6 +40,9 @@ class Tests:
|
||||
is_hidden = (
|
||||
"Entity is hidden",
|
||||
"Entity was not hidden")
|
||||
ldr_color_grading_lut = (
|
||||
"LDR color Grading LUT asset set",
|
||||
"LDR color Grading LUT asset could not be set")
|
||||
entity_deleted = (
|
||||
"Entity deleted",
|
||||
"Entity was not deleted")
|
||||
@@ -71,16 +75,19 @@ def AtomEditorComponents_DisplayMapper_AddedToEntity():
|
||||
5) Enter/Exit game mode.
|
||||
6) Test IsHidden.
|
||||
7) Test IsVisible.
|
||||
8) Delete Display Mapper entity.
|
||||
9) UNDO deletion.
|
||||
10) REDO deletion.
|
||||
11) Look for errors and asserts.
|
||||
8) Set LDR color Grading LUT asset.
|
||||
9) Delete Display Mapper entity.
|
||||
10) UNDO deletion.
|
||||
11) REDO deletion.
|
||||
12) Look for errors and asserts.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import os
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
from editor_python_test_tools.asset_utils import Asset
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.utils import Report, Tracer, TestHelper
|
||||
from Atom.atom_utils.atom_constants import AtomComponentProperties
|
||||
@@ -97,7 +104,7 @@ def AtomEditorComponents_DisplayMapper_AddedToEntity():
|
||||
Report.critical_result(Tests.display_mapper_creation, display_mapper_entity.exists())
|
||||
|
||||
# 2. Add Display Mapper component to Display Mapper entity.
|
||||
display_mapper_entity.add_component(AtomComponentProperties.display_mapper())
|
||||
display_mapper_component = display_mapper_entity.add_component(AtomComponentProperties.display_mapper())
|
||||
Report.critical_result(
|
||||
Tests.display_mapper_component,
|
||||
display_mapper_entity.has_component(AtomComponentProperties.display_mapper()))
|
||||
@@ -140,19 +147,29 @@ def AtomEditorComponents_DisplayMapper_AddedToEntity():
|
||||
general.idle_wait_frames(1)
|
||||
Report.result(Tests.is_visible, display_mapper_entity.is_visible() is True)
|
||||
|
||||
# 8. Delete Display Mapper entity.
|
||||
# 8. Set LDR color Grading LUT asset.
|
||||
display_mapper_asset_path = os.path.join("TestData", "test.lightingpreset.azasset")
|
||||
display_mapper_asset = Asset.find_asset_by_path(display_mapper_asset_path, False)
|
||||
display_mapper_component.set_component_property_value(
|
||||
AtomComponentProperties.display_mapper("LDR color Grading LUT"), display_mapper_asset.id)
|
||||
Report.result(
|
||||
Tests.ldr_color_grading_lut,
|
||||
display_mapper_component.get_component_property_value(
|
||||
AtomComponentProperties.display_mapper("LDR color Grading LUT")) == display_mapper_asset.id)
|
||||
|
||||
# 9. Delete Display Mapper entity.
|
||||
display_mapper_entity.delete()
|
||||
Report.result(Tests.entity_deleted, not display_mapper_entity.exists())
|
||||
|
||||
# 9. UNDO deletion.
|
||||
# 10. UNDO deletion.
|
||||
general.undo()
|
||||
Report.result(Tests.deletion_undo, display_mapper_entity.exists())
|
||||
|
||||
# 10. REDO deletion.
|
||||
# 11. REDO deletion.
|
||||
general.redo()
|
||||
Report.result(Tests.deletion_redo, not display_mapper_entity.exists())
|
||||
|
||||
# 11. Look for errors and asserts.
|
||||
# 12. Look for errors and asserts.
|
||||
TestHelper.wait_for_condition(lambda: error_tracer.has_errors or error_tracer.has_asserts, 1.0)
|
||||
for error_info in error_tracer.errors:
|
||||
Report.info(f"Error: {error_info.filename} {error_info.function} | {error_info.message}")
|
||||
|
||||
@@ -26,8 +26,8 @@ INSTALL
|
||||
It is recommended to set up these these tools with O3DE's CMake build commands.
|
||||
Assuming CMake is already setup on your operating system, below are some sample build commands:
|
||||
cd /path/to/od3e/
|
||||
mkdir windows_vs2019
|
||||
cd windows_vs2019
|
||||
mkdir windows
|
||||
cd windows
|
||||
cmake .. -G "Visual Studio 16 2019" -DLY_PROJECTS=AutomatedTesting
|
||||
|
||||
To manually install the project in development mode using your own installed Python interpreter:
|
||||
|
||||
+11
@@ -459,3 +459,14 @@ class EditorEntity:
|
||||
"""
|
||||
new_translation = convert_to_azvector3(new_translation)
|
||||
azlmbr.components.TransformBus(azlmbr.bus.Event, "SetLocalTranslation", self.id, new_translation)
|
||||
|
||||
# Use this only when prefab system is enabled as it will fail otherwise.
|
||||
def focus_on_owning_prefab(self) -> None:
|
||||
"""
|
||||
Focuses on the owning prefab instance of the given entity.
|
||||
:param entity: The entity used to fetch the owning prefab to focus on.
|
||||
"""
|
||||
|
||||
assert self.id.isValid(), "A valid entity id is required to focus on its owning prefab."
|
||||
focus_prefab_result = azlmbr.prefab.PrefabFocusPublicRequestBus(bus.Broadcast, "FocusOnOwningPrefab", self.id)
|
||||
assert focus_prefab_result.IsSuccess(), f"Prefab operation 'FocusOnOwningPrefab' failed. Error: {focus_prefab_result.GetError()}"
|
||||
|
||||
+32
@@ -34,6 +34,38 @@ class TestHelper:
|
||||
# JIRA: SPEC-2880
|
||||
# general.idle_wait_frames(1)
|
||||
|
||||
@staticmethod
|
||||
def create_level(level_name: str) -> bool:
|
||||
"""
|
||||
:param level_name: The name of the level to be created
|
||||
:return: True if ECreateLevelResult returns 0, False otherwise with logging to report reason
|
||||
"""
|
||||
Report.info(f"Creating level {level_name}")
|
||||
|
||||
# Use these hardcoded values to pass expected values for old terrain system until new create_level API is
|
||||
# available
|
||||
heightmap_resolution = 1024
|
||||
heightmap_meters_per_pixel = 1
|
||||
terrain_texture_resolution = 4096
|
||||
use_terrain = False
|
||||
|
||||
result = general.create_level_no_prompt(level_name, heightmap_resolution, heightmap_meters_per_pixel,
|
||||
terrain_texture_resolution, use_terrain)
|
||||
|
||||
# Result codes are ECreateLevelResult defined in CryEdit.h
|
||||
if result == 1:
|
||||
Report.info(f"{level_name} level already exists")
|
||||
elif result == 2:
|
||||
Report.info("Failed to create directory")
|
||||
elif result == 3:
|
||||
Report.info("Directory length is too long")
|
||||
elif result != 0:
|
||||
Report.info("Unknown error, failed to create level")
|
||||
else:
|
||||
Report.info(f"{level_name} level created successfully")
|
||||
|
||||
return result == 0
|
||||
|
||||
@staticmethod
|
||||
def open_level(directory : str, level : str):
|
||||
# type: (str, str) -> None
|
||||
|
||||
@@ -61,3 +61,11 @@ class TestAutomation(TestAutomationBase):
|
||||
def test_CreatePrefab_UnderAnotherPrefab(self, request, workspace, editor, launcher_platform):
|
||||
from Prefab.tests.create_prefab import CreatePrefab_UnderAnotherPrefab as test_module
|
||||
self._run_prefab_test(request, workspace, editor, test_module, autotest_mode=False)
|
||||
|
||||
def test_DeleteEntity_UnderAnotherPrefab(self, request, workspace, editor, launcher_platform):
|
||||
from Prefab.tests.delete_entity import DeleteEntity_UnderAnotherPrefab as test_module
|
||||
self._run_prefab_test(request, workspace, editor, test_module, autotest_mode=False)
|
||||
|
||||
def test_DeleteEntity_UnderLevelPrefab(self, request, workspace, editor, launcher_platform):
|
||||
from Prefab.tests.delete_entity import DeleteEntity_UnderLevelPrefab as test_module
|
||||
self._run_prefab_test(request, workspace, editor, test_module, autotest_mode=False)
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
def DeleteEntity_UnderAnotherPrefab():
|
||||
"""
|
||||
Test description:
|
||||
- Creates an entity.
|
||||
- Creates a prefab out of the above entity.
|
||||
- Focuses on the created prefab and destroys the entity within.
|
||||
Checks that the entity is correctly destroyed.
|
||||
"""
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
from editor_python_test_tools.prefab_utils import Prefab
|
||||
|
||||
import Prefab.tests.PrefabTestUtils as prefab_test_utils
|
||||
|
||||
prefab_test_utils.open_base_tests_level()
|
||||
|
||||
PREFAB_FILE_NAME = 'some_prefab'
|
||||
|
||||
# Creates a new entity at the root level
|
||||
entity = EditorEntity.create_editor_entity()
|
||||
assert entity.id.IsValid(), "Couldn't create entity."
|
||||
|
||||
# Asserts if prefab creation doesn't succeed
|
||||
child_prefab, child_instance = Prefab.create_prefab([entity], PREFAB_FILE_NAME)
|
||||
child_entity_ids_inside_prefab = child_instance.get_direct_child_entities()
|
||||
assert len(
|
||||
child_entity_ids_inside_prefab) == 1, f"{len(child_entity_ids_inside_prefab)} entities found inside prefab" \
|
||||
f" when there should have been just 1 entity"
|
||||
|
||||
child_entity_inside_prefab = child_entity_ids_inside_prefab[0]
|
||||
child_entity_inside_prefab.focus_on_owning_prefab()
|
||||
|
||||
child_entity_inside_prefab.delete()
|
||||
|
||||
# Wait till prefab propagation finishes before validating entity deletion.
|
||||
azlmbr.legacy.general.idle_wait_frames(1)
|
||||
|
||||
child_entity_ids_inside_prefab = child_instance.get_direct_child_entities()
|
||||
assert len(
|
||||
child_entity_ids_inside_prefab) == 0, f"{len(child_entity_ids_inside_prefab)} entities found inside prefab" \
|
||||
f" when there should have been 0 entities"
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(DeleteEntity_UnderAnotherPrefab)
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
def DeleteEntity_UnderLevelPrefab():
|
||||
"""
|
||||
Test description:
|
||||
- Creates an entity.
|
||||
- Destroys the created entity.
|
||||
Checks that the entity is correctly destroyed.
|
||||
"""
|
||||
|
||||
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||
import Prefab.tests.PrefabTestUtils as prefab_test_utils
|
||||
|
||||
prefab_test_utils.open_base_tests_level()
|
||||
|
||||
# Creates a new Entity at the root level
|
||||
# Asserts if creation didn't succeed
|
||||
entity = EditorEntity.create_editor_entity_at((100.0, 100.0, 100.0), name = "TestEntity")
|
||||
assert entity.id.IsValid(), "Couldn't create entity"
|
||||
|
||||
level_container_entity = EditorEntity(entity.get_parent_id())
|
||||
entity.delete()
|
||||
|
||||
# Wait till prefab propagation finishes before validating entity deletion.
|
||||
azlmbr.legacy.general.idle_wait_frames(1)
|
||||
level_container_child_entities_count = len(level_container_entity.get_children_ids())
|
||||
assert level_container_child_entities_count == 0, f"The level still has {level_container_child_entities_count}" \
|
||||
f" children when it should have 0."
|
||||
|
||||
if __name__ == "__main__":
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(DeleteEntity_UnderLevelPrefab)
|
||||
@@ -72,7 +72,7 @@ def Terrain_SupportsPhysics():
|
||||
|
||||
# 2) Create 2 test entities, one parent at 512.0, 512.0, 50.0 and one child at the default position and add the required components
|
||||
entity1_components_to_add = ["Axis Aligned Box Shape", "Terrain Layer Spawner", "Terrain Height Gradient List", "Terrain Physics Heightfield Collider", "PhysX Heightfield Collider"]
|
||||
entity2_components_to_add = ["Vegetation Reference Shape", "Gradient Transform Modifier", "FastNoise Gradient"]
|
||||
entity2_components_to_add = ["Shape Reference", "Gradient Transform Modifier", "FastNoise Gradient"]
|
||||
ball_components_to_add = ["Sphere Shape", "PhysX Collider", "PhysX Rigid Body"]
|
||||
terrain_spawner_entity = hydra.Entity("TestEntity1")
|
||||
terrain_spawner_entity.create_entity(azmath.Vector3(512.0, 512.0, 50.0), entity1_components_to_add)
|
||||
|
||||
@@ -4,7 +4,7 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
A fixture for Setting Up Asset Processor Batch workspace for tests in lmbr_test
|
||||
A fixture for Setting Up Asset Processor Batch workspace for tests
|
||||
"""
|
||||
|
||||
# Import builtin libraries
|
||||
|
||||
+5
-1
@@ -4,7 +4,7 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
A fixture for using the Asset Processor in lmbr_test, this will stop the asset processor after every test via
|
||||
A fixture for using the Asset Processor, this will stop the asset processor after every test via
|
||||
the teardown. Using the fixture at class level will stop the asset processor after the suite completes.
|
||||
Using the fixture at test level will stop asset processor after the test completes. Calling this fixture as a test argument will still run the teardown to stop the Asset Processor.
|
||||
"""
|
||||
@@ -15,6 +15,7 @@ import logging
|
||||
|
||||
# Import LyTestTools
|
||||
import ly_test_tools.o3de.asset_processor as asset_processor_commands
|
||||
import ly_test_tools.o3de.asset_processor_utils
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -36,5 +37,8 @@ def asset_processor(request: pytest.fixture, workspace: pytest.fixture) -> asset
|
||||
ap.stop()
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
for n in ly_test_tools.o3de.asset_processor_utils.processList:
|
||||
assert not ly_test_tools.o3de.asset_processor_utils.check_ap_running(n), f"{n} process did not shutdown correctly."
|
||||
|
||||
|
||||
return ap
|
||||
|
||||
@@ -103,6 +103,19 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
AZ::AssetBundlerBatch
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AssetPipelineTests.BundleMode
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/bundle_mode_tests.py
|
||||
EXCLUDE_TEST_RUN_TARGET_FROM_IDE
|
||||
TEST_SERIAL
|
||||
TEST_SUITE periodic
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
AZ::AssetBundlerBatch
|
||||
Legacy::Editor
|
||||
AutomatedTesting.Assets
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AssetPipelineTests.AssetBuilder
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/asset_builder_tests.py
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
import azlmbr.bus
|
||||
import azlmbr.editor
|
||||
import azlmbr.legacy.general
|
||||
import sys
|
||||
|
||||
# Print out the passed in bundle_path, so the outer test can verify this was sent in correctly
|
||||
bundle_path = sys.argv[1]
|
||||
print('Bundle mode test running with path {}'.format(sys.argv[1]))
|
||||
|
||||
# Turn on bundle mode. This will trigger some printouts that the outer test logic will validate.
|
||||
azlmbr.legacy.general.set_cvar_integer("sys_report_files_not_found_in_paks", 1)
|
||||
azlmbr.legacy.general.run_console(f"loadbundles {bundle_path}")
|
||||
|
||||
azlmbr.editor.EditorToolsApplicationRequestBus(azlmbr.bus.Broadcast, 'ExitNoPrompt')
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
pytest.importorskip('ly_test_tools')
|
||||
|
||||
import ly_test_tools.environment.file_system as fs
|
||||
import ly_test_tools.environment.waiter as waiter
|
||||
import ly_test_tools.log.log_monitor
|
||||
|
||||
from ..ap_fixtures.asset_processor_fixture import asset_processor as asset_processor
|
||||
from ..ap_fixtures.bundler_batch_setup_fixture import bundler_batch_setup_fixture as bundler_batch_helper
|
||||
from ..ap_fixtures.timeout_option_fixture import timeout_option_fixture as timeout
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize('launcher_platform', ['windows_editor'])
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['auto_test'])
|
||||
class TestBundleMode(object):
|
||||
def test_bundle_mode_with_levels_mounts_bundles_correctly(self, request, editor, level, launcher_platform,
|
||||
asset_processor, workspace, bundler_batch_helper):
|
||||
level_pak = os.path.join("levels", level, "level.pak")
|
||||
|
||||
bundles_folder = os.path.join(workspace.paths.project(), "Bundles")
|
||||
bundle_request_path = os.path.join(bundles_folder, "bundle.pak")
|
||||
bundle_result_path = os.path.join(bundles_folder,
|
||||
bundler_batch_helper.platform_file_name(
|
||||
"bundle.pak", workspace.asset_processor_platform))
|
||||
|
||||
# Create target 'Bundles' folder if it doesn't exist
|
||||
if not os.path.exists(bundles_folder):
|
||||
os.mkdir(bundles_folder)
|
||||
# Delete target bundle file if it already exists
|
||||
if os.path.exists(bundle_result_path):
|
||||
fs.delete([bundle_result_path], True, False)
|
||||
|
||||
# Make asset list file to use in the bundle
|
||||
bundler_batch_helper.call_assetLists(
|
||||
addSeed=level_pak,
|
||||
assetListFile=bundler_batch_helper["asset_info_file_request"],
|
||||
)
|
||||
|
||||
# Make bundle in <project_folder>/Bundles
|
||||
bundler_batch_helper.call_bundles(
|
||||
assetListFile=bundler_batch_helper["asset_info_file_result"],
|
||||
outputBundlePath=bundle_request_path,
|
||||
maxSize="2048",
|
||||
)
|
||||
|
||||
# Ensure the bundle was created
|
||||
assert os.path.exists(bundle_result_path), f"Bundle was not created at location: {bundle_result_path}"
|
||||
|
||||
# The editor flips the slash direction in some of the printouts
|
||||
bundle_result_path_editor_separator = bundle_result_path.replace('\\', '/')
|
||||
|
||||
expected_lines = [
|
||||
# A beginning of test printout can help debug where failures occur, if this line is missing
|
||||
# then the Editor didn't launch, didn't run the Python test, or didn't pass in the right parameter
|
||||
f'Bundle mode test running with path {bundles_folder}',
|
||||
# These printouts happen in response to the loadbundles call, and verify this bundle is actually loaded
|
||||
f"[CONSOLE] Executing console command 'loadbundles {bundles_folder}'",
|
||||
f'(BundlingSystem) - Loading bundles from {bundles_folder} of type .pak',
|
||||
f'(Archive) - Opening archive file {bundle_result_path_editor_separator}',
|
||||
]
|
||||
unexpected_lines = []
|
||||
|
||||
timeout = 180
|
||||
halt_on_unexpected = False
|
||||
test_directory = os.path.join(os.path.dirname(__file__))
|
||||
test_file = os.path.join(test_directory, 'bundle_mode_in_editor_tests.py')
|
||||
editor.args.extend(['-NullRenderer', '-rhi=Null', "--skipWelcomeScreenDialog",
|
||||
"--autotest_mode", "--runpythontest", test_file, "--runpythonargs", bundles_folder])
|
||||
|
||||
with editor.start(launch_ap=True):
|
||||
editor_log_file = os.path.join(editor.workspace.paths.project_log(), 'Editor.log')
|
||||
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(editor, editor_log_file)
|
||||
waiter.wait_for(
|
||||
lambda: editor.is_alive(),
|
||||
timeout,
|
||||
exc=("Log file '{}' was never opened by another process.".format(editor_log_file)),
|
||||
interval=1)
|
||||
log_monitor.monitor_log_for_lines(expected_lines, unexpected_lines, halt_on_unexpected, timeout)
|
||||
|
||||
# Delete the bundle created and used in this test
|
||||
fs.delete([bundle_result_path], True, False)
|
||||
@@ -7,60 +7,6 @@
|
||||
#
|
||||
|
||||
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_FOUNDATION_TEST_SUPPORTED)
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::EditorTests_Main
|
||||
TEST_SUITE main
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main.py
|
||||
PYTEST_MARKS "not REQUIRES_gpu"
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
Editor
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::EditorTests_Main_GPU
|
||||
TEST_SUITE main
|
||||
TEST_SERIAL
|
||||
TEST_REQUIRES gpu
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main.py
|
||||
PYTEST_MARKS "REQUIRES_gpu"
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
Editor
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::EditorTests_Periodic
|
||||
TEST_SUITE periodic
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Periodic.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
Editor
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::EditorTests_Sandbox
|
||||
TEST_SUITE sandbox
|
||||
TEST_SERIAL
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Sandbox.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
Editor
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::EditorTests_Main_Optimized
|
||||
|
||||
@@ -49,7 +49,6 @@ class TestAutomationNoAutoTestMode(EditorTestSuite):
|
||||
from .EditorScripts import AssetPicker_UI_UX as test_module
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="Optimized tests are experimental, we will enable xfail and monitor them temporarily.")
|
||||
@pytest.mark.SUITE_main
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
|
||||
@@ -11,24 +11,10 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
## DynVeg ##
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::DynamicVegetationTests_Main
|
||||
NAME AutomatedTesting::DynamicVegetationTests_Main_Optimized
|
||||
TEST_SERIAL
|
||||
TEST_SUITE main
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg/TestSuite_Main.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
AutomatedTesting.GameLauncher
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
LargeWorlds
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::DynamicVegetationTests_Periodic
|
||||
TEST_SERIAL
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg/TestSuite_Periodic.py
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg/TestSuite_Main_Optimized.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -37,7 +23,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
COMPONENT
|
||||
LargeWorlds
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::DynamicVegetationTests_Periodic_Optimized
|
||||
TEST_SERIAL
|
||||
@@ -52,20 +37,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
LargeWorlds
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME AutomatedTesting::DynamicVegetationTests_Main_Optimized
|
||||
TEST_SERIAL
|
||||
TEST_SUITE main
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/dyn_veg/TestSuite_Main_Optimized.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
AutomatedTesting.Assets
|
||||
AutomatedTesting.GameLauncher
|
||||
COMPONENT
|
||||
LargeWorlds
|
||||
)
|
||||
|
||||
## LandscapeCanvas ##
|
||||
|
||||
ly_add_pytest(
|
||||
|
||||
+2
-2
@@ -72,9 +72,9 @@ def DynamicSliceInstanceSpawner_Embedded_E2E():
|
||||
# 1) Create a new, temporary level
|
||||
lvl_name = "tmp_level"
|
||||
helper.init_idle()
|
||||
level_created = general.create_level_no_prompt(lvl_name, 1024, 1, 4096, False)
|
||||
level_created = helper.create_level(lvl_name)
|
||||
general.idle_wait(1.0)
|
||||
Report.critical_result(Tests.level_created, level_created == 0)
|
||||
Report.critical_result(Tests.level_created, level_created)
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) Create a new entity with required vegetation area components and Script Canvas component for launcher test
|
||||
|
||||
+2
-2
@@ -73,9 +73,9 @@ def DynamicSliceInstanceSpawner_External_E2E():
|
||||
# 1) Create a new, temporary level
|
||||
lvl_name = "tmp_level"
|
||||
helper.init_idle()
|
||||
level_created = general.create_level_no_prompt(lvl_name, 1024, 1, 4096, False)
|
||||
level_created = helper.create_level(lvl_name)
|
||||
general.idle_wait(1.0)
|
||||
Report.critical_result(Tests.level_created, level_created == 0)
|
||||
Report.critical_result(Tests.level_created, level_created)
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) Create a new entity with required vegetation area components and switch the Vegetation Asset List Source
|
||||
|
||||
+2
-2
@@ -76,9 +76,9 @@ def LayerBlender_E2E_Editor():
|
||||
# 1) Create a new, temporary level
|
||||
lvl_name = "tmp_level"
|
||||
helper.init_idle()
|
||||
level_created = general.create_level_no_prompt(lvl_name, 1024, 1, 4096, False)
|
||||
level_created = helper.create_level(lvl_name)
|
||||
general.idle_wait(1.0)
|
||||
Report.critical_result(Tests.level_created, level_created == 0)
|
||||
Report.critical_result(Tests.level_created, level_created)
|
||||
|
||||
general.set_current_view_position(500.49, 498.69, 46.66)
|
||||
general.set_current_view_rotation(-42.05, 0.00, -36.33)
|
||||
|
||||
+2
-2
@@ -78,7 +78,7 @@ def LayerSpawner_InheritBehaviorFlag():
|
||||
# Create Vegetation area and assign a valid asset
|
||||
veg_1 = hydra.Entity("veg_1")
|
||||
veg_1.create_entity(
|
||||
position, ["Vegetation Layer Spawner", "Vegetation Reference Shape", "Vegetation Asset List"]
|
||||
position, ["Vegetation Layer Spawner", "Shape Reference", "Vegetation Asset List"]
|
||||
)
|
||||
set_dynamic_slice_asset(veg_1, 2, os.path.join("Slices", "PinkFlower.dynamicslice"))
|
||||
veg_1.get_set_test(1, "Configuration|Shape Entity Id", blender_entity.id)
|
||||
@@ -86,7 +86,7 @@ def LayerSpawner_InheritBehaviorFlag():
|
||||
# Create second vegetation area and assign a valid asset
|
||||
veg_2 = hydra.Entity("veg_2")
|
||||
veg_2.create_entity(
|
||||
position, ["Vegetation Layer Spawner", "Vegetation Reference Shape", "Vegetation Asset List"]
|
||||
position, ["Vegetation Layer Spawner", "Shape Reference", "Vegetation Asset List"]
|
||||
)
|
||||
set_dynamic_slice_asset(veg_2, 2, os.path.join("Slices", "PurpleFlower.dynamicslice"))
|
||||
veg_2.get_set_test(1, "Configuration|Shape Entity Id", blender_entity.id)
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
def LayerSpawner_InstancesPlantInAllSupportedShapes():
|
||||
"""
|
||||
Summary:
|
||||
The level is loaded and vegetation area is created. Then the Vegetation Reference Shape
|
||||
The level is loaded and vegetation area is created. Then the Shape Reference
|
||||
component of vegetation area is pinned with entities of different shape components to check
|
||||
if the vegetation plants in different shaped areas.
|
||||
|
||||
@@ -67,7 +67,7 @@ def LayerSpawner_InstancesPlantInAllSupportedShapes():
|
||||
10.0, 10.0, 10.0,
|
||||
asset_path)
|
||||
vegetation.remove_component("Box Shape")
|
||||
vegetation.add_component("Vegetation Reference Shape")
|
||||
vegetation.add_component("Shape Reference")
|
||||
|
||||
# Create surface for planting on
|
||||
dynveg.create_surface_entity("Surface Entity", entity_position, 60.0, 60.0, 1.0)
|
||||
|
||||
@@ -12,13 +12,23 @@ import ly_test_tools.environment.file_system as file_system
|
||||
from ly_test_tools.o3de.editor_test import EditorSingleTest, EditorSharedTest, EditorParallelTest, EditorTestSuite
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="Optimized tests are experimental, we will enable xfail and monitor them temporarily.")
|
||||
@pytest.mark.SUITE_main
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(EditorTestSuite):
|
||||
|
||||
enable_prefab_system = False
|
||||
|
||||
# Helpers for test asset cleanup
|
||||
def cleanup_test_level(self, workspace):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "Levels", "tmp_level")],
|
||||
True, True)
|
||||
|
||||
def cleanup_test_slices(self, workspace):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "slices",
|
||||
"TestSlice_1.slice")], True, True)
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "slices",
|
||||
"TestSlice_2.slice")], True, True)
|
||||
|
||||
class test_DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks(EditorParallelTest):
|
||||
from .EditorScripts import DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks as test_module
|
||||
@@ -38,10 +48,7 @@ class TestAutomation(EditorTestSuite):
|
||||
class test_SpawnerSlices_SliceCreationAndVisibilityToggleWorks(EditorSingleTest):
|
||||
# Custom teardown to remove slice asset created during test
|
||||
def teardown(self, request, workspace, editor, editor_test_results, launcher_platform):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "slices",
|
||||
"TestSlice_1.slice")], True, True)
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "slices",
|
||||
"TestSlice_2.slice")], True, True)
|
||||
TestAutomation.cleanup_test_slices(self, workspace)
|
||||
from .EditorScripts import SpawnerSlices_SliceCreationAndVisibilityToggleWorks as test_module
|
||||
|
||||
class test_AssetListCombiner_CombinedDescriptorsExpressInConfiguredArea(EditorParallelTest):
|
||||
@@ -152,23 +159,29 @@ class TestAutomation(EditorTestSuite):
|
||||
class test_DynamicSliceInstanceSpawner_Embedded_E2E_Editor(EditorSingleTest):
|
||||
from .EditorScripts import DynamicSliceInstanceSpawner_Embedded_E2E as test_module
|
||||
|
||||
# Custom teardown to remove test level created during test
|
||||
# Custom setup/teardown to remove test level created during test
|
||||
def setup(self, request, workspace, editor, editor_test_results, launcher_platform):
|
||||
TestAutomation.cleanup_test_level(self, workspace)
|
||||
|
||||
def teardown(self, request, workspace, editor, editor_test_results, launcher_platform):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "Levels", "tmp_level")],
|
||||
True, True)
|
||||
TestAutomation.cleanup_test_level(self, workspace)
|
||||
|
||||
class test_DynamicSliceInstanceSpawner_External_E2E_Editor(EditorSingleTest):
|
||||
from .EditorScripts import DynamicSliceInstanceSpawner_External_E2E as test_module
|
||||
|
||||
# Custom teardown to remove test level created during test
|
||||
# Custom setup/teardown to remove test level created during test
|
||||
def setup(self, request, workspace, editor, editor_test_results, launcher_platform):
|
||||
TestAutomation.cleanup_test_level(self, workspace)
|
||||
|
||||
def teardown(self, request, workspace, editor, editor_test_results, launcher_platform):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "Levels", "tmp_level")],
|
||||
True, True)
|
||||
|
||||
TestAutomation.cleanup_test_level(self, workspace)
|
||||
|
||||
class test_LayerBlender_E2E_Editor(EditorSingleTest):
|
||||
from .EditorScripts import LayerBlender_E2E_Editor as test_module
|
||||
|
||||
# Custom teardown to remove test level created during test
|
||||
# Custom setup/teardown to remove test level created during test
|
||||
def setup(self, request, workspace, editor, editor_test_results, launcher_platform):
|
||||
TestAutomation.cleanup_test_level(self, workspace)
|
||||
|
||||
def teardown(self, request, workspace, editor, editor_test_results, launcher_platform):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "Levels", "tmp_level")],
|
||||
True, True)
|
||||
TestAutomation.cleanup_test_level(self, workspace)
|
||||
|
||||
+2
-2
@@ -96,7 +96,7 @@ def AreaNodes_DependentComponentsAdded():
|
||||
'SpawnerAreaNode': [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Asset List',
|
||||
'Vegetation Reference Shape'
|
||||
'Shape Reference'
|
||||
],
|
||||
'MeshBlockerAreaNode': [
|
||||
'Vegetation Layer Blocker (Mesh)',
|
||||
@@ -104,7 +104,7 @@ def AreaNodes_DependentComponentsAdded():
|
||||
],
|
||||
'BlockerAreaNode': [
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Reference Shape'
|
||||
'Shape Reference'
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ def Edit_DisabledNodeDuplication():
|
||||
nodes = {
|
||||
'SpawnerAreaNode': 'Vegetation Asset List',
|
||||
'MeshBlockerAreaNode': 'Mesh',
|
||||
'BlockerAreaNode': 'Vegetation Reference Shape',
|
||||
'BlockerAreaNode': 'Shape Reference',
|
||||
'FastNoiseGradientNode': 'Gradient Transform Modifier',
|
||||
'ImageGradientNode': 'Gradient Transform Modifier',
|
||||
'PerlinNoiseGradientNode': 'Gradient Transform Modifier',
|
||||
|
||||
+2
-2
@@ -104,7 +104,7 @@ def GradientNodes_DependentComponentsAdded():
|
||||
# we will be checking for
|
||||
commonComponents = [
|
||||
'Gradient Transform Modifier',
|
||||
'Vegetation Reference Shape'
|
||||
'Shape Reference'
|
||||
]
|
||||
componentNames = []
|
||||
for name in gradients:
|
||||
@@ -114,7 +114,7 @@ def GradientNodes_DependentComponentsAdded():
|
||||
|
||||
# Create nodes for the gradients that have additional required dependencies and check if
|
||||
# the Entity created by adding the node has the appropriate Component and required
|
||||
# Gradient Transform Modifier and Vegetation Reference Shape components added automatically to it
|
||||
# Gradient Transform Modifier and Shape Reference components added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7e169277bca473325281d5fe043cffc9196bd3ef46f6bffbea6e0b5e3b7194a1
|
||||
size 62700
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"values": [
|
||||
{
|
||||
"$type": "ScriptProcessorRule",
|
||||
"scriptFilename": "Editor/Scripts/auto_lod.py"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
// CryCommon
|
||||
#include <CryCommon/INavigationSystem.h>
|
||||
#include <CryCommon/LyShine/ILyShine.h>
|
||||
#include <CryCommon/MainThreadRenderRequestBus.h>
|
||||
|
||||
// Editor
|
||||
@@ -595,13 +594,6 @@ void CGameEngine::SwitchToInEditor()
|
||||
// Enable accelerators.
|
||||
GetIEditor()->EnableAcceleratos(true);
|
||||
|
||||
|
||||
// reset UI system
|
||||
if (gEnv->pLyShine)
|
||||
{
|
||||
gEnv->pLyShine->Reset();
|
||||
}
|
||||
|
||||
// [Anton] - order changed, see comments for CGameEngine::SetSimulationMode
|
||||
//! Send event to switch out of game.
|
||||
GetIEditor()->GetObjectManager()->SendEvent(EVENT_OUTOFGAME);
|
||||
|
||||
@@ -13,7 +13,6 @@ set(FILES
|
||||
EditorCommonAPI.h
|
||||
ActionOutput.h
|
||||
ActionOutput.cpp
|
||||
UiEditorDLLBus.h
|
||||
DockTitleBarWidget.cpp
|
||||
DockTitleBarWidget.h
|
||||
SaveUtilities/AsyncSaveRunner.h
|
||||
|
||||
@@ -75,17 +75,16 @@ void CImageEx::ReverseUpDown()
|
||||
}
|
||||
|
||||
uint32* pPixData = GetData();
|
||||
uint32* pReversePix = new uint32[GetWidth() * GetHeight()];
|
||||
|
||||
for (int i = GetHeight() - 1, i2 = 0; i >= 0; i--, i2++)
|
||||
const int height = GetHeight();
|
||||
const int width = GetWidth();
|
||||
for (int i = 0; i < height / 2; i++)
|
||||
{
|
||||
for (int k = 0; k < GetWidth(); k++)
|
||||
for (int j = 0; j < width; j++)
|
||||
{
|
||||
pReversePix[i2 * GetWidth() + k] = pPixData[i * GetWidth() + k];
|
||||
AZStd::swap(pPixData[i * width + j], pPixData[(height - 1 - i) * width + j]);
|
||||
}
|
||||
}
|
||||
|
||||
Attach(pReversePix, GetWidth(), GetHeight());
|
||||
}
|
||||
|
||||
void CImageEx::FillAlpha(unsigned char value)
|
||||
|
||||
@@ -325,13 +325,13 @@ namespace AZ
|
||||
|
||||
T& operator*() const
|
||||
{
|
||||
AZ_Assert(m_assetData, "Asset is not loaded");
|
||||
AZ_Assert(m_assetData, "Asset %s (%s) is not loaded", m_assetId.ToString<AZStd::string>().c_str(), m_assetHint.c_str());
|
||||
return *Get();
|
||||
}
|
||||
|
||||
T* operator->() const
|
||||
{
|
||||
AZ_Assert(m_assetData, "Asset is not loaded");
|
||||
AZ_Assert(m_assetData, "Asset %s (%s) is not loaded", m_assetId.ToString<AZStd::string>().c_str(), m_assetHint.c_str());
|
||||
return Get();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,16 @@ namespace AZ
|
||||
template <typename BASE_TYPE, ThreadSafety THREAD_SAFETY>
|
||||
inline void ConsoleDataWrapper<BASE_TYPE, THREAD_SAFETY>::operator =(const BASE_TYPE& rhs)
|
||||
{
|
||||
const BASE_TYPE currentValue = this->m_value;
|
||||
// Do the value assignment outside new value check.
|
||||
// Client code can supply a type for m_value that overrides the operator= function and trigger side effects
|
||||
// in the operator= function body. Doing the assignment outside the value change check avoids those side
|
||||
// effects not being triggered because AzCore believes the value wouldn't change.
|
||||
this->m_value = rhs;
|
||||
if (currentValue != rhs)
|
||||
{
|
||||
InvokeCallback();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename BASE_TYPE, ThreadSafety THREAD_SAFETY>
|
||||
|
||||
@@ -78,7 +78,8 @@ namespace AZ::IO
|
||||
|
||||
// native format observers
|
||||
//! Returns string_view stored within the PathView
|
||||
constexpr AZStd::string_view Native() const noexcept;
|
||||
constexpr const AZStd::string_view& Native() const noexcept;
|
||||
constexpr AZStd::string_view& Native() noexcept;
|
||||
//! Conversion operator to retrieve string_view stored within the PathView
|
||||
constexpr explicit operator AZStd::string_view() const noexcept;
|
||||
|
||||
|
||||
@@ -101,7 +101,11 @@ namespace AZ::IO
|
||||
}
|
||||
|
||||
// native format observers
|
||||
constexpr auto PathView::Native() const noexcept -> AZStd::string_view
|
||||
constexpr auto PathView::Native() const noexcept -> const AZStd::string_view&
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
constexpr auto PathView::Native() noexcept -> AZStd::string_view&
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
//
|
||||
// When AZ_CRC("My string") is used by default it will map to AZ::Crc32("My string").
|
||||
// We do have a pro-processor program which will precompute the crc for you and
|
||||
// transform that macro to AZ_CRC("My string",0xabcdef00) this will expand to just 0xabcdef00.
|
||||
// transform that macro to AZ_CRC("My string", 0x18fbd270) this will expand to just 0x18fbd270.
|
||||
// This will remove completely the "My string" from your executable, it will add it to a database and so on.
|
||||
// WHen you want to update the string, just change the string.
|
||||
// If you don't run the precompile step the code should still run fine, except it will be slower,
|
||||
@@ -24,7 +24,7 @@
|
||||
// a constant expression.
|
||||
// For example
|
||||
// switch(id) {
|
||||
// case AZ_CRC("My string",0xabcdef00): {} break; // this will compile fine
|
||||
// case AZ_CRC("My string",0x18fbd270): {} break; // this will compile fine
|
||||
// case AZ_CRC("My string"): {} break; // this will cause "error C2051: case expression not constant"
|
||||
// }
|
||||
// So it's you choice what you do, depending on your needs.
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Console/ConsoleFunctor.h>
|
||||
#include <AzCore/IO/ByteContainerStream.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/Settings/SettingsRegistryConsoleUtils.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
@@ -36,7 +37,7 @@ namespace AZ::SettingsRegistryConsoleUtils
|
||||
combinedKeyValueCommand.c_str());
|
||||
AZ::Debug::Trace::Output("SettingsRegistry", setOutput.c_str());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void ConsoleRemoveSettingsRegistryValue(SettingsRegistryInterface& settingsRegistry, const ConsoleCommandContainer& commandArgs)
|
||||
{
|
||||
@@ -57,7 +58,7 @@ namespace AZ::SettingsRegistryConsoleUtils
|
||||
AZ::Debug::Trace::Output("SettingsRegistry", removeOutput.c_str());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void ConsoleDumpSettingsRegistryValue(SettingsRegistryInterface& settingsRegistry, const ConsoleCommandContainer& commandArgs)
|
||||
{
|
||||
@@ -88,13 +89,39 @@ namespace AZ::SettingsRegistryConsoleUtils
|
||||
}
|
||||
|
||||
AZ::Debug::Trace::Output("SettingsRegistry", outputString.c_str());
|
||||
};
|
||||
}
|
||||
|
||||
static void ConsoleDumpAllSettingsRegistryValues(SettingsRegistryInterface& settingsRegistry,
|
||||
[[maybe_unused]] const ConsoleCommandContainer& commandArgs)
|
||||
{
|
||||
ConsoleDumpSettingsRegistryValue(settingsRegistry, { "" });
|
||||
};
|
||||
}
|
||||
|
||||
static void ConsoleMergeFileToSettingsRegistry(SettingsRegistryInterface& settingsRegistry, const ConsoleCommandContainer& commandArgs)
|
||||
{
|
||||
if (commandArgs.empty())
|
||||
{
|
||||
AZ_Error("SettingsRegistryConsoleUtils", false, "Command %s requires a <file path> argument to locate json file to merge",
|
||||
SettingsRegistryMergeFile);
|
||||
return;
|
||||
}
|
||||
|
||||
auto commandArgumentsIter = commandArgs.begin();
|
||||
// Extract the JSON pointer path from the argument list
|
||||
AZStd::string_view filePath{ *commandArgumentsIter++ };
|
||||
AZ::SettingsRegistryInterface::FixedValueString jsonAnchorPath;
|
||||
AZ::StringFunc::Join(jsonAnchorPath, commandArgumentsIter, commandArgs.end(), ' ');
|
||||
|
||||
const auto mergeFormat = AZ::IO::PathView(filePath).Extension() != ".setregpatch" ? AZ::SettingsRegistryInterface::Format::JsonMergePatch : AZ::SettingsRegistryInterface::Format::JsonPatch;
|
||||
if (settingsRegistry.MergeSettingsFile(filePath, mergeFormat, jsonAnchorPath))
|
||||
{
|
||||
const auto mergeFileOutput = AZ::SettingsRegistryInterface::FixedValueString::format(
|
||||
R"(Merged json file "%*.s" anchored to json path "%s" into the global settings registry)" "\n",
|
||||
AZ_STRING_ARG(filePath), jsonAnchorPath.c_str());
|
||||
AZ::Debug::Trace::Output("SettingsRegistry", mergeFileOutput.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]] ConsoleFunctorHandle RegisterAzConsoleCommands(SettingsRegistryInterface& registry, AZ::IConsole& azConsole)
|
||||
{
|
||||
@@ -115,6 +142,11 @@ namespace AZ::SettingsRegistryConsoleUtils
|
||||
resultHandle.m_consoleFunctors.emplace_back(azConsole, SettingsRegistryDumpAll,
|
||||
R"(Dumps all values from the global settings registry)" "\n",
|
||||
ConsoleFunctorFlags::Null, AZ::TypeId::CreateNull(), registry, &ConsoleDumpAllSettingsRegistryValues);
|
||||
resultHandle.m_consoleFunctors.emplace_back(azConsole, SettingsRegistryMergeFile,
|
||||
R"(Merges File into the global settings registry)" "\n"
|
||||
R"(@param file-path - path to JSON formatted file to merge)" "\n"
|
||||
R"(@param anchor-path - JSON path to anchor merge operation. Defaults to "")" "\n",
|
||||
ConsoleFunctorFlags::Null, AZ::TypeId::CreateNull(), registry, &ConsoleMergeFileToSettingsRegistry);
|
||||
|
||||
return resultHandle;
|
||||
}
|
||||
|
||||
@@ -14,15 +14,16 @@
|
||||
|
||||
namespace AZ::SettingsRegistryConsoleUtils
|
||||
{
|
||||
//! Only 4 console command are registered for the settings registry
|
||||
//! "regset", "regremove", "regdump", "regdumpall"
|
||||
//! The following console command are registered for the settings registry
|
||||
//! "regset", "regremove", "regdump", "regdumpall", "regset-file"
|
||||
//! The value should be increased if more commands are needed
|
||||
inline constexpr size_t MaxSettingsRegistryConsoleFunctors = 4;
|
||||
inline constexpr size_t MaxSettingsRegistryConsoleFunctors = 5;
|
||||
|
||||
inline constexpr const char* SettingsRegistrySet = "sr_regset";
|
||||
inline constexpr const char* SettingsRegistryRemove = "sr_regremove";
|
||||
inline constexpr const char* SettingsRegistryDump = "sr_regdump";
|
||||
inline constexpr const char* SettingsRegistryDumpAll = "sr_regdumpall";
|
||||
inline constexpr const char* SettingsRegistryMergeFile = "sr_regset_file";
|
||||
|
||||
// RAII structure which owns the instances of the Settings Registry Console commands
|
||||
// registered with an AZ Console
|
||||
@@ -51,6 +52,10 @@ namespace AZ::SettingsRegistryConsoleUtils
|
||||
//!
|
||||
//! "sr_regdumpall" accepts 0 arguments and dumps the entire settings registry
|
||||
//! NOTE: this might result in a large amount of output to the console
|
||||
//!
|
||||
//! "sr_regset_file" accepts 1 or 2 arguments - <file-path> [<anchor json path>]
|
||||
//! Merges the json formatted file <file path> into the settings registry underneath the root anchor ""
|
||||
//! or <anchor json path> if supplied
|
||||
[[nodiscard]] ConsoleFunctorHandle RegisterAzConsoleCommands(SettingsRegistryInterface& registry, AZ::IConsole& azConsole);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Settings/CommandLine.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/std/string/wildcard.h>
|
||||
#include <AzCore/std/tuple.h>
|
||||
#include <AzCore/std/containers/variant.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
#include <cinttypes>
|
||||
@@ -983,7 +980,7 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
// code in the loop makes calls that mutates the `commandLine` instance, invalidating the iterators. Making a copy
|
||||
// ensures that the iterators remain valid.
|
||||
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
||||
void MergeSettingsToRegistry_CommandLine(SettingsRegistryInterface& registry, AZ::CommandLine commandLine, bool executeCommands)
|
||||
void MergeSettingsToRegistry_CommandLine(SettingsRegistryInterface& registry, AZ::CommandLine commandLine, bool executeRegdumpCommands)
|
||||
{
|
||||
// Iterate over all the command line options in order to parse the --regset and --regremove
|
||||
// arguments in the order they were supplied
|
||||
@@ -998,18 +995,44 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (commandArgument.m_option == "regset-file")
|
||||
{
|
||||
AZStd::string_view fileArg(commandArgument.m_value);
|
||||
AZStd::string_view jsonAnchorPath;
|
||||
// double colons is treated as the separator for an anchor path
|
||||
// single colon cannot be used as it is used in Windows paths
|
||||
if (auto anchorPathIndex = AZ::StringFunc::Find(fileArg, "::");
|
||||
anchorPathIndex != AZStd::string_view::npos)
|
||||
{
|
||||
jsonAnchorPath = fileArg.substr(anchorPathIndex + 2);
|
||||
fileArg = fileArg.substr(0, anchorPathIndex);
|
||||
}
|
||||
if (!fileArg.empty())
|
||||
{
|
||||
AZ::IO::PathView filePath(fileArg);
|
||||
const auto mergeFormat = filePath.Extension() != ".setregpatch"
|
||||
? AZ::SettingsRegistryInterface::Format::JsonMergePatch
|
||||
: AZ::SettingsRegistryInterface::Format::JsonPatch;
|
||||
if (!registry.MergeSettingsFile(filePath.Native(), mergeFormat, jsonAnchorPath))
|
||||
{
|
||||
AZ_Warning("SettingsRegistryMergeUtils", false, R"(Merging of file "%.*s" to the Settings Registry has failed at anchor "%.*s".)",
|
||||
AZ_STRING_ARG(filePath.Native()), AZ_STRING_ARG(jsonAnchorPath));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (commandArgument.m_option == "regremove")
|
||||
{
|
||||
if (!registry.Remove(commandArgument.m_value))
|
||||
{
|
||||
AZ_Warning("SettingsRegistryMergeUtils", false, "Unable to remove value at JSON Pointer %s for --regremove.",
|
||||
commandArgument.m_value.data());
|
||||
commandArgument.m_value.c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (executeCommands)
|
||||
if (executeRegdumpCommands)
|
||||
{
|
||||
constexpr bool prettifyOutput = true;
|
||||
const size_t regdumpSwitchValues = commandLine.GetNumSwitchValues("regdump");
|
||||
|
||||
@@ -157,6 +157,22 @@ namespace AZ::Statistics
|
||||
}
|
||||
}
|
||||
|
||||
void GetAllStatistics(AZStd::vector<NamedRunningStatistic*>& stats)
|
||||
{
|
||||
for (auto& iter : m_profilers)
|
||||
{
|
||||
iter.second.m_profiler.GetStatsManager().GetAllStatistics(stats);
|
||||
}
|
||||
}
|
||||
|
||||
void GetAllStatisticsOfUnits(AZStd::vector<NamedRunningStatistic*>& stats, const char* units)
|
||||
{
|
||||
for (auto& iter : m_profilers)
|
||||
{
|
||||
iter.second.m_profiler.GetStatsManager().GetAllStatisticsOfUnits(stats, units);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
struct ProfilerInfo
|
||||
{
|
||||
|
||||
@@ -56,13 +56,25 @@ namespace AZ
|
||||
|
||||
void GetAllStatistics(AZStd::vector<NamedRunningStatistic*>& vector)
|
||||
{
|
||||
for (auto const& it : m_statistics)
|
||||
for (const auto& it : m_statistics)
|
||||
{
|
||||
NamedRunningStatistic* stat = it.second;
|
||||
vector.push_back(stat);
|
||||
}
|
||||
}
|
||||
|
||||
void GetAllStatisticsOfUnits(AZStd::vector<NamedRunningStatistic*>& vector, const char* units)
|
||||
{
|
||||
for (const auto& it : m_statistics)
|
||||
{
|
||||
NamedRunningStatistic* stat = it.second;
|
||||
if (stat->GetUnits() == units)
|
||||
{
|
||||
vector.push_back(stat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Helper method to apply units to statistics with empty units string.
|
||||
AZ::u32 ApplyUnits(const AZStd::string& units)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <AzCore/std/functional.h>
|
||||
#include <AzCore/std/parallel/condition_variable.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AzCore/UnitTest/Mocks/MockFileIOBase.h>
|
||||
#include <AZTestShared/Utils/Utils.h>
|
||||
#include <Streamer/IStreamerMock.h>
|
||||
#include <Tests/Asset/BaseAssetManagerTest.h>
|
||||
@@ -131,8 +132,8 @@ namespace UnitTest
|
||||
* This will test the aspect of the system where ObjectStreams and asset jobs loading dependent
|
||||
* assets will do the work in their own thread.
|
||||
*/
|
||||
class AssetJobsFloodTest
|
||||
: public BaseAssetManagerTest
|
||||
|
||||
class AssetJobsFloodTest : public DisklessAssetManagerBase
|
||||
{
|
||||
public:
|
||||
TestAssetManager* m_testAssetManager{ nullptr };
|
||||
@@ -183,15 +184,14 @@ namespace UnitTest
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
BaseAssetManagerTest::SetUp();
|
||||
DisklessAssetManagerBase::SetUp();
|
||||
SetupTest();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
TearDownTest();
|
||||
AssetManager::Destroy();
|
||||
BaseAssetManagerTest::TearDown();
|
||||
DisklessAssetManagerBase::TearDown();
|
||||
}
|
||||
|
||||
void SetupAssets()
|
||||
@@ -257,9 +257,9 @@ namespace UnitTest
|
||||
AssetWithSerializedData ap2;
|
||||
AssetWithSerializedData ap3;
|
||||
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset4.txt", AZ::DataStream::ST_XML, &ap1, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset5.txt", AZ::DataStream::ST_XML, &ap2, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset6.txt", AZ::DataStream::ST_XML, &ap3, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset4.txt", &ap1, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset5.txt", &ap2, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset6.txt", &ap3, m_serializeContext));
|
||||
|
||||
AssetWithAssetReference assetWithPreload1;
|
||||
AssetWithAssetReference assetWithPreload2;
|
||||
@@ -273,11 +273,11 @@ namespace UnitTest
|
||||
noLoadAsset.m_asset = m_testAssetManager->CreateAsset<AssetWithSerializedData>(MyAsset2Id, AssetLoadBehavior::NoLoad);
|
||||
EXPECT_EQ(m_assetHandlerAndCatalog->m_numCreations, 4);
|
||||
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &assetWithPreload1, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &assetWithPreload2, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &assetWithPreload3, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "DelayLoadAsset.txt", AZ::DataStream::ST_XML, &delayedAsset, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "NoLoadAsset.txt", AZ::DataStream::ST_XML, &noLoadAsset, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset1.txt", &assetWithPreload1, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset2.txt", &assetWithPreload2, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset3.txt", &assetWithPreload3, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("DelayLoadAsset.txt", &delayedAsset, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("NoLoadAsset.txt", &noLoadAsset, m_serializeContext));
|
||||
|
||||
AssetWithQueueAndPreLoadReferences preLoadRoot;
|
||||
AssetWithQueueAndPreLoadReferences preLoadA;
|
||||
@@ -297,16 +297,16 @@ namespace UnitTest
|
||||
preLoadBrokenA.m_preLoad = m_testAssetManager->CreateAsset<AssetWithAssetReference>(PreloadBrokenDepBId, AssetLoadBehavior::PreLoad);
|
||||
preLoadBrokenB.m_preLoad = m_testAssetManager->CreateAsset<AssetWithAssetReference>(PreloadAssetNoDataId, AssetLoadBehavior::PreLoad);
|
||||
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadRoot.txt", AZ::DataStream::ST_XML, &preLoadRoot, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadA.txt", AZ::DataStream::ST_XML, &preLoadA, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadB.txt", AZ::DataStream::ST_XML, &noRefs, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadC.txt", AZ::DataStream::ST_XML, &noRefs, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "QueueLoadA.txt", AZ::DataStream::ST_XML, &queueLoadA, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "QueueLoadB.txt", AZ::DataStream::ST_XML, &noRefs, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "QueueLoadC.txt", AZ::DataStream::ST_XML, &noRefs, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadBrokenA.txt", AZ::DataStream::ST_XML, &preLoadBrokenA, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadBrokenB.txt", AZ::DataStream::ST_XML, &preLoadBrokenB, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadNoData.txt", AZ::DataStream::ST_XML, &noRefs, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadRoot.txt", &preLoadRoot, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadA.txt", &preLoadA, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadB.txt", &noRefs, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadC.txt", &noRefs, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("QueueLoadA.txt", &queueLoadA, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("QueueLoadB.txt", &noRefs, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("QueueLoadC.txt", &noRefs, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadBrokenA.txt", &preLoadBrokenA, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadBrokenB.txt", &preLoadBrokenB, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadNoData.txt", &noRefs, m_serializeContext));
|
||||
|
||||
AssetWithQueueAndPreLoadReferences circularA;
|
||||
AssetWithQueueAndPreLoadReferences circularB;
|
||||
@@ -318,43 +318,15 @@ namespace UnitTest
|
||||
circularC.m_preLoad = m_testAssetManager->CreateAsset<AssetWithAssetReference>(CircularBId, AssetLoadBehavior::PreLoad);
|
||||
circularD.m_preLoad = circularC.m_preLoad;
|
||||
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "CircularA.txt", AZ::DataStream::ST_XML, &circularA, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "CircularB.txt", AZ::DataStream::ST_XML, &circularB, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "CircularC.txt", AZ::DataStream::ST_XML, &circularC, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "CircularD.txt", AZ::DataStream::ST_XML, &circularD, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("CircularA.txt", &circularA, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("CircularB.txt", &circularB, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("CircularC.txt", &circularC, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("CircularD.txt", &circularD, m_serializeContext));
|
||||
|
||||
m_assetHandlerAndCatalog->m_numCreations = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void TearDownTest()
|
||||
{
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset4.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset5.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset6.txt");
|
||||
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset1.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset2.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset3.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "DelayLoadAsset.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "NoLoadAsset.txt");
|
||||
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadRoot.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadA.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadB.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadC.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "QueueLoadA.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "QueueLoadB.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "QueueLoadC.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadBrokenA.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadBrokenB.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadNoData.txt");
|
||||
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "CircularA.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "CircularB.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "CircularC.txt");
|
||||
DeleteAssetFromDisk(GetTestFolderPath() + "CircularD.txt");
|
||||
}
|
||||
|
||||
void CheckFinishedCreationsAndDestructions()
|
||||
{
|
||||
// Make sure asset jobs have finished before validating the number of destroyed assets, because it's possible that the asset job
|
||||
@@ -367,7 +339,7 @@ namespace UnitTest
|
||||
};
|
||||
|
||||
static constexpr AZStd::chrono::seconds MaxDispatchTimeoutSeconds = BaseAssetManagerTest::DefaultTimeoutSeconds * 12;
|
||||
|
||||
|
||||
template <typename Pred>
|
||||
bool DispatchEventsUntilCondition(AZ::Data::AssetManager& assetManager, Pred&& conditionPredicate,
|
||||
AZStd::chrono::seconds logIntervalSeconds = BaseAssetManagerTest::DefaultTimeoutSeconds,
|
||||
@@ -608,7 +580,7 @@ namespace UnitTest
|
||||
AZ::Data::AssetData::AssetStatus expected_base_status = AZ::Data::AssetData::AssetStatus::Ready;
|
||||
EXPECT_EQ(baseStatus, expected_base_status);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(AssetJobsFloodTest, RapidAcquireAndRelease)
|
||||
{
|
||||
auto assetUuids = {
|
||||
@@ -641,7 +613,7 @@ namespace UnitTest
|
||||
{
|
||||
Asset<AssetWithAssetReference> asset1 =
|
||||
m_testAssetManager->GetAsset(assetUuid, azrtti_typeid<AssetWithAssetReference>(), AZ::Data::AssetLoadBehavior::PreLoad);
|
||||
|
||||
|
||||
if (checkLoaded)
|
||||
{
|
||||
asset1.BlockUntilLoadComplete();
|
||||
@@ -714,8 +686,8 @@ namespace UnitTest
|
||||
|
||||
AssetWithSerializedData ap;
|
||||
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "a.txt", AZ::DataStream::ST_XML, &ap, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "b.txt", AZ::DataStream::ST_XML, &ap, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("a.txt", &ap, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("b.txt", &ap, m_serializeContext));
|
||||
}
|
||||
|
||||
auto& assetManager = AssetManager::Instance();
|
||||
@@ -778,7 +750,7 @@ namespace UnitTest
|
||||
* Verify that loads without using the Asset Container still work correctly
|
||||
*/
|
||||
class AssetContainerDisableTest
|
||||
: public BaseAssetManagerTest
|
||||
: public DisklessAssetManagerBase
|
||||
{
|
||||
public:
|
||||
static inline const AZ::Uuid MyAsset1Id{ "{5B29FE2B-6B41-48C9-826A-C723951B0560}" };
|
||||
@@ -797,7 +769,7 @@ namespace UnitTest
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
BaseAssetManagerTest::SetUp();
|
||||
DisklessAssetManagerBase::SetUp();
|
||||
SetupTest();
|
||||
|
||||
}
|
||||
@@ -807,7 +779,7 @@ namespace UnitTest
|
||||
AssetManager::Instance().UnregisterHandler(m_assetHandlerAndCatalog);
|
||||
delete m_assetHandlerAndCatalog;
|
||||
AssetManager::Destroy();
|
||||
BaseAssetManagerTest::TearDown();
|
||||
DisklessAssetManagerBase::TearDown();
|
||||
}
|
||||
|
||||
void SetupAssets()
|
||||
@@ -849,9 +821,9 @@ namespace UnitTest
|
||||
AssetWithSerializedData ap2;
|
||||
AssetWithSerializedData ap3;
|
||||
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset4.txt", AZ::DataStream::ST_XML, &ap1, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset5.txt", AZ::DataStream::ST_XML, &ap2, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset6.txt", AZ::DataStream::ST_XML, &ap3, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset4.txt", &ap1, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset5.txt", &ap2, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset6.txt", &ap3, m_serializeContext));
|
||||
|
||||
AssetWithAssetReference assetWithPreload1;
|
||||
AssetWithAssetReference assetWithPreload2;
|
||||
@@ -862,9 +834,9 @@ namespace UnitTest
|
||||
assetWithPreload3.m_asset = m_testAssetManager->CreateAsset<AssetWithSerializedData>(MyAsset6Id, AssetLoadBehavior::PreLoad);
|
||||
EXPECT_EQ(m_assetHandlerAndCatalog->m_numCreations, 3);
|
||||
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &assetWithPreload1, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &assetWithPreload2, m_serializeContext));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &assetWithPreload3, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset1.txt", &assetWithPreload1, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset2.txt", &assetWithPreload2, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset3.txt", &assetWithPreload3, m_serializeContext));
|
||||
|
||||
m_assetHandlerAndCatalog->m_numCreations = 0;
|
||||
}
|
||||
@@ -2014,11 +1986,12 @@ namespace UnitTest
|
||||
CheckFinishedCreationsAndDestructions();
|
||||
m_assetHandlerAndCatalog->AssetCatalogRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run multiple threads that get and release assets simultaneously to test AssetManager's thread safety
|
||||
*/
|
||||
class AssetJobsMultithreadedTest
|
||||
: public BaseAssetManagerTest
|
||||
: public DisklessAssetManagerBase
|
||||
{
|
||||
public:
|
||||
static inline const AZ::Uuid MyAsset1Id{ "{5B29FE2B-6B41-48C9-826A-C723951B0560}" };
|
||||
@@ -2028,6 +2001,7 @@ namespace UnitTest
|
||||
static inline const AZ::Uuid MyAsset5Id{ "{D9CDAB04-D206-431E-BDC0-1DD615D56197}" };
|
||||
static inline const AZ::Uuid MyAsset6Id{ "{B2F139C3-5032-4B52-ADCA-D52A8F88E043}" };
|
||||
|
||||
|
||||
// Initialize the Job Manager with 2 threads for the Asset Manager to use.
|
||||
size_t GetNumJobManagerThreads() const override { return 2; }
|
||||
|
||||
@@ -2078,9 +2052,9 @@ namespace UnitTest
|
||||
AssetWithSerializedData ap2;
|
||||
AssetWithSerializedData ap3;
|
||||
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset4.txt", AZ::DataStream::ST_XML, &ap1, &context));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset5.txt", AZ::DataStream::ST_XML, &ap2, &context));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset6.txt", AZ::DataStream::ST_XML, &ap3, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset4.txt", &ap1, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset5.txt", &ap2, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset6.txt", &ap3, &context));
|
||||
|
||||
AssetWithAssetReference assetWithPreload1;
|
||||
AssetWithAssetReference assetWithPreload2;
|
||||
@@ -2089,9 +2063,9 @@ namespace UnitTest
|
||||
assetWithPreload2.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset5Id, AssetLoadBehavior::PreLoad);
|
||||
assetWithPreload3.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset6Id, AssetLoadBehavior::PreLoad);
|
||||
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &assetWithPreload1, &context));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &assetWithPreload2, &context));
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &assetWithPreload3, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset1.txt", &assetWithPreload1, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset2.txt", &assetWithPreload2, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset3.txt", &assetWithPreload3, &context));
|
||||
|
||||
EXPECT_TRUE(assetHandlerAndCatalog->m_numCreations == 3);
|
||||
assetHandlerAndCatalog->m_numCreations = 0;
|
||||
@@ -2191,22 +2165,22 @@ namespace UnitTest
|
||||
// A will be saved to disk with MyAsset1Id
|
||||
AssetWithAssetReference a;
|
||||
a.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset2Id);
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &a, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset1.txt", &a, &context));
|
||||
AssetWithAssetReference b;
|
||||
b.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset3Id);
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &b, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset2.txt", &b, &context));
|
||||
AssetWithAssetReference c;
|
||||
c.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset4Id);
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &c, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset3.txt", &c, &context));
|
||||
AssetWithAssetReference d;
|
||||
d.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset5Id);
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset4.txt", AZ::DataStream::ST_XML, &d, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset4.txt", &d, &context));
|
||||
AssetWithAssetReference e;
|
||||
e.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset6Id);
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset5.txt", AZ::DataStream::ST_XML, &e, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset5.txt", &e, &context));
|
||||
AssetWithAssetReference f;
|
||||
f.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset1Id); // refer back to asset1
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset6.txt", AZ::DataStream::ST_XML, &f, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset6.txt", &f, &context));
|
||||
|
||||
EXPECT_TRUE(assetHandlerAndCatalog->m_numCreations == 6);
|
||||
assetHandlerAndCatalog->m_numCreations = 0;
|
||||
@@ -2347,26 +2321,26 @@ namespace UnitTest
|
||||
// AssetD is MYASSETD
|
||||
AssetWithSerializedData d;
|
||||
d.m_data = 42;
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset4.txt", AZ::DataStream::ST_XML, &d, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset4.txt", &d, &context));
|
||||
|
||||
// AssetC is MYASSETC
|
||||
AssetWithAssetReference c;
|
||||
c.m_asset = db.CreateAsset<AssetWithSerializedData>(AssetId(MyAssetDId)); // point at D
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &c, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset3.txt", &c, &context));
|
||||
|
||||
// AssetB is MYASSETB
|
||||
AssetWithAssetReference b;
|
||||
b.m_asset = db.CreateAsset<AssetWithAssetReference>(AssetId(MyAssetCId)); // point at C
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &b, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset2.txt", &b, &context));
|
||||
|
||||
// AssetA will be written to disk as MYASSETA
|
||||
AssetWithAssetReference a;
|
||||
a.m_asset = db.CreateAsset<AssetWithAssetReference>(AssetId(MyAssetBId)); // point at B
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &a, &context));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset1.txt", &a, &context));
|
||||
}
|
||||
|
||||
const size_t numThreads = 4;
|
||||
AZStd::atomic_int threadCount(numThreads);
|
||||
constexpr size_t NumThreads = 4;
|
||||
AZStd::atomic_int threadCount(NumThreads);
|
||||
AZStd::condition_variable cv;
|
||||
AZStd::vector<AZStd::thread> threads;
|
||||
AZStd::atomic_bool keepDispatching(true);
|
||||
@@ -2381,7 +2355,7 @@ namespace UnitTest
|
||||
|
||||
AZStd::thread dispatchThread(dispatch);
|
||||
|
||||
for (size_t threadIdx = 0; threadIdx < numThreads; ++threadIdx)
|
||||
for (size_t threadIdx = 0; threadIdx < NumThreads; ++threadIdx)
|
||||
{
|
||||
threads.emplace_back([&threadCount, &db, &cv]()
|
||||
{
|
||||
@@ -2569,7 +2543,6 @@ namespace UnitTest
|
||||
#if AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_TESTS
|
||||
TEST_F(AssetJobsMultithreadedTest, DISABLED_ParallelDeepAssetReferences)
|
||||
#else
|
||||
// temporarily disabled until sporadic failures can be root caused
|
||||
TEST_F(AssetJobsMultithreadedTest, ParallelDeepAssetReferences)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_TESTS
|
||||
{
|
||||
@@ -2577,7 +2550,7 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
class AssetManagerTests
|
||||
: public BaseAssetManagerTest
|
||||
: public DisklessAssetManagerBase
|
||||
{
|
||||
protected:
|
||||
static inline const AZ::Uuid MyAsset1Id{ "{5B29FE2B-6B41-48C9-826A-C723951B0560}" };
|
||||
@@ -2592,7 +2565,7 @@ namespace UnitTest
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
BaseAssetManagerTest::SetUp();
|
||||
DisklessAssetManagerBase::SetUp();
|
||||
|
||||
m_console = AZStd::make_unique<AZ::Console>();
|
||||
AZ::Interface<AZ::IConsole>::Register(m_console.get());
|
||||
@@ -2631,7 +2604,7 @@ namespace UnitTest
|
||||
AssetManager::Destroy();
|
||||
AZ::Interface<AZ::IConsole>::Unregister(m_console.get());
|
||||
m_console = nullptr;
|
||||
BaseAssetManagerTest::TearDown();
|
||||
DisklessAssetManagerBase::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2982,7 +2955,7 @@ namespace UnitTest
|
||||
* the middle of loading. The tests help ensure that assets can't get stuck in perpetual loading states.
|
||||
**/
|
||||
class AssetManagerClearAssetReferenceTests
|
||||
: public BaseAssetManagerTest
|
||||
: public DisklessAssetManagerBase
|
||||
{
|
||||
protected:
|
||||
static inline const AZ::Uuid RootAssetId{ "{AB13F568-C676-41FE-A7E9-341F71A78104}" };
|
||||
@@ -3001,7 +2974,7 @@ namespace UnitTest
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
BaseAssetManagerTest::SetUp();
|
||||
DisklessAssetManagerBase::SetUp();
|
||||
|
||||
// create the database
|
||||
AssetManager::Descriptor desc;
|
||||
@@ -3039,21 +3012,18 @@ namespace UnitTest
|
||||
|
||||
// Create and save the dependent asset first, so that we can get a reference to it.
|
||||
AssetWithSerializedData dependentBlockingAsset;
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "DependentPreloadBlockingAsset.txt",
|
||||
AZ::DataStream::ST_XML, &dependentBlockingAsset, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("DependentPreloadBlockingAsset.txt", &dependentBlockingAsset, m_serializeContext));
|
||||
|
||||
AssetWithAssetReference dependentAsset;
|
||||
dependentAsset.m_asset = AssetManager::Instance().CreateAsset<AssetWithAssetReference>(
|
||||
NestedDependentPreloadBlockingAssetId, AssetLoadBehavior::PreLoad);
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "DependentPreloadAsset.txt",
|
||||
AZ::DataStream::ST_XML, &dependentAsset, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("DependentPreloadAsset.txt", &dependentAsset, m_serializeContext));
|
||||
|
||||
// Create and save the top-level asset.
|
||||
AssetWithAssetReference rootAsset;
|
||||
rootAsset.m_asset = AssetManager::Instance().CreateAsset<AssetWithAssetReference>(
|
||||
DependentPreloadAssetId, AssetLoadBehavior::PreLoad);
|
||||
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "RootAsset.txt",
|
||||
AZ::DataStream::ST_XML, &rootAsset, m_serializeContext));
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("RootAsset.txt", &rootAsset, m_serializeContext));
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
@@ -3065,7 +3035,7 @@ namespace UnitTest
|
||||
delete m_assetHandlerAndCatalog;
|
||||
|
||||
AssetManager::Destroy();
|
||||
BaseAssetManagerTest::TearDown();
|
||||
DisklessAssetManagerBase::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -165,4 +165,254 @@ namespace UnitTest
|
||||
|
||||
EXPECT_FALSE(AssetManager::Instance().HasActiveJobsOrStreamerRequests());
|
||||
}
|
||||
|
||||
MemoryStreamerWrapper::MemoryStreamerWrapper()
|
||||
{
|
||||
using ::testing::_;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Return;
|
||||
|
||||
ON_CALL(m_mockStreamer, SuspendProcessing()).WillByDefault([this]()
|
||||
{
|
||||
m_suspended = true;
|
||||
});
|
||||
|
||||
ON_CALL(m_mockStreamer, ResumeProcessing()).WillByDefault([this]()
|
||||
{
|
||||
AZStd::unique_lock lock(m_mutex);
|
||||
|
||||
m_suspended = false;
|
||||
|
||||
while (!m_processingQueue.empty())
|
||||
{
|
||||
FileRequestHandle requestHandle = m_processingQueue.front();
|
||||
m_processingQueue.pop();
|
||||
|
||||
const auto& onCompleteCallback = GetReadRequest(requestHandle)->m_callback;
|
||||
|
||||
if (onCompleteCallback)
|
||||
{
|
||||
onCompleteCallback(requestHandle);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ON_CALL(m_mockStreamer, Read(_, ::testing::An<IStreamerTypes::RequestMemoryAllocator&>(), _, _, _, _))
|
||||
.WillByDefault(
|
||||
[this](
|
||||
[[maybe_unused]] AZStd::string_view relativePath, IStreamerTypes::RequestMemoryAllocator& allocator, size_t size,
|
||||
AZStd::chrono::microseconds deadline, IStreamerTypes::Priority priority, [[maybe_unused]] size_t offset)
|
||||
{
|
||||
AZStd::unique_lock lock(m_mutex);
|
||||
|
||||
ReadRequest request;
|
||||
|
||||
// Save off the requested deadline and priority
|
||||
request.m_deadline = deadline;
|
||||
request.m_priority = priority;
|
||||
request.m_data = allocator.Allocate(size, size, 8);
|
||||
|
||||
const auto* virtualFile = FindFile(relativePath);
|
||||
|
||||
AZ_Assert(
|
||||
virtualFile->size() == size, "Streamer read request size did not match size of saved file: %d vs %d (%.*s)",
|
||||
virtualFile->size(), size,
|
||||
relativePath.size(), relativePath.data());
|
||||
AZ_Assert(size > 0, "Size is zero %.*s", relativePath.size(), relativePath.data());
|
||||
|
||||
memcpy(request.m_data.m_address, virtualFile->data(), size);
|
||||
|
||||
// Create a real file request result and return it
|
||||
request.m_request = m_context.GetNewExternalRequest();
|
||||
|
||||
m_readRequests.push_back(request);
|
||||
|
||||
return request.m_request;
|
||||
});
|
||||
|
||||
ON_CALL(m_mockStreamer, SetRequestCompleteCallback(_, _))
|
||||
.WillByDefault([this](FileRequestPtr& request, AZ::IO::IStreamer::OnCompleteCallback callback) -> FileRequestPtr&
|
||||
{
|
||||
// Save off the callback just so that we can call it when the request is "done"
|
||||
AZStd::unique_lock lock(m_mutex);
|
||||
ReadRequest* readRequest = GetReadRequest(request);
|
||||
readRequest->m_callback = callback;
|
||||
|
||||
return request;
|
||||
});
|
||||
|
||||
ON_CALL(m_mockStreamer, QueueRequest(_))
|
||||
.WillByDefault([this](const auto& fileRequest)
|
||||
{
|
||||
if (!m_suspended)
|
||||
{
|
||||
decltype(ReadRequest::m_callback) onCompleteCallback;
|
||||
|
||||
AZStd::unique_lock lock(m_mutex);
|
||||
ReadRequest* readRequest = GetReadRequest(fileRequest);
|
||||
onCompleteCallback = readRequest->m_callback;
|
||||
|
||||
if (onCompleteCallback)
|
||||
{
|
||||
onCompleteCallback(fileRequest);
|
||||
|
||||
m_readRequests.erase(readRequest);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AZStd::unique_lock lock(m_mutex);
|
||||
|
||||
m_processingQueue.push(fileRequest);
|
||||
}
|
||||
});
|
||||
|
||||
ON_CALL(m_mockStreamer, GetRequestStatus(_))
|
||||
.WillByDefault([]([[maybe_unused]] FileRequestHandle request)
|
||||
{
|
||||
// Return whatever request status has been set in this class
|
||||
return IO::IStreamerTypes::RequestStatus::Completed;
|
||||
});
|
||||
|
||||
ON_CALL(m_mockStreamer, GetReadRequestResult(_, _, _, _))
|
||||
.WillByDefault([this](
|
||||
[[maybe_unused]] FileRequestHandle request, void*& buffer, AZ::u64& numBytesRead,
|
||||
IStreamerTypes::ClaimMemory claimMemory)
|
||||
{
|
||||
// Make sure the requestor plans to free the data buffer we allocated.
|
||||
EXPECT_EQ(claimMemory, IStreamerTypes::ClaimMemory::Yes);
|
||||
|
||||
AZStd::unique_lock lock(m_mutex);
|
||||
|
||||
ReadRequest* readRequest = GetReadRequest(request);
|
||||
|
||||
// Provide valid data buffer results.
|
||||
numBytesRead = readRequest->m_data.m_size;
|
||||
buffer = readRequest->m_data.m_address;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
ON_CALL(m_mockStreamer, RescheduleRequest(_, _, _))
|
||||
.WillByDefault([this](IO::FileRequestPtr target, AZStd::chrono::microseconds newDeadline, IO::IStreamerTypes::Priority newPriority)
|
||||
{
|
||||
AZStd::unique_lock lock(m_mutex);
|
||||
ReadRequest* readRequest = GetReadRequest(target);
|
||||
|
||||
readRequest->m_deadline = newDeadline;
|
||||
readRequest->m_priority = newPriority;
|
||||
|
||||
return target;
|
||||
});
|
||||
}
|
||||
|
||||
ReadRequest* MemoryStreamerWrapper::GetReadRequest(FileRequestHandle request)
|
||||
{
|
||||
auto itr = AZStd::find_if(
|
||||
m_readRequests.begin(), m_readRequests.end(),
|
||||
[request](const ReadRequest& searchItem) -> bool
|
||||
{
|
||||
return (searchItem.m_request == request);
|
||||
});
|
||||
|
||||
return itr;
|
||||
}
|
||||
|
||||
AZStd::vector<char>* MemoryStreamerWrapper::FindFile(AZStd::string_view path)
|
||||
{
|
||||
auto itr = m_virtualFiles.find(path);
|
||||
|
||||
if (itr == m_virtualFiles.end())
|
||||
{
|
||||
// Path didn't work as-is, does it have the test folder prefixed? If so try removing it
|
||||
if (AZ::StringFunc::StartsWith(path, GetTestFolderPath()))
|
||||
{
|
||||
AZStd::string_view pathWithoutFolder = path;
|
||||
|
||||
pathWithoutFolder = AZ::StringFunc::LStrip(pathWithoutFolder, GetTestFolderPath().c_str());
|
||||
itr = m_virtualFiles.find(pathWithoutFolder);
|
||||
}
|
||||
else // Path isn't prefixed, so try adding it
|
||||
{
|
||||
itr = m_virtualFiles.find(GetTestFolderPath().append(path));
|
||||
}
|
||||
}
|
||||
|
||||
if (itr != m_virtualFiles.end())
|
||||
{
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
// Currently no test expects a file not to exist so we assert to make it easy to quickly find where something went wrong
|
||||
// If we ever need to test for a non-existent file this assert should just be conditionally disabled for that specific test
|
||||
AZ_Assert(false, "Failed to find virtual file %*.s", path.size(), path.data())
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DisklessAssetManagerBase::SetUp()
|
||||
{
|
||||
using ::testing::_;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Return;
|
||||
|
||||
BaseAssetManagerTest::SetUp();
|
||||
|
||||
ON_CALL(m_fileIO, Size(::testing::Matcher<const char*>(::testing::_), _))
|
||||
.WillByDefault(
|
||||
[this](const char* path, u64& size)
|
||||
{
|
||||
AZStd::scoped_lock lock(m_streamerWrapper->m_mutex);
|
||||
|
||||
const auto* file = m_streamerWrapper->FindFile(path);
|
||||
|
||||
if (file)
|
||||
{
|
||||
size = file->size();
|
||||
return ResultCode::Success;
|
||||
}
|
||||
|
||||
AZ_Error("DisklessAssetManagerBase", false, "Failed to find virtual file %.*s", path);
|
||||
|
||||
return ResultCode::Error;
|
||||
});
|
||||
|
||||
m_prevFileIO = IO::FileIOBase::GetInstance();
|
||||
IO::FileIOBase::SetInstance(nullptr);
|
||||
IO::FileIOBase::SetInstance(&m_fileIO);
|
||||
}
|
||||
|
||||
void DisklessAssetManagerBase::TearDown()
|
||||
{
|
||||
IO::FileIOBase::SetInstance(nullptr);
|
||||
IO::FileIOBase::SetInstance(m_prevFileIO);
|
||||
|
||||
BaseAssetManagerTest::TearDown();
|
||||
}
|
||||
|
||||
IO::IStreamer* DisklessAssetManagerBase::CreateStreamer()
|
||||
{
|
||||
m_streamerWrapper = AZStd::make_unique<MemoryStreamerWrapper>();
|
||||
|
||||
return &(m_streamerWrapper->m_mockStreamer);
|
||||
}
|
||||
|
||||
void DisklessAssetManagerBase::DestroyStreamer(IO::IStreamer*)
|
||||
{
|
||||
m_streamerWrapper = nullptr;
|
||||
}
|
||||
|
||||
void DisklessAssetManagerBase::WriteAssetToDisk(const AZStd::string& assetName, const AZStd::string&)
|
||||
{
|
||||
AZStd::string assetFileName = GetTestFolderPath() + assetName;
|
||||
|
||||
AssetWithCustomData asset;
|
||||
|
||||
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile(assetFileName, &asset, m_serializeContext));
|
||||
}
|
||||
|
||||
void DisklessAssetManagerBase::DeleteAssetFromDisk(const AZStd::string&)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
#include <Tests/Asset/TestAssetTypes.h>
|
||||
#include <Tests/SerializeContextFixture.h>
|
||||
#include <Tests/TestCatalog.h>
|
||||
|
||||
#include <AzCore/UnitTest/Mocks/MockFileIOBase.h>
|
||||
#include <Streamer/IStreamerMock.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
@@ -58,7 +59,11 @@ namespace UnitTest
|
||||
|
||||
// Subclasses can optionally override the streamer creation and destruction
|
||||
virtual IO::IStreamer* CreateStreamer() { return aznew IO::Streamer(AZStd::thread_desc{}, StreamerComponent::CreateStreamerStack()); }
|
||||
virtual void DestroyStreamer(IO::IStreamer* streamer) { delete streamer; }
|
||||
virtual void DestroyStreamer(IO::IStreamer* streamer)
|
||||
{
|
||||
delete streamer;
|
||||
streamer = nullptr;
|
||||
}
|
||||
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
@@ -66,8 +71,8 @@ namespace UnitTest
|
||||
static void SuppressTraceOutput(bool suppress);
|
||||
|
||||
// Helper methods to create and destroy actual assets on the disk for true end-to-end asset loading.
|
||||
void WriteAssetToDisk(const AZStd::string& assetName, const AZStd::string& assetIdGuid);
|
||||
void DeleteAssetFromDisk(const AZStd::string& assetName);
|
||||
virtual void WriteAssetToDisk(const AZStd::string& assetName, const AZStd::string& assetIdGuid);
|
||||
virtual void DeleteAssetFromDisk(const AZStd::string& assetName);
|
||||
|
||||
void BlockUntilAssetJobsAreComplete();
|
||||
|
||||
@@ -82,4 +87,57 @@ namespace UnitTest
|
||||
AZStd::vector<AZStd::string> m_assetsWritten;
|
||||
};
|
||||
|
||||
|
||||
struct ReadRequest
|
||||
{
|
||||
AZStd::chrono::milliseconds m_deadline{};
|
||||
AZ::IO::IStreamerTypes::Priority m_priority{};
|
||||
IO::IStreamerTypes::RequestMemoryAllocatorResult m_data{ nullptr, 0, IO::IStreamerTypes::MemoryType::ReadWrite };
|
||||
AZ::IO::IStreamer::OnCompleteCallback m_callback;
|
||||
IO::FileRequestPtr m_request;
|
||||
};
|
||||
|
||||
struct MemoryStreamerWrapper
|
||||
{
|
||||
MemoryStreamerWrapper();
|
||||
~MemoryStreamerWrapper() = default;
|
||||
|
||||
ReadRequest* GetReadRequest(IO::FileRequestHandle request);
|
||||
|
||||
template<typename TObject>
|
||||
bool WriteMemoryFile(const AZStd::string& filePath, TObject* object, AZ::SerializeContext* context)
|
||||
{
|
||||
auto& buffer = m_virtualFiles[filePath];
|
||||
ByteContainerStream stream(&buffer);
|
||||
|
||||
return AZ::Utils::SaveObjectToStream(stream, DataStream::StreamType::ST_XML, object, context);
|
||||
}
|
||||
|
||||
AZStd::vector<char>* FindFile(AZStd::string_view path);
|
||||
|
||||
::testing::NiceMock<StreamerMock> m_mockStreamer;
|
||||
IO::StreamerContext m_context;
|
||||
AZStd::atomic_bool m_suspended{ false };
|
||||
|
||||
AZStd::recursive_mutex m_mutex;
|
||||
AZStd::queue<FileRequestHandle> m_processingQueue; // Keeps tracks of requests that have been queued while processing is suspended
|
||||
AZStd::vector<ReadRequest> m_readRequests;
|
||||
AZStd::unordered_map<AZStd::string, AZStd::vector<char>> m_virtualFiles;
|
||||
};
|
||||
|
||||
struct DisklessAssetManagerBase : BaseAssetManagerTest
|
||||
{
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
IO::IStreamer* CreateStreamer() override;
|
||||
void DestroyStreamer(IO::IStreamer*) override;
|
||||
|
||||
void WriteAssetToDisk(const AZStd::string& assetName, const AZStd::string& assetIdGuid) override;
|
||||
void DeleteAssetFromDisk(const AZStd::string& assetName) override;
|
||||
|
||||
AZStd::unique_ptr<MemoryStreamerWrapper> m_streamerWrapper;
|
||||
::testing::NiceMock<MockFileIOBase> m_fileIO;
|
||||
IO::FileIOBase* m_prevFileIO{};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -539,6 +539,22 @@ tags=tools,renderer,metal)"
|
||||
EXPECT_STREQ("Bat", commandLine.GetMiscValue(2).c_str());
|
||||
}
|
||||
|
||||
TEST_F(SettingsRegistryMergeUtilsCommandLineFixture, RegsetFileArgument_DoesNotMergeNUL)
|
||||
{
|
||||
AZStd::string regsetFile = AZ::IO::SystemFile::GetNullFilename();
|
||||
AZ::CommandLine commandLine;
|
||||
commandLine.Parse({ "--regset-file", regsetFile });
|
||||
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(*m_registry, commandLine, false);
|
||||
|
||||
// Add a settings path to anchor loaded settings underneath
|
||||
regsetFile = AZStd::string::format("%s::/AnchorPath/Of/Settings", AZ::IO::SystemFile::GetNullFilename());
|
||||
commandLine.Parse({ "--regset-file", regsetFile });
|
||||
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(*m_registry, commandLine, false);
|
||||
EXPECT_EQ(AZ::SettingsRegistryInterface::Type::NoType, m_registry->GetType("/AnchorPath/Of/Settings"));
|
||||
}
|
||||
|
||||
using SettingsRegistryAncestorDescendantOrEqualPathFixture = SettingsRegistryMergeUtilsCommandLineFixture;
|
||||
|
||||
TEST_F(SettingsRegistryAncestorDescendantOrEqualPathFixture, ValidateThatAncestorOrDescendantOrPathWithTheSameValue_Succeeds)
|
||||
|
||||
@@ -167,7 +167,8 @@ namespace UnitTest
|
||||
if (!info.m_streamName.empty())
|
||||
{
|
||||
AZStd::string fullName = GetTestFolderPath() + info.m_streamName;
|
||||
info.m_dataLen = static_cast<size_t>(IO::SystemFile::Length(fullName.c_str()));
|
||||
IO::FileIOBase* io = IO::FileIOBase::GetInstance();
|
||||
io->Size(fullName.c_str(), info.m_dataLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -187,8 +188,11 @@ namespace UnitTest
|
||||
|
||||
if (!info.m_streamName.empty())
|
||||
{
|
||||
IO::FileIOBase* io = AZ::IO::FileIOBase::GetInstance();
|
||||
|
||||
AZStd::string fullName = GetTestFolderPath() + info.m_streamName;
|
||||
info.m_dataLen = static_cast<size_t>(IO::SystemFile::Length(fullName.c_str()));
|
||||
|
||||
io->Size(fullName.c_str(), info.m_dataLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+7
-6
@@ -6,16 +6,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "CommunicatorTracePrinter.h"
|
||||
#include "ProcessCommunicatorTracePrinter.h"
|
||||
|
||||
CommunicatorTracePrinter::CommunicatorTracePrinter(AzFramework::ProcessCommunicator* communicator, const char* window) :
|
||||
|
||||
ProcessCommunicatorTracePrinter::ProcessCommunicatorTracePrinter(AzFramework::ProcessCommunicator* communicator, const char* window) :
|
||||
m_communicator(communicator),
|
||||
m_window(window)
|
||||
{
|
||||
m_stringBeingConcatenated.reserve(1024);
|
||||
}
|
||||
|
||||
CommunicatorTracePrinter::~CommunicatorTracePrinter()
|
||||
ProcessCommunicatorTracePrinter::~ProcessCommunicatorTracePrinter()
|
||||
{
|
||||
// flush stdout
|
||||
WriteCurrentString(false);
|
||||
@@ -24,7 +25,7 @@ CommunicatorTracePrinter::~CommunicatorTracePrinter()
|
||||
WriteCurrentString(true);
|
||||
}
|
||||
|
||||
void CommunicatorTracePrinter::Pump()
|
||||
void ProcessCommunicatorTracePrinter::Pump()
|
||||
{
|
||||
if (m_communicator->IsValid())
|
||||
{
|
||||
@@ -42,7 +43,7 @@ void CommunicatorTracePrinter::Pump()
|
||||
}
|
||||
}
|
||||
|
||||
void CommunicatorTracePrinter::ParseDataBuffer(AZ::u32 readSize, bool isFromStdErr)
|
||||
void ProcessCommunicatorTracePrinter::ParseDataBuffer(AZ::u32 readSize, bool isFromStdErr)
|
||||
{
|
||||
if (readSize > AZ_ARRAY_SIZE(m_streamBuffer))
|
||||
{
|
||||
@@ -67,7 +68,7 @@ void CommunicatorTracePrinter::ParseDataBuffer(AZ::u32 readSize, bool isFromStdE
|
||||
}
|
||||
}
|
||||
|
||||
void CommunicatorTracePrinter::WriteCurrentString(bool isFromStdErr)
|
||||
void ProcessCommunicatorTracePrinter::WriteCurrentString(bool isFromStdErr)
|
||||
{
|
||||
AZStd::string& bufferToUse = isFromStdErr ? m_errorStringBeingConcatenated : m_stringBeingConcatenated;
|
||||
|
||||
+7
-6
@@ -10,20 +10,21 @@
|
||||
|
||||
#include <AzFramework/Process/ProcessCommunicator.h>
|
||||
|
||||
//! CommunicatorTracePrinter listens to stderr and stdout of a running process and writes its output to the AZ_Trace system
|
||||
//! ProcessCommunicatorTracePrinter listens to stderr and stdout of a running process and writes its output to the AZ_Trace system
|
||||
//! Importantly, it does not do any blocking operations.
|
||||
class CommunicatorTracePrinter
|
||||
class ProcessCommunicatorTracePrinter
|
||||
{
|
||||
public:
|
||||
CommunicatorTracePrinter(AzFramework::ProcessCommunicator* communicator, const char* window);
|
||||
~CommunicatorTracePrinter();
|
||||
ProcessCommunicatorTracePrinter(AzFramework::ProcessCommunicator* communicator, const char* window);
|
||||
~ProcessCommunicatorTracePrinter();
|
||||
|
||||
// call this periodically to drain the buffers and write them.
|
||||
//! Call this periodically to drain the buffers and write them.
|
||||
void Pump();
|
||||
|
||||
// drains the buffer into the string thats being built, then traces the string when it hits a newline.
|
||||
//! Drains the buffer into the string that's being built, then traces the string when it hits a newline.
|
||||
void ParseDataBuffer(AZ::u32 readSize, bool isFromStdErr);
|
||||
|
||||
//! Prints the current buffer to AZ_Error or AZ_TracePrintf so that it can be picked up by AZ::Debug::Trace
|
||||
void WriteCurrentString(bool isFromStdError);
|
||||
|
||||
private:
|
||||
@@ -71,10 +71,11 @@ namespace AzFramework::Terrain
|
||||
->Event("GetSurfaceWeights", &AzFramework::Terrain::TerrainDataRequestBus::Events::GetSurfaceWeights)
|
||||
->Event("GetSurfaceWeightsFromVector2",
|
||||
&AzFramework::Terrain::TerrainDataRequestBus::Events::GetSurfaceWeightsFromVector2)
|
||||
->Event("GetIsHole", &AzFramework::Terrain::TerrainDataRequestBus::Events::GetIsHole)
|
||||
->Event("GetIsHoleFromFloats", &AzFramework::Terrain::TerrainDataRequestBus::Events::GetIsHoleFromFloats)
|
||||
->Event("GetSurfacePoint", &AzFramework::Terrain::TerrainDataRequestBus::Events::GetSurfacePoint)
|
||||
->Event("GetSurfacePoint", &AzFramework::Terrain::TerrainDataRequestBus::Events::BehaviorContextGetSurfacePoint)
|
||||
->Event("GetSurfacePointFromVector2",
|
||||
&AzFramework::Terrain::TerrainDataRequestBus::Events::GetSurfacePointFromVector2)
|
||||
&AzFramework::Terrain::TerrainDataRequestBus::Events::BehaviorContextGetSurfacePointFromVector2)
|
||||
->Event("GetTerrainAabb", &AzFramework::Terrain::TerrainDataRequestBus::Events::GetTerrainAabb)
|
||||
->Event("GetTerrainHeightQueryResolution",
|
||||
&AzFramework::Terrain::TerrainDataRequestBus::Events::GetTerrainHeightQueryResolution)
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace AzFramework
|
||||
virtual void SetTerrainAabb(const AZ::Aabb& worldBounds) = 0;
|
||||
|
||||
//! Returns terrains height in meters at location x,y.
|
||||
//! @terrainExistsPtr: Can be nullptr. If != nullptr then, if there's no terrain at location x,y or location x,y is inside a terrain HOLE then *terrainExistsPtr will become false,
|
||||
//! otherwise *terrainExistsPtr will become true.
|
||||
//! @terrainExistsPtr: Can be nullptr. If != nullptr then, if there's no terrain at location x,y or location x,y is inside
|
||||
//! a terrain HOLE then *terrainExistsPtr will become false, otherwise *terrainExistsPtr will become true.
|
||||
virtual float GetHeight(const AZ::Vector3& position, Sampler sampler = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
|
||||
virtual float GetHeightFromVector2(
|
||||
const AZ::Vector2& position, Sampler sampler = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
|
||||
@@ -68,8 +68,7 @@ namespace AzFramework
|
||||
|
||||
// Given an XY coordinate, return the surface normal.
|
||||
//! @terrainExists: Can be nullptr. If != nullptr then, if there's no terrain at location x,y or location x,y is inside a
|
||||
//! terrain HOLE then *terrainExistsPtr will be set to false,
|
||||
//! otherwise *terrainExistsPtr will be set to true.
|
||||
//! terrain HOLE then *terrainExistsPtr will be set to false, otherwise *terrainExistsPtr will be set to true.
|
||||
virtual AZ::Vector3 GetNormal(
|
||||
const AZ::Vector3& position, Sampler sampleFilter = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
|
||||
virtual AZ::Vector3 GetNormalFromVector2(
|
||||
@@ -78,8 +77,8 @@ namespace AzFramework
|
||||
float x, float y, Sampler sampleFilter = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
|
||||
|
||||
//! Given an XY coordinate, return the max surface type and weight.
|
||||
//! @terrainExists: Can be nullptr. If != nullptr then, if there's no terrain at location x,y or location x,y is inside a terrain HOLE then *terrainExistsPtr will be set to false,
|
||||
//! otherwise *terrainExistsPtr will be set to true.
|
||||
//! @terrainExists: Can be nullptr. If != nullptr then, if there's no terrain at location x,y or location x,y is inside
|
||||
//! a terrain HOLE then *terrainExistsPtr will be set to false, otherwise *terrainExistsPtr will be set to true.
|
||||
virtual SurfaceData::SurfaceTagWeight GetMaxSurfaceWeight(
|
||||
const AZ::Vector3& position, Sampler sampleFilter = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
|
||||
virtual SurfaceData::SurfaceTagWeight GetMaxSurfaceWeightFromVector2(
|
||||
@@ -87,8 +86,8 @@ namespace AzFramework
|
||||
virtual SurfaceData::SurfaceTagWeight GetMaxSurfaceWeightFromFloats(
|
||||
float x, float y, Sampler sampleFilter = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
|
||||
|
||||
//! Given an XY coordinate, return the set of surface types and weights. The Vector3 input position version is defined to ignore
|
||||
//! the input Z value.
|
||||
//! Given an XY coordinate, return the set of surface types and weights. The Vector3 input position version is defined to
|
||||
//! ignore the input Z value.
|
||||
virtual void GetSurfaceWeights(
|
||||
const AZ::Vector3& inPosition,
|
||||
SurfaceData::SurfaceTagWeightList& outSurfaceWeights,
|
||||
@@ -106,13 +105,14 @@ namespace AzFramework
|
||||
Sampler sampleFilter = Sampler::DEFAULT,
|
||||
bool* terrainExistsPtr = nullptr) const = 0;
|
||||
|
||||
//! Convenience function for low level systems that can't do a reverse lookup from Crc to string. Everyone else should use GetMaxSurfaceWeight or GetMaxSurfaceWeightFromFloats.
|
||||
//! Convenience function for low level systems that can't do a reverse lookup from Crc to string. Everyone else should use
|
||||
//! GetMaxSurfaceWeight or GetMaxSurfaceWeightFromFloats.
|
||||
//! Not available in the behavior context.
|
||||
//! Returns nullptr if the position is inside a hole or outside of the terrain boundaries.
|
||||
virtual const char* GetMaxSurfaceName(
|
||||
const AZ::Vector3& position, Sampler sampleFilter = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
|
||||
|
||||
//! Given an XY coordinate, return all terrain information at that location. The Vector3 input position version is defined
|
||||
//! Given an XY coordinate, return all terrain information at that location. The Vector3 input position version is defined
|
||||
//! to ignore the input Z value.
|
||||
virtual void GetSurfacePoint(
|
||||
const AZ::Vector3& inPosition,
|
||||
@@ -132,6 +132,25 @@ namespace AzFramework
|
||||
bool* terrainExistsPtr = nullptr) const = 0;
|
||||
|
||||
private:
|
||||
// Private variations of the GetSurfacePoint API exposed to BehaviorContext that returns a value instead of
|
||||
// using an "out" parameter. The "out" parameter is useful for reusing memory allocated in SurfacePoint when
|
||||
// using the public API, but can't easily be used from Script Canvas.
|
||||
SurfaceData::SurfacePoint BehaviorContextGetSurfacePoint(
|
||||
const AZ::Vector3& inPosition,
|
||||
Sampler sampleFilter = Sampler::DEFAULT) const
|
||||
{
|
||||
SurfaceData::SurfacePoint result;
|
||||
GetSurfacePoint(inPosition, result, sampleFilter);
|
||||
return result;
|
||||
}
|
||||
SurfaceData::SurfacePoint BehaviorContextGetSurfacePointFromVector2(
|
||||
const AZ::Vector2& inPosition,
|
||||
Sampler sampleFilter = Sampler::DEFAULT) const
|
||||
{
|
||||
SurfaceData::SurfacePoint result;
|
||||
GetSurfacePointFromVector2(inPosition, result, sampleFilter);
|
||||
return result;
|
||||
|
||||
// Functions without the optional bool* parameter that can be used from Python tests.
|
||||
float GetHeightVal(AZ::Vector3 position, Sampler sampler = Sampler::BILINEAR) const
|
||||
{
|
||||
|
||||
@@ -143,6 +143,13 @@ namespace AzFramework
|
||||
return vsync_interval;
|
||||
}
|
||||
|
||||
bool NativeWindow::SetSyncInterval(uint32_t newSyncInterval)
|
||||
{
|
||||
vsync_interval = newSyncInterval;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*static*/ bool NativeWindow::GetFullScreenStateOfDefaultWindow()
|
||||
{
|
||||
NativeWindowHandle defaultWindowHandle = nullptr;
|
||||
|
||||
@@ -132,6 +132,7 @@ namespace AzFramework
|
||||
void ToggleFullScreenState() override;
|
||||
float GetDpiScaleFactor() const override;
|
||||
uint32_t GetSyncInterval() const override;
|
||||
bool SetSyncInterval(uint32_t newSyncInterval) override;
|
||||
uint32_t GetDisplayRefreshRate() const override;
|
||||
|
||||
//! Get the full screen state of the default window.
|
||||
|
||||
@@ -78,6 +78,10 @@ namespace AzFramework
|
||||
//! Returns the sync interval which tells the drivers the number of v-blanks to synchronize with
|
||||
virtual uint32_t GetSyncInterval() const = 0;
|
||||
|
||||
//! Sets the sync interval which tells the drivers the number of v-blanks to synchronize with
|
||||
//! Returns if the sync interval was succesfully set
|
||||
virtual bool SetSyncInterval(uint32_t newSyncInterval) = 0;
|
||||
|
||||
//! Returns the refresh rate of the main display
|
||||
virtual uint32_t GetDisplayRefreshRate() const = 0;
|
||||
};
|
||||
|
||||
@@ -277,6 +277,8 @@ set(FILES
|
||||
Process/ProcessWatcher.cpp
|
||||
Process/ProcessWatcher.h
|
||||
Process/ProcessCommon_fwd.h
|
||||
Process/ProcessCommunicatorTracePrinter.cpp
|
||||
Process/ProcessCommunicatorTracePrinter.h
|
||||
ProjectManager/ProjectManager.h
|
||||
ProjectManager/ProjectManager.cpp
|
||||
Render/GameIntersectorComponent.h
|
||||
|
||||
@@ -29,6 +29,13 @@ namespace InputUnitTests
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class InputTest : public ScopedAllocatorSetupFixture
|
||||
{
|
||||
public:
|
||||
InputTest() : ScopedAllocatorSetupFixture()
|
||||
{
|
||||
// Many input tests are only valid if the GamePad device is supported on this platform.
|
||||
m_gamepadSupported = InputDeviceGamepad::GetMaxSupportedGamepads() > 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void SetUp() override
|
||||
@@ -46,6 +53,7 @@ namespace InputUnitTests
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
AZStd::unique_ptr<InputSystemComponent> m_inputSystemComponent;
|
||||
bool m_gamepadSupported;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -78,12 +86,17 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputContext_ActivateDeactivate_Successfull)
|
||||
#else
|
||||
TEST_F(InputTest, InputContext_ActivateDeactivate_Successfull)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputContext_ActivateDeactivate_Successfull";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputContext_ActivateDeactivate_Successfull";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
// Create an input context (they are inactive by default).
|
||||
InputContext inputContext("TestInputContext");
|
||||
|
||||
@@ -148,12 +161,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputContext_AddRemoveInputMapping_Successfull)
|
||||
#else
|
||||
TEST_F(InputTest, InputContext_AddRemoveInputMapping_Successfull)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputContext_AddRemoveInputMapping_Successfull";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputContext_AddRemoveInputMapping_Successfull";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an input context and activate it.
|
||||
InputContext inputContext("TestInputContext");
|
||||
inputContext.Activate();
|
||||
@@ -256,12 +275,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputContext_ConsumeProcessedInput_Consumed)
|
||||
#else
|
||||
TEST_F(InputTest, InputContext_ConsumeProcessedInput_Consumed)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputContext_ConsumeProcessedInput_Consumed";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputContext_ConsumeProcessedInput_Consumed";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
InputContext::InitData initData;
|
||||
|
||||
// Create a high priority input context that consumes input processed by any of its mappings.
|
||||
@@ -340,12 +365,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputContext_FilteredInput_Mapped)
|
||||
#else
|
||||
TEST_F(InputTest, InputContext_FilteredInput_Mapped)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputContext_FilteredInput_Mapped";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputContext_FilteredInput_Mapped";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an input context that initially only listens for keyboard input.
|
||||
InputContext::InitData initData;
|
||||
initData.autoActivate = true;
|
||||
@@ -413,12 +444,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputMappingOr_AddRemoveSourceInput_Successful)
|
||||
#else
|
||||
TEST_F(InputTest, InputMappingOr_AddRemoveSourceInput_Successful)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputMappingOr_AddRemoveSourceInput_Successful";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputMappingOr_AddRemoveSourceInput_Successful";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an input context and activate it.
|
||||
InputContext inputContext("TestInputContext");
|
||||
inputContext.Activate();
|
||||
@@ -491,12 +528,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputMappingOr_SingleSourceInput_Mapped)
|
||||
#else
|
||||
TEST_F(InputTest, InputMappingOr_SingleSourceInput_Mapped)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputMappingOr_SingleSourceInput_Mapped";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputMappingOr_SingleSourceInput_Mapped";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an input context and activate it.
|
||||
InputContext inputContext("TestInputContext");
|
||||
inputContext.Activate();
|
||||
@@ -558,12 +601,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputMappingOr_MultipleSourceInputs_Mapped)
|
||||
#else
|
||||
TEST_F(InputTest, InputMappingOr_MultipleSourceInputs_Mapped)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputMappingOr_MultipleSourceInputs_Mapped";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputMappingOr_MultipleSourceInputs_Mapped";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an input context and activate it.
|
||||
InputContext inputContext("TestInputContext");
|
||||
inputContext.Activate();
|
||||
@@ -650,12 +699,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputMappingAnd_AddRemoveSourceInput_Successful)
|
||||
#else
|
||||
TEST_F(InputTest, InputMappingAnd_AddRemoveSourceInput_Successful)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputMappingAnd_AddRemoveSourceInput_Successful";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputMappingAnd_AddRemoveSourceInput_Successful";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an input context and activate it.
|
||||
InputContext inputContext("TestInputContext");
|
||||
inputContext.Activate();
|
||||
@@ -728,12 +783,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputMappingAnd_SingleSourceInput_Mapped)
|
||||
#else
|
||||
TEST_F(InputTest, InputMappingAnd_SingleSourceInput_Mapped)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputMappingAnd_SingleSourceInput_Mapped";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputMappingAnd_SingleSourceInput_Mapped";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an input context and activate it.
|
||||
InputContext inputContext("TestInputContext");
|
||||
inputContext.Activate();
|
||||
@@ -795,12 +856,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputMappingAnd_MultipleSourceInputs_Mapped)
|
||||
#else
|
||||
TEST_F(InputTest, InputMappingAnd_MultipleSourceInputs_Mapped)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputMappingAnd_MultipleSourceInputs_Mapped";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputMappingAnd_MultipleSourceInputs_Mapped";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an input context and activate it.
|
||||
InputContext inputContext("TestInputContext");
|
||||
inputContext.Activate();
|
||||
@@ -909,12 +976,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputMappingAnd_MultipleSourceInputsWithDifferentValues_ValuesAveraged)
|
||||
#else
|
||||
TEST_F(InputTest, InputMappingAnd_MultipleSourceInputsWithDifferentValues_ValuesAveraged)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputMappingAnd_MultipleSourceInputsWithDifferentValues_ValuesAveraged";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputMappingAnd_MultipleSourceInputsWithDifferentValues_ValuesAveraged";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an input context and activate it.
|
||||
InputContext inputContext("TestInputContext");
|
||||
inputContext.Activate();
|
||||
@@ -969,12 +1042,18 @@ namespace InputUnitTests
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
TEST_F(InputTest, DISABLED_InputMappingAnd_MultipleSourceInputsFromTheSameInputDeviceTypeWithDifferentIndicies_NotMapped)
|
||||
#else
|
||||
TEST_F(InputTest, InputMappingAnd_MultipleSourceInputsFromTheSameInputDeviceTypeWithDifferentIndicies_NotMapped)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
|
||||
{
|
||||
if (!m_gamepadSupported)
|
||||
{
|
||||
#if defined(GTEST_SKIP)
|
||||
GTEST_SKIP() << "Skipping test InputMappingAnd_MultipleSourceInputsFromTheSameInputDeviceTypeWithDifferentIndicies_NotMapped";
|
||||
#else
|
||||
SUCCEED() << "Skipping test InputMappingAnd_MultipleSourceInputsFromTheSameInputDeviceTypeWithDifferentIndicies_NotMapped";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an input context and activate it.
|
||||
InputContext inputContext("TestInputContext");
|
||||
inputContext.Activate();
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace UnitTest
|
||||
MOCK_METHOD0(ToggleFullScreenState, void());
|
||||
MOCK_CONST_METHOD0(GetDpiScaleFactor, float());
|
||||
MOCK_CONST_METHOD0(GetSyncInterval, uint32_t());
|
||||
MOCK_METHOD1(SetSyncInterval, bool(uint32_t));
|
||||
MOCK_CONST_METHOD0(GetDisplayRefreshRate, uint32_t());
|
||||
};
|
||||
} // namespace UnitTest
|
||||
|
||||
@@ -53,7 +53,6 @@ static void OptimizedSetParent(QWidget* widget, QWidget* parent)
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
static const FancyDockingDropZoneConstants g_FancyDockingConstants;
|
||||
|
||||
// Constant for the threshold in pixels for snapping to edges while dragging for docking
|
||||
static const int g_snapThresholdInPixels = 15;
|
||||
@@ -155,7 +154,7 @@ namespace AzQtComponents
|
||||
|
||||
// Timer for updating our hovered drop zone opacity
|
||||
QObject::connect(m_dropZoneHoverFadeInTimer, &QTimer::timeout, this, &FancyDocking::onDropZoneHoverFadeInUpdate);
|
||||
m_dropZoneHoverFadeInTimer->setInterval(g_FancyDockingConstants.dropZoneHoverFadeUpdateIntervalMS);
|
||||
m_dropZoneHoverFadeInTimer->setInterval(FancyDockingDropZoneConstants::dropZoneHoverFadeUpdateIntervalMS);
|
||||
QIcon dragIcon = QIcon(QStringLiteral(":/Cursors/Grabbing.svg"));
|
||||
m_dragCursor = QCursor(dragIcon.pixmap(16), 5, 2);
|
||||
}
|
||||
@@ -333,13 +332,13 @@ namespace AzQtComponents
|
||||
*/
|
||||
void FancyDocking::onDropZoneHoverFadeInUpdate()
|
||||
{
|
||||
const qreal dropZoneHoverOpacity = g_FancyDockingConstants.dropZoneHoverFadeIncrement + m_dropZoneState.dropZoneHoverOpacity();
|
||||
const qreal dropZoneHoverOpacity = FancyDockingDropZoneConstants::dropZoneHoverFadeIncrement + m_dropZoneState.dropZoneHoverOpacity();
|
||||
|
||||
// Once we've reached the full drop zone opacity, cut it off in case we
|
||||
// went over and stop the timer
|
||||
if (dropZoneHoverOpacity >= g_FancyDockingConstants.dropZoneOpacity)
|
||||
if (dropZoneHoverOpacity >= FancyDockingDropZoneConstants::dropZoneOpacity)
|
||||
{
|
||||
m_dropZoneState.setDropZoneHoverOpacity(g_FancyDockingConstants.dropZoneOpacity);
|
||||
m_dropZoneState.setDropZoneHoverOpacity(FancyDockingDropZoneConstants::dropZoneOpacity);
|
||||
m_dropZoneHoverFadeInTimer->stop();
|
||||
}
|
||||
else
|
||||
@@ -792,12 +791,12 @@ namespace AzQtComponents
|
||||
QPoint mainWindowTopLeft = multiscreenMapFromGlobal(mainWindow->mapToGlobal(mainWindowRect.topLeft()));
|
||||
QPoint mainWindowTopRight = multiscreenMapFromGlobal(mainWindow->mapToGlobal(mainWindowRect.topRight()));
|
||||
QPoint mainWindowBottomLeft = multiscreenMapFromGlobal(mainWindow->mapToGlobal(mainWindowRect.bottomLeft()));
|
||||
QSize absoluteLeftRightSize(g_FancyDockingConstants.absoluteDropZoneSizeInPixels, mainWindowRect.height());
|
||||
QSize absoluteLeftRightSize(FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels, mainWindowRect.height());
|
||||
QRect absoluteLeftDropZone(mainWindowTopLeft, absoluteLeftRightSize);
|
||||
QRect absoluteRightDropZone(mainWindowTopRight - QPoint(g_FancyDockingConstants.absoluteDropZoneSizeInPixels, 0), absoluteLeftRightSize);
|
||||
QSize absoluteTopBottomSize(mainWindowRect.width(), g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
|
||||
QRect absoluteRightDropZone(mainWindowTopRight - QPoint(FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels, 0), absoluteLeftRightSize);
|
||||
QSize absoluteTopBottomSize(mainWindowRect.width(), FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
|
||||
QRect absoluteTopDropZone(mainWindowTopLeft, absoluteTopBottomSize);
|
||||
QRect absoluteBottomDropZone(mainWindowBottomLeft - QPoint(0, g_FancyDockingConstants.absoluteDropZoneSizeInPixels), absoluteTopBottomSize);
|
||||
QRect absoluteBottomDropZone(mainWindowBottomLeft - QPoint(0, FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels), absoluteTopBottomSize);
|
||||
|
||||
// If the drop target is a main window, then we will only show the absolute
|
||||
// drop zone if the cursor is in that zone already
|
||||
@@ -986,16 +985,16 @@ namespace AzQtComponents
|
||||
switch (m_dropZoneState.absoluteDropZoneArea())
|
||||
{
|
||||
case Qt::LeftDockWidgetArea:
|
||||
dockRect.setX(dockRect.x() + g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
|
||||
dockRect.setX(dockRect.x() + FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
|
||||
break;
|
||||
case Qt::RightDockWidgetArea:
|
||||
dockRect.setWidth(dockRect.width() - g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
|
||||
dockRect.setWidth(dockRect.width() - FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
|
||||
break;
|
||||
case Qt::TopDockWidgetArea:
|
||||
dockRect.setY(dockRect.y() + g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
|
||||
dockRect.setY(dockRect.y() + FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
|
||||
break;
|
||||
case Qt::BottomDockWidgetArea:
|
||||
dockRect.setHeight(dockRect.height() - g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
|
||||
dockRect.setHeight(dockRect.height() - FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1034,15 +1033,15 @@ namespace AzQtComponents
|
||||
// Set the drop zone width/height to the default, but if the dock widget
|
||||
// width and/or height is below the threshold, then switch to scaling them
|
||||
// down accordingly
|
||||
int dropZoneWidth = g_FancyDockingConstants.dropZoneSizeInPixels;
|
||||
if (dockWidth < g_FancyDockingConstants.minDockSizeBeforeDropZoneScalingInPixels)
|
||||
int dropZoneWidth = FancyDockingDropZoneConstants::dropZoneSizeInPixels;
|
||||
if (dockWidth < FancyDockingDropZoneConstants::minDockSizeBeforeDropZoneScalingInPixels)
|
||||
{
|
||||
dropZoneWidth = aznumeric_cast<int>(dockWidth * g_FancyDockingConstants.dropZoneScaleFactor);
|
||||
dropZoneWidth = aznumeric_cast<int>(dockWidth * FancyDockingDropZoneConstants::dropZoneScaleFactor);
|
||||
}
|
||||
int dropZoneHeight = g_FancyDockingConstants.dropZoneSizeInPixels;
|
||||
if (dockHeight < g_FancyDockingConstants.minDockSizeBeforeDropZoneScalingInPixels)
|
||||
int dropZoneHeight = FancyDockingDropZoneConstants::dropZoneSizeInPixels;
|
||||
if (dockHeight < FancyDockingDropZoneConstants::minDockSizeBeforeDropZoneScalingInPixels)
|
||||
{
|
||||
dropZoneHeight = aznumeric_cast<int>(dockHeight * g_FancyDockingConstants.dropZoneScaleFactor);
|
||||
dropZoneHeight = aznumeric_cast<int>(dockHeight * FancyDockingDropZoneConstants::dropZoneScaleFactor);
|
||||
}
|
||||
|
||||
// Calculate the inner corners to be used when constructing the drop zone polygons
|
||||
@@ -1078,7 +1077,7 @@ namespace AzQtComponents
|
||||
int innerDropZoneWidth = m_dropZoneState.innerDropZoneRect().width();
|
||||
int innerDropZoneHeight = m_dropZoneState.innerDropZoneRect().height();
|
||||
int centerDropZoneDiameter = (innerDropZoneWidth < innerDropZoneHeight) ? innerDropZoneWidth : innerDropZoneHeight;
|
||||
centerDropZoneDiameter = aznumeric_cast<int>(centerDropZoneDiameter * g_FancyDockingConstants.centerTabDropZoneScale);
|
||||
centerDropZoneDiameter = aznumeric_cast<int>(centerDropZoneDiameter * FancyDockingDropZoneConstants::centerTabDropZoneScale);
|
||||
|
||||
// Setup our center tab drop zone
|
||||
const QSize centerDropZoneSize(centerDropZoneDiameter, centerDropZoneDiameter);
|
||||
@@ -1986,7 +1985,7 @@ namespace AzQtComponents
|
||||
// hasn't faded in all the way yet, then ignore the drop zone area
|
||||
// which will make the widget floating
|
||||
bool modifiedKeyPressed = FancyDockingDropZoneWidget::CheckModifierKey();
|
||||
if (modifiedKeyPressed || m_dropZoneState.dropZoneHoverOpacity() != g_FancyDockingConstants.dropZoneOpacity)
|
||||
if (modifiedKeyPressed || m_dropZoneState.dropZoneHoverOpacity() != FancyDockingDropZoneConstants::dropZoneOpacity)
|
||||
{
|
||||
area = Qt::NoDockWidgetArea;
|
||||
}
|
||||
@@ -3026,7 +3025,7 @@ namespace AzQtComponents
|
||||
{
|
||||
bool modifiedKeyPressed = FancyDockingDropZoneWidget::CheckModifierKey();
|
||||
|
||||
m_ghostWidget->setWindowOpacity(modifiedKeyPressed ? 1.0f : g_FancyDockingConstants.draggingDockWidgetOpacity);
|
||||
m_ghostWidget->setWindowOpacity(modifiedKeyPressed ? 1.0f : FancyDockingDropZoneConstants::draggingDockWidgetOpacity);
|
||||
m_ghostWidget->setPixmap(m_state.dockWidgetScreenGrab.screenGrab, m_state.placeholder(), m_state.placeholderScreen());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-27
@@ -19,26 +19,6 @@
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
static const FancyDockingDropZoneConstants g_Constants;
|
||||
|
||||
FancyDockingDropZoneConstants::FancyDockingDropZoneConstants()
|
||||
{
|
||||
draggingDockWidgetOpacity = 0.6;
|
||||
dropZoneOpacity = 0.4;
|
||||
dropZoneSizeInPixels = 40;
|
||||
minDockSizeBeforeDropZoneScalingInPixels = dropZoneSizeInPixels * 3;
|
||||
dropZoneScaleFactor = 0.25;
|
||||
centerTabDropZoneScale = 0.5;
|
||||
centerTabIconScale = 0.5;
|
||||
dropZoneColor = QColor(155, 155, 155);
|
||||
dropZoneBorderColor = Qt::black;
|
||||
dropZoneBorderInPixels = 1;
|
||||
absoluteDropZoneSizeInPixels = 25;
|
||||
dockingTargetDelayMS = 110;
|
||||
dropZoneHoverFadeUpdateIntervalMS = 20;
|
||||
dropZoneHoverFadeIncrement = dropZoneOpacity / (dockingTargetDelayMS / dropZoneHoverFadeUpdateIntervalMS);
|
||||
centerDropZoneIconPath = QString(":/stylesheet/img/UI20/docking/tabs_icon.svg");
|
||||
}
|
||||
|
||||
FancyDockingDropZoneWidget::FancyDockingDropZoneWidget(QMainWindow* mainWindow, QWidget* coordinatesRelativeTo, QScreen* screen, FancyDockingDropZoneState* dropZoneState)
|
||||
// NOTE: this will not work with multiple monitors if this widget has a parent. The floating drop zone
|
||||
@@ -154,7 +134,7 @@ namespace AzQtComponents
|
||||
|
||||
// Draw all of the normal drop zones if they exist (if a dock widget is hovered over)
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setOpacity(g_Constants.dropZoneOpacity);
|
||||
painter.setOpacity(FancyDockingDropZoneConstants::dropZoneOpacity);
|
||||
auto dropZones = m_dropZoneState->dropZones();
|
||||
for (auto it = dropZones.cbegin(); it != dropZones.cend(); ++it)
|
||||
{
|
||||
@@ -189,7 +169,7 @@ namespace AzQtComponents
|
||||
// Otherwise, set the normal color
|
||||
else
|
||||
{
|
||||
painter.setBrush(g_Constants.dropZoneColor);
|
||||
painter.setBrush(FancyDockingDropZoneConstants::dropZoneColor);
|
||||
}
|
||||
|
||||
// negate the window position to offset everything by that much
|
||||
@@ -214,8 +194,8 @@ namespace AzQtComponents
|
||||
// Scale the tabs icon based on the drop zone size and our specified offset
|
||||
// Doing this through QIcon to make sure that SVG is rendered already in desired resolution
|
||||
const QSize& dropZoneSize = dropZoneRect.size();
|
||||
const QSize requestedIconSize = dropZoneSize * g_Constants.centerTabIconScale;
|
||||
const QIcon dropZoneIcon = QIcon(g_Constants.centerDropZoneIconPath);
|
||||
const QSize requestedIconSize = dropZoneSize * FancyDockingDropZoneConstants::centerTabIconScale;
|
||||
const QIcon dropZoneIcon = QIcon(FancyDockingDropZoneConstants::centerDropZoneIconPath);
|
||||
const QPixmap dropZonePixmap = dropZoneIcon.pixmap(requestedIconSize);
|
||||
const QSize receivedIconSize = dropZoneIcon.actualSize(requestedIconSize);
|
||||
|
||||
@@ -264,7 +244,7 @@ namespace AzQtComponents
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.setBrush(g_Constants.dropZoneColor);
|
||||
painter.setBrush(FancyDockingDropZoneConstants::dropZoneColor);
|
||||
}
|
||||
painter.drawRect(absoluteDropZoneRect);
|
||||
|
||||
@@ -313,8 +293,8 @@ namespace AzQtComponents
|
||||
const QPoint innerBottomRight = innerDropZoneRect.bottomRight();
|
||||
|
||||
// Draw the lines using the appropriate pen
|
||||
QPen dropZoneBorderPen(g_Constants.dropZoneBorderColor);
|
||||
dropZoneBorderPen.setWidth(g_Constants.dropZoneBorderInPixels);
|
||||
QPen dropZoneBorderPen(FancyDockingDropZoneConstants::dropZoneBorderColor);
|
||||
dropZoneBorderPen.setWidth(FancyDockingDropZoneConstants::dropZoneBorderInPixels);
|
||||
painter.setPen(dropZoneBorderPen);
|
||||
painter.setOpacity(1);
|
||||
painter.drawLine(topLeft, innerTopLeft);
|
||||
|
||||
+16
-21
@@ -28,63 +28,58 @@ class QPainter;
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
struct AZ_QT_COMPONENTS_API FancyDockingDropZoneConstants
|
||||
namespace FancyDockingDropZoneConstants
|
||||
{
|
||||
// Constant for the opacity of the screen grab for the dock widget being dragged
|
||||
qreal draggingDockWidgetOpacity;
|
||||
static constexpr qreal draggingDockWidgetOpacity = 0.6;
|
||||
|
||||
// Constant for the opacity of the normal drop zones
|
||||
qreal dropZoneOpacity;
|
||||
static constexpr qreal dropZoneOpacity = 0.4;
|
||||
|
||||
// Constant for the default drop zone size (in pixels)
|
||||
int dropZoneSizeInPixels;
|
||||
static constexpr int dropZoneSizeInPixels = 40;
|
||||
|
||||
// Constant for the dock width/height size (in pixels) before we need to start
|
||||
// scaling down the drop zone sizes, or else they will overlap with the center
|
||||
// tab icon or each other
|
||||
int minDockSizeBeforeDropZoneScalingInPixels;
|
||||
static constexpr int minDockSizeBeforeDropZoneScalingInPixels = dropZoneSizeInPixels * 3;
|
||||
|
||||
// Constant for the factor by which we must scale down the drop zone sizes once
|
||||
// the dock width/height size is too small
|
||||
qreal dropZoneScaleFactor;
|
||||
static constexpr qreal dropZoneScaleFactor = 0.25;
|
||||
|
||||
// Constant for the percentage to scale down the inner drop zone rectangle for the center tab drop zone
|
||||
qreal centerTabDropZoneScale;
|
||||
static constexpr qreal centerTabDropZoneScale = 0.5;
|
||||
|
||||
// Constant for the percentage to scale down the center tab drop zone for the center tab icon
|
||||
qreal centerTabIconScale;
|
||||
static constexpr qreal centerTabIconScale = 0.5;
|
||||
|
||||
// Constant for the drop zone hotspot default color
|
||||
QColor dropZoneColor;
|
||||
static const QColor dropZoneColor = QColor(155, 155, 155);
|
||||
|
||||
// Constant for the drop zone border color
|
||||
QColor dropZoneBorderColor;
|
||||
static const QColor dropZoneBorderColor = Qt::black;
|
||||
|
||||
// Constant for the border width in pixels separating the drop zones
|
||||
int dropZoneBorderInPixels;
|
||||
static constexpr int dropZoneBorderInPixels = 1;
|
||||
|
||||
// Constant for the border width in pixels separating the drop zones
|
||||
int absoluteDropZoneSizeInPixels;
|
||||
static constexpr int absoluteDropZoneSizeInPixels = 25;
|
||||
|
||||
// Constant for the delay (in milliseconds) before a drop zone becomes active
|
||||
// once it is hovered over
|
||||
int dockingTargetDelayMS;
|
||||
static constexpr int dockingTargetDelayMS = 110;
|
||||
|
||||
// Constant for the rate at which we will update (fade in) the drop zone opacity
|
||||
// when hovered over (in milliseconds)
|
||||
int dropZoneHoverFadeUpdateIntervalMS;
|
||||
static constexpr int dropZoneHoverFadeUpdateIntervalMS = 20;
|
||||
|
||||
// Constant for the incremental opacity increase for the hovered drop zone
|
||||
// that will fade in to the full drop zone opacity in the desired time
|
||||
qreal dropZoneHoverFadeIncrement;
|
||||
static constexpr qreal dropZoneHoverFadeIncrement = dropZoneOpacity / (dockingTargetDelayMS / dropZoneHoverFadeUpdateIntervalMS);
|
||||
|
||||
// Constant for the path to the center drop zone tabs icon
|
||||
QString centerDropZoneIconPath;
|
||||
|
||||
FancyDockingDropZoneConstants();
|
||||
|
||||
FancyDockingDropZoneConstants(const FancyDockingDropZoneConstants&) = delete;
|
||||
FancyDockingDropZoneConstants& operator=(const FancyDockingDropZoneConstants&) = delete;
|
||||
static const QString centerDropZoneIconPath = QStringLiteral(":/stylesheet/img/UI20/docking/tabs_icon.svg");
|
||||
};
|
||||
|
||||
class FancyDockingDropZoneState
|
||||
|
||||
+4
-3
@@ -323,7 +323,7 @@ namespace AzQtComponents
|
||||
saturation *= 2.0 - lightness;
|
||||
}
|
||||
double value = (lightness + saturation) / 2.0;
|
||||
saturation = (2.0 * saturation) / (lightness + saturation);
|
||||
saturation = qFuzzyIsNull(lightness + saturation) ? 0 : (2.0 * saturation) / (lightness + saturation);
|
||||
|
||||
m_hsv.saturation = AZ::GetClamp(saturation, 0.0, 1.0);
|
||||
m_hsv.value = AZ::GetClamp(value, 0.0, 12.5);
|
||||
@@ -341,11 +341,12 @@ namespace AzQtComponents
|
||||
double saturation = m_hsv.saturation * m_hsv.value;
|
||||
if (lightness <= 1.0)
|
||||
{
|
||||
saturation /= lightness;
|
||||
saturation = (qFuzzyIsNull(lightness)) ? 0.0 : saturation / lightness;
|
||||
}
|
||||
else
|
||||
{
|
||||
saturation /= 2.0 - lightness;
|
||||
double two_minus_lightness = 2.0 - lightness;
|
||||
saturation = (qFuzzyIsNull(two_minus_lightness)) ? 0.0 : saturation / two_minus_lightness;
|
||||
}
|
||||
lightness /= 2.0;
|
||||
|
||||
|
||||
@@ -164,11 +164,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if AZ_TRAIT_DISABLE_FAILED_ZERO_COLOR_CONVERSION_TEST
|
||||
TEST(AzQtComponents, DISABLED_ColorConversionsTestAllZeros)
|
||||
#else
|
||||
TEST(AzQtComponents, ColorConversionsTestAllZeros)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_ZERO_COLOR_CONVERSION_TEST
|
||||
{
|
||||
TestConversions({ 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 });
|
||||
}
|
||||
|
||||
@@ -13,19 +13,16 @@
|
||||
#define AZ_TRAIT_UNIT_TEST_ENTITY_ID_GEN_TEST_COUNT 10000
|
||||
#define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000
|
||||
|
||||
#define AZ_TRAIT_DISABLE_ALL_SAVE_DATA_TESTS true
|
||||
|
||||
#define AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_ASSET_LOAD_TESTS true
|
||||
|
||||
#define AZ_TRAIT_DISABLE_FAILED_ATOM_RPI_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_ZERO_COLOR_CONVERSION_TEST true
|
||||
|
||||
#define AZ_TRAIT_DISABLE_FAILED_FRAMEPROFILER_TEST true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_FRAMEWORK_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_GRADIENT_SIGNAL_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_MULTIPLAYER_GRIDMATE_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_NATIVE_WINDOWS_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS true
|
||||
#define AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_TESTS true
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <AzToolsFramework/ContainerEntity/ContainerEntitySystemComponent.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextComponent.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntitySystemComponent.h>
|
||||
#include <AzToolsFramework/FocusMode/FocusModeSystemComponent.h>
|
||||
#include <AzToolsFramework/Slice/SliceMetadataEntityContextComponent.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabSystemComponent.h>
|
||||
@@ -268,6 +269,7 @@ namespace AzToolsFramework
|
||||
azrtti_typeid<Components::EditorEntityUiSystemComponent>(),
|
||||
azrtti_typeid<FocusModeSystemComponent>(),
|
||||
azrtti_typeid<ContainerEntitySystemComponent>(),
|
||||
azrtti_typeid<ReadOnlyEntitySystemComponent>(),
|
||||
azrtti_typeid<SliceMetadataEntityContextComponent>(),
|
||||
azrtti_typeid<Prefab::PrefabSystemComponent>(),
|
||||
azrtti_typeid<EditorEntityFixupComponent>(),
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <AzToolsFramework/Entity/EditorEntityModelComponent.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntitySearchComponent.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntitySortComponent.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntitySystemComponent.h>
|
||||
#include <AzToolsFramework/FocusMode/FocusModeSystemComponent.h>
|
||||
#include <AzToolsFramework/PropertyTreeEditor/PropertyTreeEditorComponent.h>
|
||||
#include <AzToolsFramework/Render/EditorIntersectorComponent.h>
|
||||
@@ -75,6 +76,7 @@ namespace AzToolsFramework
|
||||
EditorEntityFixupComponent::CreateDescriptor(),
|
||||
EntityUtilityComponent::CreateDescriptor(),
|
||||
ContainerEntitySystemComponent::CreateDescriptor(),
|
||||
ReadOnlyEntitySystemComponent::CreateDescriptor(),
|
||||
FocusModeSystemComponent::CreateDescriptor(),
|
||||
SliceMetadataEntityContextComponent::CreateDescriptor(),
|
||||
SliceRequestComponent::CreateDescriptor(),
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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 <AzCore/Component/EntityId.h>
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
|
||||
#include <AzFramework/Entity/EntityContext.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
//! Used to notify changes of state for read-only entities.
|
||||
class ReadOnlyEntityPublicNotifications
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = AzFramework::EntityContextId;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Triggered when an entity's read-only status changes.
|
||||
//! @param entityId The entity whose status has changed.
|
||||
//! @param readOnly The read-only state the container was changed to.
|
||||
virtual void OnReadOnlyEntityStatusChanged([[maybe_unused]] const AZ::EntityId& entityId, [[maybe_unused]] bool readOnly) {}
|
||||
|
||||
protected:
|
||||
~ReadOnlyEntityPublicNotifications() = default;
|
||||
};
|
||||
using ReadOnlyEntityPublicNotificationBus = AZ::EBus<ReadOnlyEntityPublicNotifications>;
|
||||
|
||||
//! Used by the ReadOnlyEntitySystemComponent to query the read-only state of entities as set by systems using the API.
|
||||
class ReadOnlyEntityQueryRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = AzFramework::EntityContextId;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Triggered when an entity's read-only status is queried.
|
||||
//! Allows multiple systems to weigh in on the read-only status of an entity.
|
||||
//! @param entityId The entity whose status has changed.
|
||||
//! @param[out] isReadOnly The output of the query. Should only be changed to true, and left untouched if false.
|
||||
virtual void IsReadOnly(const AZ::EntityId& entityId, bool& isReadOnly) = 0;
|
||||
|
||||
protected:
|
||||
~ReadOnlyEntityQueryRequests() = default;
|
||||
};
|
||||
using ReadOnlyEntityQueryRequestBus = AZ::EBus<ReadOnlyEntityQueryRequests>;
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
#include <AzFramework/Entity/EntityContextBus.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
//! An entity registered as read-only cannot be altered in the editor.
|
||||
class ReadOnlyEntityPublicInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ReadOnlyEntityPublicInterface, "{921FE15B-6EBD-47F0-8238-BC63318DEDEA}");
|
||||
|
||||
//! Returns whether the entity id provided is registered as read-only.
|
||||
virtual bool IsReadOnly(const AZ::EntityId& entityId) = 0;
|
||||
};
|
||||
|
||||
//! An entity registered as read-only cannot be altered in the editor.
|
||||
class ReadOnlyEntityQueryInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ReadOnlyEntityQueryInterface, "{2ACD63C5-1F3E-4DE8-880E-8115F857D329}");
|
||||
|
||||
//! Refreshes the cached read-only status for the entities provided.
|
||||
//! @param entityIds The entityIds whose read-only state will be queried again.
|
||||
virtual void RefreshReadOnlyState(const EntityIdList& entityIds) = 0;
|
||||
|
||||
//! Refreshes the cached read-only status for all entities.
|
||||
//! Useful when disconnecting a handler at runtime.
|
||||
virtual void RefreshReadOnlyStateForAllEntities() = 0;
|
||||
};
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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 <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntitySystemComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void ReadOnlyEntitySystemComponent::Activate()
|
||||
{
|
||||
AZ::Interface<ReadOnlyEntityQueryInterface>::Register(this);
|
||||
AZ::Interface<ReadOnlyEntityPublicInterface>::Register(this);
|
||||
EditorEntityContextNotificationBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void ReadOnlyEntitySystemComponent::Deactivate()
|
||||
{
|
||||
EditorEntityContextNotificationBus::Handler::BusDisconnect();
|
||||
AZ::Interface<ReadOnlyEntityPublicInterface>::Unregister(this);
|
||||
AZ::Interface<ReadOnlyEntityQueryInterface>::Unregister(this);
|
||||
}
|
||||
|
||||
void ReadOnlyEntitySystemComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<ReadOnlyEntitySystemComponent, AZ::Component>()->Version(1);
|
||||
}
|
||||
}
|
||||
|
||||
void ReadOnlyEntitySystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
{
|
||||
provided.push_back(AZ_CRC_CE("ReadOnlyEntityService"));
|
||||
}
|
||||
|
||||
bool ReadOnlyEntitySystemComponent::IsReadOnly(const AZ::EntityId& entityId)
|
||||
{
|
||||
if (!m_readOnlystates.contains(entityId))
|
||||
{
|
||||
QueryReadOnlyStateForEntity(entityId);
|
||||
}
|
||||
|
||||
return m_readOnlystates[entityId];
|
||||
}
|
||||
|
||||
void ReadOnlyEntitySystemComponent::RefreshReadOnlyState(const EntityIdList& entityIds)
|
||||
{
|
||||
for (const AZ::EntityId entityId : entityIds)
|
||||
{
|
||||
bool wasReadOnly = m_readOnlystates[entityId];
|
||||
QueryReadOnlyStateForEntity(entityId);
|
||||
|
||||
if (bool isReadOnly = m_readOnlystates[entityId]; wasReadOnly != isReadOnly)
|
||||
{
|
||||
ReadOnlyEntityPublicNotificationBus::Broadcast(
|
||||
&ReadOnlyEntityPublicNotificationBus::Events::OnReadOnlyEntityStatusChanged, entityId, isReadOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReadOnlyEntitySystemComponent::RefreshReadOnlyStateForAllEntities()
|
||||
{
|
||||
for (auto elem : m_readOnlystates)
|
||||
{
|
||||
AZ::EntityId entityId = elem.first;
|
||||
bool wasReadOnly = m_readOnlystates[entityId];
|
||||
QueryReadOnlyStateForEntity(entityId);
|
||||
|
||||
if (bool isReadOnly = m_readOnlystates[entityId]; wasReadOnly != isReadOnly)
|
||||
{
|
||||
ReadOnlyEntityPublicNotificationBus::Broadcast(
|
||||
&ReadOnlyEntityPublicNotificationBus::Events::OnReadOnlyEntityStatusChanged, entityId, isReadOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReadOnlyEntitySystemComponent::OnContextReset()
|
||||
{
|
||||
m_readOnlystates.clear();
|
||||
}
|
||||
|
||||
void ReadOnlyEntitySystemComponent::QueryReadOnlyStateForEntity(const AZ::EntityId& entityId)
|
||||
{
|
||||
bool isReadOnly = false;
|
||||
|
||||
ReadOnlyEntityQueryRequestBus::Broadcast(
|
||||
&ReadOnlyEntityQueryRequestBus::Events::IsReadOnly, entityId, isReadOnly);
|
||||
|
||||
m_readOnlystates[entityId] = isReadOnly;
|
||||
}
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 <AzCore/Component/Component.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
//! System Component to track read-only entity registration.
|
||||
//! An entity registered as ReadOnly cannot be altered in the Editor.
|
||||
class ReadOnlyEntitySystemComponent final
|
||||
: public AZ::Component
|
||||
, private ReadOnlyEntityPublicInterface
|
||||
, private ReadOnlyEntityQueryInterface
|
||||
, private EditorEntityContextNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(ReadOnlyEntitySystemComponent, "{B32EB03F-D88F-4B3A-9C16-071AF04DA646}");
|
||||
|
||||
ReadOnlyEntitySystemComponent() = default;
|
||||
virtual ~ReadOnlyEntitySystemComponent() = default;
|
||||
|
||||
// AZ::Component overrides ...
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
||||
|
||||
// ReadOnlyEntityPublicNotifications overrides ...
|
||||
bool IsReadOnly(const AZ::EntityId& entityId) override;
|
||||
|
||||
// ReadOnlyEntityQueryInterface overrides ...
|
||||
void RefreshReadOnlyState(const EntityIdList& entityIds) override;
|
||||
void RefreshReadOnlyStateForAllEntities() override;
|
||||
|
||||
// EditorEntityContextNotificationBus overrides ...
|
||||
void OnContextReset() override;
|
||||
|
||||
private:
|
||||
void QueryReadOnlyStateForEntity(const AZ::EntityId& entityId);
|
||||
|
||||
AZStd::unordered_map<AZ::EntityId, bool> m_readOnlystates;
|
||||
};
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
@@ -34,10 +34,12 @@ namespace AzToolsFramework::Prefab
|
||||
PrefabPublicNotificationBus::Handler::BusConnect();
|
||||
AZ::Interface<PrefabFocusInterface>::Register(this);
|
||||
AZ::Interface<PrefabFocusPublicInterface>::Register(this);
|
||||
PrefabFocusPublicRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
PrefabFocusHandler::~PrefabFocusHandler()
|
||||
{
|
||||
PrefabFocusPublicRequestBus::Handler::BusDisconnect();
|
||||
AZ::Interface<PrefabFocusPublicInterface>::Unregister(this);
|
||||
AZ::Interface<PrefabFocusInterface>::Unregister(this);
|
||||
PrefabPublicNotificationBus::Handler::BusDisconnect();
|
||||
@@ -45,6 +47,18 @@ namespace AzToolsFramework::Prefab
|
||||
EditorEntityInfoNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void PrefabFocusHandler::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context); behaviorContext)
|
||||
{
|
||||
behaviorContext->EBus<PrefabFocusPublicRequestBus>("PrefabFocusPublicRequestBus")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Prefab")
|
||||
->Attribute(AZ::Script::Attributes::Module, "prefab")
|
||||
->Event("FocusOnOwningPrefab", &PrefabFocusPublicInterface::FocusOnOwningPrefab);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefabFocusHandler::InitializeEditorInterfaces()
|
||||
{
|
||||
m_containerEntityInterface = AZ::Interface<ContainerEntityInterface>::Get();
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace AzToolsFramework::Prefab
|
||||
|
||||
//! Handles Prefab Focus mode, determining which prefab file entity changes will target.
|
||||
class PrefabFocusHandler final
|
||||
: private PrefabFocusInterface
|
||||
, private PrefabFocusPublicInterface
|
||||
: public PrefabFocusPublicRequestBus::Handler
|
||||
, private PrefabFocusInterface
|
||||
, private PrefabPublicNotificationBus::Handler
|
||||
, private EditorEntityContextNotificationBus::Handler
|
||||
, private EditorEntityInfoNotificationBus::Handler
|
||||
@@ -42,13 +42,15 @@ namespace AzToolsFramework::Prefab
|
||||
PrefabFocusHandler();
|
||||
~PrefabFocusHandler();
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
// PrefabFocusInterface overrides ...
|
||||
void InitializeEditorInterfaces() override;
|
||||
PrefabFocusOperationResult FocusOnPrefabInstanceOwningEntityId(AZ::EntityId entityId) override;
|
||||
TemplateId GetFocusedPrefabTemplateId(AzFramework::EntityContextId entityContextId) const override;
|
||||
InstanceOptionalReference GetFocusedPrefabInstance(AzFramework::EntityContextId entityContextId) const override;
|
||||
|
||||
// PrefabFocusPublicInterface overrides ...
|
||||
// PrefabFocusPublicInterface and PrefabFocusPublicRequestBus overrides ...
|
||||
PrefabFocusOperationResult FocusOnOwningPrefab(AZ::EntityId entityId) override;
|
||||
PrefabFocusOperationResult FocusOnParentOfFocusedPrefab(AzFramework::EntityContextId entityContextId) override;
|
||||
PrefabFocusOperationResult FocusOnPathIndex(AzFramework::EntityContextId entityContextId, int index) override;
|
||||
|
||||
@@ -58,4 +58,18 @@ namespace AzToolsFramework::Prefab
|
||||
virtual const int GetPrefabFocusPathLength(AzFramework::EntityContextId entityContextId) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* The primary purpose of this bus is to facilitate writing automated tests for prefab focus mode.
|
||||
* If you would like to integrate prefabs focus mode into your system, please call PrefabFocusPublicInterface
|
||||
* for better performance.
|
||||
*/
|
||||
class PrefabFocusPublicRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
};
|
||||
|
||||
using PrefabFocusPublicRequestBus = AZ::EBus<PrefabFocusPublicInterface, PrefabFocusPublicRequests>;
|
||||
|
||||
} // namespace AzToolsFramework::Prefab
|
||||
|
||||
@@ -521,21 +521,18 @@ namespace AzToolsFramework
|
||||
nestedInstanceLink.has_value(),
|
||||
"A valid link was not found for one of the instances provided as input for the CreatePrefab operation.");
|
||||
|
||||
PrefabDomReference nestedInstanceLinkDom = nestedInstanceLink->get().GetLinkDom();
|
||||
AZ_Assert(
|
||||
nestedInstanceLinkDom.has_value(),
|
||||
"A valid DOM was not found for the link corresponding to one of the instances provided as input for the "
|
||||
"CreatePrefab operation.");
|
||||
|
||||
PrefabDomValueReference nestedInstanceLinkPatches =
|
||||
PrefabDomUtils::FindPrefabDomValue(nestedInstanceLinkDom->get(), PrefabDomUtils::PatchesName);
|
||||
AZ_Assert(
|
||||
nestedInstanceLinkPatches.has_value(),
|
||||
"A valid DOM for patches was not found for the link corresponding to one of the instances provided as input for the "
|
||||
"CreatePrefab operation.");
|
||||
|
||||
PrefabDom patchesCopyForUndoSupport;
|
||||
patchesCopyForUndoSupport.CopyFrom(nestedInstanceLinkPatches->get(), patchesCopyForUndoSupport.GetAllocator());
|
||||
PrefabDomReference nestedInstanceLinkDom = nestedInstanceLink->get().GetLinkDom();
|
||||
if (nestedInstanceLinkDom.has_value())
|
||||
{
|
||||
PrefabDomValueReference nestedInstanceLinkPatches =
|
||||
PrefabDomUtils::FindPrefabDomValue(nestedInstanceLinkDom->get(), PrefabDomUtils::PatchesName);
|
||||
if (nestedInstanceLinkPatches.has_value())
|
||||
{
|
||||
patchesCopyForUndoSupport.CopyFrom(nestedInstanceLinkPatches->get(), patchesCopyForUndoSupport.GetAllocator());
|
||||
}
|
||||
}
|
||||
|
||||
PrefabUndoHelpers::RemoveLink(
|
||||
sourceInstance->GetTemplateId(), targetTemplateId, sourceInstance->GetInstanceAlias(), sourceInstance->GetLinkId(),
|
||||
AZStd::move(patchesCopyForUndoSupport), undoBatch);
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace AzToolsFramework
|
||||
AzToolsFramework::Prefab::PrefabConversionUtils::PrefabCatchmentProcessor::Reflect(context);
|
||||
AzToolsFramework::Prefab::PrefabConversionUtils::EditorInfoRemover::Reflect(context);
|
||||
PrefabPublicRequestHandler::Reflect(context);
|
||||
PrefabFocusHandler::Reflect(context);
|
||||
PrefabLoader::Reflect(context);
|
||||
PrefabSystemScriptingHandler::Reflect(context);
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace AzToolsFramework
|
||||
/// @name Reverse URLs.
|
||||
/// Used to identify common actions and override them when necessary.
|
||||
//@{
|
||||
static const AZ::Crc32 s_backAction = AZ_CRC("com.o3de.action.common.back", 0xd772a2af);
|
||||
static const AZ::Crc32 s_deleteAction = AZ_CRC("com.o3de.action.common.delete", 0x5731f6cb);
|
||||
static const AZ::Crc32 s_duplicateAction = AZ_CRC("com.o3de.action.common.duplicate", 0x08ccf461);
|
||||
static const AZ::Crc32 s_nextComponentMode = AZ_CRC("com.o3de.action.common.nextComponentMode", 0xcc26094f);
|
||||
static const AZ::Crc32 s_previousComponentMode = AZ_CRC("com.o3de.action.common.previousComponentMode", 0x0d18ff39);
|
||||
static const AZ::Crc32 s_backAction = AZ_CRC("com.o3de.action.common.back", 0x80c3030f);
|
||||
static const AZ::Crc32 s_deleteAction = AZ_CRC("com.o3de.action.common.delete", 0x58e78eed);
|
||||
static const AZ::Crc32 s_duplicateAction = AZ_CRC("com.o3de.action.common.duplicate", 0xbc5a4a23);
|
||||
static const AZ::Crc32 s_nextComponentMode = AZ_CRC("com.o3de.action.common.nextComponentMode", 0xf9aca3a8);
|
||||
static const AZ::Crc32 s_previousComponentMode = AZ_CRC("com.o3de.action.common.previousComponentMode", 0x0580eaec);
|
||||
//@}
|
||||
|
||||
/// Specific Action properties to be sent to a type implementing
|
||||
|
||||
@@ -159,6 +159,10 @@ set(FILES
|
||||
Entity/SliceEditorEntityOwnershipServiceBus.h
|
||||
Entity/EntityUtilityComponent.h
|
||||
Entity/EntityUtilityComponent.cpp
|
||||
Entity/ReadOnly/ReadOnlyEntityInterface.h
|
||||
Entity/ReadOnly/ReadOnlyEntityBus.h
|
||||
Entity/ReadOnly/ReadOnlyEntitySystemComponent.cpp
|
||||
Entity/ReadOnly/ReadOnlyEntitySystemComponent.h
|
||||
Fingerprinting/TypeFingerprinter.h
|
||||
Fingerprinting/TypeFingerprinter.cpp
|
||||
FocusMode/FocusModeInterface.h
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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 <Tests/Entity/ReadOnly/ReadOnlyEntityFixture.h>
|
||||
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void ReadOnlyEntityFixture::SetUpEditorFixtureImpl()
|
||||
{
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
|
||||
m_readOnlyEntityPublicInterface = AZ::Interface<ReadOnlyEntityPublicInterface>::Get();
|
||||
ASSERT_TRUE(m_readOnlyEntityPublicInterface != nullptr);
|
||||
|
||||
GenerateTestHierarchy();
|
||||
}
|
||||
|
||||
void ReadOnlyEntityFixture::TearDownEditorFixtureImpl()
|
||||
{
|
||||
}
|
||||
|
||||
void ReadOnlyEntityFixture::GenerateTestHierarchy()
|
||||
{
|
||||
/*
|
||||
* Root
|
||||
* |_ Child
|
||||
* |_ GrandChild1
|
||||
* |_ GrandChild2
|
||||
*/
|
||||
|
||||
m_entityMap[RootEntityName] = CreateEditorEntity(RootEntityName, AZ::EntityId());
|
||||
m_entityMap[ChildEntityName] = CreateEditorEntity(ChildEntityName, m_entityMap[RootEntityName]);
|
||||
m_entityMap[GrandChild1EntityName] = CreateEditorEntity(GrandChild1EntityName, m_entityMap[ChildEntityName]);
|
||||
m_entityMap[GrandChild2EntityName] = CreateEditorEntity(GrandChild2EntityName, m_entityMap[ChildEntityName]);
|
||||
}
|
||||
|
||||
AZ::EntityId ReadOnlyEntityFixture::CreateEditorEntity(const char* name, AZ::EntityId parentId)
|
||||
{
|
||||
AZ::Entity* entity = nullptr;
|
||||
UnitTest::CreateDefaultEditorEntity(name, &entity);
|
||||
|
||||
// Parent
|
||||
AZ::TransformBus::Event(entity->GetId(), &AZ::TransformInterface::SetParent, parentId);
|
||||
|
||||
return entity->GetId();
|
||||
}
|
||||
|
||||
ReadOnlyHandlerAlwaysTrue::ReadOnlyHandlerAlwaysTrue()
|
||||
{
|
||||
auto editorEntityContextId = AzFramework::EntityContextId::CreateNull();
|
||||
EditorEntityContextRequestBus::BroadcastResult(editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
|
||||
|
||||
ReadOnlyEntityQueryRequestBus::Handler::BusConnect(editorEntityContextId);
|
||||
}
|
||||
|
||||
ReadOnlyHandlerAlwaysTrue::~ReadOnlyHandlerAlwaysTrue()
|
||||
{
|
||||
ReadOnlyEntityQueryRequestBus::Handler::BusDisconnect();
|
||||
|
||||
if (auto readOnlyEntityQueryInterface = AZ::Interface<ReadOnlyEntityQueryInterface>::Get())
|
||||
{
|
||||
readOnlyEntityQueryInterface->RefreshReadOnlyStateForAllEntities();
|
||||
}
|
||||
}
|
||||
|
||||
void ReadOnlyHandlerAlwaysTrue::IsReadOnly([[maybe_unused]] const AZ::EntityId& entityId, bool& isReadOnly)
|
||||
{
|
||||
isReadOnly = true;
|
||||
}
|
||||
|
||||
ReadOnlyHandlerAlwaysFalse::ReadOnlyHandlerAlwaysFalse()
|
||||
{
|
||||
auto editorEntityContextId = AzFramework::EntityContextId::CreateNull();
|
||||
EditorEntityContextRequestBus::BroadcastResult(editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
|
||||
|
||||
ReadOnlyEntityQueryRequestBus::Handler::BusConnect(editorEntityContextId);
|
||||
}
|
||||
|
||||
ReadOnlyHandlerAlwaysFalse::~ReadOnlyHandlerAlwaysFalse()
|
||||
{
|
||||
ReadOnlyEntityQueryRequestBus::Handler::BusDisconnect();
|
||||
|
||||
if (auto readOnlyEntityQueryInterface = AZ::Interface<ReadOnlyEntityQueryInterface>::Get())
|
||||
{
|
||||
readOnlyEntityQueryInterface->RefreshReadOnlyStateForAllEntities();
|
||||
}
|
||||
}
|
||||
|
||||
ReadOnlyHandlerEntityId::ReadOnlyHandlerEntityId(AZ::EntityId entityId)
|
||||
: m_entityId(entityId)
|
||||
{
|
||||
auto editorEntityContextId = AzFramework::EntityContextId::CreateNull();
|
||||
EditorEntityContextRequestBus::BroadcastResult(editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
|
||||
|
||||
ReadOnlyEntityQueryRequestBus::Handler::BusConnect(editorEntityContextId);
|
||||
}
|
||||
|
||||
ReadOnlyHandlerEntityId::~ReadOnlyHandlerEntityId()
|
||||
{
|
||||
ReadOnlyEntityQueryRequestBus::Handler::BusDisconnect();
|
||||
|
||||
if (auto readOnlyEntityQueryInterface = AZ::Interface<ReadOnlyEntityQueryInterface>::Get())
|
||||
{
|
||||
readOnlyEntityQueryInterface->RefreshReadOnlyStateForAllEntities();
|
||||
}
|
||||
}
|
||||
|
||||
void ReadOnlyHandlerEntityId::IsReadOnly(const AZ::EntityId& entityId, bool& isReadOnly)
|
||||
{
|
||||
if (entityId == m_entityId)
|
||||
{
|
||||
isReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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 <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityBus.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
class ReadOnlyEntityFixture
|
||||
: public UnitTest::ToolsApplicationFixture
|
||||
{
|
||||
protected:
|
||||
void SetUpEditorFixtureImpl() override;
|
||||
void TearDownEditorFixtureImpl() override;
|
||||
|
||||
void GenerateTestHierarchy();
|
||||
AZ::EntityId CreateEditorEntity(const char* name, AZ::EntityId parentId);
|
||||
|
||||
AZStd::unordered_map<AZStd::string, AZ::EntityId> m_entityMap;
|
||||
|
||||
ReadOnlyEntityPublicInterface* m_readOnlyEntityPublicInterface = nullptr;
|
||||
|
||||
public:
|
||||
inline static const char* RootEntityName = "Root";
|
||||
inline static const char* ChildEntityName = "Child";
|
||||
inline static const char* GrandChild1EntityName = "GrandChild1";
|
||||
inline static const char* GrandChild2EntityName = "GrandChild2";
|
||||
};
|
||||
|
||||
class ReadOnlyHandlerAlwaysTrue
|
||||
: public ReadOnlyEntityQueryRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
ReadOnlyHandlerAlwaysTrue();
|
||||
~ReadOnlyHandlerAlwaysTrue();
|
||||
|
||||
// ReadOnlyEntityQueryNotificationBus overrides ...
|
||||
void IsReadOnly(const AZ::EntityId& entityId, bool& isReadOnly) override;
|
||||
};
|
||||
|
||||
class ReadOnlyHandlerAlwaysFalse
|
||||
: public ReadOnlyEntityQueryRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
ReadOnlyHandlerAlwaysFalse();
|
||||
~ReadOnlyHandlerAlwaysFalse();
|
||||
|
||||
// ReadOnlyEntityQueryNotificationBus overrides ...
|
||||
void IsReadOnly([[maybe_unused]] const AZ::EntityId& entityId, [[maybe_unused]] bool& isReadOnly) override {}
|
||||
};
|
||||
|
||||
class ReadOnlyHandlerEntityId
|
||||
: public ReadOnlyEntityQueryRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
ReadOnlyHandlerEntityId(AZ::EntityId entityId);
|
||||
~ReadOnlyHandlerEntityId();
|
||||
|
||||
// ReadOnlyEntityQueryNotificationBus overrides ...
|
||||
void IsReadOnly(const AZ::EntityId& entityId, bool& isReadOnly) override;
|
||||
|
||||
private:
|
||||
AZ::EntityId m_entityId;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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 <Tests/Entity/ReadOnly/ReadOnlyEntityFixture.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
TEST_F(ReadOnlyEntityFixture, NoHandlerEntityIsNotReadOnlyByDefault)
|
||||
{
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
|
||||
}
|
||||
|
||||
TEST_F(ReadOnlyEntityFixture, SingleHandlerEntityIsReadOnly)
|
||||
{
|
||||
// Create a handler that sets all entities to read-only.
|
||||
ReadOnlyHandlerAlwaysTrue alwaysTrueHandler;
|
||||
|
||||
// All entities should be marked read-only now.
|
||||
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[RootEntityName]));
|
||||
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
|
||||
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild1EntityName]));
|
||||
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild2EntityName]));
|
||||
}
|
||||
|
||||
TEST_F(ReadOnlyEntityFixture, SingleHandlerEntityIsNotReadOnly)
|
||||
{
|
||||
// Create a handler that sets all entities to read-only.
|
||||
ReadOnlyHandlerAlwaysFalse alwaysFalseHandler;
|
||||
|
||||
// All entities should not be marked read-only now.
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[RootEntityName]));
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild1EntityName]));
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild2EntityName]));
|
||||
}
|
||||
|
||||
TEST_F(ReadOnlyEntityFixture, SingleHandlerWithLogic)
|
||||
{
|
||||
// Create a handler that sets just the child entity to read-only.
|
||||
ReadOnlyHandlerEntityId entityIdHandler(m_entityMap[ChildEntityName]);
|
||||
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[RootEntityName]));
|
||||
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild1EntityName]));
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild2EntityName]));
|
||||
}
|
||||
|
||||
TEST_F(ReadOnlyEntityFixture, TwoHandlersCanOverlap)
|
||||
{
|
||||
// Create two handlers that set different entities to read-only.
|
||||
ReadOnlyHandlerEntityId entityIdHandler1(m_entityMap[ChildEntityName]);
|
||||
ReadOnlyHandlerEntityId entityIdHandler2(m_entityMap[GrandChild2EntityName]);
|
||||
|
||||
// Both entities should be marked as read-only, while others aren't.
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[RootEntityName]));
|
||||
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild1EntityName]));
|
||||
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild2EntityName]));
|
||||
}
|
||||
|
||||
TEST_F(ReadOnlyEntityFixture, EnsureCacheIsRefreshedCorrectly)
|
||||
{
|
||||
// Verify the child entity is not marked as read-only
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
|
||||
|
||||
// Create a handler that sets the child entity to read-only.
|
||||
ReadOnlyHandlerEntityId entityIdHandler(m_entityMap[ChildEntityName]);
|
||||
|
||||
// Communicate to the ReadOnlyEntitySystemComponent that the read-only state for the child entity may have changed.
|
||||
// Note that this operation would usually be executed by the handler, hence the Query interface call.
|
||||
if (auto readOnlyEntityQueryInterface = AZ::Interface<ReadOnlyEntityQueryInterface>::Get())
|
||||
{
|
||||
readOnlyEntityQueryInterface->RefreshReadOnlyState({ m_entityMap[ChildEntityName] });
|
||||
}
|
||||
|
||||
// Verify the child entity is marked as read-only
|
||||
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
|
||||
}
|
||||
|
||||
TEST_F(ReadOnlyEntityFixture, EnsureCacheIsClearedCorrectly)
|
||||
{
|
||||
{
|
||||
// Create a handler that sets the child entity to read-only.
|
||||
ReadOnlyHandlerEntityId entityIdHandler(m_entityMap[ChildEntityName]);
|
||||
|
||||
// Verify the child entity is marked as read-only
|
||||
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
|
||||
}
|
||||
// When the handler goes out of scope, it calls RefreshReadOnlyStateForAllEntities and refreshes the cache.
|
||||
|
||||
// Verify the child entity is no longer marked as read-only
|
||||
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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 <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
|
||||
|
||||
#include <Prefab/PrefabTestComponent.h>
|
||||
#include <Prefab/PrefabTestDomUtils.h>
|
||||
#include <Prefab/PrefabTestFixture.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
using PrefabDeleteTest = PrefabTestFixture;
|
||||
|
||||
TEST_F(PrefabDeleteTest, DeleteEntitiesInInstance_DeleteSingleEntitySucceeds)
|
||||
{
|
||||
PrefabEntityResult createEntityResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
|
||||
|
||||
// Verify that a valid entity is created.
|
||||
AZ::EntityId testEntityId = createEntityResult.GetValue();
|
||||
ASSERT_TRUE(testEntityId.IsValid());
|
||||
AZ::Entity* testEntity = AzToolsFramework::GetEntityById(testEntityId);
|
||||
ASSERT_TRUE(testEntity != nullptr);
|
||||
|
||||
m_prefabPublicInterface->DeleteEntitiesInInstance(AzToolsFramework::EntityIdList{ testEntityId });
|
||||
|
||||
// Verify that entity can't be found after deletion.
|
||||
testEntity = AzToolsFramework::GetEntityById(testEntityId);
|
||||
EXPECT_TRUE(testEntity == nullptr);
|
||||
}
|
||||
|
||||
TEST_F(PrefabDeleteTest, DeleteEntitiesInInstance_DeleteSinglePrefabSucceeds)
|
||||
{
|
||||
PrefabEntityResult createEntityResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
|
||||
|
||||
// Verify that a valid entity is created.
|
||||
AZ::EntityId createdEntityId = createEntityResult.GetValue();
|
||||
ASSERT_TRUE(createdEntityId.IsValid());
|
||||
AZ::Entity* createdEntity = AzToolsFramework::GetEntityById(createdEntityId);
|
||||
ASSERT_TRUE(createdEntity != nullptr);
|
||||
|
||||
// Rather than hardcode a path, use a path from settings registry since that will work on all platforms.
|
||||
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
|
||||
AZ::IO::FixedMaxPath path;
|
||||
registry->Get(path.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
|
||||
CreatePrefabResult createPrefabResult =
|
||||
m_prefabPublicInterface->CreatePrefabInMemory(AzToolsFramework::EntityIdList{ createdEntityId }, path);
|
||||
|
||||
AZ::EntityId createdPrefabContainerId = createPrefabResult.GetValue();
|
||||
ASSERT_TRUE(createdPrefabContainerId.IsValid());
|
||||
AZ::Entity* prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
|
||||
ASSERT_TRUE(prefabContainerEntity != nullptr);
|
||||
|
||||
// Verify that the prefab container entity and the entity within are deleted.
|
||||
m_prefabPublicInterface->DeleteEntitiesInInstance(AzToolsFramework::EntityIdList{ createdPrefabContainerId });
|
||||
prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
|
||||
EXPECT_TRUE(prefabContainerEntity == nullptr);
|
||||
createdEntity = AzToolsFramework::GetEntityById(createdEntityId);
|
||||
EXPECT_TRUE(createdEntity == nullptr);
|
||||
}
|
||||
|
||||
TEST_F(PrefabDeleteTest, DeleteEntitiesAndAllDescendantsInInstance_DeletingEntityDeletesChildEntityToo)
|
||||
{
|
||||
PrefabEntityResult parentEntityCreationResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
|
||||
|
||||
// Verify that valid parent entity is created.
|
||||
AZ::EntityId parentEntityId = parentEntityCreationResult.GetValue();
|
||||
ASSERT_TRUE(parentEntityId.IsValid());
|
||||
AZ::Entity* parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
|
||||
ASSERT_TRUE(parentEntity != nullptr);
|
||||
|
||||
// Verify that valid child entity is created.
|
||||
PrefabEntityResult childEntityCreationResult = m_prefabPublicInterface->CreateEntity(parentEntityId, AZ::Vector3());
|
||||
AZ::EntityId childEntityId = childEntityCreationResult.GetValue();
|
||||
ASSERT_TRUE(childEntityId.IsValid());
|
||||
AZ::Entity* childEntity = AzToolsFramework::GetEntityById(childEntityId);
|
||||
ASSERT_TRUE(childEntity != nullptr);
|
||||
|
||||
// PrefabTestFixture won't add required editor components by default. Hence we add them here.
|
||||
AddRequiredEditorComponents(childEntity);
|
||||
AddRequiredEditorComponents(parentEntity);
|
||||
|
||||
// Parent the child entity under the parent entity.
|
||||
AZ::TransformBus::Event(childEntityId, &AZ::TransformBus::Events::SetParent, parentEntityId);
|
||||
|
||||
// Delete parent entity and its children.
|
||||
m_prefabPublicInterface->DeleteEntitiesAndAllDescendantsInInstance(AzToolsFramework::EntityIdList{ parentEntityId });
|
||||
|
||||
// Verify that both the parent and child entities are deleted.
|
||||
parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
|
||||
EXPECT_TRUE(parentEntity == nullptr);
|
||||
childEntity = AzToolsFramework::GetEntityById(childEntityId);
|
||||
EXPECT_TRUE(childEntity == nullptr);
|
||||
}
|
||||
|
||||
TEST_F(PrefabDeleteTest, DeleteEntitiesAndAllDescendantsInInstance_DeletingEntityDeletesChildPrefabToo)
|
||||
{
|
||||
PrefabEntityResult entityToBePutUnderPrefabResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
|
||||
|
||||
// Verify that a valid entity is created that will be put in a prefab later.
|
||||
AZ::EntityId entityToBePutUnderPrefabId = entityToBePutUnderPrefabResult.GetValue();
|
||||
ASSERT_TRUE(entityToBePutUnderPrefabId.IsValid());
|
||||
AZ::Entity* entityToBePutUnderPrefab = AzToolsFramework::GetEntityById(entityToBePutUnderPrefabId);
|
||||
ASSERT_TRUE(entityToBePutUnderPrefab != nullptr);
|
||||
|
||||
// Verify that a valid parent entity is created.
|
||||
PrefabEntityResult parentEntityCreationResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
|
||||
AZ::EntityId parentEntityId = parentEntityCreationResult.GetValue();
|
||||
ASSERT_TRUE(parentEntityId.IsValid());
|
||||
AZ::Entity* parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
|
||||
ASSERT_TRUE(parentEntity != nullptr);
|
||||
|
||||
// Rather than hardcode a path, use a path from settings registry since that will work on all platforms.
|
||||
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
|
||||
AZ::IO::FixedMaxPath path;
|
||||
registry->Get(path.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
|
||||
CreatePrefabResult createPrefabResult =
|
||||
m_prefabPublicInterface->CreatePrefabInMemory(AzToolsFramework::EntityIdList{ entityToBePutUnderPrefabId }, path);
|
||||
|
||||
// Verify that a valid prefab container entity is created.
|
||||
AZ::EntityId createdPrefabContainerId = createPrefabResult.GetValue();
|
||||
ASSERT_TRUE(createdPrefabContainerId.IsValid());
|
||||
AZ::Entity* prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
|
||||
ASSERT_TRUE(prefabContainerEntity != nullptr);
|
||||
|
||||
// PrefabTestFixture won't add required editor components by default. Hence we add them here.
|
||||
AddRequiredEditorComponents(parentEntity);
|
||||
AddRequiredEditorComponents(prefabContainerEntity);
|
||||
|
||||
// Parent the prefab under the parent entity.
|
||||
AZ::TransformBus::Event(createdPrefabContainerId, &AZ::TransformBus::Events::SetParent, parentEntityId);
|
||||
|
||||
// Delete the parent entity.
|
||||
m_prefabPublicInterface->DeleteEntitiesAndAllDescendantsInInstance(AzToolsFramework::EntityIdList{ parentEntityId });
|
||||
|
||||
// Validate that the parent and the prefab under it and the entity inside the prefab are all deleted.
|
||||
parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
|
||||
ASSERT_TRUE(parentEntity == nullptr);
|
||||
entityToBePutUnderPrefab = AzToolsFramework::GetEntityById(entityToBePutUnderPrefabId);
|
||||
ASSERT_TRUE(entityToBePutUnderPrefab == nullptr);
|
||||
prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
|
||||
EXPECT_TRUE(prefabContainerEntity == nullptr);
|
||||
}
|
||||
} // namespace UnitTest
|
||||
@@ -57,6 +57,11 @@ namespace UnitTest
|
||||
return AZStd::make_unique<PrefabTestToolsApplication>("PrefabTestApplication");
|
||||
}
|
||||
|
||||
void PrefabTestFixture::PropagateAllTemplateChanges()
|
||||
{
|
||||
m_prefabSystemComponent->OnSystemTick();
|
||||
}
|
||||
|
||||
AZ::Entity* PrefabTestFixture::CreateEntity(const char* entityName, const bool shouldActivate)
|
||||
{
|
||||
// Circumvent the EntityContext system and generate a new entity with a transformcomponent
|
||||
@@ -125,4 +130,13 @@ namespace UnitTest
|
||||
EXPECT_EQ(entityInInstance->GetState(), AZ::Entity::State::Active);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefabTestFixture::AddRequiredEditorComponents(AZ::Entity* entity)
|
||||
{
|
||||
ASSERT_TRUE(entity != nullptr);
|
||||
entity->Deactivate();
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorEntityContextRequests::AddRequiredComponents, *entity);
|
||||
entity->Activate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ namespace UnitTest
|
||||
|
||||
AZStd::unique_ptr<ToolsTestApplication> CreateTestApplication() override;
|
||||
|
||||
void PropagateAllTemplateChanges();
|
||||
|
||||
AZ::Entity* CreateEntity(const char* entityName, const bool shouldActivate = true);
|
||||
|
||||
void CompareInstances(const Instance& instanceA, const Instance& instanceB, bool shouldCompareLinkIds = true,
|
||||
@@ -62,6 +64,8 @@ namespace UnitTest
|
||||
//! Validates that all entities within a prefab instance are in 'Active' state.
|
||||
void ValidateInstanceEntitiesActive(Instance& instance);
|
||||
|
||||
void AddRequiredEditorComponents(AZ::Entity* entity);
|
||||
|
||||
PrefabSystemComponent* m_prefabSystemComponent = nullptr;
|
||||
PrefabLoaderInterface* m_prefabLoaderInterface = nullptr;
|
||||
PrefabPublicInterface* m_prefabPublicInterface = nullptr;
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace UnitTest
|
||||
void ProcessDeferredUpdates()
|
||||
{
|
||||
// Force a prefab propagation for updates that are deferred to the next tick.
|
||||
m_prefabSystemComponent->OnSystemTick();
|
||||
PropagateAllTemplateChanges();
|
||||
|
||||
// Ensure the model process its entity update queue
|
||||
m_model->ProcessEntityUpdates();
|
||||
|
||||
@@ -28,6 +28,9 @@ set(FILES
|
||||
Entity/EditorEntitySearchComponentTests.cpp
|
||||
Entity/EditorEntitySelectionTests.cpp
|
||||
Entity/EntityUtilityComponentTests.cpp
|
||||
Entity/ReadOnly/ReadOnlyEntityFixture.cpp
|
||||
Entity/ReadOnly/ReadOnlyEntityFixture.h
|
||||
Entity/ReadOnly/ReadOnlyEntityTests.cpp
|
||||
EntityIdQLabelTests.cpp
|
||||
EntityInspectorTests.cpp
|
||||
EntityOwnershipService/EntityOwnershipServiceTestFixture.cpp
|
||||
@@ -66,6 +69,7 @@ set(FILES
|
||||
Prefab/PrefabFocus/PrefabFocusTests.cpp
|
||||
Prefab/MockPrefabFileIOActionValidator.cpp
|
||||
Prefab/MockPrefabFileIOActionValidator.h
|
||||
Prefab/PrefabDeleteTests.cpp
|
||||
Prefab/PrefabDuplicateTests.cpp
|
||||
Prefab/PrefabEntityAliasTests.cpp
|
||||
Prefab/PrefabInstanceToTemplatePropagatorTests.cpp
|
||||
|
||||
@@ -71,6 +71,14 @@ public:
|
||||
// The value of the argument as integer number.
|
||||
virtual const int GetIValue() const = 0;
|
||||
// </interfuscator:shuffle>
|
||||
|
||||
// Description:
|
||||
// Retrieve the value of the argument.
|
||||
// Arguments:
|
||||
// cmdLineValue. The cmdline value will be filled out if a valid boolean is found.
|
||||
// Return Value:
|
||||
// Returns true if the cmdline arg is actually a boolean string matching "true" or "false"; otherwise return false.
|
||||
virtual const bool GetBoolValue(bool& cmdLineValue) const = 0;
|
||||
};
|
||||
|
||||
// Command line interface
|
||||
|
||||
@@ -100,85 +100,8 @@ set(FILES
|
||||
platform_impl.cpp
|
||||
Win32specific.h
|
||||
Win64specific.h
|
||||
LyShine/IDraw2d.h
|
||||
LyShine/ILyShine.h
|
||||
LyShine/ISprite.h
|
||||
LyShine/IRenderGraph.h
|
||||
LyShine/UiAssetTypes.h
|
||||
LyShine/UiComponentTypes.h
|
||||
LyShine/UiBase.h
|
||||
LyShine/UiEntityContext.h
|
||||
LyShine/UiLayoutCellBase.h
|
||||
LyShine/UiSerializeHelpers.h
|
||||
LyShine/Animation/IUiAnimation.h
|
||||
LyShine/Bus/UiAnimateEntityBus.h
|
||||
LyShine/Bus/UiAnimationBus.h
|
||||
LyShine/Bus/UiButtonBus.h
|
||||
LyShine/Bus/UiCanvasBus.h
|
||||
LyShine/Bus/UiCanvasManagerBus.h
|
||||
LyShine/Bus/UiCanvasUpdateNotificationBus.h
|
||||
LyShine/Bus/UiCheckboxBus.h
|
||||
LyShine/Bus/UiCursorBus.h
|
||||
LyShine/Bus/UiDraggableBus.h
|
||||
LyShine/Bus/UiDropdownBus.h
|
||||
LyShine/Bus/UiDropdownOptionBus.h
|
||||
LyShine/Bus/UiDropTargetBus.h
|
||||
LyShine/Bus/UiDynamicLayoutBus.h
|
||||
LyShine/Bus/UiDynamicScrollBoxBus.h
|
||||
LyShine/Bus/UiEditorBus.h
|
||||
LyShine/Bus/UiEditorCanvasBus.h
|
||||
LyShine/Bus/UiEditorChangeNotificationBus.h
|
||||
LyShine/Bus/UiElementBus.h
|
||||
LyShine/Bus/UiEntityContextBus.h
|
||||
LyShine/Bus/UiFaderBus.h
|
||||
LyShine/Bus/UiFlipbookAnimationBus.h
|
||||
LyShine/Bus/UiGameEntityContextBus.h
|
||||
LyShine/Bus/UiImageBus.h
|
||||
LyShine/Bus/UiImageSequenceBus.h
|
||||
LyShine/Bus/UiIndexableImageBus.h
|
||||
LyShine/Bus/UiInitializationBus.h
|
||||
LyShine/Bus/UiInteractableActionsBus.h
|
||||
LyShine/Bus/UiInteractableBus.h
|
||||
LyShine/Bus/UiInteractableStatesBus.h
|
||||
LyShine/Bus/UiInteractionMaskBus.h
|
||||
LyShine/Bus/UiLayoutBus.h
|
||||
LyShine/Bus/UiLayoutCellBus.h
|
||||
LyShine/Bus/UiLayoutCellDefaultBus.h
|
||||
LyShine/Bus/UiLayoutColumnBus.h
|
||||
LyShine/Bus/UiLayoutControllerBus.h
|
||||
LyShine/Bus/UiLayoutFitterBus.h
|
||||
LyShine/Bus/UiLayoutGridBus.h
|
||||
LyShine/Bus/UiLayoutManagerBus.h
|
||||
LyShine/Bus/UiLayoutRowBus.h
|
||||
LyShine/Bus/UiMarkupButtonBus.h
|
||||
LyShine/Bus/UiMaskBus.h
|
||||
LyShine/Bus/UiNavigationBus.h
|
||||
LyShine/Bus/UiParticleEmitterBus.h
|
||||
LyShine/Bus/UiRadioButtonBus.h
|
||||
LyShine/Bus/UiRadioButtonCommunicationBus.h
|
||||
LyShine/Bus/UiRadioButtonGroupBus.h
|
||||
LyShine/Bus/UiRadioButtonGroupCommunicationBus.h
|
||||
LyShine/Bus/UiRenderBus.h
|
||||
LyShine/Bus/UiRenderControlBus.h
|
||||
LyShine/Bus/UiScrollableBus.h
|
||||
LyShine/Bus/UiScrollBarBus.h
|
||||
LyShine/Bus/UiScrollBoxBus.h
|
||||
LyShine/Bus/UiScrollerBus.h
|
||||
LyShine/Bus/UiSliderBus.h
|
||||
LyShine/Bus/UiSpawnerBus.h
|
||||
LyShine/Bus/UiSystemBus.h
|
||||
LyShine/Bus/UiTextBus.h
|
||||
LyShine/Bus/UiTextInputBus.h
|
||||
LyShine/Bus/UiTooltipBus.h
|
||||
LyShine/Bus/UiTooltipDataPopulatorBus.h
|
||||
LyShine/Bus/UiTooltipDisplayBus.h
|
||||
LyShine/Bus/UiTransform2dBus.h
|
||||
LyShine/Bus/UiTransformBus.h
|
||||
LyShine/Bus/UiVisualBus.h
|
||||
LyShine/Bus/Sprite/UiSpriteBus.h
|
||||
LyShine/Bus/World/UiCanvasOnMeshBus.h
|
||||
LyShine/Bus/World/UiCanvasRefBus.h
|
||||
LyShine/Bus/Tools/UiSystemToolsBus.h
|
||||
Maestro/Bus/EditorSequenceAgentComponentBus.h
|
||||
Maestro/Bus/EditorSequenceBus.h
|
||||
Maestro/Bus/EditorSequenceComponentBus.h
|
||||
|
||||
@@ -36,9 +36,10 @@ public:
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
inline static void Connect()
|
||||
inline static void Connect(bool suppressSystemOutput)
|
||||
{
|
||||
GetInstance().m_ignoredAsserts = new IgnoredAssertMap();
|
||||
GetInstance().m_suppressSystemOutput = suppressSystemOutput;
|
||||
GetInstance().BusConnect();
|
||||
}
|
||||
|
||||
@@ -126,7 +127,7 @@ public:
|
||||
CryLogAlways("%s", message);
|
||||
}
|
||||
|
||||
return true; // suppress default AzCore behavior.
|
||||
return m_suppressSystemOutput;
|
||||
#else
|
||||
AZ_UNUSED(fileName);
|
||||
AZ_UNUSED(line);
|
||||
@@ -146,7 +147,7 @@ public:
|
||||
return false; // allow AZCore to do its default behavior.
|
||||
}
|
||||
gEnv->pLog->LogError("(%s) - %s", window, message);
|
||||
return true; // suppress default AzCore behavior.
|
||||
return m_suppressSystemOutput;
|
||||
}
|
||||
|
||||
bool OnPreWarning(const char* window, const char* fileName, int line, const char* func, const char* message) override
|
||||
@@ -161,7 +162,7 @@ public:
|
||||
}
|
||||
|
||||
CryWarning(VALIDATOR_MODULE_UNKNOWN, VALIDATOR_WARNING, "(%s) - %s", window, message);
|
||||
return true; // suppress default AzCore behavior.
|
||||
return m_suppressSystemOutput;
|
||||
}
|
||||
|
||||
bool OnOutput(const char* window, const char* message) override
|
||||
@@ -179,12 +180,13 @@ public:
|
||||
{
|
||||
CryLog("(%s) - %s", window, message);
|
||||
}
|
||||
|
||||
return true; // suppress default AzCore behavior.
|
||||
|
||||
return m_suppressSystemOutput;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
using IgnoredAssertMap = AZStd::unordered_map<AZ::Crc32, bool, AZStd::hash<AZ::Crc32>, AZStd::equal_to<AZ::Crc32>, AZ::OSStdAllocator>;
|
||||
IgnoredAssertMap* m_ignoredAsserts;
|
||||
bool m_suppressSystemOutput = true;
|
||||
};
|
||||
|
||||
@@ -42,5 +42,22 @@ const int CCmdLineArg::GetIValue() const
|
||||
{
|
||||
return atoi(m_value.c_str());
|
||||
}
|
||||
const bool CCmdLineArg::GetBoolValue(bool& cmdLineValue) const
|
||||
{
|
||||
AZStd::string lowercaseValue(m_value);
|
||||
AZStd::to_lower(lowercaseValue.begin(), lowercaseValue.end());
|
||||
if (lowercaseValue == "true")
|
||||
{
|
||||
cmdLineValue = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lowercaseValue == "false")
|
||||
{
|
||||
cmdLineValue = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
const ECmdLineArgType GetType() const;
|
||||
const float GetFValue() const;
|
||||
const int GetIValue() const;
|
||||
const bool GetBoolValue(bool& cmdLineValue) const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <AzFramework/Spawnable/RootSpawnableInterface.h>
|
||||
|
||||
#include "MainThreadRenderRequestBus.h"
|
||||
#include <LyShine/ILyShine.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
@@ -882,12 +881,6 @@ void CLevelSystem::UnloadLevel()
|
||||
// Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event).
|
||||
EBUS_EVENT(AZ::ScriptSystemRequestBus, GarbageCollect);
|
||||
|
||||
// Perform level unload procedures for the LyShine UI system
|
||||
if (gEnv && gEnv->pLyShine)
|
||||
{
|
||||
gEnv->pLyShine->OnLevelUnload();
|
||||
}
|
||||
|
||||
m_bLevelLoaded = false;
|
||||
|
||||
[[maybe_unused]] const AZ::TimeMs unloadTimeMs = AZ::GetRealElapsedTimeMs() - beginTimeMs;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <AzFramework/Input/Buses/Requests/InputChannelRequestBus.h>
|
||||
|
||||
#include "MainThreadRenderRequestBus.h"
|
||||
#include <LyShine/ILyShine.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/Settings/SettingsRegistryVisitorUtils.h>
|
||||
@@ -558,12 +557,6 @@ namespace LegacyLevelSystem
|
||||
// Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event).
|
||||
EBUS_EVENT(AZ::ScriptSystemRequestBus, GarbageCollect);
|
||||
|
||||
// Perform level unload procedures for the LyShine UI system
|
||||
if (gEnv && gEnv->pLyShine)
|
||||
{
|
||||
gEnv->pLyShine->OnLevelUnload();
|
||||
}
|
||||
|
||||
m_bLevelLoaded = false;
|
||||
|
||||
[[maybe_unused]] const AZ::TimeMs unloadTimeMs = AZ::GetRealElapsedTimeMs() - beginTimeMs;
|
||||
|
||||
@@ -116,7 +116,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
#include <ILog.h>
|
||||
#include <IAudioSystem.h>
|
||||
#include <IProcess.h>
|
||||
#include <LyShine/ILyShine.h>
|
||||
|
||||
#include <LoadScreenBus.h>
|
||||
|
||||
@@ -373,14 +372,7 @@ void CSystem::ShutDown()
|
||||
m_pSystemEventDispatcher->OnSystemEvent(ESYSTEM_EVENT_FULL_SHUTDOWN, 0, 0);
|
||||
}
|
||||
|
||||
if (gEnv && gEnv->pLyShine)
|
||||
{
|
||||
gEnv->pLyShine->Release();
|
||||
gEnv->pLyShine = nullptr;
|
||||
}
|
||||
|
||||
SAFE_RELEASE(m_env.pMovieSystem);
|
||||
SAFE_RELEASE(m_env.pLyShine);
|
||||
SAFE_RELEASE(m_env.pCryFont);
|
||||
if (m_env.pConsole)
|
||||
{
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
#include <AzFramework/Archive/ArchiveFileIO.h>
|
||||
|
||||
#include <LoadScreenBus.h>
|
||||
#include <LyShine/Bus/UiSystemBus.h>
|
||||
#include <AzFramework/Logging/MissingAssetLogger.h>
|
||||
#include <AzFramework/Platform/PlatformDefaults.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
@@ -77,7 +76,6 @@
|
||||
#include <IAudioSystem.h>
|
||||
#include <ICmdLine.h>
|
||||
#include <IProcess.h>
|
||||
#include <LyShine/ILyShine.h>
|
||||
|
||||
#include <AzFramework/Archive/Archive.h>
|
||||
#include "XConsole.h"
|
||||
@@ -737,7 +735,17 @@ bool CSystem::Init(const SSystemInitParams& startupParams)
|
||||
|
||||
m_pCmdLine = new CCmdLine(startupParams.szSystemCmdLine);
|
||||
|
||||
AZCoreLogSink::Connect();
|
||||
// Init AZCoreLogSink. Don't suppress system output if we're running as an editor-server
|
||||
bool suppressSystemOutput = true;
|
||||
if (const ICmdLineArg* isEditorServerArg = m_pCmdLine->FindArg(eCLAT_Pre, "editorsv_isDedicated"))
|
||||
{
|
||||
bool editorsv_isDedicated = false;
|
||||
if (isEditorServerArg->GetBoolValue(editorsv_isDedicated) && editorsv_isDedicated)
|
||||
{
|
||||
suppressSystemOutput = false;
|
||||
}
|
||||
}
|
||||
AZCoreLogSink::Connect(suppressSystemOutput);
|
||||
|
||||
// Registers all AZ Console Variables functors specified within CrySystem
|
||||
if (auto azConsole = AZ::Interface<AZ::IConsole>::Get(); azConsole)
|
||||
@@ -1095,11 +1103,6 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
InlineInitializationProcessing("CSystem::Init Level System");
|
||||
|
||||
if (m_env.pLyShine)
|
||||
{
|
||||
m_env.pLyShine->PostInit();
|
||||
}
|
||||
|
||||
InlineInitializationProcessing("CSystem::Init InitLmbrAWS");
|
||||
|
||||
// Az to Cry console binding
|
||||
|
||||
@@ -92,8 +92,6 @@ set(FILES
|
||||
native/utilities/BuilderManager.inl
|
||||
native/utilities/ByteArrayStream.cpp
|
||||
native/utilities/ByteArrayStream.h
|
||||
native/utilities/CommunicatorTracePrinter.cpp
|
||||
native/utilities/CommunicatorTracePrinter.h
|
||||
native/utilities/IniConfiguration.cpp
|
||||
native/utilities/IniConfiguration.h
|
||||
native/utilities/JobDiagnosticTracker.cpp
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzFramework/Application/Application.h>
|
||||
|
||||
#include <AzFramework/Process/ProcessCommunicator.h>
|
||||
#include <AzFramework/Process/ProcessWatcher.h>
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
|
||||
@@ -31,7 +30,6 @@
|
||||
|
||||
#include "native/utilities/assetUtils.h"
|
||||
#include "native/utilities/AssetBuilderInfo.h"
|
||||
#include "native/utilities/CommunicatorTracePrinter.h"
|
||||
|
||||
#include <AssetProcessor_Traits_Platform.h>
|
||||
|
||||
|
||||
@@ -1482,7 +1482,7 @@ bool ApplicationManagerBase::WaitForBuilderExit(AzFramework::ProcessWatcher* pro
|
||||
AZ::u32 exitCode = 0;
|
||||
bool finishedOK = false;
|
||||
QElapsedTimer ticker;
|
||||
CommunicatorTracePrinter tracer(processWatcher->GetCommunicator(), "AssetBuilder");
|
||||
ProcessCommunicatorTracePrinter tracer(processWatcher->GetCommunicator(), "AssetBuilder");
|
||||
|
||||
ticker.start();
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user