remove some flackyness in physx automated tests (#4547)
Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com>
This commit is contained in:
@@ -525,10 +525,6 @@ class TestAutomation(TestAutomationBase):
|
||||
from .tests.joints import Joints_BallNoLimitsConstrained as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_Joints_FixedLeadFollowerCollide(self, request, workspace, editor, launcher_platform):
|
||||
from .tests.joints import Joints_FixedLeadFollowerCollide as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_Joints_GlobalFrameConstrained(self, request, workspace, editor, launcher_platform):
|
||||
from .tests.joints import Joints_GlobalFrameConstrained as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ def ForceRegion_SplineRegionWithModifiedTransform():
|
||||
import azlmbr.bus as bus
|
||||
|
||||
# region Constants
|
||||
TIMEOUT = 5.0
|
||||
TIMEOUT = 10.0
|
||||
MIN_TRIGGER_DISTANCE = 2.0
|
||||
# endregion
|
||||
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ def ForceRegion_ZeroPointForceDoesNothing():
|
||||
|
||||
helper.init_idle()
|
||||
|
||||
TIMEOUT_SECONDS = 3.0
|
||||
TIMEOUT_SECONDS = 5.0
|
||||
X_Y_Z_TOLERANCE = 1.5
|
||||
REGION_HEIGHT = 3.0
|
||||
TERRAIN_HEIGHT = 32.0
|
||||
|
||||
@@ -45,8 +45,13 @@ class JointEntity:
|
||||
# Entity class that sets a flag when an instance receives collision events.
|
||||
class JointEntityCollisionAware(JointEntity):
|
||||
def on_collision_begin(self, args):
|
||||
if not self.collided:
|
||||
self.collided = True
|
||||
self.collided = True
|
||||
|
||||
def on_collision_persist(self, args):
|
||||
self.collided = True
|
||||
|
||||
def on_collision_end(self, args):
|
||||
self.collided = True
|
||||
|
||||
def __init__(self, name):
|
||||
self.id = general.find_game_entity(name)
|
||||
@@ -58,3 +63,5 @@ class JointEntityCollisionAware(JointEntity):
|
||||
self.handler = azlmbr.physics.CollisionNotificationBusHandler()
|
||||
self.handler.connect(self.id)
|
||||
self.handler.add_callback("OnCollisionBegin", self.on_collision_begin)
|
||||
self.handler.add_callback("OnCollisionPresist", self.on_collision_persist)
|
||||
self.handler.add_callback("OnCollisionEnd", self.on_collision_end)
|
||||
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
"""
|
||||
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 : C18243582
|
||||
# Test Case Title : Check that fixed joint allows lead-follower collision
|
||||
|
||||
|
||||
# fmt: off
|
||||
class Tests:
|
||||
enter_game_mode = ("Entered game mode", "Failed to enter game mode")
|
||||
exit_game_mode = ("Exited game mode", "Couldn't exit game mode")
|
||||
lead_found = ("Found lead", "Did not find lead")
|
||||
follower_found = ("Found follower", "Did not find follower")
|
||||
check_collision_happened = ("Lead and follower collided", "Lead and follower did not collide")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def Joints_FixedLeadFollowerCollide():
|
||||
"""
|
||||
Summary: Check that fixed joint allows lead-follower collision
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with fixed joint. Starts with initial velocity of (5, 0, 0) in positive X direction.
|
||||
|
||||
Expected Behavior:
|
||||
The follower entity moves in the positive X direction and the lead entity is dragged along towards the positive X direction.
|
||||
The x position of the lead entity is incremented from its original.
|
||||
The lead and follower entities are kept apart at a distance of approximately 1.0 due to collision.
|
||||
|
||||
Test Steps:
|
||||
1) Open Level
|
||||
2) Enter Game Mode
|
||||
3) Create and Validate Entities
|
||||
4) Wait for several seconds
|
||||
5) Check to see if lead and follower behaved as expected.
|
||||
6) Exit Game Mode
|
||||
7) Close 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
|
||||
|
||||
from JointsHelper import JointEntityCollisionAware
|
||||
|
||||
# Helper Entity class - self.collided flag is set when instance receives collision event.
|
||||
class Entity(JointEntityCollisionAware):
|
||||
def criticalEntityFound(self): # Override function to use local Test dictionary
|
||||
Report.critical_result(Tests.__dict__[self.name + "_found"], self.id.isValid())
|
||||
|
||||
# Main Script
|
||||
helper.init_idle()
|
||||
|
||||
# 1) Open Level
|
||||
helper.open_level("Physics", "Joints_FixedLeadFollowerCollide")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
|
||||
# 4) Wait for several seconds
|
||||
general.idle_wait(2.0) # wait for lead and follower to move
|
||||
|
||||
# 5) Check to see if lead entity and follower collided
|
||||
Report.critical_result(Tests.check_collision_happened, lead.collided and follower.collided)
|
||||
|
||||
# 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(Joints_FixedLeadFollowerCollide)
|
||||
+15
-15
@@ -80,6 +80,20 @@ def RigidBody_KinematicModeWorks():
|
||||
ramp_id = general.find_game_entity("Ramp")
|
||||
Report.result(Tests.find_ramp, ramp_id.IsValid())
|
||||
|
||||
# 2.1) setup collision handler
|
||||
class RampTouched:
|
||||
value = False
|
||||
|
||||
def on_collision_begin(args):
|
||||
other_id = args[0]
|
||||
if other_id.Equal(ramp_id):
|
||||
Report.info("Box touched ramp")
|
||||
RampTouched.value = True
|
||||
|
||||
handler = azlmbr.physics.CollisionNotificationBusHandler()
|
||||
handler.connect(box_id)
|
||||
handler.add_callback("OnCollisionBegin", on_collision_begin)
|
||||
|
||||
# 3) Check for kinematic ramp and not kinematic box
|
||||
box_kinematic = azlmbr.physics.RigidBodyRequestBus(azlmbr.bus.Event, "IsKinematic", box_id)
|
||||
Report.result(Tests.box_is_not_kinematic, not box_kinematic)
|
||||
@@ -98,21 +112,7 @@ def RigidBody_KinematicModeWorks():
|
||||
ramp_pos_start = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", ramp_id)
|
||||
Report.info("Ramp's initial position: {}".format(ramp_pos_start))
|
||||
|
||||
# 6) Check to see that the box hits the ramp
|
||||
class RampTouched:
|
||||
value = False
|
||||
|
||||
def on_collision_begin(args):
|
||||
other_id = args[0]
|
||||
if other_id.Equal(ramp_id):
|
||||
Report.info("Box touched ramp")
|
||||
RampTouched.value = True
|
||||
|
||||
handler = azlmbr.physics.CollisionNotificationBusHandler()
|
||||
handler.connect(box_id)
|
||||
handler.add_callback("OnCollisionBegin", on_collision_begin)
|
||||
|
||||
# 6.5) Wait for the box to touch the ramp or timeout
|
||||
# 6) Wait for the box to touch the ramp or timeout
|
||||
helper.wait_for_condition(lambda: RampTouched.value, TIME_OUT)
|
||||
Report.result(Tests.box_touched_ramp, RampTouched.value)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user