Merging latest origin
This commit is contained in:
@@ -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")
|
||||
|
||||
+2
@@ -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")
|
||||
|
||||
+2
@@ -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)
|
||||
|
||||
+2
@@ -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")
|
||||
|
||||
+2
@@ -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")
|
||||
|
||||
+1
@@ -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)
|
||||
|
||||
+2
@@ -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")
|
||||
|
||||
+2
@@ -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)
|
||||
|
||||
+1
@@ -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)
|
||||
|
||||
+2
@@ -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)
|
||||
|
||||
+3
@@ -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")
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
+1
-1
@@ -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")
|
||||
|
||||
+3
@@ -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")
|
||||
|
||||
+2
@@ -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")
|
||||
|
||||
+2
@@ -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")
|
||||
|
||||
+3
@@ -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")
|
||||
|
||||
+3
@@ -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")
|
||||
|
||||
@@ -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>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
+14
-3
@@ -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)
|
||||
|
||||
+13
@@ -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
@@ -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*/) {}
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+4
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
@@ -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
|
||||
@@ -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>
|
||||
@@ -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
|
||||
@@ -580,7 +580,6 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
|
||||
|
||||
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);
|
||||
|
||||
@@ -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"
|
||||
@@ -153,7 +151,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"
|
||||
@@ -399,11 +396,8 @@ void CCryEditApp::RegisterActionHandlers()
|
||||
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)
|
||||
@@ -413,11 +407,9 @@ void CCryEditApp::RegisterActionHandlers()
|
||||
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)
|
||||
@@ -524,12 +516,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 +2729,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 +2737,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()
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -2986,14 +2898,6 @@ void CCryEditApp::OnUpdateEditmodeScale(QAction* action)
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnUpdateEditmodeVertexSnapping(QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
CEditTool* pEditTool = GetIEditor()->GetEditTool();
|
||||
action->setChecked(qobject_cast<CVertexSnappingModeTool*>(pEditTool) != nullptr);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnObjectSetArea()
|
||||
{
|
||||
@@ -3143,19 +3047,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.
|
||||
@@ -3480,37 +3371,8 @@ void CCryEditApp::OnAlignToGrid()
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
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);
|
||||
}
|
||||
@@ -5136,12 +4998,6 @@ void CCryEditApp::OnOpenUICanvasEditor()
|
||||
QtViewPaneManager::instance()->OpenPane(LyViewPane::UiEditor);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnMaterialPicktool()
|
||||
{
|
||||
GetIEditor()->SetEditTool("EditTool.PickMaterial");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnTimeOfDay()
|
||||
{
|
||||
@@ -5296,12 +5152,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);
|
||||
|
||||
@@ -225,11 +225,8 @@ public:
|
||||
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);
|
||||
@@ -247,14 +244,11 @@ public:
|
||||
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();
|
||||
@@ -491,7 +485,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);
|
||||
|
||||
@@ -279,7 +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);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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
@@ -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
|
||||
@@ -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>
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,6 @@ struct QMetaObject;
|
||||
class CBaseObject;
|
||||
class CCryEditDoc;
|
||||
class CSelectionGroup;
|
||||
class CEditTool;
|
||||
class CAnimationContext;
|
||||
class CTrackViewSequenceManager;
|
||||
class CGameEngine;
|
||||
@@ -623,14 +622,6 @@ struct IEditor
|
||||
//! 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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -451,12 +446,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, ...)
|
||||
@@ -682,14 +671,6 @@ void CEditorImpl::SetEditMode(int editMode)
|
||||
}
|
||||
}
|
||||
|
||||
if ((EEditMode)editMode == eEditModeRotate)
|
||||
{
|
||||
if (GetEditTool() && GetEditTool()->IsCircleTypeRotateGizmo())
|
||||
{
|
||||
editMode = eEditModeRotateCircle;
|
||||
}
|
||||
}
|
||||
|
||||
EEditMode newEditMode = (EEditMode)editMode;
|
||||
if (m_currEditMode == newEditMode)
|
||||
{
|
||||
@@ -700,11 +681,6 @@ void CEditorImpl::SetEditMode(int editMode)
|
||||
AABB box(Vec3(0, 0, 0), Vec3(0, 0, 0));
|
||||
SetSelectedRegion(box);
|
||||
|
||||
if (GetEditTool() && !GetEditTool()->IsNeedMoveTool())
|
||||
{
|
||||
SetEditTool(0, true);
|
||||
}
|
||||
|
||||
Notify(eNotify_OnEditModeChange);
|
||||
}
|
||||
|
||||
@@ -719,139 +695,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)
|
||||
|
||||
@@ -229,18 +229,6 @@ public:
|
||||
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();
|
||||
void SetAxisConstraints(AxisConstrains axis);
|
||||
@@ -400,7 +388,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;
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#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>
|
||||
@@ -58,7 +57,6 @@ CInfoBar::CInfoBar(QWidget* parent)
|
||||
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
|
||||
@@ -251,28 +249,6 @@ void CInfoBar::OnVectorUpdate(bool followTerrain)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -421,39 +397,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;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,6 @@ protected:
|
||||
bool m_bDragMode;
|
||||
QString m_sLastText;
|
||||
|
||||
CEditTool* m_editTool;
|
||||
Vec3 m_lastValue;
|
||||
Vec3 m_currValue;
|
||||
float m_oldMainVolume;
|
||||
|
||||
@@ -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;
|
||||
@@ -125,10 +125,6 @@ public:
|
||||
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 ));
|
||||
|
||||
@@ -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
|
||||
@@ -1104,11 +1093,6 @@ void MainWindow::InitActions()
|
||||
.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"))
|
||||
@@ -1459,10 +1443,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 +1490,6 @@ void MainWindow::OnEscapeAction()
|
||||
{
|
||||
AzToolsFramework::EditorEvents::Bus::Broadcast(
|
||||
&AzToolsFramework::EditorEvents::OnEscape);
|
||||
|
||||
CCryEditApp::instance()->OnEditEscape();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2640,7 +2618,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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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>
|
||||
@@ -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; }
|
||||
};
|
||||
@@ -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>
|
||||
@@ -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
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "RenderHelpers/AxisHelper.h"
|
||||
#include "RenderHelpers/AxisHelperExtended.h"
|
||||
#include "IObjectManager.h"
|
||||
#include "EditTool.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CAxisGizmo implementation.
|
||||
@@ -381,12 +380,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point
|
||||
break;
|
||||
}
|
||||
|
||||
CEditTool* pEditTool = view->GetEditTool();
|
||||
if (pEditTool)
|
||||
{
|
||||
pEditTool->OnManipulatorMouseEvent(view, this, event, point, nFlags);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -540,12 +533,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point
|
||||
break;
|
||||
}
|
||||
|
||||
CEditTool* pEditTool = view->GetEditTool();
|
||||
if (pEditTool && bCallBack)
|
||||
{
|
||||
pEditTool->OnManipulatorDrag(view, this, m_cMouseDownPos, point, vDragValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -573,12 +560,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 +574,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);
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "Include/IDisplayViewport.h"
|
||||
#include "Include/HitContext.h"
|
||||
#include "Util/Math.h"
|
||||
#include "EditTool.h"
|
||||
#include "IObjectManager.h"
|
||||
#include <Cry_Geo.h>
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
#include "Util/fastlib.h"
|
||||
#include "CryEditDoc.h"
|
||||
#include "GameEngine.h"
|
||||
#include "EditTool.h"
|
||||
#include "ViewManager.h"
|
||||
#include "Objects/DisplayContext.h"
|
||||
#include "DisplaySettings.h"
|
||||
@@ -1948,12 +1947,6 @@ void CRenderViewport::RenderAll()
|
||||
|
||||
m_entityVisibilityQuery.DisplayVisibility(*debugDisplay);
|
||||
|
||||
if (GetEditTool())
|
||||
{
|
||||
// display editing tool
|
||||
GetEditTool()->Display(displayContext);
|
||||
}
|
||||
|
||||
if (m_manipulatorManager != nullptr)
|
||||
{
|
||||
using namespace AzToolsFramework::ViewportInteraction;
|
||||
@@ -2776,35 +2769,6 @@ void CRenderViewport::OnMouseWheel(Qt::KeyboardModifiers modifiers, short zDelta
|
||||
|
||||
handled = result != MouseInteractionResult::None;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_manipulatorManager == nullptr || m_manipulatorManager->ConsumeViewportMouseWheel(mouseInteraction))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (AzToolsFramework::ComponentModeFramework::InComponentMode())
|
||||
{
|
||||
AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus::EventResult(
|
||||
handled, AzToolsFramework::GetEntityContextId(),
|
||||
&EditorInteractionSystemViewportSelectionRequestBus::Events::InternalHandleMouseViewportInteraction,
|
||||
MouseInteractionEvent(mouseInteraction, zDelta));
|
||||
}
|
||||
else
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Asks current edit tool to handle mouse callback.
|
||||
CEditTool* pEditTool = GetEditTool();
|
||||
if (pEditTool && (modifiers & Qt::ControlModifier))
|
||||
{
|
||||
QPoint tempPoint(scaledPoint.x(), scaledPoint.y());
|
||||
if (pEditTool->MouseCallback(this, eMouseWheel, tempPoint, zDelta))
|
||||
{
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!handled)
|
||||
{
|
||||
@@ -4347,10 +4311,6 @@ void CRenderViewport::RenderSnappingGrid()
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (GetIEditor()->GetEditTool() && !GetIEditor()->GetEditTool()->IsDisplayGrid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayContext& dc = m_displayContext;
|
||||
|
||||
|
||||
@@ -123,7 +123,6 @@
|
||||
#define ID_TOOL_SHELVE_LAST 33375
|
||||
#define ID_EDIT_SELECTALL 33376
|
||||
#define ID_EDIT_SELECTNONE 33377
|
||||
#define ID_OBJECTMODIFY_VERTEXSNAPPING 33384
|
||||
#define ID_WIREFRAME 33410
|
||||
#define ID_FILE_GENERATETERRAINTEXTURE 33445
|
||||
#define ID_GENERATORS_LIGHTING 33446
|
||||
@@ -275,7 +274,6 @@
|
||||
#define ID_GAME_PC_ENABLEMEDIUMSPEC 33961
|
||||
#define ID_GAME_PC_ENABLEHIGHSPEC 33962
|
||||
#define ID_GAME_PC_ENABLEVERYHIGHSPEC 33963
|
||||
#define ID_MODIFY_ALIGNOBJTOSURF 33968
|
||||
#define ID_PANEL_VEG_CREATE_SEL 33990
|
||||
#define ID_TOOLS_UPDATEPROCEDURALVEGETATION 33999
|
||||
#define ID_DISPLAY_GOTOPOSITION 34004
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,283 +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.
|
||||
*
|
||||
*/
|
||||
#ifndef CRYINCLUDE_EDITOR_ROTATETOOL_H
|
||||
#define CRYINCLUDE_EDITOR_ROTATETOOL_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include "EditTool.h"
|
||||
#include "IObjectManager.h"
|
||||
#include "EditMode/ObjectMode.h"
|
||||
#include "Objects/BaseObject.h" // for CBaseObject::EventListener
|
||||
#include "Objects/DisplayContext.h"
|
||||
#include "Include/HitContext.h"
|
||||
#endif
|
||||
|
||||
//! Provides rendering utilities to support CRotateTool
|
||||
namespace RotationDrawHelper
|
||||
{
|
||||
//! Circle drawing and hit testing functionality over arbitrary axes
|
||||
class Axis
|
||||
{
|
||||
public:
|
||||
|
||||
//! \param defaultColor Color used to draw the camera aligned portion of the axis.
|
||||
//! \param highlightColor Color used to draw the circle when it is in focus.
|
||||
Axis(const ColorF& defaultColor = Col_White, const ColorF& highlightColor = Col_Yellow);
|
||||
|
||||
//! Draws an axis aligned circle.
|
||||
//! \param dc DisplayContext to use for rendering.
|
||||
//! \param position World space position used as the center of the circle.
|
||||
//! \param axis The axis by which to align the circle.
|
||||
//! \param angleRadians The angle towards which the circle will be highlighted.
|
||||
//! \param radius The radius of the circle.
|
||||
//! \param highlighted If true it will draw the circle in the specified highlightColor.
|
||||
void Draw(DisplayContext& dc, const Vec3& position, const Vec3& axis, float angleRadians, float angleStepRadians, float radius, bool highlighted, CBaseObject* object, float screenScale);
|
||||
|
||||
//! Calculates a hit testing mesh (invisible) used for intersection testing.
|
||||
//! \param object The object selected if hit testing return true.
|
||||
//! \param hc The HitContext in which the hit object is set if an intersection is true.
|
||||
//! \param radius The radius for the axis' circle.
|
||||
//! \param angleStepRadians The angle for the step used to calculate the circle, a smaller angle results in a higher quality circle.
|
||||
//! \param axis The axis by which to align the intersection geometry.
|
||||
//! \param screenScale This is an internal parameter used to deduce the view distance ratio in order to scale the tool.
|
||||
bool HitTest(CBaseObject* object, HitContext& hc, float radius, float angleStepRadians, const Vec3& axis, float screenScale);
|
||||
|
||||
//! Draws the generated hit testing geometry, good for diagnostics and debugging.
|
||||
//! \param dc DisplayContext to use for rendering.
|
||||
//! \param hc The HitContext that contains the view direction raycast.
|
||||
//! \param position World space position used as the center of the circle.
|
||||
//! \param radius The radius for the axis' circle.
|
||||
//! \param angleStepRadians The angle for the step used to calculate the circle, a smaller angle results in a higher quality circle.
|
||||
//! \param axis The axis by which to align the intersection geometry.
|
||||
//! \param screenScale This is an internal parameter used to deduce the view distance ratio in order to scale the tool.
|
||||
void DebugDrawHitTestSurface(DisplayContext& dc, HitContext& hc, const Vec3& position, float radius, float angleStepRadians, const Vec3& axis, float screenScale);
|
||||
|
||||
protected:
|
||||
|
||||
enum States
|
||||
{
|
||||
StateDefault,
|
||||
StateHighlight,
|
||||
StateCount
|
||||
};
|
||||
|
||||
ColorF m_colors[StateCount];
|
||||
|
||||
//! Defines the width of the generated hit testing geometry.
|
||||
float m_hitTestWidth = 0.4f;
|
||||
|
||||
//! Contains the vertices that make up the ring for the intersection testing geometry.
|
||||
//! \remark Only contains the center positions, quads are generated by calculating the four vertices offset by m_hitTestWidth.
|
||||
std::vector<Vec3> m_vertices;
|
||||
|
||||
//! Generates the world space geometry necessary to perform hit testing.
|
||||
//! \param hc The HitContext data.
|
||||
//! \param position The world space position around which the geometry will be centered.
|
||||
//! \param radius The radius of the ring.
|
||||
//! \param angleStepRadians The angle for the step used to calculate the circle, a smaller angle results in a higher quality circle.
|
||||
//! \param axis The axis to which the geometry will be aligned to.
|
||||
//! \param screenScale This is an internal parameter used to deduce the view distance ratio in order to scale the tool.
|
||||
void GenerateHitTestGeometry(HitContext& hc, const Vec3& position, float radius, float angleStepRadians, const Vec3& axis, float screenScale);
|
||||
|
||||
//! Performs intersection testing between a ray and both sides of a quad
|
||||
//! \param ray The ray to test (in world space)
|
||||
//! \param quad An array of four Vec3 points in world space.
|
||||
//! \param[out] contact The intersection position in world space at which the intersection occurred.
|
||||
bool IntersectRayWithQuad(const Ray&ray, Vec3 quad[4], Vec3 & contact);
|
||||
};
|
||||
|
||||
//! Provides the means to set and restore DisplayContext settings within a given scope.
|
||||
class DisplayContextScope
|
||||
{
|
||||
public:
|
||||
DisplayContextScope(DisplayContext& dc)
|
||||
: m_dc(dc)
|
||||
{
|
||||
m_dc.DepthTestOff();
|
||||
m_dc.CullOff();
|
||||
}
|
||||
|
||||
~DisplayContextScope()
|
||||
{
|
||||
m_dc.DepthTestOn();
|
||||
m_dc.CullOn();
|
||||
}
|
||||
|
||||
DisplayContext& m_dc;
|
||||
};
|
||||
|
||||
//! Helper function that draws the representation of the inner angle of a rotation.
|
||||
namespace AngleDecorator
|
||||
{
|
||||
//! \param dc
|
||||
//! \param position World space position of the center of the decorator.
|
||||
//! \param axisToAlign Axis to which the decorator will be aligned to.
|
||||
//! \param startAngleRadians The starting angle from which the rotation will be performed.
|
||||
//! \param sweepAngleRadians An angle that represents the sweep of the rotation arc.
|
||||
//! \param angleStepRadians The angle for the step used to calculate the circle, a smaller angle results in a higher quality circle.
|
||||
//! \param radius The radius of the decorator.
|
||||
//! \param screenScale This is an internal parameter used to deduce the view distance ratio in order to scale the tool.
|
||||
void Draw(DisplayContext& dc, const Vec3& position, const Vec3& axisToAlign, float startAngleRadians, float sweepAngleRadians, float stepAngleRadians, float radius, float screenScale);
|
||||
}
|
||||
}
|
||||
|
||||
//! Provides rotation manipulation controls.
|
||||
class SANDBOX_API CRotateTool
|
||||
: public CObjectMode
|
||||
, public IObjectSelectCallback
|
||||
, public CBaseObject::EventListener
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_INVOKABLE CRotateTool(CBaseObject* pObject = nullptr, QWidget* parent = nullptr);
|
||||
virtual ~CRotateTool();
|
||||
|
||||
static const GUID& GetClassID();
|
||||
|
||||
// Registration function.
|
||||
static void RegisterTool(CRegistrationContext& rc);
|
||||
|
||||
void Display(DisplayContext& dc) override;
|
||||
void DrawObjectHelpers([[maybe_unused]] CBaseObject* pObject, [[maybe_unused]] DisplayContext& dc) override {}
|
||||
bool HitTest(CBaseObject* pObject, HitContext& hc) override;
|
||||
void DeleteThis() override;
|
||||
bool OnLButtonDown(CViewport* view, int nFlags, const QPoint& point) override;
|
||||
bool OnLButtonUp(CViewport* view, int nFlags, const QPoint& point) override;
|
||||
bool OnMouseMove(CViewport* view, int nFlags, const QPoint& point) override;
|
||||
|
||||
protected:
|
||||
|
||||
//! Utility to calculate the view distance ratio used to scale the tool.
|
||||
float GetScreenScale(IDisplayViewport* view, CCamera* camera = nullptr);
|
||||
|
||||
enum Axis
|
||||
{
|
||||
AxisNone,
|
||||
AxisX, //! X axis visualization and hit testing
|
||||
AxisY, //! Y axis visualization and hit testing
|
||||
AxisZ, //! Z axis visualization and hit testing
|
||||
AxisView, //! View direction axis, used to rotate along the vector from the camera to the object.
|
||||
AxisCount
|
||||
};
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
//! Axis visualization and hit testing
|
||||
RotationDrawHelper::Axis m_axes[Axis::AxisCount];
|
||||
|
||||
//! We record the starting angle when we begin to drag an object
|
||||
float m_initialViewAxisAngleRadians;
|
||||
|
||||
//! The angle from the object's (or selection's) center to the mouse cursor.
|
||||
float m_angleToCursor;
|
||||
|
||||
//! Specified which axis is currently selected.
|
||||
Axis m_highlightAxis;
|
||||
|
||||
//! True when we are using the view direction rotation axis.
|
||||
bool m_viewAxisRotation;
|
||||
|
||||
//! True when the mouse has been pressed, becomes false on release.
|
||||
bool m_draggingMouse;
|
||||
|
||||
//! The last mouse position on screen when rotating.
|
||||
QPoint m_lastPosition;
|
||||
|
||||
//! Cumulative rotation angle in degrees.
|
||||
Ang3 m_rotationAngles;
|
||||
|
||||
//! The selected object.
|
||||
CBaseObject* m_object;
|
||||
|
||||
//! True if there has been a change in rotation that affects the object.
|
||||
bool m_bTransformChanged;
|
||||
|
||||
//! Sum of the total rotation angles.
|
||||
float m_totalRotationAngle;
|
||||
|
||||
//! Radius used to draw the XYZ axes
|
||||
float m_basisAxisRadius;
|
||||
|
||||
//! Radius used to draw the view direction axis
|
||||
float m_viewAxisRadius;
|
||||
|
||||
//! Rotation step controls the quality of the axes, a smaller angle represents a higher number of vertices.
|
||||
float m_arcRotationStepRadians;
|
||||
|
||||
//! Thickness of for the axis line rendering.
|
||||
float m_lineThickness = 4.f;
|
||||
|
||||
//! Draws angle decorator for the current rotation axis.
|
||||
void DrawAngleDecorator(DisplayContext& dc);
|
||||
|
||||
//! Useful for debugging and visualizing hit testing
|
||||
void DrawHitTestGeometry(DisplayContext& dc, HitContext& hc);
|
||||
|
||||
//! Diagnostic tool to examine view direction angle (follows mouse cursor)
|
||||
void DrawViewDirectionAngleTracking(DisplayContext& dc, HitContext& hc);
|
||||
|
||||
//! Callback registered to receive Selection callbacks to set m_object
|
||||
bool OnSelectObject(CBaseObject* object) override;
|
||||
|
||||
//! Callback to check that an object can be selected
|
||||
bool CanSelectObject(CBaseObject* object) override;
|
||||
|
||||
//! Callback installed on the object, used to determine destruction or deselection.
|
||||
void OnObjectEvent(CBaseObject* object, int event) override;
|
||||
|
||||
//! Handle key down events.
|
||||
bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags) override;
|
||||
|
||||
//! Retrieves the object's transformation according to the specified reference coordinate system.
|
||||
Matrix34 GetTransform(RefCoordSys referenceCoordinateSystem, IDisplayViewport* view);
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
//! Calculate orientation of 3 points on screen, return 1.0f if clockwise, -1.0f if counter-clockwise
|
||||
float CalculateOrientation(const QPoint& p1, const QPoint& p2, const QPoint& p3);
|
||||
|
||||
private:
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
HitContext m_hc; //!< HACK: Cache the hitcontext given that it's values may differ depending on the viewport they are coming from.
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
//! Singleton that holds all the configuration cvars for the different features and debug options
|
||||
//! used by the CRotationControl
|
||||
class RotationControlConfiguration
|
||||
{
|
||||
public:
|
||||
|
||||
static RotationControlConfiguration& Get()
|
||||
{
|
||||
static RotationControlConfiguration instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
//! If enabled it will draw the inner rotation decorator.
|
||||
DeclareConstIntCVar(RotationControl_DrawDecorators, 0);
|
||||
|
||||
//! If enabled the hit testing geometry is rendered.
|
||||
DeclareConstIntCVar(RotationControl_DebugHitTesting, 0);
|
||||
|
||||
//! If enabled a sphere will be drawn to represent the view axis angle to the mouse cursor.
|
||||
DeclareConstIntCVar(RotationControl_AngleTracking, 0);
|
||||
|
||||
private:
|
||||
|
||||
RotationControlConfiguration();
|
||||
RotationControlConfiguration(const RotationControlConfiguration&) = delete;
|
||||
RotationControlConfiguration& operator = (const RotationControlConfiguration&) = delete;
|
||||
~RotationControlConfiguration() {}
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_ROTATETOOL_H
|
||||
@@ -653,12 +653,6 @@ void SEditorSettings::Save()
|
||||
|
||||
SaveValue("Settings", "ForceSkyUpdate", gSettings.bForceSkyUpdate);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Vertex snapping settings
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SaveValue("Settings\\VertexSnapping", "VertexCubeSize", vertexSnappingSettings.vertexCubeSize);
|
||||
SaveValue("Settings\\VertexSnapping", "RenderPenetratedBoundBox", vertexSnappingSettings.bRenderPenetratedBoundBox);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Smart file open settings
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -886,12 +880,6 @@ void SEditorSettings::Load()
|
||||
|
||||
LoadValue("Settings", "ForceSkyUpdate", gSettings.bForceSkyUpdate);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Vertex snapping settings
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
LoadValue("Settings\\VertexSnapping", "VertexCubeSize", vertexSnappingSettings.vertexCubeSize);
|
||||
LoadValue("Settings\\VertexSnapping", "RenderPenetratedBoundBox", vertexSnappingSettings.bRenderPenetratedBoundBox);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Smart file open settings
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -119,18 +119,6 @@ struct SDeepSelectionSettings
|
||||
bool bStickDuplicate;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Settings for vertex snapping.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct SVertexSnappingSettings
|
||||
{
|
||||
SVertexSnappingSettings()
|
||||
: vertexCubeSize(0.01f)
|
||||
, bRenderPenetratedBoundBox(false) {}
|
||||
float vertexCubeSize;
|
||||
bool bRenderPenetratedBoundBox;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct SObjectColors
|
||||
{
|
||||
@@ -474,9 +462,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
|
||||
// Object Highlight Settings
|
||||
SObjectColors objectColorSettings;
|
||||
|
||||
// Vertex Snapping Settings
|
||||
SVertexSnappingSettings vertexSnappingSettings;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
SSmartOpenDialogSettings smartOpenSettings;
|
||||
|
||||
@@ -625,7 +625,6 @@ AmazonToolbar ToolbarManager::GetObjectToolbar() const
|
||||
t.AddAction(ID_GOTO_SELECTED, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_OBJECTMODIFY_ALIGNTOGRID, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_OBJECTMODIFY_SETHEIGHT, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_MODIFY_ALIGNOBJTOSURF, ORIGINAL_TOOLBAR_VERSION);
|
||||
|
||||
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
|
||||
{
|
||||
@@ -634,8 +633,6 @@ AmazonToolbar ToolbarManager::GetObjectToolbar() const
|
||||
t.AddAction(ID_EDIT_UNFREEZEALL, ORIGINAL_TOOLBAR_VERSION);
|
||||
}
|
||||
|
||||
t.AddAction(ID_OBJECTMODIFY_VERTEXSNAPPING, ORIGINAL_TOOLBAR_VERSION);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "Util/Ruler.h"
|
||||
#include "PluginManager.h"
|
||||
#include "Include/IRenderListener.h"
|
||||
#include "EditTool.h"
|
||||
#include "GameEngine.h"
|
||||
#include "Settings.h"
|
||||
|
||||
@@ -207,8 +206,6 @@ QtViewport::QtViewport(QWidget* parent)
|
||||
|
||||
GetIEditor()->GetViewManager()->RegisterViewport(this);
|
||||
|
||||
m_pLocalEditTool = 0;
|
||||
|
||||
m_nCurViewportID = MAX_NUM_VIEWPORTS - 1;
|
||||
m_dropCallback = nullptr; // Leroy@Conffx
|
||||
|
||||
@@ -232,8 +229,6 @@ QtViewport::QtViewport(QWidget* parent)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QtViewport::~QtViewport()
|
||||
{
|
||||
if (m_pLocalEditTool)
|
||||
m_pLocalEditTool->deleteLater();
|
||||
delete m_pVisibleObjectsCache;
|
||||
|
||||
GetIEditor()->GetViewManager()->UnregisterViewport(this);
|
||||
@@ -258,42 +253,6 @@ void QtViewport::GetDimensions(int* pWidth, int* pHeight) const
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CEditTool* QtViewport::GetEditTool()
|
||||
{
|
||||
if (m_pLocalEditTool)
|
||||
{
|
||||
return m_pLocalEditTool;
|
||||
}
|
||||
return GetIEditor()->GetEditTool();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void QtViewport::SetEditTool(CEditTool* pEditTool, bool bLocalToViewport /*=false */)
|
||||
{
|
||||
if (m_pLocalEditTool == pEditTool)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pLocalEditTool)
|
||||
{
|
||||
m_pLocalEditTool->EndEditParams();
|
||||
}
|
||||
m_pLocalEditTool = 0;
|
||||
|
||||
if (bLocalToViewport)
|
||||
{
|
||||
m_pLocalEditTool = pEditTool;
|
||||
m_pLocalEditTool->BeginEditParams(GetIEditor(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pLocalEditTool = 0;
|
||||
GetIEditor()->SetEditTool(pEditTool);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void QtViewport::RegisterRenderListener(IRenderListener* piListener)
|
||||
{
|
||||
@@ -466,12 +425,6 @@ void QtViewport::Update()
|
||||
|
||||
m_bAdvancedSelectMode = false;
|
||||
bool bSpaceClick = false;
|
||||
CEditTool* pEditTool = GetIEditor()->GetEditTool();
|
||||
if (pEditTool && pEditTool->IsNeedSpecificBehaviorForSpaceAcce())
|
||||
{
|
||||
bSpaceClick = CheckVirtualKey(Qt::Key_Space);
|
||||
}
|
||||
else
|
||||
{
|
||||
bSpaceClick = CheckVirtualKey(Qt::Key_Space) & !CheckVirtualKey(Qt::Key_Shift) /*& !CheckVirtualKey(Qt::Key_Control)*/;
|
||||
}
|
||||
@@ -726,10 +679,6 @@ void QtViewport::OnMouseMove(Qt::KeyboardModifiers modifiers, Qt::MouseButtons b
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void QtViewport::OnSetCursor()
|
||||
{
|
||||
if (GetEditTool())
|
||||
{
|
||||
GetEditTool()->OnSetCursor(this);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -803,39 +752,23 @@ void QtViewport::OnRButtonDblClk(Qt::KeyboardModifiers modifiers, const QPoint&
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void QtViewport::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
||||
void QtViewport::OnKeyDown([[maybe_unused]] UINT nChar, [[maybe_unused]] UINT nRepCnt, [[maybe_unused]] UINT nFlags)
|
||||
{
|
||||
if (GetIEditor()->IsInGameMode())
|
||||
{
|
||||
// Ignore key downs while in game.
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetEditTool())
|
||||
{
|
||||
if (GetEditTool()->OnKeyDown(this, nChar, nRepCnt, nFlags))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void QtViewport::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
|
||||
void QtViewport::OnKeyUp([[maybe_unused]] UINT nChar, [[maybe_unused]] UINT nRepCnt, [[maybe_unused]] UINT nFlags)
|
||||
{
|
||||
if (GetIEditor()->IsInGameMode())
|
||||
{
|
||||
// Ignore key downs while in game.
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetEditTool())
|
||||
{
|
||||
if (GetEditTool()->OnKeyUp(this, nChar, nRepCnt, nFlags))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -1454,28 +1387,6 @@ bool QtViewport::MouseCallback(EMouseEvent event, const QPoint& point, Qt::Keybo
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Asks current edit tool to handle mouse callback.
|
||||
CEditTool* pEditTool = GetEditTool();
|
||||
if (pEditTool)
|
||||
{
|
||||
if (pEditTool->MouseCallback(this, event, tempPoint, flags))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ask all chain of parent tools if they are handling mouse event.
|
||||
CEditTool* pParentTool = pEditTool->GetParentTool();
|
||||
while (pParentTool)
|
||||
{
|
||||
if (pParentTool->MouseCallback(this, event, tempPoint, flags))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
pParentTool = pParentTool->GetParentTool();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user