5a60cb15fc
* Spec-5799 Add PhysX tests to Main Suite to run under 3 min Adding 12 tests to Main Suite from Periodic Suite. Moved 1 test case to Sandbox Suite as it was failing and needs to be investigated. Run results on local : 12 passed, 1 warning in 172.31s (0:02:52) Test Case list in Main suite: test_C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC test_C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies test_C4044459_Material_DynamicFriction test_C15425929_Undo_Redo test_C4976243_Collision_SameCollisionGroupDiffCollisionLayers test_C14654881_CharacterController_SwitchLevels test_C17411467_AddPhysxRagdollComponent test_C12712453_ScriptCanvas_MultipleRaycastNode test_C4982593_PhysXCollider_CollisionLayerTest test_C18243586_Joints_HingeLeadFollowerCollide test_C19578021_ShapeCollider_CanBeAdded test_C4982803_Enable_PxMesh_Option Test moved to Sandbox Suite : test_C13895144_Ragdoll_ChangeLevel * Delete .gitignore * Revert "Delete .gitignore" This reverts commit 9540e000c85e2a2015fbb8251f0a3248494349b0. Revert the modification of adding the buildoutput folder. * Spec-5799:Fixing Cyclinder ShapeCollider test and adding it to Main Suite Changes : 1. Fixed and Added test C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain to TestSuite_Main.py and updated the level for the test. 2. Removed test test_C19578021_ShapeCollider_CanBeAdded from Main suite back to Periodic Suite * Update TestSuite_Periodic.py Adding xfail to test case test_C13895144_Ragdoll_ChangeLevel as the previous change had overridden Sean Cove's change with commit95a44c481a* Update TestSuite_Sandbox.py Removing test case test_C13895144_Ragdoll_ChangeLevel and moving it to Periodic Suite as the previous change had overridden Sean Cove's change with commit95a44c481aCo-authored-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com>
147 lines
5.8 KiB
Python
Executable File
147 lines
5.8 KiB
Python
Executable File
"""
|
|
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
its licensors.
|
|
|
|
For complete copyright and license terms please see the LICENSE at the root of this
|
|
distribution (the "License"). All use of this software is governed by the License,
|
|
or, if provided, by the license below or the license accompanying this file. Do not
|
|
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
"""
|
|
|
|
|
|
# Test case ID : C24308873
|
|
# Test Case Title : Check that cylinder shape collider collides with terrain
|
|
# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/24308873
|
|
# A cylinder is suspended slightly over PhysX Terrain to check that it collides when dropped
|
|
|
|
|
|
# fmt: off
|
|
class Tests():
|
|
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
|
find_cylinder = ("Cylinder entity found", "Cylinder entity not found")
|
|
create_terrain = ("Terrain entity created successfully", "Failed to create Terrain Entity")
|
|
find_terrain = ("Terrain entity found", "Terrain entity not found")
|
|
add_physx_shape_collider = ("Added PhysX Shape Collider", "Failed to add PhysX Shape Collider")
|
|
add_box_shape = ("Added Box Shape", "Failed to add Box Shape")
|
|
cylinder_above_terrain = ("Cylinder position above ground", "Cylinder is not above the ground")
|
|
time_out = ("No time out occurred", "A time out occurred, please validate level setup")
|
|
touched_ground = ("Touched ground before time out", "Did not touch ground before time out")
|
|
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
|
# fmt: on
|
|
|
|
|
|
def C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain():
|
|
"""
|
|
Summary:
|
|
Runs a test to make sure that a PhysX Rigid Body and Cylinder Shape Collider can successfully collide with a PhysX Terrain entity.
|
|
|
|
Level Description:
|
|
A cylinder with rigid body and collider is positioned above a PhysX terrain.
|
|
|
|
Expected Outcome:
|
|
Once game mode is entered, the cylinder should fall toward and collide with the terrain.
|
|
|
|
Steps:
|
|
1) Open level and create terrain Entity.
|
|
2) Enter Game Mode.
|
|
3) Retrieve entities and positions
|
|
4) Wait for cylinder to collide with terrain OR time out
|
|
5) Exit game mode
|
|
6) Close the editor
|
|
|
|
:return:
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
import ImportPathHelper as imports
|
|
|
|
imports.init()
|
|
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
|
import azlmbr.legacy.general as general
|
|
import azlmbr.bus
|
|
import azlmbr.math as math
|
|
from editor_python_test_tools.utils import Report
|
|
from editor_python_test_tools.utils import TestHelper as helper
|
|
|
|
# Global time out
|
|
TIME_OUT = 1.0
|
|
|
|
# 1) Open level
|
|
helper.init_idle()
|
|
helper.open_level("Physics", "C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain")
|
|
|
|
# Create terrain entity
|
|
terrain = EditorEntity.create_editor_entity_at([30.0, 30.0, 33.96], "Terrain")
|
|
Report.result(Tests.create_terrain, terrain.id.IsValid())
|
|
|
|
terrain.add_component("PhysX Shape Collider")
|
|
Report.result(Tests.add_physx_shape_collider, terrain.has_component("PhysX Shape Collider"))
|
|
|
|
box_shape_component = terrain.add_component("Box Shape")
|
|
Report.result(Tests.add_box_shape, terrain.has_component("Box Shape"))
|
|
|
|
box_shape_component.set_component_property_value("Box Shape|Box Configuration|Dimensions",
|
|
math.Vector3(1024.0, 1024.0, 0.01))
|
|
|
|
# 2)Enter game mode
|
|
helper.enter_game_mode(Tests.enter_game_mode)
|
|
|
|
# 3) Retrieve entities and positions
|
|
cylinder_id = general.find_game_entity("PhysX_Cylinder")
|
|
Report.critical_result(Tests.find_cylinder, cylinder_id.IsValid())
|
|
|
|
|
|
terrain_id = general.find_game_entity("Terrain")
|
|
Report.critical_result(Tests.find_terrain, terrain_id.IsValid())
|
|
|
|
|
|
cylinder_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", cylinder_id)
|
|
#Cylinder position is 64,84,35
|
|
terrain_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", terrain_id)
|
|
Report.info_vector3(cylinder_pos, "Cylinder:")
|
|
Report.info_vector3(terrain_pos, "Terrain:")
|
|
Report.critical_result(
|
|
Tests.cylinder_above_terrain,
|
|
(cylinder_pos.z - terrain_pos.z) > 0.5,
|
|
"Please make sure the cylinder entity is set above the terrain",
|
|
)
|
|
|
|
# Enable gravity (just in case it is not enabled)
|
|
if not azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "IsGravityEnabled", cylinder_id):
|
|
azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "SetGravityEnabled", cylinder_id, True)
|
|
|
|
class TouchGround:
|
|
value = False
|
|
|
|
# Collision event handler
|
|
def on_collision_begin(args):
|
|
other_id = args[0]
|
|
if other_id.Equal(terrain_id):
|
|
Report.info("Touched ground")
|
|
TouchGround.value = True
|
|
|
|
# Assign event handler to cylinder
|
|
handler = azlmbr.physics.CollisionNotificationBusHandler()
|
|
handler.connect(cylinder_id)
|
|
handler.add_callback("OnCollisionBegin", on_collision_begin)
|
|
|
|
# 4) Wait for the cylinder to hit the ground OR time out
|
|
test_completed = helper.wait_for_condition((lambda: TouchGround.value), TIME_OUT)
|
|
|
|
Report.critical_result(Tests.time_out, test_completed)
|
|
Report.result(Tests.touched_ground, TouchGround.value)
|
|
|
|
# 5) Exit game mode
|
|
helper.exit_game_mode(Tests.exit_game_mode)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import ImportPathHelper as imports
|
|
imports.init()
|
|
|
|
from editor_python_test_tools.utils import Report
|
|
Report.start_test(C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain)
|