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:
+98
@@ -0,0 +1,98 @@
|
||||
"""
|
||||
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 : C18243580
|
||||
# Test Case Title : Check that fixed joint constrains 2 bodies
|
||||
|
||||
|
||||
# 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_lead_position = ("Lead moved in X direction", "Lead did not move in X direction")
|
||||
check_follower_position = ("Follower moved in X direction", "Follower did not move in X direction")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243580_Joints_Fixed2BodiesConstrained():
|
||||
"""
|
||||
Summary: Check that fixed joint constrains 2 bodies
|
||||
|
||||
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.
|
||||
|
||||
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 entity and follower entity moved in positive X direction.
|
||||
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 JointEntity
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243580_Joints_Fixed2BodiesConstrained")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
Report.info_vector3(lead.position, "lead initial position:")
|
||||
Report.info_vector3(follower.position, "follower initial position:")
|
||||
leadInitialPosition = lead.position.x
|
||||
followerInitialPosition = follower.position.x
|
||||
|
||||
# 4) Wait for several seconds
|
||||
general.idle_wait(1.0) # wait for lead and follower to move
|
||||
|
||||
# 5) Check to see if lead entity and follower entity moved in positive X direction.
|
||||
Report.info_vector3(lead.position, "lead position after 1 second:")
|
||||
Report.info_vector3(follower.position, "follower position after 1 second:")
|
||||
Report.critical_result(Tests.check_lead_position, lead.position.x > leadInitialPosition)
|
||||
Report.critical_result(Tests.check_follower_position, follower.position.x > followerInitialPosition)
|
||||
|
||||
# 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(C18243580_Joints_Fixed2BodiesConstrained)
|
||||
@@ -0,0 +1,97 @@
|
||||
"""
|
||||
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 : C18243581
|
||||
# Test Case Title : Check that fixed joint is breakable
|
||||
|
||||
|
||||
# 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_lead_position = ("Lead did not move in X direction","Lead moved in X direction")
|
||||
check_follower_position = ("Follower moved in X direction", "Follower did not move in X direction")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243581_Joints_FixedBreakable():
|
||||
"""
|
||||
Summary: Check that fixed joint is breakable
|
||||
|
||||
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 but the lead entity does not move in the positive X direction by more than a distance of 0.5.
|
||||
|
||||
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 JointEntity
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243581_Joints_FixedBreakable")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
Report.info_vector3(lead.position, "lead initial position:")
|
||||
Report.info_vector3(follower.position, "follower initial position:")
|
||||
leadInitialPosition = lead.position.x
|
||||
followerInitialPosition = follower.position.x
|
||||
|
||||
# 4) Wait for several seconds
|
||||
general.idle_wait(1.0) # wait for lead and follower to move
|
||||
|
||||
# 5) Check to see if lead and follower behaved as expected
|
||||
Report.info_vector3(lead.position, "lead position after 1 second:")
|
||||
Report.info_vector3(follower.position, "follower position after 1 second:")
|
||||
Report.critical_result(Tests.check_lead_position, (lead.position.x - leadInitialPosition) < 0.5)
|
||||
Report.critical_result(Tests.check_follower_position, (follower.position.x - followerInitialPosition) > 0.5)
|
||||
|
||||
# 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(C18243581_Joints_FixedBreakable)
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
"""
|
||||
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 C18243582_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", "C18243582_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(C18243582_Joints_FixedLeadFollowerCollide)
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
"""
|
||||
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 : C18243583
|
||||
# Test Case Title : Check that hinge joint constrains 2 bodies about X-axis
|
||||
|
||||
|
||||
# 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_lead_position = ("Lead stays still", "Lead moved")
|
||||
check_follower_position = ("Follower moved in X and Z directions only", "Follower did not move in X and Z directions, or moved in Y direction")
|
||||
check_follower_below_lead = ("Follower remains below lead", "Follower moved above lead")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243583_Joints_Hinge2BodiesConstrained():
|
||||
"""
|
||||
Summary: Check that hinge joint constrains 2 bodies about X-axis
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with hinge joint. Starts with initial velocity of (5, 1, 0).
|
||||
|
||||
Expected Behavior:
|
||||
The follower entity moved in the positive X and Z directions, but not in the Y direction.
|
||||
The position of the lead entity does not change much.
|
||||
The follower entity did not move above the lead entity.
|
||||
|
||||
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
|
||||
|
||||
import JointsHelper
|
||||
from JointsHelper import JointEntity
|
||||
|
||||
# Constants
|
||||
FLOAT_EPSILON = 0.1
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243583_Joints_Hinge2BodiesConstrained")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
Report.info_vector3(lead.position, "lead initial position:")
|
||||
Report.info_vector3(follower.position, "follower initial position:")
|
||||
leadInitialPosition = lead.position
|
||||
followerInitialPosition = follower.position
|
||||
|
||||
# 4) Wait for several seconds
|
||||
general.idle_wait(1.0) # wait for lead and follower to move
|
||||
|
||||
# 5) Check to see if lead and follower behaved as expected
|
||||
Report.info_vector3(lead.position, "lead position after 1 second:")
|
||||
Report.info_vector3(follower.position, "follower position after 1 second:")
|
||||
|
||||
leadPositionDelta = lead.position.Subtract(leadInitialPosition)
|
||||
leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_lead_position, leadRemainedStill)
|
||||
|
||||
followerMovedInXAndZOnly = ((follower.position.x - followerInitialPosition.x) > FLOAT_EPSILON and
|
||||
(follower.position.y - followerInitialPosition.y) < FLOAT_EPSILON and
|
||||
(follower.position.z - followerInitialPosition.z) > FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_follower_position, followerMovedInXAndZOnly)
|
||||
|
||||
followerBelowLead = follower.position.z < lead.position.z
|
||||
Report.critical_result(Tests.check_follower_below_lead, followerBelowLead)
|
||||
|
||||
# 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(C18243583_Joints_Hinge2BodiesConstrained)
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
"""
|
||||
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 : C18243584
|
||||
# Test Case Title : Check that hinge joint allows soft limit constraints on 2 bodies
|
||||
|
||||
|
||||
# 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_lead_position = ("Lead stays still", "Lead moved")
|
||||
check_follower_position = ("Follower moved higher than lead, but does not swing over it", "Follower did not move higher than lead, or swinged over it")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243584_Joints_HingeSoftLimitsConstrained():
|
||||
"""
|
||||
Summary: Check that hinge joint allows soft limit constraints on 2 bodies
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with a hinge joint. Starts with initial velocity of (5, 1, 0).
|
||||
forceRegion - This force region has a suction (negative point) force that will hold the follower if it reaches the position that will pass the test.
|
||||
|
||||
Expected Behavior:
|
||||
Lead entity remains still.
|
||||
Follower moved higher than lead, but does not swing over it.
|
||||
Since the 45 degree limit is soft, the follower can swing to a position higher than the lead, but will not swing over it.
|
||||
|
||||
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
|
||||
import math
|
||||
|
||||
|
||||
|
||||
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 JointsHelper
|
||||
from JointsHelper import JointEntity
|
||||
|
||||
# Constants
|
||||
FLOAT_EPSILON = 0.2
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243584_Joints_HingeSoftLimitsConstrained")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
Report.info_vector3(lead.position, "lead initial position:")
|
||||
Report.info_vector3(follower.position, "follower initial position:")
|
||||
leadInitialPosition = lead.position
|
||||
|
||||
# 4) Wait for the follower to move above the lead or Timeout
|
||||
normalizedStartPos = JointsHelper.getRelativeVector(lead.position, follower.position)
|
||||
normalizedStartPos = normalizedStartPos.GetNormalizedSafe()
|
||||
|
||||
class WaitCondition:
|
||||
TARGET_ANGLE = math.radians(45)
|
||||
TARGET_MAX_ANGLE = math.radians(180)
|
||||
|
||||
angleAchieved = 0.0
|
||||
followerMovedAbove45Deg = False #this is expected to be true to pass the test
|
||||
followerMovedAbove180Deg = True #this is expected to be false to pass the test
|
||||
|
||||
def checkConditionMet(self):
|
||||
#calculate the current follower-lead vector
|
||||
normalVec = JointsHelper.getRelativeVector(lead.position, follower.position)
|
||||
normalVec = normalVec.GetNormalizedSafe()
|
||||
#dot product + acos to get the angle
|
||||
currentAngle = math.acos(normalizedStartPos.Dot(normalVec))
|
||||
#if the angle is now less then last time, it is no longer rising, so end the test.
|
||||
if currentAngle < self.angleAchieved:
|
||||
return True
|
||||
|
||||
self.angleAchieved = currentAngle
|
||||
self.followerMovedAbove45Deg = currentAngle > self.TARGET_ANGLE
|
||||
self.followerMovedAbove180Deg = currentAngle > self.TARGET_MAX_ANGLE
|
||||
return False
|
||||
|
||||
def isFollowerPositionCorrect(self):
|
||||
return self.followerMovedAbove45Deg and not self.followerMovedAbove180Deg
|
||||
|
||||
waitCondition = WaitCondition()
|
||||
|
||||
MAX_WAIT_TIME = 5.0 #seconds
|
||||
conditionMet = helper.wait_for_condition(lambda: waitCondition.checkConditionMet(), MAX_WAIT_TIME)
|
||||
|
||||
# 5) Check to see if lead and follower behaved as expected
|
||||
Report.info_vector3(lead.position, "lead position after test:")
|
||||
Report.info_vector3(follower.position, "follower position after test:")
|
||||
|
||||
leadPositionDelta = lead.position.Subtract(leadInitialPosition)
|
||||
leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_lead_position, leadRemainedStill)
|
||||
|
||||
Report.critical_result(Tests.check_follower_position, conditionMet and waitCondition.isFollowerPositionCorrect())
|
||||
|
||||
# 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(C18243584_Joints_HingeSoftLimitsConstrained)
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
"""
|
||||
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 : C18243585
|
||||
# Test Case Title : Check that hinge joint allows no limit constraints on 2 bodies
|
||||
|
||||
|
||||
# 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_lead_position = ("Lead stays still", "Lead moved")
|
||||
check_follower_position = ("Follower moved higher than lead, and swinged over it", "Follower did not move higher than lead, or swing over it")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243585_Joints_HingeNoLimitsConstrained():
|
||||
"""
|
||||
Summary: Check that hinge joint allows no limit constraints on 2 bodies
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with a hinge joint. Starts with initial velocity of (5, 1, 0).
|
||||
forceRegion - Contains suction and damping force to hold follower position when it enters the region that will pass the test.
|
||||
|
||||
Expected Behavior:
|
||||
Lead entity remains still.
|
||||
Follower entity's Z position exceeds lead entity's Z position and swings past above the lead entity.
|
||||
The hinge joint constraint is not limited, the follower can swing to a position higher than the lead, and over it
|
||||
|
||||
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
|
||||
|
||||
import JointsHelper
|
||||
from JointsHelper import JointEntity
|
||||
|
||||
# Constants
|
||||
FLOAT_EPSILON = 0.2
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243585_Joints_HingeNoLimitsConstrained")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
Report.info_vector3(lead.position, "lead initial position:")
|
||||
Report.info_vector3(follower.position, "follower initial position:")
|
||||
leadInitialPosition = lead.position
|
||||
followerInitialPosition = follower.position
|
||||
|
||||
# 4) Wait for several seconds
|
||||
general.idle_wait(4.0) # wait for lead and follower to move
|
||||
|
||||
# 5) Check to see if lead and follower behaved as expected
|
||||
Report.info_vector3(lead.position, "lead position after 1 second:")
|
||||
Report.info_vector3(follower.position, "follower position after 1 second:")
|
||||
|
||||
leadPositionDelta = lead.position.Subtract(leadInitialPosition)
|
||||
leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_lead_position, leadRemainedStill)
|
||||
|
||||
followerSwingedOverLead = (follower.position.x < leadInitialPosition.x and
|
||||
follower.position.z > leadInitialPosition.z)
|
||||
Report.critical_result(Tests.check_follower_position, followerSwingedOverLead)
|
||||
|
||||
# 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(C18243585_Joints_HingeNoLimitsConstrained)
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
"""
|
||||
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 : C18243586
|
||||
# Test Case Title : Check that hinge 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 C18243586_Joints_HingeLeadFollowerCollide():
|
||||
"""
|
||||
Summary: Check that hinge joint allows lead-follower collision
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with a hinge joint. Starts with initial velocity of (5, 1, 0).
|
||||
|
||||
Expected Behavior:
|
||||
Lead entity remains still.
|
||||
Follower entity swings up, collides with the lead entity, and falls back down.
|
||||
|
||||
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 (they collided)
|
||||
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", "C18243586_Joints_HingeLeadFollowerCollide")
|
||||
|
||||
# 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 and follower behaved as expected
|
||||
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(C18243586_Joints_HingeLeadFollowerCollide)
|
||||
@@ -0,0 +1,109 @@
|
||||
"""
|
||||
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 : C18243587
|
||||
# Test Case Title : Check that hinge joint is breakable
|
||||
|
||||
|
||||
# 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_lead_position = ("Lead stays still", "Lead moved")
|
||||
check_follower_position = ("Follower moved in X direction only", "Follower did not just move in X direction, but also in Z direction")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243587_Joints_HingeBreakable():
|
||||
"""
|
||||
Summary: Check that hinge joint is breakable
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with hinge joint. Starts with initial velocity of (5, 1, 0).
|
||||
|
||||
Expected Behavior:
|
||||
Lead entity remains still.
|
||||
Follower entity moves in the positive X direction, and not much in the Z direction since the joint broke.
|
||||
|
||||
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
|
||||
|
||||
import JointsHelper
|
||||
from JointsHelper import JointEntity
|
||||
|
||||
# Constants
|
||||
FLOAT_EPSILON = 0.2
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243587_Joints_HingeBreakable")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
Report.info_vector3(lead.position, "lead initial position:")
|
||||
Report.info_vector3(follower.position, "follower initial position:")
|
||||
leadInitialPosition = lead.position
|
||||
followerInitialPosition = follower.position
|
||||
|
||||
# 4) Wait for several seconds
|
||||
general.idle_wait(1.0) # wait for lead and follower to move
|
||||
|
||||
# 5) Check to see if lead and follower behaved as expected
|
||||
Report.info_vector3(lead.position, "lead position after 1 second:")
|
||||
Report.info_vector3(follower.position, "follower position after 1 second:")
|
||||
|
||||
leadPositionDelta = lead.position.Subtract(leadInitialPosition)
|
||||
leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_lead_position, leadRemainedStill)
|
||||
|
||||
followerMovedInXOnly = ((follower.position.x - followerInitialPosition.x) > FLOAT_EPSILON and
|
||||
(follower.position.z - followerInitialPosition.z) < FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_follower_position, followerMovedInXOnly)
|
||||
|
||||
# 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(C18243587_Joints_HingeBreakable)
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
"""
|
||||
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 : C18243588
|
||||
# Test Case Title : Check that ball joint constrains 2 bodies within cone limits
|
||||
|
||||
# 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_lead_position = ("Lead stays still", "Lead moved")
|
||||
check_follower_position = ("Follower moved in X, Y and Z directions", "Follower did not move in X, Y and Z directions")
|
||||
check_follower_below_lead = ("Follower remains below lead", "Follower moved above lead")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243588_Joints_Ball2BodiesConstrained():
|
||||
"""
|
||||
Summary: Check that ball joint constrains 2 bodies within cone limits
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with ball joint. Starts with initial velocity of (5, 2, 0).
|
||||
|
||||
Expected Behavior:
|
||||
The follower entity moved in the positive X, Y and Z directions.
|
||||
The position of the lead entity does not change much.
|
||||
The follower entity did not move above the lead entity.
|
||||
|
||||
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
|
||||
|
||||
import JointsHelper
|
||||
from JointsHelper import JointEntity
|
||||
|
||||
# Constants
|
||||
FLOAT_EPSILON = 0.1 # Negligible float value for comparing with translation vectors. Values smaller than this are considered zero.
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243588_Joints_Ball2BodiesConstrained")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
Report.info_vector3(lead.position, "lead initial position:")
|
||||
Report.info_vector3(follower.position, "follower initial position:")
|
||||
leadInitialPosition = lead.position
|
||||
followerInitialPosition = follower.position
|
||||
|
||||
# 4) Wait for several seconds
|
||||
general.idle_wait(1.0) # wait for lead and follower to move
|
||||
|
||||
# 5) Check to see if lead and follower behaved as expected
|
||||
Report.info_vector3(lead.position, "lead position after 1 second:")
|
||||
Report.info_vector3(follower.position, "follower position after 1 second:")
|
||||
|
||||
leadPositionDelta = lead.position.Subtract(leadInitialPosition)
|
||||
leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_lead_position, leadRemainedStill)
|
||||
|
||||
followerPositionDelta = follower.position.Subtract(followerInitialPosition)
|
||||
followerMovedInXAndZOnly = JointsHelper.vector3LargerThanScalar(followerPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_follower_position, followerMovedInXAndZOnly)
|
||||
|
||||
followerBelowLead = follower.position.z < lead.position.z
|
||||
Report.critical_result(Tests.check_follower_below_lead, followerBelowLead)
|
||||
|
||||
# 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(C18243588_Joints_Ball2BodiesConstrained)
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
"""
|
||||
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 : 18243589
|
||||
# Test Case Title : Check that ball joint allows soft limit constraints
|
||||
|
||||
|
||||
# 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_lead_position = ("Lead stays still", "Lead moved")
|
||||
check_follower_position = ("Follower in X, Y and Z directions", "Follower did not move in X, Y, and Z directions")
|
||||
check_follower_above_joint = ("Follower swings above joint", "Follower did not swing above joint")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243589_Joints_BallSoftLimitsConstrained():
|
||||
"""
|
||||
Summary: Check that ball joint allows soft limit constraints
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with a ball joint. Starts with initial velocity of (5, 1, 0).
|
||||
|
||||
Expected Behavior:
|
||||
Lead entity remains still.
|
||||
Follower entity moves in the positive X, Y and Z directions.
|
||||
Follower entity's Z position exceeds its original Z position + 2.5, above the position where the joint is located.
|
||||
Because the cone limit is 45 degrees, if the follower manages to swing above the joint position, it is evident that the limit is soft.
|
||||
|
||||
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
|
||||
import math
|
||||
|
||||
|
||||
|
||||
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 JointsHelper
|
||||
from JointsHelper import JointEntity
|
||||
|
||||
# Constants
|
||||
FLOAT_EPSILON = 0.2
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243589_Joints_BallSoftLimitsConstrained")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
Report.info_vector3(lead.position, "lead initial position:")
|
||||
Report.info_vector3(follower.position, "follower initial position:")
|
||||
leadInitialPosition = lead.position
|
||||
followerInitialPosition = follower.position
|
||||
|
||||
followerMovedAboveJoint = False
|
||||
#calculate the start vector from follower and lead positions
|
||||
normalizedStartPos = JointsHelper.getRelativeVector(lead.position, follower.position)
|
||||
normalizedStartPos = normalizedStartPos.GetNormalizedSafe()
|
||||
#the targeted angle to reach between the initial vector and the current follower-lead vector
|
||||
TARGET_ANGLE_DEG = 45
|
||||
targetAngle = math.radians(TARGET_ANGLE_DEG)
|
||||
angleAchieved = 0.0
|
||||
|
||||
def checkAngleMet():
|
||||
#calculate the current follower-lead vector
|
||||
normalVec = JointsHelper.getRelativeVector(lead.position, follower.position)
|
||||
normalVec = normalVec.GetNormalizedSafe()
|
||||
#dot product + acos to get the angle
|
||||
angleAchieved = math.acos(normalizedStartPos.Dot(normalVec))
|
||||
#is it above target?
|
||||
return angleAchieved > targetAngle
|
||||
|
||||
MAX_WAIT_TIME = 2.0 #seconds
|
||||
followerMovedAboveJoint = helper.wait_for_condition(checkAngleMet, MAX_WAIT_TIME)
|
||||
|
||||
# 5) Check to see if lead and follower behaved as expected
|
||||
Report.info_vector3(lead.position, "lead position:")
|
||||
Report.info_vector3(follower.position, "follower position:")
|
||||
angleAchievedDeg = math.degrees(angleAchieved)
|
||||
Report.info(f"Angle achieved {angleAchievedDeg:.2f} Target {TARGET_ANGLE_DEG:.2f}")
|
||||
|
||||
leadPositionDelta = lead.position.Subtract(leadInitialPosition)
|
||||
leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_lead_position, leadRemainedStill)
|
||||
|
||||
followerPositionDelta = follower.position.Subtract(followerInitialPosition)
|
||||
followerMovedinXYZ = JointsHelper.vector3LargerThanScalar(followerPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_follower_position, followerMovedinXYZ)
|
||||
|
||||
Report.critical_result(Tests.check_follower_above_joint, followerMovedAboveJoint)
|
||||
|
||||
# 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(C18243589_Joints_BallSoftLimitsConstrained)
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
"""
|
||||
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 : C18243590
|
||||
# Test Case Title : Check that ball joint allows no limit constraints
|
||||
|
||||
|
||||
# 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_lead_position = ("Lead stays still", "Lead moved")
|
||||
check_follower_position = ("Follower moved higher than lead", "Follower did not move higher than lead")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243590_Joints_BallNoLimitsConstrained():
|
||||
"""
|
||||
Summary: Check that ball joint allows no limit constraints
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with a ball joint. The ball joint is located in between the lead and follower. Starts with initial velocity of (5, 1, 0).
|
||||
dampingRegion - A force region cube is placed at the position of the lead. If the follower swings to the position above and near the lead, the force region's damping holds the follower in the place.'
|
||||
|
||||
Expected Behavior:
|
||||
Lead entity remains still.
|
||||
Follower entity's Z position exceeds lead entity's Z position.
|
||||
Because the ball joint is somewhere in the middle of the follower and the lead,
|
||||
if the follower manages to go above the lead,
|
||||
it is evident that the ball joint without limits managed to keep the follower constrained to the lead but did not impose a limit.
|
||||
|
||||
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
|
||||
|
||||
import JointsHelper
|
||||
from JointsHelper import JointEntity
|
||||
|
||||
# Constants
|
||||
FLOAT_EPSILON = 0.2
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243590_Joints_BallNoLimitsConstrained")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
Report.info_vector3(lead.position, "lead initial position:")
|
||||
Report.info_vector3(follower.position, "follower initial position:")
|
||||
leadInitialPosition = lead.position
|
||||
followerInitialPosition = follower.position
|
||||
|
||||
# 4) Wait for several seconds
|
||||
general.idle_wait(3.0) # wait for lead and follower to move
|
||||
|
||||
# 5) Check to see if lead and follower behaved as expected
|
||||
Report.info_vector3(lead.position, "lead position after 2.5 second:")
|
||||
Report.info_vector3(follower.position, "follower position after 2.5 second:")
|
||||
|
||||
leadPositionDelta = lead.position.Subtract(leadInitialPosition)
|
||||
leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_lead_position, leadRemainedStill)
|
||||
|
||||
followerAboveLead = follower.position.z > leadInitialPosition.z
|
||||
Report.critical_result(Tests.check_follower_position, followerAboveLead)
|
||||
|
||||
# 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(C18243590_Joints_BallNoLimitsConstrained)
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
"""
|
||||
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 : C18243591
|
||||
# Test Case Title : Check that ball 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 C18243591_Joints_BallLeadFollowerCollide():
|
||||
"""
|
||||
Summary: Check that ball joint allows lead-follower collision
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with a ball joint. Starts with initial velocity of (5, 2, 0).
|
||||
|
||||
Expected Behavior:
|
||||
Lead entity remains still.
|
||||
Follower entity swings up, collides with the lead entity, and falls back down.
|
||||
|
||||
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 (they collided)
|
||||
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", "C18243591_Joints_BallLeadFollowerCollide")
|
||||
|
||||
# 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 and follower behaved as expected
|
||||
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(C18243591_Joints_BallLeadFollowerCollide)
|
||||
@@ -0,0 +1,107 @@
|
||||
"""
|
||||
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 : C18243592
|
||||
# Test Case Title : Check that ball joint is breakable
|
||||
|
||||
# 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_lead_position = ("Lead stays still", "Lead moved")
|
||||
check_follower_position = ("Follower moved in X direction only", "Follower did not just move in X direction, but also in Z direction")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243592_Joints_BallBreakable():
|
||||
"""
|
||||
Summary: Check that ball joint is breakable
|
||||
|
||||
Level Description:
|
||||
lead - Starts above follower entity
|
||||
follower - Starts below lead entity. Constrained to lead entity with ball joint. Starts with initial velocity of (5, 2, 0).
|
||||
|
||||
Expected Behavior:
|
||||
Lead entity remains still.
|
||||
Follower entity moves in the positive X direction, and not much in the Z direction since the joint broke.
|
||||
|
||||
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
|
||||
|
||||
import JointsHelper
|
||||
from JointsHelper import JointEntity
|
||||
|
||||
# Constants
|
||||
FLOAT_EPSILON = 0.2
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243592_Joints_BallBreakable")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
lead = Entity("lead")
|
||||
follower = Entity("follower")
|
||||
Report.info_vector3(lead.position, "lead initial position:")
|
||||
Report.info_vector3(follower.position, "follower initial position:")
|
||||
leadInitialPosition = lead.position
|
||||
followerInitialPosition = follower.position
|
||||
|
||||
# 4) Wait for several seconds
|
||||
general.idle_wait(1.0) # wait for lead and follower to move
|
||||
|
||||
# 5) Check to see if lead and follower behaved as expected
|
||||
Report.info_vector3(lead.position, "lead position after 1 second:")
|
||||
Report.info_vector3(follower.position, "follower position after 1 second:")
|
||||
|
||||
leadPositionDelta = lead.position.Subtract(leadInitialPosition)
|
||||
leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_lead_position, leadRemainedStill)
|
||||
|
||||
followerMovedInXOnly = ((follower.position.x - followerInitialPosition.x) > FLOAT_EPSILON and
|
||||
(follower.position.z - followerInitialPosition.z) < FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_follower_position, followerMovedInXOnly)
|
||||
|
||||
# 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(C18243592_Joints_BallBreakable)
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
"""
|
||||
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 : C18243593
|
||||
# Test Case Title : Check that fixed/hinge/ball joints allow constraints to global frame
|
||||
|
||||
|
||||
# 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")
|
||||
follower_fixed_found = ("Found follower for fixed joint", "Did not find follower for fixed joint")
|
||||
follower_hinge_found = ("Found follower for hinge joint", "Did not find follower for hinge joint")
|
||||
follower_ball_found = ("Found follower for ball joint", "Did not find follower for ball joint")
|
||||
check_fixed_follower_position = ("Fixed joint follower remained still", "Fixed joint follower did not remain still")
|
||||
check_hinge_follower_position = ("Hinge joint follower moved in X and Z directions only", "Hinge joint follower did not move in X and Z directions, or moved in Y direction")
|
||||
check_ball_follower_position = ("Ball joint follower moved in X, Y and Z directions", "Ball joint follower did not move in X, Y and Z directions")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def C18243593_Joints_GlobalFrameConstrained():
|
||||
"""
|
||||
Summary: Check that fixed/hinge/ball joints allow constraints to global frame
|
||||
|
||||
Level Description:
|
||||
follower_fixed - Constrained to fixed joint at global frame placed above the entity.
|
||||
follower_hinge - Constrained to hinge joint at global frame placed above the entity.
|
||||
follower_ball - Constrained to ball joint at global frame placed above the entity.
|
||||
|
||||
Expected Behavior:
|
||||
The follower-fixed entity should remain still.
|
||||
The follower_hinge and follower_ball entities move in the positive X and Z directions.
|
||||
|
||||
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
|
||||
|
||||
import JointsHelper
|
||||
from JointsHelper import JointEntity
|
||||
|
||||
# Constants
|
||||
FLOAT_EPSILON = 0.1
|
||||
|
||||
# Helper Entity class
|
||||
class Entity(JointEntity):
|
||||
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", "C18243593_Joints_GlobalFrameConstrained")
|
||||
|
||||
# 2) Enter Game Mode
|
||||
helper.enter_game_mode(Tests.enter_game_mode)
|
||||
|
||||
# 3) Create and Validate Entities
|
||||
followerFixed = Entity("follower_fixed")
|
||||
followerHinge = Entity("follower_hinge")
|
||||
followerBall = Entity("follower_ball")
|
||||
Report.info_vector3(followerFixed.position, "follower_fixed initial position:")
|
||||
Report.info_vector3(followerHinge.position, "follower_hinge initial position:")
|
||||
Report.info_vector3(followerBall.position, "follower_ball initial position:")
|
||||
followerFixedInitialPosition = followerFixed.position
|
||||
followerHingeInitialPosition = followerHinge.position
|
||||
followerBallInitialPosition = followerBall.position
|
||||
|
||||
# 4) Wait for several seconds
|
||||
general.idle_wait(1.0) # wait for lead and follower to move
|
||||
|
||||
# 5) Check to see if lead and follower behaved as expected
|
||||
Report.info_vector3(followerFixed.position, "follower_fixed initial position after 1 second:")
|
||||
Report.info_vector3(followerHinge.position, "follower_hinge initial position after 1 second:")
|
||||
Report.info_vector3(followerBall.position, "follower_ball initial position after 1 second:")
|
||||
|
||||
followerFixedPositionDelta = followerFixed.position.Subtract(followerFixedInitialPosition)
|
||||
fixedFollowerRemainedStill = JointsHelper.vector3SmallerThanScalar(followerFixedPositionDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_fixed_follower_position, fixedFollowerRemainedStill)
|
||||
|
||||
hingeFollowerMovedInXAndZOnly = ((followerHinge.position.x - followerHingeInitialPosition.x) > FLOAT_EPSILON and
|
||||
(followerHinge.position.y - followerHingeInitialPosition.y) < FLOAT_EPSILON and
|
||||
(followerHinge.position.z - followerHingeInitialPosition.z) > FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_hinge_follower_position, hingeFollowerMovedInXAndZOnly)
|
||||
|
||||
followerBallPositinDelta = followerBall.position.Subtract(followerBallInitialPosition)
|
||||
ballFollowerMovedinXYZ = JointsHelper.vector3LargerThanScalar(followerBallPositinDelta, FLOAT_EPSILON)
|
||||
Report.critical_result(Tests.check_ball_follower_position, ballFollowerMovedinXYZ)
|
||||
|
||||
# 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(C18243593_Joints_GlobalFrameConstrained)
|
||||
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus
|
||||
|
||||
def vector3SmallerThanScalar(vec3Value, scalarValue):
|
||||
return (vec3Value.x < scalarValue and
|
||||
vec3Value.y < scalarValue and
|
||||
vec3Value.z < scalarValue)
|
||||
|
||||
def vector3LargerThanScalar(vec3Value, scalarValue):
|
||||
return (vec3Value.x > scalarValue and
|
||||
vec3Value.y > scalarValue and
|
||||
vec3Value.z > scalarValue)
|
||||
|
||||
def getRelativeVector(vecA, vecB):
|
||||
relativeVec = vecA
|
||||
relativeVec.x = relativeVec.x - vecB.x
|
||||
relativeVec.y = relativeVec.y - vecB.y
|
||||
relativeVec.z = relativeVec.z - vecB.z
|
||||
return relativeVec
|
||||
|
||||
|
||||
# Entity class for joints tests
|
||||
class JointEntity:
|
||||
def criticalEntityFound(self): # For overriding in sub-classes so that can report if entities are found using their own dictionary of entities
|
||||
pass
|
||||
|
||||
def __init__(self, name):
|
||||
self.id = general.find_game_entity(name)
|
||||
self.name = name
|
||||
self.criticalEntityFound()
|
||||
|
||||
@property
|
||||
def position(self):
|
||||
# type () -> Vector3
|
||||
return azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", self.id)
|
||||
|
||||
# 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
|
||||
|
||||
def __init__(self, name):
|
||||
self.id = general.find_game_entity(name)
|
||||
self.name = name
|
||||
self.criticalEntityFound()
|
||||
|
||||
self.collided = False
|
||||
# Set up collision notification handler
|
||||
self.handler = azlmbr.physics.CollisionNotificationBusHandler()
|
||||
self.handler.connect(self.id)
|
||||
self.handler.add_callback("OnCollisionBegin", self.on_collision_begin)
|
||||
Reference in New Issue
Block a user