Overhaul physics test organization (#3684)

* Moved files

Signed-off-by: Garcia Ruiz <aljanru@amazon.co.uk>

* Fixes for moved files

Signed-off-by: Garcia Ruiz <aljanru@amazon.co.uk>

* Removed tmp file

Signed-off-by: Garcia Ruiz <aljanru@amazon.co.uk>

Co-authored-by: Garcia Ruiz <aljanru@amazon.co.uk>
This commit is contained in:
AMZN-AlexOteiza
2021-08-31 10:04:24 +01:00
committed by GitHub
parent d784ff8c57
commit 77e630085b
161 changed files with 316 additions and 1333 deletions
@@ -0,0 +1,121 @@
"""
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
"""
# Test case ID : C14976307
# Test Case Title : Check that Set Gravity Enabled works on an entity with gravity that starts as disabled
# fmt: off
class Tests():
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
find_entities = ("Entities are found", "Entities are not found")
gravity_initially_disabled = ("Gravity was initially disabled", "Gravity was initially enabled")
gravity_enabled = ("Enabled gravity successfully", "Failed to enable gravity")
collision_occured = ("Sphere collided with terrain", "Sphere did not collide with terrain")
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
# fmt: on
def C14976307_Gravity_SetGravityWorks():
"""
Summary:
Check that Set Gravity Enabled works on an entity with gravity that starts as disabled
Level Description:
Terrain (entity) - Terrain entity is created in the level
Sphere (entity) - Entity with PhysX rigid body, mesh and collider with gravity disabled placed above
the terrain
Expected Behavior:
After 5 seconds, when SetGravity is called, the entity falls to the ground
We are checking if entities are valid and enabling the gravity after 5 seconds in game mode to check if ball
falls on the terrain.
Test Steps:
1) Open level
2) Enter game mode
3) Retrieve and validate entities
4) Gravity check for entity
5) Enabling gravity after 5 seconds
6) Adding collision handlers for terrain
7) Checking if the object collides with terrain
8) Exit game mode
9) Close the editor
Note:
- This test file must be called from the Open 3D Engine Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
import os
import sys
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
import azlmbr.legacy.general as general
import azlmbr.bus
# Constants
TIME_OUT = 3.0
WAIT_TIME = 5.0
helper.init_idle()
# 1) Open level
helper.open_level("Physics", "C14976307_Gravity_SetGravityWorks")
# 2) Enter game mode
helper.enter_game_mode(Tests.enter_game_mode)
# 3) Retrieve and validate entities
terrain_id = general.find_game_entity("Terrain")
sphere_id = general.find_game_entity("Sphere")
Report.critical_result(Tests.find_entities, terrain_id.IsValid() and sphere_id.IsValid())
sphere_gravity_enabled = False
class Sphere:
sphere_collision_occured = False
# 4) Gravity check for entities
sphere_gravity_enabled = azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "IsGravityEnabled", sphere_id)
Report.result(Tests.gravity_initially_disabled, not sphere_gravity_enabled)
# 5) Adding collision handlers for terrain
def on_collision_begin(args):
other_id = args[0]
if other_id.Equal(sphere_id):
Report.info("Sphere collided with the terrain")
Sphere.sphere_collision_occured = True
handler = azlmbr.physics.CollisionNotificationBusHandler()
handler.connect(terrain_id)
handler.add_callback("OnCollisionBegin", on_collision_begin)
# 6) Enabling gravity after 5 seconds
general.idle_wait(WAIT_TIME)
azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "SetGravityEnabled", sphere_id, True)
sphere_gravity_enabled = azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "IsGravityEnabled", sphere_id)
Report.result(Tests.gravity_enabled, sphere_gravity_enabled)
# 7) Checking if the object collides with terrain
helper.wait_for_condition(lambda: Sphere.sphere_collision_occured, TIME_OUT)
Report.result(Tests.collision_occured, Sphere.sphere_collision_occured)
# 8) Exit game mode
helper.exit_game_mode(Tests.exit_game_mode)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(C14976307_Gravity_SetGravityWorks)
@@ -0,0 +1,90 @@
"""
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
"""
# Test case ID : C15425929
# Test Case Title : Verify that undo - redo operations do not create any error
# fmt: off
class Tests:
entity_found = ("Entity was initially found", "Entity COULD NOT be found initially")
entity_deleted = ("Entity was deleted", "Entity WAS NOT deleted")
deletion_undone = ("Undo worked", "Undo DID NOT work")
deletion_redone = ("Redo worked", "Redo DID NOT work")
no_error_occurred = ("Undo/redo completed without errors", "An error occurred during undo/redo")
# fmt: off
def C15425929_Undo_Redo():
"""
Summary:
Tests that no error messages arise when using the undo and redo functions in the editor.
Level Description:
DeleteMe - an entity that just exists above the terrain with a sphere shape component on it.
Steps:
1) Load level
2) Initially find the entity
3) Delete the entity
4) Undo the deletion
5) Redo the deletion
6) Look for errors
7) Close the editor
Expected Behavior:
The entity should be deleted, un-deleted, and re-deleted.
:return: None
"""
import os
import sys
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
from editor_python_test_tools.utils import Tracer
import azlmbr.legacy.general as general
helper.init_idle()
# 1) Load the level
helper.open_level("Physics", "C15425929_Undo_Redo")
with Tracer() as error_tracer:
# Entity to delete and undo and re-delete
entity_name = "DeleteMe"
# 2) Find entity initially
entity_id = general.find_editor_entity(entity_name)
Report.critical_result(Tests.entity_found, entity_id.IsValid())
# 3) Delete entity
general.select_objects([entity_name])
general.delete_selected()
entity_id = general.find_editor_entity(entity_name)
Report.result(Tests.entity_deleted, not entity_id.IsValid())
# 4) Undo deletion
general.undo()
entity_id = general.find_editor_entity(entity_name)
Report.result(Tests.deletion_undone, entity_id.IsValid())
# 5) Redo deletion
general.redo()
entity_id = general.find_editor_entity(entity_name)
Report.result(Tests.deletion_redone, not entity_id.IsValid())
# 6) Look for errors
helper.wait_for_condition(lambda: error_tracer.has_errors, 1.0)
Report.result(Tests.no_error_occurred, not error_tracer.has_errors)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(C15425929_Undo_Redo)
@@ -0,0 +1,68 @@
"""
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
Test case ID : C19536274
Test Case Title : Verify that the Get Collision Layer Name node prints the name of the collision layer
"""
# fmt: off
class Tests():
test_entity_enabled = ("Test entity was enabled", "Test entity failed to enable")
game_mode_entered = ("Successfully entered Game Mode", "Failed to enter Game Mode")
# fmt: on
def C19536274_GetCollisionName_PrintsName():
"""
Summary:
Loads a level that contains an entity with script canvas and PhysX Collider components
Level Description:
Mostly empty level that contains a few different entities (one for each test using the level).
Each entity is named after the testrail id for the respective test. Each entity contains PhysX Collider component
and a Script Canvas Component with a matching .scriptcanvas file provided in the testrail.
Expected Behavior:
The level loads, enters game mode, and the script canvas prints out "Layer Name: Right"
Test Steps:
1) Load the test level
2) Find and enable the test entity
3) Enter game mode
Note:
- This test file must be called from the Open 3D Engine Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
# Helper Files
from editor_python_test_tools.utils import Report
from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity
from editor_python_test_tools.utils import TestHelper as helper
ACTIVE_STATUS = azlmbr.globals.property.EditorEntityStartStatus_StartActive
helper.init_idle()
# 1) Load the test level
helper.open_level("Physics", "NameNode_Prints")
# 2) Find and enable the test entity
test_entity = Entity.find_editor_entity("C19536274")
test_entity.set_start_status("active")
Report.result(Tests.test_entity_enabled, test_entity.get_start_status() == ACTIVE_STATUS)
# 3) Enter game mode
helper.enter_game_mode(Tests.game_mode_entered)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(C19536274_GetCollisionName_PrintsName)
@@ -0,0 +1,68 @@
"""
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
Test case ID : C19536277
Test Case Title : Verify that when a group is modified using ToggleCollisionLayer node such that the new group is not in the pre-existing groups, GetCollisionGroupName node prints no value
"""
# fmt: off
class Tests():
test_entity_enabled = ("Test Entity successfully enabled", "Failed to enable Test Entity")
game_mode_entered = ("Successfully entered Game Mode", "Failed to enter Game Mode")
# fmt: on
def C19536277_GetCollisionName_PrintsNothing():
"""
Summary:
Loads a level that contains an entity with script canvas and PhysX Collider components
Level Description:
Mostly empty level that contains a few different entities (one for each test using the level).
Each entity is named after the testrail id for the respective test. Each entity contains PhysX Collider component
and a Script Canvas Component with a matching .scriptcanvas file provided in the testrail.
Expected Behavior:
The level loads, enters game mode, and the script canvas prints out "GroupName: "
Test Steps:
1) Load the test level
2) Find and enable the test entity
3) Enter game mode
Note:
- This test file must be called from the Open 3D Engine Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
# Helper Files
from editor_python_test_tools.utils import Report
from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity
from editor_python_test_tools.utils import TestHelper as helper
ACTIVE_STATUS = azlmbr.globals.property.EditorEntityStartStatus_StartActive
helper.init_idle()
# 1) Load the test level
helper.open_level("Physics", "NameNode_Prints")
# 2) Find and enable the test entity
test_entity = Entity.find_editor_entity("C19536277")
test_entity.set_start_status("active")
Report.result(Tests.test_entity_enabled, test_entity.get_start_status() == ACTIVE_STATUS)
# 3) Enter game mode
helper.enter_game_mode(Tests.game_mode_entered)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(C19536277_GetCollisionName_PrintsNothing)
@@ -0,0 +1,153 @@
"""
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
"""
# Test case ID : C29032500
# Test Case Title : Check that WorldRequestBus works with editor components
# fmt: off
class Tests():
find_staticshapebox = ("Found StaticShapeBox", "Failed to find StaticShapeBox")
find_staticsphere = ("Found StaticSphere", "Failed to find StaticSphere")
find_staticbox = ("Found StaticBox", "Failed to find StaticBox")
find_staticcapsule = ("Found StaticCapsule", "Failed to find StaticCapsule")
find_staticmesh = ("Found StaticMesh", "Failed to find StaticMesh")
find_shapebox = ("Found ShapeBox", "Failed to find ShapeBox")
find_sphere = ("Found Sphere", "Failed to find Sphere")
find_box = ("Found Box", "Failed to find Box")
find_capsule = ("Found Capsule", "Failed to find Capsule")
find_mesh = ("Found Mesh", "Failed to find Mesh")
aabb_staticshapebox = ("Correct AABB for StaticShapeBox", "Incorrect AABB for StaticShapeBox")
aabb_staticsphere = ("Correct AABB for StaticSphere", "Incorrect AABB for StaticSphere")
aabb_staticbox = ("Correct AABB for StaticBox", "Incorrect AABB for StaticBox")
aabb_staticcapsule = ("Correct AABB for StaticCapsule", "Incorrect AABB for StaticCapsule")
aabb_staticmesh = ("Correct AABB for StaticMesh", "Incorrect AABB for StaticMesh")
aabb_shapebox = ("Correct AABB for ShapeBox", "Incorrect AABB for ShapeBox")
aabb_sphere = ("Correct AABB for Sphere", "Incorrect AABB for Sphere")
aabb_box = ("Correct AABB for Box", "Incorrect AABB for Box")
aabb_capsule = ("Correct AABB for Capsule", "Incorrect AABB for Capsule")
aabb_mesh = ("Correct AABB for Mesh", "Incorrect AABB for Mesh")
raycast_staticshapebox = ("Correct raycast for StaticShapeBox", "Incorrect raycast for StaticShapeBox")
raycast_staticsphere = ("Correct raycast for StaticSphere", "Incorrect raycast for StaticSphere")
raycast_staticbox = ("Correct raycast for StaticBox", "Incorrect raycast for StaticBox")
raycast_staticcapsule = ("Correct raycast for StaticCapsule", "Incorrect raycast for StaticCapsule")
raycast_staticmesh = ("Correct raycast for StaticMesh", "Incorrect raycast for StaticMesh")
raycast_shapebox = ("Correct raycast for ShapeBox", "Incorrect raycast for ShapeBox")
raycast_sphere = ("Correct raycast for Sphere", "Incorrect raycast for Sphere")
raycast_box = ("Correct raycast for Box", "Incorrect raycast for Box")
raycast_capsule = ("Correct raycast for Capsule", "Incorrect raycast for Capsule")
raycast_mesh = ("Correct raycast for Mesh", "Incorrect raycast for Mesh")
# fmt: on
def C29032500_EditorComponents_WorldBodyBusWorks():
r"""
Summary:
Runs a test to make sure that a WorldBodyBus works property for components
Level Description:
- Dynamic
- Sphere: Sphere with Rigid body
- Box: Box with Rigid body
- Capsule: Capsule with Rigid body
- Mesh: Sedan car Mesh with Rigid body
- ShapeBox: Shape Collider component + Box with rigidBody
- Static
- StaticSphere: Sphere with only Coollider component
- StaticBox: Box with only Coollider component
- StaticCapsule: Capsule with only Coollider component
- StaticMesh: Sedan car Mesh with only Coollider component
- StaticShapeBox: Only Shape Collider component + Box
TopDown view:
____
[!] o [ ] ( ) (____)
ShapeBox Sphere Box Capsule Mesh
____
[!] o [ ] ( ) (____)
StaticShapeBox StaticSphere StaticBox StaticCapsule StaticMesh
Expected Outcome:
Checks AABB and RayCast functions of WorldBodyBus against the All the entities in the level
:return:
"""
import os
import sys
import azlmbr.legacy.general as general
import azlmbr.bus
import math
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
from editor_python_test_tools.utils import vector3_str, aabb_str
AABB_THRESHOLD = 0.01 # Entities won't move in the simulation
helper.init_idle()
helper.open_level("Physics", "C29032500_EditorComponents_WorldBodyBusWorks")
def create_aabb(aabb_min_tuple, aabb_max_tuple):
return azlmbr.math.Aabb_CreateFromMinMax(azlmbr.math.Vector3(aabb_min_tuple[0], aabb_min_tuple[1], aabb_min_tuple[2]),
azlmbr.math.Vector3(aabb_max_tuple[0], aabb_max_tuple[1], aabb_max_tuple[2]))
class EntityData:
def __init__(self, name, target_aabb):
self.name = name
self.target_aabb = target_aabb
def get_test_tuple_for_entity(testprefix, entity_name):
return Tests.__dict__[testprefix.lower() + "_" + entity_name.lower()]
ENTITY_DATA = [ EntityData("ShapeBox", create_aabb((509.82, 523.08, 32.81), (510.82, 524.08, 33.81))),
EntityData("Sphere", create_aabb((509.82, 526.39, 32.81), (510.82, 527.39, 33.81))),
EntityData("Box", create_aabb((509.82, 529.66, 32.81), (510.82, 530.66, 33.81))),
EntityData("Capsule", create_aabb((510.07, 533.70, 32.81), (510.57, 534.20, 33.81))),
EntityData("Mesh", create_aabb((509.48, 536.30, 33.31), (511.16, 540.38, 34.38))),
EntityData("StaticShapeBox", create_aabb((512.08, 523.08, 32.81), (513.08, 524.08, 33.81))),
EntityData("StaticSphere", create_aabb((512.08, 526.39, 32.81), (513.08, 527.39, 33.81))),
EntityData("StaticBox", create_aabb((512.08, 529.66, 32.81), (513.08, 530.66, 33.81))),
EntityData("StaticCapsule", create_aabb((512.33, 533.70, 32.81), (512.83, 534.20, 33.81))),
EntityData("StaticMesh", create_aabb((511.74, 536.30, 33.31), (513.42, 540.38, 34.38))) ] # AABB data obtained by observation
for entity_data in ENTITY_DATA:
entity_id = general.find_editor_entity(entity_data.name);
Report.result(get_test_tuple_for_entity("find", entity_data.name), entity_id.IsValid())
if entity_id.IsValid():
# AABB test
aabb = azlmbr.physics.WorldBodyRequestBus(azlmbr.bus.Event, "GetAabb", entity_id)
Report.info("%s AABB -> %s" % (entity_data.name, aabb_str(aabb)))
Report.info("%s expected AABB -> %s" % (entity_data.name, aabb_str(entity_data.target_aabb)))
is_expected_aabb_size = aabb.min.IsClose(entity_data.target_aabb.min, AABB_THRESHOLD) and aabb.max.IsClose(entity_data.target_aabb.max, AABB_THRESHOLD)
Report.result(get_test_tuple_for_entity("aabb", entity_data.name), is_expected_aabb_size)
# Raycast test
entity_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTM", entity_id).GetPosition()
raycast_request = azlmbr.physics.RayCastRequest()
raycast_request.Start = entity_pos.Add(azlmbr.math.Vector3(0.0, 0.0, 100.0))
raycast_request.Distance = 500.0
raycast_request.Direction = azlmbr.math.Vector3(0.0, 0.0, -1.0)
result = azlmbr.physics.WorldBodyRequestBus(azlmbr.bus.Event, "RayCast", entity_id, raycast_request)
if result:
# Following line crashes due to a hydra bug, use distance for now
# has_hit = ragdoll_id.Equal(result.EntityId)
has_hit = result.Distance > 0.1 and math.isclose(result.Position.x, entity_pos.x) and math.isclose(result.Position.y, entity_pos.y)
Report.info("Hit: %s" % vector3_str(result.Position))
Report.result(get_test_tuple_for_entity("raycast", entity_data.name), has_hit)
else:
Report.failure(get_test_tuple_for_entity("raycast", entity_data.name))
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(C29032500_EditorComponents_WorldBodyBusWorks)
@@ -0,0 +1,105 @@
"""
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
"""
# Test case ID : C5689529
# Test Case Title : Create an entity with PhysX Terrain component and add
# PhysX Rigid Body PhysX, PhysX Collider and Rendering Mesh to it and
# verify that it works in game mode
# fmt: off
class Tests():
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
find_entity = ("Entity found", "Entity not found")
gravity_enabled = ("Gravity is enabled", "Gravity is disabled")
mass_equal = ("Mass of rigid body equal to the expected mass", "Mass of rigid body not equal to the expected mass")
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
# fmt: on
def C5689529_Verify_Terrain_RigidBody_Collider_Mesh():
"""
Summary:
Create an entity with PhysX Terrain component and add PhysX Rigid Body PhysX,
PhysX Collider and Rendering Mesh to it and verify that it works in game mode
Level Description:
PhysXRigidBody (entity) - Entity with components PhysX Rigid Body, PhysX Collider, Terrain and Rendering Mesh
Expected Behavior:
The rigid body entity should be working in the game mode.
We are checking if entity id is valid and extracting some properties of rigid body.
Also we are waiting for few frames to ensure that the editor did not crash.
Test Steps:
1) Open level
2) Enter game mode
3) Retrieve and validate entities
4) Waiting for WAIT_FRAMES to ensure that the editor did not crash in the game mode
5) Check the properties of rigid body like Gravity(enabled) and Mass(1.0kg)
6) Exit game mode
7) Close the editor
Note:
- This test file must be called from the Open 3D Engine Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
import os
import sys
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
import azlmbr.legacy.general as general
import azlmbr.bus
# Constants
WAIT_FRAMES = 2
EXPECTED_MASS = 1.0 # Default mass of a rigid body component
helper.init_idle()
# 1) Open level
helper.open_level("Physics", "C5689529_Verify_Terrain_RigidBody_Collider_Mesh")
# 2) Enter game mode
helper.enter_game_mode(Tests.enter_game_mode)
# 3) Retrieve and validate entities
rigid_body_id = general.find_game_entity("PhysXRigidBody")
Report.critical_result(Tests.find_entity, rigid_body_id.IsValid())
class RigidBody:
gravity_enabled = False
collison_occued = False
mass = 0.0
# 4) Waiting for WAIT_FRAMES to ensure that the editor did not crash in the game mode
general.idle_wait_frames(WAIT_FRAMES)
Report.info("Editor did not crash after waiting for " + str(WAIT_FRAMES) + " frames")
# 5) Check the properties of rigid body like Gravity(enabled) and Mass(1.0kg)
RigidBody.gravity_enabled = azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "IsGravityEnabled", rigid_body_id)
Report.critical_result(Tests.gravity_enabled, RigidBody.gravity_enabled)
RigidBody.mass = azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "GetMass", rigid_body_id)
Report.critical_result(Tests.mass_equal, RigidBody.mass == EXPECTED_MASS)
# 6) Exit game mode
helper.exit_game_mode(Tests.exit_game_mode)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(C5689529_Verify_Terrain_RigidBody_Collider_Mesh)
@@ -0,0 +1,102 @@
"""
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
"""
# Test case ID : C6131473
# Test Case Title : Verify a static slice is not spawned automatically everytime a dynamic slice with
# PhysX Components is spawned
# fmt: off
class Tests():
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
find_entity = ("Entities are found", "Entities are not found")
dynamic_slice_entity = ("Dynamic slice entity not found", "Dynamic slice entity found")
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
# fmt: on
def C6131473_StaticSlice_OnDynamicSliceSpawn():
"""
Summary:
Verify a static slice is not spawned automatically everytime a dynamic slice with PhysX Components is spawned
Level Description:
Spawner (entity) - Entity with a spawner component with a dynamic slice attached to it.
"Spawn on activate" is enabled for the spawner component.
The Spawner is attached to a dynamic slice "RigidBody" with components
PhysX Rigid body,
PhysX Collider with shape as Sphere and radius as 1.0,
Rendering mesh with mesh as primitive_sphere
Expected Behavior:
We are checking if the dynamic slice "RigidBody" is present in the current level.
The test fails if the dynamic slice is found in the level.
Test Steps:
1) Open level
2) Enter game mode
3) Retrieve and validate entities
4) Verify if the dynamic slice entity exists in the current level
5) Exit game mode
6) Close the editor
Note:
- This test file must be called from the Open 3D Engine Editor command terminal
- Any passed and failed tests are written to the Editor.log file.
Parsing the file or running a log_monitor are required to observe the test results.
:return: None
"""
import os
import sys
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
import azlmbr.legacy.general as general
import azlmbr.bus
import azlmbr.entity as entity
# Constants
DYNAMIC_SLICE_NAME = "RigidBody"
helper.init_idle()
# 1) Open level
helper.open_level("Physics", "C6131473_StaticSlice_OnDynamicSliceSpawn")
# 2) Enter game mode
helper.enter_game_mode(Tests.enter_game_mode)
# 3) Retrieve and validate entities
spawner_id = general.find_game_entity("SpawnerEntity")
Report.result(Tests.find_entity, spawner_id.IsValid())
# 4) Verify if the dynamic slice entity exists in the current level
# Get all the entity ids in the level
searchFilter = entity.SearchFilter()
searchFilter.Names = ["*"]
entity_ids = entity.SearchBus(azlmbr.bus.Broadcast, "SearchEntities", searchFilter)
entity_names = [
azlmbr.entity.GameEntityContextRequestBus(azlmbr.bus.Broadcast, "GetEntityName", entity_id)
for entity_id in entity_ids
]
# check if the dynamic slice ("RigidBody") exists in the list if entities
Report.result(Tests.dynamic_slice_entity, DYNAMIC_SLICE_NAME not in entity_names)
# 5) Exit game mode
helper.exit_game_mode(Tests.exit_game_mode)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(C6131473_StaticSlice_OnDynamicSliceSpawn)