Physics/test axis aligned box shape configuration works #7378a (#5366)
* Safety commit before merging Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Moved from Physics to Terrain Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Changes from PR + AR fix Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Fixed another AR bug Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Fixed another AR compilation bug Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * More PR changes Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Added virtual destructor Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Added TestSuite_main_Optimized.py Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Changes from PR Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Further fixes for PR Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Fix to editor_test.py Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Testing prefab level Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Testing slice level Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Testing prefab level Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> * Disabled orefab loading for the time being. Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>monroegm-disable-blank-issue-2
parent
938899a495
commit
c35f74e9ce
@ -0,0 +1,24 @@
|
|||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||||
|
|
||||||
|
ly_add_pytest(
|
||||||
|
NAME AutomatedTesting::TerrainTests_Main
|
||||||
|
TEST_SUITE main
|
||||||
|
TEST_SERIAL
|
||||||
|
PATH ${CMAKE_CURRENT_LIST_DIR}/TestSuite_Main.py
|
||||||
|
RUNTIME_DEPENDENCIES
|
||||||
|
Legacy::Editor
|
||||||
|
AZ::AssetProcessor
|
||||||
|
AutomatedTesting.Assets
|
||||||
|
COMPONENT
|
||||||
|
Terrain
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
@ -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
|
||||||
|
"""
|
||||||
|
|
||||||
|
#fmt: off
|
||||||
|
class Tests():
|
||||||
|
create_test_entity = ("Entity created successfully", "Failed to create Entity")
|
||||||
|
add_axis_aligned_box_shape = ("Axis Aligned Box Shape component added", "Failed to add Axis Aligned Box Shape component")
|
||||||
|
add_terrain_collider = ("Terrain Physics Heightfield Collider component added", "Failed to add a Terrain Physics Heightfield Collider component")
|
||||||
|
box_dimensions_changed = ("Aabb dimensions changed successfully", "Failed change Aabb dimensions")
|
||||||
|
configuration_changed = ("Terrain size changed successfully", "Failed terrain size change")
|
||||||
|
no_errors_and_warnings_found = ("No errors and warnings found", "Found errors and warnings")
|
||||||
|
#fmt: on
|
||||||
|
|
||||||
|
def TerrainPhysicsCollider_ChangesSizeWithAxisAlignedBoxShapeChanges():
|
||||||
|
"""
|
||||||
|
Summary:
|
||||||
|
Test aspects of the TerrainHeightGradientList through the BehaviorContext and the Property Tree.
|
||||||
|
|
||||||
|
Test Steps:
|
||||||
|
Expected Behavior:
|
||||||
|
The Editor is stable there are no warnings or errors.
|
||||||
|
|
||||||
|
Test Steps:
|
||||||
|
1) Load the base level
|
||||||
|
2) Create test entity
|
||||||
|
3) Start the Tracer to catch any errors and warnings
|
||||||
|
4) Add the Axis Aligned Box Shape and Terrain Physics Heightfield Collider components
|
||||||
|
5) Change the Axis Aligned Box Shape dimensions
|
||||||
|
6) Check the Heightfield provider is returning the correct size
|
||||||
|
7) Verify there are no errors and warnings in the logs
|
||||||
|
|
||||||
|
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
|
||||||
|
from editor_python_test_tools.editor_entity_utils import EditorEntity
|
||||||
|
from editor_python_test_tools.utils import TestHelper as helper
|
||||||
|
from editor_python_test_tools.utils import Report, Tracer
|
||||||
|
import azlmbr.legacy.general as general
|
||||||
|
import azlmbr.physics as physics
|
||||||
|
import azlmbr.math as azmath
|
||||||
|
import azlmbr.bus as bus
|
||||||
|
import sys
|
||||||
|
import math
|
||||||
|
|
||||||
|
SET_BOX_X_SIZE = 5.0
|
||||||
|
SET_BOX_Y_SIZE = 6.0
|
||||||
|
EXPECTED_COLUMN_SIZE = SET_BOX_X_SIZE + 1
|
||||||
|
EXPECTED_ROW_SIZE = SET_BOX_Y_SIZE + 1
|
||||||
|
helper.init_idle()
|
||||||
|
|
||||||
|
# 1) Load the level
|
||||||
|
helper.open_level("", "Base")
|
||||||
|
|
||||||
|
# 2) Create test entity
|
||||||
|
test_entity = EditorEntity.create_editor_entity("TestEntity")
|
||||||
|
Report.result(Tests.create_test_entity, test_entity.id.IsValid())
|
||||||
|
|
||||||
|
# 3) Start the Tracer to catch any errors and warnings
|
||||||
|
with Tracer() as section_tracer:
|
||||||
|
# 4) Add the Axis Aligned Box Shape and Terrain Physics Heightfield Collider components
|
||||||
|
aaBoxShape_component = test_entity.add_component("Axis Aligned Box Shape")
|
||||||
|
Report.result(Tests.add_axis_aligned_box_shape, test_entity.has_component("Axis Aligned Box Shape"))
|
||||||
|
terrainPhysics_component = test_entity.add_component("Terrain Physics Heightfield Collider")
|
||||||
|
Report.result(Tests.add_terrain_collider, test_entity.has_component("Terrain Physics Heightfield Collider"))
|
||||||
|
|
||||||
|
# 5) Change the Axis Aligned Box Shape dimensions
|
||||||
|
aaBoxShape_component.set_component_property_value("Axis Aligned Box Shape|Box Configuration|Dimensions", azmath.Vector3(SET_BOX_X_SIZE, SET_BOX_Y_SIZE, 1.0))
|
||||||
|
add_check = aaBoxShape_component.get_component_property_value("Axis Aligned Box Shape|Box Configuration|Dimensions") == azmath.Vector3(SET_BOX_X_SIZE, SET_BOX_Y_SIZE, 1.0)
|
||||||
|
Report.result(Tests.box_dimensions_changed, add_check)
|
||||||
|
|
||||||
|
# 6) Check the Heightfield provider is returning the correct size
|
||||||
|
columns = physics.HeightfieldProviderRequestsBus(bus.Broadcast, "GetHeightfieldGridColumns")
|
||||||
|
rows = physics.HeightfieldProviderRequestsBus(bus.Broadcast, "GetHeightfieldGridRows")
|
||||||
|
Report.result(Tests.configuration_changed, math.isclose(columns, EXPECTED_COLUMN_SIZE) and math.isclose(rows, EXPECTED_ROW_SIZE))
|
||||||
|
|
||||||
|
helper.wait_for_condition(lambda: section_tracer.has_errors or section_tracer.has_asserts, 1.0)
|
||||||
|
for error_info in section_tracer.errors:
|
||||||
|
Report.info(f"Error: {error_info.filename} {error_info.function} | {error_info.message}")
|
||||||
|
for assert_info in section_tracer.asserts:
|
||||||
|
Report.info(f"Assert: {assert_info.filename} {assert_info.function} | {assert_info.message}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
from editor_python_test_tools.utils import Report
|
||||||
|
Report.start_test(TerrainPhysicsCollider_ChangesSizeWithAxisAlignedBoxShapeChanges)
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
"""
|
||||||
|
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
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# This suite consists of all test cases that are passing and have been verified.
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from ly_test_tools import LAUNCHERS
|
||||||
|
from ly_test_tools.o3de.editor_test import EditorTestSuite, EditorSingleTest
|
||||||
|
|
||||||
|
@pytest.mark.SUITE_main
|
||||||
|
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||||
|
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||||
|
class TestAutomation(EditorTestSuite):
|
||||||
|
#global_extra_cmdline_args=["--regset=/Amazon/Preferences/EnablePrefabSystem=true"]
|
||||||
|
|
||||||
|
class test_AxisAlignedBoxShape_ConfigurationWorks(EditorSingleTest):
|
||||||
|
from .EditorScripts import TerrainPhysicsCollider_ChangesSizeWithAxisAlignedBoxShapeChanges as test_module
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
"""
|
||||||
|
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
|
||||||
|
"""
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"ContainerEntity": {
|
||||||
|
"Id": "Entity_[1146574390643]",
|
||||||
|
"Name": "Level",
|
||||||
|
"Components": {
|
||||||
|
"Component_[10641544592923449938]": {
|
||||||
|
"$type": "EditorInspectorComponent",
|
||||||
|
"Id": 10641544592923449938
|
||||||
|
},
|
||||||
|
"Component_[12039882709170782873]": {
|
||||||
|
"$type": "EditorOnlyEntityComponent",
|
||||||
|
"Id": 12039882709170782873
|
||||||
|
},
|
||||||
|
"Component_[12265484671603697631]": {
|
||||||
|
"$type": "EditorPendingCompositionComponent",
|
||||||
|
"Id": 12265484671603697631
|
||||||
|
},
|
||||||
|
"Component_[14126657869720434043]": {
|
||||||
|
"$type": "EditorEntitySortComponent",
|
||||||
|
"Id": 14126657869720434043
|
||||||
|
},
|
||||||
|
"Component_[15230859088967841193]": {
|
||||||
|
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||||
|
"Id": 15230859088967841193,
|
||||||
|
"Parent Entity": ""
|
||||||
|
},
|
||||||
|
"Component_[16239496886950819870]": {
|
||||||
|
"$type": "EditorDisabledCompositionComponent",
|
||||||
|
"Id": 16239496886950819870
|
||||||
|
},
|
||||||
|
"Component_[5688118765544765547]": {
|
||||||
|
"$type": "EditorEntityIconComponent",
|
||||||
|
"Id": 5688118765544765547
|
||||||
|
},
|
||||||
|
"Component_[6545738857812235305]": {
|
||||||
|
"$type": "SelectionComponent",
|
||||||
|
"Id": 6545738857812235305
|
||||||
|
},
|
||||||
|
"Component_[7247035804068349658]": {
|
||||||
|
"$type": "EditorPrefabComponent",
|
||||||
|
"Id": 7247035804068349658
|
||||||
|
},
|
||||||
|
"Component_[9307224322037797205]": {
|
||||||
|
"$type": "EditorLockComponent",
|
||||||
|
"Id": 9307224322037797205
|
||||||
|
},
|
||||||
|
"Component_[9562516168917670048]": {
|
||||||
|
"$type": "EditorVisibilityComponent",
|
||||||
|
"Id": 9562516168917670048
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "HeightfieldProviderBus.h"
|
||||||
|
#include <AzCore/RTTI/BehaviorContext.h>
|
||||||
|
#include <AzCore/Math/Transform.h>
|
||||||
|
#include <AzCore/Serialization/SerializeContext.h>
|
||||||
|
|
||||||
|
namespace Physics
|
||||||
|
{
|
||||||
|
void HeightfieldProviderRequests::Reflect(AZ::ReflectContext* context)
|
||||||
|
{
|
||||||
|
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||||
|
{
|
||||||
|
behaviorContext->EBus<Physics::HeightfieldProviderRequestsBus>("HeightfieldProviderRequestsBus")
|
||||||
|
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||||
|
->Attribute(AZ::Script::Attributes::Module, "physics")
|
||||||
|
->Attribute(AZ::Script::Attributes::Category, "PhysX")
|
||||||
|
->Event("GetHeightfieldGridSpacing", &Physics::HeightfieldProviderRequestsBus::Events::GetHeightfieldGridSpacing)
|
||||||
|
->Event("GetHeightfieldAabb", &Physics::HeightfieldProviderRequestsBus::Events::GetHeightfieldAabb)
|
||||||
|
->Event("GetHeightfieldTransform", &Physics::HeightfieldProviderRequestsBus::Events::GetHeightfieldTransform)
|
||||||
|
->Event("GetMaterialList", &Physics::HeightfieldProviderRequestsBus::Events::GetMaterialList)
|
||||||
|
->Event("GetHeights", &Physics::HeightfieldProviderRequestsBus::Events::GetHeights)
|
||||||
|
->Event("GetHeightsAndMaterials", &Physics::HeightfieldProviderRequestsBus::Events::GetHeightsAndMaterials)
|
||||||
|
->Event("GetHeightfieldMinHeight", &Physics::HeightfieldProviderRequestsBus::Events::GetHeightfieldMinHeight)
|
||||||
|
->Event("GetHeightfieldMaxHeight", &Physics::HeightfieldProviderRequestsBus::Events::GetHeightfieldMaxHeight)
|
||||||
|
->Event("GetHeightfieldGridColumns", &Physics::HeightfieldProviderRequestsBus::Events::GetHeightfieldGridColumns)
|
||||||
|
->Event("GetHeightfieldGridRows", &Physics::HeightfieldProviderRequestsBus::Events::GetHeightfieldGridRows)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HeightMaterialPoint::Reflect(AZ::ReflectContext* context)
|
||||||
|
{
|
||||||
|
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||||
|
{
|
||||||
|
behaviorContext->Class<Physics::HeightMaterialPoint>()->Attribute(AZ::Script::Attributes::Category, "Physics");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Physics
|
||||||
Loading…
Reference in New Issue