Merge pull request #4770 from aws-lumberyard-dev/Atom/scottmur/Atom-16561

AtomComponentProperties class for atom_constants to store property paths and other constant values
monroegm-disable-blank-issue-2
jromnoa 4 years ago committed by GitHub
commit 267d690171
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,3 +17,392 @@ LIGHT_TYPES = {
'simple_point': 6, 'simple_point': 6,
'simple_spot': 7, 'simple_spot': 7,
} }
class AtomComponentProperties:
"""
Holds Atom component related constants
"""
@staticmethod
def actor(property: str = 'name') -> str:
"""
Actor component properties.
: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': 'Actor',
}
return properties[property]
@staticmethod
def bloom(property: str = 'name') -> str:
"""
Bloom component properties. Requires PostFX Layer component.
- 'requires' a list of component names as strings required by this component.
Use editor_entity_utils EditorEntity.add_components(list) to add this list of requirements.\n
: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': 'Bloom',
'requires': [AtomComponentProperties.postfx_layer()],
}
return properties[property]
@staticmethod
def camera(property: str = 'name') -> str:
"""
Camera component properties.
: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': 'Camera',
}
return properties[property]
@staticmethod
def decal(property: str = 'name') -> str:
"""
Decal component properties.
- 'Material' the material Asset.id of the decal.
: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': 'Decal',
'Material': 'Controller|Configuration|Material',
}
return properties[property]
@staticmethod
def deferred_fog(property: str = 'name') -> str:
"""
Deferred Fog component properties. Requires PostFX Layer component.
- 'requires' a list of component names as strings required by this component.
Use editor_entity_utils EditorEntity.add_components(list) to add this list of requirements.\n
: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': 'Deferred Fog',
'requires': [AtomComponentProperties.postfx_layer()],
}
return properties[property]
@staticmethod
def depth_of_field(property: str = 'name') -> str:
"""
Depth of Field component properties. Requires PostFX Layer component.
- 'requires' a list of component names as strings required by this component.
Use editor_entity_utils EditorEntity.add_components(list) to add this list of requirements.\n
- 'Camera Entity' an EditorEntity.id reference to the Camera component required for this effect.
Must be a different entity than the one which hosts Depth of Field component.\n
: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': 'DepthOfField',
'requires': [AtomComponentProperties.postfx_layer()],
'Camera Entity': 'Controller|Configuration|Camera Entity',
}
return properties[property]
@staticmethod
def diffuse_probe(property: str = 'name') -> str:
"""
Diffuse Probe Grid component properties. Requires one of 'shapes'.
- 'shapes' a list of supported shapes as component names.
: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': 'Diffuse Probe Grid',
'shapes': ['Axis Aligned Box Shape', 'Box Shape']
}
return properties[property]
@staticmethod
def directional_light(property: str = 'name') -> str:
"""
Directional Light component properties.
- 'Camera' an EditorEntity.id reference to the Camera component that controls cascaded shadow view frustum.
Must be a different entity than the one which hosts Directional Light component.\n
: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': 'Directional Light',
'Camera': 'Controller|Configuration|Shadow|Camera',
}
return properties[property]
@staticmethod
def display_mapper(property: str = 'name') -> str:
"""
Display Mapper component properties.
: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',
}
return properties[property]
@staticmethod
def entity_reference(property: str = 'name') -> str:
"""
Entity Reference component properties.
: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': 'Entity Reference',
}
return properties[property]
@staticmethod
def exposure_control(property: str = 'name') -> str:
"""
Exposure Control component properties. Requires PostFX Layer component.
- 'requires' a list of component names as strings required by this component.
Use editor_entity_utils EditorEntity.add_components(list) to add this list of requirements.\n
: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': 'Exposure Control',
'requires': [AtomComponentProperties.postfx_layer()],
}
return properties[property]
@staticmethod
def global_skylight(property: str = 'name') -> str:
"""
Global Skylight (IBL) component properties.
- 'Diffuse Image' Asset.id for the cubemap image for determining diffuse lighting.
- 'Specular Image' Asset.id for the cubemap image for determining specular lighting.
: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': 'Global Skylight (IBL)',
'Diffuse Image': 'Controller|Configuration|Diffuse Image',
'Specular Image': 'Controller|Configuration|Specular Image',
}
return properties[property]
@staticmethod
def grid(property: str = 'name') -> str:
"""
Grid component properties.
: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': 'Grid',
}
return properties[property]
@staticmethod
def hdr_color_grading(property: str = 'name') -> str:
"""
HDR Color Grading component properties. Requires PostFX Layer component.
- 'requires' a list of component names as strings required by this component.
Use editor_entity_utils EditorEntity.add_components(list) to add this list of requirements.\n
: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': 'HDR Color Grading',
'requires': [AtomComponentProperties.postfx_layer()],
}
return properties[property]
@staticmethod
def hdri_skybox(property: str = 'name') -> str:
"""
HDRi Skybox component properties.
: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': 'HDRi Skybox',
}
return properties[property]
@staticmethod
def light(property: str = 'name') -> str:
"""
Light component properties.
- 'Light type' from atom_constants.py LIGHT_TYPES
: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': 'Light',
'Light type': 'Controller|Configuration|Light type',
}
return properties[property]
@staticmethod
def look_modification(property: str = 'name') -> str:
"""
Look Modification component properties. Requires PostFX Layer component.
- 'requires' a list of component names as strings required by this component.
Use editor_entity_utils EditorEntity.add_components(list) to add this list of requirements.\n
: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': 'Look Modification',
'requires': [AtomComponentProperties.postfx_layer()],
}
return properties[property]
@staticmethod
def material(property: str = 'name') -> str:
"""
Material component properties. Requires one of Actor OR Mesh component.
- 'requires' a list of component names as strings required by this component.
Only one of these is required at a time for this component.\n
: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': 'Material',
'requires': [AtomComponentProperties.actor(), AtomComponentProperties.mesh()],
}
return properties[property]
@staticmethod
def mesh(property: str = 'name') -> str:
"""
Mesh component properties.
- 'Mesh Asset' Asset.id of the mesh model.
: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.
:rtype: str
"""
properties = {
'name': 'Mesh',
'Mesh Asset': 'Controller|Configuration|Mesh Asset',
}
return properties[property]
@staticmethod
def occlusion_culling_plane(property: str = 'name') -> str:
"""
Occlusion Culling Plane component properties.
: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': 'Occlusion Culling Plane',
}
return properties[property]
@staticmethod
def physical_sky(property: str = 'name') -> str:
"""
Physical Sky component properties.
: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': 'Physical Sky',
}
return properties[property]
@staticmethod
def postfx_layer(property: str = 'name') -> str:
"""
PostFX Layer component properties.
: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': 'PostFX Layer',
}
return properties[property]
@staticmethod
def postfx_gradient(property: str = 'name') -> str:
"""
PostFX Gradient Weight Modifier component properties. Requires PostFX Layer component.
- 'requires' a list of component names as strings required by this component.
Use editor_entity_utils EditorEntity.add_components(list) to add this list of requirements.\n
: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': 'PostFX Gradient Weight Modifier',
'requires': [AtomComponentProperties.postfx_layer()],
}
return properties[property]
@staticmethod
def postfx_radius(property: str = 'name') -> str:
"""
PostFX Radius Weight Modifier component properties. Requires PostFX Layer component.
- 'requires' a list of component names as strings required by this component.
Use editor_entity_utils EditorEntity.add_components(list) to add this list of requirements.\n
: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': 'PostFX Radius Weight Modifier',
'requires': [AtomComponentProperties.postfx_layer()],
}
return properties[property]
@staticmethod
def postfx_shape(property: str = 'name') -> str:
"""
PostFX Shape Weight Modifier component properties. Requires PostFX Layer and one of 'shapes' listed.
- 'requires' a list of component names as strings required by this component.
Use editor_entity_utils EditorEntity.add_components(list) to add this list of requirements.\n
- 'shapes' a list of supported shapes as component names. 'Tube Shape' is also supported but requires 'Spline'.
: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': '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'],
}
return properties[property]
@staticmethod
def reflection_probe(property: str = 'name') -> str:
"""
Reflection Probe component properties. Requires one of 'shapes' listed.
- 'shapes' a list of supported shapes as component names.
- 'Baked Cubemap Path' Asset.id of the baked cubemap image generated by a call to 'BakeReflectionProbe' ebus.
: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': 'Reflection Probe',
'shapes': ['Axis Aligned Box Shape', 'Box Shape'],
'Baked Cubemap Path': 'Cubemap|Baked Cubemap Path',
}
return properties[property]
@staticmethod
def ssao(property: str = 'name') -> str:
"""
SSAO component properties. Requires PostFX Layer component.
- 'requires' a list of component names as strings required by this component.
Use editor_entity_utils EditorEntity.add_components(list) to add this list of requirements.\n
: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': 'SSAO',
'requires': [AtomComponentProperties.postfx_layer()],
}
return properties[property]

@ -80,25 +80,25 @@ def AtomEditorComponents_Mesh_AddedToEntity():
from editor_python_test_tools.asset_utils import Asset from editor_python_test_tools.asset_utils import Asset
from editor_python_test_tools.editor_entity_utils import EditorEntity from editor_python_test_tools.editor_entity_utils import EditorEntity
from editor_python_test_tools.utils import Report, Tracer, TestHelper as helper from editor_python_test_tools.utils import Report, Tracer, TestHelper
from Atom.atom_utils.atom_constants import AtomComponentProperties as Atom
with Tracer() as error_tracer: with Tracer() as error_tracer:
# Test setup begins. # Test setup begins.
# Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level. # Setup: Wait for Editor idle loop before executing Python hydra scripts then open "Base" level.
helper.init_idle() TestHelper.init_idle()
helper.open_level("", "Base") TestHelper.open_level("", "Base")
# Test steps begin. # Test steps begin.
# 1. Create a Mesh entity with no components. # 1. Create a Mesh entity with no components.
mesh_name = "Mesh" mesh_entity = EditorEntity.create_editor_entity(Atom.mesh())
mesh_entity = EditorEntity.create_editor_entity(mesh_name)
Report.critical_result(Tests.mesh_entity_creation, mesh_entity.exists()) Report.critical_result(Tests.mesh_entity_creation, mesh_entity.exists())
# 2. Add a Mesh component to Mesh entity. # 2. Add a Mesh component to Mesh entity.
mesh_component = mesh_entity.add_component(mesh_name) mesh_component = mesh_entity.add_component(Atom.mesh())
Report.critical_result( Report.critical_result(
Tests.mesh_component_added, Tests.mesh_component_added,
mesh_entity.has_component(mesh_name)) mesh_entity.has_component(Atom.mesh()))
# 3. UNDO the entity creation and component addition. # 3. UNDO the entity creation and component addition.
# -> UNDO component addition. # -> UNDO component addition.
@ -125,17 +125,16 @@ def AtomEditorComponents_Mesh_AddedToEntity():
Report.result(Tests.creation_redo, mesh_entity.exists()) Report.result(Tests.creation_redo, mesh_entity.exists())
# 5. Set Mesh component asset property # 5. Set Mesh component asset property
mesh_property_asset = 'Controller|Configuration|Mesh Asset'
model_path = os.path.join('Objects', 'shaderball', 'shaderball_default_1m.azmodel') model_path = os.path.join('Objects', 'shaderball', 'shaderball_default_1m.azmodel')
model = Asset.find_asset_by_path(model_path) model = Asset.find_asset_by_path(model_path)
mesh_component.set_component_property_value(mesh_property_asset, model.id) mesh_component.set_component_property_value(Atom.mesh('Mesh Asset'), model.id)
Report.result(Tests.mesh_asset_specified, Report.result(Tests.mesh_asset_specified,
mesh_component.get_component_property_value(mesh_property_asset) == model.id) mesh_component.get_component_property_value(Atom.mesh('Mesh Asset')) == model.id)
# 6. Enter/Exit game mode. # 6. Enter/Exit game mode.
helper.enter_game_mode(Tests.enter_game_mode) TestHelper.enter_game_mode(Tests.enter_game_mode)
general.idle_wait_frames(1) general.idle_wait_frames(1)
helper.exit_game_mode(Tests.exit_game_mode) TestHelper.exit_game_mode(Tests.exit_game_mode)
# 7. Test IsHidden. # 7. Test IsHidden.
mesh_entity.set_visibility_state(False) mesh_entity.set_visibility_state(False)
@ -159,7 +158,7 @@ def AtomEditorComponents_Mesh_AddedToEntity():
Report.result(Tests.deletion_redo, not mesh_entity.exists()) Report.result(Tests.deletion_redo, not mesh_entity.exists())
# 12. Look for errors or asserts. # 12. Look for errors or asserts.
helper.wait_for_condition(lambda: error_tracer.has_errors or error_tracer.has_asserts, 1.0) TestHelper.wait_for_condition(lambda: error_tracer.has_errors or error_tracer.has_asserts, 1.0)
for error_info in error_tracer.errors: for error_info in error_tracer.errors:
Report.info(f"Error: {error_info.filename} {error_info.function} | {error_info.message}") Report.info(f"Error: {error_info.filename} {error_info.function} | {error_info.message}")
for assert_info in error_tracer.asserts: for assert_info in error_tracer.asserts:

Loading…
Cancel
Save