Merge branch 'main' into transform-float-scale

This commit is contained in:
greerdv
2021-05-24 23:01:29 +01:00
33 changed files with 582 additions and 962 deletions
@@ -74,15 +74,23 @@ def add_component(componentName, entityId):
typeIdsList = editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeIdsByEntityType', [componentName],
entity.EntityType().Game)
typeNamesList = editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeNames', typeIdsList)
# If the type name comes back as empty, then it means componentName is invalid
if len(typeNamesList) != 1 or not typeNamesList[0]:
print('Unable to find component TypeId for {}'.format(componentName))
return None
componentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', entityId, typeIdsList)
if not componentOutcome.IsSuccess():
print('Failed to add {} component to entity'.format(typeNamesList[0]))
return None
isActive = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', componentOutcome.GetValue()[0])
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', entityId, typeIdsList[0])
if componentOutcome.IsSuccess() and isActive:
if isActive:
print('{} component was added to entity'.format(typeNamesList[0]))
elif componentOutcome.IsSuccess() and not isActive:
else:
print('{} component was added to entity, but the component is disabled'.format(typeNamesList[0]))
elif not componentOutcome.IsSuccess():
print('Failed to add {} component to entity'.format(typeNamesList[0]))
if hasComponent:
print('Entity has a {} component'.format(typeNamesList[0]))
return componentOutcome.GetValue()[0]
@@ -218,7 +226,8 @@ class Entity:
def add_component(self, component):
new_component = add_component(component, self.id)
self.components.append(new_component)
if new_component:
self.components.append(new_component)
def add_component_of_type(self, componentTypeId):
new_component = add_component_of_type(componentTypeId, self.id)
@@ -135,9 +135,7 @@ def run():
# Delete all existing entities initially
search_filter = azlmbr.entity.SearchFilter()
all_entities = entity.SearchBus(azlmbr.bus.Broadcast, "SearchEntities", search_filter)
general.idle_wait_frames(1)
editor.ToolsApplicationRequestBus(bus.Broadcast, "DeleteEntities", all_entities)
general.idle_wait_frames(1)
class ComponentTests:
"""Test launcher for each component."""
@@ -149,11 +147,9 @@ def run():
def run_component_tests(self):
# Run common and additional tests
entity_obj = create_entity_undo_redo_component_addition(self.component_name)
general.idle_wait(0.5)
# Enter/Exit game mode test
verify_enter_exit_game_mode(self.component_name)
general.idle_wait(0.5)
# Any additional tests are executed here
for test in self.additional_tests:
@@ -161,16 +157,13 @@ def run():
# Hide/Unhide entity test
verify_hide_unhide_entity(self.component_name, entity_obj)
general.idle_wait(0.5)
# Deletion/Undo/Redo test
verify_deletion_undo_redo(self.component_name, entity_obj)
general.idle_wait(0.5)
# DepthOfField Component
camera_entity = hydra.Entity("camera_entity")
camera_entity.create_entity(math.Vector3(512.0, 512.0, 34.0), ["Camera"])
general.idle_wait(0.5)
depth_of_field = "DepthOfField"
ComponentTests(
depth_of_field,
@@ -27,7 +27,6 @@ TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "atom_hydra_scripts")
@pytest.mark.parametrize("level", ["auto_test"])
class TestAtomEditorComponentsMain(object):
@pytest.mark.xfail(reason="Timing out sporadically, LYN-3956")
@pytest.mark.test_case_id(
"C32078130", # Display Mapper
"C32078129", # Light
@@ -10,11 +10,27 @@
#
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_FOUNDATION_TEST_SUPPORTED)
ly_add_pytest(
NAME AutomatedTesting::EditorTests_Main
TEST_SUITE main
TEST_SERIAL
PATH ${CMAKE_CURRENT_LIST_DIR}
PYTEST_MARKS "not SUITE_sandbox and not SUITE_periodic and not SUITE_benchmark"
TIMEOUT 1500
RUNTIME_DEPENDENCIES
Legacy::Editor
AZ::AssetProcessor
AutomatedTesting.Assets
COMPONENT
Editor
)
ly_add_pytest(
NAME AutomatedTesting::EditorTests_Periodic
TEST_SUITE periodic
TEST_SERIAL
PATH ${CMAKE_CURRENT_LIST_DIR}
PYTEST_MARKS "SUITE_periodic"
TIMEOUT 1500
RUNTIME_DEPENDENCIES
Legacy::Editor
@@ -0,0 +1,160 @@
"""
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.
"""
"""
C6351273: Create a new level
C6384955: Basic Workflow: Entity Manipulation in the Outliner
C16929880: Add Delete Components
C15167490: Save a level
C15167491: Export a level
"""
import os
import sys
from PySide2 import QtWidgets
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity as entity
import azlmbr.math as math
import azlmbr.paths
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
from editor_python_test_tools.editor_test_helper import EditorTestHelper
import editor_python_test_tools.pyside_utils as pyside_utils
import editor_python_test_tools.hydra_editor_utils as hydra
class TestBasicEditorWorkflows(EditorTestHelper):
def __init__(self):
EditorTestHelper.__init__(self, log_prefix="BasicEditorWorkflows_LevelEntityComponent", args=["level"])
@pyside_utils.wrap_async
async def run_test(self):
"""
Summary:
Open Lumberyard editor and check if basic Editor workflows are completable.
Expected Behavior:
- A new level can be created
- A new entity can be created
- Entity hierarchy can be adjusted
- Components can be added/removed/updated
- Level can be saved
- Level can be exported
Note:
- This test file must be called from the Lumberyard 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
"""
def find_entity_by_name(entity_name):
search_filter = entity.SearchFilter()
search_filter.names = [entity_name]
results = entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)
if len(results) > 0:
return results[0]
return None
# 1) Create a new level
editor_window = pyside_utils.get_editor_main_window()
new_level_action = pyside_utils.get_action_for_menu_path(editor_window, "File", "New Level")
pyside_utils.trigger_action_async(new_level_action)
active_modal_widget = await pyside_utils.wait_for_modal_widget()
new_level_dlg = active_modal_widget.findChild(QtWidgets.QWidget, "CNewLevelDialog")
if new_level_dlg:
if new_level_dlg.windowTitle() == "New Level":
self.log("New Level dialog opened")
grp_box = new_level_dlg.findChild(QtWidgets.QGroupBox, "STATIC_GROUP1")
level_name = grp_box.findChild(QtWidgets.QLineEdit, "LEVEL")
level_name.setText(self.args["level"])
level_folders = grp_box.findChild(QtWidgets.QComboBox, "LEVEL_FOLDERS")
level_folders.setCurrentText("Levels/")
button_box = new_level_dlg.findChild(QtWidgets.QDialogButtonBox, "buttonBox")
button_box.button(QtWidgets.QDialogButtonBox.Ok).click()
# Verify new level was created successfully
level_create_success = await pyside_utils.wait_for_condition(lambda: editor.EditorToolsApplicationRequestBus(
bus.Broadcast, "GetCurrentLevelName") == self.args["level"], 5.0)
self.test_success = level_create_success
self.log(f"Create and load new level: {level_create_success}")
# Execute EditorTestHelper setup since level was created outside of EditorTestHelper's methods
self.test_success = self.test_success and self.after_level_load()
# 2) Delete existing entities, and create and manipulate new entities via Entity Inspector
search_filter = azlmbr.entity.SearchFilter()
all_entities = entity.SearchBus(azlmbr.bus.Broadcast, "SearchEntities", search_filter)
editor.ToolsApplicationRequestBus(bus.Broadcast, "DeleteEntities", all_entities)
entity_outliner_widget = editor_window.findChild(QtWidgets.QWidget, "OutlinerWidgetUI")
outliner_object_list = entity_outliner_widget.findChild(QtWidgets.QWidget, "m_objectList_Contents")
outliner_tree = outliner_object_list.findChild(QtWidgets.QWidget, "m_objectTree")
await pyside_utils.trigger_context_menu_entry(outliner_tree, "Create entity")
# Find the new entity
parent_entity_id = find_entity_by_name("Entity1")
parent_entity_success = await pyside_utils.wait_for_condition(lambda: parent_entity_id is not None, 5.0)
self.test_success = self.test_success and parent_entity_success
self.log(f"New entity creation: {parent_entity_success}")
# TODO: Replace Hydra call to creates child entity and add components with context menu triggering - LYN-3951
# Create a new child entity
child_entity = hydra.Entity("Child")
entity_position = math.Vector3(0.0, 0.0, 0.0)
components_to_add = []
child_entity.create_entity(entity_position, components_to_add, parent_entity_id)
# Verify entity hierarchy
child_entity.get_parent_info()
self.test_success = self.test_success and child_entity.parent_id == parent_entity_id
self.log(f"Create entity hierarchy: {child_entity.parent_id == parent_entity_id}")
# 3) Add/configure a component on an entity
# Add component and verify success
child_entity.add_component("Box Shape")
component_add_success = self.wait_for_condition(lambda: hydra.has_components(child_entity.id, ["Box Shape"]), 5.0)
self.test_success = self.test_success and component_add_success
self.log(f"Add component: {component_add_success}")
# Update the component
dimensions_to_set = math.Vector3(16.0, 16.0, 16.0)
child_entity.get_set_test(0, "Box Shape|Box Configuration|Dimensions", dimensions_to_set)
box_shape_dimensions = hydra.get_component_property_value(child_entity.components[0], "Box Shape|Box Configuration|Dimensions")
self.test_success = self.test_success and box_shape_dimensions == dimensions_to_set
self.log(f"Component update: {box_shape_dimensions == dimensions_to_set}")
# Remove the component
child_entity.remove_component("Box Shape")
component_rem_success = self.wait_for_condition(lambda: not hydra.has_components(child_entity.id, ["Box Shape"]),
5.0)
self.test_success = self.test_success and component_rem_success
self.log(f"Remove component: {component_rem_success}")
# 4) Save the level
save_level_action = pyside_utils.get_action_for_menu_path(editor_window, "File", "Save")
pyside_utils.trigger_action_async(save_level_action)
# 5) Export the level
export_action = pyside_utils.get_action_for_menu_path(editor_window, "Game", "Export to Engine")
pyside_utils.trigger_action_async(export_action)
level_pak_file = os.path.join(
"AutomatedTesting", "Levels", self.args["level"], "level.pak"
)
export_success = self.wait_for_condition(lambda: os.path.exists(level_pak_file), 5.0)
self.test_success = self.test_success and export_success
self.log(f"Save and Export: {export_success}")
test = TestBasicEditorWorkflows()
test.run()
@@ -0,0 +1,63 @@
"""
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.
"""
import os
import pytest
# Bail on the test if ly_test_tools doesn't exist.
pytest.importorskip('ly_test_tools')
import ly_test_tools.environment.file_system as file_system
import editor_python_test_tools.hydra_test_utils as hydra
test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts")
log_monitor_timeout = 180
@pytest.mark.parametrize('project', ['AutomatedTesting'])
@pytest.mark.parametrize('level', ['tmp_level'])
@pytest.mark.usefixtures("automatic_process_killer")
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
class TestBasicEditorWorkflows(object):
@pytest.fixture(autouse=True)
def setup_teardown(self, request, workspace, project, level):
def teardown():
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
request.addfinalizer(teardown)
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True)
@pytest.mark.test_case_id("C6351273", "C6384955", "C16929880", "C15167490", "C15167491")
@pytest.mark.SUITE_main
def test_BasicEditorWorkflows_LevelEntityComponentCRUD(self, request, editor, level, launcher_platform):
expected_lines = [
"Create and load new level: True",
"New entity creation: True",
"Create entity hierarchy: True",
"Add component: True",
"Component update: True",
"Remove component: True",
"Save and Export: True",
"BasicEditorWorkflows_LevelEntityComponent: result=SUCCESS",
]
hydra.launch_and_validate_results(
request,
test_directory,
editor,
"BasicEditorWorkflows_LevelEntityComponentCRUD.py",
expected_lines,
cfg_args=[level],
timeout=log_monitor_timeout,
auto_test_mode=False
)
@@ -60,6 +60,7 @@ namespace AzFramework
virtual void DrawTrianglesIndexed(const AZStd::vector<AZ::Vector3>& vertices, const AZStd::vector<AZ::u32>& indices, const AZ::Color& color) { (void)vertices; (void)indices, (void)color; }
virtual void DrawWireBox(const AZ::Vector3& min, const AZ::Vector3& max) { (void)min; (void)max; }
virtual void DrawSolidBox(const AZ::Vector3& min, const AZ::Vector3& max) { (void)min; (void)max; }
virtual void DrawWireOBB(const AZ::Vector3& center, const AZ::Vector3& axisX, const AZ::Vector3& axisY, const AZ::Vector3& axisZ, const AZ::Vector3& halfExtents) { (void)center; (void)axisX; (void)axisY; (void)axisZ; (void)halfExtents; }
virtual void DrawSolidOBB(const AZ::Vector3& center, const AZ::Vector3& axisX, const AZ::Vector3& axisY, const AZ::Vector3& axisZ, const AZ::Vector3& halfExtents) { (void)center; (void)axisX; (void)axisY; (void)axisZ; (void)halfExtents; }
virtual void DrawPoint(const AZ::Vector3& p, int nSize = 1) { (void)p; (void)nSize; }
virtual void DrawLine(const AZ::Vector3& p1, const AZ::Vector3& p2) { (void)p1; (void)p2; }
@@ -70,18 +71,15 @@ namespace AzFramework
virtual void DrawLine2d(const AZ::Vector2& p1, const AZ::Vector2& p2, float z) { (void)p1; (void)p2; (void)z; }
virtual void DrawLine2dGradient(const AZ::Vector2& p1, const AZ::Vector2& p2, float z, const AZ::Vector4& firstColor, const AZ::Vector4& secondColor) { (void)p1; (void)p2; (void)z; (void)firstColor; (void)secondColor; }
virtual void DrawWireCircle2d(const AZ::Vector2& center, float radius, float z) { (void)center; (void)radius; (void)z; }
virtual void DrawTerrainCircle(const AZ::Vector3& worldPos, float radius, float height) { (void)worldPos; (void)radius; (void)height; }
virtual void DrawTerrainCircle(const AZ::Vector3& center, float radius, float angle1, float angle2, float height) { (void)center; (void)radius; (void)angle1; (void)angle2; (void)height; }
virtual void DrawArc(const AZ::Vector3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, int referenceAxis = 2) { (void)pos; (void)radius; (void)startAngleDegrees; (void)sweepAngleDegrees; (void)angularStepDegrees; (void)referenceAxis; }
virtual void DrawArc(const AZ::Vector3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, const AZ::Vector3& fixedAxis) { (void)pos; (void)radius; (void)startAngleDegrees; (void)sweepAngleDegrees; (void)angularStepDegrees; (void)fixedAxis; }
virtual void DrawCircle(const AZ::Vector3& pos, float radius, int nUnchangedAxis = 2 /*z axis*/) { (void)pos; (void)radius; (void)nUnchangedAxis; }
virtual void DrawHalfDottedCircle(const AZ::Vector3& pos, float radius, const AZ::Vector3& viewPos, int nUnchangedAxis = 2 /*z axis*/) { (void)pos; (void)radius; (void)viewPos; (void)nUnchangedAxis; }
virtual void DrawCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height, bool drawShaded = true) { (void)pos; (void)dir; (void)radius; (void)height; (void)drawShaded; }
virtual void DrawWireCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height) { (void)pos; (void)dir; (void)radius; (void)height; }
virtual void DrawSolidCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height, bool drawShaded = true) { (void)pos; (void)dir; (void)radius; (void)height; (void)drawShaded; }
virtual void DrawWireCylinder(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float height) { (void)center; (void)axis; (void)radius; (void)height; }
virtual void DrawSolidCylinder(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float height, bool drawShaded = true) { (void)center; (void)axis; (void)radius; (void)height; (void)drawShaded; }
virtual void DrawWireCapsule(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float heightStraightSection) { (void)center; (void)axis; (void)radius; (void)heightStraightSection; }
virtual void DrawTerrainRect(float x1, float y1, float x2, float y2, float height) { (void)x1; (void)y1; (void)x2; (void)y2; (void)height; }
virtual void DrawTerrainLine(AZ::Vector3 worldPos1, AZ::Vector3 worldPos2) { (void)worldPos1; (void)worldPos2; }
virtual void DrawWireSphere(const AZ::Vector3& pos, float radius) { (void)pos; (void)radius; }
virtual void DrawWireSphere(const AZ::Vector3& pos, const AZ::Vector3 radius) { (void)pos; (void)radius; }
virtual void DrawWireDisk(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius) { (void)pos; (void)dir; (void)radius; }
@@ -91,11 +89,8 @@ namespace AzFramework
virtual void DrawTextLabel(const AZ::Vector3& pos, float size, const char* text, const bool bCenter = false, int srcOffsetX = 0, int srcOffsetY = 0) { (void)pos; (void)size; (void)text; (void)bCenter; (void)srcOffsetX; (void)srcOffsetY; }
virtual void Draw2dTextLabel(float x, float y, float size, const char* text, bool bCenter = false) { (void)x; (void)y; (void)size; (void)text; (void)bCenter; }
virtual void DrawTextOn2DBox(const AZ::Vector3& pos, const char* text, float textScale, const AZ::Vector4& TextColor, const AZ::Vector4& TextBackColor) { (void)pos; (void)text; (void)textScale; (void)TextColor; (void)TextBackColor; }
virtual void DrawTextureLabel(ITexture* texture, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) { (void)texture; (void)pos; (void)sizeX; (void)sizeY; (void)texIconFlags; }
virtual void DrawTextureLabel(int textureId, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) { (void)textureId; (void)pos; (void)sizeX; (void)sizeY; (void)texIconFlags; }
virtual void SetLineWidth(float width) { (void)width; }
virtual bool IsVisible(const AZ::Aabb& bounds) { (void)bounds; return false; }
virtual int SetFillMode(int nFillMode) { (void)nFillMode; return 0; }
virtual float GetLineWidth() { return 0.0f; }
virtual float GetAspectRatio() { return 0.0f; }
virtual void DepthTestOff() {}
@@ -123,8 +123,9 @@ namespace AzFramework
OctreeNode* insertCheck = this;
while (insertCheck != nullptr)
{
if (AZ::ShapeIntersection::Contains(insertCheck->m_bounds, boundingVolume))
if (AZ::ShapeIntersection::Contains(insertCheck->m_bounds, boundingVolume) || !insertCheck->m_parent)
{
// Insert here if the entry is fully contained or if we've reached the root node
return insertCheck->Insert(octreeScene, entry);
}
insertCheck = insertCheck->m_parent;
@@ -447,17 +447,14 @@ namespace AzToolsFramework
m_radius * viewScale);
debugDisplay.SetColor(ViewColor(manipulatorState.m_mouseOver, m_color, m_mouseOverColor).GetAsVector4());
// show wireframe if the axis has been corrected/flipped
// note: please see IRenderAuxGeom.h for the definition of e_FillModeWireframe and e_FillModeSolid.
// it is not possible to include IRenderAuxGeom from here and we also don't want to introduce that dependency.
// these legacy enums should be wrapped so set SetFillMode can be used in a type safe way, until then,
// use the values directly until the API has been updated.
const AZ::u32 prevFillMode = debugDisplay.SetFillMode(
m_shouldCorrect ? /*e_FillModeWireframe =*/ 0x1 << 26 : /*e_FillModeSolid =*/ 0);
debugDisplay.DrawCone(coneBound.m_base, coneBound.m_axis, coneBound.m_radius, coneBound.m_height, false);
debugDisplay.SetFillMode(prevFillMode);
if (m_shouldCorrect)
{
debugDisplay.DrawWireCone(coneBound.m_base, coneBound.m_axis, coneBound.m_radius, coneBound.m_height);
}
else
{
debugDisplay.DrawSolidCone(coneBound.m_base, coneBound.m_axis, coneBound.m_radius, coneBound.m_height, false);
}
RefreshBoundInternal(managerId, manipulatorId, coneBound);
}
@@ -140,8 +140,7 @@ namespace AzToolsFramework
ProductAssetBrowserEntry* productEntry = static_cast<ProductAssetBrowserEntry*>(childEntry);
AZStd::string assetName;
AzFramework::StringFunc::Path::GetFileName(productEntry->GetFullPath().c_str(), assetName);
m_assets.push_back({
assetName, productEntry->GetFullPath(), productEntry->GetAssetId()
m_assets.push_back({ productEntry->GetName(), productEntry->GetFullPath(), productEntry->GetAssetId()
});
}
@@ -233,9 +233,9 @@ namespace AzToolsFramework
}();
debugDisplay.SetColor(iconHighlight);
debugDisplay.DrawTextureLabel(
iconTextureId, entityPosition, iconSize, iconSize,
/*DisplayContext::ETextureIconFlags::TEXICON_ON_TOP=*/ 0x0008);
// debugDisplay.DrawTextureLabel(
// iconTextureId, entityPosition, iconSize, iconSize,
// /*DisplayContext::ETextureIconFlags::TEXICON_ON_TOP=*/ 0x0008);
}
}
}
+77 -18
View File
@@ -14,6 +14,7 @@
#include <AzCore/Console/IConsole.h>
#include <AzCore/Console/Console.h>
#include <AzCore/Name/NameDictionary.h>
#include <AzCore/Console/IConsole.h>
#include <AzFramework/Visibility/OctreeSystemComponent.h>
#include <random>
@@ -94,6 +95,20 @@ namespace UnitTest
AZ::Console* m_console;
};
void ValidateEntryCountEqualsExpectedCount(const IVisibilityScene* visScene, uint32_t expectedEntryCount)
{
// InsertOrUpdateEntry assumes that updating an existing entry won't change the count
// so it doesn't modify the counter used by GetEntryCount.
// If an entry is removed from the octree as an unintended side effect of updating an existing entry,
// GetEntryCount can't be relied upon to report the actual entry count.
// So manually count the entries when using the entry count for validation.
uint32_t manualEntryCount = 0;
visScene->EnumerateNoCull([&manualEntryCount](const AzFramework::IVisibilityScene::NodeData& nodeData) { manualEntryCount += nodeData.m_entries.size(); });
EXPECT_EQ(manualEntryCount, expectedEntryCount);
EXPECT_EQ(visScene->GetEntryCount(), expectedEntryCount);
}
TEST_F(OctreeTests, InsertDeleteSingleEntry)
{
AzFramework::VisibilityEntry visEntry;
@@ -102,11 +117,11 @@ namespace UnitTest
m_octreeScene->InsertOrUpdateEntry(visEntry);
EXPECT_TRUE(visEntry.m_internalNode != nullptr);
EXPECT_TRUE(visEntry.m_internalNodeIndex == 0);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 1);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 1);
m_octreeScene->RemoveEntry(visEntry);
EXPECT_TRUE(visEntry.m_internalNode == nullptr);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 0);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 0);
EXPECT_TRUE(true); //TEST
}
@@ -121,34 +136,34 @@ namespace UnitTest
m_octreeScene->InsertOrUpdateEntry(visEntry[0]);
EXPECT_TRUE(visEntry[0].m_internalNode != nullptr);
EXPECT_TRUE(visEntry[0].m_internalNodeIndex == 0);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 1);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 1);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1);
m_octreeScene->InsertOrUpdateEntry(visEntry[1]); // This should force a split of the root node
EXPECT_TRUE(visEntry[1].m_internalNode != nullptr);
EXPECT_TRUE(visEntry[1].m_internalNodeIndex == 0);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 2);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 2);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1 + m_octreeScene->GetChildNodeCount());
m_octreeScene->InsertOrUpdateEntry(visEntry[2]); // This should force a split of the roots +/+/+ child node
EXPECT_TRUE(visEntry[2].m_internalNode != nullptr);
EXPECT_TRUE(visEntry[2].m_internalNodeIndex == 0);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 3);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 3);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1 + (2 * m_octreeScene->GetChildNodeCount()));
m_octreeScene->RemoveEntry(visEntry[2]);
EXPECT_TRUE(visEntry[2].m_internalNode == nullptr);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 2);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 2);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1 + m_octreeScene->GetChildNodeCount());
m_octreeScene->RemoveEntry(visEntry[1]);
EXPECT_TRUE(visEntry[1].m_internalNode == nullptr);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 1);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 1);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1);
m_octreeScene->RemoveEntry(visEntry[0]);
EXPECT_TRUE(visEntry[0].m_internalNode == nullptr);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 0);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 0);
}
TEST_F(OctreeTests, UpdateSingleEntry)
@@ -159,19 +174,19 @@ namespace UnitTest
m_octreeScene->InsertOrUpdateEntry(visEntry);
EXPECT_TRUE(visEntry.m_internalNode != nullptr);
EXPECT_TRUE(visEntry.m_internalNodeIndex == 0);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 1);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 1);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1);
visEntry.m_boundingVolume = AZ::Aabb::CreateFromMinMax(AZ::Vector3(-0.5f), AZ::Vector3(0.5f));
m_octreeScene->InsertOrUpdateEntry(visEntry);
EXPECT_TRUE(visEntry.m_internalNode != nullptr);
EXPECT_TRUE(visEntry.m_internalNodeIndex == 0);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 1);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 1);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1);
m_octreeScene->RemoveEntry(visEntry);
EXPECT_TRUE(visEntry.m_internalNode == nullptr);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 0);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 0);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1);
}
@@ -185,19 +200,19 @@ namespace UnitTest
m_octreeScene->InsertOrUpdateEntry(visEntry[0]);
EXPECT_TRUE(visEntry[0].m_internalNode != nullptr);
EXPECT_TRUE(visEntry[0].m_internalNodeIndex == 0);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 1);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 1);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1);
m_octreeScene->InsertOrUpdateEntry(visEntry[1]); // This should force a split of the root node
EXPECT_TRUE(visEntry[1].m_internalNode != nullptr);
EXPECT_TRUE(visEntry[1].m_internalNodeIndex == 0);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 2);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 2);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1 + m_octreeScene->GetChildNodeCount());
m_octreeScene->InsertOrUpdateEntry(visEntry[2]); // This should force a split of the roots +/+/+ child node
EXPECT_TRUE(visEntry[2].m_internalNode != nullptr);
EXPECT_TRUE(visEntry[2].m_internalNodeIndex == 0);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 3);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 3);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1 + (2 * m_octreeScene->GetChildNodeCount()));
visEntry[1].m_boundingVolume = AZ::Aabb::CreateFromMinMax(AZ::Vector3(-0.9f), AZ::Vector3(-0.6f));
@@ -206,22 +221,22 @@ namespace UnitTest
m_octreeScene->InsertOrUpdateEntry(visEntry[0]);
m_octreeScene->InsertOrUpdateEntry(visEntry[1]);
m_octreeScene->InsertOrUpdateEntry(visEntry[2]);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 3);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 3);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1 + (2 * m_octreeScene->GetChildNodeCount()));
m_octreeScene->RemoveEntry(visEntry[2]);
EXPECT_TRUE(visEntry[2].m_internalNode == nullptr);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 2);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 2);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1 + m_octreeScene->GetChildNodeCount());
m_octreeScene->RemoveEntry(visEntry[1]);
EXPECT_TRUE(visEntry[1].m_internalNode == nullptr);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 1);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 1);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1);
m_octreeScene->RemoveEntry(visEntry[0]);
EXPECT_TRUE(visEntry[0].m_internalNode == nullptr);
EXPECT_TRUE(m_octreeScene->GetEntryCount() == 0);
ValidateEntryCountEqualsExpectedCount(m_octreeScene, 0);
EXPECT_TRUE(m_octreeScene->GetNodeCount() == 1);
}
@@ -365,4 +380,48 @@ namespace UnitTest
AZ::Frustum bound3 = AZ::Frustum(AZ::ViewFrustumAttributes(frustumTransform, 1.0f, 2.0f * atanf(0.5f), 2.6f, 2.9f));
EnumerateMultipleEntriesHelper(m_octreeScene, bound1, bound2, bound3);
}
TEST_F(OctreeTests, InsertOrUpdateEntry_OverFillRootNodeWithLargeEntries_EntriesAreNotLost)
{
// Validate that the octree works if you exceed the max entry count with large entries,
// which will overfill the root node since they can't be distributed to child nodes
// Get the max extents and entries-per-node for the octree
AZ::IConsole* console = AZ::Interface<AZ::IConsole>::Get();
EXPECT_TRUE(console);
float maxExtents = 0.0f;
AZ::GetValueResult getCvarResult = console->GetCvarValue("bg_octreeMaxWorldExtents", maxExtents);
EXPECT_EQ(getCvarResult, AZ::GetValueResult::Success);
uint32_t maxEntriesPerNode = 0;
getCvarResult = console->GetCvarValue("bg_octreeNodeMaxEntries", maxEntriesPerNode);
EXPECT_EQ(getCvarResult, AZ::GetValueResult::Success);
// Create root entries that would exceed the size of the root node
AZ::Aabb exceedMaxExtents = AZ::Aabb::CreateFromMinMax(AZ::Vector3(-maxExtents - 1.0f), AZ::Vector3(maxExtents + 1.0f));
uint32_t exceedMaxEntriesPerNode = maxEntriesPerNode + 1;
AzFramework::VisibilityEntry visEntry;
visEntry.m_boundingVolume = exceedMaxExtents;
AZStd::vector<AzFramework::VisibilityEntry> visEntries(exceedMaxEntriesPerNode, visEntry);
// Insert them all into the scene
for (AzFramework::VisibilityEntry& entry : visEntries)
{
m_octreeScene->InsertOrUpdateEntry(entry);
}
// Expect all the entries to be in the scene
ValidateEntryCountEqualsExpectedCount(m_octreeScene, visEntries.size());
// Update them, without making any actual changes
for (AzFramework::VisibilityEntry& entry : visEntries)
{
m_octreeScene->InsertOrUpdateEntry(entry);
}
// Expect all the entries to be in the scene
ValidateEntryCountEqualsExpectedCount(m_octreeScene, visEntries.size());
}
}
@@ -382,11 +382,6 @@ void SandboxIntegrationManager::Teardown()
{
AzToolsFramework::Layers::EditorLayerComponentNotificationBus::Handler::BusDisconnect();
AzFramework::DisplayContextRequestBus::Handler::BusDisconnect();
if( m_debugDisplayBusImplementationActive)
{
AzFramework::DebugDisplayRequestBus::Handler::BusDisconnect();
m_debugDisplayBusImplementationActive = false;
}
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
@@ -2041,678 +2036,6 @@ void SandboxIntegrationManager::BrowseForAssets(AssetSelectionModel& selection)
AssetBrowserComponentRequestBus::Broadcast(&AssetBrowserComponentRequests::PickAssets, selection, GetMainWindow());
}
void SandboxIntegrationManager::SetColor(float r, float g, float b, float a)
{
if (m_dc)
{
m_dc->SetColor(Vec3(r, g, b), a);
}
}
void SandboxIntegrationManager::SetColor(const AZ::Color& color)
{
if (m_dc)
{
m_dc->SetColor(AZColorToLYColorF(color));
}
}
void SandboxIntegrationManager::SetColor(const AZ::Vector4& color)
{
if (m_dc)
{
m_dc->SetColor(AZVec3ToLYVec3(color.GetAsVector3()), color.GetW());
}
}
void SandboxIntegrationManager::SetAlpha(float a)
{
if (m_dc)
{
m_dc->SetAlpha(a);
}
}
void SandboxIntegrationManager::DrawQuad(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector3& p3, const AZ::Vector3& p4)
{
if (m_dc)
{
m_dc->DrawQuad(
AZVec3ToLYVec3(p1),
AZVec3ToLYVec3(p2),
AZVec3ToLYVec3(p3),
AZVec3ToLYVec3(p4));
}
}
void SandboxIntegrationManager::DrawQuad(float width, float height)
{
if (m_dc)
{
m_dc->DrawQuad(width, height);
}
}
void SandboxIntegrationManager::DrawWireQuad(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector3& p3, const AZ::Vector3& p4)
{
if (m_dc)
{
m_dc->DrawWireQuad(
AZVec3ToLYVec3(p1),
AZVec3ToLYVec3(p2),
AZVec3ToLYVec3(p3),
AZVec3ToLYVec3(p4));
}
}
void SandboxIntegrationManager::DrawWireQuad(float width, float height)
{
if (m_dc)
{
m_dc->DrawWireQuad(width, height);
}
}
void SandboxIntegrationManager::DrawQuadGradient(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector3& p3, const AZ::Vector3& p4, const AZ::Vector4& firstColor, const AZ::Vector4& secondColor)
{
if (m_dc)
{
m_dc->DrawQuadGradient(
AZVec3ToLYVec3(p1),
AZVec3ToLYVec3(p2),
AZVec3ToLYVec3(p3),
AZVec3ToLYVec3(p4),
ColorF(AZVec3ToLYVec3(firstColor.GetAsVector3()), firstColor.GetW()),
ColorF(AZVec3ToLYVec3(secondColor.GetAsVector3()), secondColor.GetW()));
}
}
void SandboxIntegrationManager::DrawTri(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector3& p3)
{
if (m_dc)
{
m_dc->DrawTri(
AZVec3ToLYVec3(p1),
AZVec3ToLYVec3(p2),
AZVec3ToLYVec3(p3));
}
}
void SandboxIntegrationManager::DrawTriangles(const AZStd::vector<AZ::Vector3>& vertices, const AZ::Color& color)
{
if (m_dc)
{
// transform to world space
const auto vecTransform = [this](const AZ::Vector3& vec)
{
return m_dc->GetMatrix() * AZVec3ToLYVec3(vec);
};
AZStd::vector<Vec3> cryVertices;
cryVertices.reserve(vertices.size());
AZStd::transform(vertices.begin(), vertices.end(), AZStd::back_inserter(cryVertices), vecTransform);
m_dc->DrawTriangles(
cryVertices,
AZColorToLYColorF(color));
}
}
void SandboxIntegrationManager::DrawTrianglesIndexed(const AZStd::vector<AZ::Vector3>& vertices, const AZStd::vector<AZ::u32>& indices, const AZ::Color& color)
{
if (m_dc)
{
// transform to world space
const auto vecTransform = [this](const AZ::Vector3& vec)
{
return m_dc->GetMatrix() * AZVec3ToLYVec3(vec);
};
AZStd::vector<Vec3> cryVertices;
cryVertices.reserve(vertices.size());
AZStd::transform(vertices.begin(), vertices.end(), AZStd::back_inserter(cryVertices), vecTransform);
m_dc->DrawTrianglesIndexed(
cryVertices,
indices,
AZColorToLYColorF(color));
}
}
void SandboxIntegrationManager::DrawWireBox(const AZ::Vector3& min, const AZ::Vector3& max)
{
if (m_dc)
{
m_dc->DrawWireBox(
AZVec3ToLYVec3(min),
AZVec3ToLYVec3(max));
}
}
void SandboxIntegrationManager::DrawSolidBox(const AZ::Vector3& min, const AZ::Vector3& max)
{
if (m_dc)
{
m_dc->DrawSolidBox(
AZVec3ToLYVec3(min),
AZVec3ToLYVec3(max));
}
}
void SandboxIntegrationManager::DrawSolidOBB(const AZ::Vector3& center, const AZ::Vector3& axisX, const AZ::Vector3& axisY, const AZ::Vector3& axisZ, const AZ::Vector3& halfExtents)
{
if (m_dc)
{
m_dc->DrawSolidOBB(AZVec3ToLYVec3(center), AZVec3ToLYVec3(axisX), AZVec3ToLYVec3(axisY), AZVec3ToLYVec3(axisZ), AZVec3ToLYVec3(halfExtents));
}
}
void SandboxIntegrationManager::DrawPoint(const AZ::Vector3& p, int nSize)
{
if (m_dc)
{
m_dc->DrawPoint(AZVec3ToLYVec3(p), nSize);
}
}
void SandboxIntegrationManager::DrawLine(const AZ::Vector3& p1, const AZ::Vector3& p2)
{
if (m_dc)
{
m_dc->DrawLine(
AZVec3ToLYVec3(p1),
AZVec3ToLYVec3(p2));
}
}
void SandboxIntegrationManager::DrawLine(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector4& col1, const AZ::Vector4& col2)
{
if (m_dc)
{
m_dc->DrawLine(
AZVec3ToLYVec3(p1),
AZVec3ToLYVec3(p2),
ColorF(AZVec3ToLYVec3(col1.GetAsVector3()), col1.GetW()),
ColorF(AZVec3ToLYVec3(col2.GetAsVector3()), col2.GetW()));
}
}
void SandboxIntegrationManager::DrawLines(const AZStd::vector<AZ::Vector3>& lines, const AZ::Color& color)
{
if (m_dc)
{
// transform to world space
const auto vecTransform = [this](const AZ::Vector3& vec)
{
return m_dc->GetMatrix() * AZVec3ToLYVec3(vec);
};
AZStd::vector<Vec3> cryLines;
cryLines.reserve(cryLines.size());
AZStd::transform(lines.begin(), lines.end(), AZStd::back_inserter(cryLines), vecTransform);
m_dc->DrawLines(cryLines, AZColorToLYColorF(color));
}
}
void SandboxIntegrationManager::DrawPolyLine(const AZ::Vector3* pnts, int numPoints, bool cycled)
{
if (m_dc)
{
Vec3* points = new Vec3[numPoints];
for (int i = 0; i < numPoints; ++i)
{
points[i] = AZVec3ToLYVec3(pnts[i]);
}
m_dc->DrawPolyLine(points, numPoints, cycled);
delete[] points;
}
}
void SandboxIntegrationManager::DrawWireQuad2d(const AZ::Vector2& p1, const AZ::Vector2& p2, float z)
{
if (m_dc)
{
m_dc->DrawWireQuad2d(
QPoint(static_cast<int>(p1.GetX()), static_cast<int>(p1.GetY())),
QPoint(static_cast<int>(p2.GetX()), static_cast<int>(p2.GetY())),
z);
}
}
void SandboxIntegrationManager::DrawLine2d(const AZ::Vector2& p1, const AZ::Vector2& p2, float z)
{
if (m_dc)
{
m_dc->DrawLine2d(
QPoint(static_cast<int>(p1.GetX()), static_cast<int>(p1.GetY())),
QPoint(static_cast<int>(p2.GetX()), static_cast<int>(p2.GetY())),
z);
}
}
void SandboxIntegrationManager::DrawLine2dGradient(const AZ::Vector2& p1, const AZ::Vector2& p2, float z, const AZ::Vector4& firstColor, const AZ::Vector4& secondColor)
{
if (m_dc)
{
m_dc->DrawLine2dGradient(
QPoint(static_cast<int>(p1.GetX()), static_cast<int>(p1.GetY())),
QPoint(static_cast<int>(p2.GetX()), static_cast<int>(p2.GetY())),
z,
ColorF(AZVec3ToLYVec3(firstColor.GetAsVector3()), firstColor.GetW()),
ColorF(AZVec3ToLYVec3(secondColor.GetAsVector3()), secondColor.GetW()));
}
}
void SandboxIntegrationManager::DrawWireCircle2d(const AZ::Vector2& center, float radius, float z)
{
if (m_dc)
{
m_dc->DrawWireCircle2d(
QPoint(static_cast<int>(center.GetX()), static_cast<int>(center.GetY())),
radius, z);
}
}
void SandboxIntegrationManager::DrawTerrainCircle(const AZ::Vector3& worldPos, float radius, float height)
{
if (m_dc)
{
m_dc->DrawTerrainCircle(
AZVec3ToLYVec3(worldPos), radius, height);
}
}
void SandboxIntegrationManager::DrawTerrainCircle(const AZ::Vector3& center, float radius, float angle1, float angle2, float height)
{
if (m_dc)
{
m_dc->DrawTerrainCircle(
AZVec3ToLYVec3(center), radius, angle1, angle2, height);
}
}
void SandboxIntegrationManager::DrawArc(const AZ::Vector3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, int referenceAxis)
{
if (m_dc)
{
m_dc->DrawArc(
AZVec3ToLYVec3(pos),
radius,
startAngleDegrees,
sweepAngleDegrees,
angularStepDegrees,
referenceAxis);
}
}
void SandboxIntegrationManager::DrawArc(const AZ::Vector3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, const AZ::Vector3& fixedAxis)
{
if (m_dc)
{
m_dc->DrawArc(
AZVec3ToLYVec3(pos),
radius,
startAngleDegrees,
sweepAngleDegrees,
angularStepDegrees,
AZVec3ToLYVec3(fixedAxis));
}
}
void SandboxIntegrationManager::DrawCircle(const AZ::Vector3& pos, float radius, int nUnchangedAxis)
{
if (m_dc)
{
m_dc->DrawCircle(
AZVec3ToLYVec3(pos),
radius,
nUnchangedAxis);
}
}
void SandboxIntegrationManager::DrawHalfDottedCircle(const AZ::Vector3& pos, float radius, const AZ::Vector3& viewPos, int nUnchangedAxis)
{
if (m_dc)
{
m_dc->DrawHalfDottedCircle(
AZVec3ToLYVec3(pos),
radius,
AZVec3ToLYVec3(viewPos),
nUnchangedAxis);
}
}
void SandboxIntegrationManager::DrawCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height, bool drawShaded)
{
if (m_dc)
{
m_dc->DrawCone(
AZVec3ToLYVec3(pos),
AZVec3ToLYVec3(dir),
radius,
height,
drawShaded);
}
}
void SandboxIntegrationManager::DrawWireCylinder(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float height)
{
if (m_dc)
{
m_dc->DrawWireCylinder(
AZVec3ToLYVec3(center),
AZVec3ToLYVec3(axis),
radius,
height);
}
}
void SandboxIntegrationManager::DrawSolidCylinder(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float height, bool drawShaded)
{
if (m_dc)
{
m_dc->DrawSolidCylinder(
AZVec3ToLYVec3(center),
AZVec3ToLYVec3(axis),
radius,
height,
drawShaded);
}
}
void SandboxIntegrationManager::DrawWireCapsule(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float height)
{
if (m_dc)
{
m_dc->DrawWireCapsule(
AZVec3ToLYVec3(center),
AZVec3ToLYVec3(axis),
radius,
height);
}
}
void SandboxIntegrationManager::DrawTerrainRect(float x1, float y1, float x2, float y2, float height)
{
if (m_dc)
{
m_dc->DrawTerrainRect(x1, y1, x2, y2, height);
}
}
void SandboxIntegrationManager::DrawTerrainLine(AZ::Vector3 worldPos1, AZ::Vector3 worldPos2)
{
if (m_dc)
{
m_dc->DrawTerrainLine(
AZVec3ToLYVec3(worldPos1),
AZVec3ToLYVec3(worldPos2));
}
}
void SandboxIntegrationManager::DrawWireSphere(const AZ::Vector3& pos, float radius)
{
if (m_dc)
{
m_dc->DrawWireSphere(AZVec3ToLYVec3(pos), radius);
}
}
void SandboxIntegrationManager::DrawWireSphere(const AZ::Vector3& pos, const AZ::Vector3 radius)
{
if (m_dc)
{
m_dc->DrawWireSphere(
AZVec3ToLYVec3(pos),
AZVec3ToLYVec3(radius));
}
}
void SandboxIntegrationManager::DrawWireDisk(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius)
{
if (m_dc)
{
m_dc->DrawWireDisk(
AZVec3ToLYVec3(pos),
AZVec3ToLYVec3(dir),
radius);
}
}
void SandboxIntegrationManager::DrawBall(const AZ::Vector3& pos, float radius, bool drawShaded)
{
if (m_dc)
{
m_dc->DrawBall(AZVec3ToLYVec3(pos), radius, drawShaded);
}
}
void SandboxIntegrationManager::DrawDisk(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius)
{
if (m_dc)
{
m_dc->DrawDisk(
AZVec3ToLYVec3(pos),
AZVec3ToLYVec3(dir),
radius);
}
}
void SandboxIntegrationManager::DrawArrow(const AZ::Vector3& src, const AZ::Vector3& trg, float fHeadScale, bool b2SidedArrow)
{
if (m_dc)
{
m_dc->DrawArrow(
AZVec3ToLYVec3(src),
AZVec3ToLYVec3(trg),
fHeadScale,
b2SidedArrow);
}
}
void SandboxIntegrationManager::DrawTextLabel(const AZ::Vector3& pos, float size, const char* text, const bool bCenter, int srcOffsetX, int srcOffsetY)
{
if (m_dc)
{
m_dc->DrawTextLabel(
AZVec3ToLYVec3(pos),
size,
text,
bCenter,
srcOffsetX,
srcOffsetY);
}
}
void SandboxIntegrationManager::Draw2dTextLabel(float x, float y, float size, const char* text, bool bCenter)
{
if (m_dc)
{
m_dc->Draw2dTextLabel(x, y, size, text, bCenter);
}
}
void SandboxIntegrationManager::DrawTextureLabel(ITexture* texture, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags)
{
if (m_dc)
{
if (texture)
{
float textureWidth = aznumeric_caster(texture->GetWidth());
float textureHeight = aznumeric_caster(texture->GetHeight());
// resize the label in proportion to the actual texture size
if (textureWidth > textureHeight)
{
sizeY = sizeX * (textureHeight / textureWidth);
}
else
{
sizeX = sizeY * (textureWidth / textureHeight);
}
m_dc->DrawTextureLabel(AZVec3ToLYVec3(pos), sizeX, sizeY, texture->GetTextureID(), texIconFlags);
}
}
}
void SandboxIntegrationManager::DrawTextureLabel(int textureId, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags)
{
// ToDo: With Atom?
AZ_UNUSED(textureId);
AZ_UNUSED(pos);
AZ_UNUSED(sizeX);
AZ_UNUSED(sizeY);
AZ_UNUSED(texIconFlags);
}
void SandboxIntegrationManager::SetLineWidth(float width)
{
if (m_dc)
{
m_dc->SetLineWidth(width);
}
}
bool SandboxIntegrationManager::IsVisible(const AZ::Aabb& bounds)
{
if (m_dc)
{
const AABB aabb(
AZVec3ToLYVec3(bounds.GetMin()),
AZVec3ToLYVec3(bounds.GetMax()));
return m_dc->IsVisible(aabb);
}
return 0;
}
int SandboxIntegrationManager::SetFillMode(int nFillMode)
{
if (m_dc)
{
return m_dc->SetFillMode(nFillMode);
}
return 0;
}
float SandboxIntegrationManager::GetLineWidth()
{
if (m_dc)
{
return m_dc->GetLineWidth();
}
return 0.f;
}
float SandboxIntegrationManager::GetAspectRatio()
{
if (m_dc && m_dc->GetView())
{
return m_dc->GetView()->GetAspectRatio();
}
return 0.f;
}
void SandboxIntegrationManager::DepthTestOff()
{
if (m_dc)
{
m_dc->DepthTestOff();
}
}
void SandboxIntegrationManager::DepthTestOn()
{
if (m_dc)
{
m_dc->DepthTestOn();
}
}
void SandboxIntegrationManager::DepthWriteOff()
{
if (m_dc)
{
m_dc->DepthWriteOff();
}
}
void SandboxIntegrationManager::DepthWriteOn()
{
if (m_dc)
{
m_dc->DepthWriteOn();
}
}
void SandboxIntegrationManager::CullOff()
{
if (m_dc)
{
m_dc->CullOff();
}
}
void SandboxIntegrationManager::CullOn()
{
if (m_dc)
{
m_dc->CullOn();
}
}
bool SandboxIntegrationManager::SetDrawInFrontMode(bool bOn)
{
if (m_dc)
{
return m_dc->SetDrawInFrontMode(bOn);
}
return 0.f;
}
AZ::u32 SandboxIntegrationManager::GetState()
{
if (m_dc)
{
return m_dc->GetState();
}
return 0;
}
AZ::u32 SandboxIntegrationManager::SetState(AZ::u32 state)
{
if (m_dc)
{
return m_dc->SetState(state);
}
return 0;
}
void SandboxIntegrationManager::PushMatrix(const AZ::Transform& tm)
{
if (m_dc)
{
const Matrix34 m = AZTransformToLYTransform(tm);
m_dc->PushMatrix(m);
}
}
void SandboxIntegrationManager::PopMatrix()
{
if (m_dc)
{
m_dc->PopMatrix();
}
}
bool SandboxIntegrationManager::DisplayHelpersVisible()
{
return GetIEditor()->GetDisplaySettings()->IsDisplayHelpers();
@@ -100,7 +100,6 @@ class SandboxIntegrationManager
, private AzToolsFramework::EditorEvents::Bus::Handler
, private AzToolsFramework::EditorWindowRequests::Bus::Handler
, private AzFramework::AssetCatalogEventBus::Handler
, private AzFramework::DebugDisplayRequestBus::Handler
, private AzFramework::DisplayContextRequestBus::Handler
, private AzToolsFramework::EditorEntityContextNotificationBus::Handler
, private AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler
@@ -202,70 +201,6 @@ private:
const AzFramework::SliceInstantiationTicket& ticket) override;
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::DebugDisplayRequestBus
void SetColor(float r, float g, float b, float a) override;
void SetColor(const AZ::Color& color) override;
void SetColor(const AZ::Vector4& color) override;
void SetAlpha(float a) override;
void DrawQuad(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector3& p3, const AZ::Vector3& p4) override;
void DrawQuad(float width, float height) override;
void DrawWireQuad(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector3& p3, const AZ::Vector3& p4) override;
void DrawWireQuad(float width, float height) override;
void DrawQuadGradient(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector3& p3, const AZ::Vector3& p4, const AZ::Vector4& firstColor, const AZ::Vector4& secondColor) override;
void DrawTri(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector3& p3) override;
void DrawTriangles(const AZStd::vector<AZ::Vector3>& vertices, const AZ::Color& color) override;
void DrawTrianglesIndexed(const AZStd::vector<AZ::Vector3>& vertices, const AZStd::vector<AZ::u32>& indices, const AZ::Color& color) override;
void DrawWireBox(const AZ::Vector3& min, const AZ::Vector3& max) override;
void DrawSolidBox(const AZ::Vector3& min, const AZ::Vector3& max) override;
void DrawSolidOBB(const AZ::Vector3& center, const AZ::Vector3& axisX, const AZ::Vector3& axisY, const AZ::Vector3& axisZ, const AZ::Vector3& halfExtents) override;
void DrawPoint(const AZ::Vector3& p, int nSize) override;
void DrawLine(const AZ::Vector3& p1, const AZ::Vector3& p2) override;
void DrawLine(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector4& col1, const AZ::Vector4& col2) override;
void DrawLines(const AZStd::vector<AZ::Vector3>& lines, const AZ::Color& color) override;
void DrawPolyLine(const AZ::Vector3* pnts, int numPoints, bool cycled) override;
void DrawWireQuad2d(const AZ::Vector2& p1, const AZ::Vector2& p2, float z) override;
void DrawLine2d(const AZ::Vector2& p1, const AZ::Vector2& p2, float z) override;
void DrawLine2dGradient(const AZ::Vector2& p1, const AZ::Vector2& p2, float z, const AZ::Vector4& firstColor, const AZ::Vector4& secondColor) override;
void DrawWireCircle2d(const AZ::Vector2& center, float radius, float z) override;
void DrawTerrainCircle(const AZ::Vector3& worldPos, float radius, float height) override;
void DrawTerrainCircle(const AZ::Vector3& center, float radius, float angle1, float angle2, float height) override;
void DrawArc(const AZ::Vector3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, int referenceAxis) override;
void DrawArc(const AZ::Vector3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, const AZ::Vector3& fixedAxis) override;
void DrawCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height, bool drawShaded = true) override;
void DrawCircle(const AZ::Vector3& pos, float radius, int nUnchangedAxis) override;
void DrawHalfDottedCircle(const AZ::Vector3& pos, float radius, const AZ::Vector3& viewPos, int nUnchangedAxis) override;
void DrawWireCylinder(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float height) override;
void DrawSolidCylinder(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float height, bool drawShaded = true) override;
void DrawWireCapsule(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float height) override;
void DrawTerrainRect(float x1, float y1, float x2, float y2, float height) override;
void DrawTerrainLine(AZ::Vector3 worldPos1, AZ::Vector3 worldPos2) override;
void DrawWireSphere(const AZ::Vector3& pos, float radius) override;
void DrawWireSphere(const AZ::Vector3& pos, const AZ::Vector3 radius) override;
void DrawWireDisk(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius) override;
void DrawBall(const AZ::Vector3& pos, float radius, bool drawShaded = true) override;
void DrawDisk(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius) override;
void DrawArrow(const AZ::Vector3& src, const AZ::Vector3& trg, float fHeadScale, bool b2SidedArrow) override;
void DrawTextLabel(const AZ::Vector3& pos, float size, const char* text, const bool bCenter, int srcOffsetX, int scrOffsetY) override;
void Draw2dTextLabel(float x, float y, float size, const char* text, bool bCenter) override;
void DrawTextureLabel(ITexture* texture, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) override;
void DrawTextureLabel(int textureId, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) override;
void SetLineWidth(float width) override;
bool IsVisible(const AZ::Aabb& bounds) override;
int SetFillMode(int nFillMode) override;
float GetLineWidth() override;
float GetAspectRatio() override;
void DepthTestOff() override;
void DepthTestOn() override;
void DepthWriteOff() override;
void DepthWriteOn() override;
void CullOff() override;
void CullOn() override;
bool SetDrawInFrontMode(bool bOn) override;
AZ::u32 GetState() override;
AZ::u32 SetState(AZ::u32 state) override;
void PushMatrix(const AZ::Transform& tm) override;
void PopMatrix() override;
// AzFramework::DisplayContextRequestBus (and @deprecated EntityDebugDisplayRequestBus)
// AzFramework::DisplayContextRequestBus
void SetDC(DisplayContext* dc) override;
@@ -114,6 +114,11 @@ namespace AZ
extern "C" AZ_DLL_EXPORT void InitializeDynamicModule(void* env)
{
AZ::Environment::Attach(static_cast<AZ::EnvironmentInstance>(env));
if (!AZ::SceneAPI::FbxSceneBuilder::g_fbxImporter)
{
AZ::SceneAPI::FbxSceneBuilder::g_fbxImporter = aznew AZ::SceneAPI::FbxSceneImporter::FbxImportRequestHandler();
AZ::SceneAPI::FbxSceneBuilder::g_fbxImporter->Activate();
}
}
extern "C" AZ_DLL_EXPORT void Reflect(AZ::SerializeContext* context)
{
@@ -39,9 +39,7 @@ namespace AZ
void FbxImportRequestHandler::Activate()
{
auto settingsRegistry = AZ::SettingsRegistry::Get();
if (settingsRegistry)
if (auto* settingsRegistry = AZ::SettingsRegistry::Get())
{
settingsRegistry->GetObject(m_settings, "/O3DE/SceneAPI/AssetImporter");
}
@@ -70,6 +68,15 @@ namespace AZ
void FbxImportRequestHandler::GetSupportedFileExtensions(AZStd::unordered_set<AZStd::string>& extensions)
{
// It's unlikely an empty file extension list is intentional,
// so if it's empty, try reloading it from the registry.
if (m_settings.m_supportedFileTypeExtensions.empty())
{
if (auto* settingsRegistry = AZ::SettingsRegistry::Get())
{
settingsRegistry->GetObject(m_settings, "/O3DE/SceneAPI/AssetImporter");
}
}
extensions.insert(m_settings.m_supportedFileTypeExtensions.begin(), m_settings.m_supportedFileTypeExtensions.end());
}
@@ -151,7 +151,7 @@ namespace AZ
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<AssImpAnimationImporter, SceneCore::LoadingComponent>()->Version(3); // [LYN-3349] Rolling back rotation change
serializeContext->Class<AssImpAnimationImporter, SceneCore::LoadingComponent>()->Version(4); // [LYN-3971] Bone pruning crash fix in AssImp SDK
}
}
@@ -51,6 +51,25 @@ namespace AZ
float m_maxY = 0.0f;
float m_minZ = 0.0f;
float m_maxZ = 1.0f;
float GetWidth() const;
float GetHeight() const;
float GetDepth() const;
};
} // namespace RHI
} // namespace AZ
inline float AZ::RHI::Viewport::GetWidth() const
{
return m_maxX - m_minX;
}
inline float AZ::RHI::Viewport::GetHeight() const
{
return m_maxY - m_minY;
}
inline float AZ::RHI::Viewport::GetDepth() const
{
return m_maxZ - m_minZ;
}
@@ -798,7 +798,8 @@ namespace MaterialEditor
propertyConfig.m_showThumbnail = true;
propertyConfig.m_originalValue = AtomToolsFramework::ConvertToEditableType(m_materialAsset->GetPropertyValues()[propertyIndex.GetIndex()]);
propertyConfig.m_parentValue = AtomToolsFramework::ConvertToEditableType(parentPropertyValues[propertyIndex.GetIndex()]);
propertyConfig.m_groupName = m_materialTypeSourceData.FindGroup(groupNameId)->m_displayName;
auto groupDefinition = m_materialTypeSourceData.FindGroup(groupNameId);
propertyConfig.m_groupName = groupDefinition ? groupDefinition->m_displayName : groupNameId;
m_properties[propertyConfig.m_id] = AtomToolsFramework::DynamicProperty(propertyConfig);
}
return true;
@@ -24,6 +24,7 @@ AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnin
#include <QIcon>
#include <QMenu>
#include <QToolButton>
#include <QAbstractItemView>
AZ_POP_DISABLE_WARNING
namespace MaterialEditor
@@ -86,11 +87,13 @@ namespace MaterialEditor
// Add model combo box
auto modelPresetComboBox = new ModelPresetComboBox(this);
modelPresetComboBox->setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy::AdjustToContents);
modelPresetComboBox->view()->setMinimumWidth(200);
addWidget(modelPresetComboBox);
// Add lighting preset combo box
auto lightingPresetComboBox = new LightingPresetComboBox(this);
lightingPresetComboBox->setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy::AdjustToContents);
lightingPresetComboBox->view()->setMinimumWidth(200);
addWidget(lightingPresetComboBox);
MaterialViewportNotificationBus::Handler::BusConnect();
@@ -576,6 +576,29 @@ namespace AZ::AtomBridge
}
}
void AtomDebugDisplayViewportInterface::DrawWireOBB(
const AZ::Vector3& center,
const AZ::Vector3& axisX,
const AZ::Vector3& axisY,
const AZ::Vector3& axisZ,
const AZ::Vector3& halfExtents)
{
if (m_auxGeomPtr)
{
AZ::Quaternion rotation = AZ::Quaternion::CreateFromMatrix3x3(AZ::Matrix3x3::CreateFromColumns(axisX, axisY, axisZ));
AZ::Obb obb = AZ::Obb::CreateFromPositionRotationAndHalfLengths(center, rotation, halfExtents);
m_auxGeomPtr->DrawObb(
obb,
AZ::Vector3::CreateZero(),
m_rendState.m_color,
AZ::RPI::AuxGeomDraw::DrawStyle::Line,
m_rendState.m_depthTest,
m_rendState.m_depthWrite,
m_rendState.m_faceCullMode,
m_rendState.m_viewProjOverrideIndex);
}
}
void AtomDebugDisplayViewportInterface::DrawSolidOBB(
const AZ::Vector3& center,
const AZ::Vector3& axisX,
@@ -906,7 +929,28 @@ namespace AZ::AtomBridge
}
}
void AtomDebugDisplayViewportInterface::DrawCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height, bool drawShaded)
void AtomDebugDisplayViewportInterface::DrawWireCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height)
{
if (m_auxGeomPtr)
{
const AZ::Vector3 worldPos = ToWorldSpacePosition(pos);
const AZ::Vector3 worldDir = ToWorldSpaceVector(dir);
m_auxGeomPtr->DrawCone(
worldPos,
worldDir,
radius,
height,
m_rendState.m_color,
AZ::RPI::AuxGeomDraw::DrawStyle::Line,
m_rendState.m_depthTest,
m_rendState.m_depthWrite,
m_rendState.m_faceCullMode,
m_rendState.m_viewProjOverrideIndex
);
}
}
void AtomDebugDisplayViewportInterface::DrawSolidCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height, bool drawShaded)
{
if (m_auxGeomPtr)
{
@@ -1336,8 +1380,6 @@ namespace AZ::AtomBridge
{
AZ_Assert(false, "Unexpected use of legacy api, please file a feature request with the rendering team to get this implemented!");
}
// unhandledled on Atom - virtual void DrawTextureLabel(ITexture* texture, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) override;
// void AtomDebugDisplayViewportInterface::DrawTextureLabel(int textureId, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) override;
void AtomDebugDisplayViewportInterface::SetLineWidth(float width)
{
@@ -153,6 +153,7 @@ namespace AZ::AtomBridge
void DrawTrianglesIndexed(const AZStd::vector<AZ::Vector3>& vertices, const AZStd::vector<AZ::u32>& indices, const AZ::Color& color) override;
void DrawWireBox(const AZ::Vector3& min, const AZ::Vector3& max) override;
void DrawSolidBox(const AZ::Vector3& min, const AZ::Vector3& max) override;
void DrawWireOBB(const AZ::Vector3& center, const AZ::Vector3& axisX, const AZ::Vector3& axisY, const AZ::Vector3& axisZ, const AZ::Vector3& halfExtents) override;
void DrawSolidOBB(const AZ::Vector3& center, const AZ::Vector3& axisX, const AZ::Vector3& axisY, const AZ::Vector3& axisZ, const AZ::Vector3& halfExtents) override;
void DrawPoint(const AZ::Vector3& p, int nSize = 1) override;
void DrawLine(const AZ::Vector3& p1, const AZ::Vector3& p2) override;
@@ -167,7 +168,8 @@ namespace AZ::AtomBridge
void DrawArc(const AZ::Vector3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, const AZ::Vector3& fixedAxis) override;
void DrawCircle(const AZ::Vector3& pos, float radius, int nUnchangedAxis = 2 /*z axis*/) override;
void DrawHalfDottedCircle(const AZ::Vector3& pos, float radius, const AZ::Vector3& viewPos, int nUnchangedAxis = 2 /*z axis*/) override;
void DrawCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height, bool drawShaded) override;
void DrawWireCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height) override;
void DrawSolidCone(const AZ::Vector3& pos, const AZ::Vector3& dir, float radius, float height, bool drawShaded) override;
void DrawWireCylinder(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float height) override;
void DrawSolidCylinder(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float height, bool drawShaded) override;
void DrawWireCapsule(const AZ::Vector3& center, const AZ::Vector3& axis, float radius, float heightStraightSection) override;
@@ -180,11 +182,8 @@ namespace AZ::AtomBridge
void DrawTextLabel(const AZ::Vector3& pos, float size, const char* text, const bool bCenter = false, int srcOffsetX = 0, int srcOffsetY = 0) override;
void Draw2dTextLabel(float x, float y, float size, const char* text, bool bCenter = false) override;
void DrawTextOn2DBox(const AZ::Vector3& pos, const char* text, float textScale, const AZ::Vector4& TextColor, const AZ::Vector4& TextBackColor) override;
// unhandled on Atom - virtual void DrawTextureLabel(ITexture* texture, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) override;
// void DrawTextureLabel(int textureId, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) override;
void SetLineWidth(float width) override;
bool IsVisible(const AZ::Aabb& bounds) override;
// int SetFillMode(int nFillMode) override;
float GetLineWidth() override;
float GetAspectRatio() override;
void DepthTestOff() override;
@@ -1786,18 +1786,17 @@ void AZ::FFont::DrawScreenAlignedText3d(
}
AZ::Vector3 positionNDC = AzFramework::WorldToScreenNDC(
params.m_position,
currentView->GetViewToWorldMatrix(),
currentView->GetWorldToViewMatrix(),
currentView->GetViewToClipMatrix()
);
AzFramework::TextDrawParameters param2d = params;
param2d.m_position = positionNDC;
internalParams.m_ctx.m_sizeIn800x600 = false;
DrawStringUInternal(
*internalParams.m_viewport,
internalParams.m_viewportContext,
internalParams.m_position.GetX(),
internalParams.m_position.GetY(),
params.m_position.GetZ(), // Z
positionNDC.GetX() * internalParams.m_viewport->GetWidth(),
(1.0f - positionNDC.GetY()) * internalParams.m_viewport->GetHeight(),
positionNDC.GetZ(), // Z
text.data(),
params.m_multiline,
internalParams.m_ctx
+6
View File
@@ -21,6 +21,9 @@ ly_add_target(
Include
BUILD_DEPENDENCIES
PUBLIC
AZ::AtomCore
Gem::Atom_RPI.Public
Gem::Atom_Bootstrap.Headers
Legacy::CryCommon
)
@@ -51,6 +54,9 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
Source
PUBLIC
Include
COMPILE_DEFINITIONS
PRIVATE
DEBUGDRAW_GEM_EDITOR=1
BUILD_DEPENDENCIES
PRIVATE
Gem::DebugDraw.Static
@@ -41,9 +41,8 @@ namespace DebugDraw
, m_worldLocation(AZ::Vector3::CreateZero())
, m_owningEditorComponent(AZ::InvalidComponentId)
, m_scale(AZ::Vector3(1.0f, 1.0f, 1.0f))
{
m_obb.CreateFromPositionRotationAndHalfLengths(m_worldLocation, AZ::Quaternion::CreateIdentity(), AZ::Vector3::CreateOne());
}
, m_obb(AZ::Obb::CreateFromPositionRotationAndHalfLengths(m_worldLocation, AZ::Quaternion::CreateIdentity(), AZ::Vector3::CreateOne()))
{}
};
class DebugDrawObbComponent
@@ -19,11 +19,6 @@
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/std/parallel/lock.h>
#include <IRenderAuxGeom.h>
#include <Cry_Camera.h>
#include <MathConversion.h>
#include "DebugDrawSystemComponent.h"
// Editor specific
@@ -37,6 +32,9 @@
#include <AzToolsFramework/Entity/EditorEntityContextComponent.h>
#endif // DEBUGDRAW_GEM_EDITOR
#include <Atom/RPI.Public/RPISystemInterface.h>
#include <Atom/RPI.Public/Scene.h>
namespace DebugDraw
{
void DebugDrawSystemComponent::Reflect(AZ::ReflectContext* context)
@@ -96,7 +94,7 @@ namespace DebugDraw
void DebugDrawSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
(void)required;
required.push_back(AZ_CRC("RPISystem", 0xf2add773));
}
void DebugDrawSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
@@ -112,7 +110,7 @@ namespace DebugDraw
{
DebugDrawInternalRequestBus::Handler::BusConnect();
DebugDrawRequestBus::Handler::BusConnect();
AZ::TickBus::Handler::BusConnect();
AZ::Render::Bootstrap::NotificationBus::Handler::BusConnect();
#ifdef DEBUGDRAW_GEM_EDITOR
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
@@ -125,7 +123,7 @@ namespace DebugDraw
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect();
#endif // DEBUGDRAW_GEM_EDITOR
AZ::TickBus::Handler::BusDisconnect();
AZ::RPI::SceneNotificationBus::Handler::BusDisconnect();
DebugDrawRequestBus::Handler::BusDisconnect();
DebugDrawInternalRequestBus::Handler::BusDisconnect();
@@ -155,6 +153,13 @@ namespace DebugDraw
}
}
void DebugDrawSystemComponent::OnBootstrapSceneReady(AZ::RPI::Scene* scene)
{
AZ_Assert(scene, "Invalid scene received in OnBootstrapSceneReady");
AZ::RPI::SceneNotificationBus::Handler::BusConnect(scene->GetId());
AZ::Render::Bootstrap::NotificationBus::Handler::BusDisconnect();
}
#ifdef DEBUGDRAW_GEM_EDITOR
void DebugDrawSystemComponent::OnStopPlayInEditor()
{
@@ -255,16 +260,26 @@ namespace DebugDraw
}
#endif // DEBUGDRAW_GEM_EDITOR
void DebugDrawSystemComponent::OnTick([[maybe_unused]] float deltaTime, AZ::ScriptTimePoint time)
void DebugDrawSystemComponent::OnBeginPrepareRender()
{
AZ::ScriptTimePoint time;
AZ::TickRequestBus::BroadcastResult(time, &AZ::TickRequestBus::Events::GetTimeAtCurrentTick);
m_currentTime = time.GetSeconds();
OnTickAabbs();
OnTickLines();
OnTickObbs();
OnTickRays();
OnTickSpheres();
OnTickText();
AzFramework::DebugDisplayRequestBus::BusPtr debugDisplayBus;
AzFramework::DebugDisplayRequestBus::Bind(
debugDisplayBus, AzFramework::g_defaultSceneEntityDebugDisplayId);
AZ_Assert(debugDisplayBus, "Invalid DebugDisplayRequestBus.");
AzFramework::DebugDisplayRequests* debugDisplay =
AzFramework::DebugDisplayRequestBus::FindFirstHandler(debugDisplayBus);
OnTickAabbs(*debugDisplay);
OnTickLines(*debugDisplay);
OnTickObbs(*debugDisplay);
OnTickRays(*debugDisplay);
OnTickSpheres(*debugDisplay);
OnTickText(*debugDisplay);
}
template <typename F>
@@ -277,7 +292,7 @@ namespace DebugDraw
vectorToExpire.erase(removalCondition, std::end(vectorToExpire));
}
void DebugDrawSystemComponent::OnTickAabbs()
void DebugDrawSystemComponent::OnTickAabbs(AzFramework::DebugDisplayRequests& debugDisplay)
{
AZStd::lock_guard<AZStd::mutex> locker(m_activeAabbsMutex);
@@ -295,17 +310,14 @@ namespace DebugDraw
AZ::Vector3 currentCenter = transformedAabb.GetCenter();
transformedAabb.Set(transformedAabb.GetMin() - currentCenter + aabbElement.m_worldLocation, transformedAabb.GetMax() - currentCenter + aabbElement.m_worldLocation);
}
ColorB lyColor(aabbElement.m_color.ToU32());
Vec3 worldLocation(AZVec3ToLYVec3(aabbElement.m_worldLocation));
AABB lyAABB(AZAabbToLyAABB(transformedAabb));
gEnv->pRenderer->GetIRenderAuxGeom()->DrawAABB(lyAABB, false, lyColor, EBoundingBoxDrawStyle::eBBD_Extremes_Color_Encoded);
debugDisplay.SetColor(aabbElement.m_color);
debugDisplay.DrawSolidBox(transformedAabb.GetMin(), transformedAabb.GetMax());
}
removeExpiredDebugElementsFromVector(m_activeAabbs);
}
void DebugDrawSystemComponent::OnTickLines()
void DebugDrawSystemComponent::OnTickLines(AzFramework::DebugDisplayRequests& debugDisplay)
{
AZStd::lock_guard<AZStd::mutex> locker(m_activeLinesMutex);
size_t numActiveLines = m_activeLines.size();
@@ -339,26 +351,14 @@ namespace DebugDraw
&AZ::TransformBus::Events::GetWorldTranslation);
}
Vec3 start(AZVec3ToLYVec3(lineElement.m_startWorldLocation));
Vec3 end(AZVec3ToLYVec3(lineElement.m_endWorldLocation));
ColorB lyColor(lineElement.m_color.ToU32());
m_batchPoints.push_back(start);
m_batchPoints.push_back(end);
m_batchColors.push_back(lyColor);
m_batchColors.push_back(lyColor);
}
if (!m_batchPoints.empty())
{
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLines(m_batchPoints.begin(), m_batchPoints.size(), m_batchColors.begin(), 1.0f);
debugDisplay.SetColor(lineElement.m_color);
debugDisplay.DrawLine(lineElement.m_startWorldLocation, lineElement.m_endWorldLocation);
}
removeExpiredDebugElementsFromVector(m_activeLines);
}
void DebugDrawSystemComponent::OnTickObbs()
void DebugDrawSystemComponent::OnTickObbs(AzFramework::DebugDisplayRequests& debugDisplay)
{
AZStd::lock_guard<AZStd::mutex> locker(m_activeObbsMutex);
@@ -382,20 +382,18 @@ namespace DebugDraw
transformedObb.SetHalfLength(i, obbElement.m_scale.GetElement(i));
}
}
obbElement.m_worldLocation = transformedObb.GetPosition();
ColorB lyColor(obbElement.m_color.ToU32());
Vec3 worldLocation(AZVec3ToLYVec3(obbElement.m_worldLocation));
OBB lyOBB(AZObbToLyOBB(transformedObb));
lyOBB.c = Vec3(0.f);
gEnv->pRenderer->GetIRenderAuxGeom()->DrawOBB(lyOBB, worldLocation, false, lyColor, EBoundingBoxDrawStyle::eBBD_Extremes_Color_Encoded);
else
{
obbElement.m_worldLocation = transformedObb.GetPosition();
}
debugDisplay.SetColor(obbElement.m_color);
debugDisplay.DrawSolidOBB(obbElement.m_worldLocation, transformedObb.GetAxisX(), transformedObb.GetAxisY(), transformedObb.GetAxisZ(), transformedObb.GetHalfLengths());
}
removeExpiredDebugElementsFromVector(m_activeObbs);
}
void DebugDrawSystemComponent::OnTickRays()
void DebugDrawSystemComponent::OnTickRays(AzFramework::DebugDisplayRequests& debugDisplay)
{
AZStd::lock_guard<AZStd::mutex> locker(m_activeRaysMutex);
@@ -415,22 +413,20 @@ namespace DebugDraw
rayElement.m_worldDirection = (endWorldLocation - rayElement.m_worldLocation);
}
ColorB lyColor(rayElement.m_color.ToU32());
Vec3 start(AZVec3ToLYVec3(rayElement.m_worldLocation));
Vec3 end(AZVec3ToLYVec3(endWorldLocation));
Vec3 direction(AZVec3ToLYVec3(rayElement.m_worldDirection));
float conePercentHeight = 0.5f;
float coneHeight = direction.GetLength() * conePercentHeight;
Vec3 coneBaseLocation = end - direction * conePercentHeight;
float coneHeight = rayElement.m_worldDirection.GetLength() * conePercentHeight;
AZ::Vector3 coneBaseLocation = endWorldLocation - rayElement.m_worldDirection * conePercentHeight;
float coneRadius = AZ::GetClamp(coneHeight * 0.07f, 0.05f, 0.2f);
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(start, lyColor, coneBaseLocation, lyColor, 5.0f);
gEnv->pRenderer->GetIRenderAuxGeom()->DrawCone(coneBaseLocation, direction, coneRadius, coneHeight, lyColor, false);
debugDisplay.SetColor(rayElement.m_color);
debugDisplay.SetLineWidth(5.0f);
debugDisplay.DrawLine(rayElement.m_worldLocation, coneBaseLocation);
debugDisplay.DrawSolidCone(coneBaseLocation, rayElement.m_worldDirection, coneRadius, coneHeight, false);
}
removeExpiredDebugElementsFromVector(m_activeRays);
}
void DebugDrawSystemComponent::OnTickSpheres()
void DebugDrawSystemComponent::OnTickSpheres(AzFramework::DebugDisplayRequests& debugDisplay)
{
AZStd::lock_guard<AZStd::mutex> locker(m_activeSpheresMutex);
@@ -442,19 +438,14 @@ namespace DebugDraw
{
AZ::TransformBus::EventResult(sphereElement.m_worldLocation, sphereElement.m_targetEntityId, &AZ::TransformBus::Events::GetWorldTranslation);
}
if (gEnv->pRenderer)
{
ColorB lyColor(sphereElement.m_color.ToU32());
Vec3 worldLocation(AZVec3ToLYVec3(sphereElement.m_worldLocation));
gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(worldLocation, sphereElement.m_radius, lyColor, true);
}
debugDisplay.SetColor(sphereElement.m_color);
debugDisplay.DrawBall(sphereElement.m_worldLocation, sphereElement.m_radius, true);
}
removeExpiredDebugElementsFromVector(m_activeSpheres);
}
void DebugDrawSystemComponent::OnTickText()
void DebugDrawSystemComponent::OnTickText(AzFramework::DebugDisplayRequests& debugDisplay)
{
AZStd::lock_guard<AZStd::mutex> locker(m_activeTextsMutex);
@@ -471,30 +462,20 @@ namespace DebugDraw
#endif // DEBUGDRAW_GEM_EDITOR
// Draw text elements and remove any that are expired
AZStd::unordered_map<AZ::EntityId, AZ::u32> textPerEntityCount;
int numScreenTexts = 0;
AZ::EntityId lastTargetEntityId;
for (auto& textElement : m_activeTexts)
{
const AZ::Color textColor = needsGammaConversion ? textElement.m_color.GammaToLinear() : textElement.m_color;
debugDisplay.SetColor(textColor);
if (textElement.m_drawMode == DebugDrawTextElement::DrawMode::OnScreen)
{
const AZ::Color textColor = needsGammaConversion ? textElement.m_color.GammaToLinear() : textElement.m_color;
gEnv->pRenderer->GetIRenderAuxGeom()->Draw3dLabel(Vec3(20.f, 20.f + ((float)numScreenTexts * 15.0f), 0.5f), 1.4f, AZColorToLYColorF(textColor), textElement.m_text.c_str());
debugDisplay.Draw2dTextLabel(100.0f, 20.f + ((float)numScreenTexts * 15.0f), 1.4f, textElement.m_text.c_str() );
++numScreenTexts;
}
else if (textElement.m_drawMode == DebugDrawTextElement::DrawMode::InWorld)
{
SDrawTextInfo ti;
ti.xscale = ti.yscale = 1.4f;
ti.flags = eDrawText_2D | eDrawText_FixedSize | eDrawText_Monospace | eDrawText_Center;
const AZ::Color textColor = needsGammaConversion ? textElement.m_color.GammaToLinear() : textElement.m_color;
ti.color[0] = textColor.GetR();
ti.color[1] = textColor.GetG();
ti.color[2] = textColor.GetB();
ti.color[3] = textColor.GetA();
AZ::Vector3 worldLocation;
if (textElement.m_targetEntityId.IsValid())
{
@@ -507,32 +488,7 @@ namespace DebugDraw
worldLocation = textElement.m_worldLocation;
}
const CCamera& camera = gEnv->pSystem->GetViewCamera();
const AZ::Vector3 cameraTranslation = LYVec3ToAZVec3(camera.GetPosition());
Vec3 lyWorldLoc = AZVec3ToLYVec3(worldLocation);
Vec3 screenPos(0.f);
if (camera.Project(lyWorldLoc, screenPos, Vec2i(0, 0), Vec2i(0, 0)))
{
// Handle spacing for world text so it doesn't draw on top of each other
// This works for text drawing on entities (considered one block), but not for world text.
// World text will get handled when we have screen-aware positioning of text elements
if (textElement.m_targetEntityId.IsValid())
{
auto iter = textPerEntityCount.find(textElement.m_targetEntityId);
if (iter != textPerEntityCount.end())
{
AZ::u32 count = iter->second;
screenPos.y += ((float)count * 15.0f);
iter->second = count + 1;
}
else
{
auto newEntry = textPerEntityCount.insert_key(textElement.m_targetEntityId);
newEntry.first->second = 1;
}
}
gEnv->pRenderer->GetIRenderAuxGeom()->Draw3dLabel(Vec3(screenPos.x, screenPos.y, 0.5f), 1.4f, AZColorToLYColorF(textColor), textElement.m_text.c_str());
}
debugDisplay.DrawTextLabel(worldLocation, 1.4f, textElement.m_text.c_str() );
}
}
@@ -550,9 +506,9 @@ namespace DebugDraw
CreateLineEntryForComponent(lineComponent->GetEntityId(), lineComponent->m_element);
}
#ifdef DEBUGDRAW_GEM_EDITOR
else if (EditorDebugDrawLineComponent* lineComponent = azrtti_cast<EditorDebugDrawLineComponent*>(component))
else if (EditorDebugDrawLineComponent* editorLineComponent = azrtti_cast<EditorDebugDrawLineComponent*>(component))
{
CreateLineEntryForComponent(lineComponent->GetEntityId(), lineComponent->m_element);
CreateLineEntryForComponent(editorLineComponent->GetEntityId(), editorLineComponent->m_element);
}
#endif // DEBUGDRAW_GEM_EDITOR
else if (DebugDrawRayComponent* rayComponent = azrtti_cast<DebugDrawRayComponent*>(component))
@@ -560,9 +516,9 @@ namespace DebugDraw
CreateRayEntryForComponent(rayComponent->GetEntityId(), rayComponent->m_element);
}
#ifdef DEBUGDRAW_GEM_EDITOR
else if (EditorDebugDrawRayComponent* rayComponent = azrtti_cast<EditorDebugDrawRayComponent*>(component))
else if (EditorDebugDrawRayComponent* editorRayComponent = azrtti_cast<EditorDebugDrawRayComponent*>(component))
{
CreateRayEntryForComponent(rayComponent->GetEntityId(), rayComponent->m_element);
CreateRayEntryForComponent(editorRayComponent->GetEntityId(), editorRayComponent->m_element);
}
#endif // DEBUGDRAW_GEM_EDITOR
else if (DebugDrawSphereComponent* sphereComponent = azrtti_cast<DebugDrawSphereComponent*>(component))
@@ -570,9 +526,9 @@ namespace DebugDraw
CreateSphereEntryForComponent(sphereComponent->GetEntityId(), sphereComponent->m_element);
}
#ifdef DEBUGDRAW_GEM_EDITOR
else if (EditorDebugDrawSphereComponent* sphereComponent = azrtti_cast<EditorDebugDrawSphereComponent*>(component))
else if (EditorDebugDrawSphereComponent* editorSphereComponent = azrtti_cast<EditorDebugDrawSphereComponent*>(component))
{
CreateSphereEntryForComponent(sphereComponent->GetEntityId(), sphereComponent->m_element);
CreateSphereEntryForComponent(editorSphereComponent->GetEntityId(), editorSphereComponent->m_element);
}
#endif // DEBUGDRAW_GEM_EDITOR
else if (DebugDrawObbComponent* obbComponent = azrtti_cast<DebugDrawObbComponent*>(component))
@@ -581,9 +537,9 @@ namespace DebugDraw
}
#ifdef DEBUGDRAW_GEM_EDITOR
else if (EditorDebugDrawObbComponent* obbComponent = azrtti_cast<EditorDebugDrawObbComponent*>(component))
else if (EditorDebugDrawObbComponent* editorObbComponent = azrtti_cast<EditorDebugDrawObbComponent*>(component))
{
CreateObbEntryForComponent(obbComponent->GetEntityId(), obbComponent->m_element);
CreateObbEntryForComponent(editorObbComponent->GetEntityId(), editorObbComponent->m_element);
}
#endif // DEBUGDRAW_GEM_EDITOR
@@ -593,9 +549,9 @@ namespace DebugDraw
}
#ifdef DEBUGDRAW_GEM_EDITOR
else if (EditorDebugDrawTextComponent* textComponent = azrtti_cast<EditorDebugDrawTextComponent*>(component))
else if (EditorDebugDrawTextComponent* editorTextComponent = azrtti_cast<EditorDebugDrawTextComponent*>(component))
{
CreateTextEntryForComponent(textComponent->GetEntityId(), textComponent->m_element);
CreateTextEntryForComponent(editorTextComponent->GetEntityId(), editorTextComponent->m_element);
}
#endif // DEBUGDRAW_GEM_EDITOR
}
@@ -32,6 +32,9 @@
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#endif // DEBUGDRAW_GEM_EDITOR
#include <Atom/RPI.Public/SceneBus.h>
#include <Atom/Bootstrap/BootstrapNotificationBus.h>
namespace DebugDraw
{
// DebugDraw elements that don't have corresponding component representations yet
@@ -61,10 +64,11 @@ namespace DebugDraw
class DebugDrawSystemComponent
: public AZ::Component
, public AZ::TickBus::Handler
, public AZ::EntityBus::MultiHandler
, protected DebugDrawRequestBus::Handler
, protected DebugDrawInternalRequestBus::Handler
, public AZ::RPI::SceneNotificationBus::Handler
, public AZ::Render::Bootstrap::NotificationBus::Handler
#ifdef DEBUGDRAW_GEM_EDITOR
, protected AzToolsFramework::EditorEntityContextNotificationBus::Handler
@@ -113,20 +117,22 @@ namespace DebugDraw
void Activate() override;
void Deactivate() override;
// TickBus
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
int GetTickOrder() override { return AZ::ComponentTickBus::TICK_DEFAULT; }
// SceneNotificationBus
void OnBeginPrepareRender() override;
// AZ::Render::Bootstrap::NotificationBus
void OnBootstrapSceneReady(AZ::RPI::Scene* scene);
// EntityBus
void OnEntityDeactivated(const AZ::EntityId& entityId) override;
// Ticking functions for drawing debug elements
void OnTickAabbs();
void OnTickLines();
void OnTickObbs();
void OnTickRays();
void OnTickSpheres();
void OnTickText();
void OnTickAabbs(AzFramework::DebugDisplayRequests& debugDisplay);
void OnTickLines(AzFramework::DebugDisplayRequests& debugDisplay);
void OnTickObbs(AzFramework::DebugDisplayRequests& debugDisplay);
void OnTickRays(AzFramework::DebugDisplayRequests& debugDisplay);
void OnTickSpheres(AzFramework::DebugDisplayRequests& debugDisplay);
void OnTickText(AzFramework::DebugDisplayRequests& debugDisplay);
// Element creation functions, used when DebugDraw components register themselves
void CreateAabbEntryForComponent(const AZ::EntityId& componentEntityId, const DebugDrawAabbElement& element);
@@ -154,7 +160,7 @@ namespace DebugDraw
double m_currentTime;
AZStd::vector<Vec3> m_batchPoints;
AZStd::vector<ColorB> m_batchColors;
AZStd::vector<AZ::Vector3> m_batchPoints;
AZStd::vector<AZ::Color> m_batchColors;
};
}
@@ -11,6 +11,3 @@
*/
#pragma once
#include <platform.h> // Many CryCommon files require that this is included first.
#include <Cry_Color.h>
@@ -15,6 +15,7 @@
#ifdef IMGUI_ENABLED
#include <AzCore/std/string/conversions.h>
#include <AzCore/std/sort.h>
#include <AzFramework/Input/Buses/Requests/InputSystemCursorRequestBus.h>
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
#include <ILevelSystem.h>
@@ -251,15 +252,37 @@ namespace ImGui
if (usePrefabSystemForLevels)
{
char levelName[256];
ImGui::TextColored(ImGui::Colors::s_PlainLabelColor, "Load Level: ");
bool result = ImGui::InputText("", levelName, sizeof(levelName), ImGuiInputTextFlags_EnterReturnsTrue);
if (result)
// Run through all the assets in the asset catalog and gather up the list of level assets
AZ::Data::AssetType levelAssetType = lvlSystem->GetLevelAssetType();
AZStd::vector<AZStd::string> levelNames;
auto enumerateCB =
[levelAssetType, &levelNames]([[maybe_unused]] const AZ::Data::AssetId id, const AZ::Data::AssetInfo& assetInfo)
{
AZ_TracePrintf("Imgui", "Attempting to load level '%s'\n", levelName);
AZ::TickBus::QueueFunction([lvlSystem, levelName]() {
lvlSystem->LoadLevel(levelName);
});
if (assetInfo.m_assetType == levelAssetType)
{
levelNames.emplace_back(assetInfo.m_relativePath);
}
};
AZ::Data::AssetCatalogRequestBus::Broadcast(
&AZ::Data::AssetCatalogRequestBus::Events::EnumerateAssets, nullptr, enumerateCB, nullptr);
AZStd::sort(levelNames.begin(), levelNames.end());
// Create a menu item for each level asset, with an action to load it if selected.
ImGui::TextColored(ImGui::Colors::s_PlainLabelColor, "Load Level: ");
for (int i = 0; i < levelNames.size(); i++)
{
if (ImGui::MenuItem(AZStd::string::format("%d- %s", i, levelNames[i].c_str()).c_str()))
{
AZ::TickBus::QueueFunction(
[lvlSystem, levelNames, i]()
{
lvlSystem->LoadLevel(levelNames[i].c_str());
});
}
}
}
else
@@ -269,9 +292,8 @@ namespace ImGui
{
if (ImGui::MenuItem(AZStd::string::format("%d- %s", i, lvlSystem->GetLevelInfo(i)->GetName()).c_str()))
{
AZStd::string mapCommandString = AZStd::string::format("map %s", lvlSystem->GetLevelInfo(i)->GetName());
AZ::TickBus::QueueFunction([mapCommandString]() {
gEnv->pConsole->ExecuteString(mapCommandString.c_str());
AZ::TickBus::QueueFunction([lvlSystem, i]() {
lvlSystem->LoadLevel(lvlSystem->GetLevelInfo(i)->GetName());
});
}
}
+10
View File
@@ -11,6 +11,7 @@
*/
#include <AzCore/UnitTest/UnitTest.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzQtComponents/Utilities/QtPluginPaths.h>
#include <AzTest/AzTest.h>
#include <AzTest/GemTestEnvironment.h>
@@ -39,6 +40,15 @@ namespace Multiplayer
AddComponentDescriptors(descriptors);
}
/// Allows derived environments to override to perform additional steps after the system entity is activated.
void PostSystemEntityActivate() override
{
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
// in the unit tests.
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
}
};
} // namespace UnitTest
+1 -1
View File
@@ -14,7 +14,7 @@ ly_associate_package(PACKAGE_NAME zlib-1.2.8-rev2-multiplatform TARG
ly_associate_package(PACKAGE_NAME ilmbase-2.3.0-rev4-multiplatform TARGETS ilmbase PACKAGE_HASH 97547fdf1fbc4d81b8ccf382261f8c25514ed3b3c4f8fd493f0a4fa873bba348)
ly_associate_package(PACKAGE_NAME hdf5-1.0.11-rev2-multiplatform TARGETS hdf5 PACKAGE_HASH 11d5e04df8a93f8c52a5684a4cacbf0d9003056360983ce34f8d7b601082c6bd)
ly_associate_package(PACKAGE_NAME alembic-1.7.11-rev3-multiplatform TARGETS alembic PACKAGE_HASH ba7a7d4943dd752f5a662374f6c48b93493df1d8e2c5f6a8d101f3b50700dd25)
ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev7-multiplatform TARGETS assimplib PACKAGE_HASH def855c89d8210db3040f1cb6ec837141ab9b8e74c158eae7c03d50160fcf30b)
ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev9-multiplatform TARGETS assimplib PACKAGE_HASH 448530277b51b145ca43b96becd0266e29ae210fc9e2b45f5afe85f301a040e7)
ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3)
ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326)
ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf)
+2 -2
View File
@@ -14,7 +14,7 @@ ly_associate_package(PACKAGE_NAME zlib-1.2.8-rev2-multiplatform
ly_associate_package(PACKAGE_NAME ilmbase-2.3.0-rev4-multiplatform TARGETS ilmbase PACKAGE_HASH 97547fdf1fbc4d81b8ccf382261f8c25514ed3b3c4f8fd493f0a4fa873bba348)
ly_associate_package(PACKAGE_NAME hdf5-1.0.11-rev2-multiplatform TARGETS hdf5 PACKAGE_HASH 11d5e04df8a93f8c52a5684a4cacbf0d9003056360983ce34f8d7b601082c6bd)
ly_associate_package(PACKAGE_NAME alembic-1.7.11-rev3-multiplatform TARGETS alembic PACKAGE_HASH ba7a7d4943dd752f5a662374f6c48b93493df1d8e2c5f6a8d101f3b50700dd25)
ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev7-multiplatform TARGETS assimplib PACKAGE_HASH def855c89d8210db3040f1cb6ec837141ab9b8e74c158eae7c03d50160fcf30b)
ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev9-multiplatform TARGETS assimplib PACKAGE_HASH 448530277b51b145ca43b96becd0266e29ae210fc9e2b45f5afe85f301a040e7)
ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3)
ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326)
ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf)
@@ -26,7 +26,7 @@ ly_associate_package(PACKAGE_NAME lz4-r128-multiplatform
ly_associate_package(PACKAGE_NAME expat-2.1.0-multiplatform TARGETS expat PACKAGE_HASH 452256acd1fd699cef24162575b3524fccfb712f5321c83f1df1ce878de5b418)
ly_associate_package(PACKAGE_NAME zstd-1.35-multiplatform TARGETS zstd PACKAGE_HASH 45d466c435f1095898578eedde85acf1fd27190e7ea99aeaa9acfd2f09e12665)
ly_associate_package(PACKAGE_NAME SQLite-3.32.2-rev3-multiplatform TARGETS SQLite PACKAGE_HASH dd4d3de6cbb4ce3d15fc504ba0ae0587e515dc89a25228037035fc0aef4831f4)
ly_associate_package(PACKAGE_NAME SPIRVCross-2020.04.20-rev1-multiplatform TARGETS SPIRVCross PACKAGE_HASH 7c8c0eaa0166c26745c62d2238525af7e27ac058a5db3defdbaec1878e8798dd)
ly_associate_package(PACKAGE_NAME SPIRVCross-2021.04.29-rev1-mac TARGETS SPIRVCross PACKAGE_HASH 78c6376ed2fd195b9b1f5fb2b56e5267a32c3aa21fb399e905308de470eb4515)
ly_associate_package(PACKAGE_NAME DirectXShaderCompiler-1.6.2104-o3de-rev1-mac TARGETS DirectXShaderCompilerDxc PACKAGE_HASH 4e97484f8fcf73fc39f22fc85ae86933a8f2e3ba0748fcec128bce05795035a6)
ly_associate_package(PACKAGE_NAME azslc-1.7.21-rev1-multiplatform TARGETS azslc PACKAGE_HASH 772b7a2d9cc68aa1da4f0ee7db57ee1b4e7a8f20b81961fc5849af779582f4df)
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)
@@ -14,7 +14,7 @@ ly_associate_package(PACKAGE_NAME zlib-1.2.8-rev2-multiplatform
ly_associate_package(PACKAGE_NAME ilmbase-2.3.0-rev4-multiplatform TARGETS ilmbase PACKAGE_HASH 97547fdf1fbc4d81b8ccf382261f8c25514ed3b3c4f8fd493f0a4fa873bba348)
ly_associate_package(PACKAGE_NAME hdf5-1.0.11-rev2-multiplatform TARGETS hdf5 PACKAGE_HASH 11d5e04df8a93f8c52a5684a4cacbf0d9003056360983ce34f8d7b601082c6bd)
ly_associate_package(PACKAGE_NAME alembic-1.7.11-rev3-multiplatform TARGETS alembic PACKAGE_HASH ba7a7d4943dd752f5a662374f6c48b93493df1d8e2c5f6a8d101f3b50700dd25)
ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev7-multiplatform TARGETS assimplib PACKAGE_HASH def855c89d8210db3040f1cb6ec837141ab9b8e74c158eae7c03d50160fcf30b)
ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev9-multiplatform TARGETS assimplib PACKAGE_HASH 448530277b51b145ca43b96becd0266e29ae210fc9e2b45f5afe85f301a040e7)
ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3)
ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326)
ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf)
@@ -26,7 +26,7 @@ ly_associate_package(PACKAGE_NAME lz4-r128-multiplatform
ly_associate_package(PACKAGE_NAME expat-2.1.0-multiplatform TARGETS expat PACKAGE_HASH 452256acd1fd699cef24162575b3524fccfb712f5321c83f1df1ce878de5b418)
ly_associate_package(PACKAGE_NAME zstd-1.35-multiplatform TARGETS zstd PACKAGE_HASH 45d466c435f1095898578eedde85acf1fd27190e7ea99aeaa9acfd2f09e12665)
ly_associate_package(PACKAGE_NAME SQLite-3.32.2-rev3-multiplatform TARGETS SQLite PACKAGE_HASH dd4d3de6cbb4ce3d15fc504ba0ae0587e515dc89a25228037035fc0aef4831f4)
ly_associate_package(PACKAGE_NAME SPIRVCross-2020.04.20-rev1-multiplatform TARGETS SPIRVCross PACKAGE_HASH 7c8c0eaa0166c26745c62d2238525af7e27ac058a5db3defdbaec1878e8798dd)
ly_associate_package(PACKAGE_NAME SPIRVCross-2021.04.29-rev1-windows TARGETS SPIRVCross PACKAGE_HASH 7d601ea9d625b1d509d38bd132a1f433d7e895b16adab76bac6103567a7a6817)
ly_associate_package(PACKAGE_NAME DirectXShaderCompiler-1.6.2104-o3de-rev1-windows TARGETS DirectXShaderCompilerDxc PACKAGE_HASH 2c60297758d73f7833911e5ae3006fe0b10ced6e0b1b54764b33ae2b86e0d41d)
ly_associate_package(PACKAGE_NAME azslc-1.7.21-rev1-multiplatform TARGETS azslc PACKAGE_HASH 772b7a2d9cc68aa1da4f0ee7db57ee1b4e7a8f20b81961fc5849af779582f4df)
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)