NvCloth_AddClothSimulationToActor.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. # Test case ID : C18977330
  7. # Test Case Title : Add cloth simulation to an Actor
  8. # fmt: off
  9. class Tests:
  10. enter_game_mode = ("Entered game mode", "Failed to enter game mode")
  11. no_errors_and_warnings_found = ("No errors and warnings found", "Found errors and warnings")
  12. exit_game_mode = ("Exited game mode", "Failed to exit game mode")
  13. # fmt: on
  14. def NvCloth_AddClothSimulationToActor():
  15. """
  16. Summary:
  17. Load level with Entity having Actor and Cloth components already setup. Verify that editor remains stable in Game mode.
  18. Expected Behavior:
  19. The Editor is stable there are no warnings or errors.
  20. Test Steps:
  21. 1) Load the level
  22. 2) Start the Tracer to catch any errors and warnings
  23. 3) Enter game mode
  24. 4) Wait in game mode some frames to let cloth simulation run
  25. 5) Verify there are no errors and warnings in the logs
  26. 6) Exit game mode
  27. 7) Close the editor
  28. Note:
  29. At the time of writing this test it was not possible to set a component property
  30. with a dropdown, which is necessary to setup a Cloth component. Because of this limitation
  31. the components of this test are not setup by the script and a level was provided instead.
  32. :return: None
  33. """
  34. import azlmbr.legacy.general as general
  35. from editor_python_test_tools.editor_entity_utils import EditorEntity
  36. from editor_python_test_tools.utils import Report
  37. from editor_python_test_tools.utils import TestHelper as helper
  38. from editor_python_test_tools.utils import Tracer
  39. # Constants
  40. FRAMES_IN_GAME_MODE = 200
  41. CLOTH_GEM_ERROR_WARNING_LIST = ["Cloth", "NvCloth", "ClothComponentMesh", "ActorClothSkinning", "ActorClothSkinning", "TangentSpaceHelper", "MeshAssetHelper", "ActorAssetHelper", "ClothDebugDisplay"]
  42. helper.init_idle()
  43. # 1) Load the level
  44. helper.open_level("NvCloth", "NvCloth_AddClothSimulationToActor")
  45. # 2) Start the Tracer to catch any errors and warnings
  46. with Tracer() as section_tracer:
  47. # 3) Enter game mode
  48. helper.enter_game_mode(Tests.enter_game_mode)
  49. # 4) Wait in game mode some frames to let cloth simulation run
  50. general.idle_wait_frames(FRAMES_IN_GAME_MODE)
  51. # 5) Verify there are no errors and warnings in the logs
  52. has_errors_or_warnings = False
  53. for error_msg in section_tracer.errors:
  54. if error_msg.window in CLOTH_GEM_ERROR_WARNING_LIST:
  55. has_errors_or_warnings = True
  56. Report.info(f"Cloth error found: {error_msg}")
  57. for warning_msg in section_tracer.warnings:
  58. if warning_msg.window in CLOTH_GEM_ERROR_WARNING_LIST:
  59. has_errors_or_warnings = True
  60. Report.info(f"Cloth warning found: {warning_msg}")
  61. Report.result(Tests.no_errors_and_warnings_found, not has_errors_or_warnings)
  62. # 6) Exit game mode
  63. helper.exit_game_mode(Tests.exit_game_mode)
  64. # 7) Close the editor
  65. helper.close_editor()
  66. if __name__ == "__main__":
  67. from editor_python_test_tools.utils import Report
  68. Report.start_test(NvCloth_AddClothSimulationToActor)