Merge pull request #7302 from aws-lumberyard-dev/Atom/scottmur/P1_decal_null

P1 Decal tests for null renderer
monroegm-disable-blank-issue-2
jromnoa 4 years ago committed by GitHub
commit 9a30c5366c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -87,12 +87,18 @@ class AtomComponentProperties:
def decal(property: str = 'name') -> str: def decal(property: str = 'name') -> str:
""" """
Decal component properties. Decal component properties.
- 'Attenuation Angle' controls how much the angle between geometry and decal impacts opacity. 0-1 Radians
- 'Opacity' where one is opaque and zero is transparent
- 'Sort Key' 0-255 stacking z-sort like key to define which decal is on top of another
- 'Material' the material Asset.id of the decal. - '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. :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. :return: Full property path OR component name if no property specified.
""" """
properties = { properties = {
'name': 'Decal', 'name': 'Decal',
'Attenuation Angle': 'Controller|Configuration|Attenuation Angle',
'Opacity': 'Controller|Configuration|Opacity',
'Sort Key': 'Controller|Configuration|Sort Key',
'Material': 'Controller|Configuration|Material', 'Material': 'Controller|Configuration|Material',
} }
return properties[property] return properties[property]

@ -8,49 +8,61 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
class Tests: class Tests:
camera_creation = ( camera_creation = (
"Camera Entity successfully created", "Camera Entity successfully created",
"Camera Entity failed to be created") "P0: Camera Entity failed to be created")
camera_component_added = ( camera_component_added = (
"Camera component was added to entity", "Camera component was added to entity",
"Camera component failed to be added to entity") "P0: Camera component failed to be added to entity")
camera_component_check = ( camera_component_check = (
"Entity has a Camera component", "Entity has a Camera component",
"Entity failed to find Camera component") "P0: Entity failed to find Camera component")
creation_undo = ( creation_undo = (
"UNDO Entity creation success", "UNDO Entity creation success",
"UNDO Entity creation failed") "P0: UNDO Entity creation failed")
creation_redo = ( creation_redo = (
"REDO Entity creation success", "REDO Entity creation success",
"REDO Entity creation failed") "P0: REDO Entity creation failed")
decal_creation = ( decal_creation = (
"Decal Entity successfully created", "Decal Entity successfully created",
"Decal Entity failed to be created") "P0: Decal Entity failed to be created")
decal_component = ( decal_component = (
"Entity has a Decal component", "Entity has a Decal component",
"Entity failed to find Decal component") "P0: Entity failed to find Decal component")
decal_component_removed = (
"Decal component removed",
"P0: Decal component failed to be removed")
material_property_set = ( material_property_set = (
"Material property set on Decal component", "Material property set on Decal component",
"Couldn't set Material property on Decal component") "P0: Couldn't set Material property on Decal component")
attenuation_property_set = (
"Attenuation Angle property set on Decal component",
"P1: Couldn't set Attenuation Angle property on Decal component")
opacity_property_set = (
"Opacity property set on Decal component",
"P1: Coudn't set Opacity property on Decal component")
sort_key_property_set = (
"Sort Key property set on Decal component",
"P1: Couldn't set Sort Key property on Decal component")
enter_game_mode = ( enter_game_mode = (
"Entered game mode", "Entered game mode",
"Failed to enter game mode") "P0: Failed to enter game mode")
exit_game_mode = ( exit_game_mode = (
"Exited game mode", "Exited game mode",
"Couldn't exit game mode") "P0: Couldn't exit game mode")
is_visible = ( is_visible = (
"Entity is visible", "Entity is visible",
"Entity was not visible") "P0: Entity was not visible")
is_hidden = ( is_hidden = (
"Entity is hidden", "Entity is hidden",
"Entity was not hidden") "P0: Entity was not hidden")
entity_deleted = ( entity_deleted = (
"Entity deleted", "Entity deleted",
"Entity was not deleted") "P0: Entity was not deleted")
deletion_undo = ( deletion_undo = (
"UNDO deletion success", "UNDO deletion success",
"UNDO deletion failed") "P0: UNDO deletion failed")
deletion_redo = ( deletion_redo = (
"REDO deletion success", "REDO deletion success",
"REDO deletion failed") "P0: REDO deletion failed")
def AtomEditorComponents_Decal_AddedToEntity(): def AtomEditorComponents_Decal_AddedToEntity():
@ -71,14 +83,18 @@ def AtomEditorComponents_Decal_AddedToEntity():
2) Add Decal component to Decal entity. 2) Add Decal component to Decal entity.
3) UNDO the entity creation and component addition. 3) UNDO the entity creation and component addition.
4) REDO the entity creation and component addition. 4) REDO the entity creation and component addition.
5) Enter/Exit game mode. 5) Set Material property on Decal component.
6) Test IsHidden. 6) Set Attenuation Angle property on Decal component.
7) Test IsVisible. 7) Set Opacity property on Decal component
8) Set Material property on Decal component. 8) Set Sort Key property on Decal Component
9) Delete Decal entity. 9) Remove Decal component then UNDO the remove
10) UNDO deletion. 10) Enter/Exit game mode.
11) REDO deletion. 11) Test IsHidden.
12) Look for errors and asserts. 12) Test IsVisible.
13) Delete Decal entity.
14) UNDO deletion.
15) REDO deletion.
16) Look for errors and asserts.
:return: None :return: None
""" """
@ -130,42 +146,69 @@ def AtomEditorComponents_Decal_AddedToEntity():
general.idle_wait_frames(1) general.idle_wait_frames(1)
Report.result(Tests.creation_redo, decal_entity.exists()) Report.result(Tests.creation_redo, decal_entity.exists())
# 5. Enter/Exit game mode. # 5. Set Material property on Decal component.
decal_material_asset_path = os.path.join("materials", "decal", "airship_symbol_decal.azmaterial")
decal_material_asset = Asset.find_asset_by_path(decal_material_asset_path, False)
decal_component.set_component_property_value(AtomComponentProperties.decal('Material'), decal_material_asset.id)
get_material_property = decal_component.get_component_property_value(AtomComponentProperties.decal('Material'))
Report.result(Tests.material_property_set, get_material_property == decal_material_asset.id)
# 6. Set Attenuation Angle property on Decal component
decal_component.set_component_property_value(AtomComponentProperties.decal('Attenuation Angle'), value=0.75)
get_attenuation_property = decal_component.get_component_property_value(
AtomComponentProperties.decal('Attenuation Angle'))
Report.result(Tests.attenuation_property_set, get_attenuation_property == 0.75)
# 7. Set Opacity property on Decal component
decal_component.set_component_property_value(AtomComponentProperties.decal('Opacity'), value=0.5)
get_opacity_property = decal_component.get_component_property_value(AtomComponentProperties.decal('Opacity'))
Report.result(Tests.opacity_property_set, get_opacity_property == 0.5)
# 8. Set Sort Key property on Decal component
decal_component.set_component_property_value(AtomComponentProperties.decal('Sort Key'), value=255.0)
get_sort_key_property = decal_component.get_component_property_value(AtomComponentProperties.decal('Sort Key'))
Report.result(Tests.sort_key_property_set, get_sort_key_property == 255.0)
decal_component.set_component_property_value(AtomComponentProperties.decal('Sort Key'), value=0)
get_sort_key_property = decal_component.get_component_property_value(AtomComponentProperties.decal('Sort Key'))
Report.result(Tests.sort_key_property_set, get_sort_key_property == 0)
# 9. Remove Decal component then UNDO the remove
decal_component.remove()
general.idle_wait_frames(1)
Report.result(Tests.decal_component_removed, not decal_entity.has_component(AtomComponentProperties.decal()))
general.undo()
general.idle_wait_frames(1)
Report.result(Tests.decal_component, decal_entity.has_component(AtomComponentProperties.decal()))
# 10. Enter/Exit game mode.
TestHelper.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)
TestHelper.exit_game_mode(Tests.exit_game_mode) TestHelper.exit_game_mode(Tests.exit_game_mode)
# 6. Test IsHidden. # 11. Test IsHidden.
decal_entity.set_visibility_state(False) decal_entity.set_visibility_state(False)
Report.result(Tests.is_hidden, decal_entity.is_hidden() is True) Report.result(Tests.is_hidden, decal_entity.is_hidden() is True)
# 7. Test IsVisible. # 12. Test IsVisible.
decal_entity.set_visibility_state(True) decal_entity.set_visibility_state(True)
general.idle_wait_frames(1) general.idle_wait_frames(1)
Report.result(Tests.is_visible, decal_entity.is_visible() is True) Report.result(Tests.is_visible, decal_entity.is_visible() is True)
# 8. Set Material property on Decal component. # 13. Delete Decal entity.
decal_material_asset_path = os.path.join("materials", "basic_grey.azmaterial")
decal_material_asset = Asset.find_asset_by_path(decal_material_asset_path, False)
decal_component.set_component_property_value(AtomComponentProperties.decal('Material'), decal_material_asset.id)
get_material_property = decal_component.get_component_property_value(AtomComponentProperties.decal('Material'))
Report.result(Tests.material_property_set, get_material_property == decal_material_asset.id)
# 9. Delete Decal entity.
decal_entity.delete() decal_entity.delete()
Report.result(Tests.entity_deleted, not decal_entity.exists()) Report.result(Tests.entity_deleted, not decal_entity.exists())
# 10. UNDO deletion. # 14. UNDO deletion.
general.undo() general.undo()
general.idle_wait_frames(1) general.idle_wait_frames(1)
Report.result(Tests.deletion_undo, decal_entity.exists()) Report.result(Tests.deletion_undo, decal_entity.exists())
# 11. REDO deletion. # 15. REDO deletion.
general.redo() general.redo()
general.idle_wait_frames(1) general.idle_wait_frames(1)
Report.result(Tests.deletion_redo, not decal_entity.exists()) Report.result(Tests.deletion_redo, not decal_entity.exists())
# 12. Look for errors and asserts. # 16. Look for errors and asserts.
TestHelper.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}")

@ -34,6 +34,7 @@ class EditorComponent:
EditorEntity.add_component() or Entity.add_components() or EditorEntity.get_components_of_type() EditorEntity.add_component() or Entity.add_components() or EditorEntity.get_components_of_type()
which also assigns self.id and self.type_id to the EditorComponent object. which also assigns self.id and self.type_id to the EditorComponent object.
self.type_id is the UUID for the component type as provided by an ebus call. self.type_id is the UUID for the component type as provided by an ebus call.
self.id is an azlmbr.entity.EntityComponentIdPair which contains both entity and component id's
""" """
def __init__(self, type_id: uuid): def __init__(self, type_id: uuid):
@ -270,6 +271,13 @@ class EditorComponent:
warnings.warn("disable_component is deprecated, use set_enabled(False) instead.", DeprecationWarning) warnings.warn("disable_component is deprecated, use set_enabled(False) instead.", DeprecationWarning)
editor.EditorComponentAPIBus(bus.Broadcast, "DisableComponents", [self.id]) editor.EditorComponentAPIBus(bus.Broadcast, "DisableComponents", [self.id])
def remove(self):
"""
Removes the component from its associated entity. Essentially a delete since only UNDO can return it.
:return: None
"""
editor.EditorComponentAPIBus(bus.Broadcast, "RemoveComponents", [self.id])
@staticmethod @staticmethod
def get_type_ids(component_names: list, entity_type: EditorEntityType = EditorEntityType.GAME) -> list: def get_type_ids(component_names: list, entity_type: EditorEntityType = EditorEntityType.GAME) -> list:
""" """

@ -0,0 +1,36 @@
{
"materialType": "Materials/Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"textureMap": "Materials/decal/airship_symbol_decal.tif"
},
"general": {
"doubleSided": true
},
"metallic": {
"useTexture": false
},
"normal": {
"useTexture": false
},
"opacity": {
"alphaSource": "Split",
"factor": 0.6899999976158142,
"mode": "Cutout",
"textureMap": "Materials/decal/airship_symbol_decal.tif"
},
"roughness": {
"useTexture": false
},
"specularF0": {
"useTexture": false
},
"uv": {
"center": [
0.0,
1.0
]
}
}
}

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2252ba28e19432d99e58fa03b672f855e1f520805eda71764e076fe349e1915a
size 4205906
Loading…
Cancel
Save