Merge branch 'main' into ATOM/tonypeng/ATOM-15175

This commit is contained in:
Peng
2021-04-22 14:46:26 -07:00
441 changed files with 16223 additions and 26825 deletions
@@ -27,15 +27,6 @@ def testing_cvar(setMethod, methodName, label, value, compare):
print('{} failed'.format(methodName))
def testing_edit_mode(mode):
general.set_edit_mode(mode)
if (general.get_edit_mode(mode)):
return True
return False
def testing_axis_constraints(constraint):
general.set_axis_constraint(constraint)
@@ -58,15 +49,6 @@ compare = lambda lhs, rhs: rhs == int(lhs)
testing_cvar(general.set_cvar_integer, 'set_cvar_integer', 'sys_LocalMemoryGeometryLimit', 33, compare)
# ----- Test Edit Mode
if (testing_edit_mode("SELECT") and testing_edit_mode('SELECTAREA') and
testing_edit_mode("MOVE") and testing_edit_mode("ROTATE") and
testing_edit_mode("SCALE") and testing_edit_mode("TOOL")):
print("edit mode works")
# ----- Test Axis Constraints
if (testing_axis_constraints("X") and testing_axis_constraints("Y") and
@@ -33,7 +33,6 @@ class TestEditorAutomation(object):
"SetCVarFromFloat worked",
"SetCVarFromString worked",
"SetCVarFromInteger worked",
"edit mode works",
"axis constraint works",
"end of editor utility tests"
]
@@ -48,7 +47,6 @@ class TestEditorAutomation(object):
"set_cvar_float worked",
"set_cvar_string worked",
"set_cvar_integer worked",
"edit mode works",
"axis constraint works",
"end of editor utility tests"
]
@@ -28,15 +28,6 @@ def testing_cvar(setMethod, methodName, label, value, compare):
print('{} failed'.format(methodName))
def testing_edit_mode(mode):
python_editor_funcs.PythonEditorBus(bus.Broadcast, 'SetEditMode', mode)
if mode == python_editor_funcs.PythonEditorBus(bus.Broadcast, 'GetEditMode'):
return True
return False
def testing_axis_constraints(constraint):
python_editor_funcs.PythonEditorBus(bus.Broadcast, 'SetAxisConstraint', constraint)
@@ -57,13 +48,6 @@ testing_cvar('SetCVarFromString', 'SetCVarFromString', 'e_ScreenShotFileFormat',
compare = lambda lhs, rhs: rhs == int(lhs)
testing_cvar('SetCVarFromInteger', 'SetCVarFromInteger', 'sys_LocalMemoryGeometryLimit', 33, compare)
# ----- Test Edit Mode
if (testing_edit_mode("SELECT") and testing_edit_mode('SELECTAREA') and
testing_edit_mode("MOVE") and testing_edit_mode("ROTATE") and
testing_edit_mode("SCALE") and testing_edit_mode("TOOL")):
print("edit mode works")
# ----- Test Axis Constraints
if (testing_axis_constraints("X") and testing_axis_constraints("Y") and
@@ -22,7 +22,7 @@ import ly_test_tools.environment.file_system as file_system
import ly_test_tools.log.log_monitor
import ly_test_tools.environment.waiter as waiter
@pytest.mark.SUITE_sandbox
@pytest.mark.SUITE_periodic
@pytest.mark.parametrize('launcher_platform', ['windows_editor'])
@pytest.mark.parametrize('project', ['AutomatedTesting'])
@pytest.mark.parametrize('level', ['auto_test'])
@@ -31,14 +31,13 @@ class TestPythonAssetProcessing(object):
unexpected_lines = []
expected_lines = [
'Mock asset exists',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_X_negative.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_X_positive.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel) found'
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive_1.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative_1.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive_1.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative_1.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive_1.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative_1.azmodel) found',
'Expected subId for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center_1.azmodel) found'
]
timeout = 180
halt_on_unexpected = False
@@ -26,8 +26,9 @@ assetId = azlmbr.asset.AssetCatalogRequestBus(azlmbr.bus.Broadcast, 'GetAssetIdB
if (assetId.is_valid() is False):
raise_and_stop(f'Mock AssetId is not valid! Got {assetId.to_string()} instead')
if (assetId.to_string().endswith(':54c06b89') is False):
raise_and_stop(f'Mock AssetId has unexpected sub-id for {mockAssetPath}!')
assetIdString = assetId.to_string()
if (assetIdString.endswith(':528cca58') is False):
raise_and_stop(f'Mock AssetId {assetIdString} has unexpected sub-id for {mockAssetPath}!')
print ('Mock asset exists')
@@ -41,12 +42,12 @@ def test_azmodel_product(generatedModelAssetPath, expectedSubId):
else:
print(f'Expected subId for asset ({generatedModelAssetPath}) found')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.azmodel', '10412075')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_X_positive.azmodel', '10d16e68')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_X_negative.azmodel', '10a71973')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_Y_positive.azmodel', '10130556')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_Y_negative.azmodel', '1065724d')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_Z_positive.azmodel', '1024be55')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_Z_negative.azmodel', '1052c94e')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive_1.azmodel', '10315ae0')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative_1.azmodel', '10661093')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive_1.azmodel', '10af8810')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative_1.azmodel', '10f8c263')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive_1.azmodel', '100ac47f')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative_1.azmodel', '105d8e0c')
test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center_1.azmodel', '1002d464')
azlmbr.editor.EditorToolsApplicationRequestBus(azlmbr.bus.Broadcast, 'ExitNoPrompt')
@@ -1,7 +1,6 @@
"""
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
@@ -27,7 +26,10 @@ def get_mesh_node_names(sceneGraph):
nodeContent = sceneGraph.get_node_content(node)
if nodeContent is not None and nodeContent.CastWithTypeName('MeshData'):
if sceneGraph.is_node_end_point(node) is False:
meshDataList.append(sceneData.SceneGraphName(sceneGraph.get_node_name(node)))
nodeName = sceneData.SceneGraphName(sceneGraph.get_node_name(node))
nodePath = nodeName.get_path()
if (len(nodeName.get_path())):
meshDataList.append(sceneData.SceneGraphName(sceneGraph.get_node_name(node)))
# advance to next node
if sceneGraph.has_node_sibling(node):
@@ -54,17 +56,7 @@ def update_manifest(scene):
meshGroup['id'] = '{' + str(uuid.uuid5(uuid.NAMESPACE_DNS, sourceFilenameOnly + chunkPath)) + '}'
sceneManifest.mesh_group_add_comment(meshGroup, 'auto generated by scene manifest')
sceneManifest.mesh_group_add_advanced_coordinate_system(meshGroup, None, None, None, 1.0)
# create selection node list
pathSet = set()
for meshIndex in range(len(meshNameList)):
targetPath = meshNameList[meshIndex].get_path()
if (activeMeshIndex == meshIndex):
sceneManifest.mesh_group_select_node(meshGroup, targetPath)
else:
if targetPath not in pathSet:
pathSet.update(targetPath)
sceneManifest.mesh_group_unselect_node(meshGroup, targetPath)
sceneManifest.mesh_group_select_node(meshGroup, chunkPath)
return sceneManifest.export()
@@ -85,4 +77,4 @@ def main():
mySceneJobHandler.add_callback('OnUpdateManifest', on_update_manifest)
if __name__ == "__main__":
main()
main()
@@ -117,7 +117,8 @@ class EditorTestHelper:
# Set the viewport back to whatever size it was at the start and restore the pane layout
general.set_viewport_size(int(self.viewport_size.x), int(self.viewport_size.y))
general.set_viewport_expansion_policy("AutoExpand")
general.set_view_pane_layout(self.viewport_layout)
# Temporarily disabling reset of view pane layout: LYN-3120
# general.set_view_pane_layout(self.viewport_layout)
general.update_viewport()
self.log("test finished")
@@ -53,6 +53,8 @@ class TestAltitudeFilterFilterStageToggle(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# Create basic vegetation entity
position = math.Vector3(512.0, 512.0, 32.0)
asset_path = os.path.join("Slices", "PinkFlower.dynamicslice")
@@ -59,6 +59,8 @@ class TestAreaComponentsSliceCreationAndVisibilityToggle(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# 2) C2627900 Verifies if a slice containing the Vegetation Layer Spawner component can be created.
# 2.1) Create basic vegetation entity
position = math.Vector3(512.0, 512.0, 32.0)
@@ -63,6 +63,8 @@ class TestDistanceBetweenFilterComponentOverrides(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# 2) Create a new entity with required vegetation area components
spawner_center_point = math.Vector3(520.0, 520.0, 32.0)
asset_path = os.path.join("Slices", "1m_cube.dynamicslice")
@@ -61,6 +61,8 @@ class TestDistanceBetweenFilterComponent(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# 2) Create a new entity with required vegetation area components
spawner_center_point = math.Vector3(520.0, 520.0, 32.0)
asset_path = os.path.join("Slices", "1m_cube.dynamicslice")
@@ -43,6 +43,7 @@ class TestDynamicSliceInstanceSpawner(EditorTestHelper):
use_terrain=False,
)
general.idle_wait(1.0)
general.set_current_view_position(512.0, 480.0, 38.0)
# Grab the UUID that we need for creating an Dynamic Slice Instance Spawner
dynamic_slice_spawner_uuid = azlmbr.math.Uuid_CreateString('{BBA5CC1E-B4CA-4792-89F7-93711E98FBD1}', 0)
@@ -65,6 +65,8 @@ class TestDynamicSliceInstanceSpawnerEmbeddedEditor(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# 2) Create a new entity with required vegetation area components and Script Canvas component for launcher test
center_point = math.Vector3(512.0, 512.0, 32.0)
asset_path = os.path.join("Slices", "PinkFlower.dynamicslice")
@@ -65,6 +65,8 @@ class TestDynamicSliceInstanceSpawnerExternalEditor(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# 2) Create a new entity with required vegetation area components and switch the Vegetation Asset List Source
# Type to External
entity_position = math.Vector3(512.0, 512.0, 32.0)
@@ -43,6 +43,7 @@ class TestEmptyInstanceSpawner(EditorTestHelper):
use_terrain=False,
)
general.idle_wait(1.0)
general.set_current_view_position(512.0, 480.0, 38.0)
# Grab the UUID that we need for creating an Empty Spawner
empty_spawner_uuid = azlmbr.math.Uuid_CreateString('{23C40FD4-A55F-4BD3-BE5B-DC5423F217C2}', 0)
@@ -60,6 +60,8 @@ class TestLayerSpawnerInheritBehavior(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# Create Emitter entity and add the required components
position = math.Vector3(512.0, 512.0, 32.0)
emitter_entity = dynveg.create_surface_entity("emitter_entity", position, 16.0, 16.0, 1.0)
@@ -61,6 +61,9 @@ class test_MeshBlocker_InstancesBlockedByMesh(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(500.49, 498.69, 46.66)
general.set_current_view_rotation(-42.05, 0.00, -36.33)
# Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape"
entity_position = math.Vector3(512.0, 512.0, 32.0)
asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice")
@@ -90,7 +90,7 @@ class TestRotationModifierOverrides_InstancesRotateWithinRange(EditorTestHelper)
terrain_texture_resolution=4096,
use_terrain=False,
)
general.run_console("e_WaterOcean=0")
general.set_current_view_position(512.0, 480.0, 38.0)
# 2) Create vegetation entity and add components
entity_position = math.Vector3(512.0, 512.0, 32.0)
@@ -103,7 +103,7 @@ class TestRotationModifier_InstancesRotateWithinRange(EditorTestHelper):
terrain_texture_resolution=4096,
use_terrain=False,
)
general.run_console("e_WaterOcean=0")
general.set_current_view_position(512.0, 480.0, 38.0)
# 2) Set up vegetation entities
asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice")
@@ -17,6 +17,7 @@ import azlmbr.paths
import azlmbr.editor as editor
import azlmbr.entity as EntityId
import azlmbr.components as components
import azlmbr.legacy.general as general
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
import automatedtesting_shared.hydra_editor_utils as hydra
@@ -48,6 +49,8 @@ class TestSlopeFilterFilterStageToggle(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# Create basic vegetation entity
position = math.Vector3(512.0, 512.0, 32.0)
asset_path = os.path.join("Slices", "PinkFlower.dynamicslice")
@@ -103,6 +103,8 @@ class TestExclusiveSurfaceMasksTag(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# 2) Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape"
entity_position = math.Vector3(512.0, 512.0, 32.0)
asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice")
@@ -104,6 +104,8 @@ class TestInclusiveSurfaceMasksTag(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# 2) Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape"
entity_position = math.Vector3(512.0, 512.0, 32.0)
asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice")
@@ -15,6 +15,7 @@ import azlmbr.math as math
import azlmbr.paths
import azlmbr.editor as editor
import azlmbr.bus as bus
import azlmbr.legacy.general as general
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
import automatedtesting_shared.hydra_editor_utils as hydra
@@ -52,6 +53,8 @@ class TestSystemSettingsSectorPointDensity(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# Create basic vegetation entity
position = math.Vector3(512.0, 512.0, 32.0)
asset_path = os.path.join("Slices", "PinkFlower.dynamicslice")
@@ -15,6 +15,7 @@ import azlmbr.math as math
import azlmbr.paths
import azlmbr.editor as editor
import azlmbr.bus as bus
import azlmbr.legacy.general as general
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
import automatedtesting_shared.hydra_editor_utils as hydra
@@ -48,6 +49,8 @@ class TestSystemSettingsSectorSize(EditorTestHelper):
use_terrain=False,
)
general.set_current_view_position(512.0, 480.0, 38.0)
# Create basic vegetation entity
position = math.Vector3(512.0, 512.0, 32.0)
asset_path = os.path.join("Slices", "PinkFlower.dynamicslice")
+2 -1
View File
@@ -22,6 +22,7 @@ if(CMAKE_VERSION VERSION_EQUAL 3.19)
endif()
include(cmake/Version.cmake)
include(cmake/OutputDirectory.cmake)
if(NOT PROJECT_NAME)
project(O3DE
@@ -30,7 +31,7 @@ if(NOT PROJECT_NAME)
)
endif()
include(cmake/Initialize.cmake)
include(cmake/GeneralSettings.cmake)
include(cmake/FileUtil.cmake)
include(cmake/PAL.cmake)
include(cmake/PALTools.cmake)
+1 -352
View File
@@ -11,7 +11,7 @@
*/
#pragma once
#include <LyShine/ILyShine.h>
#include <IRenderer.h>
#include <AzCore/Math/Vector2.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/Math/Color.h>
@@ -115,355 +115,4 @@ public: // member functions
//! Implement virtual destructor just for safety.
virtual ~IDraw2d() {}
//! Start a section of 2D drawing function calls. This will set appropriate render state.
//
//! \param deferCalls If true then actual render calls are deferred until the end of the frame
virtual void BeginDraw2d(bool deferCalls = false) = 0;
//! Start a section of 2D drawing function calls. This will set appropriate render state.
//! This variant allows the viewport size to be specified
//
//! \param viewportSize The size of the viewport being rendered to
//! \param deferCalls If true then actual render calls are deferred until the end of the frame
virtual void BeginDraw2d(AZ::Vector2 viewportSize, bool deferCalls = false) = 0;
//! End a section of 2D drawing function calls. This will reset some render state.
virtual void EndDraw2d() = 0;
//! Draw a textured quad with the top left corner at the given position.
//
//! The image is drawn with the color specified by SetShapeColor and the opacity
//! passed as an argument.
//! If rotation is non-zero then the quad is rotated. If the pivot point is
//! provided then the points of the quad are rotated about that point, otherwise
//! they are rotated about the top left corner of the quad.
//! \param texId The texture ID returned by ITexture::GetTextureID()
//! \param position Position of the top left corner of the quad (before rotation) in pixels
//! \param size The width and height of the quad. Use texture width and height to avoid minification,
//! magnification or stretching (assuming the minMaxTexCoords are left to the default)
//! \param opacity The alpha value used when blending
//! \param rotation Angle of rotation in degrees counter-clockwise
//! \param pivotPoint The point about which the quad is rotated
//! \param minMaxTexCoords An optional two component array. The first component is the UV coord for the top left
//! point of the quad and the second is the UV coord of the bottom right point of the quad
//! \param imageOptions Optional struct specifying options that tend to be the same from call to call
virtual void DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float opacity = 1.0f,
float rotation = 0.0f, const AZ::Vector2* pivotPoint = nullptr, const AZ::Vector2* minMaxTexCoords = nullptr,
ImageOptions* imageOptions = nullptr) = 0;
//! Draw a textured quad where the position specifies the point specified by the alignment.
//
//! Rotation is always around the position.
//! \param texId The texture ID returned by ITexture::GetTextureID()
//! \param position Position align point of the quad (before rotation) in pixels
//! \param size The width and height of the quad. Use texture width and height to avoid minification,
//! magnification or stretching (assuming the minMaxTexCoords are left to the default)
//! \param horizontalAlignment Specifies how the quad is horizontally aligned to the given position
//! \param verticalAlignment Specifies how the quad is vertically aligned to the given position
//! \param opacity The alpha value used when blending
//! \param rotation Angle of rotation in degrees counter-clockwise
//! \param minMaxTexCoords An optional two component array. The first component is the UV coord for the top left
//! point of the quad and the second is the UV coord of the bottom right point of the quad
//! \param imageOptions Optional struct specifying options that tend to be the same from call to call
virtual void DrawImageAligned(int texId, AZ::Vector2 position, AZ::Vector2 size,
HAlign horizontalAlignment, VAlign verticalAlignment,
float opacity = 1.0f, float rotation = 0.0f, const AZ::Vector2* minMaxTexCoords = nullptr,
ImageOptions* imageOptions = nullptr) = 0;
//! Draw a textured quad where the position, color and uv of each point is specified explicitly
//
//! \param texId The texture ID returned by ITexture::GetTextureID()
//! \param verts An array of 4 vertices, in clockwise order (e.g. top left, top right, bottom right, bottom left)
//! \param blendMode UseDefault means default blend mode (currently GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA)
//! \param pixelRounding Whether and how to round pixel coordinates
//! \param baseState Additional render state to pass to or into value passed to renderer SetState
virtual void DrawQuad(int texId, VertexPosColUV* verts,
int blendMode = UseDefault,
Rounding pixelRounding = Rounding::Nearest,
int baseState = UseDefault) = 0;
//! Draw a line
//
//! \param start The start position
//! \param end The end position
//! \param color The color of the line
//! \param blendMode UseDefault means default blend mode (currently GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA)
//! \param pixelRounding Whether and how to round pixel coordinates
//! \param baseState Additional render state to pass to or into value passed to renderer SetState
virtual void DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color,
int blendMode = UseDefault,
IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest,
int baseState = UseDefault) = 0;
//! Draw a line with a texture so it can be dotted or dashed
//
//! \param texId The texture ID returned by ITexture::GetTextureID()
//! \param verts An array of 2 vertices for the start and end points of the line
//! \param blendMode UseDefault means default blend mode (currently GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA)
//! \param pixelRounding Whether and how to round pixel coordinates
//! \param baseState Additional render state to pass to or into value passed to renderer SetState
virtual void DrawLineTextured(int texId, VertexPosColUV* verts,
int blendMode = UseDefault,
IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest,
int baseState = UseDefault) = 0;
//! Draw a text string. Only supports ASCII text.
//
//! The font and effect used to render the text are specified in the textOptions structure
//! \param textString A null terminated ASCII text string. May contain \n characters
//! \param position Position of the text in pixels. Alignment values in textOptions affect actual position
//! \param pointSize The size of the font to use
//! \param opacity The opacity (alpha value) to use to draw the text
//! \param textOptions Pointer to an options struct. If null the default options are used
virtual void DrawText(const char* textString, AZ::Vector2 position, float pointSize,
float opacity = 1.0f, TextOptions* textOptions = nullptr) = 0;
//! Get the width and height (in pixels) that would be used to draw the given text string.
//
//! Pass the same parameter values that would be used to draw the string
virtual AZ::Vector2 GetTextSize(const char* textString, float pointSize, TextOptions* textOptions = nullptr) = 0;
//! Get the width of the rendering viewport (in pixels).
//
//! If rendering full screen this is the native width from IRenderer
virtual float GetViewportWidth() const = 0;
//! Get the height of the rendering viewport (in pixels).
//
//! If rendering full screen this is the native width from IRenderer
virtual float GetViewportHeight() const = 0;
//! Get the default values that would be used if no image options were passed in
//
//! This is a convenient way to initialize the imageOptions struct
virtual const ImageOptions& GetDefaultImageOptions() const = 0;
//! Get the default values that would be used if no text options were passed in
//
//! This is a convenient way to initialize the textOptions struct
virtual const TextOptions& GetDefaultTextOptions() const = 0;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Helper class for using the IDraw2d interface
//!
//! The Draw2dHelper class is an inline wrapper that provides two convenience features:
//! 1. It automatically calls BeginDraw2d/EndDraw2d in its construction/destruction.
//! 2. It automatically sets member options structures to their defaults and provides set functions
//! to set them.
class Draw2dHelper
{
public: // member functions
//! Start a section of 2D drawing function calls. This will set appropriate render state.
Draw2dHelper(bool deferCalls = false)
: m_draw2d(GetDraw2d())
{
if (m_draw2d)
{
m_draw2d->BeginDraw2d(deferCalls);
m_imageOptions = m_draw2d->GetDefaultImageOptions();
m_textOptions = m_draw2d->GetDefaultTextOptions();
}
}
//! End a section of 2D drawing function calls. This will reset some render state.
~Draw2dHelper()
{
if (m_draw2d)
{
m_draw2d->EndDraw2d();
}
}
//! Draw a textured quad, optional rotation is counter-clockwise in degrees.
//
//! See IDraw2d:DrawImage for parameter descriptions
void DrawImage(int texId, AZ::Vector2 position, AZ::Vector2 size, float opacity = 1.0f,
float rotation = 0.0f, const AZ::Vector2* pivotPoint = nullptr, const AZ::Vector2* minMaxTexCoords = nullptr)
{
if (m_draw2d)
{
m_draw2d->DrawImage(texId, position, size, opacity, rotation, pivotPoint, minMaxTexCoords, &m_imageOptions);
}
}
//! Draw a textured quad where the position specifies the point specified by the alignment.
//
//! See IDraw2d:DrawImageAligned for parameter descriptions
void DrawImageAligned(int texId, AZ::Vector2 position, AZ::Vector2 size,
IDraw2d::HAlign horizontalAlignment, IDraw2d::VAlign verticalAlignment,
float opacity = 1.0f, float rotation = 0.0f, const AZ::Vector2* minMaxTexCoords = nullptr)
{
if (m_draw2d)
{
m_draw2d->DrawImageAligned(texId, position, size, horizontalAlignment, verticalAlignment,
opacity, rotation, minMaxTexCoords, &m_imageOptions);
}
}
//! Draw a textured quad where the position, color and uv of each point is specified explicitly
//
//! See IDraw2d:DrawQuad for parameter descriptions
void DrawQuad(int texId, IDraw2d::VertexPosColUV* verts, int blendMode = IDraw2d::UseDefault,
IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest,
int baseState = IDraw2d::UseDefault)
{
if (m_draw2d)
{
m_draw2d->DrawQuad(texId, verts, blendMode, pixelRounding, baseState);
}
}
//! Draw a line
//
//! See IDraw2d:DrawLine for parameter descriptions
void DrawLine(AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, int blendMode = IDraw2d::UseDefault,
IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest,
int baseState = IDraw2d::UseDefault)
{
if (m_draw2d)
{
m_draw2d->DrawLine(start, end, color, blendMode, pixelRounding, baseState);
}
}
//! Draw a line with a texture so it can be dotted or dashed
//
//! See IDraw2d:DrawLineTextured for parameter descriptions
void DrawLineTextured(int texId, IDraw2d::VertexPosColUV* verts, int blendMode = IDraw2d::UseDefault,
IDraw2d::Rounding pixelRounding = IDraw2d::Rounding::Nearest,
int baseState = IDraw2d::UseDefault)
{
if (m_draw2d)
{
m_draw2d->DrawLineTextured(texId, verts, blendMode, pixelRounding, baseState);
}
}
//! Draw a text string. Only supports ASCII text.
//
//! See IDraw2d:DrawText for parameter descriptions
void DrawText(const char* textString, AZ::Vector2 position, float pointSize, float opacity = 1.0f)
{
if (m_draw2d)
{
m_draw2d->DrawText(textString, position, pointSize, opacity, &m_textOptions);
}
}
//! Get the width and height (in pixels) that would be used to draw the given text string.
//
//! See IDraw2d:GetTextSize for parameter descriptions
AZ::Vector2 GetTextSize(const char* textString, float pointSize)
{
if (m_draw2d)
{
return m_draw2d->GetTextSize(textString, pointSize, &m_textOptions);
}
else
{
return AZ::Vector2(0, 0);
}
}
// State management
//! Set the blend mode used for images, default is GS_BLSRC_SRCALPHA|GS_BLDST_ONEMINUSSRCALPHA.
void SetImageBlendMode(int mode) { m_imageOptions.blendMode = mode; }
//! Set the color used for DrawImage and other image drawing.
void SetImageColor(AZ::Vector3 color) { m_imageOptions.color = color; }
//! Set whether images are rounded to have the points on exact pixel boundaries.
void SetImagePixelRounding(IDraw2d::Rounding round) { m_imageOptions.pixelRounding = round; }
//! Set the base state (that blend mode etc is combined with) used for images, default is GS_NODEPTHTEST.
void SetImageBaseState(int state) { m_imageOptions.baseState = state; }
//! Set the text font.
void SetTextFont(IFFont* font) { m_textOptions.font = font; }
//! Set the text font effect index.
void SetTextEffectIndex(unsigned int effectIndex) { m_textOptions.effectIndex = effectIndex; }
//! Set the text color.
void SetTextColor(AZ::Vector3 color) { m_textOptions.color = color; }
//! Set the text alignment.
void SetTextAlignment(IDraw2d::HAlign horizontalAlignment, IDraw2d::VAlign verticalAlignment)
{
m_textOptions.horizontalAlignment = horizontalAlignment;
m_textOptions.verticalAlignment = verticalAlignment;
}
//! Set a drop shadow for text drawing. An alpha of zero disables drop shadow.
void SetTextDropShadow(AZ::Vector2 offset, AZ::Color color)
{
m_textOptions.dropShadowOffset = offset;
m_textOptions.dropShadowColor = color;
}
//! Set a rotation for the text. The text rotates around its position (taking into account alignment).
void SetTextRotation(float rotation)
{
m_textOptions.rotation = rotation;
}
//! Set the base state (that blend mode etc is combined with) used for text, default is GS_NODEPTHTEST.
void SetTextBaseState(int state) { m_textOptions.baseState = state; }
public: // static member functions
//! Helper to get the IDraw2d interface
static IDraw2d* GetDraw2d() { return (gEnv && gEnv->pLyShine) ? gEnv->pLyShine->GetDraw2d() : nullptr; }
//! Get the width of the rendering viewport (in pixels).
static float GetViewportWidth()
{
IDraw2d* draw2d = GetDraw2d();
return (draw2d) ? draw2d->GetViewportWidth() : 0.0f;
}
//! Get the height of the rendering viewport (in pixels).
static float GetViewportHeight()
{
IDraw2d* draw2d = GetDraw2d();
return (draw2d) ? draw2d->GetViewportHeight() : 0.0f;
}
//! Round the X and Y coordinates of a point using the given rounding policy
template<typename T>
static T RoundXY(T value, IDraw2d::Rounding roundingType)
{
T result = value;
switch (roundingType)
{
case IDraw2d::Rounding::None:
// nothing to do
break;
case IDraw2d::Rounding::Nearest:
result.SetX(floor(value.GetX() + 0.5f));
result.SetY(floor(value.GetY() + 0.5f));
break;
case IDraw2d::Rounding::Down:
result.SetX(floor(value.GetX()));
result.SetY(floor(value.GetY()));
break;
case IDraw2d::Rounding::Up:
result.SetX(ceil(value.GetX()));
result.SetY(ceil(value.GetY()));
break;
}
return result;
}
protected: // attributes
IDraw2d::ImageOptions m_imageOptions; //!< image options are stored locally and updated by member functions
IDraw2d::TextOptions m_textOptions; //!< text options are stored locally and updated by member functions
IDraw2d* m_draw2d;
};
@@ -1,79 +0,0 @@
/*
* 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.
*
*/
#pragma once
#include <LyShine/IDraw2d.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface used by UI components to render to the canvas
//
//! The IUiRenderer provides helper functions for UI rendering and also manages state that
//! persists between UI elements when rendering a UI canvas.
//! For example one UI component can turn on stencil test and that affects all UI rendering
//! until it is turned off.
//!
//! This is a singleton class that is accessed via IUiRenderer::Get() which is a shortcut for
//! gEnv->pLyShine()->GetUiRenderer();
class IUiRenderer
{
public: // types
public: // member functions
//! Implement virtual destructor for safety.
virtual ~IUiRenderer() {}
//! Start the rendering of a UI canvas
virtual void BeginCanvasRender(AZ::Vector2 viewportSize) = 0;
//! End the rendering of a UI canvas
virtual void EndCanvasRender() = 0;
//! Get the current base state
virtual int GetBaseState() = 0;
//! Set the base state
virtual void SetBaseState(int state) = 0;
//! Get the current stencil test reference value
virtual uint32 GetStencilRef() = 0;
//! Set the stencil test reference value
virtual void SetStencilRef(uint32) = 0;
//! Increment the current stencil reference value
virtual void IncrementStencilRef() = 0;
//! Decrement the current stencil reference value
virtual void DecrementStencilRef() = 0;
//! Get flag that indicates we are rendering into a mask. Used to avoid masks on child mask elements.
virtual bool IsRenderingToMask() = 0;
//! Set flag that we are rendering into a mask. Used to avoid masks on child mask elements.
virtual void SetIsRenderingToMask(bool isRenderingToMask) = 0;
//! Push an alpha fade, this is multiplied with any existing alpha fade from parents
virtual void PushAlphaFade(float alphaFadeValue) = 0;
//! Pop an alpha fade off the stack
virtual void PopAlphaFade() = 0;
//! Get the current alpha fade value
virtual float GetAlphaFade() const = 0;
public: // static member functions
//! Helper function to get the singleton UiRenderer
static IUiRenderer* Get() { return gEnv->pLyShine->GetUiRenderer(); }
};
@@ -20,6 +20,7 @@
#include <AzCore/Component/Entity.h>
#include <LyShine/UiAssetTypes.h>
#include <LyShine/UiBase.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
+1
View File
@@ -4094,6 +4094,7 @@ void CSystem::CreateSystemVars()
"0 = Suppress Asserts\n"
"1 = Log Asserts\n"
"2 = Show Assert Dialog\n"
"3 = Crashes the Application on Assert\n"
"Note: when set to '0 = Suppress Asserts', assert expressions are still evaluated. To turn asserts into a no-op, undefine AZ_ENABLE_TRACING and recompile.",
OnAssertLevelCvarChanged);
CSystem::SetAssertLevel(defaultAssertValue);
@@ -63,13 +63,13 @@ namespace AZ
static AssetTrackingImpl* GetSharedInstance();
static ThreadData& GetSharedThreadData();
using MasterAssets = AZStd::unordered_map<AssetTrackingId, AssetMasterInfo, AZStd::hash<AssetTrackingId>, AZStd::equal_to<AssetTrackingId>, AZStdAssetTrackingAllocator>;
using PrimaryAssets = AZStd::unordered_map<AssetTrackingId, AssetPrimaryInfo, AZStd::hash<AssetTrackingId>, AZStd::equal_to<AssetTrackingId>, AZStdAssetTrackingAllocator>;
using ThreadData = ThreadData;
using mutex_type = AZStd::mutex;
using lock_type = AZStd::lock_guard<mutex_type>;
mutex_type m_mutex;
MasterAssets m_masterAssets;
PrimaryAssets m_primaryAssets;
AssetTreeNodeBase* m_assetRoot = nullptr;
AssetAllocationTableBase* m_allocationTable = nullptr;
bool m_performingAnalysis = false;
@@ -118,7 +118,7 @@ namespace AZ
auto& threadData = GetSharedThreadData();
AssetTreeNodeBase* parentAsset = threadData.m_currentAssetStack.empty() ? nullptr : threadData.m_currentAssetStack.back();
AssetTreeNodeBase* childAsset;
AssetMasterInfo* assetMasterInfo;
AssetPrimaryInfo* assetPrimaryInfo;
if (!parentAsset)
{
@@ -128,22 +128,22 @@ namespace AZ
{
lock_type lock(m_mutex);
// Locate or create the master record for this asset
auto masterItr = m_masterAssets.find(assetId);
// Locate or create the primary record for this asset
auto primaryItr = m_primaryAssets.find(assetId);
if (masterItr != m_masterAssets.end())
if (primaryItr != m_primaryAssets.end())
{
assetMasterInfo = &masterItr->second;
assetPrimaryInfo = &primaryItr->second;
}
else
{
auto insertResult = m_masterAssets.emplace(assetId, AssetMasterInfo());
assetMasterInfo = &insertResult.first->second;
assetMasterInfo->m_id = &insertResult.first->first;
auto insertResult = m_primaryAssets.emplace(assetId, AssetPrimaryInfo());
assetPrimaryInfo = &insertResult.first->second;
assetPrimaryInfo->m_id = &insertResult.first->first;
}
// Add this asset to the stack for this thread's context
childAsset = parentAsset->FindOrAddChild(assetId, assetMasterInfo);
childAsset = parentAsset->FindOrAddChild(assetId, assetPrimaryInfo);
}
threadData.m_currentAssetStack.push_back(childAsset);
@@ -304,7 +304,7 @@ namespace AZ
char* pos = buffer;
for (auto itr = assetStack.rbegin(); itr != assetStack.rend(); ++itr)
{
pos += azsnprintf(pos, BUFFER_SIZE - (pos - buffer), "%s\n", (*itr)->GetAssetMasterInfo()->m_id->m_id.c_str());
pos += azsnprintf(pos, BUFFER_SIZE - (pos - buffer), "%s\n", (*itr)->GetAssetPrimaryInfo()->m_id->m_id.c_str());
if (pos >= buffer + BUFFER_SIZE)
{
@@ -79,9 +79,9 @@ namespace AZ
AssetTrackingString m_id;
};
// Master information about an asset.
// Primary information about an asset.
// Currently just contains the ID of the asset, but in the future may carry additional information about that asset (such as where in code it was initialized).
struct AssetMasterInfo
struct AssetPrimaryInfo
{
const AssetTrackingId* m_id;
};
@@ -90,8 +90,8 @@ namespace AZ
class AssetTreeNodeBase
{
public:
virtual const AssetMasterInfo* GetAssetMasterInfo() const = 0;
virtual AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetMasterInfo* info) = 0;
virtual const AssetPrimaryInfo* GetAssetPrimaryInfo() const = 0;
virtual AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetPrimaryInfo* info) = 0;
};
// Base class for an asset tree. Implemented by the template AssetTree<>.
@@ -29,18 +29,18 @@ namespace AZ
class AssetTreeNode : public AssetTreeNodeBase
{
public:
AssetTreeNode(const AssetMasterInfo* masterInfo = nullptr, AssetTreeNode* parent = nullptr) :
m_masterInfo(masterInfo),
AssetTreeNode(const AssetPrimaryInfo* primaryInfo = nullptr, AssetTreeNode* parent = nullptr) :
m_primaryinfo(primaryInfo),
m_parent(parent)
{
}
const AssetMasterInfo* GetAssetMasterInfo() const override
const AssetPrimaryInfo* GetAssetPrimaryInfo() const override
{
return m_masterInfo;
return m_primaryinfo;
}
AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetMasterInfo* info) override
AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetPrimaryInfo* info) override
{
AssetTreeNodeBase* result = nullptr;
auto childItr = m_children.find(id);
@@ -61,7 +61,7 @@ namespace AZ
using AssetMap = AssetTrackingMap<AssetTrackingId, AssetTreeNode>;
const AssetMasterInfo* m_masterInfo;
const AssetPrimaryInfo* m_primaryinfo;
AssetTreeNode* m_parent;
AssetMap m_children;
AssetDataT m_data;
+9 -2
View File
@@ -70,6 +70,7 @@ namespace AZ
static const char* logVerbosityUID = "sys_LogLevel";
static const int assertLevel_log = 1;
static const int assertLevel_nativeUI = 2;
static const int assertLevel_crash = 3;
static const int logLevel_errorWarning = 1;
static const int logLevel_full = 2;
static AZ::EnvironmentVariable<AZStd::unordered_set<size_t>> g_ignoredAsserts;
@@ -289,8 +290,8 @@ namespace AZ
}
#if AZ_ENABLE_TRACE_ASSERTS
//display native UI dialogs at verbosity level 2 or higher
if (currentLevel >= assertLevel_nativeUI)
//display native UI dialogs at verbosity level 2
if (currentLevel == assertLevel_nativeUI)
{
AZ::NativeUI::AssertAction buttonResult;
EBUS_EVENT_RESULT(buttonResult, AZ::NativeUI::NativeUIRequestBus, DisplayAssertDialog, dialogBoxText);
@@ -314,7 +315,13 @@ namespace AZ
break;
}
}
else
#endif //AZ_ENABLE_TRACE_ASSERTS
// Crash the application directly at assert level 3
if (currentLevel >= assertLevel_crash)
{
AZ_Crash();
}
}
g_alreadyHandlingAssertOrFatal = false;
}
+29 -2
View File
@@ -146,8 +146,8 @@ namespace AZ
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Method("GetTranslated", &Aabb::GetTranslated)
->Method("GetSurfaceArea", &Aabb::GetSurfaceArea)
->Method("GetTransformedObb", &Aabb::GetTransformedObb)
->Method("GetTransformedAabb", &Aabb::GetTransformedAabb)
->Method("GetTransformedObb", static_cast<Obb(Aabb::*)(const Transform&) const>(&Aabb::GetTransformedObb))
->Method("GetTransformedAabb", static_cast<Aabb(Aabb::*)(const Transform&) const>(&Aabb::GetTransformedAabb))
->Method("ApplyTransform", &Aabb::ApplyTransform)
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Method("Clone", [](const Aabb& rhs) -> Aabb { return rhs; })
@@ -195,6 +195,20 @@ namespace AZ
}
Obb Aabb::GetTransformedObb(const Matrix3x4& matrix3x4) const
{
Matrix3x4 matrixNoScale = matrix3x4;
const AZ::Vector3 scale = matrixNoScale.ExtractScale();
const AZ::Quaternion rotation = AZ::Quaternion::CreateFromMatrix3x4(matrixNoScale);
return Obb::CreateFromPositionRotationAndHalfLengths(
matrix3x4 * GetCenter(),
rotation,
0.5f * scale * GetExtents()
);
}
void Aabb::ApplyTransform(const Transform& transform)
{
Vector3 a, b, axisCoeffs;
@@ -224,4 +238,17 @@ namespace AZ
m_min = newMin;
m_max = newMax;
}
void Aabb::ApplyMatrix3x4(const Matrix3x4& matrix3x4)
{
const AZ::Vector3 extents = GetExtents();
const AZ::Vector3 center = matrix3x4 * GetCenter();
AZ::Vector3 newHalfExtents(
0.5f * matrix3x4.GetRowAsVector3(0).GetAbs().Dot(extents),
0.5f * matrix3x4.GetRowAsVector3(1).GetAbs().Dot(extents),
0.5f * matrix3x4.GetRowAsVector3(2).GetAbs().Dot(extents));
m_min = center - newHalfExtents;
m_max = center + newHalfExtents;
}
}
+12 -2
View File
@@ -129,11 +129,21 @@ namespace AZ
void ApplyTransform(const Transform& transform);
void ApplyMatrix3x4(const Matrix3x4& matrix3x4);
void MultiplyByScale(const Vector3& scale);
//! Transforms an Aabb and returns the resulting Obb.
class Obb GetTransformedObb(const Transform& transform) const;
[[nodiscard]] Obb GetTransformedObb(const Transform& transform) const;
//! Transforms an Aabb and returns the resulting Obb.
[[nodiscard]] Obb GetTransformedObb(const Matrix3x4& matrix3x4) const;
//! Returns a new AABB containing the transformed AABB.
Aabb GetTransformedAabb(const Transform& transform) const;
[[nodiscard]] Aabb GetTransformedAabb(const Transform& transform) const;
//! Returns a new AABB containing the transformed AABB.
[[nodiscard]] Aabb GetTransformedAabb(const Matrix3x4& matrix3x4) const;
//! Checks if this aabb is equal to another within a floating point tolerance.
bool IsClose(const Aabb& rhs, float tolerance = Constants::Tolerance) const;
@@ -292,6 +292,14 @@ namespace AZ
}
AZ_MATH_INLINE void Aabb::MultiplyByScale(const Vector3& scale)
{
m_min *= scale;
m_max *= scale;
AZ_MATH_ASSERT(IsValid(), "Min must be less than Max");
}
AZ_MATH_INLINE Aabb Aabb::GetTransformedAabb(const Transform& transform) const
{
Aabb aabb = Aabb::CreateFromMinMax(m_min, m_max);
@@ -300,6 +308,14 @@ namespace AZ
}
AZ_MATH_INLINE Aabb Aabb::GetTransformedAabb(const Matrix3x4& matrix3x4) const
{
Aabb aabb = Aabb::CreateFromMinMax(m_min, m_max);
aabb.ApplyMatrix3x4(matrix3x4);
return aabb;
}
AZ_MATH_INLINE bool Aabb::IsClose(const Aabb& rhs, float tolerance) const
{
return m_min.IsClose(rhs.m_min, tolerance) && m_max.IsClose(rhs.m_max, tolerance);
@@ -105,7 +105,7 @@ namespace UnitTest
EXPECT_EQ(&rootAsset, &m_env->m_tree.GetRoot());
ASSERT_NE(itr, rootAsset.m_children.end());
EXPECT_EQ(itr->second.m_masterInfo->m_id->m_id, "TestScopedAllocation.1");
EXPECT_EQ(itr->second.m_primaryinfo->m_id->m_id, "TestScopedAllocation.1");
EXPECT_EQ(&itr->second, m_env->m_table.FindAllocation(TEST_POINTER));
@@ -15,6 +15,7 @@
#include <AzCore/Math/Vector3.h>
#include <AzCore/Math/Transform.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AZTestShared/Math/MathTestHelpers.h>
using namespace AZ;
@@ -385,4 +386,77 @@ namespace UnitTest
EXPECT_TRUE(aabb.GetMin().IsClose(transAabb.GetMin()));
EXPECT_TRUE(aabb.GetMax().IsClose(transAabb.GetMax()));
}
TEST(MATH_AabbTransform, GetTransformedObbMatrix3x4)
{
Vector3 min(-1.0f, -2.0f, -3.0f);
Vector3 max(4.0f, 3.0f, 2.0f);
Aabb aabb = Aabb::CreateFromMinMax(min, max);
Quaternion rotation(0.46f, 0.26f, 0.58f, 0.62f);
Vector3 translation(5.0f, 7.0f, 9.0f);
Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation);
matrix3x4.MultiplyByScale(Vector3(0.5f, 1.5f, 2.0f));
Obb obb = aabb.GetTransformedObb(matrix3x4);
EXPECT_THAT(obb.GetRotation(), IsClose(rotation));
EXPECT_THAT(obb.GetHalfLengths(), IsClose(Vector3(1.25f, 3.75f, 5.0f)));
EXPECT_THAT(obb.GetPosition(), IsClose(Vector3(3.928f, 7.9156f, 9.3708f)));
}
TEST(MATH_AabbTransform, GetTransformedAabbMatrix3x4)
{
Vector3 min(2.0f, 3.0f, 5.0f);
Vector3 max(6.0f, 5.0f, 11.0f);
Aabb aabb = Aabb::CreateFromMinMax(min, max);
Quaternion rotation(0.34f, 0.46f, 0.58f, 0.58f);
Vector3 translation(-3.0f, -4.0f, -5.0f);
Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation);
matrix3x4.MultiplyByScale(Vector3(1.2f, 0.8f, 2.0f));
Aabb transformedAabb = aabb.GetTransformedAabb(matrix3x4);
EXPECT_THAT(transformedAabb.GetMin(), IsClose(Vector3(4.1488f, -0.01216f, -0.31904f)));
EXPECT_THAT(transformedAabb.GetMax(), IsClose(Vector3(16.3216f, 6.54272f, 5.98112f)));
}
TEST(MATH_AabbTransform, GetTransformedObbFitsInsideTransformedAabb)
{
Vector3 min(4.0f, 3.0f, 1.0f);
Vector3 max(7.0f, 6.0f, 8.0f);
Aabb aabb = Aabb::CreateFromMinMax(min, max);
Quaternion rotation(0.40f, 0.40f, 0.64f, 0.52f);
Vector3 translation(-2.0f, 4.0f, -3.0f);
Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation);
matrix3x4.MultiplyByScale(Vector3(2.2f, 0.6f, 1.4f));
Aabb transformedAabb = aabb.GetTransformedAabb(matrix3x4);
Obb transformedObb = aabb.GetTransformedObb(matrix3x4);
Aabb aabbContainingTransformedObb = Aabb::CreateFromObb(transformedObb);
EXPECT_THAT(transformedAabb.GetMin(), IsClose(aabbContainingTransformedObb.GetMin()));
EXPECT_THAT(transformedAabb.GetMax(), IsClose(aabbContainingTransformedObb.GetMax()));
}
TEST(MATH_AabbTransform, MultiplyByScale)
{
Vector3 min(2.0f, 6.0f, 8.0f);
Vector3 max(6.0f, 9.0f, 10.0f);
Aabb aabb = Aabb::CreateFromMinMax(min, max);
Vector3 scale(0.5f, 2.0f, 1.5f);
aabb.MultiplyByScale(scale);
EXPECT_THAT(aabb.GetMin(), IsClose(Vector3(1.0f, 12.0f, 12.0f)));
EXPECT_THAT(aabb.GetMax(), IsClose(Vector3(3.0f, 18.0f, 15.0f)));
}
}
@@ -29,6 +29,20 @@ namespace AzFramework::AssetSystem::Platform
bool LaunchAssetProcessor(AZStd::string_view executableDirectory, AZStd::string_view engineRoot,
AZStd::string_view projectPath)
{
AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory };
assetProcessorPath /= "AssetProcessor";
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor";
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
return false;
}
}
pid_t firstChildPid = fork();
if (firstChildPid == 0)
{
@@ -47,9 +61,6 @@ namespace AzFramework::AssetSystem::Platform
pid_t secondChildPid = fork();
if (secondChildPid == 0)
{
AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory };
assetProcessorPath /= "AssetProcessor";
AZStd::array args {
assetProcessorPath.c_str(), assetProcessorPath.c_str(), "--start-hidden",
static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), static_cast<const char*>(nullptr)
@@ -11,6 +11,7 @@
*/
#include <AzCore/IO/Path/Path.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <sys/types.h>
@@ -20,6 +21,7 @@ namespace AzFramework::AssetSystem::Platform
{
void AllowAssetProcessorToForeground()
{}
bool LaunchAssetProcessor(AZStd::string_view executableDirectory, AZStd::string_view engineRoot,
AZStd::string_view projectPath)
{
@@ -29,6 +31,17 @@ namespace AzFramework::AssetSystem::Platform
assetProcessorPath /= "../../../AssetProcessor.app";
assetProcessorPath = assetProcessorPath.LexicallyNormal();
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.app";
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
return false;
}
}
auto fullLaunchCommand = AZ::IO::FixedMaxPathString::format(R"(open -g "%s" --args --start-hidden)", assetProcessorPath.c_str());
// Add the engine path to the launch command if not empty
if (!engineRoot.empty())
@@ -12,6 +12,7 @@
#include <AzCore/PlatformIncl.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <Psapi.h>
@@ -67,6 +68,17 @@ namespace AzFramework::AssetSystem::Platform
AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory };
assetProcessorPath /= "AssetProcessor.exe";
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.exe";
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
return false;
}
}
auto fullLaunchCommand = AZ::IO::FixedMaxPathString::format(R"("%s" --start-hidden)", assetProcessorPath.c_str());
// Add the engine path to the launch command if not empty
@@ -2298,6 +2298,12 @@ namespace AzQtComponents
OptimizedSetParent(dock, mainWindow);
mainWindow->addDockWidget(Qt::LeftDockWidgetArea, dock);
dock->show();
// Make sure we listen for events on the dock widget being put into a floating dock window
// because this might be called programmatically, so the dock widget might have never been
// parented to our m_mainWindow initially, so it won't already have an event filter,
// which will prevent the docking functionality from working.
dock->installEventFilter(this);
}
}
@@ -815,8 +815,6 @@ namespace AzToolsFramework
/// Hide or show the circular dependency error when saving slices
virtual void SetShowCircularDependencyError(const bool& /*showCircularDependencyError*/) {}
virtual void SetEditTool(const char* /*tool*/) {}
/// Launches the Lua editor and opens the specified (space separated) files.
virtual void LaunchLuaEditor(const char* /*files*/) {}
@@ -140,7 +140,7 @@ namespace AzToolsFramework
else
{
QPixmap pixmap = thumbnail->GetPixmap(size);
painter->drawPixmap(point.x(), point.y(), size.width(), size.height(), pixmap);
painter->drawPixmap(point, pixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
return m_iconSize;
}
@@ -10,12 +10,14 @@
*
*/
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
AZ_PUSH_DISABLE_WARNING(4127 4251 4800 4244, "-Wunknown-warning-option") // 4127: conditional expression is constant
// 4251: 'QTextCodec::ConverterState::flags': class 'QFlags<QTextCodec::ConversionFlag>' needs to have dll-interface to be used by clients of struct 'QTextCodec::ConverterState'
// 4800: 'QTextBoundaryFinderPrivate *const ': forcing value to bool 'true' or 'false' (performance warning)
// 4244: conversion from 'int' to 'qint8', possible loss of data
#include <QtConcurrent/QtConcurrent>
#include <QThreadPool>
AZ_POP_DISABLE_WARNING
namespace AzToolsFramework
@@ -80,7 +82,11 @@ namespace AzToolsFramework
if (m_state == State::Unloaded)
{
m_state = State::Loading;
QFuture<void> future = QtConcurrent::run([this](){ LoadThread(); });
QThreadPool* threadPool;
ThumbnailContextRequestBus::BroadcastResult(
threadPool,
&ThumbnailContextRequestBus::Handler::GetThreadPool);
QFuture<void> future = QtConcurrent::run(threadPool, [this](){ LoadThread(); });
m_watcher.setFuture(future);
}
}
@@ -28,10 +28,15 @@ namespace AzToolsFramework
: m_missingThumbnail(new MissingThumbnail(thumbnailSize))
, m_loadingThumbnail(new LoadingThumbnail(thumbnailSize))
, m_thumbnailSize(thumbnailSize)
, m_threadPool(this)
{
ThumbnailContextRequestBus::Handler::BusConnect();
}
ThumbnailContext::~ThumbnailContext() = default;
ThumbnailContext::~ThumbnailContext()
{
ThumbnailContextRequestBus::Handler::BusDisconnect();
}
bool ThumbnailContext::IsLoading(SharedThumbnailKey key)
{
@@ -53,6 +58,11 @@ namespace AzToolsFramework
AzToolsFramework::AssetBrowser::AssetBrowserViewRequestBus::Broadcast(&AzToolsFramework::AssetBrowser::AssetBrowserViewRequests::Update);
}
QThreadPool* ThumbnailContext::GetThreadPool()
{
return &m_threadPool;
}
SharedThumbnail ThumbnailContext::GetThumbnail(SharedThumbnailKey key)
{
SharedThumbnail thumbnail;
@@ -19,6 +19,7 @@
#include <QObject>
#include <QList>
#include <QThreadPool>
#endif
class QString;
@@ -40,6 +41,7 @@ namespace AzToolsFramework
*/
class ThumbnailContext
: public QObject
, public ThumbnailContextRequestBus::Handler
{
Q_OBJECT
public:
@@ -58,10 +60,13 @@ namespace AzToolsFramework
void UnregisterThumbnailProvider(const char* providerName);
void RedrawThumbnail();
//! Default context used for most thumbnails
static constexpr const char* DefaultContext = "Default";
// ThumbnailContextRequestBus::Handler interface overrides...
QThreadPool* GetThreadPool() override;
private:
struct ProviderCompare {
bool operator() (const SharedThumbnailProvider& lhs, const SharedThumbnailProvider& rhs) const
@@ -79,6 +84,9 @@ namespace AzToolsFramework
SharedThumbnail m_loadingThumbnail;
//! Thumbnail size (width and height in pixels)
int m_thumbnailSize;
//! There is only a limited number of threads on global threadPool, because there can be many thumbnails rendering at once
//! an individual threadPool is needed to avoid deadlocks
QThreadPool m_threadPool;
};
} // namespace Thumbnailer
} // namespace AzToolsFramework
@@ -81,6 +81,9 @@ namespace AzToolsFramework
int x = (originalWidth - realWidth) / 2;
// pixmap needs to be manually scaled to produce smoother result and avoid looking pixelated
// using painter.setRenderHint(QPainter::SmoothPixmapTransform); does not seem to work
// Note: there is a potential issue with pixmap.scaled:
// it is multithreaded (using global threadPool) and blocking until finished.
// A deadlock will happen if global threadPool has no free threads available.
painter.drawPixmap(QPoint(x, 0), pixmap.scaled(realWidth, realHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
QWidget::paintEvent(event);
@@ -17,11 +17,23 @@
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
class QPixmap;
class QThreadPool;
namespace AzToolsFramework
{
namespace Thumbnailer
{
//! Interaction with thumbnail context
class ThumbnailContextRequests
: public AZ::EBusTraits
{
public:
//! Get thread pool for drawing thumbnails
virtual QThreadPool* GetThreadPool() = 0;
};
using ThumbnailContextRequestBus = AZ::EBus<ThumbnailContextRequests>;
//! Interaction with thumbnailer
class ThumbnailerRequests
: public AZ::EBusTraits
@@ -192,6 +192,10 @@ namespace LegacyFramework
// if we're in console mode, listen for CTRL+C
::SetConsoleCtrlHandler(CTRL_BREAK_HandlerRoutine, true);
#endif
m_ptrCommandLineParser = aznew AzFramework::CommandLine();
m_ptrCommandLineParser->Parse(m_desc.m_argc, m_desc.m_argv);
// If we don't have one create a serialize context
if (GetSerializeContext() == nullptr)
{
-6
View File
@@ -20,7 +20,6 @@
#include "2DViewport.h"
#include "CryEditDoc.h"
#include "DisplaySettings.h"
#include "EditTool.h"
#include "GameEngine.h"
#include "Settings.h"
#include "ViewManager.h"
@@ -1117,11 +1116,6 @@ void Q2DViewport::DrawObjects(DisplayContext& dc)
GetIEditor()->GetObjectManager()->Display(dc);
}
// Display editing tool.
if (GetEditTool())
{
GetEditTool()->Display(dc);
}
dc.PopMatrix();
}
@@ -1,588 +0,0 @@
/*
* 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.
*
*/
#include "EditorDefs.h"
#include "QRollupCtrl.h"
// Qt
#include <QMenu>
#include <QStylePainter>
#include <QVBoxLayout>
#include <QSettings>
#include <QToolButton>
#include <QStyleOptionToolButton>
//////////////////////////////////////////////////////////////////////////
class QRollupCtrlButton
: public QToolButton
{
public:
QRollupCtrlButton(QWidget* parent);
inline void setSelected(bool b) { selected = b; update(); }
inline bool isSelected() const { return selected; }
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
protected:
void paintEvent(QPaintEvent*) override;
private:
bool selected;
};
QRollupCtrlButton::QRollupCtrlButton(QWidget* parent)
: QToolButton(parent)
, selected(true)
{
setBackgroundRole(QPalette::Window);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
setFocusPolicy(Qt::NoFocus);
setStyleSheet("* {margin: 2px 5px 2px 5px; border: 1px solid #CBA457;}");
}
QSize QRollupCtrlButton::sizeHint() const
{
QSize iconSize(8, 8);
if (!icon().isNull())
{
int icone = style()->pixelMetric(QStyle::PM_SmallIconSize);
iconSize += QSize(icone + 2, icone);
}
QSize textSize = fontMetrics().size(Qt::TextShowMnemonic, text()) + QSize(0, 8);
QSize total(iconSize.width() + textSize.width(), qMax(iconSize.height(), textSize.height()));
return total.expandedTo(QApplication::globalStrut());
}
QSize QRollupCtrlButton::minimumSizeHint() const
{
if (icon().isNull())
{
return QSize();
}
int icone = style()->pixelMetric(QStyle::PM_SmallIconSize);
return QSize(icone + 8, icone + 8);
}
void QRollupCtrlButton::paintEvent(QPaintEvent*)
{
QStylePainter p(this);
// draw the background manually, not to clash with UI 2.0 style shets
// the numbers here are taken from the stylesheet in the constructor
p.fillRect(QRect(5, 1, width() - 10, height() - 3), QColor(52, 52, 52));
{
QStyleOptionToolButton opt;
initStyleOption(&opt);
if (isSelected())
{
if (opt.state & QStyle::State_MouseOver)
{
opt.state |= QStyle::State_Sunken;
}
opt.state |= QStyle::State_MouseOver;
}
p.drawComplexControl(QStyle::CC_ToolButton, opt);
}
{
p.setPen(QPen(QColor(132, 128, 125)));
int top = height() / 2 - 2;
p.drawLine(2, top, 4, top);
p.drawLine(width() - 5, top, width() - 3, top);
int bottom = !isSelected() ? top + 4 : height();
p.drawLine(2, bottom, 2, top);
p.drawLine(width() - 3, bottom, width() - 3, top);
if (!isSelected())
{
p.drawLine(2, bottom, 4, bottom);
p.drawLine(width() - 5, bottom, width() - 3, bottom);
}
}
}
//////////////////////////////////////////////////////////////////////////
QRollupCtrl::Page* QRollupCtrl::page(QWidget* widget) const
{
if (!widget)
{
return 0;
}
for (PageList::ConstIterator i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i)
{
if ((*i).widget == widget)
{
return (Page*)&(*i);
}
}
return 0;
}
QRollupCtrl::Page* QRollupCtrl::page(int index)
{
if (index >= 0 && index < m_pageList.size())
{
return &m_pageList[index];
}
return 0;
}
const QRollupCtrl::Page* QRollupCtrl::page(int index) const
{
if (index >= 0 && index < m_pageList.size())
{
return &m_pageList.at(index);
}
return 0;
}
inline void QRollupCtrl::Page::setText(const QString& text) { button->setText(text); }
inline void QRollupCtrl::Page::setIcon(const QIcon& is) { button->setIcon(is); }
inline void QRollupCtrl::Page::setToolTip(const QString& tip) { button->setToolTip(tip); }
inline QString QRollupCtrl::Page::text() const { return button->text(); }
inline QIcon QRollupCtrl::Page::icon() const { return button->icon(); }
inline QString QRollupCtrl::Page::toolTip() const { return button->toolTip(); }
//////////////////////////////////////////////////////////////////////////
QRollupCtrl::QRollupCtrl(QWidget* parent)
: QScrollArea(parent)
, m_layout(0)
{
m_body = new QWidget(this);
m_body->setBackgroundRole(QPalette::Button);
setWidgetResizable(true);
setAlignment(Qt::AlignLeft | Qt::AlignTop);
setWidget(m_body);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
relayout();
}
QRollupCtrl::~QRollupCtrl()
{
foreach(const QRollupCtrl::Page & c, m_pageList)
disconnect(c.widget, &QObject::destroyed, this, &QRollupCtrl::_q_widgetDestroyed);
}
void QRollupCtrl::readSettings(const QString& qSettingsGroup)
{
QSettings settings;
settings.beginGroup(qSettingsGroup);
int i = 0;
foreach(const QRollupCtrl::Page & c, m_pageList) {
QString qObjectName = c.widget->objectName();
bool bHidden = settings.value(qObjectName, true).toBool();
setIndexVisible(i++, !bHidden);
}
settings.endGroup();
}
void QRollupCtrl::writeSettings(const QString& qSettingsGroup)
{
QSettings settings;
settings.beginGroup(qSettingsGroup);
for (int i = 0; i < count(); i++)
{
QString qObjectName;
bool bHidden = isPageHidden(i, qObjectName);
settings.setValue(qObjectName, bHidden);
}
}
void QRollupCtrl::updateTabs()
{
for (auto i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i)
{
QRollupCtrlButton* tB = (*i).button;
QWidget* tW = (*i).sv;
tB->setSelected(tW->isVisible());
tB->update();
}
}
int QRollupCtrl::insertItem(int index, QWidget* widget, const QIcon& icon, const QString& text)
{
if (!widget)
{
return -1;
}
auto it = std::find_if(m_pageList.cbegin(), m_pageList.cend(), [widget](const Page& page) { return page.widget == widget; });
if (it != m_pageList.cend())
{
return -1;
}
connect(widget, &QObject::destroyed, this, &QRollupCtrl::_q_widgetDestroyed);
QRollupCtrl::Page c;
c.widget = widget;
c.button = new QRollupCtrlButton(m_body);
c.button->setContextMenuPolicy(Qt::CustomContextMenu);
connect(c.button, &QRollupCtrlButton::clicked, this, &QRollupCtrl::_q_buttonClicked);
connect(c.button, &QRollupCtrlButton::customContextMenuRequested, this, &QRollupCtrl::_q_custumButtonMenu);
c.sv = new QFrame(m_body);
c.sv->setObjectName("rollupPaneFrame");
// c.sv->setFixedHeight(qMax(widget->sizeHint().height(), widget->size().height()));
QVBoxLayout* layout = new QVBoxLayout;
layout->setMargin(3);
layout->addWidget(widget);
c.sv->setLayout(layout);
c.sv->setStyleSheet("QFrame#rollupPaneFrame {margin: 0px 2px 2px 2px; border: 1px solid #84807D; border-top:0px;}");
c.sv->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
c.sv->show();
c.setText(text);
c.setIcon(icon);
const int numPages = m_pageList.count();
if (index < 0 || index >= numPages)
{
m_pageList.append(c);
index = numPages - 1;
m_layout->insertWidget(m_layout->count() - 1, c.button);
m_layout->insertWidget(m_layout->count() - 1, c.sv);
}
else
{
m_pageList.insert(index, c);
relayout();
}
c.button->show();
updateTabs();
itemInserted(index);
return index;
}
void QRollupCtrl::_q_buttonClicked()
{
QObject* tb = sender();
QWidget* item = 0;
for (auto i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i)
{
if ((*i).button == tb)
{
item = (*i).widget;
break;
}
}
if (item)
{
setIndexVisible(indexOf(item), !item->isVisible());
}
}
int QRollupCtrl::count() const
{
return m_pageList.count();
}
bool QRollupCtrl::isPageHidden(int index, QString& qObjectName) const
{
if (index < 0 || index >= m_pageList.size())
{
return true;
}
const QRollupCtrl::Page& c = m_pageList.at(index);
qObjectName = c.widget->objectName();
return c.sv->isHidden();
}
void QRollupCtrl::setIndexVisible(int index, bool visible)
{
QRollupCtrl::Page* c = page(index);
if (!c)
{
return;
}
if (c->sv->isHidden() && visible)
{
c->sv->show();
}
else if (c->sv->isVisible() && !visible)
{
c->sv->hide();
}
updateTabs();
}
void QRollupCtrl::setWidgetVisible(QWidget* widget, bool visible)
{
setIndexVisible(indexOf(widget), visible);
}
void QRollupCtrl::relayout()
{
delete m_layout;
m_layout = new QVBoxLayout(m_body);
m_layout->setMargin(3);
m_layout->setSpacing(0);
for (QRollupCtrl::PageList::ConstIterator i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i)
{
m_layout->addWidget((*i).button);
m_layout->addWidget((*i).sv);
}
m_layout->addStretch();
updateTabs();
}
void QRollupCtrl::_q_widgetDestroyed(QObject* object)
{
// no verification - vtbl corrupted already
QWidget* p = (QWidget*)object;
QRollupCtrl::Page* c = page(p);
if (!p || !c)
{
return;
}
m_layout->removeWidget(c->sv);
m_layout->removeWidget(c->button);
c->sv->deleteLater(); // page might still be a child of sv
delete c->button;
m_pageList.removeOne(*c);
}
void QRollupCtrl::_q_custumButtonMenu([[maybe_unused]] const QPoint& pos)
{
QMenu menu;
menu.addAction("Expand All")->setData(-1);
menu.addAction("Collapse All")->setData(-2);
menu.addSeparator();
for (int i = 0; i < m_pageList.size(); ++i)
{
QRollupCtrl::Page* c = page(i);
QAction* action = menu.addAction(c->button->text());
action->setCheckable(true);
action->setChecked(c->sv->isVisible());
action->setData(i);
}
QAction* action = menu.exec(QCursor::pos());
if (!action)
{
return;
}
int res = action->data().toInt();
switch (res)
{
case -1: // fall through
case -2:
expandAllPages(res == -1);
break;
default:
{
QRollupCtrl::Page* c = page(res);
if (c)
{
setIndexVisible(res, !c->sv->isVisible());
}
}
break;
}
}
void QRollupCtrl::expandAllPages(bool v)
{
for (int i = 0; i < m_pageList.size(); i++)
{
setIndexVisible(i, v);
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
void QRollupCtrl::clear()
{
while (!m_pageList.isEmpty())
{
removeItem(0);
}
}
void QRollupCtrl::removeItem(QWidget* widget)
{
auto it = std::find_if(m_pageList.cbegin(), m_pageList.cend(), [widget](const Page& page) { return page.widget == widget; });
if (it != m_pageList.cend())
{
removeItem(it - m_pageList.cbegin());
}
}
void QRollupCtrl::removeItem(int index)
{
if (QWidget* w = widget(index))
{
disconnect(w, &QObject::destroyed, this, &QRollupCtrl::_q_widgetDestroyed);
w->setParent(this);
// destroy internal data
_q_widgetDestroyed(w);
itemRemoved(index);
}
}
QWidget* QRollupCtrl::widget(int index) const
{
if (index < 0 || index >= (int) m_pageList.size())
{
return 0;
}
return m_pageList.at(index).widget;
}
int QRollupCtrl::indexOf(QWidget* widget) const
{
QRollupCtrl::Page* c = page(widget);
return c ? m_pageList.indexOf(*c) : -1;
}
void QRollupCtrl::setItemEnabled(int index, bool enabled)
{
QRollupCtrl::Page* c = page(index);
if (!c)
{
return;
}
c->button->setEnabled(enabled);
if (!enabled)
{
int curIndexUp = index;
int curIndexDown = curIndexUp;
const int count = m_pageList.count();
while (curIndexUp > 0 || curIndexDown < count - 1)
{
if (curIndexDown < count - 1)
{
if (page(++curIndexDown)->button->isEnabled())
{
index = curIndexDown;
break;
}
}
if (curIndexUp > 0)
{
if (page(--curIndexUp)->button->isEnabled())
{
index = curIndexUp;
break;
}
}
}
}
}
void QRollupCtrl::setItemText(int index, const QString& text)
{
QRollupCtrl::Page* c = page(index);
if (c)
{
c->setText(text);
}
}
void QRollupCtrl::setItemIcon(int index, const QIcon& icon)
{
QRollupCtrl::Page* c = page(index);
if (c)
{
c->setIcon(icon);
}
}
void QRollupCtrl::setItemToolTip(int index, const QString& toolTip)
{
QRollupCtrl::Page* c = page(index);
if (c)
{
c->setToolTip(toolTip);
}
}
bool QRollupCtrl::isItemEnabled(int index) const
{
const QRollupCtrl::Page* c = page(index);
return c && c->button->isEnabled();
}
QString QRollupCtrl::itemText(int index) const
{
const QRollupCtrl::Page* c = page(index);
return (c ? c->text() : QString());
}
QIcon QRollupCtrl::itemIcon(int index) const
{
const QRollupCtrl::Page* c = page(index);
return (c ? c->icon() : QIcon());
}
QString QRollupCtrl::itemToolTip(int index) const
{
const QRollupCtrl::Page* c = page(index);
return (c ? c->toolTip() : QString());
}
void QRollupCtrl::changeEvent(QEvent* ev)
{
if (ev->type() == QEvent::StyleChange)
{
updateTabs();
}
QFrame::changeEvent(ev);
}
void QRollupCtrl::showEvent(QShowEvent* ev)
{
if (isVisible())
{
updateTabs();
}
IEditor* pEditor = GetIEditor();
pEditor->SetEditMode(EEditMode::eEditModeSelect);
QFrame::showEvent(ev);
}
void QRollupCtrl::itemInserted(int index)
{
Q_UNUSED(index)
}
void QRollupCtrl::itemRemoved(int index)
{
Q_UNUSED(index)
}
#include <Controls/moc_QRollupCtrl.cpp>
-126
View File
@@ -1,126 +0,0 @@
#ifndef CRYINCLUDE_EDITOR_CONTROLS_QROLLUPCTRL_H
#define CRYINCLUDE_EDITOR_CONTROLS_QROLLUPCTRL_H
/*
* 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.
*
*/
#if !defined(Q_MOC_RUN)
#include <QFrame>
#include <QScrollArea>
#include <QIcon>
#endif
class QVBoxLayout;
class QRollupCtrlButton;
class QRollupCtrl
: public QScrollArea
{
Q_OBJECT
Q_PROPERTY(int count READ count)
public:
explicit QRollupCtrl(QWidget* parent = 0);
~QRollupCtrl();
int addItem(QWidget* widget, const QString& text);
int addItem(QWidget* widget, const QIcon& icon, const QString& text);
int insertItem(int index, QWidget* widget, const QString& text);
int insertItem(int index, QWidget* widget, const QIcon& icon, const QString& text);
void clear();
void removeItem(QWidget* widget);
void removeItem(int index);
void setItemEnabled(int index, bool enabled);
bool isItemEnabled(int index) const;
void setItemText(int index, const QString& text);
QString itemText(int index) const;
void setItemIcon(int index, const QIcon& icon);
QIcon itemIcon(int index) const;
void setItemToolTip(int index, const QString& toolTip);
QString itemToolTip(int index) const;
QWidget* widget(int index) const;
int indexOf(QWidget* widget) const;
int count() const;
void readSettings (const QString& qSettingsGroup);
void writeSettings(const QString& qSettingsGroup);
public slots:
void setIndexVisible(int index, bool visible);
void setWidgetVisible(QWidget* widget, bool visible);
void expandAllPages(bool v);
protected:
virtual void itemInserted(int index);
virtual void itemRemoved(int index);
void changeEvent(QEvent*) override;
void showEvent(QShowEvent*) override;
private:
Q_DISABLE_COPY(QRollupCtrl)
struct Page
{
QRollupCtrlButton* button;
QFrame* sv;
QWidget* widget;
void setText(const QString& text);
void setIcon(const QIcon& is);
void setToolTip(const QString& tip);
QString text() const;
QIcon icon() const;
QString toolTip() const;
inline bool operator==(const Page& other) const
{
return widget == other.widget;
}
};
typedef QList<Page> PageList;
Page* page(QWidget* widget) const;
const Page* page(int index) const;
Page* page(int index);
void updateTabs();
void relayout();
bool isPageHidden(int index, QString& qObjectName) const;
QWidget* m_body;
PageList m_pageList;
QVBoxLayout* m_layout;
private slots:
void _q_buttonClicked();
void _q_widgetDestroyed(QObject*);
void _q_custumButtonMenu(const QPoint&);
};
//////////////////////////////////////////////////////////////////////////
inline int QRollupCtrl::addItem(QWidget* item, const QString& text)
{ return insertItem(-1, item, QIcon(), text); }
inline int QRollupCtrl::addItem(QWidget* item, const QIcon& iconSet, const QString& text)
{ return insertItem(-1, item, iconSet, text); }
inline int QRollupCtrl::insertItem(int index, QWidget* item, const QString& text)
{ return insertItem(index, item, QIcon(), text); }
#endif
-171
View File
@@ -1,171 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : implementation file
#include "EditorDefs.h"
// Editor
#include "CryEditDoc.h"
#include "EditTool.h"
#include "ToolButton.h"
QEditorToolButton::QEditorToolButton(QWidget* parent /* = nullptr */)
: QPushButton(parent)
, m_styleSheet(styleSheet())
, m_toolClass(nullptr)
, m_toolCreated(nullptr)
, m_needDocument(true)
{
setSizePolicy({ QSizePolicy::Expanding, QSizePolicy::Fixed });
connect(this, &QAbstractButton::clicked, this, &QEditorToolButton::OnClicked);
GetIEditor()->RegisterNotifyListener(this);
}
QEditorToolButton::~QEditorToolButton()
{
GetIEditor()->UnregisterNotifyListener(this);
}
void QEditorToolButton::SetToolName(const QString& editToolName, const QString& userDataKey, void* userData)
{
IClassDesc* klass = GetIEditor()->GetClassFactory()->FindClass(editToolName.toUtf8().data());
if (!klass)
{
Warning(QStringLiteral("Editor Tool %1 not registered.").arg(editToolName).toUtf8().data());
return;
}
if (klass->SystemClassID() != ESYSTEM_CLASS_EDITTOOL)
{
Warning(QStringLiteral("Class name %1 is not a valid Edit Tool class.").arg(editToolName).toUtf8().data());
return;
}
QScopedPointer<QObject> o(klass->CreateQObject());
if (!qobject_cast<CEditTool*>(o.data()))
{
Warning(QStringLiteral("Class name %1 is not a valid Edit Tool class.").arg(editToolName).toUtf8().data());
return;
}
SetToolClass(o->metaObject(), userDataKey, userData);
}
//////////////////////////////////////////////////////////////////////////
void QEditorToolButton::SetToolClass(const QMetaObject* toolClass, const QString& userDataKey, void* userData)
{
m_toolClass = toolClass;
m_userData = userData;
if (!userDataKey.isEmpty())
{
m_userDataKey = userDataKey;
}
}
void QEditorToolButton::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
switch (event)
{
case eNotify_OnBeginNewScene:
case eNotify_OnBeginLoad:
case eNotify_OnBeginSceneOpen:
{
if (m_needDocument)
{
setEnabled(false);
}
break;
}
case eNotify_OnEndNewScene:
case eNotify_OnEndLoad:
case eNotify_OnEndSceneOpen:
{
if (m_needDocument)
{
setEnabled(true);
}
break;
}
case eNotify_OnEditToolChange:
{
CEditTool* tool = GetIEditor()->GetEditTool();
if (!tool || tool != m_toolCreated || tool->metaObject() != m_toolClass)
{
m_toolCreated = nullptr;
SetSelected(false);
}
}
default:
break;
}
}
void QEditorToolButton::OnClicked()
{
if (!m_toolClass)
{
return;
}
if (m_needDocument && !GetIEditor()->GetDocument()->IsDocumentReady())
{
return;
}
CEditTool* tool = GetIEditor()->GetEditTool();
if (tool && tool->IsMoveToObjectModeAfterEnd() && tool->metaObject() == m_toolClass && tool == m_toolCreated)
{
GetIEditor()->SetEditTool(nullptr);
SetSelected(false);
}
else
{
CEditTool* newTool = qobject_cast<CEditTool*>(m_toolClass->newInstance());
if (!newTool)
{
return;
}
m_toolCreated = newTool;
SetSelected(true);
if (m_userData)
{
newTool->SetUserData(m_userDataKey.toUtf8().data(), (void*)m_userData);
}
update();
// Must be last function, can delete this.
GetIEditor()->SetEditTool(newTool);
}
}
void QEditorToolButton::SetSelected(bool selected)
{
if (selected)
{
setStyleSheet(QStringLiteral("QPushButton { background-color: palette(highlight); color: palette(highlighted-text); }"));
}
else
{
setStyleSheet(m_styleSheet);
}
}
#include <Controls/moc_ToolButton.cpp>
-60
View File
@@ -1,60 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_CONTROLS_TOOLBUTTON_H
#define CRYINCLUDE_EDITOR_CONTROLS_TOOLBUTTON_H
#pragma once
// ToolButton.h : header file
//
#if !defined(Q_MOC_RUN)
#include <AzCore/PlatformDef.h>
#include <QPushButton>
#endif
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
class SANDBOX_API QEditorToolButton
: public QPushButton
, public IEditorNotifyListener
{
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
Q_OBJECT
// Construction
public:
QEditorToolButton(QWidget* parent = nullptr);
virtual ~QEditorToolButton();
void SetToolClass(const QMetaObject* toolClass, const QString& userDataKey = 0, void* userData = nullptr);
void SetToolName(const QString& editToolName, const QString& userDataKey = 0, void* userData = nullptr);
// Set if this tool button relies on a loaded level / ready document. By default every tool button only works if a level is loaded.
// However some tools are also used without a loaded level (e.g. UI Emulator)
void SetNeedDocument(bool needDocument) { m_needDocument = needDocument; }
void SetSelected(bool selected);
void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
protected:
void OnClicked();
const QString m_styleSheet;
//! Tool associated with this button.
const QMetaObject* m_toolClass;
CEditTool* m_toolCreated;
QString m_userDataKey;
void* m_userData;
bool m_needDocument;
};
#endif // CRYINCLUDE_EDITOR_CONTROLS_TOOLBUTTON_H
@@ -577,17 +577,6 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
modifyMenu.AddAction(ID_MODIFY_LINK);
modifyMenu.AddAction(ID_MODIFY_UNLINK);
modifyMenu.AddSeparator();
auto alignMenu = modifyMenu.AddMenu(tr("Align"));
alignMenu.AddAction(ID_OBJECTMODIFY_ALIGNTOGRID);
alignMenu.AddAction(ID_MODIFY_ALIGNOBJTOSURF);
auto constrainMenu = modifyMenu.AddMenu(tr("Constrain"));
constrainMenu.AddAction(ID_SELECT_AXIS_X);
constrainMenu.AddAction(ID_SELECT_AXIS_Y);
constrainMenu.AddAction(ID_SELECT_AXIS_Z);
constrainMenu.AddAction(ID_SELECT_AXIS_XY);
constrainMenu.AddAction(ID_SELECT_AXIS_TERRAIN);
}
auto snapMenu = modifyMenu.AddMenu(tr("Snap"));
@@ -609,20 +598,10 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
}
auto transformModeMenu = modifyMenu.AddMenu(tr("Transform Mode"));
if (!newViewportInteractionModelEnabled)
{
transformModeMenu.AddAction(ID_EDITMODE_SELECT);
}
transformModeMenu.AddAction(ID_EDITMODE_MOVE);
transformModeMenu.AddAction(ID_EDITMODE_ROTATE);
transformModeMenu.AddAction(ID_EDITMODE_SCALE);
if (!newViewportInteractionModelEnabled)
{
transformModeMenu.AddAction(ID_EDITMODE_SELECTAREA);
}
editMenu.AddSeparator();
// Lock Selection
+30 -390
View File
@@ -95,7 +95,6 @@ AZ_POP_DISABLE_WARNING
#include "Core/QtEditorApplication.h"
#include "StringDlg.h"
#include "VoxelAligningTool.h"
#include "NewLevelDialog.h"
#include "GridSettingsDialog.h"
#include "LayoutConfigDialog.h"
@@ -110,7 +109,6 @@ AZ_POP_DISABLE_WARNING
#include "DisplaySettings.h"
#include "GameEngine.h"
#include "ObjectCloneTool.h"
#include "StartupTraceHandler.h"
#include "ThumbnailGenerator.h"
#include "ToolsConfigPage.h"
@@ -127,7 +125,6 @@ AZ_POP_DISABLE_WARNING
#include "AnimationContext.h"
#include "GotoPositionDlg.h"
#include "SetVectorDlg.h"
#include "ConsoleDialog.h"
#include "Controls/ConsoleSCB.h"
@@ -153,7 +150,6 @@ AZ_POP_DISABLE_WARNING
#include "LevelIndependentFileMan.h"
#include "WelcomeScreen/WelcomeScreenDialog.h"
#include "Dialogs/DuplicatedObjectsHandlerDlg.h"
#include "EditMode/VertexSnappingModeTool.h"
#include "Controls/ReflectedPropertyControl/PropertyCtrl.h"
#include "Controls/ReflectedPropertyControl/ReflectedVar.h"
@@ -398,34 +394,20 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_EDITMODE_MOVE, OnEditmodeMove)
ON_COMMAND(ID_EDITMODE_ROTATE, OnEditmodeRotate)
ON_COMMAND(ID_EDITMODE_SCALE, OnEditmodeScale)
ON_COMMAND(ID_EDITMODE_SELECT, OnEditmodeSelect)
ON_COMMAND(ID_EDIT_ESCAPE, OnEditEscape)
ON_COMMAND(ID_OBJECTMODIFY_SETAREA, OnObjectSetArea)
ON_COMMAND(ID_OBJECTMODIFY_SETHEIGHT, OnObjectSetHeight)
ON_COMMAND(ID_OBJECTMODIFY_VERTEXSNAPPING, OnObjectVertexSnapping)
ON_COMMAND(ID_MODIFY_ALIGNOBJTOSURF, OnAlignToVoxel)
ON_COMMAND(ID_OBJECTMODIFY_FREEZE, OnObjectmodifyFreeze)
ON_COMMAND(ID_OBJECTMODIFY_UNFREEZE, OnObjectmodifyUnfreeze)
ON_COMMAND(ID_EDITMODE_SELECTAREA, OnEditmodeSelectarea)
ON_COMMAND(ID_SELECT_AXIS_X, OnSelectAxisX)
ON_COMMAND(ID_SELECT_AXIS_Y, OnSelectAxisY)
ON_COMMAND(ID_SELECT_AXIS_Z, OnSelectAxisZ)
ON_COMMAND(ID_SELECT_AXIS_XY, OnSelectAxisXy)
ON_COMMAND(ID_UNDO, OnUndo)
ON_COMMAND(ID_TOOLBAR_WIDGET_REDO, OnUndo) // Can't use the same ID, because for the menu we can't have a QWidgetAction, while for the toolbar we want one
ON_COMMAND(ID_EDIT_CLONE, OnEditClone)
ON_COMMAND(ID_SELECTION_SAVE, OnSelectionSave)
ON_COMMAND(ID_IMPORT_ASSET, OnOpenAssetImporter)
ON_COMMAND(ID_SELECTION_LOAD, OnSelectionLoad)
ON_COMMAND(ID_MODIFY_ALIGNOBJTOSURF, OnAlignToVoxel)
ON_COMMAND(ID_OBJECTMODIFY_ALIGNTOGRID, OnAlignToGrid)
ON_COMMAND(ID_LOCK_SELECTION, OnLockSelection)
ON_COMMAND(ID_EDIT_LEVELDATA, OnEditLevelData)
ON_COMMAND(ID_FILE_EDITLOGFILE, OnFileEditLogFile)
ON_COMMAND(ID_FILE_RESAVESLICES, OnFileResaveSlices)
ON_COMMAND(ID_FILE_EDITEDITORINI, OnFileEditEditorini)
ON_COMMAND(ID_SELECT_AXIS_TERRAIN, OnSelectAxisTerrain)
ON_COMMAND(ID_SELECT_AXIS_SNAPTOALL, OnSelectAxisSnapToAll)
ON_COMMAND(ID_PREFERENCES, OnPreferences)
ON_COMMAND(ID_RELOAD_GEOMETRY, OnReloadGeometry)
ON_COMMAND(ID_REDO, OnRedo)
@@ -492,7 +474,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_VIEW_CYCLE2DVIEWPORT, OnViewCycle2dviewport)
#endif
ON_COMMAND(ID_DISPLAY_GOTOPOSITION, OnDisplayGotoPosition)
ON_COMMAND(ID_DISPLAY_SETVECTOR, OnDisplaySetVector)
ON_COMMAND(ID_SNAPANGLE, OnSnapangle)
ON_COMMAND(ID_RULER, OnRuler)
ON_COMMAND(ID_ROTATESELECTION_XAXIS, OnRotateselectionXaxis)
@@ -524,12 +505,10 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_OPEN_MATERIAL_EDITOR, OnOpenMaterialEditor)
ON_COMMAND(ID_GOTO_VIEWPORTSEARCH, OnGotoViewportSearch)
ON_COMMAND(ID_MATERIAL_PICKTOOL, OnMaterialPicktool)
ON_COMMAND(ID_DISPLAY_SHOWHELPERS, OnShowHelpers)
ON_COMMAND(ID_OPEN_TRACKVIEW, OnOpenTrackView)
ON_COMMAND(ID_OPEN_UICANVASEDITOR, OnOpenUICanvasEditor)
ON_COMMAND(ID_GOTO_VIEWPORTSEARCH, OnGotoViewportSearch)
ON_COMMAND(ID_MATERIAL_PICKTOOL, OnMaterialPicktool)
ON_COMMAND(ID_TERRAIN_TIMEOFDAY, OnTimeOfDay)
ON_COMMAND(ID_TERRAIN_TIMEOFDAYBUTTON, OnTimeOfDay)
@@ -2739,15 +2718,6 @@ void CCryEditApp::OnEditDelete()
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::DeleteSelectedEntities([[maybe_unused]] bool includeDescendants)
{
// If Edit tool active cannot delete object.
if (GetIEditor()->GetEditTool())
{
if (GetIEditor()->GetEditTool()->OnKeyDown(GetIEditor()->GetViewManager()->GetView(0), VK_DELETE, 0, 0))
{
return;
}
}
GetIEditor()->BeginUndo();
CUndo undo("Delete Selected Object");
GetIEditor()->GetObjectManager()->DeleteSelection();
@@ -2756,75 +2726,6 @@ void CCryEditApp::DeleteSelectedEntities([[maybe_unused]] bool includeDescendant
GetIEditor()->SetModifiedModule(eModifiedBrushes);
}
void CCryEditApp::OnEditClone()
{
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
{
if (GetIEditor()->GetObjectManager()->GetSelection()->IsEmpty())
{
QMessageBox::critical(AzToolsFramework::GetActiveWindow(), QString(),
QObject::tr("You have to select objects before you can clone them!"));
return;
}
// Clear Widget selection - Prevents issues caused by cloning entities while a property in the Reflected Property Editor is being edited.
if (QApplication::focusWidget())
{
QApplication::focusWidget()->clearFocus();
}
CEditTool* tool = GetIEditor()->GetEditTool();
if (tool && qobject_cast<CObjectCloneTool*>(tool))
{
((CObjectCloneTool*)tool)->Accept();
}
CObjectCloneTool* cloneTool = new CObjectCloneTool;
GetIEditor()->SetEditTool(cloneTool);
GetIEditor()->SetModifiedFlag();
GetIEditor()->SetModifiedModule(eModifiedBrushes);
// Accept the clone operation if users didn't choose to stick duplicated entities to the cursor
// This setting can be changed in the global preference of the editor
if (!gSettings.deepSelectionSettings.bStickDuplicate)
{
cloneTool->Accept();
GetIEditor()->GetSelection()->FinishChanges();
}
}
}
void CCryEditApp::OnEditEscape()
{
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
{
CEditTool* pEditTool = GetIEditor()->GetEditTool();
// Abort current operation.
if (pEditTool)
{
// If Edit tool active cannot delete object.
CViewport* vp = GetIEditor()->GetActiveView();
if (GetIEditor()->GetEditTool()->OnKeyDown(vp, VK_ESCAPE, 0, 0))
{
return;
}
if (GetIEditor()->GetEditMode() == eEditModeSelectArea)
{
GetIEditor()->SetEditMode(eEditModeSelect);
}
// Disable current tool.
GetIEditor()->SetEditTool(0);
}
else
{
// Clear selection on escape.
GetIEditor()->ClearSelection();
}
}
}
void CCryEditApp::OnMoveObject()
{
////////////////////////////////////////////////////////////////////////
@@ -2843,85 +2744,31 @@ void CCryEditApp::OnSetHeight()
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnEditmodeMove()
{
if (GetIEditor()->IsNewViewportInteractionModelEnabled())
{
using namespace AzToolsFramework;
EditorTransformComponentSelectionRequestBus::Event(
GetEntityContextId(),
&EditorTransformComponentSelectionRequests::SetTransformMode,
EditorTransformComponentSelectionRequests::Mode::Translation);
}
else
{
GetIEditor()->SetEditMode(eEditModeMove);
}
using namespace AzToolsFramework;
EditorTransformComponentSelectionRequestBus::Event(
GetEntityContextId(),
&EditorTransformComponentSelectionRequests::SetTransformMode,
EditorTransformComponentSelectionRequests::Mode::Translation);
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnEditmodeRotate()
{
if (GetIEditor()->IsNewViewportInteractionModelEnabled())
{
using namespace AzToolsFramework;
EditorTransformComponentSelectionRequestBus::Event(
GetEntityContextId(),
&EditorTransformComponentSelectionRequests::SetTransformMode,
EditorTransformComponentSelectionRequests::Mode::Rotation);
}
else
{
GetIEditor()->SetEditMode(eEditModeRotate);
}
using namespace AzToolsFramework;
EditorTransformComponentSelectionRequestBus::Event(
GetEntityContextId(),
&EditorTransformComponentSelectionRequests::SetTransformMode,
EditorTransformComponentSelectionRequests::Mode::Rotation);
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnEditmodeScale()
{
if (GetIEditor()->IsNewViewportInteractionModelEnabled())
{
using namespace AzToolsFramework;
EditorTransformComponentSelectionRequestBus::Event(
GetEntityContextId(),
&EditorTransformComponentSelectionRequests::SetTransformMode,
EditorTransformComponentSelectionRequests::Mode::Scale);
}
else
{
GetIEditor()->SetEditMode(eEditModeScale);
}
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnEditmodeSelect()
{
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
{
GetIEditor()->SetEditMode(eEditModeSelect);
}
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnEditmodeSelectarea()
{
// TODO: Add your command handler code here
GetIEditor()->SetEditMode(eEditModeSelectArea);
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnUpdateEditmodeSelectarea(QAction* action)
{
Q_ASSERT(action->isCheckable());
action->setChecked(GetIEditor()->GetEditMode() == eEditModeSelectArea);
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnUpdateEditmodeSelect(QAction* action)
{
Q_ASSERT(action->isCheckable());
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
{
action->setChecked(GetIEditor()->GetEditMode() == eEditModeSelect);
}
using namespace AzToolsFramework;
EditorTransformComponentSelectionRequestBus::Event(
GetEntityContextId(),
&EditorTransformComponentSelectionRequests::SetTransformMode,
EditorTransformComponentSelectionRequests::Mode::Scale);
}
//////////////////////////////////////////////////////////////////////////
@@ -2929,19 +2776,12 @@ void CCryEditApp::OnUpdateEditmodeMove(QAction* action)
{
Q_ASSERT(action->isCheckable());
if (GetIEditor()->IsNewViewportInteractionModelEnabled())
{
AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode;
AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult(
mode, AzToolsFramework::GetEntityContextId(),
&AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode);
AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode;
AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult(
mode, AzToolsFramework::GetEntityContextId(),
&AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode);
action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Translation);
}
else
{
action->setChecked(GetIEditor()->GetEditMode() == eEditModeMove);
}
action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Translation);
}
//////////////////////////////////////////////////////////////////////////
@@ -2949,20 +2789,12 @@ void CCryEditApp::OnUpdateEditmodeRotate(QAction* action)
{
Q_ASSERT(action->isCheckable());
if (GetIEditor()->IsNewViewportInteractionModelEnabled())
{
AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode;
AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult(
mode, AzToolsFramework::GetEntityContextId(),
&AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode);
AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode;
AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult(
mode, AzToolsFramework::GetEntityContextId(),
&AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode);
action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Rotation);
}
else
{
action->setChecked(GetIEditor()->GetEditMode() == eEditModeRotate);
action->setEnabled(true);
}
action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Rotation);
}
//////////////////////////////////////////////////////////////////////////
@@ -2970,28 +2802,12 @@ void CCryEditApp::OnUpdateEditmodeScale(QAction* action)
{
Q_ASSERT(action->isCheckable());
if (GetIEditor()->IsNewViewportInteractionModelEnabled())
{
AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode;
AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult(
mode, AzToolsFramework::GetEntityContextId(),
&AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode);
AzToolsFramework::EditorTransformComponentSelectionRequests::Mode mode;
AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult(
mode, AzToolsFramework::GetEntityContextId(),
&AzToolsFramework::EditorTransformComponentSelectionRequests::GetTransformMode);
action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Scale);
}
else
{
action->setChecked(GetIEditor()->GetEditMode() == eEditModeScale);
action->setEnabled(true);
}
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnUpdateEditmodeVertexSnapping(QAction* action)
{
Q_ASSERT(action->isCheckable());
CEditTool* pEditTool = GetIEditor()->GetEditTool();
action->setChecked(qobject_cast<CVertexSnappingModeTool*>(pEditTool) != nullptr);
action->setChecked(mode == AzToolsFramework::EditorTransformComponentSelectionRequests::Mode::Scale);
}
//////////////////////////////////////////////////////////////////////////
@@ -3143,19 +2959,6 @@ void CCryEditApp::OnObjectSetHeight()
}
}
void CCryEditApp::OnObjectVertexSnapping()
{
CEditTool* pEditTool = GetIEditor()->GetEditTool();
if (qobject_cast<CVertexSnappingModeTool*>(pEditTool))
{
GetIEditor()->SetEditTool(NULL);
}
else
{
GetIEditor()->SetEditTool("EditTool.VertexSnappingMode");
}
}
void CCryEditApp::OnObjectmodifyFreeze()
{
// Freeze selection.
@@ -3185,101 +2988,6 @@ void CCryEditApp::OnViewSwitchToGame()
GetIEditor()->SetInGameMode(inGame);
}
void CCryEditApp::OnSelectAxisX()
{
AxisConstrains axis = (GetIEditor()->GetAxisConstrains() != AXIS_X) ? AXIS_X : AXIS_NONE;
GetIEditor()->SetAxisConstraints(axis);
}
void CCryEditApp::OnSelectAxisY()
{
AxisConstrains axis = (GetIEditor()->GetAxisConstrains() != AXIS_Y) ? AXIS_Y : AXIS_NONE;
GetIEditor()->SetAxisConstraints(axis);
}
void CCryEditApp::OnSelectAxisZ()
{
AxisConstrains axis = (GetIEditor()->GetAxisConstrains() != AXIS_Z) ? AXIS_Z : AXIS_NONE;
GetIEditor()->SetAxisConstraints(axis);
}
void CCryEditApp::OnSelectAxisXy()
{
AxisConstrains axis = (GetIEditor()->GetAxisConstrains() != AXIS_XY) ? AXIS_XY : AXIS_NONE;
GetIEditor()->SetAxisConstraints(axis);
}
void CCryEditApp::OnUpdateSelectAxisX(QAction* action)
{
Q_ASSERT(action->isCheckable());
action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_X);
}
void CCryEditApp::OnUpdateSelectAxisXy(QAction* action)
{
Q_ASSERT(action->isCheckable());
action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_XY);
}
void CCryEditApp::OnUpdateSelectAxisY(QAction* action)
{
Q_ASSERT(action->isCheckable());
action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_Y);
}
void CCryEditApp::OnUpdateSelectAxisZ(QAction* action)
{
Q_ASSERT(action->isCheckable());
action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_Z);
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnSelectAxisTerrain()
{
IEditor* editor = GetIEditor();
bool isAlreadyEnabled = (editor->GetAxisConstrains() == AXIS_TERRAIN) && (editor->IsTerrainAxisIgnoreObjects());
if (!isAlreadyEnabled)
{
editor->SetAxisConstraints(AXIS_TERRAIN);
editor->SetTerrainAxisIgnoreObjects(true);
}
else
{
// behave like a toggle button - click on the same thing again to disable.
editor->SetAxisConstraints(AXIS_NONE);
}
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnSelectAxisSnapToAll()
{
IEditor* editor = GetIEditor();
bool isAlreadyEnabled = (editor->GetAxisConstrains() == AXIS_TERRAIN) && (!editor->IsTerrainAxisIgnoreObjects());
if (!isAlreadyEnabled)
{
editor->SetAxisConstraints(AXIS_TERRAIN);
editor->SetTerrainAxisIgnoreObjects(false);
}
else
{
// behave like a toggle button - click on the same thing again to disable.
editor->SetAxisConstraints(AXIS_NONE);
}
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnUpdateSelectAxisTerrain(QAction* action)
{
Q_ASSERT(action->isCheckable());
action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_TERRAIN && GetIEditor()->IsTerrainAxisIgnoreObjects());
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnUpdateSelectAxisSnapToAll(QAction* action)
{
action->setChecked(GetIEditor()->GetAxisConstrains() == AXIS_TERRAIN && !GetIEditor()->IsTerrainAxisIgnoreObjects());
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnExportSelectedObjects()
{
@@ -3460,57 +3168,8 @@ void CCryEditApp::OnUpdateSelected(QAction* action)
action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty());
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnAlignToGrid()
{
CSelectionGroup* sel = GetIEditor()->GetSelection();
if (!sel->IsEmpty())
{
CUndo undo("Align To Grid");
Matrix34 tm;
for (int i = 0; i < sel->GetCount(); i++)
{
CBaseObject* obj = sel->GetObject(i);
tm = obj->GetWorldTM();
Vec3 snaped = gSettings.pGrid->Snap(tm.GetTranslation());
tm.SetTranslation(snaped);
obj->SetWorldTM(tm, eObjectUpdateFlags_UserInput);
obj->OnEvent(EVENT_ALIGN_TOGRID);
}
}
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnAlignToVoxel()
{
CEditTool* pEditTool = GetIEditor()->GetEditTool();
if (qobject_cast<CVoxelAligningTool*>(pEditTool) != nullptr)
{
GetIEditor()->SetEditTool(nullptr);
}
else
{
GetIEditor()->SetEditTool(new CVoxelAligningTool());
}
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnUpdateAlignToVoxel(QAction* action)
{
Q_ASSERT(action->isCheckable());
CEditTool* pEditTool = GetIEditor()->GetEditTool();
action->setChecked(qobject_cast<CVoxelAligningTool*>(pEditTool) != nullptr);
action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty());
}
void CCryEditApp::OnShowHelpers()
{
CEditTool* pEditTool(GetIEditor()->GetEditTool());
if (pEditTool && pEditTool->IsNeedSpecificBehaviorForSpaceAcce())
{
return;
}
GetIEditor()->GetDisplaySettings()->DisplayHelpers(!GetIEditor()->GetDisplaySettings()->IsDisplayHelpers());
GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate);
}
@@ -4668,13 +4327,6 @@ void CCryEditApp::OnDisplayGotoPosition()
dlg.exec();
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnDisplaySetVector()
{
CSetVectorDlg dlg;
dlg.exec();
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnSnapangle()
{
@@ -5136,12 +4788,6 @@ void CCryEditApp::OnOpenUICanvasEditor()
QtViewPaneManager::instance()->OpenPane(LyViewPane::UiEditor);
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnMaterialPicktool()
{
GetIEditor()->SetEditTool("EditTool.PickMaterial");
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnTimeOfDay()
{
@@ -5296,12 +4942,6 @@ void CCryEditApp::OnOpenQuickAccessBar()
return;
}
CEditTool* pEditTool(GetIEditor()->GetEditTool());
if (pEditTool && pEditTool->IsNeedSpecificBehaviorForSpaceAcce())
{
return;
}
QRect geo = m_pQuickAccessBar->geometry();
geo.moveCenter(MainWindow::instance()->geometry().center());
m_pQuickAccessBar->setGeometry(geo);
-25
View File
@@ -224,46 +224,23 @@ public:
void OnEditmodeMove();
void OnEditmodeRotate();
void OnEditmodeScale();
void OnEditmodeSelect();
void OnEditEscape();
void OnObjectSetArea();
void OnObjectSetHeight();
void OnObjectVertexSnapping();
void OnUpdateEditmodeVertexSnapping(QAction* action);
void OnUpdateEditmodeSelect(QAction* action);
void OnUpdateEditmodeMove(QAction* action);
void OnUpdateEditmodeRotate(QAction* action);
void OnUpdateEditmodeScale(QAction* action);
void OnObjectmodifyFreeze();
void OnObjectmodifyUnfreeze();
void OnEditmodeSelectarea();
void OnUpdateEditmodeSelectarea(QAction* action);
void OnSelectAxisX();
void OnSelectAxisY();
void OnSelectAxisZ();
void OnSelectAxisXy();
void OnUpdateSelectAxisX(QAction* action);
void OnUpdateSelectAxisXy(QAction* action);
void OnUpdateSelectAxisY(QAction* action);
void OnUpdateSelectAxisZ(QAction* action);
void OnUndo();
void OnEditClone();
void OnSelectionSave();
void OnOpenAssetImporter();
void OnSelectionLoad();
void OnUpdateSelected(QAction* action);
void OnAlignToVoxel();
void OnAlignToGrid();
void OnUpdateAlignToVoxel(QAction* action);
void OnLockSelection();
void OnEditLevelData();
void OnFileEditLogFile();
void OnFileResaveSlices();
void OnFileEditEditorini();
void OnSelectAxisTerrain();
void OnSelectAxisSnapToAll();
void OnUpdateSelectAxisTerrain(QAction* action);
void OnUpdateSelectAxisSnapToAll(QAction* action);
void OnPreferences();
void OnReloadTextures();
void OnReloadGeometry();
@@ -454,7 +431,6 @@ private:
void OnToolsScriptHelp();
void OnViewCycle2dviewport();
void OnDisplayGotoPosition();
void OnDisplaySetVector();
void OnSnapangle();
void OnUpdateSnapangle(QAction* action);
void OnRuler();
@@ -491,7 +467,6 @@ private:
void OnOpenAudioControlsEditor();
void OnOpenUICanvasEditor();
void OnGotoViewportSearch();
void OnMaterialPicktool();
void OnTimeOfDay();
void OnChangeGameSpec(UINT nID);
void SetGameSpecCheck(ESystemConfigSpec spec, ESystemConfigPlatform platform, int &nCheck, bool &enable);
-3
View File
@@ -279,9 +279,6 @@ void CCryEditDoc::DeleteContents()
// [LY-90904] move this to the EditorVegetationManager component
InstanceStatObjEventBus::Broadcast(&InstanceStatObjEventBus::Events::ReleaseData);
GetIEditor()->SetEditTool(0); // Turn off any active edit tools.
GetIEditor()->SetEditMode(eEditModeSelect);
//////////////////////////////////////////////////////////////////////////
// Clear all undo info.
//////////////////////////////////////////////////////////////////////////
-1
View File
@@ -216,7 +216,6 @@ protected:
void OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId, const AzFramework::SliceInstantiationTicket& /*ticket*/) override;
//////////////////////////////////////////////////////////////////////////
QString m_strMasterCDFolder;
bool m_bLoadFailed;
QColor m_waterColor;
XmlNodeRef m_fogTemplate;
@@ -1,123 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "ButtonsPanel.h"
// Qt
#include <QGridLayout>
// Editor
#include "Controls/ToolButton.h"
/////////////////////////////////////////////////////////////////////////////
// CButtonsPanel dialog
CButtonsPanel::CButtonsPanel(QWidget* parent)
: QWidget(parent)
{
}
CButtonsPanel::~CButtonsPanel()
{
}
//////////////////////////////////////////////////////////////////////////
void CButtonsPanel::AddButton(const SButtonInfo& button)
{
SButton b;
b.info = button;
m_buttons.push_back(b);
}
//////////////////////////////////////////////////////////////////////////
void CButtonsPanel::AddButton(const QString& name, const QString& toolClass)
{
SButtonInfo bi;
bi.name = name;
bi.toolClassName = toolClass;
AddButton(bi);
}
//////////////////////////////////////////////////////////////////////////
void CButtonsPanel::AddButton(const QString& name, const QMetaObject* pToolClass)
{
SButtonInfo bi;
bi.name = name;
bi.pToolClass = pToolClass;
AddButton(bi);
}
//////////////////////////////////////////////////////////////////////////
void CButtonsPanel::ClearButtons()
{
auto buttons = layout()->findChildren<QEditorToolButton*>();
foreach(auto button, buttons)
{
layout()->removeWidget(button);
delete button;
}
m_buttons.clear();
}
void CButtonsPanel::UncheckAll()
{
for (auto& button : m_buttons)
{
button.pButton->SetSelected(false);
}
}
void CButtonsPanel::OnInitDialog()
{
auto layout = new QGridLayout(this);
setLayout(layout);
layout->setMargin(4);
layout->setHorizontalSpacing(4);
layout->setVerticalSpacing(1);
// Create Buttons.
int index = 0;
for (auto& button : m_buttons)
{
button.pButton = new QEditorToolButton(this);
button.pButton->setObjectName(button.info.name);
button.pButton->setText(button.info.name);
button.pButton->SetNeedDocument(button.info.bNeedDocument);
button.pButton->setToolTip(button.info.toolTip);
if (button.info.pToolClass)
{
button.pButton->SetToolClass(button.info.pToolClass, button.info.toolUserDataKey, (void*)button.info.toolUserData.c_str());
}
else if (!button.info.toolClassName.isEmpty())
{
button.pButton->SetToolName(button.info.toolClassName, button.info.toolUserDataKey, (void*)button.info.toolUserData.c_str());
}
layout->addWidget(button.pButton, index / 2, index % 2);
connect(button.pButton, &QEditorToolButton::clicked, this, [&]() { OnButtonPressed(button.info); });
++index;
}
}
void CButtonsPanel::EnableButton(const QString& buttonName, bool enable)
{
for (auto& button : m_buttons)
{
if (button.pButton->objectName() == buttonName)
{
button.pButton->setEnabled(enable);
}
}
}
#include <Dialogs/moc_ButtonsPanel.cpp>
@@ -1,76 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_DIALOGS_BUTTONSPANEL_H
#define CRYINCLUDE_EDITOR_DIALOGS_BUTTONSPANEL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <QWidget>
#endif
class QEditorToolButton;
/////////////////////////////////////////////////////////////////////////////
// Panel with custom auto arranged buttons
class CButtonsPanel
: public QWidget
{
Q_OBJECT
public:
struct SButtonInfo
{
QString name;
QString toolClassName;
QString toolUserDataKey;
std::string toolUserData;
QString toolTip;
bool bNeedDocument;
const QMetaObject* pToolClass;
SButtonInfo()
: pToolClass(nullptr)
, bNeedDocument(true) {};
};
CButtonsPanel(QWidget* parent);
virtual ~CButtonsPanel();
virtual void AddButton(const SButtonInfo& button);
virtual void AddButton(const QString& name, const QString& toolClass);
virtual void AddButton(const QString& name, const QMetaObject* pToolClass);
virtual void EnableButton(const QString& buttonName, bool disable);
virtual void ClearButtons();
virtual void OnButtonPressed([[maybe_unused]] const SButtonInfo& button) {};
virtual void UncheckAll();
protected:
void ReleaseGuiButtons();
virtual void OnInitDialog();
//////////////////////////////////////////////////////////////////////////
struct SButton
{
SButtonInfo info;
QEditorToolButton* pButton;
SButton()
: pButton(nullptr) {};
};
std::vector<SButton> m_buttons;
};
#endif // CRYINCLUDE_EDITOR_DIALOGS_BUTTONSPANEL_H
File diff suppressed because it is too large Load Diff
-134
View File
@@ -1,134 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Object edit mode describe viewport input behavior when operating on objects.
#ifndef CRYINCLUDE_EDITOR_EDITMODE_OBJECTMODE_H
#define CRYINCLUDE_EDITOR_EDITMODE_OBJECTMODE_H
#pragma once
// {87109FED-BDB5-4874-936D-338400079F58}
DEFINE_GUID(OBJECT_MODE_GUID, 0x87109fed, 0xbdb5, 0x4874, 0x93, 0x6d, 0x33, 0x84, 0x0, 0x7, 0x9f, 0x58);
#include "EditTool.h"
class CBaseObject;
class CDeepSelection;
/*!
* CObjectMode is an abstract base class for All Editing Tools supported by Editor.
* Edit tools handle specific editing modes in viewports.
*/
class SANDBOX_API CObjectMode
: public CEditTool
{
Q_OBJECT
public:
Q_INVOKABLE CObjectMode(QObject* parent = nullptr);
virtual ~CObjectMode();
static const GUID& GetClassID() { return OBJECT_MODE_GUID; }
// Registration function.
static void RegisterTool(CRegistrationContext& rc);
//////////////////////////////////////////////////////////////////////////
// CEditTool implementation.
//////////////////////////////////////////////////////////////////////////
virtual void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) {};
virtual void EndEditParams();
virtual void Display(struct DisplayContext& dc);
virtual void DisplaySelectionPreview(struct DisplayContext& dc);
virtual void DrawSelectionPreview(struct DisplayContext& dc, CBaseObject* drawObject);
void DisplayExtraLightInfo(struct DisplayContext& dc);
virtual bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
virtual bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags);
virtual bool OnKeyUp(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags);
virtual bool OnSetCursor([[maybe_unused]] CViewport* vp) { return false; };
virtual void OnManipulatorDrag(CViewport* view, ITransformManipulator* pManipulator, QPoint& p0, QPoint& p1, const Vec3& value) override;
bool IsUpdateUIPanel() override { return true; }
protected:
enum ECommandMode
{
NothingMode = 0,
ScrollZoomMode,
SelectMode,
MoveMode,
RotateMode,
ScaleMode,
ScrollMode,
ZoomMode,
};
virtual bool OnLButtonDown(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnLButtonDblClk(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnLButtonUp(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnRButtonDown(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnRButtonUp(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnMButtonDown(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnMouseMove(CViewport* view, int nFlags, const QPoint& point);
virtual bool OnMouseLeave(CViewport* view);
void SetCommandMode(ECommandMode mode) { m_commandMode = mode; }
ECommandMode GetCommandMode() const { return m_commandMode; }
//! Ctrl-Click in move mode to move selected objects to given pos.
void MoveSelectionToPos(CViewport* view, Vec3& pos, bool align, const QPoint& point);
void SetObjectCursor(CViewport* view, CBaseObject* hitObj, bool bChangeNow = false);
virtual void DeleteThis() { delete this; };
void UpdateStatusText();
void AwakeObjectAtPoint(CViewport* view, const QPoint& point);
void HideMoveByFaceNormGizmo();
void HandleMoveByFaceNormal(HitContext& hitInfo);
void UpdateMoveByFaceNormGizmo(CBaseObject* pHitObject);
protected:
bool m_openContext;
private:
void CheckDeepSelection(HitContext& hitContext, CViewport* view);
Vec3& GetScale(const CViewport* view, const QPoint& point, Vec3& OutScale);
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
QPoint m_cMouseDownPos;
bool m_bDragThresholdExceeded;
ECommandMode m_commandMode;
GUID m_MouseOverObject;
typedef std::vector<GUID> TGuidContainer;
TGuidContainer m_PreviewGUIDs;
_smart_ptr<CDeepSelection> m_pDeepSelection;
bool m_bMoveByFaceNormManipShown;
CBaseObject* m_pHitObject;
bool m_bTransformChanged;
QPoint m_prevMousePos = QPoint(0, 0);
Vec3 m_lastValidMoveVector = Vec3(0, 0, 0);
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_EDITMODE_OBJECTMODE_H
@@ -1,430 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#if defined(AZ_PLATFORM_WINDOWS)
#include <InitGuid.h>
#endif
#include "VertexSnappingModeTool.h"
// Editor
#include "Settings.h"
#include "Viewport.h"
#include "SurfaceInfoPicker.h"
#include "Material/Material.h"
#include "Util/KDTree.h"
// {3e008046-9269-41d7-82e2-07ffd7254c10}
DEFINE_GUID(VERTEXSNAPPING_MODE_GUID, 0x3e008046, 0x9269, 0x41d7, 0x82, 0xe2, 0x07, 0xff, 0xd7, 0x25, 0x4c, 0x10);
bool FindNearestVertex(CBaseObject* pObject, CKDTree* pTree, const Vec3& vWorldRaySrc, const Vec3& vWorldRayDir, Vec3& outPos, Vec3& vOutHitPosOnCube)
{
Matrix34 worldInvTM = pObject->GetWorldTM().GetInverted();
Vec3 vRaySrc = worldInvTM.TransformPoint(vWorldRaySrc);
Vec3 vRayDir = worldInvTM.TransformVector(vWorldRayDir);
Vec3 vLocalCameraPos = worldInvTM.TransformPoint(gEnv->pRenderer->GetCamera().GetPosition());
Vec3 vPos;
Vec3 vHitPosOnCube;
if (pTree)
{
if (pTree->FindNearestVertex(vRaySrc, vRayDir, gSettings.vertexSnappingSettings.vertexCubeSize, vLocalCameraPos, vPos, vHitPosOnCube))
{
outPos = pObject->GetWorldTM().TransformPoint(vPos);
vOutHitPosOnCube = pObject->GetWorldTM().TransformPoint(vHitPosOnCube);
return true;
}
}
else
{
// for objects without verts, the pivot is the nearest vertex
// return true if the ray hits the bounding box
outPos = pObject->GetWorldPos();
AABB bbox;
pObject->GetBoundBox(bbox);
if (bbox.IsContainPoint(vWorldRaySrc))
{
// if ray starts inside bounding box, reject cases where pivot is behind the ray
float hitDistAlongRay = vWorldRayDir.Dot(outPos - vWorldRaySrc);
if (hitDistAlongRay >= 0.f)
{
vHitPosOnCube = vWorldRaySrc + (vWorldRayDir * hitDistAlongRay);
return true;
}
}
else if (Intersect::Ray_AABB(vWorldRaySrc, vWorldRayDir, bbox, vOutHitPosOnCube))
{
return true;
}
}
return false;
}
CVertexSnappingModeTool::CVertexSnappingModeTool()
{
m_modeStatus = eVSS_SelectFirstVertex;
m_bHit = false;
}
CVertexSnappingModeTool::~CVertexSnappingModeTool()
{
std::map<CBaseObjectPtr, CKDTree*>::iterator ii = m_ObjectKdTreeMap.begin();
for (; ii != m_ObjectKdTreeMap.end(); ++ii)
{
delete ii->second;
}
}
const GUID& CVertexSnappingModeTool::GetClassID()
{
return VERTEXSNAPPING_MODE_GUID;
}
void CVertexSnappingModeTool::RegisterTool(CRegistrationContext& rc)
{
rc.pClassFactory->RegisterClass(new CQtViewClass<CVertexSnappingModeTool>("EditTool.VertexSnappingMode", "Select", ESYSTEM_CLASS_EDITTOOL));
}
bool CVertexSnappingModeTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
{
CBaseObjectPtr pExcludedObject = NULL;
if (m_modeStatus == eVSS_MoveSelectVertexToAnotherVertex)
{
pExcludedObject = m_SelectionInfo.m_pObject;
}
m_bHit = HitTest(view, point, pExcludedObject, m_vHitVertex, m_pHitObject, m_Objects);
if (event == eMouseLDown && m_bHit && m_pHitObject && m_modeStatus == eVSS_SelectFirstVertex)
{
m_modeStatus = eVSS_MoveSelectVertexToAnotherVertex;
m_SelectionInfo.m_pObject = m_pHitObject;
m_SelectionInfo.m_vPos = m_vHitVertex;
GetIEditor()->BeginUndo();
m_pHitObject->StoreUndo("Vertex Snapping", true);
view->SetCapture();
}
if (m_modeStatus == eVSS_MoveSelectVertexToAnotherVertex)
{
if (event == eMouseLUp)
{
m_modeStatus = eVSS_SelectFirstVertex;
GetIEditor()->AcceptUndo("Vertex Snapping");
view->ReleaseMouse();
}
else if ((flags & MK_LBUTTON) && event == eMouseMove)
{
Vec3 vOffset = m_SelectionInfo.m_pObject->GetWorldPos() - m_SelectionInfo.m_vPos;
m_SelectionInfo.m_pObject->SetWorldPos(m_vHitVertex + vOffset);
m_SelectionInfo.m_vPos = m_SelectionInfo.m_pObject->GetWorldPos() - vOffset;
}
}
return true;
}
bool CVertexSnappingModeTool::HitTest(CViewport* view, const QPoint& point, CBaseObject* pExcludedObj, Vec3& outHitPos, CBaseObjectPtr& pOutHitObject, std::vector<CBaseObjectPtr>& outObjects)
{
if (gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox)
{
m_DebugBoxes.clear();
}
pOutHitObject = NULL;
outObjects.clear();
//
// Collect valid objects that mouse is over
//
CSurfaceInfoPicker picker;
CSurfaceInfoPicker::CExcludedObjects excludedObjects;
if (pExcludedObj)
{
excludedObjects.Add(pExcludedObj);
}
int nPickFlag = CSurfaceInfoPicker::ePOG_Entity;
std::vector<CBaseObjectPtr> penetratedObjects;
if (!picker.PickByAABB(point, nPickFlag, view, &excludedObjects, &penetratedObjects))
{
return false;
}
for (int i = 0, iCount(penetratedObjects.size()); i < iCount; ++i)
{
CMaterial* pMaterial = penetratedObjects[i]->GetMaterial();
if (pMaterial)
{
QString matName = pMaterial->GetName();
if (!QString::compare(matName, "Objects/sky/forest_sky_dome", Qt::CaseInsensitive))
{
continue;
}
}
outObjects.push_back(penetratedObjects[i]);
}
//
// Find the best vertex.
//
Vec3 vWorldRaySrc, vWorldRayDir;
view->ViewToWorldRay(point, vWorldRaySrc, vWorldRayDir);
std::vector<CBaseObjectPtr>::iterator ii = outObjects.begin();
float fNearestDist = 3e10f;
Vec3 vNearestPos;
CBaseObjectPtr pNearestObject = NULL;
for (ii = outObjects.begin(); ii != outObjects.end(); ++ii)
{
if (gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox)
{
// add to debug boxes: the penetrated nodes of each object's kd-tree
if (auto pTree = GetKDTree(*ii))
{
Matrix34 invWorldTM = (*ii)->GetWorldTM().GetInverted();
int nIndex = m_DebugBoxes.size();
Vec3 vLocalRaySrc = invWorldTM.TransformPoint(vWorldRaySrc);
Vec3 vLocalRayDir = invWorldTM.TransformVector(vWorldRayDir);
pTree->GetPenetratedBoxes(vLocalRaySrc, vLocalRayDir, m_DebugBoxes);
for (int i = nIndex; i < m_DebugBoxes.size(); ++i)
{
m_DebugBoxes[i].SetTransformedAABB((*ii)->GetWorldTM(), m_DebugBoxes[i]);
}
}
}
// find the nearest vertex on this object
Vec3 vPos, vHitPosOnCube;
if (FindNearestVertex(*ii, GetKDTree(*ii), vWorldRaySrc, vWorldRayDir, vPos, vHitPosOnCube))
{
// is this the best so far?
float fDistance = vHitPosOnCube.GetDistance(vWorldRaySrc);
if (fDistance < fNearestDist)
{
fNearestDist = fDistance;
vNearestPos = vPos;
pNearestObject = *ii;
}
}
}
if (fNearestDist < 3e10f)
{
outHitPos = vNearestPos;
pOutHitObject = pNearestObject;
}
// if the mouse is over the object's pivot, use that instead of a vertex
if (pOutHitObject)
{
Vec3 vPivotPos = pOutHitObject->GetWorldPos();
Vec3 vPivotBox = GetCubeSize(view, pOutHitObject->GetWorldPos());
AABB pivotAABB(vPivotPos - vPivotBox, vPivotPos + vPivotBox);
Vec3 vPosOnPivotCube;
if (Intersect::Ray_AABB(vWorldRaySrc, vWorldRayDir, pivotAABB, vPosOnPivotCube))
{
outHitPos = vPivotPos;
return true;
}
}
return pOutHitObject && pOutHitObject == pNearestObject;
}
Vec3 CVertexSnappingModeTool::GetCubeSize(IDisplayViewport* pView, const Vec3& pos) const
{
if (!pView)
{
return Vec3(0, 0, 0);
}
float fScreenFactor = pView->GetScreenScaleFactor(pos);
return gSettings.vertexSnappingSettings.vertexCubeSize * Vec3(fScreenFactor, fScreenFactor, fScreenFactor);
}
void CVertexSnappingModeTool::Display(struct DisplayContext& dc)
{
const ColorB SnappedColor(0xFF00FF00);
const ColorB PivotColor(0xFF2020FF);
const ColorB VertexColor(0xFFFFAAAA);
// draw all objects under mouse
dc.SetColor(VertexColor);
for (int i = 0, iCount(m_Objects.size()); i < iCount; ++i)
{
AABB worldAABB;
m_Objects[i]->GetBoundBox(worldAABB);
if (!dc.view->IsBoundsVisible(worldAABB))
{
continue;
}
if (auto pStatObj = m_Objects[i]->GetIStatObj())
{
DrawVertexCubes(dc, m_Objects[i]->GetWorldTM(), pStatObj);
}
else
{
dc.DrawWireBox(worldAABB.min, worldAABB.max);
}
}
// draw object being moved
if (m_modeStatus == eVSS_MoveSelectVertexToAnotherVertex && m_SelectionInfo.m_pObject)
{
dc.SetColor(QColor(0xaa, 0xaa, 0xaa));
if (auto pStatObj = m_SelectionInfo.m_pObject->GetIStatObj())
{
DrawVertexCubes(dc, m_SelectionInfo.m_pObject->GetWorldTM(), pStatObj);
}
else
{
AABB bounds;
m_SelectionInfo.m_pObject->GetBoundBox(bounds);
dc.DrawWireBox(bounds.min, bounds.max);
}
}
// draw pivot of hit object
if (m_pHitObject && (!m_bHit || m_bHit && !m_pHitObject->GetWorldPos().IsEquivalent(m_vHitVertex, 0.001f)))
{
dc.SetColor(PivotColor);
dc.DepthTestOff();
Vec3 vBoxSize = GetCubeSize(dc.view, m_pHitObject->GetWorldPos()) * 1.2f;
AABB vertexBox(m_pHitObject->GetWorldPos() - vBoxSize, m_pHitObject->GetWorldPos() + vBoxSize);
dc.DrawBall((vertexBox.min + vertexBox.max) * 0.5f, (vertexBox.max.x - vertexBox.min.x) * 0.5f);
dc.DepthTestOn();
}
// draw the vertex (or pivot) that's being hit
if (m_bHit)
{
dc.DepthTestOff();
dc.SetColor(SnappedColor);
Vec3 vBoxSize = GetCubeSize(dc.view, m_vHitVertex);
if (m_vHitVertex.IsEquivalent(m_pHitObject->GetWorldPos(), 0.001f))
{
dc.DrawBall(m_vHitVertex, vBoxSize.x * 1.2f);
}
else
{
dc.DrawSolidBox(m_vHitVertex - vBoxSize, m_vHitVertex + vBoxSize);
}
dc.DepthTestOn();
}
// draw wireframe of hit object
if (m_pHitObject && m_pHitObject->GetIStatObj())
{
SGeometryDebugDrawInfo dd;
dd.tm = m_pHitObject->GetWorldTM();
dd.color = ColorB(250, 0, 250, 30);
dd.lineColor = ColorB(255, 255, 0, 160);
dd.bExtrude = true;
m_pHitObject->GetIStatObj()->DebugDraw(dd);
}
// draw debug boxes
if (gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox)
{
ColorB boxColor(40, 40, 40);
for (int i = 0, iCount(m_DebugBoxes.size()); i < iCount; ++i)
{
dc.SetColor(boxColor);
boxColor += ColorB(25, 25, 25);
dc.DrawWireBox(m_DebugBoxes[i].min, m_DebugBoxes[i].max);
}
}
}
void CVertexSnappingModeTool::DrawVertexCubes(DisplayContext& dc, const Matrix34& tm, IStatObj* pStatObj)
{
if (!pStatObj)
{
return;
}
IIndexedMesh* pIndexedMesh = pStatObj->GetIndexedMesh();
if (pIndexedMesh)
{
IIndexedMesh::SMeshDescription md;
pIndexedMesh->GetMeshDescription(md);
for (int k = 0; k < md.m_nVertCount; ++k)
{
Vec3 vPos(0, 0, 0);
if (md.m_pVerts)
{
vPos = md.m_pVerts[k];
}
else if (md.m_pVertsF16)
{
vPos = md.m_pVertsF16[k].ToVec3();
}
else
{
continue;
}
vPos = tm.TransformPoint(vPos);
Vec3 vBoxSize = GetCubeSize(dc.view, vPos);
if (!m_bHit || !m_vHitVertex.IsEquivalent(vPos, 0.001f))
{
dc.DrawSolidBox(vPos - vBoxSize, vPos + vBoxSize);
}
}
}
for (int i = 0, iSubStatObjNum(pStatObj->GetSubObjectCount()); i < iSubStatObjNum; ++i)
{
IStatObj::SSubObject* pSubObj = pStatObj->GetSubObject(i);
if (pSubObj)
{
DrawVertexCubes(dc, tm * pSubObj->localTM, pSubObj->pStatObj);
}
}
}
CKDTree* CVertexSnappingModeTool::GetKDTree(CBaseObject* pObject)
{
auto existingTree = m_ObjectKdTreeMap.find(pObject);
if (existingTree != m_ObjectKdTreeMap.end())
{
return existingTree->second;
}
// Don't build a kd-tree for objects without verts
CKDTree* pTree = nullptr;
if (auto pStatObj = pObject->GetIStatObj())
{
pTree = new CKDTree();
pTree->Build(pObject->GetIStatObj());
}
m_ObjectKdTreeMap[pObject] = pTree;
return pTree;
}
#include <EditMode/moc_VertexSnappingModeTool.cpp>
@@ -1,91 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_EDITMODE_VERTEXSNAPPINGMODETOOL_H
#define CRYINCLUDE_EDITOR_EDITMODE_VERTEXSNAPPINGMODETOOL_H
#pragma once
#include "EditTool.h"
#include "Objects/BaseObject.h"
class CKDTree;
struct IDisplayViewport;
class CVertexSnappingModeTool
: public CEditTool
{
Q_OBJECT
public:
Q_INVOKABLE CVertexSnappingModeTool();
~CVertexSnappingModeTool();
static const GUID& GetClassID();
static void RegisterTool(CRegistrationContext& rc);
void Display(DisplayContext& dc);
bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
protected:
void DrawVertexCubes(DisplayContext& dc, const Matrix34& tm, IStatObj* pStatObj);
void DeleteThis(){ delete this; }
Vec3 GetCubeSize(IDisplayViewport* pView, const Vec3& pos) const;
private:
using CEditTool::HitTest;
bool HitTest(CViewport* view, const QPoint& point, CBaseObject* pExcludedObj, Vec3& outHitPos, CBaseObjectPtr& pOutHitObject, std::vector<CBaseObjectPtr>& outObjects);
CKDTree* GetKDTree(CBaseObject* pObject);
enum EVertexSnappingStatus
{
eVSS_SelectFirstVertex,
eVSS_MoveSelectVertexToAnotherVertex
};
EVertexSnappingStatus m_modeStatus;
struct SSelectionInfo
{
SSelectionInfo()
{
m_pObject = NULL;
m_vPos = Vec3(0, 0, 0);
}
CBaseObjectPtr m_pObject;
Vec3 m_vPos;
};
/// Info on object being moved (when in eVSS_MoveSelectVertexToAnotherVertex mode).
SSelectionInfo m_SelectionInfo;
/// Objects that mouse is over
std::vector<CBaseObjectPtr> m_Objects;
/// Position of vertex that mouse is hitting.
/// Invalid when m_bHit is false.
Vec3 m_vHitVertex;
/// Whether the mouse hit test succeeded
bool m_bHit;
/// Object that mouse is hitting
CBaseObjectPtr m_pHitObject;
/// Boxes to render for debug drawing
std::vector<AABB> m_DebugBoxes;
/// For each object, a tree containing its vertices.
std::map<CBaseObjectPtr, CKDTree*> m_ObjectKdTreeMap;
};
#endif // CRYINCLUDE_EDITOR_EDITMODE_VERTEXSNAPPINGMODETOOL_H
-89
View File
@@ -1,89 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "EditTool.h"
// Editor
#include "Include/IObjectManager.h"
#include "Objects/SelectionGroup.h"
//////////////////////////////////////////////////////////////////////////
// Class description.
//////////////////////////////////////////////////////////////////////////
class CEditTool_ClassDesc
: public CRefCountClassDesc
{
virtual ESystemClassID SystemClassID() { return ESYSTEM_CLASS_EDITTOOL; }
virtual REFGUID ClassID()
{
// {0A43AB8E-B1AE-44aa-93B1-229F73D58CA4}
static const GUID guid = {
0xa43ab8e, 0xb1ae, 0x44aa, { 0x93, 0xb1, 0x22, 0x9f, 0x73, 0xd5, 0x8c, 0xa4 }
};
return guid;
}
virtual QString ClassName() { return "EditTool.Default"; };
virtual QString Category() { return "EditTool"; };
};
CEditTool_ClassDesc g_stdClassDesc;
//////////////////////////////////////////////////////////////////////////
CEditTool::CEditTool(QObject* parent)
: QObject(parent)
{
m_pClassDesc = &g_stdClassDesc;
m_nRefCount = 0;
};
//////////////////////////////////////////////////////////////////////////
void CEditTool::SetParentTool(CEditTool* pTool)
{
m_pParentTool = pTool;
}
//////////////////////////////////////////////////////////////////////////
CEditTool* CEditTool::GetParentTool()
{
return m_pParentTool;
}
//////////////////////////////////////////////////////////////////////////
void CEditTool::Abort()
{
if (m_pParentTool)
{
GetIEditor()->SetEditTool(m_pParentTool);
}
else
{
GetIEditor()->SetEditTool(0);
}
}
//////////////////////////////////////////////////////////////////////////
void CEditTool::GetAffectedObjects(DynArray<CBaseObject*>& outAffectedObjects)
{
CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection();
if (pSelection == NULL)
{
return;
}
for (int i = 0, iCount(pSelection->GetCount()); i < iCount; ++i)
{
outAffectedObjects.push_back(pSelection->GetObject(i));
}
}
#include <moc_EditTool.cpp>
-175
View File
@@ -1,175 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_EDITOR_EDITTOOL_H
#define CRYINCLUDE_EDITOR_EDITTOOL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include "QtViewPaneManager.h"
#endif
class CViewport;
struct IClassDesc;
struct ITransformManipulator;
struct HitContext;
enum EEditToolType
{
EDIT_TOOL_TYPE_PRIMARY,
EDIT_TOOL_TYPE_SECONDARY,
};
/*!
* CEditTool is an abstract base class for All Editing Tools supported by Editor.
* Edit tools handle specific editing modes in viewports.
*/
class SANDBOX_API CEditTool
: public QObject
{
Q_OBJECT
public:
explicit CEditTool(QObject* parent = nullptr);
//////////////////////////////////////////////////////////////////////////
// For reference counting.
//////////////////////////////////////////////////////////////////////////
void AddRef() { m_nRefCount++; };
void Release()
{
AZ_Assert(m_nRefCount > 0, "Negative ref count");
if (--m_nRefCount == 0)
{
DeleteThis();
}
};
//! Returns class description for this tool.
IClassDesc* GetClassDesc() const { return m_pClassDesc; }
virtual void SetParentTool(CEditTool* pTool);
virtual CEditTool* GetParentTool();
virtual EEditToolType GetType() { return EDIT_TOOL_TYPE_PRIMARY; }
virtual EOperationMode GetMode() { return eOperationModeNone; }
// Abort tool.
virtual void Abort();
// Accept tool.
virtual void Accept([[maybe_unused]] bool resetPosition = false) {}
//! Status text displayed when this tool is active.
void SetStatusText(const QString& text) { m_statusText = text; };
QString GetStatusText() { return m_statusText; };
// Description:
// Activates tool.
// Arguments:
// pPreviousTool - Previously active edit tool.
// Return:
// True if the tool can be activated,
virtual bool Activate([[maybe_unused]] CEditTool* pPreviousTool) { return true; };
//! Used to pass user defined data to edit tool from ToolButton.
virtual void SetUserData([[maybe_unused]] const char* key, [[maybe_unused]] void* userData) {};
//! Called when user starts using this tool.
//! Flags is comnination of ObjectEditFlags flags.
virtual void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) {};
//! Called when user ends using this tool.
virtual void EndEditParams() {};
// Called each frame to display tool for given viewport.
virtual void Display(struct DisplayContext& dc) = 0;
//! Mouse callback sent from viewport.
//! Returns true if event processed by callback, and all other processing for this event should abort.
//! Return false if event was not processed by callback, and other processing for this event should occur.
//! @param view Viewport that sent this callback.
//! @param event Indicate what kind of event occured in viewport.
//! @param point 2D coordinate in viewport where event occured.
//! @param flags Additional flags (MK_LBUTTON,etc..) or from (MouseEventFlags) specified by viewport when calling callback.
virtual bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) = 0;
//! Called when key in viewport is pressed while using this tool.
//! Returns true if event processed by callback, and all other processing for this event should abort.
//! Returns false if event was not processed by callback, and other processing for this event should occur.
//! @param view Viewport where key was pressed.
//! @param nChar Specifies the virtual key code of the given key. For a list of standard virtual key codes, see Winuser.h
//! @param nRepCnt Specifies the repeat count, that is, the number of times the keystroke is repeated as a result of the user holding down the key.
//! @param nFlags Specifies the scan code, key-transition code, previous key state, and context code, (see WM_KEYDOWN)
virtual bool OnKeyDown([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; };
//! Called when key in viewport is released while using this tool.
//! Returns true if event processed by callback, and all other processing for this event should abort.
//! Returns false if event was not processed by callback, and other processing for this event should occur.
//! @param view Viewport where key was pressed.
//! @param nChar Specifies the virtual key code of the given key. For a list of standard virtual key codes, see Winuser.h
//! @param nRepCnt Specifies the repeat count, that is, the number of times the keystroke is repeated as a result of the user holding down the key.
//! @param nFlags Specifies the scan code, key-transition code, previous key state, and context code, (see WM_KEYDOWN)
virtual bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; };
//! Called when mouse is moved and give oportunity to tool to set it own cursor.
//! @return true if cursor changed. or false otherwise.
virtual bool OnSetCursor([[maybe_unused]] CViewport* vp) { return false; };
// Return objects affected by this edit tool. The returned objects usually will be the selected objects.
virtual void GetAffectedObjects(DynArray<CBaseObject*>& outAffectedObjects);
// Called in response to the dragging of the manipulator in the view.
// Allow edit tool to handle manipulator dragging the way it wants.
virtual void OnManipulatorDrag([[maybe_unused]] CViewport* view, [[maybe_unused]] ITransformManipulator* pManipulator, [[maybe_unused]] QPoint& p0, [[maybe_unused]] QPoint& p1, [[maybe_unused]] const Vec3& value) {}
virtual void OnManipulatorDrag(CViewport* view, ITransformManipulator* pManipulator, const Vec3& value)
{
// Overload with less boiler-plate
QPoint p0, p1;
OnManipulatorDrag(view, pManipulator, p0, p1, value);
}
// Called in response to mouse event of the manipulator in the view
virtual void OnManipulatorMouseEvent([[maybe_unused]] CViewport* view, [[maybe_unused]] ITransformManipulator* pManipulator, [[maybe_unused]] EMouseEvent event, [[maybe_unused]] QPoint& point, [[maybe_unused]] int flags, [[maybe_unused]] bool bHitGizmo = false) {}
virtual bool IsNeedMoveTool() { return false; }
virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return false; }
virtual bool IsNeedToSkipPivotBoxForObjects() { return false; }
virtual bool IsDisplayGrid() { return true; }
virtual bool IsUpdateUIPanel() { return false; }
virtual bool IsMoveToObjectModeAfterEnd() { return true; }
virtual bool IsCircleTypeRotateGizmo() { return false; }
// Draws object specific helpers for this tool
virtual void DrawObjectHelpers([[maybe_unused]] CBaseObject* pObject, [[maybe_unused]] DisplayContext& dc) {}
// Hit test against edit tool
virtual bool HitTest([[maybe_unused]] CBaseObject* pObject, [[maybe_unused]] HitContext& hc) { return false; }
protected:
virtual ~CEditTool() {};
//////////////////////////////////////////////////////////////////////////
// Delete edit tool.
//////////////////////////////////////////////////////////////////////////
virtual void DeleteThis() = 0;
protected:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
_smart_ptr<CEditTool> m_pParentTool; // Pointer to parent edit tool.
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
QString m_statusText;
IClassDesc* m_pClassDesc;
int m_nRefCount;
};
#endif // CRYINCLUDE_EDITOR_EDITTOOL_H
@@ -63,11 +63,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
->Field("DeepSelectionRange", &DeepSelection::m_deepSelectionRange)
->Field("StickDuplicate", &DeepSelection::m_stickDuplicate);
serialize.Class<VertexSnapping>()
->Version(1)
->Field("VertexCubeSize", &VertexSnapping::m_vertexCubeSize)
->Field("RenderPenetratedBoundBox", &VertexSnapping::m_bRenderPenetratedBoundBox);
serialize.Class<SliceSettings>()
->Version(1)
->Field("DynamicByDefault", &SliceSettings::m_slicesDynamicByDefault);
@@ -78,7 +73,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
->Field("Messaging", &CEditorPreferencesPage_General::m_messaging)
->Field("Undo", &CEditorPreferencesPage_General::m_undo)
->Field("Deep Selection", &CEditorPreferencesPage_General::m_deepSelection)
->Field("Vertex Snapping", &CEditorPreferencesPage_General::m_vertexSnapping)
->Field("Slice Settings", &CEditorPreferencesPage_General::m_sliceSettings);
@@ -119,12 +113,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 1000.0f);
editContext->Class<VertexSnapping>("Vertex Snapping", "")
->DataElement(AZ::Edit::UIHandlers::SpinBox, &VertexSnapping::m_vertexCubeSize, "Vertex Cube Size", "Vertex Cube Size")
->Attribute(AZ::Edit::Attributes::Min, 0.0001f)
->Attribute(AZ::Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::CheckBox, &VertexSnapping::m_bRenderPenetratedBoundBox, "Render Penetrated BoundBoxes", "Render Penetrated BoundBoxes");
editContext->Class<SliceSettings>("Slices", "")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &SliceSettings::m_slicesDynamicByDefault, "New Slices Dynamic By Default", "When creating slices, they will be set to dynamic by default");
@@ -135,7 +123,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_messaging, "Messaging", "Messaging")
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_undo, "Undo", "Undo Preferences")
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_deepSelection, "Selection", "Selection")
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_vertexSnapping, "Vertex Snapping", "Vertex Snapping")
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_sliceSettings, "Slices", "Slice Settings");
}
}
@@ -189,10 +176,6 @@ void CEditorPreferencesPage_General::OnApply()
gSettings.deepSelectionSettings.fRange = m_deepSelection.m_deepSelectionRange;
gSettings.deepSelectionSettings.bStickDuplicate = m_deepSelection.m_stickDuplicate;
//vertex snapping
gSettings.vertexSnappingSettings.vertexCubeSize = m_vertexSnapping.m_vertexCubeSize;
gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox = m_vertexSnapping.m_bRenderPenetratedBoundBox;
//slices
gSettings.sliceSettings.dynamicByDefault = m_sliceSettings.m_slicesDynamicByDefault;
@@ -236,10 +219,6 @@ void CEditorPreferencesPage_General::InitializeSettings()
m_deepSelection.m_deepSelectionRange = gSettings.deepSelectionSettings.fRange;
m_deepSelection.m_stickDuplicate = gSettings.deepSelectionSettings.bStickDuplicate;
//vertex snapping
m_vertexSnapping.m_vertexCubeSize = gSettings.vertexSnappingSettings.vertexCubeSize;
m_vertexSnapping.m_bRenderPenetratedBoundBox = gSettings.vertexSnappingSettings.bRenderPenetratedBoundBox;
//slices
m_sliceSettings.m_slicesDynamicByDefault = gSettings.sliceSettings.dynamicByDefault;
}
@@ -88,14 +88,6 @@ private:
bool m_stickDuplicate;
};
struct VertexSnapping
{
AZ_TYPE_INFO(VertexSnapping, "{20F16350-990C-4096-86E3-40D56DDDD702}")
float m_vertexCubeSize;
bool m_bRenderPenetratedBoundBox;
};
struct SliceSettings
{
AZ_TYPE_INFO(SliceSettings, "{8505CCC1-874C-4389-B51A-B9E5FF70CFDA}")
@@ -107,7 +99,6 @@ private:
Messaging m_messaging;
Undo m_undo;
DeepSelection m_deepSelection;
VertexSnapping m_vertexSnapping;
SliceSettings m_sliceSettings;
QIcon m_icon;
};
@@ -65,7 +65,6 @@
#include "Util/fastlib.h"
#include "CryEditDoc.h"
#include "GameEngine.h"
#include "EditTool.h"
#include "ViewManager.h"
#include "Objects/DisplayContext.h"
#include "DisplaySettings.h"
+17 -17
View File
@@ -65,7 +65,7 @@ namespace
const float kTangentDelta = 0.01f;
const float kAspectRatio = 1.777778f;
const int kReserveCount = 7; // x,y,z,rot_x,rot_y,rot_z,fov
const QString kMasterCameraName = "MasterCamera";
const QString kPrimaryCameraName = "PrimaryCamera";
} // namespace
@@ -169,10 +169,10 @@ CExportManager::CExportManager()
, m_numberOfExportFrames(0)
, m_pivotEntityObject(0)
, m_bBakedKeysSequenceExport(true)
, m_animTimeExportMasterSequenceCurrentTime(0.0f)
, m_animTimeExportPrimarySequenceCurrentTime(0.0f)
, m_animKeyTimeExport(true)
, m_soundKeyTimeExport(true)
, m_bExportOnlyMasterCamera(false)
, m_bExportOnlyPrimaryCamera(false)
{
RegisterExporter(new COBJExporter());
RegisterExporter(new COCMExporter());
@@ -773,14 +773,14 @@ bool CExportManager::ShowFBXExportDialog()
return false;
}
SetFBXExportSettings(fpsDialog.GetExportCoordsLocalToTheSelectedObject(), fpsDialog.GetExportOnlyMasterCamera(), fpsDialog.GetFPS());
SetFBXExportSettings(fpsDialog.GetExportCoordsLocalToTheSelectedObject(), fpsDialog.GetExportOnlyPrimaryCamera(), fpsDialog.GetFPS());
return true;
}
bool CExportManager::ProcessObjectsForExport()
{
Export::CObject* pObj = new Export::CObject(kMasterCameraName.toUtf8().data());
Export::CObject* pObj = new Export::CObject(kPrimaryCameraName.toUtf8().data());
pObj->entityType = Export::eCamera;
m_data.m_objects.push_back(pObj);
@@ -808,13 +808,13 @@ bool CExportManager::ProcessObjectsForExport()
Export::CObject* pObj2 = m_data.m_objects[objectID];
CBaseObject* pObject = 0;
if (QString::compare(pObj2->name, kMasterCameraName) == 0)
if (QString::compare(pObj2->name, kPrimaryCameraName) == 0)
{
pObject = GetIEditor()->GetObjectManager()->FindObject(GetIEditor()->GetViewManager()->GetCameraObjectId());
}
else
{
if (m_bExportOnlyMasterCamera && pObj2->entityType != Export::eCameraTarget)
if (m_bExportOnlyPrimaryCamera && pObj2->entityType != Export::eCameraTarget)
{
continue;
}
@@ -952,7 +952,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode*
if (numAllTracks > 0)
{
XmlNodeRef objNode = writeNode->createNode(CleanXMLText(pObjectNode->GetName()).toUtf8().data());
writeNode->setAttr("time", m_animTimeExportMasterSequenceCurrentTime);
writeNode->setAttr("time", m_animTimeExportPrimarySequenceCurrentTime);
for (unsigned int trackID = 0; trackID < numAllTracks; ++trackID)
{
@@ -1020,7 +1020,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode*
XmlNodeRef keyNode = subNode->createNode(keyContentName.toUtf8().data());
float keyGlobalTime = m_animTimeExportMasterSequenceCurrentTime + keyTime;
float keyGlobalTime = m_animTimeExportPrimarySequenceCurrentTime + keyTime;
keyNode->setAttr("keyTime", keyGlobalTime);
if (keyStartTime > 0)
@@ -1123,13 +1123,13 @@ bool CExportManager::AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNo
const QString sequenceName = pSubSequence->GetName();
XmlNodeRef subSeqNode2 = seqNode->createNode(sequenceName.toUtf8().data());
if (sequenceName == m_animTimeExportMasterSequenceName)
if (sequenceName == m_animTimeExportPrimarySequenceName)
{
m_animTimeExportMasterSequenceCurrentTime = sequenceKey.time;
m_animTimeExportPrimarySequenceCurrentTime = sequenceKey.time;
}
else
{
m_animTimeExportMasterSequenceCurrentTime += sequenceKey.time;
m_animTimeExportPrimarySequenceCurrentTime += sequenceKey.time;
}
AddObjectsFromSequence(pSubSequence, subSeqNode2);
@@ -1336,7 +1336,7 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con
{
m_numberOfExportFrames = pSequence->GetTimeRange().end * m_FBXBakedExportFPS;
if (!m_bExportOnlyMasterCamera)
if (!m_bExportOnlyPrimaryCamera)
{
AddObjectsFromSequence(pSequence);
}
@@ -1365,10 +1365,10 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con
return returnRes;
}
void CExportManager::SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyMasterCamera, const float fps)
void CExportManager::SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyPrimaryCamera, const float fps)
{
m_bExportLocalCoords = bLocalCoordsToSelectedObject;
m_bExportOnlyMasterCamera = bExportOnlyMasterCamera;
m_bExportOnlyPrimaryCamera = bExportOnlyPrimaryCamera;
m_FBXBakedExportFPS = fps;
}
@@ -1439,10 +1439,10 @@ void CExportManager::SaveNodeKeysTimeToXML()
if (dlg.exec())
{
m_animTimeNode = XmlHelpers::CreateXmlNode(pSequence->GetName());
m_animTimeExportMasterSequenceName = pSequence->GetName();
m_animTimeExportPrimarySequenceName = pSequence->GetName();
m_data.Clear();
m_animTimeExportMasterSequenceCurrentTime = 0.0;
m_animTimeExportPrimarySequenceCurrentTime = 0.0;
AddObjectsFromSequence(pSequence, m_animTimeNode);
+4 -4
View File
@@ -171,7 +171,7 @@ private:
bool AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNodeRef seqNode = 0);
bool IsDuplicateObjectBeingAdded(const QString& newObject);
void SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyMasterCamera, const float fps);
void SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyPrimaryCamera, const float fps);
bool ProcessObjectsForExport();
bool ShowFBXExportDialog();
@@ -193,13 +193,13 @@ private:
float m_FBXBakedExportFPS;
bool m_bExportLocalCoords;
bool m_bExportOnlyMasterCamera;
bool m_bExportOnlyPrimaryCamera;
int m_numberOfExportFrames;
CEntityObject* m_pivotEntityObject;
bool m_bBakedKeysSequenceExport;
QString m_animTimeExportMasterSequenceName;
float m_animTimeExportMasterSequenceCurrentTime;
QString m_animTimeExportPrimarySequenceName;
float m_animTimeExportPrimarySequenceCurrentTime;
XmlNodeRef m_animTimeNode;
bool m_animKeyTimeExport;
+3 -3
View File
@@ -55,9 +55,9 @@ bool CFBXExporterDialog::GetExportCoordsLocalToTheSelectedObject() const
return m_ui->m_exportLocalCoordsCheckbox->isChecked();
}
bool CFBXExporterDialog::GetExportOnlyMasterCamera() const
bool CFBXExporterDialog::GetExportOnlyPrimaryCamera() const
{
return m_ui->m_exportOnlyMasterCameraCheckBox->isChecked();
return m_ui->m_exportOnlyPrimaryCameraCheckBox->isChecked();
}
void CFBXExporterDialog::SetExportLocalCoordsCheckBoxEnable(bool checked)
@@ -100,7 +100,7 @@ int CFBXExporterDialog::exec()
if (m_bDisplayOnlyFPSSetting)
{
m_ui->m_exportLocalCoordsCheckbox->setEnabled(false);
m_ui->m_exportOnlyMasterCameraCheckBox->setEnabled(false);
m_ui->m_exportOnlyPrimaryCameraCheckBox->setEnabled(false);
}
m_ui->m_fpsCombo->addItem("24");
+2 -2
View File
@@ -36,7 +36,7 @@ public:
float GetFPS() const;
bool GetExportCoordsLocalToTheSelectedObject() const;
bool GetExportOnlyMasterCamera() const;
bool GetExportOnlyPrimaryCamera() const;
void SetExportLocalCoordsCheckBoxEnable(bool checked);
int exec() override;
@@ -44,7 +44,7 @@ public:
protected:
void OnFPSChange();
void SetExportLocalToTheSelectedObjectCheckBox();
void SetExportOnlyMasterCameraCheckBox();
void SetExportOnlyPrimaryCameraCheckBox();
void accept() override;
+2 -2
View File
@@ -49,9 +49,9 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="m_exportOnlyMasterCameraCheckBox">
<widget class="QCheckBox" name="m_exportOnlyPrimaryCameraCheckBox">
<property name="text">
<string>Export Only Master Camera</string>
<string>Export Only Primary Camera</string>
</property>
</widget>
</item>
-3
View File
@@ -125,9 +125,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
{
QDir::setCurrent(pEditor->GetPrimaryCDFolder());
// Close all Editor tools
pEditor->SetEditTool(0);
QString sLevelPath = Path::AddSlash(pGameEngine->GetLevelPath());
if (subdirectory && subdirectory[0] && strcmp(subdirectory, ".") != 0)
{
-23
View File
@@ -40,7 +40,6 @@ struct QMetaObject;
class CBaseObject;
class CCryEditDoc;
class CSelectionGroup;
class CEditTool;
class CAnimationContext;
class CTrackViewSequenceManager;
class CGameEngine;
@@ -319,17 +318,6 @@ enum EOperationMode
eModellingMode // Geometry modeling mode
};
enum EEditMode
{
eEditModeSelect,
eEditModeSelectArea,
eEditModeMove,
eEditModeRotate,
eEditModeScale,
eEditModeTool,
eEditModeRotateCircle,
};
//! Mouse events that viewport can send
enum EMouseEvent
{
@@ -620,17 +608,6 @@ struct IEditor
virtual void SetOperationMode(EOperationMode mode) = 0;
virtual EOperationMode GetOperationMode() = 0;
//! editMode - EEditMode
virtual void SetEditMode(int editMode) = 0;
virtual int GetEditMode() = 0;
//! Assign current edit tool, destroy previously used edit too.
virtual void SetEditTool(CEditTool* tool, bool bStopCurrentTool = true) = 0;
//! Assign current edit tool by class name.
virtual void SetEditTool(const QString& sEditToolName, bool bStopCurrentTool = true) = 0;
//! Reinitializes the current edit tool if one is selected.
virtual void ReinitializeEditTool() = 0;
//! Returns current edit tool.
virtual CEditTool* GetEditTool() = 0;
//! Shows/Hides transformation manipulator.
//! if bShow is true also returns a valid ITransformManipulator pointer.
virtual ITransformManipulator* ShowTransformManipulator(bool bShow) = 0;
+1 -269
View File
@@ -54,7 +54,6 @@ AZ_POP_DISABLE_WARNING
#include "Export/ExportManager.h"
#include "LevelIndependentFileMan.h"
#include "Material/MaterialManager.h"
#include "Material/MaterialPickTool.h"
#include "TrackView/TrackViewSequenceManager.h"
#include "AnimationContext.h"
#include "GameEngine.h"
@@ -71,13 +70,9 @@ AZ_POP_DISABLE_WARNING
#include "Objects/SelectionGroup.h"
#include "Objects/ObjectManager.h"
#include "RotateTool.h"
#include "NullEditTool.h"
#include "BackgroundTaskManager.h"
#include "BackgroundScheduleManager.h"
#include "EditorFileMonitor.h"
#include "EditMode/VertexSnappingModeTool.h"
#include "Mission.h"
#include "MainStatusBar.h"
@@ -149,8 +144,7 @@ namespace
const char* CEditorImpl::m_crashLogFileName = "SessionStatus/editor_statuses.json";
CEditorImpl::CEditorImpl()
: m_currEditMode(eEditModeSelect)
, m_operationMode(eOperationModeNone)
: m_operationMode(eOperationModeNone)
, m_pSystem(nullptr)
, m_pFileUtil(nullptr)
, m_pClassFactory(nullptr)
@@ -241,18 +235,6 @@ CEditorImpl::CEditorImpl()
m_pRuler = new CRuler;
m_selectedRegion.min = Vec3(0, 0, 0);
m_selectedRegion.max = Vec3(0, 0, 0);
ZeroStruct(m_lastAxis);
m_lastAxis[eEditModeSelect] = AXIS_TERRAIN;
m_lastAxis[eEditModeSelectArea] = AXIS_TERRAIN;
m_lastAxis[eEditModeMove] = AXIS_TERRAIN;
m_lastAxis[eEditModeRotate] = AXIS_Z;
m_lastAxis[eEditModeScale] = AXIS_XY;
ZeroStruct(m_lastCoordSys);
m_lastCoordSys[eEditModeSelect] = COORDS_LOCAL;
m_lastCoordSys[eEditModeSelectArea] = COORDS_LOCAL;
m_lastCoordSys[eEditModeMove] = COORDS_WORLD;
m_lastCoordSys[eEditModeRotate] = COORDS_WORLD;
m_lastCoordSys[eEditModeScale] = COORDS_WORLD;
DetectVersion();
RegisterTools();
@@ -262,8 +244,6 @@ CEditorImpl::CEditorImpl()
m_pAssetBrowserRequestHandler = nullptr;
m_assetEditorRequestsHandler = nullptr;
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
AZ::IO::SystemFile::CreateDir("SessionStatus");
QFile::setPermissions(m_crashLogFileName, QFileDevice::ReadOther | QFileDevice::WriteOther);
}
@@ -287,8 +267,6 @@ void CEditorImpl::Initialize()
// Activate QT immediately so that its available as soon as CEditorImpl is (and thus GetIEditor())
InitializeEditorCommon(GetIEditor());
LoadSettings();
}
//The only purpose of that function is to be called at the very begining of the shutdown sequence so that we can instrument and track
@@ -303,8 +281,6 @@ void CEditorImpl::OnEarlyExitShutdownSequence()
void CEditorImpl::Uninitialize()
{
SaveSettings();
if (m_pSystem)
{
UninitializeEditorCommonISystem(m_pSystem);
@@ -365,8 +341,6 @@ void CEditorImpl::LoadPlugins()
CEditorImpl::~CEditorImpl()
{
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect();
gSettings.Save();
m_bExiting = true; // Can't save level after this point (while Crash)
SAFE_RELEASE(m_pSourceControl);
@@ -451,12 +425,6 @@ void CEditorImpl::RegisterTools()
rc.pCommandManager = m_pCommandManager;
rc.pClassFactory = m_pClassFactory;
CObjectMode::RegisterTool(rc);
CMaterialPickTool::RegisterTool(rc);
CVertexSnappingModeTool::RegisterTool(rc);
CRotateTool::RegisterTool(rc);
NullEditTool::RegisterTool(rc);
}
void CEditorImpl::ExecuteCommand(const char* sCommand, ...)
@@ -661,53 +629,6 @@ IMainStatusBar* CEditorImpl::GetMainStatusBar()
return MainWindow::instance()->StatusBar();
}
int CEditorImpl::GetEditMode()
{
return m_currEditMode;
}
void CEditorImpl::SetEditMode(int editMode)
{
bool isEditorInGameMode = false;
EBUS_EVENT_RESULT(isEditorInGameMode, AzToolsFramework::EditorEntityContextRequestBus, IsEditorRunningGame);
if (isEditorInGameMode)
{
if (editMode != eEditModeSelect)
{
if (SelectionContainsComponentEntities())
{
return;
}
}
}
if ((EEditMode)editMode == eEditModeRotate)
{
if (GetEditTool() && GetEditTool()->IsCircleTypeRotateGizmo())
{
editMode = eEditModeRotateCircle;
}
}
EEditMode newEditMode = (EEditMode)editMode;
if (m_currEditMode == newEditMode)
{
return;
}
m_currEditMode = newEditMode;
AABB box(Vec3(0, 0, 0), Vec3(0, 0, 0));
SetSelectedRegion(box);
if (GetEditTool() && !GetEditTool()->IsNeedMoveTool())
{
SetEditTool(0, true);
}
Notify(eNotify_OnEditModeChange);
}
void CEditorImpl::SetOperationMode(EOperationMode mode)
{
m_operationMode = mode;
@@ -719,139 +640,6 @@ EOperationMode CEditorImpl::GetOperationMode()
return m_operationMode;
}
bool CEditorImpl::HasCorrectEditTool() const
{
if (!m_pEditTool)
{
return false;
}
switch (m_currEditMode)
{
case eEditModeRotate:
return qobject_cast<CRotateTool*>(m_pEditTool) != nullptr;
default:
return qobject_cast<CObjectMode*>(m_pEditTool) != nullptr && qobject_cast<CRotateTool*>(m_pEditTool) == nullptr;
}
}
CEditTool* CEditorImpl::CreateCorrectEditTool()
{
if (m_currEditMode == eEditModeRotate)
{
CBaseObject* selectedObj = nullptr;
CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection();
if (pSelection && pSelection->GetCount() > 0)
{
selectedObj = pSelection->GetObject(0);
}
return (new CRotateTool(selectedObj));
}
return (new CObjectMode);
}
void CEditorImpl::SetEditTool(CEditTool* tool, bool bStopCurrentTool)
{
CViewport* pViewport = GetIEditor()->GetActiveView();
if (pViewport)
{
pViewport->SetCurrentCursor(STD_CURSOR_DEFAULT);
}
if (!tool)
{
if (HasCorrectEditTool())
{
return;
}
else
{
tool = CreateCorrectEditTool();
}
}
if (!tool->Activate(m_pEditTool))
{
return;
}
if (bStopCurrentTool)
{
if (m_pEditTool && m_pEditTool != tool)
{
m_pEditTool->EndEditParams();
SetStatusText("Ready");
}
}
m_pEditTool = tool;
if (m_pEditTool)
{
m_pEditTool->BeginEditParams(this, 0);
}
Notify(eNotify_OnEditToolChange);
}
void CEditorImpl::ReinitializeEditTool()
{
if (m_pEditTool)
{
m_pEditTool->EndEditParams();
m_pEditTool->BeginEditParams(this, 0);
}
}
void CEditorImpl::SetEditTool(const QString& sEditToolName, [[maybe_unused]] bool bStopCurrentTool)
{
CEditTool* pTool = GetEditTool();
if (pTool && pTool->GetClassDesc())
{
// Check if already selected.
if (QString::compare(pTool->GetClassDesc()->ClassName(), sEditToolName, Qt::CaseInsensitive) == 0)
{
return;
}
}
IClassDesc* pClass = GetIEditor()->GetClassFactory()->FindClass(sEditToolName.toUtf8().data());
if (!pClass)
{
Warning("Editor Tool %s not registered.", sEditToolName.toUtf8().data());
return;
}
if (pClass->SystemClassID() != ESYSTEM_CLASS_EDITTOOL)
{
Warning("Class name %s is not a valid Edit Tool class.", sEditToolName.toUtf8().data());
return;
}
QScopedPointer<QObject> o(pClass->CreateQObject());
if (CEditTool* pEditTool = qobject_cast<CEditTool*>(o.data()))
{
GetIEditor()->SetEditTool(pEditTool);
o.take();
return;
}
else
{
Warning("Class name %s is not a valid Edit Tool class.", sEditToolName.toUtf8().data());
return;
}
}
CEditTool* CEditorImpl::GetEditTool()
{
if (m_isNewViewportInteractionModelEnabled)
{
return nullptr;
}
return m_pEditTool;
}
ITransformManipulator* CEditorImpl::ShowTransformManipulator(bool bShow)
{
if (bShow)
@@ -885,7 +673,6 @@ ITransformManipulator* CEditorImpl::GetTransformManipulator()
void CEditorImpl::SetAxisConstraints(AxisConstrains axisFlags)
{
m_selectedAxis = axisFlags;
m_lastAxis[m_currEditMode] = m_selectedAxis;
m_pViewManager->SetAxisConstrain(axisFlags);
SetTerrainAxisIgnoreObjects(false);
@@ -911,7 +698,6 @@ bool CEditorImpl::IsTerrainAxisIgnoreObjects()
void CEditorImpl::SetReferenceCoordSys(RefCoordSys refCoords)
{
m_refCoordsSys = refCoords;
m_lastCoordSys[m_currEditMode] = m_refCoordsSys;
// Update all views.
UpdateViews(eUpdateObjects, NULL);
@@ -2041,60 +1827,6 @@ bool CEditorImpl::IsNewViewportInteractionModelEnabled() const
return m_isNewViewportInteractionModelEnabled;
}
void CEditorImpl::OnStartPlayInEditor()
{
if (SelectionContainsComponentEntities())
{
SetEditMode(eEditModeSelect);
}
}
namespace
{
const std::vector<std::pair<EEditMode, QString>> s_editModeNames = {
{ eEditModeSelect, QStringLiteral("Select") },
{ eEditModeSelectArea, QStringLiteral("SelectArea") },
{ eEditModeMove, QStringLiteral("Move") },
{ eEditModeRotate, QStringLiteral("Rotate") },
{ eEditModeScale, QStringLiteral("Scale") }
};
}
void CEditorImpl::LoadSettings()
{
QSettings settings(QStringLiteral("Amazon"), QStringLiteral("O3DE"));
settings.beginGroup(QStringLiteral("Editor"));
settings.beginGroup(QStringLiteral("CoordSys"));
for (const auto& editMode : s_editModeNames)
{
if (settings.contains(editMode.second))
{
m_lastCoordSys[editMode.first] = static_cast<RefCoordSys>(settings.value(editMode.second).toInt());
}
}
settings.endGroup(); // CoordSys
settings.endGroup(); // Editor
}
void CEditorImpl::SaveSettings() const
{
QSettings settings(QStringLiteral("Amazon"), QStringLiteral("O3DE"));
settings.beginGroup(QStringLiteral("Editor"));
settings.beginGroup(QStringLiteral("CoordSys"));
for (const auto& editMode : s_editModeNames)
{
settings.setValue(editMode.second, static_cast<int>(m_lastCoordSys[editMode.first]));
}
settings.endGroup(); // CoordSys
settings.endGroup(); // Editor
}
IEditorPanelUtils* CEditorImpl::GetEditorPanelUtils()
{
return m_panelEditorUtils;
+1 -28
View File
@@ -23,7 +23,6 @@
#include <memory> // for shared_ptr
#include <QMap>
#include <QApplication>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
#include <AzCore/std/string/string.h>
@@ -86,13 +85,12 @@ namespace AssetDatabase
class CEditorImpl
: public IEditor
, protected AzToolsFramework::EditorEntityContextNotificationBus::Handler
{
Q_DECLARE_TR_FUNCTIONS(CEditorImpl)
public:
CEditorImpl();
~CEditorImpl();
virtual ~CEditorImpl();
void Initialize();
void OnBeginShutdownSequence();
@@ -226,20 +224,6 @@ public:
void SetDataModified();
void SetOperationMode(EOperationMode mode);
EOperationMode GetOperationMode();
void SetEditMode(int editMode);
int GetEditMode();
//! A correct tool is one that corresponds to the previously set edit mode.
bool HasCorrectEditTool() const;
//! Returns the edit tool required for the edit mode specified.
CEditTool* CreateCorrectEditTool();
void SetEditTool(CEditTool* tool, bool bStopCurrentTool = true) override;
void SetEditTool(const QString& sEditToolName, bool bStopCurrentTool = true) override;
void ReinitializeEditTool() override;
//! Returns current edit tool.
CEditTool* GetEditTool() override;
ITransformManipulator* ShowTransformManipulator(bool bShow);
ITransformManipulator* GetTransformManipulator();
@@ -360,23 +344,15 @@ public:
protected:
//////////////////////////////////////////////////////////////////////////
// EditorEntityContextNotificationBus implementation
void OnStartPlayInEditor() override;
//////////////////////////////////////////////////////////////////////////
AZStd::string LoadProjectIdFromProjectData();
void DetectVersion();
void RegisterTools();
void SetPrimaryCDFolder();
void LoadSettings();
void SaveSettings() const;
//! List of all notify listeners.
std::list<IEditorNotifyListener*> m_listeners;
EEditMode m_currEditMode;
EOperationMode m_operationMode;
ISystem* m_pSystem;
IFileUtil* m_pFileUtil;
@@ -390,8 +366,6 @@ protected:
AABB m_selectedRegion;
AxisConstrains m_selectedAxis;
RefCoordSys m_refCoordsSys;
AxisConstrains m_lastAxis[16];
RefCoordSys m_lastCoordSys[16];
bool m_bAxisVectorLock;
bool m_bUpdates;
bool m_bTerrainAxisIgnoreObjects;
@@ -400,7 +374,6 @@ protected:
CXmlTemplateRegistry m_templateRegistry;
CDisplaySettings* m_pDisplaySettings;
CShaderEnum* m_pShaderEnum;
_smart_ptr<CEditTool> m_pEditTool;
CIconManager* m_pIconManager;
std::unique_ptr<SGizmoParameters> m_pGizmoParameters;
QString m_primaryCDFolder;
@@ -188,8 +188,6 @@ public:
virtual void SetSelection(const QString& name) = 0;
//! Removes one of named selections.
virtual void RemoveSelection(const QString& name) = 0;
//! Checks for changes to the current selection and makes adjustments accordingly
virtual void CheckAndFixSelection() = 0;
//! Delete all objects in current selection group.
virtual void DeleteSelection() = 0;
+13 -517
View File
@@ -25,12 +25,13 @@
#include "Objects/SelectionGroup.h"
#include "Include/IObjectManager.h"
#include "MathConversion.h"
#include "EditTool.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <ui_InfoBar.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <QLineEdit>
#include <AzQtComponents/Components/Style.h>
#include "CryPhysicsDeprecation.h"
@@ -53,12 +54,7 @@ CInfoBar::CInfoBar(QWidget* parent)
{
ui->setupUi(this);
m_enabledVector = false;
m_bVectorLock = false;
m_prevEditMode = 0;
m_bSelectionLocked = false;
m_bSelectionChanged = false;
m_editTool = 0;
m_bDragMode = false;
m_prevMoveSpeed = 0;
m_currValue = Vec3(-111, +222, -333); //this wasn't initialized. I don't know what a good value is
@@ -72,25 +68,14 @@ CInfoBar::CInfoBar(QWidget* parent)
OnInitDialog();
connect(ui->m_vectorLock, &QToolButton::clicked, this, &CInfoBar::OnVectorLock);
connect(ui->m_lockSelection, &QToolButton::clicked, this, &CInfoBar::OnLockSelection);
auto comboBoxTextChanged = static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentTextChanged);
connect(ui->m_moveSpeed, comboBoxTextChanged, this, &CInfoBar::OnUpdateMoveSpeedText);
connect(ui->m_moveSpeed->lineEdit(), &QLineEdit::returnPressed, this, &CInfoBar::OnSpeedComboBoxEnter);
connect(ui->m_posCtrl, &AzQtComponents::VectorInput::valueChanged, this, &CInfoBar::OnVectorChanged);
// Hide some buttons from the expander menu
AzQtComponents::Style::addClass(ui->m_posCtrl, "expanderMenu_hide");
AzQtComponents::Style::addClass(ui->m_physDoStepBtn, "expanderMenu_hide");
AzQtComponents::Style::addClass(ui->m_physSingleStepBtn, "expanderMenu_hide");
// posCtrl is a VectorInput initialized via UI; as such, we can't construct it to have only 3 elements.
// We can just hide the W element as it is unused.
ui->m_posCtrl->getElements()[3]->setVisible(false);
connect(ui->m_setVector, &QToolButton::clicked, this, &CInfoBar::OnBnClickedSetVector);
connect(ui->m_physicsBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedPhysics);
connect(ui->m_physSingleStepBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedSingleStepPhys);
connect(ui->m_physDoStepBtn, &QToolButton::clicked, this, &CInfoBar::OnBnClickedDoStepPhys);
@@ -101,12 +86,6 @@ CInfoBar::CInfoBar(QWidget* parent)
connect(this, &CInfoBar::ActionTriggered, MainWindow::instance()->GetActionManager(), &ActionManager::ActionTriggered);
connect(ui->m_lockSelection, &QAbstractButton::toggled, ui->m_lockSelection, [this](bool checked) {
ui->m_lockSelection->setToolTip(checked ? tr("Unlock Object Selection") : tr("Lock Object Selection"));
});
connect(ui->m_vectorLock, &QAbstractButton::toggled, ui->m_vectorLock, [this](bool checked) {
ui->m_vectorLock->setToolTip(checked ? tr("Unlock Axis Vectors") : tr("Lock Axis Vectors"));
});
connect(ui->m_physicsBtn, &QAbstractButton::toggled, ui->m_physicsBtn, [this](bool checked) {
ui->m_physicsBtn->setToolTip(checked ? tr("Stop Simulation (Ctrl+P)") : tr("Simulate (Ctrl+P)"));
});
@@ -123,27 +102,6 @@ CInfoBar::CInfoBar(QWidget* parent)
ui->m_vrBtn->setToolTip(checked ? tr("Disable VR Preview") : tr("Enable VR Preview"));
});
// hide old ui elements that are not valid with the new viewport interaction model
if (GetIEditor()->IsNewViewportInteractionModelEnabled())
{
ui->m_lockSelection->setVisible(false);
AzQtComponents::Style::addClass(ui->m_lockSelection, "expanderMenu_hide");
ui->m_posCtrl->setVisible(false);
AzQtComponents::Style::addClass(ui->m_posCtrl, "expanderMenu_hide");
ui->m_setVector->setVisible(false);
AzQtComponents::Style::addClass(ui->m_setVector, "expanderMenu_hide");
ui->m_vectorLock->setVisible(false);
AzQtComponents::Style::addClass(ui->m_vectorLock, "expanderMenu_hide");
// As we're hiding some of the icons, we have an extra spacer to deal with.
// We cannot set the visibility of separators, so we'll have to take it out.
int separatorIndex = layout()->indexOf(ui->verticalSpacer_2);
QLayoutItem* separator = layout()->takeAt(separatorIndex);
// takeAt() removes the item from the layout; delete to avoid memory leaks.
delete separator;
}
ui->m_moveSpeed->setValidator(new QDoubleValidator(m_minSpeed, m_maxSpeed, m_numDecimals, ui->m_moveSpeed));
// Save off the move speed here since setting up the combo box can cause it to update values in the background.
@@ -209,172 +167,6 @@ void CInfoBar::OnEditorNotifyEvent(EEditorNotifyEvent event)
{
m_bSelectionChanged = true;
}
else if (event == eNotify_OnEditModeChange)
{
int emode = GetIEditor()->GetEditMode();
switch (emode)
{
case eEditModeMove:
ui->m_setVector->setToolTip(tr("Set Position of Selected Objects"));
break;
case eEditModeRotate:
ui->m_setVector->setToolTip(tr("Set Rotation of Selected Objects"));
break;
case eEditModeScale:
ui->m_setVector->setToolTip(tr("Set Scale of Selected Objects"));
break;
default:
ui->m_setVector->setToolTip(tr("Set Position/Rotation/Scale of Selected Objects (None Selected)"));
break;
}
}
}
//////////////////////////////////////////////////////////////////////////
void CInfoBar::OnVectorChanged()
{
SetVector(GetVector());
OnVectorUpdate(false);
}
void CInfoBar::OnVectorUpdate(bool followTerrain)
{
int emode = GetIEditor()->GetEditMode();
if (emode != eEditModeMove && emode != eEditModeRotate && emode != eEditModeScale)
{
return;
}
Vec3 v = GetVector();
ITransformManipulator* pManipulator = GetIEditor()->GetTransformManipulator();
if (pManipulator)
{
CEditTool* pEditTool = GetIEditor()->GetEditTool();
if (pEditTool)
{
Vec3 diff = v - m_lastValue;
if (emode == eEditModeMove)
{
//GetIEditor()->RestoreUndo();
pEditTool->OnManipulatorDrag(GetIEditor()->GetActiveView(), pManipulator, diff);
}
if (emode == eEditModeRotate)
{
diff = DEG2RAD(diff);
//GetIEditor()->RestoreUndo();
pEditTool->OnManipulatorDrag(GetIEditor()->GetActiveView(), pManipulator, diff);
}
if (emode == eEditModeScale)
{
//GetIEditor()->RestoreUndo();
pEditTool->OnManipulatorDrag(GetIEditor()->GetActiveView(), pManipulator, diff);
}
}
return;
}
CSelectionGroup* selection = GetIEditor()->GetObjectManager()->GetSelection();
if (selection->IsEmpty())
{
return;
}
GetIEditor()->RestoreUndo();
int referenceCoordSys = GetIEditor()->GetReferenceCoordSys();
CBaseObject* obj = GetIEditor()->GetSelectedObject();
Matrix34 tm;
AffineParts ap;
if (obj)
{
tm = obj->GetWorldTM();
ap.SpectralDecompose(tm);
}
if (emode == eEditModeMove)
{
if (obj)
{
if (referenceCoordSys == COORDS_WORLD)
{
tm.SetTranslation(v);
obj->SetWorldTM(tm);
}
else
{
obj->SetPos(v);
}
}
else
{
GetIEditor()->GetSelection()->MoveTo(v, followTerrain ? CSelectionGroup::eMS_FollowTerrain : CSelectionGroup::eMS_None, referenceCoordSys);
}
}
if (emode == eEditModeRotate)
{
if (obj)
{
AZ::Vector3 av = LYVec3ToAZVec3(v);
AZ::Transform tr = AZ::ConvertEulerDegreesToTransform(av);
Matrix34 lyTransform = AZTransformToLYTransform(tr);
AffineParts newap;
newap.SpectralDecompose(lyTransform);
if (referenceCoordSys == COORDS_WORLD)
{
tm = Matrix34::Create(ap.scale, newap.rot, ap.pos);
obj->SetWorldTM(tm);
}
else
{
obj->SetRotation(newap.rot);
}
}
else
{
CBaseObject *refObj;
CSelectionGroup* pGroup = GetIEditor()->GetSelection();
if (pGroup && pGroup->GetCount() > 0)
{
refObj = pGroup->GetObject(0);
AffineParts ap2;
ap2.SpectralDecompose(refObj->GetWorldTM());
Vec3 oldEulerRotation = AZVec3ToLYVec3(AZ::ConvertQuaternionToEulerDegrees(LYQuaternionToAZQuaternion(ap2.rot)));
Vec3 diff = v - oldEulerRotation;
GetIEditor()->GetSelection()->Rotate((Ang3)diff, referenceCoordSys);
}
}
}
if (emode == eEditModeScale)
{
if (v.x == 0 || v.y == 0 || v.z == 0)
{
return;
}
if (obj)
{
if (referenceCoordSys == COORDS_WORLD)
{
tm = Matrix34::Create(v, ap.rot, ap.pos);
obj->SetWorldTM(tm);
}
else
{
obj->SetScale(v);
}
}
else
{
GetIEditor()->GetSelection()->SetScale(v, referenceCoordSys);
}
}
}
void CInfoBar::IdleUpdate()
@@ -399,21 +191,6 @@ void CInfoBar::IdleUpdate()
Vec3 marker = GetIEditor()->GetMarkerPosition();
/*
// Get active viewport.
int hx = marker.x / 2;
int hy = marker.y / 2;
if (m_heightMapX != hx || m_heightMapY != hy)
{
m_heightMapX = hx;
m_heightMapY = hy;
updateUI = true;
}
*/
RefCoordSys coordSys = GetIEditor()->GetReferenceCoordSys();
bool bWorldSpace = GetIEditor()->GetReferenceCoordSys() == COORDS_WORLD;
CSelectionGroup* selection = GetIEditor()->GetSelection();
if (selection->GetCount() != m_numSelected)
{
@@ -421,39 +198,22 @@ void CInfoBar::IdleUpdate()
updateUI = true;
}
if (GetIEditor()->GetEditTool() != m_editTool)
{
updateUI = true;
m_editTool = GetIEditor()->GetEditTool();
}
QString str;
if (m_editTool)
{
str = m_editTool->GetStatusText();
if (str != m_sLastText)
{
updateUI = true;
}
}
if (updateUI)
{
if (!m_editTool)
if (m_numSelected == 0)
{
if (m_numSelected == 0)
{
str = tr("None Selected");
}
else if (m_numSelected == 1)
{
str = tr("1 Object Selected");
}
else
{
str = tr("%1 Objects Selected").arg(m_numSelected);
}
str = tr("None Selected");
}
else if (m_numSelected == 1)
{
str = tr("1 Object Selected");
}
else
{
str = tr("%1 Objects Selected").arg(m_numSelected);
}
ui->m_statusText->setText(str);
m_sLastText = str;
}
@@ -488,198 +248,11 @@ void CInfoBar::IdleUpdate()
}
}
bool bSelLocked = GetIEditor()->IsSelectionLocked();
if (bSelLocked != m_bSelectionLocked)
{
m_bSelectionLocked = bSelLocked;
ui->m_lockSelection->setChecked(m_bSelectionLocked);
}
if (GetIEditor()->GetSelection()->IsEmpty())
{
if (ui->m_lockSelection->isEnabled())
{
ui->m_lockSelection->setEnabled(false);
}
}
else
{
if (!ui->m_lockSelection->isEnabled())
{
ui->m_lockSelection->setEnabled(true);
}
}
//////////////////////////////////////////////////////////////////////////
// Update vector.
//////////////////////////////////////////////////////////////////////////
Vec3 v(0, 0, 0);
bool enable = false;
float min = 0, max = 10000;
int emode = GetIEditor()->GetEditMode();
ITransformManipulator* pManipulator = GetIEditor()->GetTransformManipulator();
if (pManipulator)
{
AffineParts ap;
ap.SpectralDecompose(pManipulator->GetTransformation(coordSys));
if (emode == eEditModeMove)
{
v = ap.pos;
enable = true;
min = -64000;
max = 64000;
}
if (emode == eEditModeRotate)
{
v = Vec3(RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(ap.rot))));
enable = true;
min = -10000;
max = 10000;
}
if (emode == eEditModeScale)
{
v = ap.scale;
enable = true;
min = -10000;
max = 10000;
}
}
else
{
if (selection->IsEmpty())
{
// Show marker position.
EnableVector(false);
SetVector(marker);
SetVectorRange(-100000, 100000);
return;
}
CBaseObject* obj = GetIEditor()->GetSelectedObject();
if (!obj)
{
CSelectionGroup* pGroup = GetIEditor()->GetSelection();
if (pGroup && pGroup->GetCount() > 0)
{
obj = pGroup->GetObject(0);
}
}
if (obj)
{
v = obj->GetWorldPos();
}
if (emode == eEditModeMove)
{
if (obj)
{
if (bWorldSpace)
{
v = obj->GetWorldTM().GetTranslation();
}
else
{
v = obj->GetPos();
}
}
enable = true;
min = -64000;
max = 64000;
}
if (emode == eEditModeRotate)
{
if (obj)
{
Quat objRot;
if (bWorldSpace)
{
AffineParts ap;
ap.SpectralDecompose(obj->GetWorldTM());
objRot = ap.rot;
}
else
{
objRot = obj->GetRotation();
}
// Always convert objRot to v in order to ensure that the inspector and info bar are always in sync
v = AZVec3ToLYVec3(AZ::ConvertQuaternionToEulerDegrees(LYQuaternionToAZQuaternion(objRot)));
}
enable = true;
min = -10000;
max = 10000;
}
if (emode == eEditModeScale)
{
if (obj)
{
if (bWorldSpace)
{
AffineParts ap;
ap.SpectralDecompose(obj->GetWorldTM());
v = ap.scale;
}
else
{
v = obj->GetScale();
}
}
enable = true;
min = -10000;
max = 10000;
}
}
bool updateDisplayVector = (m_currValue != v);
// If Edit mode changed.
if (m_prevEditMode != emode)
{
// Scale mode enables vector lock.
SetVectorLock(emode == eEditModeScale);
// Change undo strings.
QString undoString("Modify Object(s)");
int mode = GetIEditor()->GetEditMode();
switch (mode)
{
case eEditModeMove:
undoString = QStringLiteral("Move Object(s)");
break;
case eEditModeRotate:
undoString = QStringLiteral("Rotate Object(s)");
break;
case eEditModeScale:
undoString = QStringLiteral("Scale Object(s)");
break;
}
// edit mode changed, we must update the number values
updateDisplayVector = true;
}
SetVectorRange(min, max);
EnableVector(enable);
// if our selection changed, or if our display values are out of date
if (m_bSelectionChanged)
{
updateDisplayVector = true;
m_bSelectionChanged = false;
}
if (updateDisplayVector)
{
SetVector(v);
}
m_prevEditMode = emode;
}
inline double Round(double fVal, double fStep)
@@ -691,71 +264,6 @@ inline double Round(double fVal, double fStep)
return fVal;
}
void CInfoBar::SetVector(const Vec3& v)
{
if (!m_bDragMode)
{
m_lastValue = m_currValue;
}
if (m_currValue != v)
{
ui->m_posCtrl->setValuebyIndex(v.x, 0);
ui->m_posCtrl->setValuebyIndex(v.y, 1);
ui->m_posCtrl->setValuebyIndex(v.z, 2);
m_currValue = v;
}
}
Vec3 CInfoBar::GetVector()
{
Vec3 v;
v.x = ui->m_posCtrl->getElements()[0]->getValue();
v.y = ui->m_posCtrl->getElements()[1]->getValue();
v.z = ui->m_posCtrl->getElements()[2]->getValue();
m_currValue = v;
return v;
}
void CInfoBar::EnableVector(bool enable)
{
if (m_enabledVector != enable)
{
m_enabledVector = enable;
ui->m_posCtrl->setEnabled(enable);
ui->m_vectorLock->setEnabled(enable);
ui->m_setVector->setEnabled(enable);
}
}
void CInfoBar::SetVectorLock(bool bVectorLock)
{
m_bVectorLock = bVectorLock;
ui->m_vectorLock->setChecked(bVectorLock);
GetIEditor()->SetAxisVectorLock(bVectorLock);
}
void CInfoBar::SetVectorRange(float min, float max)
{
// Worth noting that this gets called every IdleUpdate, so it is necessary to make sure
// setting the min/max doesn't result in the Qt event queue being pumped
ui->m_posCtrl->setMinimum(min);
ui->m_posCtrl->setMaximum(max);
}
void CInfoBar::OnVectorLock()
{
SetVectorLock(!m_bVectorLock);
}
void CInfoBar::OnLockSelection()
{
bool newLockSelectionValue = !m_bSelectionLocked;
m_bSelectionLocked = newLockSelectionValue;
ui->m_lockSelection->setChecked(newLockSelectionValue);
GetIEditor()->LockSelection(newLockSelectionValue);
}
void CInfoBar::OnUpdateMoveSpeedText(const QString& text)
{
gSettings.cameraMoveSpeed = aznumeric_cast<float>(Round(text.toDouble(), m_speedStep));
@@ -771,12 +279,6 @@ void CInfoBar::OnInitDialog()
QFontMetrics metrics({});
int width = metrics.boundingRect("-9999.99").width() * m_fieldWidthMultiplier;
ui->m_posCtrl->setEnabled(false);
ui->m_posCtrl->getElements()[0]->setFixedWidth(width);
ui->m_posCtrl->getElements()[1]->setFixedWidth(width);
ui->m_posCtrl->getElements()[2]->setFixedWidth(width);
ui->m_setVector->setEnabled(false);
ui->m_moveSpeed->setFixedWidth(width);
ui->m_physicsBtn->setEnabled(false);
@@ -850,12 +352,6 @@ void CInfoBar::OnBnClickedGotoPosition()
emit ActionTriggered(ID_DISPLAY_GOTOPOSITION);
}
//////////////////////////////////////////////////////////////////////////
void CInfoBar::OnBnClickedSetVector()
{
emit ActionTriggered(ID_DISPLAY_SETVECTOR);
}
//////////////////////////////////////////////////////////////////////////
void CInfoBar::OnBnClickedMuteAudio()
{
-21
View File
@@ -59,24 +59,9 @@ protected:
virtual void OnOK() {};
virtual void OnCancel() {};
void OnVectorUpdate(bool followTerrain);
// this gets called by stepper or text edit changes
void OnVectorChanged();
void SetVector(const Vec3& v);
void SetVectorRange(float min, float max);
Vec3 GetVector();
void EnableVector(bool enable);
void SetVectorLock(bool bVectorLock);
void OnBnClickedSyncplayer();
void OnBnClickedGotoPosition();
void OnVectorLock();
void OnLockSelection();
void OnBnClickedSetVector();
void OnSpeedComboBoxEnter();
void OnUpdateMoveSpeedText(const QString&);
void OnBnClickedTerrainCollision();
@@ -98,13 +83,10 @@ protected:
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
bool m_enabledVector;
float m_width, m_height;
//int m_heightMapX,m_heightMapY;
double m_fieldWidthMultiplier = 1.8;
int m_prevEditMode;
int m_numSelected;
float m_prevMoveSpeed;
@@ -117,14 +99,11 @@ protected:
// Speed presets
float m_speedPresetValues[3] = { 0.1f, 1.0f, 10.0f };
bool m_bVectorLock;
bool m_bSelectionLocked;
bool m_bSelectionChanged;
bool m_bDragMode;
QString m_sLastText;
CEditTool* m_editTool;
Vec3 m_lastValue;
Vec3 m_currValue;
float m_oldMainVolume;
-105
View File
@@ -57,42 +57,6 @@
</property>
</widget>
</item>
<item>
<widget class="AzQtComponents::VectorInput" name="m_posCtrl" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Position</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_setVector">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>XYZ</string>
</property>
<property name="icon">
<iconset resource="InfoBar.qrc">
<normaloff>:/InfoBar/XYZ-default.svg</normaloff>:/InfoBar/XYZ-default.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>18</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_gotoPos">
<property name="sizePolicy">
@@ -135,68 +99,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="m_lockSelection">
<property name="toolTip">
<string>Lock Object Selection</string>
</property>
<property name="text">
<string>Lock Selection</string>
</property>
<property name="icon">
<iconset resource="InfoBar.qrc">
<normaloff>:/InfoBar/LockSelection-default.svg</normaloff>:/InfoBar/LockSelection-default.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_vectorLock">
<property name="toolTip">
<string>Lock Scale Axis Vectors</string>
</property>
<property name="text">
<string>Lock Scale</string>
</property>
<property name="icon">
<iconset resource="InfoBar.qrc">
<normaloff>:/InfoBar/LockScale-default.svg</normaloff>:/InfoBar/LockScale-default.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
@@ -424,13 +326,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AzQtComponents::VectorInput</class>
<extends>QWidget</extends>
<header location="global">AzQtComponents/Components/Widgets/VectorInput.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="InfoBar.qrc"/>
</resources>
+1 -7
View File
@@ -20,7 +20,7 @@ class CEditorMock
: public IEditor
{
public:
// GMock does not work with a variadic function (https://github.com/google/googlemock/blob/master/googlemock/docs/FrequentlyAskedQuestions.md)
// GMock does not work with a variadic function
void ExecuteCommand(const char* sCommand, ...) override
{
va_list args;
@@ -123,12 +123,6 @@ public:
MOCK_METHOD0(GetRuler, CRuler* ());
MOCK_METHOD1(SetOperationMode, void(EOperationMode ));
MOCK_METHOD0(GetOperationMode, EOperationMode());
MOCK_METHOD1(SetEditMode, void(int ));
MOCK_METHOD0(GetEditMode, int());
MOCK_METHOD2(SetEditTool, void(CEditTool*, bool));
MOCK_METHOD2(SetEditTool, void(const QString&, bool));
MOCK_METHOD0(ReinitializeEditTool, void());
MOCK_METHOD0(GetEditTool, CEditTool* ());
MOCK_METHOD1(ShowTransformManipulator, ITransformManipulator* (bool));
MOCK_METHOD0(GetTransformManipulator, ITransformManipulator* ());
MOCK_METHOD1(SetAxisConstraints, void(AxisConstrains ));
@@ -151,9 +151,6 @@ namespace EditorPythonBindingsUnitTests
EXPECT_TRUE(behaviorContext->m_methods.find("get_axis_constraint") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("set_axis_constraint") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("get_edit_mode") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("set_edit_mode") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("get_pak_from_file") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("log") != behaviorContext->m_methods.end());
@@ -200,8 +197,6 @@ namespace EditorPythonBindingsUnitTests
EXPECT_TRUE(behaviorBus->m_events.find("OpenFileBox") != behaviorBus->m_events.end());
EXPECT_TRUE(behaviorBus->m_events.find("GetAxisConstraint") != behaviorBus->m_events.end());
EXPECT_TRUE(behaviorBus->m_events.find("SetAxisConstraint") != behaviorBus->m_events.end());
EXPECT_TRUE(behaviorBus->m_events.find("GetEditMode") != behaviorBus->m_events.end());
EXPECT_TRUE(behaviorBus->m_events.find("SetEditMode") != behaviorBus->m_events.end());
EXPECT_TRUE(behaviorBus->m_events.find("GetPakFromFile") != behaviorBus->m_events.end());
EXPECT_TRUE(behaviorBus->m_events.find("Log") != behaviorBus->m_events.end());
EXPECT_TRUE(behaviorBus->m_events.find("Undo") != behaviorBus->m_events.end());
@@ -1,92 +0,0 @@
/*
* 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.
*
*/
#include "EditorDefs.h"
#include <AzTest/AzTest.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <SetVectorDlg.h>
using namespace AZ;
using namespace ::testing;
namespace UnitTest
{
class TestSetVectorDlg
: public ::testing::Test
{
public:
};
const float SetVectorDlgNearTolerance = 0.0001f;
TEST_F(TestSetVectorDlg, GetVectorFromString_ThreeParams_Success)
{
QString testStr{ "1,2,3" };
Vec3 result{ 0, 0, 0 };
result = CSetVectorDlg::GetVectorFromString(testStr);
EXPECT_NEAR(result[0], 1.0f, SetVectorDlgNearTolerance);
EXPECT_NEAR(result[1], 2.0f, SetVectorDlgNearTolerance);
EXPECT_NEAR(result[2], 3.0f, SetVectorDlgNearTolerance);
}
TEST_F(TestSetVectorDlg, GetVectorFromString_FourParams_ThreeParsed)
{
QString testStr{ "1,2,3,4" };
Vec3 result{ 0, 0, 0 };
result = CSetVectorDlg::GetVectorFromString(testStr);
EXPECT_NEAR(result[0], 1.0f, SetVectorDlgNearTolerance);
EXPECT_NEAR(result[1], 2.0f, SetVectorDlgNearTolerance);
EXPECT_NEAR(result[2], 3.0f, SetVectorDlgNearTolerance);
}
TEST_F(TestSetVectorDlg, GetVectorFromString_TwoParams_ThirdZero)
{
QString testStr{ "1,2" };
Vec3 result{ 0, 0, 0 };
result = CSetVectorDlg::GetVectorFromString(testStr);
EXPECT_NEAR(result[0], 1.0f, SetVectorDlgNearTolerance);
EXPECT_NEAR(result[1], 2.0f, SetVectorDlgNearTolerance);
EXPECT_NEAR(result[2], 0.0f, SetVectorDlgNearTolerance);
}
TEST_F(TestSetVectorDlg, GetVectorFromString_NoParams_AllZero)
{
QString testStr;
Vec3 result{ 0, 0, 0 };
result = CSetVectorDlg::GetVectorFromString(testStr);
EXPECT_NEAR(result[0], 0.0f, SetVectorDlgNearTolerance);
EXPECT_NEAR(result[1], 0.0f, SetVectorDlgNearTolerance);
EXPECT_NEAR(result[2], 0.0f, SetVectorDlgNearTolerance);
}
TEST_F(TestSetVectorDlg, GetVectorFromString_BadStrings_AllZero)
{
QString testStr{ "some,illegal,strings" };
Vec3 resultExpected{ 0, 1, 0 };
auto result = CSetVectorDlg::GetVectorFromString(testStr);
EXPECT_NEAR(result[0], 0.0f, SetVectorDlgNearTolerance);
EXPECT_NEAR(result[1], 0.0f, SetVectorDlgNearTolerance);
EXPECT_NEAR(result[2], 0.0f, SetVectorDlgNearTolerance);
}
} // namespace UnitTest
-163
View File
@@ -60,7 +60,6 @@ AZ_POP_DISABLE_WARNING
// Editor
#include "Resource.h"
#include "EditTool.h"
#include "Core/LevelEditorMenuHandler.h"
#include "ShortcutDispatcher.h"
#include "LayoutWnd.h"
@@ -270,15 +269,6 @@ namespace
return QtViewPaneManager::instance()->IsVisible(viewClassName);
}
AZStd::string PyGetStatusText()
{
if (GetIEditor()->GetEditTool())
{
return AZStd::string(GetIEditor()->GetEditTool()->GetStatusText().toUtf8().data());
}
return AZStd::string("");
}
AZStd::vector<AZStd::string> PyGetViewPaneNames()
{
const QtViewPanes panes = QtViewPaneManager::instance()->GetRegisteredPanes();
@@ -693,7 +683,6 @@ void MainWindow::closeEvent(QCloseEvent* event)
}
// Close all edit panels.
GetIEditor()->ClearSelection();
GetIEditor()->SetEditTool(0);
GetIEditor()->GetObjectManager()->EndEditParams();
// force clean up of all deferred deletes, so that we don't have any issues with windows from plugins not being deleted yet
@@ -761,11 +750,6 @@ void MainWindow::InitActions()
am->AddAction(ID_TOOLBAR_SEPARATOR, QString());
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
{
am->AddAction(ID_TOOLBAR_WIDGET_REF_COORD, QString());
}
am->AddAction(ID_TOOLBAR_WIDGET_UNDO, QString());
am->AddAction(ID_TOOLBAR_WIDGET_REDO, QString());
am->AddAction(ID_TOOLBAR_WIDGET_SNAP_ANGLE, QString());
@@ -1006,18 +990,6 @@ void MainWindow::InitActions()
am->AddAction(ID_EDIT_RENAMEOBJECT, tr("Rename Object(s)..."))
.SetStatusTip(tr("Rename Object"));
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
{
am->AddAction(ID_EDITMODE_SELECT, tr("Select mode"))
.SetIcon(Style::icon("Select"))
.SetApplyHoverEffect()
.SetShortcut(tr("1"))
.SetToolTip(tr("Select mode (1)"))
.SetCheckable(true)
.SetStatusTip(tr("Select object(s)"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditmodeSelect);
}
am->AddAction(ID_EDITMODE_MOVE, tr("Move"))
.SetIcon(Style::icon("Move"))
.SetApplyHoverEffect()
@@ -1043,74 +1015,6 @@ void MainWindow::InitActions()
.SetStatusTip(tr("Select and scale selected object(s)"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditmodeScale);
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
{
am->AddAction(ID_EDITMODE_SELECTAREA, tr("Select terrain"))
.SetIcon(Style::icon("Select_terrain"))
.SetApplyHoverEffect()
.SetShortcut(tr("5"))
.SetToolTip(tr("Select terrain (5)"))
.SetCheckable(true)
.SetStatusTip(tr("Switch to terrain selection mode"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditmodeSelectarea);
am->AddAction(ID_SELECT_AXIS_X, tr("Constrain to X axis"))
.SetIcon(Style::icon("X_axis"))
.SetApplyHoverEffect()
.SetShortcut(tr("Ctrl+1"))
.SetToolTip(tr("Constrain to X axis (Ctrl+1)"))
.SetCheckable(true)
.SetStatusTip(tr("Lock movement on X axis"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisX);
am->AddAction(ID_SELECT_AXIS_Y, tr("Constrain to Y axis"))
.SetIcon(Style::icon("Y_axis"))
.SetApplyHoverEffect()
.SetShortcut(tr("Ctrl+2"))
.SetToolTip(tr("Constrain to Y axis (Ctrl+2)"))
.SetCheckable(true)
.SetStatusTip(tr("Lock movement on Y axis"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisY);
am->AddAction(ID_SELECT_AXIS_Z, tr("Constrain to Z axis"))
.SetIcon(Style::icon("Z_axis"))
.SetApplyHoverEffect()
.SetShortcut(tr("Ctrl+3"))
.SetToolTip(tr("Constrain to Z axis (Ctrl+3)"))
.SetCheckable(true)
.SetStatusTip(tr("Lock movement on Z axis"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisZ);
am->AddAction(ID_SELECT_AXIS_XY, tr("Constrain to XY plane"))
.SetIcon(Style::icon("XY2_copy"))
.SetApplyHoverEffect()
.SetShortcut(tr("Ctrl+4"))
.SetToolTip(tr("Constrain to XY plane (Ctrl+4)"))
.SetCheckable(true)
.SetStatusTip(tr("Lock movement on XY plane"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisXy);
am->AddAction(ID_SELECT_AXIS_TERRAIN, tr("Constrain to terrain/geometry"))
.SetIcon(Style::icon("Object_follow_terrain"))
.SetApplyHoverEffect()
.SetShortcut(tr("Ctrl+5"))
.SetToolTip(tr("Constrain to terrain/geometry (Ctrl+5)"))
.SetCheckable(true)
.SetStatusTip(tr("Lock object movement to follow terrain"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisTerrain);
am->AddAction(ID_SELECT_AXIS_SNAPTOALL, tr("Follow terrain and snap to objects"))
.SetIcon(Style::icon("Follow_terrain"))
.SetApplyHoverEffect()
.SetShortcut(tr("Ctrl+6"))
.SetToolTip(tr("Follow terrain and snap to objects (Ctrl+6)"))
.SetCheckable(true)
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelectAxisSnapToAll);
am->AddAction(ID_OBJECTMODIFY_ALIGNTOGRID, tr("Align to grid"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelected)
.SetIcon(Style::icon("Align_to_grid"))
.SetApplyHoverEffect();
am->AddAction(ID_MODIFY_ALIGNOBJTOSURF, tr("Align object to surface (Hold CTRL)")).SetCheckable(true)
.SetToolTip(tr("Align object to surface (Hold CTRL)"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateAlignToVoxel)
.SetIcon(Style::icon("Align_object_to_surface"))
.SetApplyHoverEffect();
}
am->AddAction(ID_SNAP_TO_GRID, tr("Snap to grid"))
.SetIcon(Style::icon("Grid"))
.SetApplyHoverEffect()
@@ -1169,7 +1073,6 @@ void MainWindow::InitActions()
am->AddAction(ID_CHANGEMOVESPEED_CHANGESTEP, tr("Change Step"))
.SetStatusTip(tr("Change Flycam Movement Step"));
am->AddAction(ID_DISPLAY_GOTOPOSITION, tr("Go to Position..."));
am->AddAction(ID_DISPLAY_SETVECTOR, tr("Display Set Vector"));
am->AddAction(ID_MODIFY_GOTO_SELECTION, tr("Center on Selection"))
.SetShortcut(tr("Z"))
.SetToolTip(tr("Center on Selection (Z)"))
@@ -1459,10 +1362,6 @@ void MainWindow::InitActions()
.SetIcon(QIcon(":/MainWindow/toolbars/object_toolbar-03.svg"))
.SetApplyHoverEffect()
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelected);
// vertex snapping not yet supported when the new Viewport Interaction Model is enabled
am->AddAction(ID_OBJECTMODIFY_VERTEXSNAPPING, tr("Vertex snapping"))
.SetIcon(Style::icon("Vertex_snapping"))
.SetApplyHoverEffect();
}
// Misc Toolbar Actions
@@ -1510,8 +1409,6 @@ void MainWindow::OnEscapeAction()
{
AzToolsFramework::EditorEvents::Bus::Broadcast(
&AzToolsFramework::EditorEvents::OnEscape);
CCryEditApp::instance()->OnEditEscape();
}
}
}
@@ -1522,62 +1419,6 @@ void MainWindow::InitToolBars()
AdjustToolBarIconSize(static_cast<AzQtComponents::ToolBar::ToolBarIconSize>(gSettings.gui.nToolbarIconSize));
}
QComboBox* MainWindow::CreateRefCoordComboBox()
{
// ID_REF_COORDS_SYS;
auto coordSysCombo = new RefCoordComboBox(this);
connect(this, &MainWindow::ToggleRefCoordSys, coordSysCombo, &RefCoordComboBox::ToggleRefCoordSys);
connect(this, &MainWindow::UpdateRefCoordSys, coordSysCombo, &RefCoordComboBox::UpdateRefCoordSys);
return coordSysCombo;
}
RefCoordComboBox::RefCoordComboBox(QWidget* parent)
: QComboBox(parent)
{
addItems(coordSysList());
setCurrentIndex(0);
connect(this, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [](int index)
{
if (index >= 0 && index < LAST_COORD_SYSTEM)
{
RefCoordSys coordSys = (RefCoordSys)index;
if (GetIEditor()->GetReferenceCoordSys() != index)
{
GetIEditor()->SetReferenceCoordSys(coordSys);
}
}
});
UpdateRefCoordSys();
}
QStringList RefCoordComboBox::coordSysList() const
{
static QStringList list = { tr("View"), tr("Local"), tr("Parent"), tr("World"), tr("Custom") };
return list;
}
void RefCoordComboBox::UpdateRefCoordSys()
{
RefCoordSys coordSys = GetIEditor()->GetReferenceCoordSys();
if (coordSys >= 0 && coordSys < LAST_COORD_SYSTEM)
{
setCurrentIndex(coordSys);
}
}
void RefCoordComboBox::ToggleRefCoordSys()
{
QStringList coordSys = coordSysList();
const int localIndex = coordSys.indexOf(tr("Local"));
const int worldIndex = coordSys.indexOf(tr("World"));
const int newIndex = currentIndex() == localIndex ? worldIndex : localIndex;
setCurrentIndex(newIndex);
}
QToolButton* MainWindow::CreateUndoRedoButton(int command)
{
// We do either undo or redo below, sort that out here
@@ -2542,9 +2383,6 @@ QWidget* MainWindow::CreateToolbarWidget(int actionId)
case ID_TOOLBAR_WIDGET_REDO:
w = CreateUndoRedoButton(ID_REDO);
break;
case ID_TOOLBAR_WIDGET_REF_COORD:
w = CreateRefCoordComboBox();
break;
case ID_TOOLBAR_WIDGET_SNAP_GRID:
w = CreateSnapToGridWidget();
break;
@@ -2640,7 +2478,6 @@ namespace AzToolsFramework
addLegacyGeneral(behaviorContext->Method("exit", PyExit, nullptr, "Exits the editor."));
addLegacyGeneral(behaviorContext->Method("exit_no_prompt", PyExitNoPrompt, nullptr, "Exits the editor without prompting to save first."));
addLegacyGeneral(behaviorContext->Method("report_test_result", PyReportTest, nullptr, "Report test information."));
addLegacyGeneral(behaviorContext->Method("get_status_text", PyGetStatusText, nullptr, "Gets the status text from the Editor's current edit tool"));
}
}
}
-15
View File
@@ -77,19 +77,6 @@ namespace AzToolsFramework
// Subclassing so we can add slots to our toolbar widgets
// Using lambdas is crashy since the lamdba doesn't know when the widget is deleted.
class RefCoordComboBox
: public QComboBox
{
Q_OBJECT
public:
explicit RefCoordComboBox(QWidget* parent);
public Q_SLOTS:
void ToggleRefCoordSys();
void UpdateRefCoordSys();
private:
QStringList coordSysList() const;
};
class UndoRedoToolButton
: public QToolButton
{
@@ -229,8 +216,6 @@ private:
QWidget* CreateSnapToGridWidget();
QWidget* CreateSnapToAngleWidget();
QComboBox* CreateRefCoordComboBox();
QToolButton* CreateUndoRedoButton(int command);
QToolButton* CreateEnvironmentModeButton();
@@ -1,170 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "MaterialPickTool.h"
// Editor
#include "MaterialManager.h"
#include "SurfaceInfoPicker.h"
#include "Viewport.h"
#define RENDER_MESH_TEST_DISTANCE 0.2f
static IClassDesc * s_ToolClass = NULL;
//////////////////////////////////////////////////////////////////////////
CMaterialPickTool::CMaterialPickTool()
{
m_pClassDesc = s_ToolClass;
m_statusText = tr("Left Click To Pick Material");
}
//////////////////////////////////////////////////////////////////////////
CMaterialPickTool::~CMaterialPickTool()
{
SetMaterial(0);
}
//////////////////////////////////////////////////////////////////////////
bool CMaterialPickTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
{
if (event == eMouseLDown)
{
if (m_pMaterial)
{
CMaterial* pMtl = GetIEditor()->GetMaterialManager()->FromIMaterial(m_pMaterial);
if (pMtl)
{
GetIEditor()->GetMaterialManager()->SetHighlightedMaterial(0);
GetIEditor()->OpenMaterialLibrary(pMtl);
Abort();
return true;
}
}
}
else if (event == eMouseMove)
{
return OnMouseMove(view, flags, point);
}
return true;
}
//////////////////////////////////////////////////////////////////////////
void CMaterialPickTool::Display(DisplayContext& dc)
{
QPoint mousePoint = QCursor::pos();
dc.view->ScreenToClient(mousePoint);
Vec3 wp = dc.view->ViewToWorld(mousePoint);
if (m_pMaterial)
{
float color[4] = {1, 1, 1, 1};
dc.renderer->Draw2dLabel(mousePoint.x() + 12, mousePoint.y ()+ 8, 1.2f, color, false, "%s", m_displayString.toUtf8().data());
}
float fScreenScale = dc.view->GetScreenScaleFactor(m_HitInfo.vHitPos) * 0.06f;
dc.DepthTestOff();
dc.SetColor(ColorB(0, 0, 255, 255));
if (!m_HitInfo.vHitNormal.IsZero())
{
dc.DrawLine(m_HitInfo.vHitPos, m_HitInfo.vHitPos + m_HitInfo.vHitNormal * fScreenScale);
Vec3 raySrc, rayDir;
dc.view->ViewToWorldRay(mousePoint, raySrc, rayDir);
Matrix34 tm;
Vec3 zAxis = m_HitInfo.vHitNormal;
Vec3 xAxis = rayDir.Cross(zAxis);
if (!xAxis.IsZero())
{
xAxis.Normalize();
Vec3 yAxis = xAxis.Cross(zAxis).GetNormalized();
tm.SetFromVectors(xAxis, yAxis, zAxis, m_HitInfo.vHitPos);
dc.PushMatrix(tm);
dc.DrawCircle(Vec3(0, 0, 0), 0.5f * fScreenScale);
dc.PopMatrix();
}
}
dc.DepthTestOn();
}
//////////////////////////////////////////////////////////////////////////
bool CMaterialPickTool::OnMouseMove(CViewport* view, [[maybe_unused]] UINT nFlags, const QPoint& point)
{
view->SetCurrentCursor(STD_CURSOR_HIT, "");
_smart_ptr<IMaterial> pNearestMaterial(NULL);
m_Mouse2DPosition = point;
CSurfaceInfoPicker surfacePicker;
int nPickObjectGroupFlag = CSurfaceInfoPicker::ePOG_All;
if (surfacePicker.Pick(point, pNearestMaterial, m_HitInfo, NULL, nPickObjectGroupFlag))
{
SetMaterial(pNearestMaterial);
return true;
}
SetMaterial(0);
return false;
}
const GUID& CMaterialPickTool::GetClassID()
{
// {FD20F6F2-7B87-4349-A5D4-7533538E357F}
static const GUID guid = {
0xfd20f6f2, 0x7b87, 0x4349, { 0xa5, 0xd4, 0x75, 0x33, 0x53, 0x8e, 0x35, 0x7f }
};
return guid;
}
//////////////////////////////////////////////////////////////////////////
void CMaterialPickTool::RegisterTool(CRegistrationContext& rc)
{
rc.pClassFactory->RegisterClass(s_ToolClass = new CQtViewClass<CMaterialPickTool>("EditTool.PickMaterial", "Material", ESYSTEM_CLASS_EDITTOOL));
}
//////////////////////////////////////////////////////////////////////////
void CMaterialPickTool::SetMaterial(_smart_ptr<IMaterial> pMaterial)
{
if (pMaterial == m_pMaterial)
{
return;
}
m_pMaterial = pMaterial;
CMaterial* pCMaterial = GetIEditor()->GetMaterialManager()->FromIMaterial(m_pMaterial);
GetIEditor()->GetMaterialManager()->SetHighlightedMaterial(pCMaterial);
m_displayString = "";
if (pMaterial)
{
QString sfType;
sfType = QStringLiteral("%1 : %2").arg(pMaterial->GetSurfaceType()->GetId()).arg(pMaterial->GetSurfaceType()->GetName());
m_displayString = "\n";
m_displayString += pMaterial->GetName();
m_displayString += "\n";
m_displayString += sfType;
}
}
#include <Material/moc_MaterialPickTool.cpp>
@@ -1,57 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Definition of PickObjectTool, tool used to pick objects.
#ifndef CRYINCLUDE_EDITOR_MATERIAL_MATERIALPICKTOOL_H
#define CRYINCLUDE_EDITOR_MATERIAL_MATERIALPICKTOOL_H
#pragma once
#include "EditTool.h"
//////////////////////////////////////////////////////////////////////////
class CMaterialPickTool
: public CEditTool
{
Q_OBJECT
public:
Q_INVOKABLE CMaterialPickTool();
static const GUID& GetClassID();
static void RegisterTool(CRegistrationContext& rc);
//////////////////////////////////////////////////////////////////////////
// CEditTool implementation
//////////////////////////////////////////////////////////////////////////
virtual bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
virtual void Display(DisplayContext& dc);
//////////////////////////////////////////////////////////////////////////
protected:
bool OnMouseMove(CViewport* view, UINT nFlags, const QPoint& point);
void SetMaterial(_smart_ptr<IMaterial> pMaterial);
virtual ~CMaterialPickTool();
// Delete itself.
void DeleteThis() { delete this; };
_smart_ptr<IMaterial> m_pMaterial;
QString m_displayString;
QPoint m_Mouse2DPosition;
SRayHitInfo m_HitInfo;
};
#endif // CRYINCLUDE_EDITOR_MATERIAL_MATERIALPICKTOOL_H
-37
View File
@@ -1,37 +0,0 @@
/*
* 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.
*
*/
#include "EditorDefs.h"
#include "NullEditTool.h"
NullEditTool::NullEditTool() {}
const GUID& NullEditTool::GetClassID()
{
// {65AFF87A-34E0-479B-B062-94B1B867B13D}
static const GUID guid =
{
0x65AFF87A, 0x34E0, 0x479B,{ 0xB0, 0x62, 0x94, 0xB1, 0xB8, 0x67, 0xB1, 0x3D }
};
return guid;
}
void NullEditTool::RegisterTool(CRegistrationContext& rc)
{
rc.pClassFactory->RegisterClass(
new CQtViewClass<NullEditTool>("EditTool.NullEditTool", "Select", ESYSTEM_CLASS_EDITTOOL));
}
#include <moc_NullEditTool.cpp>
-39
View File
@@ -1,39 +0,0 @@
/*
* 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.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include "EditTool.h"
#endif
/// An EditTool that does nothing - it provides the Null-Object pattern.
class SANDBOX_API NullEditTool
: public CEditTool
{
Q_OBJECT
public:
Q_INVOKABLE NullEditTool();
virtual ~NullEditTool() = default;
static const GUID& GetClassID();
static void RegisterTool(CRegistrationContext& rc);
// CEditTool
void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) override {}
void EndEditParams() override {}
void Display([[maybe_unused]] DisplayContext& dc) override {}
bool MouseCallback([[maybe_unused]] CViewport* view, [[maybe_unused]] EMouseEvent event, [[maybe_unused]] QPoint& point, [[maybe_unused]] int flags) override { return false; }
bool OnKeyDown([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) override { return false; }
bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) override { return true; }
void DeleteThis() override { delete this; }
};
-336
View File
@@ -1,336 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "EditorDefs.h"
#include "ObjectCloneTool.h"
// Editor
#include "MainWindow.h"
#include "Viewport.h"
#include "ViewManager.h"
#include "Include/IObjectManager.h"
#include "Objects/SelectionGroup.h"
#include "Settings.h"
//////////////////////////////////////////////////////////////////////////
// Class description.
//////////////////////////////////////////////////////////////////////////
class CObjectCloneTool_ClassDesc
: public CRefCountClassDesc
{
virtual ESystemClassID SystemClassID() { return ESYSTEM_CLASS_EDITTOOL; }
virtual REFGUID ClassID()
{
// {6A73E865-71DF-4ED0-ABA2-457E66119B35}
static const GUID guid = {
0x6a73e865, 0x71df, 0x4ed0,{ 0xab, 0xa2, 0x45, 0x7e, 0x66, 0x11, 0x9b, 0x35 }
};
return guid;
}
virtual QString ClassName() { return "EditTool.Clone"; };
virtual QString Category() { return "EditTool"; };
};
CObjectCloneTool_ClassDesc g_cloneClassDesc;
//////////////////////////////////////////////////////////////////////////
CObjectCloneTool::CObjectCloneTool()
: m_currentUndoBatch(nullptr)
{
m_pClassDesc = &g_cloneClassDesc;
m_bSetConstrPlane = true;
GetIEditor()->SuperBeginUndo();
GetIEditor()->BeginUndo();
m_selection = nullptr;
if (!GetIEditor()->GetSelection()->IsEmpty())
{
QWaitCursor wait;
CloneSelection();
m_selection = GetIEditor()->GetSelection();
m_origin = m_selection->GetCenter();
}
GetIEditor()->AcceptUndo("Clone");
GetIEditor()->BeginUndo();
if (!gSettings.deepSelectionSettings.bStickDuplicate)
{
SetStatusText("Clone object at the same location");
}
else
{
SetStatusText("Left click to clone object");
}
}
//////////////////////////////////////////////////////////////////////////
CObjectCloneTool::~CObjectCloneTool()
{
EndUndoBatch();
if (GetIEditor()->IsUndoRecording())
{
GetIEditor()->SuperCancelUndo();
}
}
//////////////////////////////////////////////////////////////////////////
void CObjectCloneTool::CloneSelection()
{
// Allow component application to intercept cloning behavior.
// This is to allow support for "smart" cloning of prefabs, and other contextual features.
AZ_Assert(!m_currentUndoBatch, "CloneSelection undo batch already created.");
EBUS_EVENT_RESULT(m_currentUndoBatch, AzToolsFramework::ToolsApplicationRequests::Bus, BeginUndoBatch, "Clone Selection");
bool handled = false;
EBUS_EVENT(AzToolsFramework::EditorRequests::Bus, CloneSelection, handled);
if (handled)
{
GetIEditor()->GetObjectManager()->CheckAndFixSelection();
return;
}
// This is the legacy case. We're not cloning AZ entities, so abandon the AZ undo batch.
EndUndoBatch();
CSelectionGroup selObjects;
CSelectionGroup sel;
CSelectionGroup* currSelection = GetIEditor()->GetSelection();
currSelection->Clone(selObjects);
GetIEditor()->ClearSelection();
for (int i = 0; i < selObjects.GetCount(); i++)
{
if (selObjects.GetObject(i))
{
GetIEditor()->SelectObject(selObjects.GetObject(i));
}
}
MainWindow::instance()->setFocus();
}
//////////////////////////////////////////////////////////////////////////
void CObjectCloneTool::SetConstrPlane(CViewport* view, [[maybe_unused]] const QPoint& point)
{
Matrix34 originTM;
originTM.SetIdentity();
CSelectionGroup* selection = GetIEditor()->GetSelection();
if (selection->GetCount() == 1)
{
originTM = selection->GetObject(0)->GetWorldTM();
}
else if (selection->GetCount() > 1)
{
originTM = selection->GetObject(0)->GetWorldTM();
Vec3 center = view->SnapToGrid(originTM.GetTranslation());
originTM.SetTranslation(center);
}
view->SetConstructionMatrix(COORDS_LOCAL, originTM);
}
//static Vec3 gP1,gP2;
//////////////////////////////////////////////////////////////////////////
void CObjectCloneTool::Display([[maybe_unused]] DisplayContext& dc)
{
//dc.SetColor( 1,1,0,1 );
//dc.DrawBall( gP1,1.1f );
//dc.DrawBall( gP2,1.1f );
}
//////////////////////////////////////////////////////////////////////////
bool CObjectCloneTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
{
if (m_selection)
{
// Set construction plane origin to selection origin.
if (m_bSetConstrPlane)
{
SetConstrPlane(view, point);
m_bSetConstrPlane = false;
}
if (event == eMouseLDown)
{
// Accept group.
Accept();
GetIEditor()->GetSelection()->FinishChanges();
return true;
}
if (event == eMouseMove)
{
// Move selection.
CSelectionGroup* selection = GetIEditor()->GetSelection();
if (selection != m_selection)
{
Abort();
}
else if (!selection->IsEmpty())
{
GetIEditor()->RestoreUndo();
Vec3 v;
bool followTerrain = false;
CSelectionGroup* pSelection = GetIEditor()->GetSelection();
Vec3 selectionCenter = view->SnapToGrid(pSelection->GetCenter());
int axis = GetIEditor()->GetAxisConstrains();
if (axis == AXIS_TERRAIN)
{
bool hitTerrain;
v = view->ViewToWorld(point, &hitTerrain) - selectionCenter;
if (axis == AXIS_TERRAIN)
{
v = view->SnapToGrid(v);
if (hitTerrain)
{
followTerrain = true;
v.z = 0;
}
}
}
else
{
Vec3 p1 = selectionCenter;
Vec3 p2 = view->MapViewToCP(point);
if (p2.IsZero())
{
return true;
}
v = view->GetCPVector(p1, p2);
// Snap v offset to grid if its enabled.
view->SnapToGrid(v);
}
CSelectionGroup::EMoveSelectionFlag selectionFlag = CSelectionGroup::eMS_None;
if (followTerrain)
{
selectionFlag = CSelectionGroup::eMS_FollowTerrain;
}
// Disable undo recording for these move commands as the only operation we need
// to undo is the creation of the new object. Undo commands are queued so it's
// possible that the object creation could be undone before attempting to undo
// these move operations causing undesired behavior.
bool wasRecording = CUndo::IsRecording();
if (wasRecording)
{
GetIEditor()->SuspendUndo();
}
GetIEditor()->GetSelection()->Move(v, selectionFlag, GetIEditor()->GetReferenceCoordSys(), point);
if (wasRecording)
{
GetIEditor()->ResumeUndo();
}
}
}
if (event == eMouseWheel)
{
CSelectionGroup* selection = GetIEditor()->GetSelection();
if (selection != m_selection)
{
Abort();
}
else if (!selection->IsEmpty())
{
double angle = 1;
if (view->GetViewManager()->GetGrid()->IsAngleSnapEnabled())
{
angle = view->GetViewManager()->GetGrid()->GetAngleSnap();
}
for (int i = 0; i < selection->GetCount(); ++i)
{
CBaseObject* pObj = selection->GetFilteredObject(i);
Quat rot = pObj->GetRotation();
rot.SetRotationXYZ(Ang3(0, 0, rot.GetRotZ() + DEG2RAD(flags > 0 ? angle * (-1) : angle)));
pObj->SetRotation(rot);
}
GetIEditor()->AcceptUndo("Rotate Selection");
}
}
}
return true;
}
//////////////////////////////////////////////////////////////////////////
void CObjectCloneTool::Abort()
{
EndUndoBatch();
// Abort
GetIEditor()->SetEditTool(0);
}
//////////////////////////////////////////////////////////////////////////
void CObjectCloneTool::Accept(bool resetPosition)
{
// Close the az undo batch so it can add the appropriate objects to the cry undo stack
EndUndoBatch();
if (resetPosition)
{
GetIEditor()->GetSelection()->MoveTo(m_origin, CSelectionGroup::eMS_None, GetIEditor()->GetReferenceCoordSys());
}
if (GetIEditor()->IsUndoRecording())
{
GetIEditor()->SuperAcceptUndo("Clone");
}
GetIEditor()->SetEditTool(0);
}
//////////////////////////////////////////////////////////////////////////
void CObjectCloneTool::EndUndoBatch()
{
if (m_currentUndoBatch)
{
AzToolsFramework::UndoSystem::URSequencePoint* undoBatch = nullptr;
EBUS_EVENT_RESULT(undoBatch, AzToolsFramework::ToolsApplicationRequests::Bus, GetCurrentUndoBatch);
AZ_Error("ObjectCloneTool", undoBatch == m_currentUndoBatch, "Undo batch is not in sync.");
if (undoBatch == m_currentUndoBatch)
{
EBUS_EVENT(AzToolsFramework::ToolsApplicationRequests::Bus, EndUndoBatch);
}
m_currentUndoBatch = nullptr;
}
}
//////////////////////////////////////////////////////////////////////////
void CObjectCloneTool::BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags)
{
}
//////////////////////////////////////////////////////////////////////////
void CObjectCloneTool::EndEditParams()
{
}
//////////////////////////////////////////////////////////////////////////
bool CObjectCloneTool::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags)
{
if (nChar == VK_ESCAPE)
{
Abort();
}
return false;
}
#include <moc_ObjectCloneTool.cpp>
-81
View File
@@ -1,81 +0,0 @@
/*
* 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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Definition of ObjectCloneTool, edit tool for cloning of objects..
#ifndef CRYINCLUDE_EDITOR_OBJECTCLONETOOL_H
#define CRYINCLUDE_EDITOR_OBJECTCLONETOOL_H
#pragma once
#include "EditTool.h"
class CBaseObject;
namespace AzToolsFramework
{
namespace UndoSystem
{
class URSequencePoint;
}
}
/*!
* CObjectCloneTool, When created duplicate current selection, and manages cloned selection.
*
*/
class CObjectCloneTool
: public CEditTool
{
Q_OBJECT
public:
Q_INVOKABLE CObjectCloneTool();
//////////////////////////////////////////////////////////////////////////
// Ovverides from CEditTool
bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
virtual void BeginEditParams(IEditor* ie, int flags);
virtual void EndEditParams();
virtual void Display(DisplayContext& dc);
virtual bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags);
virtual bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; };
//////////////////////////////////////////////////////////////////////////
void Accept(bool resetPosition = false);
void Abort();
protected:
virtual ~CObjectCloneTool();
// Delete itself.
void DeleteThis() { delete this; };
private:
void CloneSelection();
void SetConstrPlane(CViewport* view, const QPoint& point);
CSelectionGroup* m_selection;
Vec3 m_origin;
bool m_bSetConstrPlane;
//bool m_bSetCapture;
void EndUndoBatch();
AzToolsFramework::UndoSystem::URSequencePoint* m_currentUndoBatch;
};
#endif // CRYINCLUDE_EDITOR_OBJECTCLONETOOL_H
+1 -233
View File
@@ -24,7 +24,6 @@
#include "RenderHelpers/AxisHelper.h"
#include "RenderHelpers/AxisHelperExtended.h"
#include "IObjectManager.h"
#include "EditTool.h"
//////////////////////////////////////////////////////////////////////////
// CAxisGizmo implementation.
@@ -138,36 +137,6 @@ void CAxisGizmo::GetWorldBounds(AABB& bbox)
void CAxisGizmo::DrawAxis(DisplayContext& dc)
{
m_pAxisHelper->SetHighlightAxis(m_highlightAxis);
// Only enable axis planes when editor is in Move mode.
int nEditMode = GetIEditor()->GetEditMode();
int nModeFlags = 0;
switch (nEditMode)
{
case eEditModeMove:
nModeFlags |= CAxisHelper::MOVE_MODE;
break;
case eEditModeRotate:
nModeFlags |= CAxisHelper::ROTATE_MODE;
nModeFlags &= ~(CAxisHelper::ROTATE_CIRCLE_MODE);
break;
case eEditModeRotateCircle:
nModeFlags |= CAxisHelper::ROTATE_CIRCLE_MODE;
nModeFlags &= ~(CAxisHelper::ROTATE_MODE);
break;
case eEditModeScale:
nModeFlags |= CAxisHelper::SCALE_MODE;
break;
case eEditModeSelect:
nModeFlags |= CAxisHelper::SELECT_MODE;
break;
case eEditModeSelectArea:
nModeFlags |= CAxisHelper::SELECT_MODE;
break;
}
//nModeFlags |= CAxisHelper::MOVE_MODE | CAxisHelper::ROTATE_MODE | CAxisHelper::SCALE_MODE;
m_pAxisHelper->SetMode(nModeFlags);
Matrix34 tm = GetTransformation(m_bAlwaysUseLocal ? COORDS_LOCAL : GetIEditor()->GetReferenceCoordSys(), dc.view);
m_pAxisHelper->DrawAxis(tm, GetIEditor()->GetGlobalGizmoParameters(), dc);
@@ -178,21 +147,6 @@ void CAxisGizmo::DrawAxis(DisplayContext& dc)
m_pAxisHelper->DrawDome(tm, GetIEditor()->GetGlobalGizmoParameters(), dc, objectBox);
}
//////////////////////////////////////////////////////////////////////////
// Draw extended infinite-axis gizmo
//////////////////////////////////////////////////////////////////////////
if (!(dc.flags & DISPLAY_2D) &&
(nModeFlags == CAxisHelper::MOVE_MODE ||
nModeFlags == CAxisHelper::ROTATE_MODE))
{
bool bClickedShift = CheckVirtualKey(Qt::Key_Shift);
if (bClickedShift && (m_axisGizmoCount == 1 || m_highlightAxis || (m_axisGizmoCount == 2 && m_object && m_object->IsSkipSelectionHelper())))
{
bool bClickedAlt = CheckVirtualKey(Qt::Key_Menu);
bool bUsePhysicalProxy = !bClickedAlt;
m_pAxisHelperExtended->DrawAxes(dc, tm, bUsePhysicalProxy);
}
}
}
//////////////////////////////////////////////////////////////////////////
@@ -325,7 +279,7 @@ Matrix34 CAxisGizmo::GetTransformation(RefCoordSys coordSys, IDisplayViewport* v
}
//////////////////////////////////////////////////////////////////////////
bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int nFlags)
bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, [[maybe_unused]] int nFlags)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor);
@@ -365,28 +319,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point
m_cMouseDownPos = point;
m_initPos = GetTransformation(COORDS_WORLD).GetTranslation();
switch (hc.manipulatorMode)
{
case 1:
view->SetCurrentCursor(STD_CURSOR_MOVE);
GetIEditor()->SetEditMode(eEditModeMove);
break;
case 2:
view->SetCurrentCursor(STD_CURSOR_ROTATE);
GetIEditor()->SetEditMode(eEditModeRotate);
break;
case 3:
view->SetCurrentCursor(STD_CURSOR_SCALE);
GetIEditor()->SetEditMode(eEditModeScale);
break;
}
CEditTool* pEditTool = view->GetEditTool();
if (pEditTool)
{
pEditTool->OnManipulatorMouseEvent(view, this, event, point, nFlags);
}
return true;
}
}
@@ -394,158 +326,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point
{
if (m_bDragging)
{
bool bCallBack = true;
Vec3 vDragValue(0, 0, 0);
// Dragging transform manipulator.
switch (GetIEditor()->GetEditMode())
{
case eEditModeMove:
{
view->SetCurrentCursor(STD_CURSOR_MOVE);
if (view->GetAxisConstrain() == AXIS_TERRAIN)
{
if (nFlags & MK_CONTROL)
{
bool bCollideWithTerrain;
Vec3 posOnTerrain = view->ViewToWorld(point, &bCollideWithTerrain, true);
if (!bCollideWithTerrain)
{
return true;
}
vDragValue = posOnTerrain - m_initPos;
}
else
{
Vec3 p1 = view->SnapToGrid(view->ViewToWorld(m_cMouseDownPos));
Vec3 p2 = view->SnapToGrid(view->ViewToWorld(point));
vDragValue = p2 - p1;
vDragValue.z = 0;
}
}
else
{
Vec3 p1 = view->MapViewToCP(m_cMouseDownPos);
Vec3 p2 = view->MapViewToCP(point);
if (p1.IsZero() || p2.IsZero())
{
return true;
}
vDragValue = view->GetCPVector(p1, p2);
}
}
break;
case eEditModeRotate:
{
view->SetCurrentCursor(STD_CURSOR_ROTATE);
Ang3 ang(0, 0, 0);
float ax = (point.x() - m_cMouseDownPos.x());
float ay = (point.y() - m_cMouseDownPos.y());
switch (view->GetAxisConstrain())
{
case AXIS_X:
ang.x = ay;
break;
case AXIS_Y:
ang.y = ay;
break;
case AXIS_Z:
ang.z = ay;
break;
case AXIS_XY:
ang(ax, ay, 0);
break;
case AXIS_XZ:
ang(ax, 0, ay);
break;
case AXIS_YZ:
ang(0, ay, ax);
break;
case AXIS_TERRAIN:
ang(ax, ay, 0);
break;
}
;
ang = gSettings.pGrid->SnapAngle(ang);
vDragValue = Vec3(DEG2RAD(ang));
}
break;
case eEditModeScale:
{
Vec3 scl(0, 0, 0);
float ay = 1.0f - 0.01f * (point.y() - m_cMouseDownPos.y());
if (ay < 0.01f)
{
ay = 0.01f;
}
scl(ay, ay, ay);
switch (view->GetAxisConstrain())
{
case AXIS_X:
scl(ay, 1, 1);
break;
case AXIS_Y:
scl(1, ay, 1);
break;
case AXIS_Z:
scl(1, 1, ay);
break;
case AXIS_XY:
scl(ay, ay, ay);
break;
case AXIS_XZ:
scl(ay, ay, ay);
break;
case AXIS_YZ:
scl(ay, ay, ay);
break;
case AXIS_XYZ:
scl(ay, ay, ay);
break;
case AXIS_TERRAIN:
scl(ay, ay, ay);
break;
}
;
view->SetCurrentCursor(STD_CURSOR_SCALE);
vDragValue = scl;
}
break;
case eEditModeRotateCircle:
{
Matrix34 tm = GetTransformation(m_bAlwaysUseLocal ? COORDS_LOCAL : GetIEditor()->GetReferenceCoordSys());
Vec3 v0, v1;
Vec3 vHitNormal;
if (m_pAxisHelper->HitTestForRotationCircle(tm, view, m_cMouseDownPos, 0.05f, &v0, &vHitNormal) && m_pAxisHelper->HitTestForRotationCircle(tm, view, point, 2.0f, &v1, &vHitNormal))
{
Vec3 vDir0 = (v0 - tm.GetTranslation()).GetNormalized();
Vec3 vDir1 = (v1 - tm.GetTranslation()).GetNormalized();
Vec3 vCurlDir = vDir0.Cross(vDir1).GetNormalized();
if (vHitNormal.Dot(vCurlDir) > 0)
{
vDragValue = Vec3(std::acos(vDir0.Dot(vDir1)), 0, 0);
}
else
{
vDragValue = Vec3(-std::acos(vDir0.Dot(vDir1)), 0, 0);
}
}
else
{
bCallBack = false;
}
}
break;
}
CEditTool* pEditTool = view->GetEditTool();
if (pEditTool && bCallBack)
{
pEditTool->OnManipulatorDrag(view, this, m_cMouseDownPos, point, vDragValue);
}
return true;
}
else
@@ -573,12 +353,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point
}
bHit = true;
}
CEditTool* pEditTool = view->GetEditTool();
if (pEditTool)
{
pEditTool->OnManipulatorMouseEvent(view, this, event, point, nFlags, bHit);
}
}
}
else if (event == eMouseLUp)
@@ -593,12 +367,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point
{
GetIEditor()->SetReferenceCoordSys(m_coordSysBackUp);
}
CEditTool* pEditTool = view->GetEditTool();
if (pEditTool)
{
pEditTool->OnManipulatorMouseEvent(view, this, event, point, nFlags);
}
}
}
@@ -39,7 +39,6 @@
#include "ViewManager.h"
#include "IEditorImpl.h"
#include "GameEngine.h"
#include "EditTool.h"
// To use the Andrew's algorithm in order to make convex hull from the points, this header is needed.
#include "Util/GeometryUtil.h"
@@ -3264,11 +3263,6 @@ ERotationWarningLevel CBaseObject::GetRotationWarningLevel() const
bool CBaseObject::IsSkipSelectionHelper() const
{
CEditTool* pEditTool(GetIEditor()->GetEditTool());
if (pEditTool && pEditTool->IsNeedToSkipPivotBoxForObjects())
{
return true;
}
return false;
}
@@ -22,12 +22,10 @@
#include "Settings.h"
#include "DisplaySettings.h"
#include "EntityObject.h"
#include "NullEditTool.h"
#include "Viewport.h"
#include "GizmoManager.h"
#include "AxisGizmo.h"
#include "ObjectPhysicsManager.h"
#include "EditMode/ObjectMode.h"
#include "GameEngine.h"
#include "WaitProgress.h"
#include "Util/Image.h"
@@ -838,8 +836,6 @@ void CObjectManager::Update()
QWidget* prevActiveWindow = QApplication::activeWindow();
CheckAndFixSelection();
// Restore focus if it changed.
if (prevActiveWindow && QApplication::activeWindow() != prevActiveWindow)
{
@@ -1230,60 +1226,6 @@ void CObjectManager::RemoveSelection(const QString& name)
}
}
//! Checks the state of the current selection and fixes it if necessary - Used when AZ Code modifies the selection
void CObjectManager::CheckAndFixSelection()
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor);
bool bObjectMode = qobject_cast<CObjectMode*>(GetIEditor()->GetEditTool()) != nullptr;
if (m_currSelection->GetCount() == 0)
{
// Nothing selected.
EndEditParams();
if (bObjectMode)
{
GetIEditor()->ShowTransformManipulator(false);
}
}
else if (m_currSelection->GetCount() == 1)
{
if (!m_bSingleSelection)
{
EndEditParams();
}
CBaseObject* newSelObject = m_currSelection->GetObject(0);
// Single object selected.
if (m_currEditObject != m_currSelection->GetObject(0))
{
m_bSelectionChanged = false;
if (!m_currEditObject || (m_currEditObject->metaObject() != newSelObject->metaObject()))
{
// If old object and new objects are of different classes.
EndEditParams();
}
if (GetIEditor()->GetEditTool() && GetIEditor()->GetEditTool()->IsUpdateUIPanel())
{
BeginEditParams(newSelObject, OBJECT_EDIT);
}
//AfxGetMainWnd()->SetFocus();
}
}
else if (m_currSelection->GetCount() > 1)
{
// Multiple objects are selected.
if (m_bSelectionChanged && bObjectMode)
{
m_bSelectionChanged = false;
m_nLastSelCount = m_currSelection->GetCount();
EndEditParams();
m_currEditObject = m_currSelection->GetObject(0);
}
}
}
void CObjectManager::SelectCurrent()
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor);
@@ -1404,8 +1346,6 @@ void CObjectManager::FindDisplayableObjects(DisplayContext& dc, bool bDisplay)
pDispayedViewObjects->ClearObjects();
pDispayedViewObjects->Reserve(m_visibleObjects.size());
CEditTool* pEditTool = GetIEditor()->GetEditTool();
const bool newViewportInteractionModelEnabled = GetIEditor()->IsNewViewportInteractionModelEnabled();
if (dc.flags & DISPLAY_2D)
@@ -1426,11 +1366,6 @@ void CObjectManager::FindDisplayableObjects(DisplayContext& dc, bool bDisplay)
{
obj->Display(dc);
}
if (pEditTool)
{
pEditTool->DrawObjectHelpers(obj, dc);
}
}
}
}
@@ -1476,11 +1411,6 @@ void CObjectManager::FindDisplayableObjects(DisplayContext& dc, bool bDisplay)
{
obj->Display(dc);
}
if (pEditTool)
{
pEditTool->DrawObjectHelpers(obj, dc);
}
}
}
}
@@ -1737,12 +1667,6 @@ bool CObjectManager::HitTestObject(CBaseObject* obj, HitContext& hc)
{
return false;
}
CEditTool* pEditTool = GetIEditor()->GetEditTool();
if (pEditTool && pEditTool->HitTest(obj, hc))
{
return true;
}
}
return (bSelectionHelperHit || obj->HitTest(hc));
@@ -2742,10 +2666,6 @@ void CObjectManager::SelectObjectInRect(CBaseObject* pObj, CViewport* view, HitC
void CObjectManager::EnteredComponentMode(const AZStd::vector<AZ::Uuid>& /*componentModeTypes*/)
{
// provide an EditTool that does nothing.
// note: will hide rotation gizmo when active (CRotateTool)
GetIEditor()->SetEditTool(new NullEditTool());
// hide current gizmo for entity (translate/rotate/scale)
IGizmoManager* gizmoManager = GetGizmoManager();
const size_t gizmoCount = static_cast<size_t>(gizmoManager->GetGizmoCount());
@@ -2757,9 +2677,6 @@ void CObjectManager::EnteredComponentMode(const AZStd::vector<AZ::Uuid>& /*compo
void CObjectManager::LeftComponentMode(const AZStd::vector<AZ::Uuid>& /*componentModeTypes*/)
{
// return to default EditTool (in whatever transform mode is set)
GetIEditor()->SetEditTool(nullptr);
// show translate/rotate/scale gizmo again
if (IGizmoManager* gizmoManager = GetGizmoManager())
{
@@ -226,8 +226,6 @@ public:
//! Set one of name selections as current selection.
void SetSelection(const QString& name);
void RemoveSelection(const QString& name);
//! Checks for changes to the current selection and makes adjustments accordingly
void CheckAndFixSelection() override;
bool IsObjectDeletionAllowed(CBaseObject* pObject);
@@ -139,16 +139,6 @@ namespace AzToolsFramework
*/
virtual void SetAxisConstraint(AZStd::string_view pConstrain) = 0;
/*
* Gets edit mode.
*/
virtual const char* GetEditMode() = 0;
/*
* Sets edit mode.
*/
virtual void SetEditMode(AZStd::string_view pEditMode) = 0;
/*
* Finds a pak file name for a given file.
*/

Some files were not shown because too many files have changed in this diff Show More