Merge remote-tracking branch 'upstream/development' into thin-transmission
This commit is contained in:
@@ -12,12 +12,36 @@ import sys
|
||||
import os
|
||||
import pytest
|
||||
import logging
|
||||
import sqlite3
|
||||
pytest.importorskip('ly_test_tools')
|
||||
|
||||
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
|
||||
|
||||
def detect_product(sql_connection, platform, target):
|
||||
cur = sql_connection.cursor()
|
||||
product_target = f'{platform}/{target}'
|
||||
print(f'Detecting {product_target} in assetdb.sqlite')
|
||||
hits = 0
|
||||
for row in cur.execute(f'select ProductID from Products where ProductName is "{product_target}"'):
|
||||
hits = hits + 1
|
||||
assert hits == 1
|
||||
|
||||
|
||||
def find_products(cache_folder, platform):
|
||||
con = sqlite3.connect(os.path.join(cache_folder, 'assetdb.sqlite'))
|
||||
detect_product(con, platform, 'gem/pythontests/pythonassetbuilder/test_asset.mock_asset')
|
||||
detect_product(con, platform, 'gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive_1.azmodel')
|
||||
detect_product(con, platform, 'gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative_1.azmodel')
|
||||
detect_product(con, platform, 'gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive_1.azmodel')
|
||||
detect_product(con, platform, 'gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative_1.azmodel')
|
||||
detect_product(con, platform, 'gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive_1.azmodel')
|
||||
detect_product(con, platform, 'gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative_1.azmodel')
|
||||
detect_product(con, platform, 'gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center_1.azmodel')
|
||||
con.close()
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize('launcher_platform', ['windows_editor'])
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@@ -25,16 +49,7 @@ import ly_test_tools.environment.waiter as waiter
|
||||
class TestPythonAssetProcessing(object):
|
||||
def test_DetectPythonCreatedAsset(self, request, editor, level, launcher_platform):
|
||||
unexpected_lines = []
|
||||
expected_lines = [
|
||||
'Mock asset exists',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative_1.azmodel) found',
|
||||
'AssetId found for asset (gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center_1.azmodel) found'
|
||||
]
|
||||
expected_lines = []
|
||||
timeout = 180
|
||||
halt_on_unexpected = False
|
||||
test_directory = os.path.join(os.path.dirname(__file__))
|
||||
@@ -50,3 +65,9 @@ class TestPythonAssetProcessing(object):
|
||||
exc=("Log file '{}' was never opened by another process.".format(editorlog_file)),
|
||||
interval=1)
|
||||
log_monitor.monitor_log_for_lines(expected_lines, unexpected_lines, halt_on_unexpected, timeout)
|
||||
|
||||
cache_folder = editor.workspace.paths.cache()
|
||||
platform = editor.workspace.asset_processor_platform
|
||||
if platform == 'windows':
|
||||
platform = 'pc'
|
||||
find_products(cache_folder, platform)
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ def output_test_data(scene):
|
||||
# Just write something to the file, but the filename is the main information
|
||||
# used for the test.
|
||||
f.write(f"scene.sourceFilename: {scene.sourceFilename}\n")
|
||||
return True
|
||||
return ''
|
||||
|
||||
mySceneJobHandler = None
|
||||
|
||||
|
||||
+7
-1
@@ -98,7 +98,13 @@ def AssetBrowser_SearchFiltering():
|
||||
# 3) Type the name of an asset in the search bar and make sure it is filtered to and selectable
|
||||
asset_browser = editor_window.findChild(QtWidgets.QDockWidget, "Asset Browser")
|
||||
search_bar = asset_browser.findChild(QtWidgets.QLineEdit, "textSearch")
|
||||
search_bar.setText("cedar.fbx")
|
||||
|
||||
# Add a small pause when typing in the search bar in order to check that the entries are updated properly
|
||||
search_bar.setText("Cedar.f")
|
||||
general.idle_wait(0.5)
|
||||
search_bar.setText("Cedar.fbx")
|
||||
general.idle_wait(0.5)
|
||||
|
||||
asset_browser_tree = asset_browser.findChild(QtWidgets.QTreeView, "m_assetBrowserTreeViewWidget")
|
||||
asset_browser_table = asset_browser.findChild(QtWidgets.QTreeView, "m_assetBrowserTableViewWidget")
|
||||
found = await pyside_utils.wait_for_condition(lambda: pyside_utils.find_child_by_pattern(asset_browser_table, "cedar.fbx"), 5.0)
|
||||
|
||||
@@ -0,0 +1,566 @@
|
||||
{
|
||||
"ContainerEntity": {
|
||||
"Id": "ContainerEntity",
|
||||
"Name": "ShadowTest",
|
||||
"Components": {
|
||||
"Component_[10182366347512475253]": {
|
||||
"$type": "EditorPrefabComponent",
|
||||
"Id": 10182366347512475253
|
||||
},
|
||||
"Component_[12917798267488243668]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 12917798267488243668
|
||||
},
|
||||
"Component_[3261249813163778338]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 3261249813163778338
|
||||
},
|
||||
"Component_[3837204912784440039]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 3837204912784440039
|
||||
},
|
||||
"Component_[4272963378099646759]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 4272963378099646759,
|
||||
"Parent Entity": ""
|
||||
},
|
||||
"Component_[4848458548047175816]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 4848458548047175816
|
||||
},
|
||||
"Component_[5787060997243919943]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 5787060997243919943
|
||||
},
|
||||
"Component_[7804170251266531779]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 7804170251266531779
|
||||
},
|
||||
"Component_[7874177159288365422]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 7874177159288365422
|
||||
},
|
||||
"Component_[8018146290632383969]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 8018146290632383969
|
||||
},
|
||||
"Component_[8452360690590857075]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 8452360690590857075
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entities": {
|
||||
"Entity_[232650527119]": {
|
||||
"Id": "Entity_[232650527119]",
|
||||
"Name": "DirectionalLight",
|
||||
"Components": {
|
||||
"Component_[10660156197505313227]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 10660156197505313227
|
||||
},
|
||||
"Component_[14184823757717157844]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 14184823757717157844,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 9854879901259791898
|
||||
},
|
||||
{
|
||||
"ComponentId": 3968519938187714949,
|
||||
"SortIndex": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[1495573908681275492]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 1495573908681275492
|
||||
},
|
||||
"Component_[15580233403487968826]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 15580233403487968826
|
||||
},
|
||||
"Component_[3968519938187714949]": {
|
||||
"$type": "AZ::Render::EditorDirectionalLightComponent",
|
||||
"Id": 3968519938187714949,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"Intensity": 0.0,
|
||||
"CameraEntityId": "",
|
||||
"ShadowmapSize": "Size2048"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[4961040003466069196]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 4961040003466069196
|
||||
},
|
||||
"Component_[7824884165323036147]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 7824884165323036147
|
||||
},
|
||||
"Component_[8741866916946672319]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 8741866916946672319
|
||||
},
|
||||
"Component_[9288966876314965560]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 9288966876314965560
|
||||
},
|
||||
"Component_[9313163355156975968]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 9313163355156975968
|
||||
},
|
||||
"Component_[9854879901259791898]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 9854879901259791898,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
0.0,
|
||||
0.0,
|
||||
2.0
|
||||
],
|
||||
"Rotate": [
|
||||
-32.05662536621094,
|
||||
-26.103206634521484,
|
||||
47.54806137084961
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[260824893221]": {
|
||||
"Id": "Entity_[260824893221]",
|
||||
"Name": "SpotLight",
|
||||
"Components": {
|
||||
"Component_[16098295228434057928]": {
|
||||
"$type": "EditorDiskShapeComponent",
|
||||
"Id": 16098295228434057928,
|
||||
"ShapeColor": [
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"DiskShape": {
|
||||
"Configuration": {
|
||||
"Radius": 0.0
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[16175995808158769171]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 16175995808158769171,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
0.6417449712753296,
|
||||
1.3211734294891357,
|
||||
3.022759199142456
|
||||
],
|
||||
"Rotate": [
|
||||
243.31329345703125,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[17136787899581093377]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 17136787899581093377
|
||||
},
|
||||
"Component_[17938027566627202610]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 17938027566627202610
|
||||
},
|
||||
"Component_[190081405128299223]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 190081405128299223
|
||||
},
|
||||
"Component_[2181418147135573579]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 2181418147135573579
|
||||
},
|
||||
"Component_[2564149706319215342]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 2564149706319215342
|
||||
},
|
||||
"Component_[3716169383940064541]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 3716169383940064541,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 16175995808158769171
|
||||
},
|
||||
{
|
||||
"ComponentId": 16665800442781289114,
|
||||
"SortIndex": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[4143676462074671972]": {
|
||||
"$type": "AZ::Render::EditorAreaLightComponent",
|
||||
"Id": 4143676462074671972,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"LightType": 2,
|
||||
"AttenuationRadius": 31.62277603149414,
|
||||
"EnableShutters": true,
|
||||
"InnerShutterAngleDegrees": 22.5,
|
||||
"OuterShutterAngleDegrees": 27.5,
|
||||
"Enable Shadow": true,
|
||||
"Shadowmap Max Size": "Size2048",
|
||||
"Filtering Sample Count": 32
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[6706371214647538019]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 6706371214647538019
|
||||
},
|
||||
"Component_[7493944209625718550]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 7493944209625718550
|
||||
},
|
||||
"Component_[7614113482082939165]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 7614113482082939165
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[269117486973]": {
|
||||
"Id": "Entity_[269117486973]",
|
||||
"Name": "Floor",
|
||||
"Components": {
|
||||
"Component_[10562678944594915756]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 10562678944594915756
|
||||
},
|
||||
"Component_[1175452962278157526]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 1175452962278157526
|
||||
},
|
||||
"Component_[13598353801231166887]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 13598353801231166887
|
||||
},
|
||||
"Component_[13735087293504923475]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 13735087293504923475
|
||||
},
|
||||
"Component_[13888244442459268363]": {
|
||||
"$type": "AZ::Render::EditorMeshComponent",
|
||||
"Id": 13888244442459268363,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"ModelAsset": {
|
||||
"assetId": {
|
||||
"guid": "{E65E9ED3-3E38-5ABA-9E22-95E34DA4C3AE}",
|
||||
"subId": 280178048
|
||||
},
|
||||
"assetHint": "objects/plane.azmodel"
|
||||
},
|
||||
"LodOverride": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[1525720357937234014]": {
|
||||
"$type": "EditorMaterialComponent",
|
||||
"Id": 1525720357937234014,
|
||||
"materialSlotsByLodEnabled": true
|
||||
},
|
||||
"Component_[16568998871680422442]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 16568998871680422442
|
||||
},
|
||||
"Component_[2147751093058990131]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 2147751093058990131,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 3266761149114817871
|
||||
},
|
||||
{
|
||||
"ComponentId": 13888244442459268363,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 1525720357937234014,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[3266761149114817871]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 3266761149114817871,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Scale": [
|
||||
100.0,
|
||||
100.0,
|
||||
100.0
|
||||
],
|
||||
"UniformScale": 100.0
|
||||
}
|
||||
},
|
||||
"Component_[4625895382416898670]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 4625895382416898670
|
||||
},
|
||||
"Component_[4856699190357614535]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 4856699190357614535
|
||||
},
|
||||
"Component_[6466465153982575739]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 6466465153982575739
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[282757803856]": {
|
||||
"Id": "Entity_[282757803856]",
|
||||
"Name": "Cube",
|
||||
"Components": {
|
||||
"Component_[11189870094752260272]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 11189870094752260272
|
||||
},
|
||||
"Component_[11909086967677513257]": {
|
||||
"$type": "AZ::Render::EditorMeshComponent",
|
||||
"Id": 11909086967677513257,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"ModelAsset": {
|
||||
"assetId": {
|
||||
"guid": "{593006BE-FE73-5A4B-A0A6-06C02EFFE458}",
|
||||
"subId": 285127096
|
||||
},
|
||||
"loadBehavior": "PreLoad",
|
||||
"assetHint": "objects/cube.azmodel"
|
||||
},
|
||||
"LodOverride": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[1443341568598731610]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 1443341568598731610
|
||||
},
|
||||
"Component_[18339772707807258951]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 18339772707807258951,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
0.6083869934082031,
|
||||
3.137901782989502,
|
||||
0.5876787900924683
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[2447207272572065708]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 2447207272572065708
|
||||
},
|
||||
"Component_[3281906807632213471]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 3281906807632213471
|
||||
},
|
||||
"Component_[3412442673858204671]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 3412442673858204671
|
||||
},
|
||||
"Component_[5382641380294287889]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 5382641380294287889
|
||||
},
|
||||
"Component_[7221534636342494619]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 7221534636342494619,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 18339772707807258951
|
||||
},
|
||||
{
|
||||
"ComponentId": 11909086967677513257,
|
||||
"SortIndex": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[7701217952253676487]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 7701217952253676487
|
||||
},
|
||||
"Component_[7758436981023123121]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 7758436981023123121
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[372196702077]": {
|
||||
"Id": "Entity_[372196702077]",
|
||||
"Name": "Bunny",
|
||||
"Components": {
|
||||
"Component_[11345914745205508221]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 11345914745205508221
|
||||
},
|
||||
"Component_[11507863983962969790]": {
|
||||
"$type": "EditorMaterialComponent",
|
||||
"Id": 11507863983962969790,
|
||||
"materialSlotsByLodEnabled": true
|
||||
},
|
||||
"Component_[1342998773562921470]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 1342998773562921470
|
||||
},
|
||||
"Component_[14975835087235718844]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 14975835087235718844,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 5012565883129470759
|
||||
},
|
||||
{
|
||||
"ComponentId": 7975043234993822905,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 11507863983962969790,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[16460806723667032929]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 16460806723667032929
|
||||
},
|
||||
"Component_[18225690044585951363]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 18225690044585951363
|
||||
},
|
||||
"Component_[18314752491697618927]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 18314752491697618927
|
||||
},
|
||||
"Component_[2431610550789583502]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 2431610550789583502
|
||||
},
|
||||
"Component_[5012565883129470759]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 5012565883129470759,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.20401419699192047
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[7975043234993822905]": {
|
||||
"$type": "AZ::Render::EditorMeshComponent",
|
||||
"Id": 7975043234993822905,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"ModelAsset": {
|
||||
"assetId": {
|
||||
"guid": "{0C6BBB76-4EC2-583A-B8C6-1A4C4FD1FE9D}",
|
||||
"subId": 283109893
|
||||
},
|
||||
"assetHint": "objects/bunny.azmodel"
|
||||
},
|
||||
"LodOverride": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[8510666363380501112]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 8510666363380501112
|
||||
},
|
||||
"Component_[9639060480533776634]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 9639060480533776634
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[670308843764]": {
|
||||
"Id": "Entity_[670308843764]",
|
||||
"Name": "Camera1",
|
||||
"Components": {
|
||||
"Component_[12951260100632682169]": {
|
||||
"$type": "GenericComponentWrapper",
|
||||
"Id": 12951260100632682169,
|
||||
"m_template": {
|
||||
"$type": "FlyCameraInputComponent"
|
||||
}
|
||||
},
|
||||
"Component_[14180723329646459524]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 14180723329646459524
|
||||
},
|
||||
"Component_[14996469885773917977]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 14996469885773917977,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
4.563776969909668,
|
||||
0.7667046785354614,
|
||||
3.000542640686035
|
||||
],
|
||||
"Rotate": [
|
||||
-9.740042686462402,
|
||||
-20.20942497253418,
|
||||
63.57760238647461
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[17638492356673689530]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 17638492356673689530
|
||||
},
|
||||
"Component_[2421853983468750254]": {
|
||||
"$type": "{CA11DA46-29FF-4083-B5F6-E02C3A8C3A3D} EditorCameraComponent",
|
||||
"Id": 2421853983468750254,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"Field of View": 90.00020599365234,
|
||||
"EditorEntityId": 666013876468
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[2572028619185965684]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 2572028619185965684
|
||||
},
|
||||
"Component_[2782900516907042776]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 2782900516907042776
|
||||
},
|
||||
"Component_[2849166119438883669]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 2849166119438883669
|
||||
},
|
||||
"Component_[4618311795498613781]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 4618311795498613781
|
||||
},
|
||||
"Component_[5402004894214413002]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 5402004894214413002
|
||||
},
|
||||
"Component_[6111028576371006514]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 6111028576371006514
|
||||
},
|
||||
"Component_[8203141294643544464]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 8203141294643544464
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
@@ -0,0 +1,705 @@
|
||||
{
|
||||
"ContainerEntity": {
|
||||
"Id": "ContainerEntity",
|
||||
"Name": "Hermanubis",
|
||||
"Components": {
|
||||
"Component_[10182366347512475253]": {
|
||||
"$type": "EditorPrefabComponent",
|
||||
"Id": 10182366347512475253
|
||||
},
|
||||
"Component_[12917798267488243668]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 12917798267488243668
|
||||
},
|
||||
"Component_[3261249813163778338]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 3261249813163778338
|
||||
},
|
||||
"Component_[3837204912784440039]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 3837204912784440039
|
||||
},
|
||||
"Component_[4272963378099646759]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 4272963378099646759,
|
||||
"Parent Entity": ""
|
||||
},
|
||||
"Component_[4848458548047175816]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 4848458548047175816
|
||||
},
|
||||
"Component_[5787060997243919943]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 5787060997243919943
|
||||
},
|
||||
"Component_[7804170251266531779]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 7804170251266531779
|
||||
},
|
||||
"Component_[7874177159288365422]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 7874177159288365422
|
||||
},
|
||||
"Component_[8018146290632383969]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 8018146290632383969
|
||||
},
|
||||
"Component_[8452360690590857075]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 8452360690590857075
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entities": {
|
||||
"Entity_[250006174949]": {
|
||||
"Id": "Entity_[250006174949]",
|
||||
"Name": "WorldOrigin",
|
||||
"Components": {
|
||||
"Component_[13379444112629774116]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 13379444112629774116
|
||||
},
|
||||
"Component_[13797113876161133062]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 13797113876161133062,
|
||||
"Parent Entity": "ContainerEntity"
|
||||
},
|
||||
"Component_[16382506042739704306]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 16382506042739704306,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 13797113876161133062
|
||||
},
|
||||
{
|
||||
"ComponentId": 8816319458242680670,
|
||||
"SortIndex": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[2147729086581105478]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 2147729086581105478
|
||||
},
|
||||
"Component_[2433100672102773575]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 2433100672102773575
|
||||
},
|
||||
"Component_[4832829387489613630]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 4832829387489613630
|
||||
},
|
||||
"Component_[5585931842723227683]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 5585931842723227683,
|
||||
"Child Entity Order": [
|
||||
"Entity_[254301142245]"
|
||||
]
|
||||
},
|
||||
"Component_[7088004383223117498]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 7088004383223117498
|
||||
},
|
||||
"Component_[7856264459806503732]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 7856264459806503732
|
||||
},
|
||||
"Component_[8816319458242680670]": {
|
||||
"$type": "AZ::Render::EditorGridComponent",
|
||||
"Id": 8816319458242680670
|
||||
},
|
||||
"Component_[930042309700959235]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 930042309700959235
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[254301142245]": {
|
||||
"Id": "Entity_[254301142245]",
|
||||
"Name": "GlobalSkylight",
|
||||
"Components": {
|
||||
"Component_[10076500561520682485]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 10076500561520682485,
|
||||
"Parent Entity": "Entity_[250006174949]"
|
||||
},
|
||||
"Component_[12626877995248630950]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 12626877995248630950,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 10076500561520682485
|
||||
},
|
||||
{
|
||||
"ComponentId": 8158442301445120126,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 7260006984216245935,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[13040837632921717329]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 13040837632921717329
|
||||
},
|
||||
"Component_[1390505494369101864]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 1390505494369101864
|
||||
},
|
||||
"Component_[6733278858932131836]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 6733278858932131836
|
||||
},
|
||||
"Component_[7260006984216245935]": {
|
||||
"$type": "AZ::Render::EditorImageBasedLightComponent",
|
||||
"Id": 7260006984216245935,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"diffuseImageAsset": {
|
||||
"assetId": {
|
||||
"guid": "{3B78EA69-7CF0-56A7-A49A-110B88412666}",
|
||||
"subId": 3000
|
||||
},
|
||||
"assetHint": "lightingpresets/greenwich_park_02_4k_iblskyboxcm_ibldiffuse.exr.streamingimage"
|
||||
},
|
||||
"specularImageAsset": {
|
||||
"assetId": {
|
||||
"guid": "{3B78EA69-7CF0-56A7-A49A-110B88412666}",
|
||||
"subId": 2000
|
||||
},
|
||||
"assetHint": "lightingpresets/greenwich_park_02_4k_iblskyboxcm_iblspecular.exr.streamingimage"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[7944006745008331817]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 7944006745008331817
|
||||
},
|
||||
"Component_[8158442301445120126]": {
|
||||
"$type": "AZ::Render::EditorHDRiSkyboxComponent",
|
||||
"Id": 8158442301445120126,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"CubemapAsset": {
|
||||
"assetId": {
|
||||
"guid": "{3B78EA69-7CF0-56A7-A49A-110B88412666}",
|
||||
"subId": 1000
|
||||
},
|
||||
"assetHint": "lightingpresets/greenwich_park_02_4k_iblskyboxcm.exr.streamingimage"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[8255370213772594097]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 8255370213772594097
|
||||
},
|
||||
"Component_[8551180373364097938]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 8551180373364097938
|
||||
},
|
||||
"Component_[8852330656608249928]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 8852330656608249928
|
||||
},
|
||||
"Component_[8913694496991926693]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 8913694496991926693
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[258596109541]": {
|
||||
"Id": "Entity_[258596109541]",
|
||||
"Name": "Hermanubis_stone",
|
||||
"Components": {
|
||||
"Component_[1026780512255775175]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 1026780512255775175
|
||||
},
|
||||
"Component_[10882452951986489612]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 10882452951986489612
|
||||
},
|
||||
"Component_[12454042755417175050]": {
|
||||
"$type": "AZ::Render::EditorMeshComponent",
|
||||
"Id": 12454042755417175050,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"ModelAsset": {
|
||||
"assetId": {
|
||||
"guid": "{1F650917-AA74-5107-9C49-648C957B33DA}",
|
||||
"subId": 275904906
|
||||
},
|
||||
"assetHint": "materialeditor/viewportmodels/hermanubis.azmodel"
|
||||
},
|
||||
"LodOverride": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[13691807045809495479]": {
|
||||
"$type": "EditorMaterialComponent",
|
||||
"Id": 13691807045809495479,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"materials": {
|
||||
"{}": {
|
||||
"MaterialAsset": {
|
||||
"assetId": {
|
||||
"guid": "{FF6412B6-F86E-54C8-835C-04F08190D81B}"
|
||||
},
|
||||
"assetHint": "objects/hermanubis/hermanubis_stone.azmaterial"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"materialSlotsByLodEnabled": true
|
||||
},
|
||||
"Component_[14490373655742304057]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 14490373655742304057
|
||||
},
|
||||
"Component_[15248132570755287431]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 15248132570755287431
|
||||
},
|
||||
"Component_[16950375358457415777]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 16950375358457415777
|
||||
},
|
||||
"Component_[17852268252813268496]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 17852268252813268496,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
1.1189539432525635,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[3867610358542973898]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 3867610358542973898
|
||||
},
|
||||
"Component_[7717372065847089412]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 7717372065847089412
|
||||
},
|
||||
"Component_[7783943040473764331]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 7783943040473764331,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 17852268252813268496
|
||||
},
|
||||
{
|
||||
"ComponentId": 12454042755417175050,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 13691807045809495479,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[833407121913837256]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 833407121913837256
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[262891076837]": {
|
||||
"Id": "Entity_[262891076837]",
|
||||
"Name": "Hermanubis_brass",
|
||||
"Components": {
|
||||
"Component_[1026780512255775175]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 1026780512255775175
|
||||
},
|
||||
"Component_[10882452951986489612]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 10882452951986489612
|
||||
},
|
||||
"Component_[12454042755417175050]": {
|
||||
"$type": "AZ::Render::EditorMeshComponent",
|
||||
"Id": 12454042755417175050,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"ModelAsset": {
|
||||
"assetId": {
|
||||
"guid": "{1F650917-AA74-5107-9C49-648C957B33DA}",
|
||||
"subId": 275904906
|
||||
},
|
||||
"assetHint": "materialeditor/viewportmodels/hermanubis.azmodel"
|
||||
},
|
||||
"LodOverride": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[13691807045809495479]": {
|
||||
"$type": "EditorMaterialComponent",
|
||||
"Id": 13691807045809495479,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"materials": {
|
||||
"{}": {
|
||||
"MaterialAsset": {
|
||||
"assetId": {
|
||||
"guid": "{B3AC2305-1DE6-54AA-AAD5-5E77C75E5BB5}"
|
||||
},
|
||||
"assetHint": "objects/hermanubis/hermanubis_brass.azmaterial"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"materialSlotsByLodEnabled": true
|
||||
},
|
||||
"Component_[14490373655742304057]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 14490373655742304057
|
||||
},
|
||||
"Component_[15248132570755287431]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 15248132570755287431
|
||||
},
|
||||
"Component_[16950375358457415777]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 16950375358457415777
|
||||
},
|
||||
"Component_[17852268252813268496]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 17852268252813268496,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
-1.4824472665786743,
|
||||
-0.034557100385427475,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[3867610358542973898]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 3867610358542973898
|
||||
},
|
||||
"Component_[7717372065847089412]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 7717372065847089412
|
||||
},
|
||||
"Component_[7783943040473764331]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 7783943040473764331,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 17852268252813268496
|
||||
},
|
||||
{
|
||||
"ComponentId": 12454042755417175050,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 13691807045809495479,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[833407121913837256]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 833407121913837256
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[267186044133]": {
|
||||
"Id": "Entity_[267186044133]",
|
||||
"Name": "SphereLight",
|
||||
"Components": {
|
||||
"Component_[10922228943444131599]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 10922228943444131599
|
||||
},
|
||||
"Component_[11625534306113165068]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 11625534306113165068,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
0.2636711895465851,
|
||||
2.2845842838287354,
|
||||
0.22468790411949158
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[12372418243816154216]": {
|
||||
"$type": "EditorSphereShapeComponent",
|
||||
"Id": 12372418243816154216,
|
||||
"ShapeColor": [
|
||||
0.3289234936237335,
|
||||
0.7307698130607605,
|
||||
0.14859239757061005,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"Component_[12579170654872581897]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 12579170654872581897
|
||||
},
|
||||
"Component_[12844637542561882557]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 12844637542561882557
|
||||
},
|
||||
"Component_[13087890528096920855]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 13087890528096920855,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 11625534306113165068
|
||||
},
|
||||
{
|
||||
"ComponentId": 13427905514841050195,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 12372418243816154216,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[13427905514841050195]": {
|
||||
"$type": "AZ::Render::EditorAreaLightComponent",
|
||||
"Id": 13427905514841050195,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"LightType": 1,
|
||||
"Color": [
|
||||
0.3289234936237335,
|
||||
0.7307698130607605,
|
||||
0.14859239757061005
|
||||
],
|
||||
"IntensityMode": 1,
|
||||
"Intensity": 676.7677001953125,
|
||||
"AttenuationRadius": 226.51287841796875
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[15364092815744365073]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 15364092815744365073
|
||||
},
|
||||
"Component_[2481373975540551564]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 2481373975540551564
|
||||
},
|
||||
"Component_[4101167782224846352]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 4101167782224846352
|
||||
},
|
||||
"Component_[8664715119660216219]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 8664715119660216219
|
||||
},
|
||||
"Component_[8952093761729701957]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 8952093761729701957,
|
||||
"VisibilityFlag": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[275775978725]": {
|
||||
"Id": "Entity_[275775978725]",
|
||||
"Name": "TubeLight",
|
||||
"Components": {
|
||||
"Component_[10922228943444131599]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 10922228943444131599,
|
||||
"DisabledComponents": [
|
||||
{
|
||||
"$type": "EditorSphereShapeComponent",
|
||||
"Id": 12372418243816154216,
|
||||
"ShapeColor": [
|
||||
0.3289234936237335,
|
||||
0.7307698130607605,
|
||||
0.14859239757061005,
|
||||
1.0
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[11625534306113165068]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 11625534306113165068,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
-4.275930881500244,
|
||||
0.5104026794433594,
|
||||
2.3807857036590576
|
||||
],
|
||||
"Rotate": [
|
||||
270.0043029785156,
|
||||
0.16617189347743988,
|
||||
268.51611328125
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[12579170654872581897]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 12579170654872581897
|
||||
},
|
||||
"Component_[12844637542561882557]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 12844637542561882557
|
||||
},
|
||||
"Component_[13087890528096920855]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 13087890528096920855,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 11625534306113165068
|
||||
},
|
||||
{
|
||||
"ComponentId": 13427905514841050195,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 12372418243816154216,
|
||||
"SortIndex": 2
|
||||
},
|
||||
{
|
||||
"ComponentId": 2193911499802409037,
|
||||
"SortIndex": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[13427905514841050195]": {
|
||||
"$type": "AZ::Render::EditorAreaLightComponent",
|
||||
"Id": 13427905514841050195,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"LightType": 3,
|
||||
"Color": [
|
||||
0.8521705865859985,
|
||||
0.7865872979164124,
|
||||
0.6079347133636475
|
||||
],
|
||||
"IntensityMode": 1,
|
||||
"Intensity": 10000.0,
|
||||
"AttenuationRadius": 21608.193359375
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[15364092815744365073]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 15364092815744365073
|
||||
},
|
||||
"Component_[2193911499802409037]": {
|
||||
"$type": "EditorCapsuleShapeComponent",
|
||||
"Id": 2193911499802409037,
|
||||
"ShapeColor": [
|
||||
0.8521705865859985,
|
||||
0.7865872979164124,
|
||||
0.6079347133636475,
|
||||
1.0
|
||||
],
|
||||
"CapsuleShape": {
|
||||
"Configuration": {
|
||||
"Height": 5.0,
|
||||
"Radius": 0.10000000149011612
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[2481373975540551564]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 2481373975540551564
|
||||
},
|
||||
"Component_[4101167782224846352]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 4101167782224846352
|
||||
},
|
||||
"Component_[8664715119660216219]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 8664715119660216219
|
||||
},
|
||||
"Component_[8952093761729701957]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 8952093761729701957,
|
||||
"VisibilityFlag": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[482743502241]": {
|
||||
"Id": "Entity_[482743502241]",
|
||||
"Name": "Camera1",
|
||||
"Components": {
|
||||
"Component_[10672707967016183310]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 10672707967016183310
|
||||
},
|
||||
"Component_[13520081755303040361]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 13520081755303040361
|
||||
},
|
||||
"Component_[13650522584195762912]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 13650522584195762912
|
||||
},
|
||||
"Component_[14204465933176839167]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 14204465933176839167
|
||||
},
|
||||
"Component_[14509697511269710983]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 14509697511269710983
|
||||
},
|
||||
"Component_[271930369355383880]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 271930369355383880
|
||||
},
|
||||
"Component_[5015186380056948439]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 5015186380056948439
|
||||
},
|
||||
"Component_[6297637832938894772]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 6297637832938894772,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
-0.0018702250672504306,
|
||||
2.9982283115386963,
|
||||
3.0017592906951904
|
||||
],
|
||||
"Rotate": [
|
||||
20.080352783203125,
|
||||
-0.020488755777478218,
|
||||
179.92381286621094
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[6611378759823339947]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 6611378759823339947
|
||||
},
|
||||
"Component_[8475839846509409509]": {
|
||||
"$type": "{CA11DA46-29FF-4083-B5F6-E02C3A8C3A3D} EditorCameraComponent",
|
||||
"Id": 8475839846509409509,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"Field of View": 90.00020599365234,
|
||||
"EditorEntityId": 478448534945
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[9659542522325095386]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 9659542522325095386
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
@@ -0,0 +1,943 @@
|
||||
{
|
||||
"ContainerEntity": {
|
||||
"Id": "ContainerEntity",
|
||||
"Name": "hermanubis_high",
|
||||
"Components": {
|
||||
"Component_[10182366347512475253]": {
|
||||
"$type": "EditorPrefabComponent",
|
||||
"Id": 10182366347512475253
|
||||
},
|
||||
"Component_[12917798267488243668]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 12917798267488243668
|
||||
},
|
||||
"Component_[3261249813163778338]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 3261249813163778338
|
||||
},
|
||||
"Component_[3837204912784440039]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 3837204912784440039
|
||||
},
|
||||
"Component_[4272963378099646759]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 4272963378099646759,
|
||||
"Parent Entity": ""
|
||||
},
|
||||
"Component_[4848458548047175816]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 4848458548047175816
|
||||
},
|
||||
"Component_[5787060997243919943]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 5787060997243919943
|
||||
},
|
||||
"Component_[7804170251266531779]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 7804170251266531779
|
||||
},
|
||||
"Component_[7874177159288365422]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 7874177159288365422,
|
||||
"Child Entity Order": [
|
||||
"Entity_[243647107259]",
|
||||
"Entity_[247179151093]",
|
||||
"Entity_[262891076837]",
|
||||
"Entity_[242884183797]",
|
||||
"Entity_[258596109541]",
|
||||
"Entity_[267186044133]",
|
||||
"Entity_[275775978725]",
|
||||
"Entity_[250006174949]"
|
||||
]
|
||||
},
|
||||
"Component_[8018146290632383969]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 8018146290632383969
|
||||
},
|
||||
"Component_[8452360690590857075]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 8452360690590857075
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entities": {
|
||||
"Entity_[242884183797]": {
|
||||
"Id": "Entity_[242884183797]",
|
||||
"Name": "Hermanubis_stone",
|
||||
"Components": {
|
||||
"Component_[1026780512255775175]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 1026780512255775175
|
||||
},
|
||||
"Component_[10882452951986489612]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 10882452951986489612
|
||||
},
|
||||
"Component_[12454042755417175050]": {
|
||||
"$type": "AZ::Render::EditorMeshComponent",
|
||||
"Id": 12454042755417175050,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"ModelAsset": {
|
||||
"assetId": {
|
||||
"guid": "{35A45F31-F1C1-5076-8B51-FF599E2EEBAA}",
|
||||
"subId": 274433667
|
||||
},
|
||||
"assetHint": "objects/hermanubis/hermanubis_high.azmodel"
|
||||
},
|
||||
"LodOverride": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[13691807045809495479]": {
|
||||
"$type": "EditorMaterialComponent",
|
||||
"Id": 13691807045809495479,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"materials": {
|
||||
"{}": {
|
||||
"MaterialAsset": {
|
||||
"assetId": {
|
||||
"guid": "{A78EA2FC-688B-5E3A-A7F6-DB413D11D4CF}"
|
||||
},
|
||||
"assetHint": "materials/presets/pbr/metal_chrome_matte.azmaterial"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"materialSlotsByLodEnabled": true
|
||||
},
|
||||
"Component_[14490373655742304057]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 14490373655742304057
|
||||
},
|
||||
"Component_[15248132570755287431]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 15248132570755287431
|
||||
},
|
||||
"Component_[16950375358457415777]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 16950375358457415777
|
||||
},
|
||||
"Component_[17852268252813268496]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 17852268252813268496,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
3.810185432434082,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[3867610358542973898]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 3867610358542973898
|
||||
},
|
||||
"Component_[7717372065847089412]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 7717372065847089412
|
||||
},
|
||||
"Component_[7783943040473764331]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 7783943040473764331,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 17852268252813268496
|
||||
},
|
||||
{
|
||||
"ComponentId": 12454042755417175050,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 13691807045809495479,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[833407121913837256]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 833407121913837256
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[243647107259]": {
|
||||
"Id": "Entity_[243647107259]",
|
||||
"Name": "Camera1",
|
||||
"Components": {
|
||||
"Component_[11276153162797125616]": {
|
||||
"$type": "GenericComponentWrapper",
|
||||
"Id": 11276153162797125616,
|
||||
"m_template": {
|
||||
"$type": "FlyCameraInputComponent"
|
||||
}
|
||||
},
|
||||
"Component_[11484120648160206262]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 11484120648160206262
|
||||
},
|
||||
"Component_[14251459960897306807]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 14251459960897306807,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
-0.10533800721168518,
|
||||
-4.001697063446045,
|
||||
3.061025619506836
|
||||
],
|
||||
"Rotate": [
|
||||
-19.998117446899414,
|
||||
0.01881762035191059,
|
||||
-0.051706261932849884
|
||||
],
|
||||
"Scale": [
|
||||
0.9999998807907104,
|
||||
1.0,
|
||||
1.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[149351061984148634]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 149351061984148634
|
||||
},
|
||||
"Component_[15121925351155689107]": {
|
||||
"$type": "{CA11DA46-29FF-4083-B5F6-E02C3A8C3A3D} EditorCameraComponent",
|
||||
"Id": 15121925351155689107,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"EditorEntityId": 243647107259
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[15327903729148812780]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 15327903729148812780
|
||||
},
|
||||
"Component_[17667820301809320373]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 17667820301809320373
|
||||
},
|
||||
"Component_[17708351813187009272]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 17708351813187009272
|
||||
},
|
||||
"Component_[17941668830905411554]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 17941668830905411554
|
||||
},
|
||||
"Component_[48451466091772435]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 48451466091772435
|
||||
},
|
||||
"Component_[6163614082436403601]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 6163614082436403601,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 14251459960897306807
|
||||
},
|
||||
{
|
||||
"ComponentId": 15121925351155689107,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 11935019334576395684,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[8660334631968180943]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 8660334631968180943
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[247179151093]": {
|
||||
"Id": "Entity_[247179151093]",
|
||||
"Name": "Hermanubis_brass",
|
||||
"Components": {
|
||||
"Component_[1026780512255775175]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 1026780512255775175
|
||||
},
|
||||
"Component_[10882452951986489612]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 10882452951986489612
|
||||
},
|
||||
"Component_[12454042755417175050]": {
|
||||
"$type": "AZ::Render::EditorMeshComponent",
|
||||
"Id": 12454042755417175050,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"ModelAsset": {
|
||||
"assetId": {
|
||||
"guid": "{35A45F31-F1C1-5076-8B51-FF599E2EEBAA}",
|
||||
"subId": 274433667
|
||||
},
|
||||
"assetHint": "objects/hermanubis/hermanubis_high.azmodel"
|
||||
},
|
||||
"LodOverride": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[13691807045809495479]": {
|
||||
"$type": "EditorMaterialComponent",
|
||||
"Id": 13691807045809495479,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"materials": {
|
||||
"{}": {
|
||||
"MaterialAsset": {
|
||||
"assetId": {
|
||||
"guid": "{80E0F2A7-1EE4-597F-80EF-985C65BCE2EB}"
|
||||
},
|
||||
"assetHint": "materials/presets/pbr/metal_brass.azmaterial"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"materialSlotsByLodEnabled": true
|
||||
},
|
||||
"Component_[14490373655742304057]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 14490373655742304057
|
||||
},
|
||||
"Component_[15248132570755287431]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 15248132570755287431
|
||||
},
|
||||
"Component_[16950375358457415777]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 16950375358457415777
|
||||
},
|
||||
"Component_[17852268252813268496]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 17852268252813268496,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
-4.019397258758545,
|
||||
-0.034557100385427475,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[3867610358542973898]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 3867610358542973898
|
||||
},
|
||||
"Component_[7717372065847089412]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 7717372065847089412
|
||||
},
|
||||
"Component_[7783943040473764331]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 7783943040473764331,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 17852268252813268496
|
||||
},
|
||||
{
|
||||
"ComponentId": 12454042755417175050,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 13691807045809495479,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[833407121913837256]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 833407121913837256
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[250006174949]": {
|
||||
"Id": "Entity_[250006174949]",
|
||||
"Name": "WorldOrigin",
|
||||
"Components": {
|
||||
"Component_[13379444112629774116]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 13379444112629774116
|
||||
},
|
||||
"Component_[13797113876161133062]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 13797113876161133062,
|
||||
"Parent Entity": "ContainerEntity"
|
||||
},
|
||||
"Component_[16382506042739704306]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 16382506042739704306,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 13797113876161133062
|
||||
},
|
||||
{
|
||||
"ComponentId": 8816319458242680670,
|
||||
"SortIndex": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[2147729086581105478]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 2147729086581105478
|
||||
},
|
||||
"Component_[2433100672102773575]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 2433100672102773575
|
||||
},
|
||||
"Component_[4832829387489613630]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 4832829387489613630
|
||||
},
|
||||
"Component_[5585931842723227683]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 5585931842723227683,
|
||||
"Child Entity Order": [
|
||||
"Entity_[254301142245]"
|
||||
]
|
||||
},
|
||||
"Component_[7088004383223117498]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 7088004383223117498
|
||||
},
|
||||
"Component_[7856264459806503732]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 7856264459806503732
|
||||
},
|
||||
"Component_[8816319458242680670]": {
|
||||
"$type": "AZ::Render::EditorGridComponent",
|
||||
"Id": 8816319458242680670
|
||||
},
|
||||
"Component_[930042309700959235]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 930042309700959235
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[254301142245]": {
|
||||
"Id": "Entity_[254301142245]",
|
||||
"Name": "GlobalSkylight",
|
||||
"Components": {
|
||||
"Component_[10076500561520682485]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 10076500561520682485,
|
||||
"Parent Entity": "Entity_[250006174949]"
|
||||
},
|
||||
"Component_[12626877995248630950]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 12626877995248630950,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 10076500561520682485
|
||||
},
|
||||
{
|
||||
"ComponentId": 8158442301445120126,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 7260006984216245935,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[13040837632921717329]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 13040837632921717329
|
||||
},
|
||||
"Component_[1390505494369101864]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 1390505494369101864
|
||||
},
|
||||
"Component_[6733278858932131836]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 6733278858932131836
|
||||
},
|
||||
"Component_[7260006984216245935]": {
|
||||
"$type": "AZ::Render::EditorImageBasedLightComponent",
|
||||
"Id": 7260006984216245935,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"diffuseImageAsset": {
|
||||
"assetId": {
|
||||
"guid": "{3B78EA69-7CF0-56A7-A49A-110B88412666}",
|
||||
"subId": 3000
|
||||
},
|
||||
"assetHint": "lightingpresets/greenwich_park_02_4k_iblskyboxcm_ibldiffuse.exr.streamingimage"
|
||||
},
|
||||
"specularImageAsset": {
|
||||
"assetId": {
|
||||
"guid": "{3B78EA69-7CF0-56A7-A49A-110B88412666}",
|
||||
"subId": 2000
|
||||
},
|
||||
"assetHint": "lightingpresets/greenwich_park_02_4k_iblskyboxcm_iblspecular.exr.streamingimage"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[7944006745008331817]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 7944006745008331817
|
||||
},
|
||||
"Component_[8158442301445120126]": {
|
||||
"$type": "AZ::Render::EditorHDRiSkyboxComponent",
|
||||
"Id": 8158442301445120126,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"CubemapAsset": {
|
||||
"assetId": {
|
||||
"guid": "{3B78EA69-7CF0-56A7-A49A-110B88412666}",
|
||||
"subId": 1000
|
||||
},
|
||||
"assetHint": "lightingpresets/greenwich_park_02_4k_iblskyboxcm.exr.streamingimage"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[8255370213772594097]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 8255370213772594097
|
||||
},
|
||||
"Component_[8551180373364097938]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 8551180373364097938
|
||||
},
|
||||
"Component_[8852330656608249928]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 8852330656608249928
|
||||
},
|
||||
"Component_[8913694496991926693]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 8913694496991926693
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[258596109541]": {
|
||||
"Id": "Entity_[258596109541]",
|
||||
"Name": "Hermanubis_stone",
|
||||
"Components": {
|
||||
"Component_[1026780512255775175]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 1026780512255775175
|
||||
},
|
||||
"Component_[10882452951986489612]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 10882452951986489612
|
||||
},
|
||||
"Component_[12454042755417175050]": {
|
||||
"$type": "AZ::Render::EditorMeshComponent",
|
||||
"Id": 12454042755417175050,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"ModelAsset": {
|
||||
"assetId": {
|
||||
"guid": "{35A45F31-F1C1-5076-8B51-FF599E2EEBAA}",
|
||||
"subId": 274433667
|
||||
},
|
||||
"assetHint": "objects/hermanubis/hermanubis_high.azmodel"
|
||||
},
|
||||
"LodOverride": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[13691807045809495479]": {
|
||||
"$type": "EditorMaterialComponent",
|
||||
"Id": 13691807045809495479,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"materials": {
|
||||
"{}": {
|
||||
"MaterialAsset": {
|
||||
"assetId": {
|
||||
"guid": "{B7C712DC-4839-58BB-B522-A4F120084CF5}"
|
||||
},
|
||||
"assetHint": "materials/presets/pbr/metal_chrome.azmaterial"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"materialSlotsByLodEnabled": true
|
||||
},
|
||||
"Component_[14490373655742304057]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 14490373655742304057
|
||||
},
|
||||
"Component_[15248132570755287431]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 15248132570755287431
|
||||
},
|
||||
"Component_[16950375358457415777]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 16950375358457415777
|
||||
},
|
||||
"Component_[17852268252813268496]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 17852268252813268496,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
1.1189539432525635,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[3867610358542973898]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 3867610358542973898
|
||||
},
|
||||
"Component_[7717372065847089412]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 7717372065847089412
|
||||
},
|
||||
"Component_[7783943040473764331]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 7783943040473764331,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 17852268252813268496
|
||||
},
|
||||
{
|
||||
"ComponentId": 12454042755417175050,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 13691807045809495479,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[833407121913837256]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 833407121913837256
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[262891076837]": {
|
||||
"Id": "Entity_[262891076837]",
|
||||
"Name": "Hermanubis_brass",
|
||||
"Components": {
|
||||
"Component_[1026780512255775175]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 1026780512255775175
|
||||
},
|
||||
"Component_[10882452951986489612]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 10882452951986489612
|
||||
},
|
||||
"Component_[12454042755417175050]": {
|
||||
"$type": "AZ::Render::EditorMeshComponent",
|
||||
"Id": 12454042755417175050,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"ModelAsset": {
|
||||
"assetId": {
|
||||
"guid": "{35A45F31-F1C1-5076-8B51-FF599E2EEBAA}",
|
||||
"subId": 274433667
|
||||
},
|
||||
"assetHint": "objects/hermanubis/hermanubis_high.azmodel"
|
||||
},
|
||||
"LodOverride": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[13691807045809495479]": {
|
||||
"$type": "EditorMaterialComponent",
|
||||
"Id": 13691807045809495479,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"materials": {
|
||||
"{}": {
|
||||
"MaterialAsset": {
|
||||
"assetId": {
|
||||
"guid": "{CAF50181-3384-5DF2-9304-C6E48E83C72D}"
|
||||
},
|
||||
"assetHint": "materials/presets/pbr/metal_chrome_polished.azmaterial"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"materialSlotsByLodEnabled": true
|
||||
},
|
||||
"Component_[14490373655742304057]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 14490373655742304057
|
||||
},
|
||||
"Component_[15248132570755287431]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 15248132570755287431
|
||||
},
|
||||
"Component_[16950375358457415777]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 16950375358457415777
|
||||
},
|
||||
"Component_[17852268252813268496]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 17852268252813268496,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
-1.4824472665786743,
|
||||
-0.034557100385427475,
|
||||
0.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[3867610358542973898]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 3867610358542973898
|
||||
},
|
||||
"Component_[7717372065847089412]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 7717372065847089412
|
||||
},
|
||||
"Component_[7783943040473764331]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 7783943040473764331,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 17852268252813268496
|
||||
},
|
||||
{
|
||||
"ComponentId": 12454042755417175050,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 13691807045809495479,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[833407121913837256]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 833407121913837256
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[267186044133]": {
|
||||
"Id": "Entity_[267186044133]",
|
||||
"Name": "SphereLight",
|
||||
"Components": {
|
||||
"Component_[10922228943444131599]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 10922228943444131599
|
||||
},
|
||||
"Component_[11625534306113165068]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 11625534306113165068,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
0.2636711895465851,
|
||||
2.2845842838287354,
|
||||
0.22468790411949158
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[12372418243816154216]": {
|
||||
"$type": "EditorSphereShapeComponent",
|
||||
"Id": 12372418243816154216,
|
||||
"ShapeColor": [
|
||||
0.3289234936237335,
|
||||
0.7307698130607605,
|
||||
0.14859239757061005,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"Component_[12579170654872581897]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 12579170654872581897
|
||||
},
|
||||
"Component_[12844637542561882557]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 12844637542561882557
|
||||
},
|
||||
"Component_[13087890528096920855]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 13087890528096920855,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 11625534306113165068
|
||||
},
|
||||
{
|
||||
"ComponentId": 13427905514841050195,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 12372418243816154216,
|
||||
"SortIndex": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[13427905514841050195]": {
|
||||
"$type": "AZ::Render::EditorAreaLightComponent",
|
||||
"Id": 13427905514841050195,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"LightType": 1,
|
||||
"Color": [
|
||||
0.3289234936237335,
|
||||
0.7307698130607605,
|
||||
0.14859239757061005
|
||||
],
|
||||
"IntensityMode": 1,
|
||||
"Intensity": 676.7677001953125,
|
||||
"AttenuationRadius": 226.51287841796875
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[15364092815744365073]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 15364092815744365073
|
||||
},
|
||||
"Component_[2481373975540551564]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 2481373975540551564
|
||||
},
|
||||
"Component_[4101167782224846352]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 4101167782224846352
|
||||
},
|
||||
"Component_[8664715119660216219]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 8664715119660216219
|
||||
},
|
||||
"Component_[8952093761729701957]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 8952093761729701957,
|
||||
"VisibilityFlag": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"Entity_[275775978725]": {
|
||||
"Id": "Entity_[275775978725]",
|
||||
"Name": "TubeLight",
|
||||
"Components": {
|
||||
"Component_[10922228943444131599]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 10922228943444131599,
|
||||
"DisabledComponents": [
|
||||
{
|
||||
"$type": "EditorSphereShapeComponent",
|
||||
"Id": 12372418243816154216,
|
||||
"ShapeColor": [
|
||||
0.3289234936237335,
|
||||
0.7307698130607605,
|
||||
0.14859239757061005,
|
||||
1.0
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[11625534306113165068]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 11625534306113165068,
|
||||
"Parent Entity": "ContainerEntity",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
-4.275930881500244,
|
||||
0.5104026794433594,
|
||||
2.3807857036590576
|
||||
],
|
||||
"Rotate": [
|
||||
270.0043029785156,
|
||||
0.16617189347743988,
|
||||
268.51611328125
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[12579170654872581897]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 12579170654872581897
|
||||
},
|
||||
"Component_[12844637542561882557]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 12844637542561882557
|
||||
},
|
||||
"Component_[13087890528096920855]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 13087890528096920855,
|
||||
"ComponentOrderEntryArray": [
|
||||
{
|
||||
"ComponentId": 11625534306113165068
|
||||
},
|
||||
{
|
||||
"ComponentId": 13427905514841050195,
|
||||
"SortIndex": 1
|
||||
},
|
||||
{
|
||||
"ComponentId": 12372418243816154216,
|
||||
"SortIndex": 2
|
||||
},
|
||||
{
|
||||
"ComponentId": 2193911499802409037,
|
||||
"SortIndex": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"Component_[13427905514841050195]": {
|
||||
"$type": "AZ::Render::EditorAreaLightComponent",
|
||||
"Id": 13427905514841050195,
|
||||
"Controller": {
|
||||
"Configuration": {
|
||||
"LightType": 3,
|
||||
"Color": [
|
||||
0.8521705865859985,
|
||||
0.7865872979164124,
|
||||
0.6079347133636475
|
||||
],
|
||||
"IntensityMode": 1,
|
||||
"Intensity": 10000.0,
|
||||
"AttenuationRadius": 21608.193359375
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[15364092815744365073]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 15364092815744365073
|
||||
},
|
||||
"Component_[2193911499802409037]": {
|
||||
"$type": "EditorCapsuleShapeComponent",
|
||||
"Id": 2193911499802409037,
|
||||
"ShapeColor": [
|
||||
0.8521705865859985,
|
||||
0.7865872979164124,
|
||||
0.6079347133636475,
|
||||
1.0
|
||||
],
|
||||
"CapsuleShape": {
|
||||
"Configuration": {
|
||||
"Height": 5.0,
|
||||
"Radius": 0.10000000149011612
|
||||
}
|
||||
}
|
||||
},
|
||||
"Component_[2481373975540551564]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 2481373975540551564
|
||||
},
|
||||
"Component_[4101167782224846352]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 4101167782224846352
|
||||
},
|
||||
"Component_[8664715119660216219]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 8664715119660216219
|
||||
},
|
||||
"Component_[8952093761729701957]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 8952093761729701957,
|
||||
"VisibilityFlag": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
0,0,0,0,0,0
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f5f7a86a693878c10f91783955cc72535bf7d7c495163087a4c1982f228d27f0
|
||||
size 2145248
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ef71257b240a7e704731806f8cd4b966af5d3c60f22881f9c6a6320180ee71a4
|
||||
size 2496384
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:531b6473b314259504ab595e4983838b5866035ef4d70cedaf4cc9c7d9e65c3a
|
||||
size 24512
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e32877eab35459499c73ff093df898f93bf3e7379de25eef6875d693be9bec81
|
||||
size 18015
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2949a50eec079a7d43a1d92e056c580ef625ee39e00e91cc25318319e37dcd3b
|
||||
size 115689
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0a1f8d75dcd85e8b4aa57f6c0c81af0300ff96915ba3c2b591095c215d5e1d8c
|
||||
size 12072
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e3bcfac5de831c269dac58e7d73d1dc61eb8d9f6d8a241f5c029537b6bcdf166
|
||||
size 1088304
|
||||
@@ -28,7 +28,7 @@ def update_manifest(scene):
|
||||
meshGroup = sceneManifest.add_mesh_group(chunkName)
|
||||
meshGroup['id'] = '{' + str(uuid.uuid5(uuid.NAMESPACE_DNS, scene.sourceFilename + chunkName)) + '}'
|
||||
sceneManifest.mesh_group_add_comment(meshGroup, 'auto generated by test_chunks_builder')
|
||||
sceneManifest.mesh_group_set_origin(meshGroup, None, 0, 0, 0, 1.0)
|
||||
sceneManifest.mesh_group_add_advanced_coordinate_system(meshGroup)
|
||||
for meshIndex in range(len(chunkNameList)):
|
||||
if (activeMeshIndex == meshIndex):
|
||||
sceneManifest.mesh_group_select_node(meshGroup, chunkNameList[meshIndex])
|
||||
|
||||
@@ -1,232 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "BaseLibrary.h"
|
||||
#include "BaseLibraryItem.h"
|
||||
#include "Include/IBaseLibraryManager.h"
|
||||
#include <Util/PathUtil.h>
|
||||
#include <IFileUtil.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CBaseLibrary implementation.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CBaseLibrary::CBaseLibrary(IBaseLibraryManager* pManager)
|
||||
: m_pManager(pManager)
|
||||
, m_bModified(false)
|
||||
, m_bLevelLib(false)
|
||||
, m_bNewLibrary(true)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CBaseLibrary::~CBaseLibrary()
|
||||
{
|
||||
m_items.clear();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IBaseLibraryManager* CBaseLibrary::GetManager()
|
||||
{
|
||||
return m_pManager;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibrary::RemoveAllItems()
|
||||
{
|
||||
AddRef();
|
||||
for (int i = 0; i < m_items.size(); i++)
|
||||
{
|
||||
// Unregister item in case it was registered. It is ok if it wasn't. This is still safe to call.
|
||||
m_pManager->UnregisterItem(m_items[i]);
|
||||
// Clear library item.
|
||||
m_items[i]->m_library = nullptr;
|
||||
}
|
||||
m_items.clear();
|
||||
Release();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibrary::SetName(const QString& name)
|
||||
{
|
||||
//the fullname of the items in the library will be changed due to library's name change
|
||||
//so we need unregistered them and register them after their name changed.
|
||||
for (int i = 0; i < m_items.size(); i++)
|
||||
{
|
||||
m_pManager->UnregisterItem(m_items[i]);
|
||||
}
|
||||
|
||||
m_name = name;
|
||||
|
||||
for (int i = 0; i < m_items.size(); i++)
|
||||
{
|
||||
m_pManager->RegisterItem(m_items[i]);
|
||||
}
|
||||
|
||||
SetModified();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const QString& CBaseLibrary::GetName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseLibrary::Save()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseLibrary::Load(const QString& filename)
|
||||
{
|
||||
m_filename = filename;
|
||||
SetModified(false);
|
||||
m_bNewLibrary = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibrary::SetModified(bool bModified)
|
||||
{
|
||||
if (bModified != m_bModified)
|
||||
{
|
||||
m_bModified = bModified;
|
||||
emit Modified(bModified);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibrary::AddItem(IDataBaseItem* item, bool bRegister)
|
||||
{
|
||||
|
||||
CBaseLibraryItem* pLibItem = (CBaseLibraryItem*)item;
|
||||
// Check if item is already assigned to this library.
|
||||
if (pLibItem->m_library != this)
|
||||
{
|
||||
pLibItem->m_library = this;
|
||||
m_items.push_back(pLibItem);
|
||||
SetModified();
|
||||
if (bRegister)
|
||||
{
|
||||
m_pManager->RegisterItem(pLibItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItem* CBaseLibrary::GetItem(int index)
|
||||
{
|
||||
assert(index >= 0 && index < m_items.size());
|
||||
return m_items[index];
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibrary::RemoveItem(IDataBaseItem* item)
|
||||
{
|
||||
|
||||
for (int i = 0; i < m_items.size(); i++)
|
||||
{
|
||||
if (m_items[i] == item)
|
||||
{
|
||||
// Unregister item in case it was registered. It is ok if it wasn't. This is still safe to call.
|
||||
m_pManager->UnregisterItem(m_items[i]);
|
||||
m_items.erase(m_items.begin() + i);
|
||||
SetModified();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItem* CBaseLibrary::FindItem(const QString& name)
|
||||
{
|
||||
for (int i = 0; i < m_items.size(); i++)
|
||||
{
|
||||
if (QString::compare(m_items[i]->GetName(), name, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return m_items[i];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CBaseLibrary::AddLibraryToSourceControl(const QString& fullPathName) const
|
||||
{
|
||||
IEditor* pEditor = GetIEditor();
|
||||
IFileUtil* pFileUtil = pEditor ? pEditor->GetFileUtil() : nullptr;
|
||||
if (pFileUtil)
|
||||
{
|
||||
return pFileUtil->CheckoutFile(fullPathName.toUtf8().data(), nullptr);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBaseLibrary::SaveLibrary(const char* name, bool saveEmptyLibrary)
|
||||
{
|
||||
assert(name != nullptr);
|
||||
if (name == nullptr)
|
||||
{
|
||||
CryFatalError("The library you are attempting to save has no name specified.");
|
||||
return false;
|
||||
}
|
||||
|
||||
QString fileName(GetFilename());
|
||||
if (fileName.isEmpty() && !saveEmptyLibrary)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
fileName = Path::GamePathToFullPath(fileName);
|
||||
|
||||
XmlNodeRef root = GetIEditor()->GetSystem()->CreateXmlNode(name);
|
||||
Serialize(root, false);
|
||||
bool bRes = XmlHelpers::SaveXmlNode(GetIEditor()->GetFileUtil(), root, fileName.toUtf8().data());
|
||||
if (m_bNewLibrary)
|
||||
{
|
||||
AddLibraryToSourceControl(fileName);
|
||||
m_bNewLibrary = false;
|
||||
}
|
||||
if (!bRes)
|
||||
{
|
||||
QByteArray filenameUtf8 = fileName.toUtf8();
|
||||
AZStd::string strMessage = AZStd::string::format("The file %s is read-only and the save of the library couldn't be performed. Try to remove the \"read-only\" flag or check-out the file and then try again.", filenameUtf8.data());
|
||||
CryMessageBox(strMessage.c_str(), "Saving Error", MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
return bRes;
|
||||
}
|
||||
|
||||
//CONFETTI BEGIN
|
||||
void CBaseLibrary::ChangeItemOrder(CBaseLibraryItem* item, unsigned int newLocation)
|
||||
{
|
||||
std::vector<_smart_ptr<CBaseLibraryItem> > temp;
|
||||
for (unsigned int i = 0; i < m_items.size(); i++)
|
||||
{
|
||||
if (i == newLocation)
|
||||
{
|
||||
temp.push_back(_smart_ptr<CBaseLibraryItem>(item));
|
||||
}
|
||||
if (m_items[i] != item)
|
||||
{
|
||||
temp.push_back(m_items[i]);
|
||||
}
|
||||
}
|
||||
// If newLocation is greater than the original size, append the item to end of the list
|
||||
if (newLocation >= m_items.size())
|
||||
{
|
||||
temp.push_back(_smart_ptr<CBaseLibraryItem>(item));
|
||||
}
|
||||
m_items = temp;
|
||||
}
|
||||
//CONFETTI END
|
||||
|
||||
#include <moc_BaseLibrary.cpp>
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_BASELIBRARY_H
|
||||
#define CRYINCLUDE_EDITOR_BASELIBRARY_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include "Include/IDataBaseLibrary.h"
|
||||
#include "Include/IBaseLibraryManager.h"
|
||||
#include "Include/EditorCoreAPI.h"
|
||||
#include "Util/TRefCountBase.h"
|
||||
|
||||
#include <QObject>
|
||||
#endif
|
||||
|
||||
// Ensure we don't try to dllimport when moc includes us
|
||||
#if defined(Q_MOC_BUILD) && !defined(EDITOR_CORE)
|
||||
#define EDITOR_CORE
|
||||
#endif
|
||||
|
||||
/** This a base class for all Libraries used by Editor.
|
||||
*/
|
||||
class EDITOR_CORE_API CBaseLibrary
|
||||
: public QObject
|
||||
, public TRefCountBase<IDataBaseLibrary>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CBaseLibrary(IBaseLibraryManager* pManager);
|
||||
~CBaseLibrary();
|
||||
|
||||
//! Set library name.
|
||||
virtual void SetName(const QString& name);
|
||||
//! Get library name.
|
||||
const QString& GetName() const override;
|
||||
|
||||
//! Set new filename for this library.
|
||||
virtual bool SetFilename(const QString& filename, [[maybe_unused]] bool checkForUnique = true) { m_filename = filename.toLower(); return true; };
|
||||
const QString& GetFilename() const override { return m_filename; };
|
||||
|
||||
bool Save() override = 0;
|
||||
bool Load(const QString& filename) override = 0;
|
||||
void Serialize(XmlNodeRef& node, bool bLoading) override = 0;
|
||||
|
||||
//! Mark library as modified.
|
||||
void SetModified(bool bModified = true) override;
|
||||
//! Check if library was modified.
|
||||
bool IsModified() const override { return m_bModified; };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Working with items.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Add a new prototype to library.
|
||||
void AddItem(IDataBaseItem* item, bool bRegister = true) override;
|
||||
//! Get number of known prototypes.
|
||||
int GetItemCount() const override { return static_cast<int>(m_items.size()); }
|
||||
//! Get prototype by index.
|
||||
IDataBaseItem* GetItem(int index) override;
|
||||
|
||||
//! Delete item by pointer of item.
|
||||
void RemoveItem(IDataBaseItem* item) override;
|
||||
|
||||
//! Delete all items from library.
|
||||
void RemoveAllItems() override;
|
||||
|
||||
//! Find library item by name.
|
||||
//! Using linear search.
|
||||
IDataBaseItem* FindItem(const QString& name) override;
|
||||
|
||||
//! Check if this library is local level library.
|
||||
bool IsLevelLibrary() const override { return m_bLevelLib; };
|
||||
|
||||
//! Set library to be level library.
|
||||
void SetLevelLibrary(bool bEnable) override { m_bLevelLib = bEnable; };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Return manager for this library.
|
||||
IBaseLibraryManager* GetManager() override;
|
||||
|
||||
// Saves the library with the main tag defined by the parameter name
|
||||
bool SaveLibrary(const char* name, bool saveEmptyLibrary = false);
|
||||
|
||||
//CONFETTI BEGIN
|
||||
// Used to change the library item order
|
||||
void ChangeItemOrder(CBaseLibraryItem* item, unsigned int newLocation) override;
|
||||
//CONFETTI END
|
||||
|
||||
signals:
|
||||
void Modified(bool bModified);
|
||||
|
||||
private:
|
||||
// Add the library to the source control
|
||||
bool AddLibraryToSourceControl(const QString& fullPathName) const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Name of the library.
|
||||
QString m_name;
|
||||
//! Filename of the library.
|
||||
QString m_filename;
|
||||
|
||||
//! Flag set when library was modified.
|
||||
bool m_bModified;
|
||||
|
||||
// Flag set when the library is just created and it's not yet saved for the first time.
|
||||
bool m_bNewLibrary;
|
||||
|
||||
//! Level library is saved within the level .ly file and is local for this level.
|
||||
bool m_bLevelLib;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Manager.
|
||||
IBaseLibraryManager* m_pManager;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
// Array of all our library items.
|
||||
std::vector<_smart_ptr<CBaseLibraryItem> > m_items;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_BASELIBRARY_H
|
||||
@@ -1,261 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "BaseLibraryItem.h"
|
||||
#include "BaseLibrary.h"
|
||||
#include "BaseLibraryManager.h"
|
||||
#include "Undo/IUndoObject.h"
|
||||
|
||||
#include <AzCore/Math/Uuid.h>
|
||||
|
||||
//undo object for multi-changes inside library item. such as set all variables to default values.
|
||||
//For example: change particle emitter shape will lead to multiple variable changes
|
||||
class CUndoBaseLibraryItem
|
||||
: public IUndoObject
|
||||
{
|
||||
public:
|
||||
CUndoBaseLibraryItem(IBaseLibraryManager *libMgr, CBaseLibraryItem* libItem, bool ignoreChild)
|
||||
: m_libMgr(libMgr)
|
||||
{
|
||||
assert(libItem);
|
||||
assert(libMgr);
|
||||
|
||||
m_itemPath = libItem->GetFullName();
|
||||
|
||||
//serialize the lib item to undo
|
||||
m_undoCtx.node = GetIEditor()->GetSystem()->CreateXmlNode("Undo");
|
||||
m_undoCtx.bIgnoreChilds = ignoreChild;
|
||||
m_undoCtx.bLoading = false; //saving
|
||||
m_undoCtx.bUniqName = false; //don't generate new name
|
||||
m_undoCtx.bCopyPaste = true; //so it won't override guid
|
||||
m_undoCtx.bUndo = true;
|
||||
libItem->Serialize(m_undoCtx);
|
||||
|
||||
//evaluate size
|
||||
XmlString xmlStr = m_undoCtx.node->getXML();
|
||||
m_size = sizeof(CUndoBaseLibraryItem);
|
||||
m_size += static_cast<int>(xmlStr.GetAllocatedMemory());
|
||||
m_size += m_itemPath.length();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
int GetSize() override
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
void Undo(bool bUndo) override
|
||||
{
|
||||
//find the libItem
|
||||
IDataBaseItem *libItem = m_libMgr->FindItemByName(m_itemPath);
|
||||
if (libItem == nullptr)
|
||||
{
|
||||
//the undo stack is not reliable any more..
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
//save for redo
|
||||
if (bUndo)
|
||||
{
|
||||
m_redoCtx.node = GetIEditor()->GetSystem()->CreateXmlNode("Redo");
|
||||
m_redoCtx.bIgnoreChilds = m_undoCtx.bIgnoreChilds;
|
||||
m_redoCtx.bLoading = false; //saving
|
||||
m_redoCtx.bUniqName = false;
|
||||
m_redoCtx.bCopyPaste = true;
|
||||
m_redoCtx.bUndo = true;
|
||||
libItem->Serialize(m_redoCtx);
|
||||
|
||||
XmlString xmlStr = m_redoCtx.node->getXML();
|
||||
m_size += static_cast<int>(xmlStr.GetAllocatedMemory());
|
||||
}
|
||||
|
||||
//load previous saved data
|
||||
m_undoCtx.bLoading = true;
|
||||
libItem->Serialize(m_undoCtx);
|
||||
}
|
||||
|
||||
void Redo() override
|
||||
{
|
||||
//find the libItem
|
||||
IDataBaseItem *libItem = m_libMgr->FindItemByName(m_itemPath);
|
||||
if (libItem == nullptr || m_redoCtx.node == nullptr)
|
||||
{
|
||||
//the undo stack is not reliable any more..
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
m_redoCtx.bLoading = true;
|
||||
libItem->Serialize(m_redoCtx);
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_itemPath;
|
||||
IDataBaseItem::SerializeContext m_undoCtx; //saved before operation
|
||||
IDataBaseItem::SerializeContext m_redoCtx; //saved after operation so used for redo
|
||||
IBaseLibraryManager* m_libMgr;
|
||||
int m_size;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CBaseLibraryItem implementation.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CBaseLibraryItem::CBaseLibraryItem()
|
||||
{
|
||||
m_library = nullptr;
|
||||
GenerateId();
|
||||
m_bModified = false;
|
||||
}
|
||||
|
||||
CBaseLibraryItem::~CBaseLibraryItem()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString CBaseLibraryItem::GetFullName() const
|
||||
{
|
||||
QString name;
|
||||
if (m_library)
|
||||
{
|
||||
name = m_library->GetName() + ".";
|
||||
}
|
||||
name += m_name;
|
||||
return name;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString CBaseLibraryItem::GetGroupName()
|
||||
{
|
||||
QString str = GetName();
|
||||
int p = str.lastIndexOf('.');
|
||||
if (p >= 0)
|
||||
{
|
||||
return str.mid(0, p);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString CBaseLibraryItem::GetShortName()
|
||||
{
|
||||
QString str = GetName();
|
||||
int p = str.lastIndexOf('.');
|
||||
if (p >= 0)
|
||||
{
|
||||
return str.mid(p + 1);
|
||||
}
|
||||
p = str.lastIndexOf('/');
|
||||
if (p >= 0)
|
||||
{
|
||||
return str.mid(p + 1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryItem::SetName(const QString& name)
|
||||
{
|
||||
assert(m_library);
|
||||
if (name == m_name)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString oldName = GetFullName();
|
||||
m_name = name;
|
||||
((CBaseLibraryManager*)m_library->GetManager())->OnRenameItem(this, oldName);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const QString& CBaseLibraryItem::GetName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryItem::GenerateId()
|
||||
{
|
||||
GUID guid = AZ::Uuid::CreateRandom();
|
||||
SetGUID(guid);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryItem::SetGUID(REFGUID guid)
|
||||
{
|
||||
if (m_library)
|
||||
{
|
||||
((CBaseLibraryManager*)m_library->GetManager())->RegisterItem(this, guid);
|
||||
}
|
||||
m_guid = guid;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryItem::Serialize(SerializeContext& ctx)
|
||||
{
|
||||
assert(m_library);
|
||||
|
||||
XmlNodeRef node = ctx.node;
|
||||
if (ctx.bLoading)
|
||||
{
|
||||
QString name = m_name;
|
||||
// Loading
|
||||
node->getAttr("Name", name);
|
||||
|
||||
if (!ctx.bUniqName)
|
||||
{
|
||||
SetName(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetName(GetLibrary()->GetManager()->MakeUniqueItemName(name));
|
||||
}
|
||||
|
||||
if (!ctx.bCopyPaste)
|
||||
{
|
||||
GUID guid;
|
||||
if (node->getAttr("Id", guid))
|
||||
{
|
||||
SetGUID(guid);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Saving.
|
||||
node->setAttr("Name", m_name.toUtf8().data());
|
||||
node->setAttr("Id", m_guid);
|
||||
node->setAttr("Library", GetLibrary()->GetName().toUtf8().data());
|
||||
}
|
||||
m_bModified = false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseLibrary* CBaseLibraryItem::GetLibrary() const
|
||||
{
|
||||
return m_library;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryItem::SetLibrary(CBaseLibrary* pLibrary)
|
||||
{
|
||||
m_library = pLibrary;
|
||||
}
|
||||
|
||||
//! Mark library as modified.
|
||||
void CBaseLibraryItem::SetModified(bool bModified)
|
||||
{
|
||||
m_bModified = bModified;
|
||||
if (m_bModified && m_library != nullptr)
|
||||
{
|
||||
m_library->SetModified(bModified);
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_BASELIBRARYITEM_H
|
||||
#define CRYINCLUDE_EDITOR_BASELIBRARYITEM_H
|
||||
#pragma once
|
||||
|
||||
#include "Include/IDataBaseItem.h"
|
||||
#include "BaseLibrary.h"
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
class CBaseLibrary;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
/** Base class for all items contained in BaseLibraray.
|
||||
*/
|
||||
class EDITOR_CORE_API CBaseLibraryItem
|
||||
: public TRefCountBase<IDataBaseItem>
|
||||
{
|
||||
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
public:
|
||||
CBaseLibraryItem();
|
||||
~CBaseLibraryItem();
|
||||
|
||||
//! Set item name.
|
||||
//! Its virtual, in case you want to override it in derrived item.
|
||||
virtual void SetName(const QString& name);
|
||||
//! Get item name.
|
||||
const QString& GetName() const;
|
||||
|
||||
//! Get full item name, including name of library.
|
||||
//! Name formed by adding dot after name of library
|
||||
//! eg. library Pickup and item PickupRL form full item name: "Pickups.PickupRL".
|
||||
QString GetFullName() const;
|
||||
|
||||
//! Get only nameof group from prototype.
|
||||
QString GetGroupName();
|
||||
//! Get short name of prototype without group.
|
||||
QString GetShortName();
|
||||
|
||||
//! Return Library this item are contained in.
|
||||
//! Item can only be at one library.
|
||||
IDataBaseLibrary* GetLibrary() const;
|
||||
void SetLibrary(CBaseLibrary* pLibrary);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Serialize library item to archive.
|
||||
virtual void Serialize(SerializeContext& ctx);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Generate new unique id for this item.
|
||||
void GenerateId();
|
||||
//! Returns GUID of this material.
|
||||
const GUID& GetGUID() const { return m_guid; }
|
||||
|
||||
//! Mark library as modified.
|
||||
void SetModified(bool bModified = true);
|
||||
//! Check if library was modified.
|
||||
bool IsModified() const { return m_bModified; };
|
||||
|
||||
//! Returns true if the item is registered, otherwise false
|
||||
bool IsRegistered() const { return m_bRegistered; };
|
||||
|
||||
//! Validate item for errors.
|
||||
virtual void Validate() {};
|
||||
|
||||
//! Get number of sub childs.
|
||||
virtual int GetChildCount() const { return 0; }
|
||||
//! Get sub child by index.
|
||||
virtual CBaseLibraryItem* GetChild([[maybe_unused]] int index) const { return nullptr; }
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Gathers resources by this item.
|
||||
virtual void GatherUsedResources([[maybe_unused]] CUsedResources& resources) {};
|
||||
|
||||
//! Get if stored item is enabled
|
||||
virtual bool GetIsEnabled() { return true; };
|
||||
|
||||
|
||||
int IsParticleItem = -1;
|
||||
protected:
|
||||
void SetGUID(REFGUID guid);
|
||||
friend class CBaseLibrary;
|
||||
friend class CBaseLibraryManager;
|
||||
// Name of this prototype.
|
||||
QString m_name;
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
//! Reference to prototype library who contains this prototype.
|
||||
_smart_ptr<CBaseLibrary> m_library;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
//! Every base library item have unique id.
|
||||
GUID m_guid;
|
||||
// True when item modified by editor.
|
||||
bool m_bModified;
|
||||
// True when item registered in manager.
|
||||
bool m_bRegistered = false;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(CBaseLibraryItem*);
|
||||
|
||||
TYPEDEF_AUTOPTR(CBaseLibraryItem);
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_BASELIBRARYITEM_H
|
||||
@@ -1,822 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "BaseLibraryManager.h"
|
||||
|
||||
// Editor
|
||||
#include "BaseLibraryItem.h"
|
||||
#include "ErrorReport.h"
|
||||
#include "Undo/IUndoObject.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CBaseLibraryManager implementation.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CBaseLibraryManager::CBaseLibraryManager()
|
||||
{
|
||||
m_bUniqNameMap = false;
|
||||
m_bUniqGuidMap = true;
|
||||
GetIEditor()->RegisterNotifyListener(this);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CBaseLibraryManager::~CBaseLibraryManager()
|
||||
{
|
||||
ClearAll();
|
||||
GetIEditor()->UnregisterNotifyListener(this);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::ClearAll()
|
||||
{
|
||||
// Delete all items from all libraries.
|
||||
for (int i = 0; i < m_libs.size(); i++)
|
||||
{
|
||||
m_libs[i]->RemoveAllItems();
|
||||
}
|
||||
|
||||
// if we will not copy maps locally then destructors of the elements of
|
||||
// the map will operate on the already invalid map object
|
||||
// see:
|
||||
// CBaseLibraryManager::UnregisterItem()
|
||||
// CBaseLibraryManager::DeleteItem()
|
||||
// CMaterial::~CMaterial()
|
||||
|
||||
ItemsGUIDMap itemsGuidMap;
|
||||
ItemsNameMap itemsNameMap;
|
||||
|
||||
{
|
||||
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
|
||||
std::swap(itemsGuidMap, m_itemsGuidMap);
|
||||
std::swap(itemsNameMap, m_itemsNameMap);
|
||||
|
||||
m_libs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseLibrary* CBaseLibraryManager::FindLibrary(const QString& library)
|
||||
{
|
||||
const int index = FindLibraryIndex(library);
|
||||
return index == -1 ? nullptr : m_libs[index];
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int CBaseLibraryManager::FindLibraryIndex(const QString& library)
|
||||
{
|
||||
QString lib = library;
|
||||
lib.replace('\\', '/');
|
||||
for (int i = 0; i < m_libs.size(); i++)
|
||||
{
|
||||
QString _lib = m_libs[i]->GetFilename();
|
||||
_lib.replace('\\', '/');
|
||||
if (QString::compare(lib, m_libs[i]->GetName(), Qt::CaseInsensitive) == 0 || QString::compare(lib, _lib, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItem* CBaseLibraryManager::FindItem(REFGUID guid) const
|
||||
{
|
||||
CBaseLibraryItem* pMtl = stl::find_in_map(m_itemsGuidMap, guid, nullptr);
|
||||
return pMtl;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::SplitFullItemName(const QString& fullItemName, QString& libraryName, QString& itemName)
|
||||
{
|
||||
int p;
|
||||
p = fullItemName.indexOf('.');
|
||||
if (p < 0 || !QString::compare(fullItemName.mid(p + 1), "mtl", Qt::CaseInsensitive))
|
||||
{
|
||||
libraryName = "";
|
||||
itemName = fullItemName;
|
||||
return;
|
||||
}
|
||||
libraryName = fullItemName.mid(0, p);
|
||||
itemName = fullItemName.mid(p + 1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItem* CBaseLibraryManager::FindItemByName(const QString& fullItemName)
|
||||
{
|
||||
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
|
||||
return stl::find_in_map(m_itemsNameMap, fullItemName, nullptr);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItem* CBaseLibraryManager::LoadItemByName(const QString& fullItemName)
|
||||
{
|
||||
QString libraryName, itemName;
|
||||
SplitFullItemName(fullItemName, libraryName, itemName);
|
||||
|
||||
if (!FindLibrary(libraryName))
|
||||
{
|
||||
LoadLibrary(MakeFilename(libraryName));
|
||||
}
|
||||
|
||||
return FindItemByName(fullItemName);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItem* CBaseLibraryManager::FindItemByName(const char* fullItemName)
|
||||
{
|
||||
return FindItemByName(QString(fullItemName));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItem* CBaseLibraryManager::LoadItemByName(const char* fullItemName)
|
||||
{
|
||||
return LoadItemByName(QString(fullItemName));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItem* CBaseLibraryManager::CreateItem(IDataBaseLibrary* pLibrary)
|
||||
{
|
||||
assert(pLibrary);
|
||||
|
||||
// Add item to this library.
|
||||
TSmartPtr<CBaseLibraryItem> pItem = MakeNewItem();
|
||||
pLibrary->AddItem(pItem);
|
||||
return pItem;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::DeleteItem(IDataBaseItem* pItem)
|
||||
{
|
||||
assert(pItem);
|
||||
|
||||
UnregisterItem((CBaseLibraryItem*)pItem);
|
||||
if (pItem->GetLibrary())
|
||||
{
|
||||
pItem->GetLibrary()->RemoveItem(pItem);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseLibrary* CBaseLibraryManager::LoadLibrary(const QString& inFilename, [[maybe_unused]] bool bReload)
|
||||
{
|
||||
if (auto lib = FindLibrary(inFilename))
|
||||
{
|
||||
return lib;
|
||||
}
|
||||
|
||||
TSmartPtr<CBaseLibrary> pLib = MakeNewLibrary();
|
||||
if (!pLib->Load(MakeFilename(inFilename)))
|
||||
{
|
||||
Error(QObject::tr("Failed to Load Item Library: %1").arg(inFilename).toUtf8().data());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_libs.push_back(pLib);
|
||||
return pLib;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int CBaseLibraryManager::GetModifiedLibraryCount() const
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < m_libs.size(); i++)
|
||||
{
|
||||
if (m_libs[i]->IsModified())
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseLibrary* CBaseLibraryManager::AddLibrary(const QString& library, bool bIsLevelLibrary, bool bIsLoading)
|
||||
{
|
||||
// Make a filename from name of library.
|
||||
QString filename = library;
|
||||
|
||||
if (filename.indexOf(".xml") == -1) // if its already a filename, we don't do anything
|
||||
{
|
||||
filename.replace(' ', '_');
|
||||
if (!bIsLevelLibrary)
|
||||
{
|
||||
filename = MakeFilename(library);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if its the level library it gets saved in the level and should not be concatenated with any other file name
|
||||
filename = filename + ".xml";
|
||||
}
|
||||
}
|
||||
|
||||
IDataBaseLibrary* pBaseLib = FindLibrary(library); //library name
|
||||
if (!pBaseLib)
|
||||
{
|
||||
pBaseLib = FindLibrary(filename); //library file name
|
||||
}
|
||||
if (pBaseLib)
|
||||
{
|
||||
return pBaseLib;
|
||||
}
|
||||
|
||||
CBaseLibrary* lib = MakeNewLibrary();
|
||||
lib->SetName(library);
|
||||
lib->SetLevelLibrary(bIsLevelLibrary);
|
||||
lib->SetFilename(filename, !bIsLoading);
|
||||
// set modified to true, so even empty particle libraries get saved
|
||||
lib->SetModified(true);
|
||||
|
||||
m_libs.push_back(lib);
|
||||
return lib;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString CBaseLibraryManager::MakeFilename(const QString& library)
|
||||
{
|
||||
QString filename = library;
|
||||
filename.replace(' ', '_');
|
||||
filename.replace(".xml", "");
|
||||
|
||||
// make it contain the canonical libs path:
|
||||
Path::ConvertBackSlashToSlash(filename);
|
||||
|
||||
QString LibsPath(GetLibsPath());
|
||||
Path::ConvertBackSlashToSlash(LibsPath);
|
||||
|
||||
if (filename.left(LibsPath.length()).compare(LibsPath, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
filename = filename.mid(LibsPath.length());
|
||||
}
|
||||
|
||||
return LibsPath + filename + ".xml";
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseLibraryManager::IsUniqueFilename(const QString& library)
|
||||
{
|
||||
QString resultPath = MakeFilename(library);
|
||||
CCryFile xmlFile;
|
||||
// If we can find a file for the path
|
||||
return !xmlFile.Open(resultPath.toUtf8().data(), "rb");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::DeleteLibrary(const QString& library, bool forceDeleteLevel)
|
||||
{
|
||||
for (int i = 0; i < m_libs.size(); i++)
|
||||
{
|
||||
if (QString::compare(library, m_libs[i]->GetName(), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
CBaseLibrary* pLibrary = m_libs[i];
|
||||
// Check if not level library, they cannot be deleted.
|
||||
if (!pLibrary->IsLevelLibrary() || forceDeleteLevel)
|
||||
{
|
||||
for (int j = 0; j < pLibrary->GetItemCount(); j++)
|
||||
{
|
||||
UnregisterItem((CBaseLibraryItem*)pLibrary->GetItem(j));
|
||||
}
|
||||
pLibrary->RemoveAllItems();
|
||||
|
||||
if (pLibrary->IsLevelLibrary())
|
||||
{
|
||||
m_pLevelLibrary = nullptr;
|
||||
}
|
||||
m_libs.erase(m_libs.begin() + i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseLibrary* CBaseLibraryManager::GetLibrary(int index) const
|
||||
{
|
||||
assert(index >= 0 && index < m_libs.size());
|
||||
return m_libs[index];
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseLibrary* CBaseLibraryManager::GetLevelLibrary() const
|
||||
{
|
||||
IDataBaseLibrary* pLevelLib = nullptr;
|
||||
|
||||
for (int i = 0; i < GetLibraryCount(); i++)
|
||||
{
|
||||
if (GetLibrary(i)->IsLevelLibrary())
|
||||
{
|
||||
pLevelLib = GetLibrary(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return pLevelLib;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::SaveAllLibs()
|
||||
{
|
||||
for (int i = 0; i < GetLibraryCount(); i++)
|
||||
{
|
||||
// Check if library is modified.
|
||||
IDataBaseLibrary* pLibrary = GetLibrary(i);
|
||||
|
||||
//Level library is saved when the level is saved
|
||||
if (pLibrary->IsLevelLibrary())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (pLibrary->IsModified())
|
||||
{
|
||||
if (pLibrary->Save())
|
||||
{
|
||||
pLibrary->SetModified(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::Serialize(XmlNodeRef& node, bool bLoading)
|
||||
{
|
||||
static const char* const LEVEL_LIBRARY_TAG = "LevelLibrary";
|
||||
|
||||
QString rootNodeName = GetRootNodeName();
|
||||
if (bLoading)
|
||||
{
|
||||
XmlNodeRef libs = node->findChild(rootNodeName.toUtf8().data());
|
||||
if (libs)
|
||||
{
|
||||
for (int i = 0; i < libs->getChildCount(); i++)
|
||||
{
|
||||
// Load only library name.
|
||||
XmlNodeRef libNode = libs->getChild(i);
|
||||
if (strcmp(libNode->getTag(), LEVEL_LIBRARY_TAG) == 0)
|
||||
{
|
||||
if (!m_pLevelLibrary)
|
||||
{
|
||||
QString libName;
|
||||
libNode->getAttr("Name", libName);
|
||||
m_pLevelLibrary = static_cast<CBaseLibrary*>(AddLibrary(libName, true));
|
||||
}
|
||||
m_pLevelLibrary->Serialize(libNode, bLoading);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString libName;
|
||||
if (libNode->getAttr("Name", libName))
|
||||
{
|
||||
// Load this library.
|
||||
if (!FindLibrary(libName))
|
||||
{
|
||||
LoadLibrary(MakeFilename(libName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save all libraries.
|
||||
XmlNodeRef libs = node->newChild(rootNodeName.toUtf8().data());
|
||||
for (int i = 0; i < GetLibraryCount(); i++)
|
||||
{
|
||||
IDataBaseLibrary* pLib = GetLibrary(i);
|
||||
if (pLib->IsLevelLibrary())
|
||||
{
|
||||
// Level libraries are saved in in level.
|
||||
XmlNodeRef libNode = libs->newChild(LEVEL_LIBRARY_TAG);
|
||||
pLib->Serialize(libNode, bLoading);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save only library name.
|
||||
XmlNodeRef libNode = libs->newChild("Library");
|
||||
libNode->setAttr("Name", pLib->GetName().toUtf8().data());
|
||||
}
|
||||
}
|
||||
SaveAllLibs();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString CBaseLibraryManager::MakeUniqueItemName(const QString& srcName, const QString& libName)
|
||||
{
|
||||
// unlikely we'll ever encounter more than 16
|
||||
std::vector<AZStd::string> possibleDuplicates;
|
||||
possibleDuplicates.reserve(16);
|
||||
|
||||
// search for strings in the database that might have a similar name (ignore case)
|
||||
IDataBaseItemEnumerator* pEnum = GetItemEnumerator();
|
||||
for (IDataBaseItem* pItem = pEnum->GetFirst(); pItem != nullptr; pItem = pEnum->GetNext())
|
||||
{
|
||||
//Check if the item is in the target library first.
|
||||
IDataBaseLibrary* itemLibrary = pItem->GetLibrary();
|
||||
QString itemLibraryName;
|
||||
if (itemLibrary)
|
||||
{
|
||||
itemLibraryName = itemLibrary->GetName();
|
||||
}
|
||||
|
||||
// Item is not in the library so there cannot be a naming conflict.
|
||||
if (!libName.isEmpty() && !itemLibraryName.isEmpty() && itemLibraryName != libName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const QString& name = pItem->GetName();
|
||||
if (name.startsWith(srcName, Qt::CaseInsensitive))
|
||||
{
|
||||
possibleDuplicates.push_back(AZStd::string(name.toUtf8().data()));
|
||||
}
|
||||
}
|
||||
pEnum->Release();
|
||||
|
||||
if (possibleDuplicates.empty())
|
||||
{
|
||||
return srcName;
|
||||
}
|
||||
|
||||
std::sort(possibleDuplicates.begin(), possibleDuplicates.end(), [](const AZStd::string& strOne, const AZStd::string& strTwo)
|
||||
{
|
||||
// I can assume size sorting since if the length is different, either one of the two strings doesn't
|
||||
// closely match the string we are trying to duplicate, or it's a bigger number (X1 vs X10)
|
||||
if (strOne.size() != strTwo.size())
|
||||
{
|
||||
return strOne.size() < strTwo.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
return azstricmp(strOne.c_str(), strTwo.c_str()) < 0;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
int num = 0;
|
||||
QString returnValue = srcName;
|
||||
while (num < possibleDuplicates.size() && QString::compare(possibleDuplicates[num].c_str(), returnValue, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
returnValue = QStringLiteral("%1%2%3").arg(srcName).arg("_").arg(num);
|
||||
++num;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::Validate()
|
||||
{
|
||||
IDataBaseItemEnumerator* pEnum = GetItemEnumerator();
|
||||
for (IDataBaseItem* pItem = pEnum->GetFirst(); pItem != nullptr; pItem = pEnum->GetNext())
|
||||
{
|
||||
pItem->Validate();
|
||||
}
|
||||
pEnum->Release();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::RegisterItem(CBaseLibraryItem* pItem, REFGUID newGuid)
|
||||
{
|
||||
assert(pItem);
|
||||
|
||||
bool bNotify = false;
|
||||
|
||||
if (m_bUniqGuidMap)
|
||||
{
|
||||
REFGUID oldGuid = pItem->GetGUID();
|
||||
if (!GuidUtil::IsEmpty(oldGuid))
|
||||
{
|
||||
m_itemsGuidMap.erase(oldGuid);
|
||||
}
|
||||
if (GuidUtil::IsEmpty(newGuid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
CBaseLibraryItem* pOldItem = stl::find_in_map(m_itemsGuidMap, newGuid, nullptr);
|
||||
if (!pOldItem)
|
||||
{
|
||||
pItem->m_guid = newGuid;
|
||||
m_itemsGuidMap[newGuid] = pItem;
|
||||
pItem->m_bRegistered = true;
|
||||
bNotify = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pOldItem != pItem)
|
||||
{
|
||||
ReportDuplicateItem(pItem, pOldItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bUniqNameMap)
|
||||
{
|
||||
QString fullName = pItem->GetFullName();
|
||||
if (!pItem->GetName().isEmpty())
|
||||
{
|
||||
CBaseLibraryItem* pOldItem = static_cast<CBaseLibraryItem*>(FindItemByName(fullName));
|
||||
if (!pOldItem)
|
||||
{
|
||||
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
|
||||
m_itemsNameMap[fullName] = pItem;
|
||||
pItem->m_bRegistered = true;
|
||||
bNotify = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pOldItem != pItem)
|
||||
{
|
||||
ReportDuplicateItem(pItem, pOldItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Notify listeners.
|
||||
if (bNotify)
|
||||
{
|
||||
NotifyItemEvent(pItem, EDB_ITEM_EVENT_ADD);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::RegisterItem(CBaseLibraryItem* pItem)
|
||||
{
|
||||
assert(pItem);
|
||||
|
||||
bool bNotify = false;
|
||||
|
||||
if (m_bUniqGuidMap)
|
||||
{
|
||||
if (GuidUtil::IsEmpty(pItem->GetGUID()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
CBaseLibraryItem* pOldItem = stl::find_in_map(m_itemsGuidMap, pItem->GetGUID(), nullptr);
|
||||
if (!pOldItem)
|
||||
{
|
||||
m_itemsGuidMap[pItem->GetGUID()] = pItem;
|
||||
pItem->m_bRegistered = true;
|
||||
bNotify = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pOldItem != pItem)
|
||||
{
|
||||
ReportDuplicateItem(pItem, pOldItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bUniqNameMap)
|
||||
{
|
||||
QString fullName = pItem->GetFullName();
|
||||
if (!fullName.isEmpty())
|
||||
{
|
||||
CBaseLibraryItem* pOldItem = static_cast<CBaseLibraryItem*>(FindItemByName(fullName));
|
||||
if (!pOldItem)
|
||||
{
|
||||
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
|
||||
m_itemsNameMap[fullName] = pItem;
|
||||
pItem->m_bRegistered = true;
|
||||
bNotify = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pOldItem != pItem)
|
||||
{
|
||||
ReportDuplicateItem(pItem, pOldItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Notify listeners.
|
||||
if (bNotify)
|
||||
{
|
||||
NotifyItemEvent(pItem, EDB_ITEM_EVENT_ADD);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::SetRegisteredFlag(CBaseLibraryItem* pItem, bool bFlag)
|
||||
{
|
||||
pItem->m_bRegistered = bFlag;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::ReportDuplicateItem(CBaseLibraryItem* pItem, CBaseLibraryItem* pOldItem)
|
||||
{
|
||||
QString sLibName;
|
||||
if (pOldItem->GetLibrary())
|
||||
{
|
||||
sLibName = pOldItem->GetLibrary()->GetName();
|
||||
}
|
||||
CErrorRecord err;
|
||||
err.pItem = pItem;
|
||||
err.error = QStringLiteral("Item %1 with duplicate GUID to loaded item %2 ignored").arg(pItem->GetFullName(), pOldItem->GetFullName());
|
||||
GetIEditor()->GetErrorReport()->ReportError(err);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::UnregisterItem(CBaseLibraryItem* pItem)
|
||||
{
|
||||
// Notify listeners.
|
||||
NotifyItemEvent(pItem, EDB_ITEM_EVENT_DELETE);
|
||||
|
||||
if (!pItem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_bUniqGuidMap)
|
||||
{
|
||||
m_itemsGuidMap.erase(pItem->GetGUID());
|
||||
}
|
||||
if (m_bUniqNameMap && !pItem->GetFullName().isEmpty())
|
||||
{
|
||||
AZStd::lock_guard<AZStd::mutex> lock(m_itemsNameMapMutex);
|
||||
auto findIter = m_itemsNameMap.find(pItem->GetFullName());
|
||||
if (findIter != m_itemsNameMap.end())
|
||||
{
|
||||
_smart_ptr<CBaseLibraryItem> item = findIter->second;
|
||||
m_itemsNameMap.erase(findIter);
|
||||
}
|
||||
}
|
||||
|
||||
pItem->m_bRegistered = false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString CBaseLibraryManager::MakeFullItemName(IDataBaseLibrary* pLibrary, const QString& group, const QString& itemName)
|
||||
{
|
||||
assert(pLibrary);
|
||||
QString name = pLibrary->GetName() + ".";
|
||||
if (!group.isEmpty())
|
||||
{
|
||||
name += group + ".";
|
||||
}
|
||||
name += itemName;
|
||||
return name;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::GatherUsedResources(CUsedResources& resources)
|
||||
{
|
||||
IDataBaseItemEnumerator* pEnum = GetItemEnumerator();
|
||||
for (IDataBaseItem* pItem = pEnum->GetFirst(); pItem != nullptr; pItem = pEnum->GetNext())
|
||||
{
|
||||
pItem->GatherUsedResources(resources);
|
||||
}
|
||||
pEnum->Release();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItemEnumerator* CBaseLibraryManager::GetItemEnumerator()
|
||||
{
|
||||
if (m_bUniqNameMap)
|
||||
{
|
||||
return new CDataBaseItemEnumerator<ItemsNameMap>(&m_itemsNameMap);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CDataBaseItemEnumerator<ItemsGUIDMap>(&m_itemsGuidMap);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case eNotify_OnBeginNewScene:
|
||||
SetSelectedItem(nullptr);
|
||||
ClearAll();
|
||||
break;
|
||||
case eNotify_OnBeginSceneOpen:
|
||||
SetSelectedItem(nullptr);
|
||||
ClearAll();
|
||||
break;
|
||||
case eNotify_OnCloseScene:
|
||||
SetSelectedItem(nullptr);
|
||||
ClearAll();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::OnRenameItem(CBaseLibraryItem* pItem, const QString& oldName)
|
||||
{
|
||||
m_itemsNameMapMutex.lock();
|
||||
if (!oldName.isEmpty())
|
||||
{
|
||||
m_itemsNameMap.erase(oldName);
|
||||
}
|
||||
if (!pItem->GetFullName().isEmpty())
|
||||
{
|
||||
m_itemsNameMap[pItem->GetFullName()] = pItem;
|
||||
}
|
||||
m_itemsNameMapMutex.unlock();
|
||||
|
||||
OnItemChanged(pItem);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::AddListener(IDataBaseManagerListener* pListener)
|
||||
{
|
||||
stl::push_back_unique(m_listeners, pListener);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::RemoveListener(IDataBaseManagerListener* pListener)
|
||||
{
|
||||
stl::find_and_erase(m_listeners, pListener);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::NotifyItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event)
|
||||
{
|
||||
// Notify listeners.
|
||||
if (!m_listeners.empty())
|
||||
{
|
||||
for (int i = 0; i < m_listeners.size(); i++)
|
||||
{
|
||||
m_listeners[i]->OnDataBaseItemEvent(pItem, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::OnItemChanged(IDataBaseItem* pItem)
|
||||
{
|
||||
NotifyItemEvent(pItem, EDB_ITEM_EVENT_CHANGED);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::OnUpdateProperties(IDataBaseItem* pItem, bool bRefresh)
|
||||
{
|
||||
NotifyItemEvent(pItem, bRefresh ? EDB_ITEM_EVENT_UPDATE_PROPERTIES
|
||||
: EDB_ITEM_EVENT_UPDATE_PROPERTIES_NO_EDITOR_REFRESH);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseLibraryManager::SetSelectedItem(IDataBaseItem* pItem)
|
||||
{
|
||||
if (m_pSelectedItem == pItem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_pSelectedItem = (CBaseLibraryItem*)pItem;
|
||||
NotifyItemEvent(m_pSelectedItem, EDB_ITEM_EVENT_SELECTED);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItem* CBaseLibraryManager::GetSelectedItem() const
|
||||
{
|
||||
return m_pSelectedItem;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseItem* CBaseLibraryManager::GetSelectedParentItem() const
|
||||
{
|
||||
return m_pSelectedParent;
|
||||
}
|
||||
|
||||
void CBaseLibraryManager::ChangeLibraryOrder(IDataBaseLibrary* lib, unsigned int newLocation)
|
||||
{
|
||||
if (!lib || newLocation >= m_libs.size() || lib == m_libs[newLocation])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_libs.size(); i++)
|
||||
{
|
||||
if (lib == m_libs[i])
|
||||
{
|
||||
_smart_ptr<CBaseLibrary> curLib = m_libs[i];
|
||||
m_libs.erase(m_libs.begin() + i);
|
||||
m_libs.insert(m_libs.begin() + newLocation, curLib);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CBaseLibraryManager::SetLibraryName(CBaseLibrary* lib, const QString& name)
|
||||
{
|
||||
// SetFilename will validate if the name is duplicate with exist libraries.
|
||||
if (lib->SetFilename(MakeFilename(name)))
|
||||
{
|
||||
lib->SetName(name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_BASELIBRARYMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_BASELIBRARYMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include "Include/IBaseLibraryManager.h"
|
||||
#include "Include/IDataBaseItem.h"
|
||||
#include "Include/IDataBaseLibrary.h"
|
||||
#include "Include/IDataBaseManager.h"
|
||||
#include "Util/TRefCountBase.h"
|
||||
#include "Util/GuidUtil.h"
|
||||
#include "BaseLibrary.h"
|
||||
#include "Util/smartptr.h"
|
||||
#include <EditorDefs.h>
|
||||
#include <QtUtil.h>
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
/** Manages all Libraries and Items.
|
||||
*/
|
||||
class SANDBOX_API CBaseLibraryManager
|
||||
: public IBaseLibraryManager
|
||||
{
|
||||
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
public:
|
||||
CBaseLibraryManager();
|
||||
~CBaseLibraryManager();
|
||||
|
||||
//! Clear all libraries.
|
||||
void ClearAll() override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// IDocListener implementation.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Library items.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Make a new item in specified library.
|
||||
IDataBaseItem* CreateItem(IDataBaseLibrary* pLibrary) override;
|
||||
//! Delete item from library and manager.
|
||||
void DeleteItem(IDataBaseItem* pItem) override;
|
||||
|
||||
//! Find Item by its GUID.
|
||||
IDataBaseItem* FindItem(REFGUID guid) const override;
|
||||
IDataBaseItem* FindItemByName(const QString& fullItemName) override;
|
||||
IDataBaseItem* LoadItemByName(const QString& fullItemName) override;
|
||||
virtual IDataBaseItem* FindItemByName(const char* fullItemName);
|
||||
virtual IDataBaseItem* LoadItemByName(const char* fullItemName);
|
||||
|
||||
IDataBaseItemEnumerator* GetItemEnumerator() override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Set item currently selected.
|
||||
void SetSelectedItem(IDataBaseItem* pItem) override;
|
||||
// Get currently selected item.
|
||||
IDataBaseItem* GetSelectedItem() const override;
|
||||
IDataBaseItem* GetSelectedParentItem() const override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Libraries.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Add Item library.
|
||||
IDataBaseLibrary* AddLibrary(const QString& library, bool bIsLevelLibrary = false, bool bIsLoading = true) override;
|
||||
void DeleteLibrary(const QString& library, bool forceDeleteLevel = false) override;
|
||||
//! Get number of libraries.
|
||||
int GetLibraryCount() const override { return static_cast<int>(m_libs.size()); };
|
||||
//! Get number of modified libraries.
|
||||
int GetModifiedLibraryCount() const override;
|
||||
|
||||
//! Get Item library by index.
|
||||
IDataBaseLibrary* GetLibrary(int index) const override;
|
||||
|
||||
//! Get Level Item library.
|
||||
IDataBaseLibrary* GetLevelLibrary() const override;
|
||||
|
||||
//! Find Items Library by name.
|
||||
IDataBaseLibrary* FindLibrary(const QString& library) override;
|
||||
|
||||
//! Find Items Library's index by name.
|
||||
int FindLibraryIndex(const QString& library) override;
|
||||
|
||||
//! Load Items library.
|
||||
IDataBaseLibrary* LoadLibrary(const QString& filename, bool bReload = false) override;
|
||||
|
||||
//! Save all modified libraries.
|
||||
void SaveAllLibs() override;
|
||||
|
||||
//! Serialize property manager.
|
||||
void Serialize(XmlNodeRef& node, bool bLoading) override;
|
||||
|
||||
//! Export items to game.
|
||||
void Export([[maybe_unused]] XmlNodeRef& node) override {};
|
||||
|
||||
//! Returns unique name base on input name.
|
||||
QString MakeUniqueItemName(const QString& name, const QString& libName = "") override;
|
||||
QString MakeFullItemName(IDataBaseLibrary* pLibrary, const QString& group, const QString& itemName) override;
|
||||
|
||||
//! Root node where this library will be saved.
|
||||
QString GetRootNodeName() override = 0;
|
||||
//! Path to libraries in this manager.
|
||||
QString GetLibsPath() override = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Validate library items for errors.
|
||||
void Validate() override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void GatherUsedResources(CUsedResources& resources) override;
|
||||
|
||||
void AddListener(IDataBaseManagerListener* pListener) override;
|
||||
void RemoveListener(IDataBaseManagerListener* pListener) override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RegisterItem(CBaseLibraryItem* pItem, REFGUID newGuid) override;
|
||||
void RegisterItem(CBaseLibraryItem* pItem) override;
|
||||
void UnregisterItem(CBaseLibraryItem* pItem) override;
|
||||
|
||||
// Only Used internally.
|
||||
void OnRenameItem(CBaseLibraryItem* pItem, const QString& oldName) override;
|
||||
|
||||
// Called by items to indicated that they have been modified.
|
||||
// Sends item changed event to listeners.
|
||||
void OnItemChanged(IDataBaseItem* pItem) override;
|
||||
void OnUpdateProperties(IDataBaseItem* pItem, bool bRefresh) override;
|
||||
|
||||
QString MakeFilename(const QString& library);
|
||||
bool IsUniqueFilename(const QString& library) override;
|
||||
|
||||
//CONFETTI BEGIN
|
||||
// Used to change the library item order
|
||||
void ChangeLibraryOrder(IDataBaseLibrary* lib, unsigned int newLocation) override;
|
||||
|
||||
bool SetLibraryName(CBaseLibrary* lib, const QString& name) override;
|
||||
|
||||
protected:
|
||||
void SplitFullItemName(const QString& fullItemName, QString& libraryName, QString& itemName);
|
||||
void NotifyItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event);
|
||||
void SetRegisteredFlag(CBaseLibraryItem* pItem, bool bFlag);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Must be overriden.
|
||||
//! Makes a new Item.
|
||||
virtual CBaseLibraryItem* MakeNewItem() = 0;
|
||||
virtual CBaseLibrary* MakeNewLibrary() = 0;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void ReportDuplicateItem(CBaseLibraryItem* pItem, CBaseLibraryItem* pOldItem);
|
||||
|
||||
protected:
|
||||
bool m_bUniqGuidMap;
|
||||
bool m_bUniqNameMap;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
//! Array of all loaded entity items libraries.
|
||||
std::vector<_smart_ptr<CBaseLibrary> > m_libs;
|
||||
|
||||
// There is always one current level library.
|
||||
TSmartPtr<CBaseLibrary> m_pLevelLibrary;
|
||||
|
||||
// GUID to item map.
|
||||
typedef std::map<GUID, _smart_ptr<CBaseLibraryItem>, guid_less_predicate> ItemsGUIDMap;
|
||||
ItemsGUIDMap m_itemsGuidMap;
|
||||
|
||||
// Case insensitive name to items map.
|
||||
typedef std::map<QString, _smart_ptr<CBaseLibraryItem>, stl::less_stricmp<QString>> ItemsNameMap;
|
||||
ItemsNameMap m_itemsNameMap;
|
||||
AZStd::mutex m_itemsNameMapMutex;
|
||||
|
||||
std::vector<IDataBaseManagerListener*> m_listeners;
|
||||
|
||||
// Currently selected item.
|
||||
_smart_ptr<CBaseLibraryItem> m_pSelectedItem;
|
||||
_smart_ptr<CBaseLibraryItem> m_pSelectedParent;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
template <class TMap>
|
||||
class CDataBaseItemEnumerator
|
||||
: public IDataBaseItemEnumerator
|
||||
{
|
||||
TMap* m_pMap;
|
||||
typename TMap::iterator m_iterator;
|
||||
|
||||
public:
|
||||
CDataBaseItemEnumerator(TMap* pMap)
|
||||
{
|
||||
assert(pMap);
|
||||
m_pMap = pMap;
|
||||
m_iterator = m_pMap->begin();
|
||||
}
|
||||
void Release() override { delete this; };
|
||||
IDataBaseItem* GetFirst() override
|
||||
{
|
||||
m_iterator = m_pMap->begin();
|
||||
if (m_iterator == m_pMap->end())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return m_iterator->second;
|
||||
}
|
||||
IDataBaseItem* GetNext() override
|
||||
{
|
||||
if (m_iterator != m_pMap->end())
|
||||
{
|
||||
m_iterator++;
|
||||
}
|
||||
if (m_iterator == m_pMap->end())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return m_iterator->second;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_BASELIBRARYMANAGER_H
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_CONSOLESCBMFC_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_CONSOLESCBMFC_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QTextEdit>
|
||||
#include <QtWidgets/QPushButton>
|
||||
|
||||
#include "ConsoleSCB.h"
|
||||
#endif
|
||||
|
||||
class QMenu;
|
||||
class ConsoleWidget;
|
||||
class QFocusEvent;
|
||||
|
||||
namespace Ui {
|
||||
class ConsoleMFC;
|
||||
}
|
||||
|
||||
namespace MFC
|
||||
{
|
||||
|
||||
struct ConsoleLine
|
||||
{
|
||||
QString text;
|
||||
bool newLine;
|
||||
};
|
||||
typedef std::deque<ConsoleLine> Lines;
|
||||
|
||||
class ConsoleLineEdit
|
||||
: public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConsoleLineEdit(QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* ev) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent* ev) override;
|
||||
void keyPressEvent(QKeyEvent* ev) override;
|
||||
bool event(QEvent* ev) override;
|
||||
|
||||
signals:
|
||||
void variableEditorRequested();
|
||||
void setWindowTitle(const QString&);
|
||||
|
||||
private:
|
||||
void DisplayHistory(bool bForward);
|
||||
QStringList m_history;
|
||||
unsigned int m_historyIndex;
|
||||
bool m_bReusedHistory;
|
||||
};
|
||||
|
||||
class ConsoleTextEdit
|
||||
: public QTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConsoleTextEdit(QWidget* parent = nullptr);
|
||||
};
|
||||
|
||||
class CConsoleSCB
|
||||
: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CConsoleSCB(QWidget* parent = nullptr);
|
||||
~CConsoleSCB();
|
||||
|
||||
static void RegisterViewClass();
|
||||
void SetInputFocus();
|
||||
void AddToConsole(const QString& text, bool bNewLine);
|
||||
void FlushText();
|
||||
void showPopupAndSetTitle();
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
static CConsoleSCB* GetCreatedInstance();
|
||||
|
||||
static void AddToPendingLines(const QString& text, bool bNewLine); // call this function instead of AddToConsole() until an instance of CConsoleSCB exists to prevent messages from getting lost
|
||||
|
||||
public Q_SLOTS:
|
||||
void OnStyleSettingsChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void showVariableEditor();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::ConsoleMFC> ui;
|
||||
int m_richEditTextLength;
|
||||
|
||||
Lines m_lines;
|
||||
static Lines s_pendingLines;
|
||||
|
||||
QList<QColor> m_colorTable;
|
||||
SEditorSettings::ConsoleColorTheme m_backgroundTheme;
|
||||
};
|
||||
|
||||
} // namespace MFC
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_CONSOLESCB_H
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConsoleMFC</class>
|
||||
<widget class="QWidget" name="Console">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>120</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Console</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="container2" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="button">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="MFC::ConsoleLineEdit" name="lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>MFC::ConsoleLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>ConsoleSCBMFC.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="ConsoleSCB.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "HotTrackingTreeCtrl.h"
|
||||
|
||||
// Qt
|
||||
#include <QMouseEvent>
|
||||
|
||||
|
||||
CHotTrackingTreeCtrl::CHotTrackingTreeCtrl(QWidget* parent)
|
||||
: QTreeWidget(parent)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
m_hHoverItem = nullptr;
|
||||
}
|
||||
|
||||
void CHotTrackingTreeCtrl::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
QTreeWidgetItem* hItem = itemAt(event->pos());
|
||||
|
||||
if (m_hHoverItem != nullptr)
|
||||
{
|
||||
QFont font = m_hHoverItem->font(0);
|
||||
font.setBold(false);
|
||||
m_hHoverItem->setFont(0, font);
|
||||
m_hHoverItem = nullptr;
|
||||
}
|
||||
|
||||
if (hItem != nullptr)
|
||||
{
|
||||
QFont font = hItem->font(0);
|
||||
font.setBold(true);
|
||||
hItem->setFont(0, font);
|
||||
m_hHoverItem = hItem;
|
||||
}
|
||||
|
||||
QTreeWidget::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
#include <Controls/moc_HotTrackingTreeCtrl.cpp>
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_HOTTRACKINGTREECTRL_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_HOTTRACKINGTREECTRL_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QTreeWidget>
|
||||
#endif
|
||||
|
||||
class CHotTrackingTreeCtrl
|
||||
: public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CHotTrackingTreeCtrl(QWidget* parent = 0);
|
||||
virtual ~CHotTrackingTreeCtrl(){};
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
private:
|
||||
QTreeWidgetItem* m_hHoverItem;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_HOTTRACKINGTREECTRL_H
|
||||
@@ -1,567 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "ImageListCtrl.h"
|
||||
|
||||
// Qt
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CImageListCtrl::CImageListCtrl(QWidget* parent)
|
||||
: QAbstractItemView(parent)
|
||||
, m_itemSize(60, 60)
|
||||
, m_borderSize(4, 4)
|
||||
, m_style(DefaultStyle)
|
||||
{
|
||||
setItemDelegate(new QImageListDelegate(this));
|
||||
setAutoFillBackground(false);
|
||||
|
||||
QPalette p = palette();
|
||||
p.setColor(QPalette::Highlight, QColor(255, 55, 50));
|
||||
setPalette(p);
|
||||
|
||||
horizontalScrollBar()->setRange(0, 0);
|
||||
verticalScrollBar()->setRange(0, 0);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CImageListCtrl::~CImageListCtrl()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CImageListCtrl::ListStyle CImageListCtrl::Style() const
|
||||
{
|
||||
return m_style;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CImageListCtrl::SetStyle(ListStyle style)
|
||||
{
|
||||
m_style = style;
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const QSize& CImageListCtrl::ItemSize() const
|
||||
{
|
||||
return m_itemSize;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CImageListCtrl::SetItemSize(QSize size)
|
||||
{
|
||||
Q_ASSERT(size.isValid());
|
||||
m_itemSize = size;
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const QSize& CImageListCtrl::BorderSize() const
|
||||
{
|
||||
return m_borderSize;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CImageListCtrl::SetBorderSize(QSize size)
|
||||
{
|
||||
Q_ASSERT(size.isValid());
|
||||
m_borderSize = size;
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QModelIndexList CImageListCtrl::ItemsInRect(const QRect& rect) const
|
||||
{
|
||||
QModelIndexList list;
|
||||
|
||||
if (!model())
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
QHash<int, QRect>::const_iterator i;
|
||||
QHash<int, QRect>::const_iterator c = m_geometry.cend();
|
||||
for (i = m_geometry.cbegin(); i != c; ++i)
|
||||
{
|
||||
if (i.value().intersects(rect))
|
||||
{
|
||||
list << model()->index(i.key(), 0, rootIndex());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CImageListCtrl::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
QAbstractItemView::paintEvent(event);
|
||||
|
||||
if (!model())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int rowCount = model()->rowCount();
|
||||
|
||||
if (m_geometry.isEmpty() && rowCount)
|
||||
{
|
||||
updateGeometries();
|
||||
}
|
||||
|
||||
QPainter painter(viewport());
|
||||
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
|
||||
painter.setBackground(palette().window());
|
||||
painter.setFont(font());
|
||||
|
||||
QStyleOptionViewItem option;
|
||||
option.palette = palette();
|
||||
option.font = font();
|
||||
option.fontMetrics = fontMetrics();
|
||||
option.decorationAlignment = Qt::AlignCenter;
|
||||
|
||||
const QRect visibleRect(QPoint(horizontalOffset(), verticalOffset()), viewport()->contentsRect().size());
|
||||
|
||||
painter.translate(-horizontalOffset(), -verticalOffset());
|
||||
|
||||
for (int r = 0; r < rowCount; ++r)
|
||||
{
|
||||
const QModelIndex& index = model()->index(r, 0, rootIndex());
|
||||
|
||||
option.rect = m_geometry.value(r);
|
||||
if (!option.rect.intersects(visibleRect))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
option.state = QStyle::State_None;
|
||||
|
||||
if (selectionModel()->isSelected(index))
|
||||
{
|
||||
option.state |= QStyle::State_Selected;
|
||||
}
|
||||
|
||||
if (currentIndex() == index)
|
||||
{
|
||||
option.state |= QStyle::State_HasFocus;
|
||||
}
|
||||
|
||||
QAbstractItemDelegate* idt = itemDelegate(index);
|
||||
idt->paint(&painter, option, index);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CImageListCtrl::rowsInserted(const QModelIndex& parent, int start, int end)
|
||||
{
|
||||
QAbstractItemView::rowsInserted(parent, start, end);
|
||||
|
||||
if (isVisible())
|
||||
{
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CImageListCtrl::updateGeometries()
|
||||
{
|
||||
ClearItemGeometries();
|
||||
|
||||
if (!model())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int rowCount = model()->rowCount();
|
||||
|
||||
const int nPageHorz = viewport()->width();
|
||||
const int nPageVert = viewport()->height();
|
||||
|
||||
if (nPageHorz == 0 || nPageVert == 0 || rowCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int x = m_borderSize.width();
|
||||
int y = m_borderSize.height();
|
||||
|
||||
const int nItemWidth = m_itemSize.width() + m_borderSize.width();
|
||||
|
||||
if (m_style == HorizontalStyle)
|
||||
{
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
m_geometry.insert(row, QRect(QPoint(x, y), m_itemSize));
|
||||
x += nItemWidth;
|
||||
}
|
||||
|
||||
horizontalScrollBar()->setPageStep(viewport()->width());
|
||||
horizontalScrollBar()->setRange(0, x - viewport()->width());
|
||||
}
|
||||
else
|
||||
{
|
||||
const int nTextHeight = fontMetrics().height();
|
||||
const int nItemHeight = m_itemSize.height() + m_borderSize.height() + nTextHeight;
|
||||
|
||||
int nNumOfHorzItems = nPageHorz / nItemWidth;
|
||||
if (nNumOfHorzItems <= 0)
|
||||
{
|
||||
nNumOfHorzItems = 1;
|
||||
}
|
||||
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
m_geometry.insert(row, QRect(QPoint(x, y), m_itemSize));
|
||||
|
||||
if ((row + 1) % nNumOfHorzItems == 0)
|
||||
{
|
||||
y += nItemHeight;
|
||||
x = m_borderSize.width();
|
||||
}
|
||||
else
|
||||
{
|
||||
x += nItemWidth;
|
||||
}
|
||||
}
|
||||
|
||||
verticalScrollBar()->setPageStep(viewport()->height());
|
||||
verticalScrollBar()->setRange(0, (y + nItemHeight) - viewport()->height());
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QModelIndex CImageListCtrl::indexAt(const QPoint& point) const
|
||||
{
|
||||
if (!model())
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
const QPoint p = point +
|
||||
QPoint(horizontalOffset(), verticalOffset());
|
||||
|
||||
QHash<int, QRect>::const_iterator i;
|
||||
QHash<int, QRect>::const_iterator c = m_geometry.cend();
|
||||
for (i = m_geometry.cbegin(); i != c; ++i)
|
||||
{
|
||||
if (i.value().contains(p))
|
||||
{
|
||||
return model()->index(i.key(), 0, rootIndex());
|
||||
}
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CImageListCtrl::scrollTo(const QModelIndex& index, ScrollHint hint)
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QRect rect = m_geometry.value(index.row());
|
||||
|
||||
switch (hint)
|
||||
{
|
||||
case EnsureVisible:
|
||||
if (horizontalOffset() > rect.right())
|
||||
{
|
||||
horizontalScrollBar()->setValue(rect.left());
|
||||
}
|
||||
else if ((horizontalOffset() + viewport()->width()) < rect.left())
|
||||
{
|
||||
horizontalScrollBar()->setValue(rect.right() - viewport()->width());
|
||||
}
|
||||
|
||||
if (verticalOffset() > rect.bottom())
|
||||
{
|
||||
verticalScrollBar()->setValue(rect.top());
|
||||
}
|
||||
else if ((verticalOffset() + viewport()->height()) < rect.top())
|
||||
{
|
||||
verticalScrollBar()->setValue(rect.bottom() - viewport()->height());
|
||||
}
|
||||
break;
|
||||
|
||||
case PositionAtTop:
|
||||
horizontalScrollBar()->setValue(rect.left());
|
||||
verticalScrollBar()->setValue(rect.top());
|
||||
break;
|
||||
|
||||
case PositionAtBottom:
|
||||
horizontalScrollBar()->setValue(rect.right() - viewport()->width());
|
||||
verticalScrollBar()->setValue(rect.bottom() - viewport()->height());
|
||||
break;
|
||||
|
||||
case PositionAtCenter:
|
||||
horizontalScrollBar()->setValue(rect.center().x() - (viewport()->width() / 2));
|
||||
verticalScrollBar()->setValue(rect.center().y() - (viewport()->height() / 2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QRect CImageListCtrl::visualRect(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
return QRect();
|
||||
}
|
||||
|
||||
|
||||
if (!m_geometry.contains(index.row()))
|
||||
{
|
||||
return QRect();
|
||||
}
|
||||
|
||||
return m_geometry.value(index.row())
|
||||
.translated(-horizontalOffset(), -verticalOffset());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QRect CImageListCtrl::ItemGeometry(const QModelIndex& index) const
|
||||
{
|
||||
Q_ASSERT(index.model() == model());
|
||||
Q_ASSERT(m_geometry.contains(index.row()));
|
||||
|
||||
return m_geometry.value(index.row());
|
||||
}
|
||||
|
||||
void CImageListCtrl::SetItemGeometry(const QModelIndex& index, const QRect& rect)
|
||||
{
|
||||
Q_ASSERT(index.model() == model());
|
||||
m_geometry.insert(index.row(), rect);
|
||||
update(rect);
|
||||
}
|
||||
|
||||
void CImageListCtrl::ClearItemGeometries()
|
||||
{
|
||||
m_geometry.clear();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int CImageListCtrl::horizontalOffset() const
|
||||
{
|
||||
return horizontalScrollBar()->value();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int CImageListCtrl::verticalOffset() const
|
||||
{
|
||||
return verticalScrollBar()->value();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CImageListCtrl::isIndexHidden([[maybe_unused]] const QModelIndex& index) const
|
||||
{
|
||||
return false; /* not supported */
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QModelIndex CImageListCtrl::moveCursor(CursorAction cursorAction, [[maybe_unused]] Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
if (!model())
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
const int rowCount = model()->rowCount();
|
||||
|
||||
if (0 == rowCount)
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
switch (cursorAction)
|
||||
{
|
||||
case MoveHome:
|
||||
return model()->index(0, 0, rootIndex());
|
||||
|
||||
case MoveEnd:
|
||||
return model()->index(rowCount - 1, 0, rootIndex());
|
||||
|
||||
case MovePrevious:
|
||||
{
|
||||
QModelIndex current = currentIndex();
|
||||
if (current.isValid())
|
||||
{
|
||||
return model()->index((current.row() - 1) % rowCount, 0, rootIndex());
|
||||
}
|
||||
} break;
|
||||
|
||||
case MoveNext:
|
||||
{
|
||||
QModelIndex current = currentIndex();
|
||||
if (current.isValid())
|
||||
{
|
||||
return model()->index((current.row() + 1) % rowCount, 0, rootIndex());
|
||||
}
|
||||
} break;
|
||||
|
||||
case MoveUp:
|
||||
case MoveDown:
|
||||
case MoveLeft:
|
||||
case MoveRight:
|
||||
case MovePageUp:
|
||||
case MovePageDown:
|
||||
/* TODO */
|
||||
break;
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CImageListCtrl::setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags)
|
||||
{
|
||||
if (!model())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QRect lrect =
|
||||
rect.translated(horizontalOffset(), verticalOffset());
|
||||
|
||||
QHash<int, QRect>::const_iterator i;
|
||||
QHash<int, QRect>::const_iterator c = m_geometry.cend();
|
||||
for (i = m_geometry.cbegin(); i != c; ++i)
|
||||
{
|
||||
if (i.value().intersects(lrect))
|
||||
{
|
||||
selectionModel()->select(model()->index(i.key(), 0, rootIndex()), flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QRegion CImageListCtrl::visualRegionForSelection(const QItemSelection& selection) const
|
||||
{
|
||||
QRegion region;
|
||||
|
||||
foreach(const QModelIndex &index, selection.indexes())
|
||||
{
|
||||
region += visualRect(index);
|
||||
}
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QImageListDelegate::QImageListDelegate(QObject* parent)
|
||||
: QAbstractItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void QImageListDelegate::paint(QPainter* painter,
|
||||
const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->setFont(option.font);
|
||||
|
||||
if (option.rect.isValid())
|
||||
{
|
||||
painter->setClipRect(option.rect);
|
||||
}
|
||||
|
||||
QRect innerRect = option.rect.adjusted(1, 1, -1, -1);
|
||||
|
||||
QRect textRect(innerRect.left(), innerRect.bottom() - option.fontMetrics.height(),
|
||||
innerRect.width(), option.fontMetrics.height() + 1);
|
||||
|
||||
/* fill item background */
|
||||
|
||||
painter->fillRect(option.rect, option.palette.color(QPalette::Base));
|
||||
|
||||
/* draw image */
|
||||
|
||||
if (index.data(Qt::DecorationRole).isValid())
|
||||
{
|
||||
const QPixmap& p = index.data(Qt::DecorationRole).value<QPixmap>();
|
||||
if (p.isNull() || p.size() == QSize(1, 1))
|
||||
{
|
||||
emit InvalidPixmapGenerated(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->drawPixmap(innerRect, p);
|
||||
}
|
||||
}
|
||||
|
||||
/* draw text */
|
||||
|
||||
const QColor trColor = option.palette.color(QPalette::Shadow);
|
||||
painter->fillRect(textRect, (option.state & QStyle::State_Selected) ?
|
||||
trColor.lighter() : trColor);
|
||||
|
||||
if (option.state & QStyle::State_Selected)
|
||||
{
|
||||
painter->setPen(QPen(option.palette.color(QPalette::HighlightedText)));
|
||||
|
||||
QFont f = painter->font();
|
||||
f.setBold(true);
|
||||
painter->setFont(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->setPen(QPen(option.palette.color(QPalette::Text)));
|
||||
}
|
||||
|
||||
painter->drawText(textRect, index.data(Qt::DisplayRole).toString(),
|
||||
QTextOption(option.decorationAlignment));
|
||||
|
||||
painter->setPen(QPen(option.palette.color(QPalette::Shadow)));
|
||||
painter->drawRect(textRect);
|
||||
|
||||
/* draw border */
|
||||
|
||||
if (option.state & QStyle::State_Selected)
|
||||
{
|
||||
QPen pen(option.palette.color(QPalette::Highlight));
|
||||
pen.setWidth(2);
|
||||
painter->setPen(pen);
|
||||
painter->drawRect(innerRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->setPen(QPen(option.palette.color(QPalette::Shadow)));
|
||||
painter->drawRect(option.rect);
|
||||
}
|
||||
|
||||
if (option.state & QStyle::State_HasFocus)
|
||||
{
|
||||
QPen pen(Qt::DotLine);
|
||||
pen.setColor(option.palette.color(QPalette::AlternateBase));
|
||||
painter->setPen(pen);
|
||||
painter->drawRect(option.rect);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QSize QImageListDelegate::sizeHint(const QStyleOptionViewItem& option,
|
||||
[[maybe_unused]] const QModelIndex& index) const
|
||||
{
|
||||
return option.rect.size();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QVector<int> QImageListDelegate::paintingRoles() const
|
||||
{
|
||||
return QVector<int>() << Qt::DecorationRole << Qt::DisplayRole;
|
||||
}
|
||||
|
||||
#include <Controls/moc_ImageListCtrl.cpp>
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_IMAGELISTCTRL_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_IMAGELISTCTRL_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QAbstractItemView>
|
||||
|
||||
#include <QHash>
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Custom control to display list of images.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CImageListCtrl
|
||||
: public QAbstractItemView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum ListStyle
|
||||
{
|
||||
DefaultStyle,
|
||||
HorizontalStyle
|
||||
};
|
||||
|
||||
public:
|
||||
CImageListCtrl(QWidget* parent = nullptr);
|
||||
~CImageListCtrl();
|
||||
|
||||
ListStyle Style() const;
|
||||
void SetStyle(ListStyle style);
|
||||
|
||||
const QSize& ItemSize() const;
|
||||
void SetItemSize(QSize size);
|
||||
|
||||
const QSize& BorderSize() const;
|
||||
void SetBorderSize(QSize size);
|
||||
|
||||
// Get all items inside specified rectangle.
|
||||
QModelIndexList ItemsInRect(const QRect& rect) const;
|
||||
|
||||
QModelIndex indexAt(const QPoint& point) const override;
|
||||
void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible) override;
|
||||
QRect visualRect(const QModelIndex& index) const override;
|
||||
|
||||
protected:
|
||||
QRect ItemGeometry(const QModelIndex& index) const;
|
||||
void SetItemGeometry(const QModelIndex& index, const QRect& rect);
|
||||
void ClearItemGeometries();
|
||||
|
||||
int horizontalOffset() const override;
|
||||
int verticalOffset() const override;
|
||||
bool isIndexHidden(const QModelIndex& index) const override;
|
||||
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
|
||||
void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags) override;
|
||||
QRegion visualRegionForSelection(const QItemSelection& selection) const override;
|
||||
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void rowsInserted(const QModelIndex& parent, int start, int end) override;
|
||||
|
||||
void updateGeometries() override;
|
||||
|
||||
private:
|
||||
QHash<int, QRect> m_geometry;
|
||||
QSize m_itemSize;
|
||||
QSize m_borderSize;
|
||||
ListStyle m_style;
|
||||
};
|
||||
|
||||
class QImageListDelegate
|
||||
: public QAbstractItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void InvalidPixmapGenerated(const QModelIndex& index) const;
|
||||
public:
|
||||
QImageListDelegate(QObject* parent = nullptr);
|
||||
|
||||
void paint(QPainter* painter,
|
||||
const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const override;
|
||||
|
||||
QSize sizeHint(const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const override;
|
||||
|
||||
QVector<int> paintingRoles() const override;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_IMAGELISTCTRL_H
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "MultiMonHelper.h"
|
||||
|
||||
// Qt
|
||||
#include <QScreen>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void ClipOrCenterRectToMonitor(QRect *prc, const UINT flags)
|
||||
{
|
||||
const QScreen* currentScreen = nullptr;
|
||||
QRect rc;
|
||||
|
||||
Q_ASSERT(prc);
|
||||
|
||||
const auto screens = qApp->screens();
|
||||
for (auto screen : screens)
|
||||
{
|
||||
if (screen->geometry().contains(prc->center()))
|
||||
{
|
||||
currentScreen = screen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentScreen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int w = prc->width();
|
||||
const int h = prc->height();
|
||||
|
||||
if (flags & MONITOR_WORKAREA)
|
||||
{
|
||||
rc = currentScreen->availableGeometry();
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = currentScreen->geometry();
|
||||
}
|
||||
|
||||
// center or clip the passed rect to the monitor rect
|
||||
if (flags & MONITOR_CENTER)
|
||||
{
|
||||
prc->setLeft(rc.left() + (rc.right() - rc.left() - w) / 2);
|
||||
prc->setTop(rc.top() + (rc.bottom() - rc.top() - h) / 2);
|
||||
prc->setRight(prc->left() + w);
|
||||
prc->setBottom(prc->top() + h);
|
||||
}
|
||||
else
|
||||
{
|
||||
prc->setLeft(qMax(rc.left(), qMin(rc.right() - w, prc->left())));
|
||||
prc->setTop(qMax(rc.top(), qMin(rc.bottom() - h, prc->top())));
|
||||
prc->setRight(prc->left() + w);
|
||||
prc->setBottom(prc->top() + h);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_MULTIMONHELPER_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_MULTIMONHELPER_H
|
||||
#pragma once
|
||||
|
||||
// Taken from: http://msdn.microsoft.com/en-us/library/dd162826(v=vs.85).aspx
|
||||
#define MONITOR_CENTER 0x0001 // center rect to monitor
|
||||
#define MONITOR_CLIP 0x0000 // clip rect to monitor
|
||||
#define MONITOR_WORKAREA 0x0002 // use monitor work area
|
||||
#define MONITOR_AREA 0x0000 // use monitor entire area
|
||||
|
||||
//
|
||||
// ClipOrCenterRectToMonitor
|
||||
//
|
||||
// The most common problem apps have when running on a
|
||||
// multimonitor system is that they "clip" or "pin" windows
|
||||
// based on the SM_CXSCREEN and SM_CYSCREEN system metrics.
|
||||
// Because of app compatibility reasons these system metrics
|
||||
// return the size of the primary monitor.
|
||||
//
|
||||
// This shows how you use the multi-monitor functions
|
||||
// to do the same thing.
|
||||
//
|
||||
// params:
|
||||
// prc : pointer to QRect to modify
|
||||
// flags : some combination of the MONITOR_* flags above
|
||||
//
|
||||
// example:
|
||||
//
|
||||
// ClipOrCenterRectToMonitor(&aRect, MONITOR_CLIP | MONITOR_WORKAREA);
|
||||
//
|
||||
// Takes parameter pointer to RECT "aRect" and flags MONITOR_CLIP | MONITOR_WORKAREA
|
||||
// This will modify aRect without resizing it so that it remains within the on-screen boundaries.
|
||||
void ClipOrCenterRectToMonitor(QRect *prc, const UINT flags);
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_MULTIMONHELPER_H
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "NumberCtrl.h"
|
||||
|
||||
|
||||
QNumberCtrl::QNumberCtrl(QWidget* parent)
|
||||
: QDoubleSpinBox(parent)
|
||||
, m_bMouseDown(false)
|
||||
, m_bDragged(false)
|
||||
, m_bUndoEnabled(false)
|
||||
, m_prevValue(0)
|
||||
{
|
||||
connect(this, &QAbstractSpinBox::editingFinished, this, &QNumberCtrl::onEditingFinished);
|
||||
}
|
||||
|
||||
void QNumberCtrl::changeEvent(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::EnabledChange)
|
||||
{
|
||||
setButtonSymbols(isEnabled() ? UpDownArrows : NoButtons);
|
||||
}
|
||||
|
||||
QDoubleSpinBox::changeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void QNumberCtrl::SetRange(double newMin, double newMax)
|
||||
{
|
||||
// Avoid setting this value if its close to the current value, because otherwise qt will pump events into the queue to redraw/etc.
|
||||
if ( (!AZ::IsClose(this->minimum(), newMin, DBL_EPSILON)) || (!AZ::IsClose(this->maximum(), newMax, DBL_EPSILON)) )
|
||||
{
|
||||
setRange(newMin, newMax);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QNumberCtrl::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
emit mousePressed();
|
||||
|
||||
m_bMouseDown = true;
|
||||
m_bDragged = false;
|
||||
m_mousePos = event->pos();
|
||||
|
||||
if (m_bUndoEnabled && !CUndo::IsRecording())
|
||||
{
|
||||
GetIEditor()->BeginUndo();
|
||||
}
|
||||
|
||||
emit dragStarted();
|
||||
|
||||
grabMouse();
|
||||
}
|
||||
|
||||
QDoubleSpinBox::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void QNumberCtrl::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
QDoubleSpinBox::mouseReleaseEvent(event);
|
||||
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_bMouseDown = m_bDragged = false;
|
||||
|
||||
emit valueUpdated();
|
||||
emit valueChanged();
|
||||
|
||||
if (m_bUndoEnabled && CUndo::IsRecording())
|
||||
{
|
||||
GetIEditor()->AcceptUndo(m_undoText);
|
||||
}
|
||||
|
||||
emit dragFinished();
|
||||
|
||||
releaseMouse();
|
||||
|
||||
m_prevValue = value();
|
||||
|
||||
emit mouseReleased();
|
||||
}
|
||||
}
|
||||
|
||||
void QNumberCtrl::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
QDoubleSpinBox::mousePressEvent(event);
|
||||
|
||||
if (m_bMouseDown)
|
||||
{
|
||||
m_bDragged = true;
|
||||
|
||||
int dy = event->pos().y() - m_mousePos.y();
|
||||
setValue(value() - singleStep() * dy);
|
||||
|
||||
emit valueUpdated();
|
||||
|
||||
m_mousePos = event->pos();
|
||||
}
|
||||
}
|
||||
|
||||
void QNumberCtrl::EnableUndo(const QString& undoText)
|
||||
{
|
||||
m_undoText = undoText;
|
||||
m_bUndoEnabled = true;
|
||||
}
|
||||
|
||||
void QNumberCtrl::focusInEvent(QFocusEvent* event)
|
||||
{
|
||||
m_prevValue = value();
|
||||
QDoubleSpinBox::focusInEvent(event);
|
||||
}
|
||||
|
||||
void QNumberCtrl::onEditingFinished()
|
||||
{
|
||||
bool undo = m_bUndoEnabled && !CUndo::IsRecording() && m_prevValue != value();
|
||||
if (undo)
|
||||
{
|
||||
GetIEditor()->BeginUndo();
|
||||
}
|
||||
|
||||
emit valueUpdated();
|
||||
emit valueChanged();
|
||||
|
||||
if (undo)
|
||||
{
|
||||
GetIEditor()->AcceptUndo(m_undoText);
|
||||
}
|
||||
|
||||
m_prevValue = value();
|
||||
}
|
||||
|
||||
#include <Controls/moc_NumberCtrl.cpp>
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_NUMBERCTRL_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_NUMBERCTRL_H
|
||||
#pragma once
|
||||
|
||||
// NumberCtrl.h : header file
|
||||
//
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QDoubleSpinBox>
|
||||
#endif
|
||||
|
||||
class QNumberCtrl
|
||||
: public QDoubleSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QNumberCtrl(QWidget* parent = nullptr);
|
||||
|
||||
bool IsDragging() const { return m_bDragged; }
|
||||
|
||||
//! If called will enable undo with given text when control is modified.
|
||||
void EnableUndo(const QString& undoText);
|
||||
void SetRange(double newMin, double maxRange);
|
||||
|
||||
Q_SIGNALS:
|
||||
void dragStarted();
|
||||
void dragFinished();
|
||||
|
||||
void valueUpdated();
|
||||
void valueChanged();
|
||||
|
||||
void mouseReleased();
|
||||
void mousePressed();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent* event) override;
|
||||
void focusInEvent(QFocusEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
|
||||
private:
|
||||
void onEditingFinished();
|
||||
void onValueChanged(double d);
|
||||
|
||||
bool m_bMouseDown;
|
||||
bool m_bDragged;
|
||||
QPoint m_mousePos;
|
||||
bool m_bUndoEnabled;
|
||||
double m_prevValue;
|
||||
QString m_undoText;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_NUMBERCTRL_H
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "TextEditorCtrl.h"
|
||||
|
||||
|
||||
// CTextEditorCtrl
|
||||
CTextEditorCtrl::CTextEditorCtrl(QWidget* pParent)
|
||||
: QTextEdit(pParent)
|
||||
{
|
||||
m_bModified = true;
|
||||
|
||||
QFont font;
|
||||
font.setFamily("Courier New");
|
||||
font.setFixedPitch(true);
|
||||
font.setPointSize(10);
|
||||
setFont(font);
|
||||
|
||||
setLineWrapMode(NoWrap);
|
||||
|
||||
connect(this, &QTextEdit::textChanged, this, &CTextEditorCtrl::OnChange);
|
||||
}
|
||||
|
||||
CTextEditorCtrl::~CTextEditorCtrl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// CTextEditorCtrl message handlers
|
||||
|
||||
void CTextEditorCtrl::LoadFile(const QString& sFileName)
|
||||
{
|
||||
if (m_filename == sFileName)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_filename = sFileName;
|
||||
|
||||
clear();
|
||||
|
||||
CCryFile file(sFileName.toUtf8().data(), "rb");
|
||||
if (file.Open(sFileName.toUtf8().data(), "rb"))
|
||||
{
|
||||
size_t length = file.GetLength();
|
||||
|
||||
QByteArray text;
|
||||
text.resize(static_cast<int>(length));
|
||||
file.ReadRaw(text.data(), length);
|
||||
|
||||
setPlainText(text);
|
||||
}
|
||||
|
||||
m_bModified = false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTextEditorCtrl::SaveFile(const QString& sFileName)
|
||||
{
|
||||
if (sFileName.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CFileUtil::OverwriteFile(sFileName.toUtf8().data()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QFile file(sFileName);
|
||||
file.open(QFile::WriteOnly);
|
||||
|
||||
file.write(toPlainText().toUtf8());
|
||||
|
||||
m_bModified = false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTextEditorCtrl::OnChange()
|
||||
{
|
||||
|
||||
m_bModified = true;
|
||||
}
|
||||
|
||||
#include <Controls/moc_TextEditorCtrl.cpp>
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_TEXTEDITORCTRL_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_TEXTEDITORCTRL_H
|
||||
#pragma once
|
||||
|
||||
// CTextEditorCtrl
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QTextEdit>
|
||||
#endif
|
||||
|
||||
class CTextEditorCtrl
|
||||
: public QTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CTextEditorCtrl(QWidget* pParent = nullptr);
|
||||
virtual ~CTextEditorCtrl();
|
||||
|
||||
void LoadFile(const QString& sFileName);
|
||||
void SaveFile(const QString& sFileName);
|
||||
QString GetFilename() const { return m_filename; }
|
||||
|
||||
bool IsModified() const { return m_bModified; }
|
||||
|
||||
//! Must be called after OnChange message.
|
||||
void OnChange();
|
||||
|
||||
protected:
|
||||
QString m_filename;
|
||||
bool m_bModified;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_TEXTEDITORCTRL_H
|
||||
@@ -1,322 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_TREECTRLUTILS_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_TREECTRLUTILS_H
|
||||
#pragma once
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace TreeCtrlUtils
|
||||
{
|
||||
template <typename P>
|
||||
class TreeItemIterator
|
||||
: public P
|
||||
{
|
||||
public:
|
||||
typedef P Traits;
|
||||
|
||||
//iterator traits, required by STL
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef HTREEITEM value_type;
|
||||
typedef HTREEITEM* pointer;
|
||||
typedef HTREEITEM& reference;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
TreeItemIterator()
|
||||
: pCtrl(0)
|
||||
, hItem(0) {}
|
||||
explicit TreeItemIterator(const P& traits)
|
||||
: P(traits)
|
||||
, pCtrl(0)
|
||||
, hItem(0) {}
|
||||
TreeItemIterator(const TreeItemIterator& other)
|
||||
: P(other)
|
||||
, pCtrl(other.pCtrl)
|
||||
, hItem(other.hItem) {}
|
||||
TreeItemIterator(CTreeCtrl* pCtrl, HTREEITEM hItem)
|
||||
: pCtrl(pCtrl)
|
||||
, hItem(hItem) {}
|
||||
TreeItemIterator(CTreeCtrl* pCtrl, HTREEITEM hItem, const P& traits)
|
||||
: P(traits)
|
||||
, pCtrl(pCtrl)
|
||||
, hItem(hItem) {}
|
||||
|
||||
HTREEITEM operator*() {return hItem; }
|
||||
bool operator==(const TreeItemIterator& other) const {return pCtrl == other.pCtrl && hItem == other.hItem; }
|
||||
bool operator!=(const TreeItemIterator& other) const {return pCtrl != other.pCtrl || hItem != other.hItem; }
|
||||
|
||||
TreeItemIterator& operator++()
|
||||
{
|
||||
HTREEITEM hNextItem = 0;
|
||||
if (RecurseToChildren(hItem))
|
||||
{
|
||||
hNextItem = (pCtrl ? pCtrl->GetChildItem(hItem) : 0);
|
||||
}
|
||||
while (pCtrl && hItem && !hNextItem)
|
||||
{
|
||||
hNextItem = pCtrl->GetNextSiblingItem(hItem);
|
||||
if (!hNextItem)
|
||||
{
|
||||
hItem = pCtrl->GetParentItem(hItem);
|
||||
}
|
||||
}
|
||||
hItem = hNextItem;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TreeItemIterator operator++(int) {TreeItemIterator old = *this; ++(*this); return old; }
|
||||
|
||||
CTreeCtrl* pCtrl;
|
||||
HTREEITEM hItem;
|
||||
};
|
||||
|
||||
class NonRecursiveTreeItemIteratorTraits
|
||||
{
|
||||
public:
|
||||
bool RecurseToChildren(HTREEITEM hItem) {return false; }
|
||||
};
|
||||
typedef TreeItemIterator<NonRecursiveTreeItemIteratorTraits> NonRecursiveTreeItemIterator;
|
||||
|
||||
class RecursiveTreeItemIteratorTraits
|
||||
{
|
||||
public:
|
||||
bool RecurseToChildren(HTREEITEM hItem) {return true; }
|
||||
};
|
||||
typedef TreeItemIterator<RecursiveTreeItemIteratorTraits> RecursiveTreeItemIterator;
|
||||
|
||||
inline RecursiveTreeItemIterator BeginTreeItemsRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
|
||||
{
|
||||
if (hItem == 0)
|
||||
{
|
||||
hItem = (pCtrl ? pCtrl->GetRootItem() : 0);
|
||||
}
|
||||
return RecursiveTreeItemIterator(pCtrl, hItem);
|
||||
}
|
||||
|
||||
inline RecursiveTreeItemIterator EndTreeItemsRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
|
||||
{
|
||||
HTREEITEM hEndItem = 0;
|
||||
HTREEITEM hParent = hItem;
|
||||
do
|
||||
{
|
||||
if (hParent)
|
||||
{
|
||||
hEndItem = pCtrl->GetNextSiblingItem(hParent);
|
||||
}
|
||||
hParent = (pCtrl && hParent ? pCtrl->GetParentItem(hParent) : 0);
|
||||
}
|
||||
while (hParent && !hEndItem);
|
||||
return RecursiveTreeItemIterator(pCtrl, hEndItem);
|
||||
}
|
||||
|
||||
inline NonRecursiveTreeItemIterator BeginTreeItemsNonRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
|
||||
{
|
||||
if (hItem == 0)
|
||||
{
|
||||
hItem = (pCtrl ? pCtrl->GetRootItem() : 0);
|
||||
}
|
||||
if (hItem)
|
||||
{
|
||||
hItem = pCtrl->GetChildItem(hItem);
|
||||
}
|
||||
return NonRecursiveTreeItemIterator(pCtrl, hItem);
|
||||
}
|
||||
|
||||
inline NonRecursiveTreeItemIterator EndTreeItemsNonRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
|
||||
{
|
||||
HTREEITEM hEndItem = 0;
|
||||
HTREEITEM hParent = 0;
|
||||
while (hParent && !hEndItem)
|
||||
{
|
||||
hParent = (pCtrl && hItem ? pCtrl->GetParentItem(hItem) : 0);
|
||||
if (hParent)
|
||||
{
|
||||
hEndItem = pCtrl->GetNextSiblingItem(hParent);
|
||||
}
|
||||
}
|
||||
return NonRecursiveTreeItemIterator(pCtrl, hEndItem);
|
||||
}
|
||||
|
||||
template <typename T, typename P>
|
||||
class TreeItemDataIterator
|
||||
{
|
||||
public:
|
||||
typedef T Type;
|
||||
typedef TreeItemIterator<P> InternalIterator;
|
||||
|
||||
//iterator traits, required by STL
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef Type* value_type;
|
||||
typedef Type** pointer;
|
||||
typedef Type*& reference;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
TreeItemDataIterator() {}
|
||||
TreeItemDataIterator(const TreeItemDataIterator& other)
|
||||
: iterator(other.iterator) {AdvanceToValidIterator(); }
|
||||
explicit TreeItemDataIterator(const InternalIterator& iterator)
|
||||
: iterator(iterator) {AdvanceToValidIterator(); }
|
||||
|
||||
Type* operator*() {return reinterpret_cast<Type*>(iterator.pCtrl->GetItemData(iterator.hItem)); }
|
||||
bool operator==(const TreeItemDataIterator& other) const {return iterator == other.iterator; }
|
||||
bool operator!=(const TreeItemDataIterator& other) const {return iterator != other.iterator; }
|
||||
|
||||
HTREEITEM GetTreeItem() {return iterator.hItem; }
|
||||
|
||||
TreeItemDataIterator& operator++()
|
||||
{
|
||||
++iterator;
|
||||
AdvanceToValidIterator();
|
||||
return *this;
|
||||
}
|
||||
|
||||
TreeItemDataIterator operator++(int) {TreeItemDataIterator old = *this; ++(*this); return old; }
|
||||
|
||||
private:
|
||||
void AdvanceToValidIterator()
|
||||
{
|
||||
while (iterator.pCtrl && iterator.hItem && !iterator.pCtrl->GetItemData(iterator.hItem))
|
||||
{
|
||||
++iterator;
|
||||
}
|
||||
}
|
||||
|
||||
InternalIterator iterator;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class RecursiveItemDataIteratorType
|
||||
{
|
||||
public: typedef TreeItemDataIterator<T, RecursiveTreeItemIteratorTraits> type;
|
||||
};
|
||||
template <typename T>
|
||||
inline TreeItemDataIterator<T, RecursiveTreeItemIteratorTraits> BeginTreeItemDataRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
|
||||
{
|
||||
return TreeItemDataIterator<T, RecursiveTreeItemIteratorTraits>(BeginTreeItemsRecursive(pCtrl, hItem));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline TreeItemDataIterator<T, RecursiveTreeItemIteratorTraits> EndTreeItemDataRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
|
||||
{
|
||||
return TreeItemDataIterator<T, RecursiveTreeItemIteratorTraits>(EndTreeItemsRecursive(pCtrl, hItem));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class NonRecursiveItemDataIteratorType
|
||||
{
|
||||
typedef TreeItemDataIterator<T, NonRecursiveTreeItemIteratorTraits> type;
|
||||
};
|
||||
template <typename T>
|
||||
inline TreeItemDataIterator<T, NonRecursiveTreeItemIteratorTraits> BeginTreeItemDataNonRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
|
||||
{
|
||||
return TreeItemDataIterator<T, NonRecursiveTreeItemIteratorTraits>(BeginTreeItemsNonRecursive(pCtrl, hItem));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline TreeItemDataIterator<T, NonRecursiveTreeItemIteratorTraits> EndTreeItemDataNonRecursive(CTreeCtrl* pCtrl, HTREEITEM hItem = 0)
|
||||
{
|
||||
return TreeItemDataIterator<T, NonRecursiveTreeItemIteratorTraits>(EndTreeItemsNonRecursive(pCtrl, hItem));
|
||||
}
|
||||
|
||||
class SelectedTreeItemIterator
|
||||
{
|
||||
public:
|
||||
SelectedTreeItemIterator()
|
||||
: pCtrl(0)
|
||||
, hItem(0) {}
|
||||
SelectedTreeItemIterator(const SelectedTreeItemIterator& other)
|
||||
: pCtrl(other.pCtrl)
|
||||
, hItem(other.hItem) {}
|
||||
SelectedTreeItemIterator(CXTTreeCtrl* pCtrl, HTREEITEM hItem)
|
||||
: pCtrl(pCtrl)
|
||||
, hItem(hItem) {}
|
||||
|
||||
HTREEITEM operator*() {return hItem; }
|
||||
bool operator==(const SelectedTreeItemIterator& other) const {return pCtrl == other.pCtrl && hItem == other.hItem; }
|
||||
bool operator!=(const SelectedTreeItemIterator& other) const {return pCtrl != other.pCtrl || hItem != other.hItem; }
|
||||
|
||||
SelectedTreeItemIterator& operator++()
|
||||
{
|
||||
hItem = (pCtrl ? pCtrl->GetNextSelectedItem(hItem) : 0);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
SelectedTreeItemIterator operator++(int) {SelectedTreeItemIterator old = *this; ++(*this); return old; }
|
||||
|
||||
CXTTreeCtrl* pCtrl;
|
||||
HTREEITEM hItem;
|
||||
};
|
||||
|
||||
SelectedTreeItemIterator BeginSelectedTreeItems(CXTTreeCtrl* pCtrl)
|
||||
{
|
||||
return SelectedTreeItemIterator(pCtrl, (pCtrl ? pCtrl->GetFirstSelectedItem() : 0));
|
||||
}
|
||||
|
||||
SelectedTreeItemIterator EndSelectedTreeItems(CXTTreeCtrl* pCtrl)
|
||||
{
|
||||
return SelectedTreeItemIterator(pCtrl, 0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class SelectedTreeItemDataIterator
|
||||
{
|
||||
public:
|
||||
typedef T Type;
|
||||
typedef SelectedTreeItemIterator InternalIterator;
|
||||
|
||||
SelectedTreeItemDataIterator() {}
|
||||
SelectedTreeItemDataIterator(const SelectedTreeItemDataIterator& other)
|
||||
: iterator(other.iterator) {AdvanceToValidIterator(); }
|
||||
explicit SelectedTreeItemDataIterator(const InternalIterator& iterator)
|
||||
: iterator(iterator) {AdvanceToValidIterator(); }
|
||||
|
||||
Type* operator*() {return reinterpret_cast<Type*>(iterator.pCtrl->GetItemData(iterator.hItem)); }
|
||||
bool operator==(const SelectedTreeItemDataIterator& other) const {return iterator == other.iterator; }
|
||||
bool operator!=(const SelectedTreeItemDataIterator& other) const {return iterator != other.iterator; }
|
||||
|
||||
HTREEITEM GetTreeItem() {return iterator.hItem; }
|
||||
|
||||
SelectedTreeItemDataIterator& operator++()
|
||||
{
|
||||
++iterator;
|
||||
AdvanceToValidIterator();
|
||||
return *this;
|
||||
}
|
||||
|
||||
SelectedTreeItemDataIterator operator++(int) {SelectedTreeItemDataIterator old = *this; ++(*this); return old; }
|
||||
|
||||
private:
|
||||
void AdvanceToValidIterator()
|
||||
{
|
||||
while (iterator.pCtrl && iterator.hItem && !iterator.pCtrl->GetItemData(iterator.hItem))
|
||||
{
|
||||
++iterator;
|
||||
}
|
||||
}
|
||||
|
||||
InternalIterator iterator;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
SelectedTreeItemDataIterator<T> BeginSelectedTreeItemData(CXTTreeCtrl* pCtrl)
|
||||
{
|
||||
return SelectedTreeItemDataIterator<T>(BeginSelectedTreeItems(pCtrl));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SelectedTreeItemDataIterator<T> EndSelectedTreeItemData(CXTTreeCtrl* pCtrl)
|
||||
{
|
||||
return SelectedTreeItemDataIterator<T>(EndSelectedTreeItems(pCtrl));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_TREECTRLUTILS_H
|
||||
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "DeepSelection.h"
|
||||
|
||||
// Editor
|
||||
#include "Objects/BaseObject.h"
|
||||
|
||||
|
||||
//! Functor for sorting selected objects on deep selection mode.
|
||||
struct NearDistance
|
||||
{
|
||||
NearDistance(){}
|
||||
bool operator()(const CDeepSelection::RayHitObject& lhs, const CDeepSelection::RayHitObject& rhs) const
|
||||
{
|
||||
return lhs.distance < rhs.distance;
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
CDeepSelection::CDeepSelection()
|
||||
: m_Mode(DSM_NONE)
|
||||
, m_previousMode(DSM_NONE)
|
||||
, m_CandidateObjectCount(0)
|
||||
, m_CurrentSelectedPos(-1)
|
||||
{
|
||||
m_LastPickPoint = QPoint(-1, -1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
CDeepSelection::~CDeepSelection()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDeepSelection::Reset(bool bResetLastPick)
|
||||
{
|
||||
for (int i = 0; i < m_CandidateObjectCount; ++i)
|
||||
{
|
||||
m_RayHitObjects[i].object->ClearFlags(OBJFLAG_NO_HITTEST);
|
||||
}
|
||||
|
||||
m_CandidateObjectCount = 0;
|
||||
m_CurrentSelectedPos = -1;
|
||||
|
||||
m_RayHitObjects.clear();
|
||||
|
||||
if (bResetLastPick)
|
||||
{
|
||||
m_LastPickPoint = QPoint(-1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDeepSelection::AddObject(float distance, CBaseObject* pObj)
|
||||
{
|
||||
m_RayHitObjects.push_back(RayHitObject(distance, pObj));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CDeepSelection::OnCycling (const QPoint& pt)
|
||||
{
|
||||
QPoint diff = m_LastPickPoint - pt;
|
||||
LONG epsilon = 2;
|
||||
m_LastPickPoint = pt;
|
||||
|
||||
if (abs(diff.x()) < epsilon && abs(diff.y()) < epsilon)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDeepSelection::ExcludeHitTest(int except)
|
||||
{
|
||||
int nExcept = except % m_CandidateObjectCount;
|
||||
|
||||
for (int i = 0; i < m_CandidateObjectCount; ++i)
|
||||
{
|
||||
m_RayHitObjects[i].object->SetFlags(OBJFLAG_NO_HITTEST);
|
||||
}
|
||||
|
||||
m_RayHitObjects[nExcept].object->ClearFlags(OBJFLAG_NO_HITTEST);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int CDeepSelection::CollectCandidate(float fMinDistance, float fRange)
|
||||
{
|
||||
m_CandidateObjectCount = 0;
|
||||
|
||||
if (!m_RayHitObjects.empty())
|
||||
{
|
||||
std::sort(m_RayHitObjects.begin(), m_RayHitObjects.end(), NearDistance());
|
||||
|
||||
for (std::vector<CDeepSelection::RayHitObject>::iterator itr = m_RayHitObjects.begin();
|
||||
itr != m_RayHitObjects.end(); ++itr)
|
||||
{
|
||||
if (itr->distance - fMinDistance < fRange)
|
||||
{
|
||||
++m_CandidateObjectCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_CandidateObjectCount;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
CBaseObject* CDeepSelection::GetCandidateObject(int index)
|
||||
{
|
||||
m_CurrentSelectedPos = index % m_CandidateObjectCount;
|
||||
|
||||
return m_RayHitObjects[m_CurrentSelectedPos].object;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//!
|
||||
void CDeepSelection::SetMode(EDeepSelectionMode mode)
|
||||
{
|
||||
m_previousMode = m_Mode;
|
||||
m_Mode = mode;
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Deep Selection Header
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_EDITMODE_DEEPSELECTION_H
|
||||
#define CRYINCLUDE_EDITOR_EDITMODE_DEEPSELECTION_H
|
||||
#pragma once
|
||||
|
||||
class CBaseObject;
|
||||
|
||||
//! Deep Selection
|
||||
//! Additional output information of HitContext on using "deep selection mode".
|
||||
//! At the deep selection mode, it supports second selection pass for easy
|
||||
//! selection on crowded area with two different method.
|
||||
//! One is to show pop menu of candidate objects list. Another is the cyclic
|
||||
//! selection on pick clicking.
|
||||
class CDeepSelection
|
||||
: public _i_reference_target_t
|
||||
{
|
||||
public:
|
||||
//! Deep Selection Mode Definition
|
||||
enum EDeepSelectionMode
|
||||
{
|
||||
DSM_NONE = 0, // Not using deep selection.
|
||||
DSM_POP = 1, // Deep selection mode with pop context menu.
|
||||
DSM_CYCLE = 2 // Deep selection mode with cyclic selection on each clinking same point.
|
||||
};
|
||||
|
||||
//! Subclass for container of the selected object with hit distance.
|
||||
struct RayHitObject
|
||||
{
|
||||
RayHitObject(float dist, CBaseObject* pObj)
|
||||
: distance(dist)
|
||||
, object(pObj)
|
||||
{
|
||||
}
|
||||
|
||||
float distance;
|
||||
CBaseObject* object;
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
CDeepSelection();
|
||||
virtual ~CDeepSelection();
|
||||
|
||||
void Reset(bool bResetLastPick = false);
|
||||
void AddObject(float distance, CBaseObject* pObj);
|
||||
//! Check if clicking point is same position with last position,
|
||||
//! to decide whether to continue cycling mode.
|
||||
bool OnCycling (const QPoint& pt);
|
||||
//! All objects in list are excluded for hitting test except one, current selection.
|
||||
void ExcludeHitTest(int except);
|
||||
void SetMode(EDeepSelectionMode mode);
|
||||
inline EDeepSelectionMode GetMode() const { return m_Mode; }
|
||||
inline EDeepSelectionMode GetPreviousMode() const { return m_previousMode; }
|
||||
//! Collect object in the deep selection range. The distance from the minimum
|
||||
//! distance is less than deep selection range.
|
||||
int CollectCandidate(float fMinDistance, float fRange);
|
||||
//! Return the candidate object in index position, then it is to be current
|
||||
//! selection position.
|
||||
CBaseObject* GetCandidateObject(int index);
|
||||
//! Return the current selection position that is update in "GetCandidateObject"
|
||||
//! function call.
|
||||
inline int GetCurrentSelectPos() const { return m_CurrentSelectedPos; }
|
||||
//! Return the number of objects in the deep selection range.
|
||||
inline int GetCandidateObjectCount() const { return m_CandidateObjectCount; }
|
||||
|
||||
private:
|
||||
//! Current mode
|
||||
EDeepSelectionMode m_Mode;
|
||||
EDeepSelectionMode m_previousMode;
|
||||
//! Last picking point to check whether cyclic selection continue.
|
||||
QPoint m_LastPickPoint;
|
||||
//! List of the selected objects with ray hitting
|
||||
std::vector<RayHitObject> m_RayHitObjects;
|
||||
int m_CandidateObjectCount;
|
||||
int m_CurrentSelectedPos;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_EDITMODE_DEEPSELECTION_H
|
||||
@@ -1,542 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "EditorPanelUtils.h"
|
||||
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
// Qt
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
// Editor
|
||||
#include "IEditorPanelUtils.h"
|
||||
#include "Objects/EntityObject.h"
|
||||
#include "CryEditDoc.h"
|
||||
#include "ViewManager.h"
|
||||
#include "Controls/QToolTipWidget.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
|
||||
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323f
|
||||
#endif
|
||||
|
||||
|
||||
struct ToolTip
|
||||
{
|
||||
bool isValid;
|
||||
QString title;
|
||||
QString content;
|
||||
QString specialContent;
|
||||
QString disabledContent;
|
||||
};
|
||||
|
||||
// internal implementation for better compile times - should also never be used externally, use IParticleEditorUtils interface for that.
|
||||
class CEditorPanelUtils_Impl
|
||||
: public IEditorPanelUtils
|
||||
{
|
||||
public:
|
||||
void SetViewportDragOperation(void(* dropCallback)(CViewport* viewport, int dragPointX, int dragPointY, void* custom), void* custom) override
|
||||
{
|
||||
for (int i = 0; i < GetIEditor()->GetViewManager()->GetViewCount(); i++)
|
||||
{
|
||||
GetIEditor()->GetViewManager()->GetView(i)->SetGlobalDropCallback(dropCallback, custom);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
int PreviewWindow_GetDisplaySettingsDebugFlags(CDisplaySettings* settings) override
|
||||
{
|
||||
CRY_ASSERT(settings);
|
||||
return settings->GetDebugFlags();
|
||||
}
|
||||
|
||||
void PreviewWindow_SetDisplaySettingsDebugFlags(CDisplaySettings* settings, int flags) override
|
||||
{
|
||||
CRY_ASSERT(settings);
|
||||
settings->SetDebugFlags(flags);
|
||||
}
|
||||
|
||||
protected:
|
||||
QVector<HotKey> hotkeys;
|
||||
bool m_hotkeysAreEnabled;
|
||||
public:
|
||||
|
||||
bool HotKey_Import() override
|
||||
{
|
||||
QVector<QPair<QString, QString> > keys;
|
||||
QString filepath = QFileDialog::getOpenFileName(nullptr, "Select shortcut configuration to load",
|
||||
QString(), "HotKey Config Files (*.hkxml)");
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QXmlStreamReader stream(&file);
|
||||
bool result = true;
|
||||
|
||||
while (!stream.isEndDocument())
|
||||
{
|
||||
if (stream.isStartElement())
|
||||
{
|
||||
if (stream.name() == "HotKey")
|
||||
{
|
||||
QPair<QString, QString> key;
|
||||
QXmlStreamAttributes att = stream.attributes();
|
||||
for (QXmlStreamAttribute attr : att)
|
||||
{
|
||||
if (attr.name().compare(QLatin1String("path"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
key.first = attr.value().toString();
|
||||
}
|
||||
if (attr.name().compare(QLatin1String("sequence"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
key.second = attr.value().toString();
|
||||
}
|
||||
}
|
||||
if (!key.first.isEmpty())
|
||||
{
|
||||
keys.push_back(key); // we allow blank key sequences for unassigned shortcuts
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false; //but not blank paths!
|
||||
}
|
||||
}
|
||||
}
|
||||
stream.readNext();
|
||||
}
|
||||
file.close();
|
||||
|
||||
if (result)
|
||||
{
|
||||
HotKey_BuildDefaults();
|
||||
for (QPair<QString, QString> key : keys)
|
||||
{
|
||||
for (int j = 0; j < hotkeys.count(); j++)
|
||||
{
|
||||
if (hotkeys[j].path.compare(key.first, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
hotkeys[j].SetPath(key.first.toStdString().c_str());
|
||||
hotkeys[j].SetSequenceFromString(key.second.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void HotKey_Export() override
|
||||
{
|
||||
auto settingDir = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / "Editor" / "Plugins" / "ParticleEditorPlugin" / "settings";
|
||||
QString filepath = QFileDialog::getSaveFileName(nullptr, "Select shortcut configuration to load", settingDir.c_str(), "HotKey Config Files (*.hkxml)");
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QXmlStreamWriter stream(&file);
|
||||
stream.setAutoFormatting(true);
|
||||
stream.writeStartDocument();
|
||||
stream.writeStartElement("HotKeys");
|
||||
|
||||
for (HotKey key : hotkeys)
|
||||
{
|
||||
stream.writeStartElement("HotKey");
|
||||
stream.writeAttribute("path", key.path);
|
||||
stream.writeAttribute("sequence", key.sequence.toString());
|
||||
stream.writeEndElement();
|
||||
}
|
||||
stream.writeEndElement();
|
||||
stream.writeEndDocument();
|
||||
file.close();
|
||||
}
|
||||
|
||||
QKeySequence HotKey_GetShortcut(const char* path) override
|
||||
{
|
||||
for (HotKey combo : hotkeys)
|
||||
{
|
||||
if (combo.IsMatch(path))
|
||||
{
|
||||
return combo.sequence;
|
||||
}
|
||||
}
|
||||
return QKeySequence();
|
||||
}
|
||||
|
||||
bool HotKey_IsPressed(const QKeyEvent* event, const char* path) override
|
||||
{
|
||||
if (!m_hotkeysAreEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
unsigned int keyInt = 0;
|
||||
//Capture any modifiers
|
||||
Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
|
||||
if (modifiers & Qt::ShiftModifier)
|
||||
{
|
||||
keyInt += Qt::SHIFT;
|
||||
}
|
||||
if (modifiers & Qt::ControlModifier)
|
||||
{
|
||||
keyInt += Qt::CTRL;
|
||||
}
|
||||
if (modifiers & Qt::AltModifier)
|
||||
{
|
||||
keyInt += Qt::ALT;
|
||||
}
|
||||
if (modifiers & Qt::MetaModifier)
|
||||
{
|
||||
keyInt += Qt::META;
|
||||
}
|
||||
//Capture any key
|
||||
keyInt += event->key();
|
||||
|
||||
QString t0 = QKeySequence(keyInt).toString();
|
||||
QString t1 = HotKey_GetShortcut(path).toString();
|
||||
|
||||
//if strings match then shortcut is pressed
|
||||
if (t1.compare(t0, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HotKey_IsPressed(const QShortcutEvent* event, const char* path) override
|
||||
{
|
||||
if (!m_hotkeysAreEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString t0 = event->key().toString();
|
||||
QString t1 = HotKey_GetShortcut(path).toString();
|
||||
|
||||
//if strings match then shortcut is pressed
|
||||
if (t1.compare(t0, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HotKey_LoadExisting() override
|
||||
{
|
||||
QSettings settings("O3DE", "O3DE");
|
||||
QString group = "Hotkeys/";
|
||||
|
||||
HotKey_BuildDefaults();
|
||||
|
||||
int size = settings.beginReadArray(group);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
QPair<QString, QString> hotkey;
|
||||
hotkey.first = settings.value("name").toString();
|
||||
hotkey.second = settings.value("keySequence").toString();
|
||||
if (!hotkey.first.isEmpty())
|
||||
{
|
||||
for (int j = 0; j < hotkeys.count(); j++)
|
||||
{
|
||||
if (hotkeys[j].path.compare(hotkey.first, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
hotkeys[j].SetPath(hotkey.first.toStdString().c_str());
|
||||
hotkeys[j].SetSequenceFromString(hotkey.second.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
settings.endArray();
|
||||
if (hotkeys.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void HotKey_SaveCurrent() override
|
||||
{
|
||||
QSettings settings("O3DE", "O3DE");
|
||||
QString group = "Hotkeys/";
|
||||
settings.remove("Hotkeys/");
|
||||
settings.sync();
|
||||
settings.beginWriteArray(group);
|
||||
int saveIndex = 0;
|
||||
for (HotKey key : hotkeys)
|
||||
{
|
||||
if (!key.path.isEmpty())
|
||||
{
|
||||
settings.setArrayIndex(saveIndex++);
|
||||
settings.setValue("name", key.path);
|
||||
settings.setValue("keySequence", key.sequence.toString());
|
||||
}
|
||||
}
|
||||
settings.endArray();
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
void HotKey_BuildDefaults() override
|
||||
{
|
||||
m_hotkeysAreEnabled = true;
|
||||
QVector<QPair<QString, QString> > keys;
|
||||
while (hotkeys.count() > 0)
|
||||
{
|
||||
hotkeys.takeAt(0);
|
||||
}
|
||||
|
||||
//MENU SELECTION SHORTCUTS////////////////////////////////////////////////
|
||||
keys.push_back(QPair<QString, QString>("Menus.File Menu", "Alt+F"));
|
||||
keys.push_back(QPair<QString, QString>("Menus.Edit Menu", "Alt+E"));
|
||||
keys.push_back(QPair<QString, QString>("Menus.View Menu", "Alt+V"));
|
||||
//FILE MENU SHORTCUTS/////////////////////////////////////////////////////
|
||||
keys.push_back(QPair<QString, QString>("File Menu.Create new emitter", "Ctrl+N"));
|
||||
keys.push_back(QPair<QString, QString>("File Menu.Create new library", "Ctrl+Shift+N"));
|
||||
keys.push_back(QPair<QString, QString>("File Menu.Create new folder", ""));
|
||||
keys.push_back(QPair<QString, QString>("File Menu.Import", "Ctrl+I"));
|
||||
keys.push_back(QPair<QString, QString>("File Menu.Import level library", "Ctrl+Shift+I"));
|
||||
keys.push_back(QPair<QString, QString>("File Menu.Save", "Ctrl+S"));
|
||||
keys.push_back(QPair<QString, QString>("File Menu.Close", "Ctrl+Q"));
|
||||
//EDIT MENU SHORTCUTS/////////////////////////////////////////////////////
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Copy", "Ctrl+C"));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Paste", "Ctrl+V"));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Duplicate", "Ctrl+D"));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Undo", "Ctrl+Z"));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Redo", "Ctrl+Shift+Z"));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Group", "Ctrl+Alt+O"));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Ungroup", "Ctrl+Alt+P"));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Rename", "Ctrl+R"));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Reset", ""));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Edit Hotkeys", ""));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Assign to selected", "Ctrl+Space"));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Insert Comment", "Ctrl+Alt+M"));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Enable/Disable Emitter", "Ctrl+E"));
|
||||
keys.push_back(QPair<QString, QString>("File Menu.Enable All", ""));
|
||||
keys.push_back(QPair<QString, QString>("File Menu.Disable All", ""));
|
||||
keys.push_back(QPair<QString, QString>("Edit Menu.Delete", "Del"));
|
||||
//VIEW MENU SHORTCUTS/////////////////////////////////////////////////////
|
||||
keys.push_back(QPair<QString, QString>("View Menu.Reset Layout", ""));
|
||||
//PLAYBACK CONTROL////////////////////////////////////////////////////////
|
||||
keys.push_back(QPair<QString, QString>("Previewer.Play/Pause Toggle", "Space"));
|
||||
keys.push_back(QPair<QString, QString>("Previewer.Step forward through time", "c"));
|
||||
keys.push_back(QPair<QString, QString>("Previewer.Loop Toggle", "z"));
|
||||
keys.push_back(QPair<QString, QString>("Previewer.Reset Playback", "x"));
|
||||
keys.push_back(QPair<QString, QString>("Previewer.Focus", "Ctrl+F"));
|
||||
keys.push_back(QPair<QString, QString>("Previewer.Zoom In", "w"));
|
||||
keys.push_back(QPair<QString, QString>("Previewer.Zoom Out", "s"));
|
||||
keys.push_back(QPair<QString, QString>("Previewer.Pan Left", "a"));
|
||||
keys.push_back(QPair<QString, QString>("Previewer.Pan Right", "d"));
|
||||
|
||||
for (QPair<QString, QString> key : keys)
|
||||
{
|
||||
unsigned int index = hotkeys.count();
|
||||
hotkeys.push_back(HotKey());
|
||||
hotkeys[index].SetPath(key.first.toStdString().c_str());
|
||||
hotkeys[index].SetSequenceFromString(key.second.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void HotKey_SetKeys(QVector<HotKey> keys) override
|
||||
{
|
||||
hotkeys = keys;
|
||||
}
|
||||
|
||||
QVector<HotKey> HotKey_GetKeys() override
|
||||
{
|
||||
return hotkeys;
|
||||
}
|
||||
|
||||
QString HotKey_GetPressedHotkey(const QKeyEvent* event) override
|
||||
{
|
||||
if (!m_hotkeysAreEnabled)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
for (HotKey key : hotkeys)
|
||||
{
|
||||
if (HotKey_IsPressed(event, key.path.toUtf8()))
|
||||
{
|
||||
return key.path;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
QString HotKey_GetPressedHotkey(const QShortcutEvent* event) override
|
||||
{
|
||||
if (!m_hotkeysAreEnabled)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
for (HotKey key : hotkeys)
|
||||
{
|
||||
if (HotKey_IsPressed(event, key.path.toUtf8()))
|
||||
{
|
||||
return key.path;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
//building the default hotkey list re-enables hotkeys
|
||||
//do not use this when rebuilding the default list is a possibility.
|
||||
void HotKey_SetEnabled(bool val) override
|
||||
{
|
||||
m_hotkeysAreEnabled = val;
|
||||
}
|
||||
|
||||
bool HotKey_IsEnabled() const override
|
||||
{
|
||||
return m_hotkeysAreEnabled;
|
||||
}
|
||||
|
||||
protected:
|
||||
QMap<QString, ToolTip> m_tooltips;
|
||||
|
||||
void ToolTip_ParseNode(XmlNodeRef node)
|
||||
{
|
||||
if (QString(node->getTag()).compare("tooltip", Qt::CaseInsensitive) != 0)
|
||||
{
|
||||
unsigned int childCount = node->getChildCount();
|
||||
|
||||
for (unsigned int i = 0; i < childCount; i++)
|
||||
{
|
||||
ToolTip_ParseNode(node->getChild(i));
|
||||
}
|
||||
}
|
||||
|
||||
QString title = node->getAttr("title");
|
||||
QString content = node->getAttr("content");
|
||||
QString specialContent = node->getAttr("special_content");
|
||||
QString disabledContent = node->getAttr("disabled_content");
|
||||
|
||||
QMap<QString, ToolTip>::iterator itr = m_tooltips.insert(node->getAttr("path"), ToolTip());
|
||||
itr->isValid = true;
|
||||
itr->title = title;
|
||||
itr->content = content;
|
||||
itr->specialContent = specialContent;
|
||||
itr->disabledContent = disabledContent;
|
||||
|
||||
unsigned int childCount = node->getChildCount();
|
||||
|
||||
for (unsigned int i = 0; i < childCount; i++)
|
||||
{
|
||||
ToolTip_ParseNode(node->getChild(i));
|
||||
}
|
||||
}
|
||||
|
||||
ToolTip GetToolTip(QString path)
|
||||
{
|
||||
if (m_tooltips.contains(path))
|
||||
{
|
||||
return m_tooltips[path];
|
||||
}
|
||||
ToolTip temp;
|
||||
temp.isValid = false;
|
||||
return temp;
|
||||
}
|
||||
|
||||
public:
|
||||
void ToolTip_LoadConfigXML(QString filepath) override
|
||||
{
|
||||
XmlNodeRef node = GetIEditor()->GetSystem()->LoadXmlFromFile(filepath.toStdString().c_str());
|
||||
ToolTip_ParseNode(node);
|
||||
}
|
||||
|
||||
void ToolTip_BuildFromConfig(IQToolTip* tooltip, QString path, QString option, QString optionalData = "", bool isEnabled = true) override
|
||||
{
|
||||
AZ_Assert(tooltip, "tooltip cannot be null");
|
||||
|
||||
QString title = ToolTip_GetTitle(path, option);
|
||||
QString content = ToolTip_GetContent(path, option);
|
||||
QString specialContent = ToolTip_GetSpecialContentType(path, option);
|
||||
QString disabledContent = ToolTip_GetDisabledContent(path, option);
|
||||
|
||||
// Even if these items are empty, we set them anyway to clear out any data that was left over from when the tooltip was used for a different object.
|
||||
tooltip->SetTitle(title);
|
||||
tooltip->SetContent(content);
|
||||
|
||||
//this only handles simple creation...if you need complex call this then add specials separate
|
||||
if (!specialContent.contains("::"))
|
||||
{
|
||||
tooltip->AddSpecialContent(specialContent, optionalData);
|
||||
}
|
||||
|
||||
if (!isEnabled) // If disabled, add disabled value
|
||||
{
|
||||
tooltip->AppendContent(disabledContent);
|
||||
}
|
||||
}
|
||||
|
||||
QString ToolTip_GetTitle(QString path, QString option) override
|
||||
{
|
||||
if (!option.isEmpty() && GetToolTip(path + "." + option).isValid)
|
||||
{
|
||||
return GetToolTip(path + "." + option).title;
|
||||
}
|
||||
if (!option.isEmpty() && GetToolTip("Options." + option).isValid)
|
||||
{
|
||||
return GetToolTip("Options." + option).title;
|
||||
}
|
||||
return GetToolTip(path).title;
|
||||
}
|
||||
|
||||
QString ToolTip_GetContent(QString path, QString option) override
|
||||
{
|
||||
if (!option.isEmpty() && GetToolTip(path + "." + option).isValid)
|
||||
{
|
||||
return GetToolTip(path + "." + option).content;
|
||||
}
|
||||
if (!option.isEmpty() && GetToolTip("Options." + option).isValid)
|
||||
{
|
||||
return GetToolTip("Options." + option).content;
|
||||
}
|
||||
return GetToolTip(path).content;
|
||||
}
|
||||
|
||||
QString ToolTip_GetSpecialContentType(QString path, QString option) override
|
||||
{
|
||||
if (!option.isEmpty() && GetToolTip(path + "." + option).isValid)
|
||||
{
|
||||
return GetToolTip(path + "." + option).specialContent;
|
||||
}
|
||||
if (!option.isEmpty() && GetToolTip("Options." + option).isValid)
|
||||
{
|
||||
return GetToolTip("Options." + option).specialContent;
|
||||
}
|
||||
return GetToolTip(path).specialContent;
|
||||
}
|
||||
|
||||
QString ToolTip_GetDisabledContent(QString path, QString option) override
|
||||
{
|
||||
if (!option.isEmpty() && GetToolTip(path + "." + option).isValid)
|
||||
{
|
||||
return GetToolTip(path + "." + option).disabledContent;
|
||||
}
|
||||
if (!option.isEmpty() && GetToolTip("Options." + option).isValid)
|
||||
{
|
||||
return GetToolTip("Options." + option).disabledContent;
|
||||
}
|
||||
return GetToolTip(path).disabledContent;
|
||||
}
|
||||
};
|
||||
|
||||
IEditorPanelUtils* CreateEditorPanelUtils()
|
||||
{
|
||||
return new CEditorPanelUtils_Impl();
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
// Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
#ifndef CRYINCLUDE_CRYEDITOR_EDITORPANELUTILS_H
|
||||
#define CRYINCLUDE_CRYEDITOR_EDITORPANELUTILS_H
|
||||
#pragma once
|
||||
|
||||
struct IEditorPanelUtils;
|
||||
IEditorPanelUtils* CreateEditorPanelUtils();
|
||||
|
||||
#endif
|
||||
@@ -28,7 +28,7 @@ void CEditorPreferencesPage_AWS::Reflect(AZ::SerializeContext& serialize)
|
||||
if (editContext)
|
||||
{
|
||||
editContext->Class<UsageOptions>("Options", "")
|
||||
->DataElement(AZ::Edit::UIHandlers::CheckBox, &UsageOptions::m_awsAttributionEnabled, "Allow O3DE to send information about your use of AWS Core Gem to AWS",
|
||||
->DataElement(AZ::Edit::UIHandlers::CheckBox, &UsageOptions::m_awsAttributionEnabled, "Allow <a href=\"https://aws.amazon.com/privacy/\">O3DE</a> to send information about your use of AWS Core Gem to AWS",
|
||||
"");
|
||||
|
||||
editContext->Class<CEditorPreferencesPage_AWS>("AWS Preferences", "AWS Preferences")
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include "ErrorRecorder.h"
|
||||
#include "BaseLibraryItem.h"
|
||||
#include "Include/IErrorReport.h"
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#define CRYINCLUDE_EDITOR_CORE_ERRORRECORDER_H
|
||||
#pragma once
|
||||
|
||||
#include "Include/EditorCoreAPI.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Automatic class to record and display error.
|
||||
class EDITOR_CORE_API CErrorsRecorder
|
||||
|
||||
@@ -67,24 +67,6 @@ QString CErrorRecord::GetErrorText() const
|
||||
{
|
||||
str += QString("\t ");
|
||||
}
|
||||
if (pItem)
|
||||
{
|
||||
switch (pItem->GetType())
|
||||
{
|
||||
case EDB_TYPE_MATERIAL:
|
||||
str += QString("\t Material=\"");
|
||||
break;
|
||||
case EDB_TYPE_PARTICLE:
|
||||
str += QString("\t Particle=\"");
|
||||
break;
|
||||
case EDB_TYPE_MUSIC:
|
||||
str += QString("\t Music=\"");
|
||||
break;
|
||||
default:
|
||||
str += QString("\t Item=\"");
|
||||
}
|
||||
str += pItem->GetFullName() + "\"";
|
||||
}
|
||||
if (pObject)
|
||||
{
|
||||
str += QString("\t Object=\"") + pObject->GetName() + "\"";
|
||||
@@ -101,7 +83,6 @@ CErrorReport::CErrorReport()
|
||||
m_bImmediateMode = true;
|
||||
m_bShowErrors = true;
|
||||
m_pObject = nullptr;
|
||||
m_pItem = nullptr;
|
||||
m_pParticle = nullptr;
|
||||
}
|
||||
|
||||
@@ -140,10 +121,6 @@ void CErrorReport::ReportError(CErrorRecord& err)
|
||||
{
|
||||
err.pObject = m_pObject;
|
||||
}
|
||||
else if (err.pItem == nullptr && m_pItem != nullptr)
|
||||
{
|
||||
err.pItem = m_pItem;
|
||||
}
|
||||
m_errors.push_back(err);
|
||||
}
|
||||
bNoRecurse = false;
|
||||
@@ -255,12 +232,6 @@ void CErrorReport::SetCurrentValidatorObject(CBaseObject* pObject)
|
||||
m_pObject = pObject;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CErrorReport::SetCurrentValidatorItem(CBaseLibraryItem* pItem)
|
||||
{
|
||||
m_pItem = pItem;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CErrorReport::SetCurrentFile(const QString& file)
|
||||
{
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
// forward declarations.
|
||||
class CParticleItem;
|
||||
|
||||
#include "BaseLibraryItem.h"
|
||||
#include <CryCommon/IValidator.h>
|
||||
#include <CryCommon/smartptr.h>
|
||||
|
||||
#include "Objects/BaseObject.h"
|
||||
#include "Include/EditorCoreAPI.h"
|
||||
#include "Include/IErrorReport.h"
|
||||
#include "ErrorRecorder.h"
|
||||
|
||||
@@ -56,16 +59,13 @@ public:
|
||||
int count;
|
||||
//! Object that caused this error.
|
||||
_smart_ptr<CBaseObject> pObject;
|
||||
//! Library Item that caused this error.
|
||||
_smart_ptr<CBaseLibraryItem> pItem;
|
||||
int flags;
|
||||
|
||||
CErrorRecord(CBaseObject* object, ESeverity _severity, const QString& _error, int _flags = 0, int _count = 0,
|
||||
CBaseLibraryItem* item = 0, EValidatorModule _module = VALIDATOR_MODULE_EDITOR)
|
||||
EValidatorModule _module = VALIDATOR_MODULE_EDITOR)
|
||||
: severity(_severity)
|
||||
, module(_module)
|
||||
, pObject(object)
|
||||
, pItem(item)
|
||||
, flags(_flags)
|
||||
, count(_count)
|
||||
, error(_error)
|
||||
@@ -77,7 +77,6 @@ public:
|
||||
severity = ESEVERITY_WARNING;
|
||||
module = VALIDATOR_MODULE_EDITOR;
|
||||
pObject = 0;
|
||||
pItem = 0;
|
||||
flags = 0;
|
||||
count = 0;
|
||||
}
|
||||
@@ -116,8 +115,6 @@ public:
|
||||
|
||||
//! Assign current Object to which new reported warnings are assigned.
|
||||
void SetCurrentValidatorObject(CBaseObject* pObject);
|
||||
//! Assign current Item to which new reported warnings are assigned.
|
||||
void SetCurrentValidatorItem(CBaseLibraryItem* pItem);
|
||||
//! Assign current filename.
|
||||
void SetCurrentFile(const QString& file);
|
||||
|
||||
@@ -127,7 +124,6 @@ private:
|
||||
bool m_bImmediateMode;
|
||||
bool m_bShowErrors;
|
||||
_smart_ptr<CBaseObject> m_pObject;
|
||||
_smart_ptr<CBaseLibraryItem> m_pItem;
|
||||
CParticleItem* m_pParticle;
|
||||
QString m_currentFilename;
|
||||
};
|
||||
|
||||
@@ -362,10 +362,6 @@ void CErrorReportDialog::CopyToClipboard()
|
||||
{
|
||||
str += QString::fromLatin1(" [Object: %1]").arg(pRecord->pObject->GetName());
|
||||
}
|
||||
if (pRecord->pItem)
|
||||
{
|
||||
str += QString::fromLatin1(" [Material: %1]").arg(pRecord->pItem->GetName());
|
||||
}
|
||||
str += QString::fromLatin1("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,11 +149,7 @@ QVariant CErrorReportTableModel::data(const CErrorRecord& record, int column, in
|
||||
case ColumnFile:
|
||||
return record.file;
|
||||
case ColumnObject:
|
||||
if (record.pItem)
|
||||
{
|
||||
return record.pItem->GetFullName();
|
||||
}
|
||||
else if (record.pObject)
|
||||
if (record.pObject)
|
||||
{
|
||||
return record.pObject->GetName();
|
||||
}
|
||||
|
||||
@@ -1,587 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "TriMesh.h"
|
||||
|
||||
// Editor
|
||||
#include "Util/fastlib.h"
|
||||
#include "Objects/SubObjSelection.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CTriMesh::CTriMesh()
|
||||
{
|
||||
pFaces = nullptr;
|
||||
pVertices = nullptr;
|
||||
pWSVertices = nullptr;
|
||||
pUV = nullptr;
|
||||
pColors = nullptr;
|
||||
pEdges = nullptr;
|
||||
pWeights = nullptr;
|
||||
|
||||
nFacesCount = 0;
|
||||
nVertCount = 0;
|
||||
nUVCount = 0;
|
||||
nEdgeCount = 0;
|
||||
|
||||
selectionType = SO_ELEM_NONE;
|
||||
|
||||
memset(m_streamSize, 0, sizeof(m_streamSize));
|
||||
memset(m_streamSel, 0, sizeof(m_streamSel));
|
||||
streamSelMask = 0;
|
||||
|
||||
m_streamSel[VERTICES] = &vertSel;
|
||||
m_streamSel[EDGES] = &edgeSel;
|
||||
m_streamSel[FACES] = &faceSel;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CTriMesh::~CTriMesh()
|
||||
{
|
||||
free(pFaces);
|
||||
free(pEdges);
|
||||
free(pVertices);
|
||||
free(pUV);
|
||||
free(pColors);
|
||||
free(pWSVertices);
|
||||
free(pWeights);
|
||||
}
|
||||
|
||||
// Set stream size.
|
||||
void CTriMesh::ReallocStream(int stream, int nNewCount)
|
||||
{
|
||||
assert(stream >= 0 && stream < LAST_STREAM);
|
||||
if (stream < 0 || stream >= LAST_STREAM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_streamSize[stream] == nNewCount)
|
||||
{
|
||||
return; // Stream already have required size.
|
||||
}
|
||||
void* pStream = nullptr;
|
||||
int nElementSize = 0;
|
||||
GetStreamInfo(stream, pStream, nElementSize);
|
||||
pStream = ReAllocElements(pStream, nNewCount, nElementSize);
|
||||
m_streamSize[stream] = nNewCount;
|
||||
|
||||
switch (stream)
|
||||
{
|
||||
case VERTICES:
|
||||
pVertices = (CTriVertex*)pStream;
|
||||
nVertCount = nNewCount;
|
||||
vertSel.resize(nNewCount);
|
||||
break;
|
||||
case FACES:
|
||||
pFaces = (CTriFace*)pStream;
|
||||
nFacesCount = nNewCount;
|
||||
faceSel.resize(nNewCount);
|
||||
break;
|
||||
case EDGES:
|
||||
pEdges = (CTriEdge*)pStream;
|
||||
nEdgeCount = nNewCount;
|
||||
edgeSel.resize(nNewCount);
|
||||
break;
|
||||
case TEXCOORDS:
|
||||
pUV = (SMeshTexCoord*)pStream;
|
||||
nUVCount = nNewCount;
|
||||
break;
|
||||
case COLORS:
|
||||
pColors = (SMeshColor*)pStream;
|
||||
break;
|
||||
case WEIGHTS:
|
||||
pWeights = (float*)pStream;
|
||||
break;
|
||||
case LINES:
|
||||
pLines = (CTriLine*)pStream;
|
||||
break;
|
||||
case WS_POSITIONS:
|
||||
pWSVertices = (Vec3*)pStream;
|
||||
break;
|
||||
default:
|
||||
assert(0); // unknown stream.
|
||||
}
|
||||
m_streamSize[stream] = nNewCount;
|
||||
}
|
||||
|
||||
// Set stream size.
|
||||
void CTriMesh::GetStreamInfo(int stream, void*& pStream, int& nElementSize) const
|
||||
{
|
||||
assert(stream >= 0 && stream < LAST_STREAM);
|
||||
switch (stream)
|
||||
{
|
||||
case VERTICES:
|
||||
pStream = pVertices;
|
||||
nElementSize = sizeof(CTriVertex);
|
||||
break;
|
||||
case FACES:
|
||||
pStream = pFaces;
|
||||
nElementSize = sizeof(CTriFace);
|
||||
break;
|
||||
case EDGES:
|
||||
pStream = pEdges;
|
||||
nElementSize = sizeof(CTriEdge);
|
||||
break;
|
||||
case TEXCOORDS:
|
||||
pStream = pUV;
|
||||
nElementSize = sizeof(SMeshTexCoord);
|
||||
break;
|
||||
case COLORS:
|
||||
pStream = pColors;
|
||||
nElementSize = sizeof(SMeshColor);
|
||||
break;
|
||||
case WEIGHTS:
|
||||
pStream = pWeights;
|
||||
nElementSize = sizeof(float);
|
||||
break;
|
||||
case LINES:
|
||||
pStream = pLines;
|
||||
nElementSize = sizeof(CTriLine);
|
||||
break;
|
||||
case WS_POSITIONS:
|
||||
pStream = pWSVertices;
|
||||
nElementSize = sizeof(Vec3);
|
||||
break;
|
||||
default:
|
||||
assert(0); // unknown stream.
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void* CTriMesh::ReAllocElements(void* old_ptr, int new_elem_num, int size_of_element)
|
||||
{
|
||||
return realloc(old_ptr, new_elem_num * size_of_element);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
inline int FindVertexInHash(const Vec3& vPosToFind, const CTriVertex* pVectors, std::vector<int>& hash, float fEpsilon)
|
||||
{
|
||||
for (uint32 i = 0; i < hash.size(); i++)
|
||||
{
|
||||
const Vec3& v0 = pVectors[hash[i]].pos;
|
||||
const Vec3& v1 = vPosToFind;
|
||||
if (fabsf(v0.y - v1.y) < fEpsilon && fabsf(v0.x - v1.x) < fEpsilon && fabsf(v0.z - v1.z) < fEpsilon)
|
||||
{
|
||||
return hash[i];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
inline int FindTexCoordInHash(const SMeshTexCoord& coordToFind, const SMeshTexCoord* pCoords, std::vector<int>& hash, float fEpsilon)
|
||||
{
|
||||
for (uint32 i = 0; i < hash.size(); i++)
|
||||
{
|
||||
const SMeshTexCoord& t0 = pCoords[hash[i]];
|
||||
const SMeshTexCoord& t1 = coordToFind;
|
||||
|
||||
if (t0.IsEquivalent(t1, fEpsilon))
|
||||
{
|
||||
return hash[i];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTriMesh::SharePositions()
|
||||
{
|
||||
float fEpsilon = 0.0001f;
|
||||
float fHashScale = 256.0f / MAX(bbox.GetSize().GetLength(), fEpsilon);
|
||||
std::vector<int> arrHashTable[256];
|
||||
|
||||
CTriVertex* pNewVerts = new CTriVertex[GetVertexCount()];
|
||||
SMeshColor* pNewColors = nullptr;
|
||||
if (pColors)
|
||||
{
|
||||
pNewColors = new SMeshColor[GetVertexCount()];
|
||||
}
|
||||
|
||||
int nLastIndex = 0;
|
||||
for (int f = 0; f < GetFacesCount(); f++)
|
||||
{
|
||||
CTriFace& face = pFaces[f];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
const Vec3& v = pVertices[face.v[i]].pos;
|
||||
uint8 nHash = static_cast<uint8>(RoundFloatToInt((v.x + v.y + v.z) * fHashScale));
|
||||
|
||||
int find = FindVertexInHash(v, pNewVerts, arrHashTable[nHash], fEpsilon);
|
||||
if (find < 0)
|
||||
{
|
||||
pNewVerts[nLastIndex] = pVertices[face.v[i]];
|
||||
if (pColors)
|
||||
{
|
||||
pNewColors[nLastIndex] = pColors[face.v[i]];
|
||||
}
|
||||
face.v[i] = nLastIndex;
|
||||
// Reserve some space already.
|
||||
arrHashTable[nHash].reserve(100);
|
||||
arrHashTable[nHash].push_back(nLastIndex);
|
||||
nLastIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
face.v[i] = find;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetVertexCount(nLastIndex);
|
||||
memcpy(pVertices, pNewVerts, nLastIndex * sizeof(CTriVertex));
|
||||
delete []pNewVerts;
|
||||
|
||||
if (pColors)
|
||||
{
|
||||
SetColorsCount(nLastIndex);
|
||||
memcpy(pColors, pNewColors, nLastIndex * sizeof(SMeshColor));
|
||||
delete []pNewColors;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTriMesh::ShareUV()
|
||||
{
|
||||
float fEpsilon = 0.0001f;
|
||||
float fHashScale = 256.0f;
|
||||
std::vector<int> arrHashTable[256];
|
||||
|
||||
SMeshTexCoord* pNewUV = new SMeshTexCoord[GetUVCount()];
|
||||
|
||||
int nLastIndex = 0;
|
||||
for (int f = 0; f < GetFacesCount(); f++)
|
||||
{
|
||||
CTriFace& face = pFaces[f];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
const Vec2 uv = pUV[face.uv[i]].GetUV();
|
||||
uint8 nHash = static_cast<uint8>(RoundFloatToInt((uv.x + uv.y) * fHashScale));
|
||||
|
||||
int find = FindTexCoordInHash(pUV[face.uv[i]], pNewUV, arrHashTable[nHash], fEpsilon);
|
||||
if (find < 0)
|
||||
{
|
||||
pNewUV[nLastIndex] = pUV[face.uv[i]];
|
||||
face.uv[i] = nLastIndex;
|
||||
arrHashTable[nHash].reserve(100);
|
||||
arrHashTable[nHash].push_back(nLastIndex);
|
||||
nLastIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
face.uv[i] = find;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetUVCount(nLastIndex);
|
||||
memcpy(pUV, pNewUV, nLastIndex * sizeof(SMeshTexCoord));
|
||||
delete []pNewUV;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTriMesh::CalcFaceNormals()
|
||||
{
|
||||
for (int i = 0; i < nFacesCount; i++)
|
||||
{
|
||||
CTriFace& face = pFaces[i];
|
||||
Vec3 p1 = pVertices[face.v[0]].pos;
|
||||
Vec3 p2 = pVertices[face.v[1]].pos;
|
||||
Vec3 p3 = pVertices[face.v[2]].pos;
|
||||
face.normal = (p2 - p1).Cross(p3 - p1);
|
||||
face.normal.Normalize();
|
||||
}
|
||||
}
|
||||
|
||||
#define TEX_EPS 0.001f
|
||||
#define VER_EPS 0.001f
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTriMesh::CopyStream(CTriMesh& fromMesh, int stream)
|
||||
{
|
||||
void* pTrgStream = nullptr;
|
||||
void* pSrcStream = nullptr;
|
||||
int nElemSize = 0;
|
||||
fromMesh.GetStreamInfo(stream, pSrcStream, nElemSize);
|
||||
if (pSrcStream)
|
||||
{
|
||||
ReallocStream(stream, fromMesh.GetStreamSize(stream));
|
||||
GetStreamInfo(stream, pTrgStream, nElemSize);
|
||||
memcpy(pTrgStream, pSrcStream, nElemSize * fromMesh.GetStreamSize(stream));
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTriMesh::Copy(CTriMesh& fromMesh, int nCopyFlags)
|
||||
{
|
||||
streamSelMask = fromMesh.streamSelMask;
|
||||
|
||||
if (nCopyFlags & COPY_VERTICES)
|
||||
{
|
||||
CopyStream(fromMesh, VERTICES);
|
||||
}
|
||||
if (nCopyFlags & COPY_FACES)
|
||||
{
|
||||
CopyStream(fromMesh, FACES);
|
||||
}
|
||||
if (nCopyFlags & COPY_EDGES)
|
||||
{
|
||||
CopyStream(fromMesh, EDGES);
|
||||
}
|
||||
if (nCopyFlags & COPY_TEXCOORDS)
|
||||
{
|
||||
CopyStream(fromMesh, TEXCOORDS);
|
||||
}
|
||||
if (nCopyFlags & COPY_COLORS)
|
||||
{
|
||||
CopyStream(fromMesh, COLORS);
|
||||
}
|
||||
if (nCopyFlags & COPY_WEIGHTS)
|
||||
{
|
||||
CopyStream(fromMesh, WEIGHTS);
|
||||
}
|
||||
if (nCopyFlags & COPY_LINES)
|
||||
{
|
||||
CopyStream(fromMesh, LINES);
|
||||
}
|
||||
|
||||
if (nCopyFlags & COPY_VERT_SEL)
|
||||
{
|
||||
vertSel = fromMesh.vertSel;
|
||||
}
|
||||
if (nCopyFlags & COPY_EDGE_SEL)
|
||||
{
|
||||
edgeSel = fromMesh.edgeSel;
|
||||
}
|
||||
if (nCopyFlags & COPY_FACE_SEL)
|
||||
{
|
||||
faceSel = fromMesh.faceSel;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTriMesh::UpdateEdges()
|
||||
{
|
||||
SetEdgeCount(GetFacesCount() * 3);
|
||||
|
||||
std::map<CTriEdge, int> edgemap;
|
||||
|
||||
int nEdges = 0;
|
||||
for (int i = 0; i < GetFacesCount(); i++)
|
||||
{
|
||||
CTriFace& face = pFaces[i];
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
int v0 = j;
|
||||
int v1 = (j != 2) ? j + 1 : 0;
|
||||
CTriEdge edge;
|
||||
edge.flags = 0;
|
||||
|
||||
// First vertex index must always be smaller.
|
||||
if (face.v[v0] < face.v[v1])
|
||||
{
|
||||
edge.v[0] = face.v[v0];
|
||||
edge.v[1] = face.v[v1];
|
||||
}
|
||||
else
|
||||
{
|
||||
edge.v[0] = face.v[v1];
|
||||
edge.v[1] = face.v[v0];
|
||||
}
|
||||
edge.face[0] = i;
|
||||
edge.face[1] = -1;
|
||||
int nedge = stl::find_in_map(edgemap, edge, -1);
|
||||
if (nedge >= 0)
|
||||
{
|
||||
// Assign this face as a second member of the edge.
|
||||
if (pEdges[nedge].face[1] < 0)
|
||||
{
|
||||
pEdges[nedge].face[1] = i;
|
||||
}
|
||||
|
||||
face.edge[j] = nedge;
|
||||
}
|
||||
else
|
||||
{
|
||||
edgemap[edge] = nEdges;
|
||||
pEdges[nEdges] = edge;
|
||||
face.edge[j] = nEdges;
|
||||
nEdges++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetEdgeCount(nEdges);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTriMesh::SoftSelection(const SSubObjSelOptions& options)
|
||||
{
|
||||
int i;
|
||||
int nVerts = GetVertexCount();
|
||||
CTriVertex* pVerts = pVertices;
|
||||
|
||||
for (i = 0; i < nVerts; i++)
|
||||
{
|
||||
if (pWeights[i] == 1.0f)
|
||||
{
|
||||
const Vec3& vp = pVerts[i].pos;
|
||||
for (int j = 0; j < nVerts; j++)
|
||||
{
|
||||
if (pWeights[j] != 1.0f)
|
||||
{
|
||||
if (vp.IsEquivalent(pVerts[j].pos, options.fSoftSelFalloff))
|
||||
{
|
||||
float fDist = vp.GetDistance(pVerts[j].pos);
|
||||
if (fDist < options.fSoftSelFalloff)
|
||||
{
|
||||
float fWeight = 1.0f - (fDist / options.fSoftSelFalloff);
|
||||
if (fWeight > pWeights[j])
|
||||
{
|
||||
pWeights[j] = fWeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CTriMesh::UpdateSelection()
|
||||
{
|
||||
bool bAnySelected = false;
|
||||
if (selectionType == SO_ELEM_VERTEX)
|
||||
{
|
||||
for (int i = 0; i < GetVertexCount(); i++)
|
||||
{
|
||||
if (vertSel[i])
|
||||
{
|
||||
bAnySelected = true;
|
||||
pWeights[i] = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
pWeights[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selectionType == SO_ELEM_EDGE)
|
||||
{
|
||||
// Clear weights.
|
||||
for (int i = 0; i < GetVertexCount(); i++)
|
||||
{
|
||||
pWeights[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < GetEdgeCount(); i++)
|
||||
{
|
||||
if (edgeSel[i])
|
||||
{
|
||||
bAnySelected = true;
|
||||
CTriEdge& edge = pEdges[i];
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
pWeights[edge.v[j]] = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (selectionType == SO_ELEM_FACE)
|
||||
{
|
||||
// Clear weights.
|
||||
for (int i = 0; i < GetVertexCount(); i++)
|
||||
{
|
||||
pWeights[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < GetFacesCount(); i++)
|
||||
{
|
||||
if (faceSel[i])
|
||||
{
|
||||
bAnySelected = true;
|
||||
CTriFace& face = pFaces[i];
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
pWeights[face.v[j]] = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return bAnySelected;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CTriMesh::ClearSelection()
|
||||
{
|
||||
bool bWasSelected = false;
|
||||
// Remove all selections.
|
||||
int i;
|
||||
for (i = 0; i < GetVertexCount(); i++)
|
||||
{
|
||||
pWeights[i] = 0;
|
||||
}
|
||||
streamSelMask = 0;
|
||||
for (int ii = 0; ii < LAST_STREAM; ii++)
|
||||
{
|
||||
if (m_streamSel[ii] && !m_streamSel[ii]->is_zero())
|
||||
{
|
||||
bWasSelected = true;
|
||||
m_streamSel[ii]->clear();
|
||||
}
|
||||
}
|
||||
return bWasSelected;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTriMesh::GetEdgesByVertex(MeshElementsArray& inVertices, MeshElementsArray& outEdges)
|
||||
{
|
||||
// Brute force algorithm using binary search.
|
||||
// for every edge check if edge vertex is inside inVertices array.
|
||||
std::sort(inVertices.begin(), inVertices.end());
|
||||
for (int i = 0; i < GetEdgeCount(); i++)
|
||||
{
|
||||
if (stl::binary_find(inVertices.begin(), inVertices.end(), static_cast<int>(pEdges[i].v[0])) != inVertices.end())
|
||||
{
|
||||
outEdges.push_back(i);
|
||||
}
|
||||
else if (stl::binary_find(inVertices.begin(), inVertices.end(), static_cast<int>(pEdges[i].v[1])) != inVertices.end())
|
||||
{
|
||||
outEdges.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CTriMesh::GetFacesByVertex(MeshElementsArray& inVertices, MeshElementsArray& outFaces)
|
||||
{
|
||||
// Brute force algorithm using binary search.
|
||||
// for every face check if face vertex is inside inVertices array.
|
||||
std::sort(inVertices.begin(), inVertices.end());
|
||||
for (int i = 0; i < GetFacesCount(); i++)
|
||||
{
|
||||
if (stl::binary_find(inVertices.begin(), inVertices.end(), static_cast<int>(pFaces[i].v[0])) != inVertices.end())
|
||||
{
|
||||
outFaces.push_back(i);
|
||||
}
|
||||
else if (stl::binary_find(inVertices.begin(), inVertices.end(), static_cast<int>(pFaces[i].v[1])) != inVertices.end())
|
||||
{
|
||||
outFaces.push_back(i);
|
||||
}
|
||||
else if (stl::binary_find(inVertices.begin(), inVertices.end(), static_cast<int>(pFaces[i].v[2])) != inVertices.end())
|
||||
{
|
||||
outFaces.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GEOMETRY_TRIMESH_H
|
||||
#define CRYINCLUDE_EDITOR_GEOMETRY_TRIMESH_H
|
||||
#pragma once
|
||||
|
||||
#include <IIndexedMesh.h>
|
||||
#include "Util/bitarray.h"
|
||||
|
||||
struct SSubObjSelOptions;
|
||||
|
||||
typedef std::vector<int> MeshElementsArray;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Vertex used in the TriMesh.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct CTriVertex
|
||||
{
|
||||
Vec3 pos;
|
||||
//float weight; // Selection weight in 0-1 range.
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Triangle face used by the Triangle mesh.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct CTriFace
|
||||
{
|
||||
uint32 v[3]; // Indices to vertices array.
|
||||
uint32 uv[3]; // Indices to texture coordinates array.
|
||||
Vec3 n[3]; // Vertex normals at face vertices.
|
||||
Vec3 normal; // Face normal.
|
||||
uint32 edge[3]; // Indices to the face edges.
|
||||
unsigned char MatID; // Index of face sub material.
|
||||
unsigned char flags; // see ETriMeshFlags
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Mesh edge.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct CTriEdge
|
||||
{
|
||||
uint32 v[2]; // Indices to edge vertices.
|
||||
int face[2]; // Indices to edge faces (-1 if no face).
|
||||
uint32 flags; // see ETriMeshFlags
|
||||
|
||||
CTriEdge() {}
|
||||
bool operator==(const CTriEdge& edge) const
|
||||
{
|
||||
if ((v[0] == edge.v[0] && v[1] == edge.v[1]) ||
|
||||
(v[0] == edge.v[1] && v[1] == edge.v[0]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator!=(const CTriEdge& edge) const { return !(*this == edge); }
|
||||
bool operator<(const CTriEdge& edge) const { return (*(uint64*)v < *(uint64*)edge.v); }
|
||||
bool operator>(const CTriEdge& edge) const { return (*(uint64*)v > *(uint64*)edge.v); }
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Mesh line.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct CTriLine
|
||||
{
|
||||
uint32 v[2]; // Indices to edge vertices.
|
||||
|
||||
CTriLine() {}
|
||||
bool operator==(const CTriLine& edge) const
|
||||
{
|
||||
if ((v[0] == edge.v[0] && v[1] == edge.v[1]) ||
|
||||
(v[0] == edge.v[1] && v[1] == edge.v[0]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator!=(const CTriLine& edge) const { return !(*this == edge); }
|
||||
bool operator<(const CTriLine& edge) const { return (*(uint64*)v < *(uint64*)edge.v); }
|
||||
bool operator>(const CTriLine& edge) const { return (*(uint64*)v > *(uint64*)edge.v); }
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct CTriMeshPoly
|
||||
{
|
||||
std::vector<uint32> v; // Indices to vertices array.
|
||||
std::vector<uint32> uv; // Indices to texture coordinates array.
|
||||
std::vector<Vec3> n; // Vertex normals at face vertices.
|
||||
Vec3 normal; // Polygon normal.
|
||||
uint32 edge[3]; // Indices to the face edges.
|
||||
unsigned char MatID; // Index of face sub material.
|
||||
unsigned char flags; // optional flags.
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CTriMesh is used in the Editor as a general purpose editable triangle mesh.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CTriMesh
|
||||
{
|
||||
public:
|
||||
enum EStream
|
||||
{
|
||||
VERTICES,
|
||||
FACES,
|
||||
EDGES,
|
||||
TEXCOORDS,
|
||||
COLORS,
|
||||
WEIGHTS,
|
||||
LINES,
|
||||
WS_POSITIONS,
|
||||
LAST_STREAM,
|
||||
};
|
||||
enum ECopyFlags
|
||||
{
|
||||
COPY_VERTICES = BIT(1),
|
||||
COPY_FACES = BIT(2),
|
||||
COPY_EDGES = BIT(3),
|
||||
COPY_TEXCOORDS = BIT(4),
|
||||
COPY_COLORS = BIT(5),
|
||||
COPY_VERT_SEL = BIT(6),
|
||||
COPY_EDGE_SEL = BIT(7),
|
||||
COPY_FACE_SEL = BIT(8),
|
||||
COPY_WEIGHTS = BIT(9),
|
||||
COPY_LINES = BIT(10),
|
||||
COPY_ALL = 0xFFFF,
|
||||
};
|
||||
// geometry data
|
||||
CTriFace* pFaces;
|
||||
CTriEdge* pEdges;
|
||||
CTriVertex* pVertices;
|
||||
SMeshTexCoord* pUV;
|
||||
SMeshColor* pColors; // If allocated same size as pVerts array.
|
||||
Vec3* pWSVertices; // World space vertices.
|
||||
float* pWeights;
|
||||
CTriLine* pLines;
|
||||
|
||||
int nFacesCount;
|
||||
int nVertCount;
|
||||
int nUVCount;
|
||||
int nEdgeCount;
|
||||
int nLinesCount;
|
||||
|
||||
AABB bbox;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Selections.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CBitArray vertSel;
|
||||
CBitArray edgeSel;
|
||||
CBitArray faceSel;
|
||||
// Every bit of the selection mask correspond to a stream, if bit is set this stream have some elements selected
|
||||
int streamSelMask;
|
||||
|
||||
// Selection element type.
|
||||
// see ESubObjElementType
|
||||
int selectionType;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Vertices of the front facing triangles.
|
||||
CBitArray frontFacingVerts;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Functions.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CTriMesh();
|
||||
~CTriMesh();
|
||||
|
||||
int GetFacesCount() const { return nFacesCount; }
|
||||
int GetVertexCount() const { return nVertCount; }
|
||||
int GetUVCount() const { return nUVCount; }
|
||||
int GetEdgeCount() const { return nEdgeCount; }
|
||||
int GetLinesCount() const { return nLinesCount; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetFacesCount(int nNewCount) { ReallocStream(FACES, nNewCount); }
|
||||
void SetVertexCount(int nNewCount)
|
||||
{
|
||||
ReallocStream(VERTICES, nNewCount);
|
||||
if (pColors)
|
||||
{
|
||||
ReallocStream(COLORS, nNewCount);
|
||||
}
|
||||
ReallocStream(WEIGHTS, nNewCount);
|
||||
}
|
||||
void SetColorsCount(int nNewCount) { ReallocStream(COLORS, nNewCount); }
|
||||
void SetUVCount(int nNewCount) { ReallocStream(TEXCOORDS, nNewCount); }
|
||||
void SetEdgeCount(int nNewCount) { ReallocStream(EDGES, nNewCount); }
|
||||
void SetLinesCount(int nNewCount) { ReallocStream(LINES, nNewCount); }
|
||||
|
||||
void ReallocStream(int stream, int nNewCount);
|
||||
void GetStreamInfo(int stream, void*& pStream, int& nElementSize) const;
|
||||
int GetStreamSize(int stream) const { return m_streamSize[stream]; };
|
||||
|
||||
// Calculate per face normal.
|
||||
void CalcFaceNormals();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Welding functions.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SharePositions();
|
||||
void ShareUV();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Recreate edges of the mesh.
|
||||
void UpdateEdges();
|
||||
|
||||
void Copy(CTriMesh& fromMesh, int nCopyFlags = COPY_ALL);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Sub-object selection specific methods.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Return true if something is selected.
|
||||
bool UpdateSelection();
|
||||
// Clear all selections, return true if something was selected.
|
||||
bool ClearSelection();
|
||||
void SoftSelection(const SSubObjSelOptions& options);
|
||||
CBitArray* GetStreamSelection(int nStream) { return m_streamSel[nStream]; };
|
||||
// Returns true if specified stream have any selected elements.
|
||||
bool StreamHaveSelection(int nStream) { return streamSelMask & (1 << nStream); }
|
||||
void GetEdgesByVertex(MeshElementsArray& inVertices, MeshElementsArray& outEdges);
|
||||
void GetFacesByVertex(MeshElementsArray& inVertices, MeshElementsArray& outFaces);
|
||||
|
||||
private:
|
||||
void* ReAllocElements(void* old_ptr, int new_elem_num, int size_of_element);
|
||||
void CopyStream(CTriMesh& fromMesh, int stream);
|
||||
|
||||
// For internal use.
|
||||
int m_streamSize[LAST_STREAM];
|
||||
CBitArray* m_streamSel[LAST_STREAM];
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GEOMETRY_TRIMESH_H
|
||||
@@ -44,7 +44,6 @@ class CMusicManager;
|
||||
struct IEditorParticleManager;
|
||||
class CEAXPresetManager;
|
||||
class CErrorReport;
|
||||
class CBaseLibraryItem;
|
||||
class ICommandManager;
|
||||
class CEditorCommandManager;
|
||||
class CHyperGraphManager;
|
||||
@@ -52,9 +51,7 @@ class CConsoleSynchronization;
|
||||
class CUIEnumsDatabase;
|
||||
struct ISourceControl;
|
||||
struct IEditorClassFactory;
|
||||
struct IDataBaseItem;
|
||||
struct ITransformManipulator;
|
||||
struct IDataBaseManager;
|
||||
class IFacialEditor;
|
||||
class CDialog;
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
@@ -69,7 +66,6 @@ class CSelectionTreeManager;
|
||||
struct SEditorSettings;
|
||||
class CGameExporter;
|
||||
class IAWSResourceManager;
|
||||
struct IEditorPanelUtils;
|
||||
|
||||
namespace WinWidget
|
||||
{
|
||||
@@ -83,8 +79,6 @@ struct IEventLoopHook;
|
||||
struct IErrorReport; // Vladimir@conffx
|
||||
struct IFileUtil; // Vladimir@conffx
|
||||
struct IEditorLog; // Vladimir@conffx
|
||||
struct IEditorMaterialManager; // Vladimir@conffx
|
||||
struct IBaseLibraryManager; // Vladimir@conffx
|
||||
struct IImageUtil; // Vladimir@conffx
|
||||
struct IEditorParticleUtils; // Leroy@conffx
|
||||
struct ILogFile; // Vladimir@conffx
|
||||
@@ -520,14 +514,8 @@ struct IEditor
|
||||
//! Get access to object manager.
|
||||
virtual struct IObjectManager* GetObjectManager() = 0;
|
||||
virtual CSettingsManager* GetSettingsManager() = 0;
|
||||
//! Get DB manager that own items of specified type.
|
||||
virtual IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType) = 0;
|
||||
virtual IBaseLibraryManager* GetMaterialManagerLibrary() = 0; // Vladimir@conffx
|
||||
virtual IEditorMaterialManager* GetIEditorMaterialManager() = 0; // Vladimir@Conffx
|
||||
//! Returns IconManager.
|
||||
virtual IIconManager* GetIconManager() = 0;
|
||||
//! Get Panel Editor Utilities
|
||||
virtual IEditorPanelUtils* GetEditorPanelUtils() = 0;
|
||||
//! Get Music Manager.
|
||||
virtual CMusicManager* GetMusicManager() = 0;
|
||||
virtual float GetTerrainElevation(float x, float y) = 0;
|
||||
|
||||
@@ -81,9 +81,6 @@ AZ_POP_DISABLE_WARNING
|
||||
// AWSNativeSDK
|
||||
#include <AWSNativeSDKInit/AWSNativeSDKInit.h>
|
||||
|
||||
#include "IEditorPanelUtils.h"
|
||||
#include "EditorPanelUtils.h"
|
||||
|
||||
#include "Core/QtEditorApplication.h" // for Editor::EditorQtApplication
|
||||
|
||||
static CCryEditDoc * theDocument;
|
||||
@@ -143,7 +140,6 @@ CEditorImpl::CEditorImpl()
|
||||
, m_QtApplication(static_cast<Editor::EditorQtApplication*>(qApp))
|
||||
, m_pImageUtil(nullptr)
|
||||
, m_pLogFile(nullptr)
|
||||
, m_panelEditorUtils(nullptr)
|
||||
{
|
||||
// note that this is a call into EditorCore.dll, which stores the g_pEditorPointer for all shared modules that share EditorCore.dll
|
||||
// this means that they don't need to do SetIEditor(...) themselves and its available immediately
|
||||
@@ -167,8 +163,6 @@ CEditorImpl::CEditorImpl()
|
||||
m_pDisplaySettings->LoadRegistry();
|
||||
m_pPluginManager = new CPluginManager;
|
||||
|
||||
m_panelEditorUtils = CreateEditorPanelUtils();
|
||||
|
||||
m_pObjectManager = new CObjectManager;
|
||||
m_pViewManager = new CViewManager;
|
||||
m_pIconManager = new CIconManager;
|
||||
@@ -301,8 +295,6 @@ CEditorImpl::~CEditorImpl()
|
||||
SAFE_DELETE(m_pViewManager)
|
||||
SAFE_DELETE(m_pObjectManager) // relies on prefab manager
|
||||
|
||||
SAFE_DELETE(m_panelEditorUtils);
|
||||
|
||||
// some plugins may be exporter - this must be above plugin manager delete.
|
||||
SAFE_DELETE(m_pExportManager);
|
||||
|
||||
@@ -900,11 +892,6 @@ void CEditorImpl::CloseView(const GUID& classId)
|
||||
}
|
||||
}
|
||||
|
||||
IDataBaseManager* CEditorImpl::GetDBItemManager([[maybe_unused]] EDataBaseItemType itemType)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CEditorImpl::SelectColor(QColor& color, QWidget* parent)
|
||||
{
|
||||
const AZ::Color c = AzQtComponents::fromQColor(color);
|
||||
@@ -1632,18 +1619,6 @@ SEditorSettings* CEditorImpl::GetEditorSettings()
|
||||
return &gSettings;
|
||||
}
|
||||
|
||||
// Vladimir@Conffx
|
||||
IBaseLibraryManager* CEditorImpl::GetMaterialManagerLibrary()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Vladimir@Conffx
|
||||
IEditorMaterialManager* CEditorImpl::GetIEditorMaterialManager()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IImageUtil* CEditorImpl::GetImageUtil()
|
||||
{
|
||||
return m_pImageUtil;
|
||||
@@ -1658,8 +1633,3 @@ void CEditorImpl::DestroyQMimeData(QMimeData* data) const
|
||||
{
|
||||
delete data;
|
||||
}
|
||||
|
||||
IEditorPanelUtils* CEditorImpl::GetEditorPanelUtils()
|
||||
{
|
||||
return m_panelEditorUtils;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,6 @@ public:
|
||||
void LockSelection(bool bLock) override;
|
||||
bool IsSelectionLocked() override;
|
||||
|
||||
IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType) override;
|
||||
CMusicManager* GetMusicManager() override { return m_pMusicManager; };
|
||||
|
||||
IEditorFileMonitor* GetFileMonitor() override;
|
||||
@@ -294,11 +293,8 @@ public:
|
||||
void RegisterObjectContextMenuExtension(TContextMenuExtensionFunc func) override;
|
||||
|
||||
SSystemGlobalEnvironment* GetEnv() override;
|
||||
IBaseLibraryManager* GetMaterialManagerLibrary() override; // Vladimir@Conffx
|
||||
IEditorMaterialManager* GetIEditorMaterialManager() override; // Vladimir@Conffx
|
||||
IImageUtil* GetImageUtil() override; // Vladimir@conffx
|
||||
SEditorSettings* GetEditorSettings() override;
|
||||
IEditorPanelUtils* GetEditorPanelUtils() override;
|
||||
ILogFile* GetLogFile() override { return m_pLogFile; }
|
||||
|
||||
void UnloadPlugins() override;
|
||||
@@ -356,7 +352,6 @@ protected:
|
||||
CErrorsDlg* m_pErrorsDlg;
|
||||
//! Source control interface.
|
||||
ISourceControl* m_pSourceControl;
|
||||
IEditorPanelUtils* m_panelEditorUtils;
|
||||
|
||||
CSelectionTreeManager* m_pSelectionTreeManager;
|
||||
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEDITOR_IPANELEDITORUTILS_H
|
||||
#define CRYINCLUDE_CRYEDITOR_IPANELEDITORUTILS_H
|
||||
#pragma once
|
||||
|
||||
#include "Cry_Vector3.h"
|
||||
|
||||
#include "DisplaySettings.h"
|
||||
#include "Include/IDisplayViewport.h"
|
||||
#include "Include/IIconManager.h"
|
||||
#include <qstringlist.h>
|
||||
#include <qkeysequence.h>
|
||||
#include <qevent.h>
|
||||
#include <QShortcutEvent>
|
||||
|
||||
class CBaseObject;
|
||||
class CViewport;
|
||||
class IQToolTip;
|
||||
|
||||
struct HotKey
|
||||
{
|
||||
HotKey()
|
||||
: path("")
|
||||
, sequence(QKeySequence())
|
||||
{
|
||||
}
|
||||
void CopyFrom(const HotKey& other)
|
||||
{
|
||||
path = other.path;
|
||||
sequence = other.sequence;
|
||||
}
|
||||
void SetPath(const char* _path)
|
||||
{
|
||||
path = QString(_path);
|
||||
}
|
||||
void SetSequenceFromString(const char* _sequence)
|
||||
{
|
||||
sequence = QKeySequence::fromString(_sequence);
|
||||
}
|
||||
void SetSequence(const QKeySequence& other)
|
||||
{
|
||||
sequence = other;
|
||||
}
|
||||
bool IsMatch(QString _path)
|
||||
{
|
||||
return path.compare(_path, Qt::CaseInsensitive) == 0;
|
||||
}
|
||||
bool IsMatch(QKeySequence _sequence)
|
||||
{
|
||||
return sequence.matches(_sequence);
|
||||
}
|
||||
bool operator < (const HotKey& other) const
|
||||
{
|
||||
//split the paths into lists compare per level
|
||||
QStringList m_categories = path.split('.');
|
||||
QStringList o_categories = other.path.split('.');
|
||||
int m_catSize = m_categories.size();
|
||||
int o_catSize = o_categories.size();
|
||||
int size = (m_catSize < o_catSize) ? m_catSize : o_catSize;
|
||||
|
||||
//sort categories to keep them together
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (m_categories[i] < o_categories[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (m_categories[i] > o_categories[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//if comparing a category and a item in that category the category is < item
|
||||
return m_catSize > o_catSize;
|
||||
}
|
||||
QKeySequence sequence;
|
||||
QString path;
|
||||
};
|
||||
|
||||
struct IEditorPanelUtils
|
||||
{
|
||||
virtual ~IEditorPanelUtils() {}
|
||||
virtual void SetViewportDragOperation(void(*)(CViewport* viewport, int dragPointX, int dragPointY, void* custom), void* custom) = 0;
|
||||
|
||||
//PREVIEW WINDOW UTILS////////////////////////////////////////////////////
|
||||
virtual int PreviewWindow_GetDisplaySettingsDebugFlags(CDisplaySettings* settings) = 0;
|
||||
virtual void PreviewWindow_SetDisplaySettingsDebugFlags(CDisplaySettings* settings, int flags) = 0;
|
||||
|
||||
//HOTKEY UTILS////////////////////////////////////////////////////////////
|
||||
virtual bool HotKey_Import() = 0;
|
||||
virtual void HotKey_Export() = 0;
|
||||
virtual QKeySequence HotKey_GetShortcut(const char* path) = 0;
|
||||
virtual bool HotKey_IsPressed(const QKeyEvent* event, const char* path) = 0;
|
||||
virtual bool HotKey_IsPressed(const QShortcutEvent* event, const char* path) = 0;
|
||||
virtual bool HotKey_LoadExisting() = 0;
|
||||
virtual void HotKey_SaveCurrent() = 0;
|
||||
virtual void HotKey_BuildDefaults() = 0;
|
||||
virtual void HotKey_SetKeys(QVector<HotKey> keys) = 0;
|
||||
virtual QVector<HotKey> HotKey_GetKeys() = 0;
|
||||
virtual QString HotKey_GetPressedHotkey(const QKeyEvent* event) = 0;
|
||||
virtual QString HotKey_GetPressedHotkey(const QShortcutEvent* event) = 0;
|
||||
virtual void HotKey_SetEnabled(bool val) = 0;
|
||||
virtual bool HotKey_IsEnabled() const = 0;
|
||||
|
||||
//TOOLTIP UTILS///////////////////////////////////////////////////////////
|
||||
|
||||
//! Loads a table of tooltip configuration data from an xml file.
|
||||
virtual void ToolTip_LoadConfigXML(QString filepath) = 0;
|
||||
|
||||
//! Initializes a QToolTipWidget from loaded configuration data (see ToolTip_LoadConfigXML())
|
||||
//! \param tooltip Will be initialized using loaded configuration data
|
||||
//! \param path Variable serialization path. Will be used as the key for looking up data in the configuration table. (ex: "Rotation.Rotation_Rate_X")
|
||||
//! \param option Name of a sub-option of the variable specified by "path". (ex: "Emitter_Strength" will look up the tooltip data for "Rotation.Rotation_Rate_X.Emitter_Strength")
|
||||
//! \param optionalData The argument to be used with "special_content" feature. See ToolTip_GetSpecialContentType() and QToolTipWidget::AddSpecialContent().
|
||||
//! \param isEnabled If false, the tooltip will indicate the reason why the widget is disabled.
|
||||
virtual void ToolTip_BuildFromConfig(IQToolTip* tooltip, QString path, QString option, QString optionalData = "", bool isEnabled = true) = 0;
|
||||
|
||||
virtual QString ToolTip_GetTitle(QString path, QString option = "") = 0;
|
||||
virtual QString ToolTip_GetContent(QString path, QString option = "") = 0;
|
||||
virtual QString ToolTip_GetSpecialContentType(QString path, QString option = "") = 0;
|
||||
virtual QString ToolTip_GetDisabledContent(QString path, QString option = "") = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -17,7 +17,6 @@
|
||||
class CGizmo;
|
||||
class CBaseObject;
|
||||
struct IDisplayViewport;
|
||||
class CDeepSelection;
|
||||
struct AABB;
|
||||
|
||||
#include <QRect>
|
||||
@@ -105,8 +104,6 @@ struct HitContext
|
||||
CBaseObject* object;
|
||||
//! gizmo object that have been hit.
|
||||
CGizmo* gizmo;
|
||||
//! for deep selection mode
|
||||
CDeepSelection* pDeepSelection;
|
||||
//! For linking tool
|
||||
const char* name;
|
||||
//! true if this hit was from the object icon
|
||||
@@ -131,7 +128,6 @@ struct HitContext
|
||||
bIgnoreAxis = false;
|
||||
bOnlyGizmo = false;
|
||||
bUseSelectionHelpers = false;
|
||||
pDeepSelection = 0;
|
||||
name = nullptr;
|
||||
iconHit = false;
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IANIMATIONCOMPRESSIONMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IANIMATIONCOMPRESSIONMANAGER_H
|
||||
#pragma once
|
||||
|
||||
struct IAnimationCompressionManager
|
||||
{
|
||||
virtual bool IsEnabled() const = 0;
|
||||
virtual void UpdateLocalAnimations() = 0;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IANIMATIONCOMPRESSIONMANAGER_H
|
||||
@@ -1,433 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Standard interface for asset display in the asset browser,
|
||||
// this header should be used to create plugins.
|
||||
// The method Release of this interface should NOT be called.
|
||||
// Instead, the FreeData from the database (from IAssetItemDatabase) should
|
||||
// be used as it will safely release all the items from the database.
|
||||
// It is still possible to call the release method, but this is not the
|
||||
// recomended method, specially for usage outside of the plugins because there
|
||||
// is no guarantee that a the asset will be properly removed from the database
|
||||
// manager.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IASSETITEM_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IASSETITEM_H
|
||||
#pragma once
|
||||
|
||||
struct IAssetItemDatabase;
|
||||
|
||||
namespace AssetViewer
|
||||
{
|
||||
// Used in GetAssetFieldValue for each asset type to check if field name is the right one
|
||||
inline bool IsFieldName(const char* pIncomingFieldName, const char* pFieldName)
|
||||
{
|
||||
return !strncmp(pIncomingFieldName, pFieldName, strlen(pIncomingFieldName));
|
||||
}
|
||||
}
|
||||
|
||||
// Description:
|
||||
// This interface allows the programmer to extend asset display types visible in the asset browser.
|
||||
struct IAssetItem
|
||||
: public IUnknown
|
||||
{
|
||||
DEFINE_UUID(0x04F20346, 0x2EC3, 0x43f2, 0xBD, 0xA1, 0x2C, 0x0B, 0x97, 0x76, 0xF3, 0x84);
|
||||
|
||||
// The supported asset flags
|
||||
enum EAssetFlags
|
||||
{
|
||||
// asset is visible in the database for filtering and sorting (not asset view control related)
|
||||
eFlag_Visible = BIT(0),
|
||||
// the asset is loaded
|
||||
eFlag_Loaded = BIT(1),
|
||||
// the asset is loaded
|
||||
eFlag_Cached = BIT(2),
|
||||
// the asset is selected in a selection set
|
||||
eFlag_Selected = BIT(3),
|
||||
// this asset is invalid, no thumb is shown/available
|
||||
eFlag_Invalid = BIT(4),
|
||||
// this asset has some errors/warnings, in the asset browser it will show some blinking/red elements
|
||||
// and the user can check out the errors. Error text will be fetched using GetAssetFieldValue( "errors", &someStringVar )
|
||||
eFlag_HasErrors = BIT(5),
|
||||
// this flag is set when the asset is rendering its contents using GDI, and not the engine's rendering capabilities
|
||||
// (this flags is used as hint for the preview tool, which will use a double-buffer canvas if this flag is set,
|
||||
// and send a memory HDC to the OnBeginPreview method, for drawing of the asset)
|
||||
eFlag_UseGdiRendering = BIT(6),
|
||||
// set if this asset is draggable into the render viewports, and can be created there
|
||||
eFlag_CanBeDraggedInViewports = BIT(7),
|
||||
// set if this asset can be moved after creation, otherwise the asset instance will just be created where user clicked
|
||||
eFlag_CanBeMovedAfterDroppedIntoViewport = BIT(8),
|
||||
// the asset thumbnail image is loaded
|
||||
eFlag_ThumbnailLoaded = BIT(9),
|
||||
// the asset thumbnail image is loaded
|
||||
eFlag_UsedInLevel = BIT(10)
|
||||
};
|
||||
|
||||
// Asset field name and field values map
|
||||
typedef std::map < QString/*fieldName*/, QString/*value*/ > TAssetFieldValuesMap;
|
||||
// Dependency category names and corresponding files map, example: "Textures"=>{ "foam.dds","water.dds","normal.dds" }
|
||||
typedef std::map < QString/*dependencyCategory*/, std::set<QString>/*dependency filenames*/ > TAssetDependenciesMap;
|
||||
|
||||
virtual ~IAssetItem() {
|
||||
}
|
||||
|
||||
// Description:
|
||||
// Get the hash number/key used for database thumbnail and info records management
|
||||
virtual uint32 GetHash() const = 0;
|
||||
// Description:
|
||||
// Set the hash number/key used for database thumbnail and info records management
|
||||
virtual void SetHash(uint32 hash) = 0;
|
||||
// Description:
|
||||
// Get the owner database for this asset
|
||||
// Return Value:
|
||||
// The owner database for this asset
|
||||
// See Also:
|
||||
// SetOwnerDatabase()
|
||||
virtual IAssetItemDatabase* GetOwnerDatabase() const = 0;
|
||||
// Description:
|
||||
// Set the owner database for this asset
|
||||
// Arguments:
|
||||
// piOwnerDisplayDatabase - the owner database
|
||||
// See Also:
|
||||
// GetOwnerDatabase()
|
||||
virtual void SetOwnerDatabase(IAssetItemDatabase* pOwnerDisplayDatabase) = 0;
|
||||
// Description:
|
||||
// Get the asset's dependency files / objects
|
||||
// Return Value:
|
||||
// The vector with filenames which this asset is dependent upon, ex.: ["Textures"].(vector of textures)
|
||||
virtual const TAssetDependenciesMap& GetDependencies() const = 0;
|
||||
// Description:
|
||||
// Set the file size of this asset in bytes
|
||||
// Arguments:
|
||||
// aSize - size of the file in bytes
|
||||
// See Also:
|
||||
// GetFileSize()
|
||||
virtual void SetFileSize(quint64 aSize) = 0;
|
||||
// Description:
|
||||
// Get the file size of this asset in bytes
|
||||
// Return Value:
|
||||
// The file size of this asset in bytes
|
||||
// See Also:
|
||||
// SetFileSize()
|
||||
virtual quint64 GetFileSize() const = 0;
|
||||
// Description:
|
||||
// Set asset filename (extension included and no path)
|
||||
// Arguments:
|
||||
// pName - the asset filename (extension included and no path)
|
||||
// See Also:
|
||||
// GetFilename()
|
||||
virtual void SetFilename(const char* pName) = 0;
|
||||
// Description:
|
||||
// Get asset filename (extension included and no path)
|
||||
// Return Value:
|
||||
// The asset filename (extension included and no path)
|
||||
// See Also:
|
||||
// SetFilename()
|
||||
virtual QString GetFilename() const = 0;
|
||||
// Description:
|
||||
// Set the asset's relative path
|
||||
// Arguments:
|
||||
// pName - file's relative path
|
||||
// See Also:
|
||||
// GetRelativePath()
|
||||
virtual void SetRelativePath(const char* pName) = 0;
|
||||
// Description:
|
||||
// Get the asset's relative path
|
||||
// Return Value:
|
||||
// The asset's relative path
|
||||
// See Also:
|
||||
// SetRelativePath()
|
||||
virtual QString GetRelativePath() const = 0;
|
||||
// Description:
|
||||
// Set the file extension ( dot(s) must be included )
|
||||
// Arguments:
|
||||
// pExt - the file's extension
|
||||
// See Also:
|
||||
// GetFileExtension()
|
||||
virtual void SetFileExtension(const char* pExt) = 0;
|
||||
// Description:
|
||||
// Get the file extension ( dot(s) included )
|
||||
// Return Value:
|
||||
// The file extension ( dot(s) included )
|
||||
// See Also:
|
||||
// SetFileExtension()
|
||||
virtual QString GetFileExtension() const = 0;
|
||||
// Description:
|
||||
// Get the asset flags, with values from IAssetItem::EAssetFlags
|
||||
// Return Value:
|
||||
// The asset flags, with values from IAssetItem::EAssetFlags
|
||||
// See Also:
|
||||
// SetFlags(), SetFlag(), IsFlagSet()
|
||||
virtual UINT GetFlags() const = 0;
|
||||
// Description:
|
||||
// Set the asset flags
|
||||
// Arguments:
|
||||
// aFlags - flags, OR-ed values from IAssetItem::EAssetFlags
|
||||
// See Also:
|
||||
// GetFlags(), SetFlag(), IsFlagSet()
|
||||
virtual void SetFlags(UINT aFlags) = 0;
|
||||
// Description:
|
||||
// Set/clear a single flag bit for the asset
|
||||
// Arguments:
|
||||
// aFlag - the flag to set/clear, with values from IAssetItem::EAssetFlags
|
||||
// See Also:
|
||||
// GetFlags(), SetFlags(), IsFlagSet()
|
||||
virtual void SetFlag(EAssetFlags aFlag, bool bSet = true) = 0;
|
||||
// Description:
|
||||
// Check if a specified flag is set
|
||||
// Arguments:
|
||||
// aFlag - the flag to check, with values from IAssetItem::EAssetFlags
|
||||
// Return Value:
|
||||
// True if the flag is set
|
||||
// See Also:
|
||||
// GetFlags(), SetFlags(), SetFlag()
|
||||
virtual bool IsFlagSet(EAssetFlags aFlag) const = 0;
|
||||
// Description:
|
||||
// Set this asset's index; used in sorting, selections, and to know where an asset is in the current list
|
||||
// Arguments:
|
||||
// aIndex - the asset's index
|
||||
// See Also:
|
||||
// GetIndex()
|
||||
virtual void SetIndex(UINT aIndex) = 0;
|
||||
// Description:
|
||||
// Get the asset's index in the current list
|
||||
// Return Value:
|
||||
// The asset's index in the current list
|
||||
// See Also:
|
||||
// SetIndex()
|
||||
virtual UINT GetIndex() const = 0;
|
||||
// Description:
|
||||
// Get the asset's field raw data value into a user location, you must check the field's type ( from asset item's owner database )
|
||||
// before using this function and send the correct pointer to destination according to the type ( int8, float32, string, etc. )
|
||||
// Arguments:
|
||||
// pFieldName - the asset field name to query the value for
|
||||
// pDest - the destination variable address, must be the same type as the field type
|
||||
// Return Value:
|
||||
// True if the asset field name is found and the value is returned correctly
|
||||
// See Also:
|
||||
// SetAssetFieldValue()
|
||||
virtual QVariant GetAssetFieldValue(const char* pFieldName) const = 0;
|
||||
// Description:
|
||||
// Set the asset's field raw data value from a user location, you must check the field's type ( from asset item's owner database )
|
||||
// before using this function and send the correct pointer to source according to the type ( int8, float32, string, etc. )
|
||||
// Arguments:
|
||||
// pFieldName - the asset field name to set the value for
|
||||
// pSrc - the source variable address, must be the same type as the field type
|
||||
// Return Value:
|
||||
// True if the asset field name is found and the value is set correctly
|
||||
// See Also:
|
||||
// GetAssetFieldValue()
|
||||
virtual bool SetAssetFieldValue(const char* pFieldName, void* pSrc) = 0;
|
||||
// Description:
|
||||
// Get the drawing rectangle for the asset's thumb ( absolute viewer canvas location )
|
||||
// Arguments:
|
||||
// rstDrawingRectangle - destination location to set with the asset's thumbnail rectangle location
|
||||
// See Also:
|
||||
// SetDrawingRectangle()
|
||||
virtual void GetDrawingRectangle(QRect& rstDrawingRectangle) const = 0;
|
||||
// Description:
|
||||
// Set the drawing rectangle for the asset's thumb ( absolute viewer canvas location )
|
||||
// Arguments:
|
||||
// crstDrawingRectangle - source to set the asset's thumbnail rectangle
|
||||
// See Also:
|
||||
// GetDrawingRectangle()
|
||||
virtual void SetDrawingRectangle(const QRect& crstDrawingRectangle) = 0;
|
||||
// Description:
|
||||
// Checks if the given 2D point is inside the asset's thumb rectangle
|
||||
// Arguments:
|
||||
// nX - mouse pointer position on X axis, relative to the asset viewer control
|
||||
// nY - mouse pointer position on Y axis, relative to the asset viewer control
|
||||
// Return Value:
|
||||
// True if the given 2D point is inside the asset's thumb rectangle
|
||||
// See Also:
|
||||
// HitTest(CRect)
|
||||
virtual bool HitTest(int nX, int nY) const = 0;
|
||||
// Description:
|
||||
// Checks if the given rectangle intersects the asset thumb's rectangle
|
||||
// Arguments:
|
||||
// nX - mouse pointer position on X axis, relative to the asset viewer control
|
||||
// nY - mouse pointer position on Y axis, relative to the asset viewer control
|
||||
// Return Value:
|
||||
// True if the given rectangle intersects the asset thumb's rectangle
|
||||
// See Also:
|
||||
// HitTest(int nX,int nY)
|
||||
virtual bool HitTest(const QRect& roTestRect) const = 0;
|
||||
// Description:
|
||||
// When user drags this asset item into a viewport, this method is called when the dragging operation ends
|
||||
// and the mouse button is released, for the asset to return an instance of the asset object to be placed in the level
|
||||
// Arguments:
|
||||
// aX - instance's X position component in world coordinates
|
||||
// aY - instance's Y position component in world coordinates
|
||||
// aZ - instance's Z position component in world coordinates
|
||||
// Return Value:
|
||||
// The newly created asset instance (Example: BrushObject*)
|
||||
// See Also:
|
||||
// MoveInstanceInViewport()
|
||||
virtual void* CreateInstanceInViewport(float aX, float aY, float aZ) = 0;
|
||||
// Description:
|
||||
// When the mouse button is released after level object creation, the user now can move the mouse
|
||||
// and move the asset instance in the 3D world
|
||||
// Arguments:
|
||||
// pDraggedObject - the actual entity or brush object (CBaseObject* usually) to be moved around with the mouse
|
||||
// returned by the CreateInstanceInViewport()
|
||||
// aNewX - the new X world coordinates of the asset instance
|
||||
// aNewY - the new Y world coordinates of the asset instance
|
||||
// aNewZ - the new Z world coordinates of the asset instance
|
||||
// Return Value:
|
||||
// True if asset instance was moved properly
|
||||
// See Also:
|
||||
// CreateInstanceInViewport()
|
||||
virtual bool MoveInstanceInViewport(const void* pDraggedObject, float aNewX, float aNewY, float aNewZ) = 0;
|
||||
// Description:
|
||||
// This will be called when the user presses ESCAPE key when dragging the asset in the viewport, you must delete the given object
|
||||
// because the creation was aborted
|
||||
// Arguments:
|
||||
// pDraggedObject - the asset instance to be deleted ( you must cast to the needed type, and delete it properly )
|
||||
// See Also:
|
||||
// CreateInstanceInViewport()
|
||||
virtual void AbortCreateInstanceInViewport(const void* pDraggedObject) = 0;
|
||||
// Description:
|
||||
// This method is used to cache/load asset's data, so it can be previewed/rendered
|
||||
// Return Value:
|
||||
// True if the asset was successfully cached
|
||||
// See Also:
|
||||
// UnCache()
|
||||
virtual bool Cache() = 0;
|
||||
// Description:
|
||||
// This method is used to force cache/load asset's data, so it can be previewed/rendered
|
||||
// Return Value:
|
||||
// True if the asset was successfully forced cached
|
||||
// See Also:
|
||||
// UnCache(), Cache()
|
||||
virtual bool ForceCache() = 0;
|
||||
// Description:
|
||||
// This method is used to load the thumbnail image of the asset
|
||||
// Return Value:
|
||||
// True if thumb loaded ok
|
||||
// See Also:
|
||||
// UnloadThumbnail()
|
||||
virtual bool LoadThumbnail() = 0;
|
||||
// Description:
|
||||
// This method is used to unload the thumbnail image of the asset
|
||||
// See Also:
|
||||
// LoadThumbnail()
|
||||
virtual void UnloadThumbnail() = 0;
|
||||
// Description:
|
||||
// This is called when the asset starts to be previewed in full detail, so here you can load the whole asset, in fine detail
|
||||
// ( textures are fully loaded, models etc. ). It is called once, when the Preview dialog is shown
|
||||
// Arguments:
|
||||
// hPreviewWnd - the window handle of the quick preview dialog
|
||||
// hMemDC - the memory DC used to render assets that can render themselves in the DC, otherwise they will render in the dialog's HWND
|
||||
// See Also:
|
||||
// OnEndPreview(), GetCustomPreviewPanelHeader()
|
||||
virtual void OnBeginPreview(QWidget* hPreviewWnd) = 0;
|
||||
// Description:
|
||||
// Called when the Preview dialog is closed, you may release the detail asset data here
|
||||
// See Also:
|
||||
// OnBeginPreview(), GetCustomPreviewPanelHeader()
|
||||
virtual void OnEndPreview() = 0;
|
||||
// Description:
|
||||
// If the asset has a special preview panel with utility controls, to be placed at the top of the Preview window, it can return an child dialog window
|
||||
// otherwise it can return nullptr, if no panel is available
|
||||
// Arguments:
|
||||
// pParentWnd - a valid CDialog*, or nullptr
|
||||
// Return Value:
|
||||
// A valid child dialog window handle, if this asset wants to have a custom panel in the top side of the Asset Preview window,
|
||||
// otherwise it can return nullptr, if no panel is available
|
||||
// See Also:
|
||||
// OnBeginPreview(), OnEndPreview()
|
||||
virtual QWidget* GetCustomPreviewPanelHeader(QWidget* pParentWnd) = 0;
|
||||
virtual QWidget* GetCustomPreviewPanelFooter(QWidget* pParentWnd) = 0;
|
||||
// Description:
|
||||
// Used when dragging/rotate/zoom a model, or other asset that can support preview
|
||||
// Arguments:
|
||||
// hRenderWindow - the rendering window handle
|
||||
// rstViewport - the viewport rectangle
|
||||
// aMouseX - the render window relative mouse pointer X coordinate
|
||||
// aMouseY - the render window relative mouse pointer Y coordinate
|
||||
// aMouseDeltaX - the X coordinate delta between two mouse movements
|
||||
// aMouseDeltaY - the Y coordinate delta between two mouse movements
|
||||
// aMouseWheelDelta - the mouse wheel scroll delta/step
|
||||
// aKeyFlags - the key flags, see WM_LBUTTONUP
|
||||
// See Also:
|
||||
// OnPreviewRenderKeyEvent()
|
||||
virtual void PreviewRender(
|
||||
QWidget* hRenderWindow,
|
||||
const QRect& rstViewport,
|
||||
int aMouseX = 0, int aMouseY = 0,
|
||||
int aMouseDeltaX = 0, int aMouseDeltaY = 0,
|
||||
int aMouseWheelDelta = 0, UINT aKeyFlags = 0) = 0;
|
||||
// Description:
|
||||
// This is called when the user manipulates the assets in interactive render and a key is pressed ( with down or up state )
|
||||
// Arguments:
|
||||
// bKeyDown - true if this is a WM_KEYDOWN event, else it is a WM_KEYUP event
|
||||
// aChar - the char/key code pressed/released
|
||||
// aKeyFlags - the key flags, compatible with WM_KEYDOWN/UP events
|
||||
// See Also:
|
||||
// InteractiveRender()
|
||||
virtual void OnPreviewRenderKeyEvent(bool bKeyDown, UINT aChar, UINT aKeyFlags) = 0;
|
||||
// Description:
|
||||
// Called when user clicked once on the thumb image
|
||||
// Arguments:
|
||||
// point - mouse coordinates relative to the thumbnail rectangle
|
||||
// aKeyFlags - the key flags, see WM_LBUTTONDOWN
|
||||
// See Also:
|
||||
// OnThumbDblClick()
|
||||
virtual void OnThumbClick(const QPoint& point, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) = 0;
|
||||
// Description:
|
||||
// Called when user double clicked on the thumb image
|
||||
// Arguments:
|
||||
// point - mouse coordinates relative to the thumbnail rectangle
|
||||
// aKeyFlags - the key flags, see WM_LBUTTONDOWN
|
||||
// See Also:
|
||||
// OnThumbClick()
|
||||
//! called when user clicked twice on the thumb image
|
||||
virtual void OnThumbDblClick(const QPoint& point, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) = 0;
|
||||
// Description:
|
||||
// Draw the cached thumb bitmap only, if any, no other kind of rendering
|
||||
// Arguments:
|
||||
// hDC - the destination DC, where to draw the thumb
|
||||
// rRect - the destination rectangle
|
||||
// Return Value:
|
||||
// True if drawing of the thumbnail was done OK
|
||||
// See Also:
|
||||
// Render()
|
||||
virtual bool DrawThumbImage(QPainter* painter, const QRect& rRect) = 0;
|
||||
// Description:
|
||||
// Writes asset info to a XML node.
|
||||
// This is needed to save cached info as a persistent XML file for the next run of the editor.
|
||||
// Arguments:
|
||||
// node - An XML node to contain the info
|
||||
// See Also:
|
||||
// FromXML()
|
||||
virtual void ToXML(XmlNodeRef& node) const = 0;
|
||||
// Description:
|
||||
// Gets asset info from a XML node.
|
||||
// This is needed to get the asset info from previous runs of the editor without re-caching it.
|
||||
// Arguments:
|
||||
// node - An XML node that contains info for this asset
|
||||
// See Also:
|
||||
// ToXML()
|
||||
virtual void FromXML(const XmlNodeRef& node) = 0;
|
||||
|
||||
// From IUnknown
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface([[maybe_unused]] const IID& riid, [[maybe_unused]] void** ppvObject)
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
};
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef()
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
virtual ULONG STDMETHODCALLTYPE Release()
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IASSETITEM_H
|
||||
@@ -1,259 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Standard interface for asset database creators used to
|
||||
// create an asset plugin for the asset browser
|
||||
// The category of the plugin must be Asset Item DB
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IASSETITEMDATABASE_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IASSETITEMDATABASE_H
|
||||
#pragma once
|
||||
struct IAssetItem;
|
||||
struct IAssetViewer;
|
||||
|
||||
class QString;
|
||||
class QStringList;
|
||||
|
||||
// Description:
|
||||
// This struct keeps the info, filter and sorting settings for an asset field
|
||||
struct SAssetField
|
||||
{
|
||||
// the condition for the current filter on the field
|
||||
enum EAssetFilterCondition
|
||||
{
|
||||
eCondition_Any = 0,
|
||||
// string conditions
|
||||
// this also supports '*' and '?' as wildcards inside text
|
||||
eCondition_Contains,
|
||||
// this filter will search the target for at least one of the words specified
|
||||
// ( ex: filter: "water car moon" , field value : "the_great_moon.dds", this will pass the test
|
||||
// it also supports '*' and '?' as wildcards inside words text
|
||||
eCondition_ContainsOneOfTheWords,
|
||||
eCondition_StartsWith,
|
||||
eCondition_EndsWith,
|
||||
// string & numerical conditions
|
||||
eCondition_Equal,
|
||||
eCondition_Greater,
|
||||
eCondition_Less,
|
||||
eCondition_GreaterOrEqual,
|
||||
eCondition_LessOrEqual,
|
||||
eCondition_Not,
|
||||
eCondition_InsideRange
|
||||
};
|
||||
|
||||
// the asset field type
|
||||
enum EAssetFieldType
|
||||
{
|
||||
eType_None = 0,
|
||||
eType_Bool,
|
||||
eType_Int8,
|
||||
eType_Int16,
|
||||
eType_Int32,
|
||||
eType_Int64,
|
||||
eType_Float,
|
||||
eType_Double,
|
||||
eType_String
|
||||
};
|
||||
|
||||
// used when a field can have different specific values
|
||||
typedef QStringList TFieldEnumValues;
|
||||
|
||||
SAssetField(
|
||||
const char* pFieldName = "",
|
||||
const char* pDisplayName = "Unnamed field",
|
||||
EAssetFieldType aFieldType = eType_None,
|
||||
UINT aColumnWidth = 50,
|
||||
bool bVisibleInUI = true,
|
||||
bool bReadOnly = true)
|
||||
{
|
||||
m_fieldName = pFieldName;
|
||||
m_displayName = pDisplayName;
|
||||
m_fieldType = aFieldType;
|
||||
m_filterCondition = eCondition_Equal;
|
||||
m_bUseEnumValues = false;
|
||||
m_bReadOnly = bReadOnly;
|
||||
m_listColumnWidth = aColumnWidth;
|
||||
m_bFieldVisibleInUI = bVisibleInUI;
|
||||
m_bPostFilter = false;
|
||||
|
||||
SetupEnumValues();
|
||||
}
|
||||
|
||||
void SetupEnumValues()
|
||||
{
|
||||
m_bUseEnumValues = true;
|
||||
|
||||
if (m_fieldType == eType_Bool)
|
||||
{
|
||||
m_enumValues.clear();
|
||||
m_enumValues.push_back("Yes");
|
||||
m_enumValues.push_back("No");
|
||||
}
|
||||
}
|
||||
|
||||
// the field's display name, used in UI
|
||||
QString m_displayName,
|
||||
// the field internal name, used in C++ code
|
||||
m_fieldName,
|
||||
// the current filter value, if its empty "" then no filter is applied
|
||||
m_filterValue,
|
||||
// the field's max value, valid when the field's filter condition is eAssertFilterCondition_InsideRange
|
||||
m_maxFilterValue,
|
||||
// the name of the database holding this field, used in Asset Browser preset editor, if its "" then the field
|
||||
// is common to all current databases
|
||||
m_parentDatabaseName;
|
||||
// is this field visible in the UI ?
|
||||
bool m_bFieldVisibleInUI,
|
||||
// if true, then you cannot modify this field of an asset item, only use it
|
||||
m_bReadOnly,
|
||||
// this field filter is applied after the other filters
|
||||
m_bPostFilter;
|
||||
// the field data type
|
||||
EAssetFieldType m_fieldType;
|
||||
// the filter's condition
|
||||
EAssetFilterCondition m_filterCondition;
|
||||
// use the enum list values to choose a value for the field ?
|
||||
bool m_bUseEnumValues;
|
||||
// this map is used when asset field has m_bUseEnumValues on true,
|
||||
// choose a value for the field from this list in the UI
|
||||
TFieldEnumValues m_enumValues;
|
||||
// recommended list column width
|
||||
unsigned int m_listColumnWidth;
|
||||
};
|
||||
|
||||
struct SFieldFiltersPreset
|
||||
{
|
||||
QString presetName2;
|
||||
QStringList checkedDatabaseNames;
|
||||
bool bUsedInLevel;
|
||||
std::vector<SAssetField> fields;
|
||||
};
|
||||
|
||||
// Description:
|
||||
// This interface allows the programmer to extend asset display types
|
||||
// visible in the asset browser.
|
||||
struct IAssetItemDatabase
|
||||
: public IUnknown
|
||||
{
|
||||
DEFINE_UUID(0xFB09B039, 0x1D9D, 0x4057, 0xA5, 0xF0, 0xAA, 0x3C, 0x7B, 0x97, 0xAE, 0xA8)
|
||||
|
||||
typedef std::vector<SAssetField> TAssetFields;
|
||||
typedef std::map < QString/*field name*/, SAssetField > TAssetFieldFiltersMap;
|
||||
typedef std::map < QString/*asset filename*/, IAssetItem* > TFilenameAssetMap;
|
||||
typedef AZStd::function<bool(const IAssetItem*)> MetaDataChangeListener;
|
||||
|
||||
// Description:
|
||||
// Refresh the database by scanning the folders/paks for files, does not load the files, only filename and filesize are fetched
|
||||
virtual void Refresh() = 0;
|
||||
// Description:
|
||||
// Fills the asset meta data from the loaded xml meta data DB.
|
||||
// Arguments:
|
||||
// db - the database XML node from where to cache the info
|
||||
virtual void PrecacheFieldsInfoFromFileDB(const XmlNodeRef& db) = 0;
|
||||
// Description:
|
||||
// Return all assets loaded/scanned by this database
|
||||
// Return Value:
|
||||
// The assets map reference (filename-asset)
|
||||
virtual TFilenameAssetMap& GetAssets() = 0;
|
||||
// Description:
|
||||
// Get an asset item by its filename
|
||||
// Return Value:
|
||||
// A single asset from the database given the filename
|
||||
virtual IAssetItem* GetAsset(const char* pAssetFilename) = 0;
|
||||
// Description:
|
||||
// Return the asset fields this database's items support
|
||||
// Return Value:
|
||||
// The asset fields vector reference
|
||||
virtual TAssetFields& GetAssetFields() = 0;
|
||||
// Description:
|
||||
// Return an asset field object pointer by the field internal name
|
||||
// Arguments:
|
||||
// pFieldName - the internal field's name (ex: "filename", "relativepath")
|
||||
// Return Value:
|
||||
// The asset field object pointer
|
||||
virtual SAssetField* GetAssetFieldByName(const char* pFieldName) = 0;
|
||||
// Description:
|
||||
// Get the database name
|
||||
// Return Value:
|
||||
// Returns the database name, ex: "Textures"
|
||||
virtual const char* GetDatabaseName() const = 0;
|
||||
// Description:
|
||||
// Get the database supported file name extension(s)
|
||||
// Return Value:
|
||||
// Returns the supported extensions, separated by comma, ex: "tga,bmp,dds"
|
||||
virtual const char* GetSupportedExtensions() const = 0;
|
||||
// Description:
|
||||
// Free the database internal data structures
|
||||
virtual void FreeData() = 0;
|
||||
// Description:
|
||||
// Apply filters to this database which will set/unset the IAssetItem::eAssetFlag_Visible of each asset, based
|
||||
// on the given field filters
|
||||
// Arguments:
|
||||
// rFieldFilters - a reference to the field filters map (fieldname-field)
|
||||
// See Also:
|
||||
// ClearFilters()
|
||||
virtual void ApplyFilters(const TAssetFieldFiltersMap& rFieldFilters) = 0;
|
||||
// Description:
|
||||
// Clear the current filters, by setting the IAssetItem::eAssetFlag_Visible of each asset to true
|
||||
// See Also:
|
||||
// ApplyFilters()
|
||||
virtual void ClearFilters() = 0;
|
||||
virtual QWidget* CreateDbFilterDialog(QWidget* pParent, IAssetViewer* pViewerCtrl) = 0;
|
||||
virtual void UpdateDbFilterDialogUI(QWidget* pDlg) = 0;
|
||||
virtual void OnAssetBrowserOpen() = 0;
|
||||
virtual void OnAssetBrowserClose() = 0;
|
||||
// Description:
|
||||
// Gets the filename for saving new cached asset info.
|
||||
// Return Value:
|
||||
// A file name to save new transactions to the persistent asset info DB
|
||||
// See Also:
|
||||
// CAssetInfoFileDB, IAssetItem::ToXML(), IAssetItem::FromXML()
|
||||
virtual const char* GetTransactionFilename() const = 0;
|
||||
// Description:
|
||||
// Adds a callback to be called when the meta data of this asset changed.
|
||||
// Arguments:
|
||||
// callBack - A functor to be added
|
||||
// Return Value:
|
||||
// True if successful, false otherwise.
|
||||
// See Also:
|
||||
// RemoveMetaDataChangeListener()
|
||||
virtual bool AddMetaDataChangeListener(MetaDataChangeListener callBack) = 0;
|
||||
// Description:
|
||||
// Removes a callback from the list of meta data change listeners.
|
||||
// Arguments:
|
||||
// callBack - A functor to be removed
|
||||
// Return Value:
|
||||
// True if successful, false otherwise.
|
||||
// See Also:
|
||||
// AddMetaDataCHangeListener()
|
||||
virtual bool RemoveMetaDataChangeListener(MetaDataChangeListener callBack) = 0;
|
||||
// Description:
|
||||
// The method that should be called when the meta data of an asset item changes to notify all listeners
|
||||
// Arguments:
|
||||
// pAssetItem - An asset item whose meta data have changed
|
||||
// See Also:
|
||||
// AddMetaDataCHangeListener(), RemoveMetaDataChangeListener()
|
||||
virtual void OnMetaDataChange(const IAssetItem* pAssetItem) = 0;
|
||||
|
||||
//! from IUnknown
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface([[maybe_unused]] REFIID riid, [[maybe_unused]] void** ppvObject)
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
};
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef()
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
virtual ULONG STDMETHODCALLTYPE Release()
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IASSETITEMDATABASE_H
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : This file declares a control which objective is to display
|
||||
// multiple assets allowing selection and preview of such things
|
||||
// It also handles scrolling and changes in the thumbnail display size
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IASSETVIEWER_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IASSETVIEWER_H
|
||||
#pragma once
|
||||
#include "IObservable.h"
|
||||
#include "IAssetItemDatabase.h"
|
||||
|
||||
struct IAssetItem;
|
||||
struct IAssetItemDatabase;
|
||||
|
||||
// Description:
|
||||
// Observer for the asset viewer events
|
||||
struct IAssetViewerObserver
|
||||
{
|
||||
virtual void OnChangeStatusBarInfo(UINT nSelectedItems, UINT nVisibleItems, UINT nTotalItems) {};
|
||||
virtual void OnSelectionChanged() {};
|
||||
virtual void OnChangedPreviewedAsset(IAssetItem* pAsset) {};
|
||||
virtual void OnAssetDblClick(IAssetItem* pAsset) {};
|
||||
virtual void OnAssetFilterChanged() {};
|
||||
};
|
||||
|
||||
// Description:
|
||||
// The asset viewer interface for the asset database plugins to use
|
||||
struct IAssetViewer
|
||||
{
|
||||
DEFINE_OBSERVABLE_PURE_METHODS(IAssetViewerObserver);
|
||||
|
||||
virtual HWND GetRenderWindow() = 0;
|
||||
virtual void ApplyFilters(const IAssetItemDatabase::TAssetFieldFiltersMap& rFieldFilters) = 0;
|
||||
virtual const IAssetItemDatabase::TAssetFieldFiltersMap& GetCurrentFilters() = 0;
|
||||
virtual void ClearFilters() = 0;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IASSETVIEWER_H
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IBASELIBRARYMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IBASELIBRARYMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include <IEditor.h>
|
||||
#include "Include/IDataBaseItem.h"
|
||||
#include "Include/IDataBaseLibrary.h"
|
||||
#include "Include/IDataBaseManager.h"
|
||||
#include "Util/TRefCountBase.h"
|
||||
|
||||
class CBaseLibraryItem;
|
||||
class CBaseLibrary;
|
||||
|
||||
struct IBaseLibraryManager
|
||||
: public TRefCountBase<IDataBaseManager>
|
||||
, public IEditorNotifyListener
|
||||
{
|
||||
//! Clear all libraries.
|
||||
virtual void ClearAll() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// IDocListener implementation.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Library items.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Make a new item in specified library.
|
||||
virtual IDataBaseItem* CreateItem(IDataBaseLibrary* pLibrary) = 0;
|
||||
//! Delete item from library and manager.
|
||||
virtual void DeleteItem(IDataBaseItem* pItem) = 0;
|
||||
|
||||
//! Find Item by its GUID.
|
||||
virtual IDataBaseItem* FindItem(REFGUID guid) const = 0;
|
||||
virtual IDataBaseItem* FindItemByName(const QString& fullItemName) = 0;
|
||||
virtual IDataBaseItem* LoadItemByName(const QString& fullItemName) = 0;
|
||||
|
||||
virtual IDataBaseItemEnumerator* GetItemEnumerator() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Set item currently selected.
|
||||
virtual void SetSelectedItem(IDataBaseItem* pItem) = 0;
|
||||
// Get currently selected item.
|
||||
virtual IDataBaseItem* GetSelectedItem() const = 0;
|
||||
virtual IDataBaseItem* GetSelectedParentItem() const = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Libraries.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Add Item library.
|
||||
virtual IDataBaseLibrary* AddLibrary(const QString& library, bool isLevelLibrary = false, bool bIsLoading = true) = 0;
|
||||
virtual void DeleteLibrary(const QString& library, bool forceDeleteLevel = false) = 0;
|
||||
//! Get number of libraries.
|
||||
virtual int GetLibraryCount() const = 0;
|
||||
//! Get number of modified libraries.
|
||||
virtual int GetModifiedLibraryCount() const = 0;
|
||||
|
||||
//! Get Item library by index.
|
||||
virtual IDataBaseLibrary* GetLibrary(int index) const = 0;
|
||||
|
||||
//! Get Level Item library.
|
||||
virtual IDataBaseLibrary* GetLevelLibrary() const = 0;
|
||||
|
||||
//! Find Items Library by name.
|
||||
virtual IDataBaseLibrary* FindLibrary(const QString& library) = 0;
|
||||
|
||||
//! Find the Library's index by name.
|
||||
virtual int FindLibraryIndex(const QString& library) = 0;
|
||||
|
||||
//! Load Items library.
|
||||
#ifdef LoadLibrary
|
||||
#undef LoadLibrary
|
||||
#endif
|
||||
virtual IDataBaseLibrary* LoadLibrary(const QString& filename, bool bReload = false) = 0;
|
||||
|
||||
//! Save all modified libraries.
|
||||
virtual void SaveAllLibs() = 0;
|
||||
|
||||
//! Serialize property manager.
|
||||
virtual void Serialize(XmlNodeRef& node, bool bLoading) = 0;
|
||||
|
||||
//! Export items to game.
|
||||
virtual void Export(XmlNodeRef& node) = 0;
|
||||
|
||||
//! Returns unique name base on input name.
|
||||
// Vera@conffx, add LibName parameter so we could make an unique name depends on input library.
|
||||
// Arguments:
|
||||
// - name: name of the item
|
||||
// - libName: The library of the item. Given the library name, the function will return a unique name in the library
|
||||
// Default value "": The function will ignore the library name and return a unique name in the manager
|
||||
virtual QString MakeUniqueItemName(const QString& name, const QString& libName = "") = 0;
|
||||
virtual QString MakeFullItemName(IDataBaseLibrary* pLibrary, const QString& group, const QString& itemName) = 0;
|
||||
|
||||
//! Root node where this library will be saved.
|
||||
virtual QString GetRootNodeName() = 0;
|
||||
//! Path to libraries in this manager.
|
||||
virtual QString GetLibsPath() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Validate library items for errors.
|
||||
virtual void Validate() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void GatherUsedResources(CUsedResources& resources) = 0;
|
||||
|
||||
virtual void AddListener(IDataBaseManagerListener* pListener) = 0;
|
||||
virtual void RemoveListener(IDataBaseManagerListener* pListener) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void RegisterItem(CBaseLibraryItem* pItem, REFGUID newGuid) = 0;
|
||||
virtual void RegisterItem(CBaseLibraryItem* pItem) = 0;
|
||||
virtual void UnregisterItem(CBaseLibraryItem* pItem) = 0;
|
||||
|
||||
// Only Used internally.
|
||||
virtual void OnRenameItem(CBaseLibraryItem* pItem, const QString& oldName) = 0;
|
||||
|
||||
// Called by items to indicated that they have been modified.
|
||||
// Sends item changed event to listeners.
|
||||
virtual void OnItemChanged(IDataBaseItem* pItem) = 0;
|
||||
virtual void OnUpdateProperties(IDataBaseItem* pItem, bool bRefresh) = 0;
|
||||
|
||||
//CONFETTI BEGIN
|
||||
// Used to change the library item order
|
||||
virtual void ChangeLibraryOrder(IDataBaseLibrary* lib, unsigned int newLocation) = 0;
|
||||
// simplifies the library renaming process
|
||||
virtual bool SetLibraryName(CBaseLibrary* lib, const QString& name) = 0;
|
||||
|
||||
|
||||
//Check if the file name is unique.
|
||||
//Params: library: library name. NOT the file path.
|
||||
virtual bool IsUniqueFilename(const QString& library) = 0;
|
||||
//CONFETTI END
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IBASELIBRARYMANAGER_H
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IDATABASEITEM_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IDATABASEITEM_H
|
||||
#pragma once
|
||||
|
||||
#include <qwindowdefs.h>
|
||||
#include <IEditor.h>
|
||||
|
||||
struct IDataBaseLibrary;
|
||||
class CUsedResources;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/** Base class for all items contained in BaseLibraray.
|
||||
*/
|
||||
struct IDataBaseItem
|
||||
{
|
||||
struct SerializeContext
|
||||
{
|
||||
XmlNodeRef node;
|
||||
bool bUndo;
|
||||
bool bLoading;
|
||||
bool bCopyPaste;
|
||||
bool bIgnoreChilds;
|
||||
bool bUniqName;
|
||||
SerializeContext()
|
||||
: node(0)
|
||||
, bLoading(false)
|
||||
, bCopyPaste(false)
|
||||
, bIgnoreChilds(false)
|
||||
, bUniqName(false)
|
||||
, bUndo(false) {};
|
||||
SerializeContext(XmlNodeRef _node, bool bLoad)
|
||||
: node(_node)
|
||||
, bLoading(bLoad)
|
||||
, bCopyPaste(false)
|
||||
, bIgnoreChilds(false)
|
||||
, bUniqName(false)
|
||||
, bUndo(false) {};
|
||||
SerializeContext(const SerializeContext& ctx)
|
||||
: node(ctx.node)
|
||||
, bLoading(ctx.bLoading)
|
||||
, bCopyPaste(ctx.bCopyPaste)
|
||||
, bIgnoreChilds(ctx.bIgnoreChilds)
|
||||
, bUniqName(ctx.bUniqName)
|
||||
, bUndo(ctx.bUndo) {};
|
||||
};
|
||||
|
||||
virtual EDataBaseItemType GetType() const = 0;
|
||||
|
||||
//! Return Library this item are contained in.
|
||||
//! Item can only be at one library.
|
||||
virtual IDataBaseLibrary* GetLibrary() const = 0;
|
||||
|
||||
//! Change item name.
|
||||
virtual void SetName(const QString& name) = 0;
|
||||
//! Get item name.
|
||||
virtual const QString& GetName() const = 0;
|
||||
|
||||
//! Get full item name, including name of library.
|
||||
//! Name formed by adding dot after name of library
|
||||
//! eg. library Pickup and item PickupRL form full item name: "Pickups.PickupRL".
|
||||
virtual QString GetFullName() const = 0;
|
||||
|
||||
//! Get only nameof group from prototype.
|
||||
virtual QString GetGroupName() = 0;
|
||||
//! Get short name of prototype without group.
|
||||
virtual QString GetShortName() = 0;
|
||||
|
||||
//! Serialize library item to archive.
|
||||
virtual void Serialize(SerializeContext& ctx) = 0;
|
||||
|
||||
//! Generate new unique id for this item.
|
||||
virtual void GenerateId() = 0;
|
||||
//! Returns GUID of this material.
|
||||
virtual const GUID& GetGUID() const = 0;
|
||||
|
||||
//! Validate item for errors.
|
||||
virtual void Validate() {};
|
||||
|
||||
//! Gathers resources by this item.
|
||||
virtual void GatherUsedResources([[maybe_unused]] CUsedResources& resources) {};
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IDATABASEITEM_H
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IDATABASELIBRARY_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IDATABASELIBRARY_H
|
||||
#pragma once
|
||||
|
||||
|
||||
struct IDataBaseManager;
|
||||
struct IDataBaseItem;
|
||||
|
||||
class QString;
|
||||
class XmlNodeRef;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Description:
|
||||
// Interface to access specific library of editor data base.
|
||||
// Ex. Archetype library, Material Library.
|
||||
// See Also:
|
||||
// IDataBaseItem,IDataBaseManager
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct IDataBaseLibrary
|
||||
{
|
||||
// Description:
|
||||
// Return IDataBaseManager interface to the manager for items stored in this library.
|
||||
virtual IDataBaseManager* GetManager() = 0;
|
||||
|
||||
// Description:
|
||||
// Return library name.
|
||||
virtual const QString& GetName() const = 0;
|
||||
|
||||
// Description:
|
||||
// Return filename where this library is stored.
|
||||
virtual const QString& GetFilename() const = 0;
|
||||
|
||||
// Description:
|
||||
// Save contents of library to file.
|
||||
virtual bool Save() = 0;
|
||||
|
||||
// Description:
|
||||
// Load library from file.
|
||||
// Arguments:
|
||||
// filename - Full specified library filename (relative to root game folder).
|
||||
virtual bool Load(const QString& filename) = 0;
|
||||
|
||||
// Description:
|
||||
// Serialize library parameters and items to/from XML node.
|
||||
virtual void Serialize(XmlNodeRef& node, bool bLoading) = 0;
|
||||
|
||||
// Description:
|
||||
// Marks library as modified, indicates that some item in library was modified.
|
||||
virtual void SetModified(bool bModified = true) = 0;
|
||||
|
||||
// Description:
|
||||
// Check if library parameters or any items where modified.
|
||||
// If any item was modified library may need saving before closing editor.
|
||||
virtual bool IsModified() const = 0;
|
||||
|
||||
// Description:
|
||||
// Check if this library is not shared and internal to current level.
|
||||
virtual bool IsLevelLibrary() const = 0;
|
||||
|
||||
// Description:
|
||||
// Make this library accessible only from current Level. (not shared)
|
||||
virtual void SetLevelLibrary(bool bEnable) = 0;
|
||||
|
||||
// Description:
|
||||
// Associate a new item with the library.
|
||||
// Watch out if item was already in another library.
|
||||
virtual void AddItem(IDataBaseItem* pItem, bool bRegister = true) = 0;
|
||||
|
||||
// Description:
|
||||
// Return number of items in library.
|
||||
virtual int GetItemCount() const = 0;
|
||||
|
||||
// Description:
|
||||
// Get item by index.
|
||||
// See Also:
|
||||
// GetItemCount
|
||||
// Arguments:
|
||||
// index - Index from 0 to GetItemCount()
|
||||
virtual IDataBaseItem* GetItem(int index) = 0;
|
||||
|
||||
// Description:
|
||||
// Remove item from library, does not destroy item,
|
||||
// only unliks it from this library, to delete item use IDataBaseManager.
|
||||
// See Also:
|
||||
// AddItem
|
||||
virtual void RemoveItem(IDataBaseItem* item) = 0;
|
||||
|
||||
// Description:
|
||||
// Remove all items from library, does not destroy items,
|
||||
// only unliks them from this library, to delete item use IDataBaseManager.
|
||||
// See Also:
|
||||
// RemoveItem,AddItem
|
||||
virtual void RemoveAllItems() = 0;
|
||||
|
||||
// Description:
|
||||
// Find item in library by name.
|
||||
// This function usually uses linear search so it is not particularry fast.
|
||||
// See Also:
|
||||
// GetItem
|
||||
virtual IDataBaseItem* FindItem(const QString& name) = 0;
|
||||
|
||||
|
||||
//CONFETTI BEGIN
|
||||
// Used to change the library item order
|
||||
virtual void ChangeItemOrder(CBaseLibraryItem* item, unsigned int newLocation) = 0;
|
||||
//CONFETTI END
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IDATABASELIBRARY_H
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IDATABASEMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IDATABASEMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
struct IDataBaseItem;
|
||||
struct IDataBaseLibrary;
|
||||
class CUsedResources;
|
||||
|
||||
enum EDataBaseItemEvent
|
||||
{
|
||||
EDB_ITEM_EVENT_ADD,
|
||||
EDB_ITEM_EVENT_DELETE,
|
||||
EDB_ITEM_EVENT_CHANGED,
|
||||
EDB_ITEM_EVENT_SELECTED,
|
||||
EDB_ITEM_EVENT_UPDATE_PROPERTIES,
|
||||
EDB_ITEM_EVENT_UPDATE_PROPERTIES_NO_EDITOR_REFRESH
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Description:
|
||||
// Callback class to intercept item creation and deletion events.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct IDataBaseManagerListener
|
||||
{
|
||||
virtual void OnDataBaseItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event) = 0;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Description:
|
||||
// his interface is used to enumerate al items registered to the database manager.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct IDataBaseItemEnumerator
|
||||
{
|
||||
virtual ~IDataBaseItemEnumerator() = default;
|
||||
|
||||
virtual void Release() = 0;
|
||||
virtual IDataBaseItem* GetFirst() = 0;
|
||||
virtual IDataBaseItem* GetNext() = 0;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Interface to the collection of all items or specific type
|
||||
// in data base libraries.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct IDataBaseManager
|
||||
{
|
||||
//! Clear all libraries.
|
||||
virtual void ClearAll() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Library items.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Make a new item in specified library.
|
||||
virtual IDataBaseItem* CreateItem(IDataBaseLibrary* pLibrary) = 0;
|
||||
//! Delete item from library and manager.
|
||||
virtual void DeleteItem(IDataBaseItem* pItem) = 0;
|
||||
|
||||
//! Find Item by its GUID.
|
||||
virtual IDataBaseItem* FindItem(REFGUID guid) const = 0;
|
||||
virtual IDataBaseItem* FindItemByName(const QString& fullItemName) = 0;
|
||||
|
||||
virtual IDataBaseItemEnumerator* GetItemEnumerator() = 0;
|
||||
|
||||
// Select one item in DB.
|
||||
virtual void SetSelectedItem(IDataBaseItem* pItem) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Libraries.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Add Item library. Set isLevelLibrary to true if its the "level" library which gets saved inside the level
|
||||
virtual IDataBaseLibrary* AddLibrary(const QString& library, bool isLevelLibrary = false, bool bIsLoading = true) = 0;
|
||||
virtual void DeleteLibrary(const QString& library, bool forceDeleteLibrary = false) = 0;
|
||||
//! Get number of libraries.
|
||||
virtual int GetLibraryCount() const = 0;
|
||||
//! Get Item library by index.
|
||||
virtual IDataBaseLibrary* GetLibrary(int index) const = 0;
|
||||
|
||||
//! Find Items Library by name.
|
||||
virtual IDataBaseLibrary* FindLibrary(const QString& library) = 0;
|
||||
|
||||
//! Load Items library.
|
||||
#ifdef LoadLibrary
|
||||
#undef LoadLibrary
|
||||
#endif
|
||||
virtual IDataBaseLibrary* LoadLibrary(const QString& filename, bool bReload = false) = 0;
|
||||
|
||||
//! Save all modified libraries.
|
||||
virtual void SaveAllLibs() = 0;
|
||||
|
||||
//! Serialize property manager.
|
||||
virtual void Serialize(XmlNodeRef& node, bool bLoading) = 0;
|
||||
|
||||
//! Export items to game.
|
||||
virtual void Export([[maybe_unused]] XmlNodeRef& node) {};
|
||||
|
||||
//! Returns unique name base on input name.
|
||||
virtual QString MakeUniqueItemName(const QString& name, const QString& libName = "") = 0;
|
||||
virtual QString MakeFullItemName(IDataBaseLibrary* pLibrary, const QString& group, const QString& itemName) = 0;
|
||||
|
||||
//! Root node where this library will be saved.
|
||||
virtual QString GetRootNodeName() = 0;
|
||||
//! Path to libraries in this manager.
|
||||
virtual QString GetLibsPath() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Validate library items for errors.
|
||||
virtual void Validate() = 0;
|
||||
|
||||
// Description:
|
||||
// Collects names of all resource files used by managed items.
|
||||
// Arguments:
|
||||
// resources - Structure where all filenames are collected.
|
||||
virtual void GatherUsedResources(CUsedResources& resources) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Register listeners.
|
||||
virtual void AddListener(IDataBaseManagerListener* pListener) = 0;
|
||||
virtual void RemoveListener(IDataBaseManagerListener* pListener) = 0;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IDATABASEMANAGER_H
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "BaseLibraryItem.h"
|
||||
#include <IMaterial.h>
|
||||
|
||||
struct IEditorMaterial
|
||||
: public CBaseLibraryItem
|
||||
{
|
||||
virtual int GetFlags() const = 0;
|
||||
virtual IMaterial* GetMatInfo(bool bUseExistingEngineMaterial = false) = 0;
|
||||
virtual void DisableHighlightForFrame() = 0;
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#ifndef CRYINCLUDE_EDITOR_MATERIAL_IEDITORMATERIALMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_MATERIAL_IEDITORMATERIALMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include <Include/IBaseLibraryManager.h>
|
||||
#include <IMaterial.h>
|
||||
|
||||
|
||||
struct IEditorMaterialManager
|
||||
{
|
||||
virtual void GotoMaterial(IMaterial* pMaterial) = 0;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_MATERIAL_MATERIALMANAGER_H
|
||||
@@ -14,7 +14,6 @@
|
||||
// forward declarations.
|
||||
class CParticleItem;
|
||||
class CBaseObject;
|
||||
class CBaseLibraryItem;
|
||||
class CErrorRecord;
|
||||
class QString;
|
||||
|
||||
@@ -52,9 +51,6 @@ struct IErrorReport
|
||||
//! Assign current Object to which new reported warnings are assigned.
|
||||
virtual void SetCurrentValidatorObject(CBaseObject* pObject) = 0;
|
||||
|
||||
//! Assign current Item to which new reported warnings are assigned.
|
||||
virtual void SetCurrentValidatorItem(CBaseLibraryItem* pItem) = 0;
|
||||
|
||||
//! Assign current filename.
|
||||
virtual void SetCurrentFile(const QString& file) = 0;
|
||||
};
|
||||
|
||||
@@ -116,9 +116,6 @@ struct IFileUtil
|
||||
virtual bool ExtractFile(QString& file, bool bMsgBoxAskForExtraction = true, const char* pDestinationFilename = nullptr) = 0;
|
||||
virtual void EditTextureFile(const char* txtureFile, bool bUseGameFolder) = 0;
|
||||
|
||||
//! dcc filename calculation and extraction sub-routines
|
||||
virtual bool CalculateDccFilename(const QString& assetFilename, QString& dccFilename) = 0;
|
||||
|
||||
//! Reformat filter string for (MFC) CFileDialog style file filtering
|
||||
virtual void FormatFilterString(QString& filter) = 0;
|
||||
|
||||
|
||||
@@ -85,9 +85,6 @@ public:
|
||||
MOCK_METHOD0(IsSelectionLocked, bool());
|
||||
MOCK_METHOD0(GetObjectManager, struct IObjectManager* ());
|
||||
MOCK_METHOD0(GetSettingsManager, CSettingsManager* ());
|
||||
MOCK_METHOD1(GetDBItemManager, IDataBaseManager* (EDataBaseItemType));
|
||||
MOCK_METHOD0(GetMaterialManagerLibrary, IBaseLibraryManager* ());
|
||||
MOCK_METHOD0(GetIEditorMaterialManager, IEditorMaterialManager* ());
|
||||
MOCK_METHOD0(GetIconManager, IIconManager* ());
|
||||
MOCK_METHOD0(GetMusicManager, CMusicManager* ());
|
||||
MOCK_METHOD2(GetTerrainElevation, float(float , float ));
|
||||
@@ -187,6 +184,5 @@ public:
|
||||
MOCK_METHOD0(UnloadPlugins, void());
|
||||
MOCK_METHOD0(LoadPlugins, void());
|
||||
MOCK_METHOD1(GetSearchPath, QString(EEditorPathName));
|
||||
MOCK_METHOD0(GetEditorPanelUtils, IEditorPanelUtils* ());
|
||||
|
||||
};
|
||||
|
||||
@@ -1,506 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "SimpleTriangleRasterizer.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#if !defined FLT_MAX
|
||||
#define FLT_MAX 3.402823466e+38F
|
||||
#endif
|
||||
|
||||
void CSimpleTriangleRasterizer::lambertHorizlineConservative(float fx1, float fx2, int yy, IRasterizeSink* inpSink)
|
||||
{
|
||||
int x1 = (int)floorf(fx1 + 0.25f), x2 = (int)floorf(fx2 + .75f);
|
||||
|
||||
if (x1 < m_iMinX)
|
||||
{
|
||||
x1 = m_iMinX;
|
||||
}
|
||||
if (x2 > m_iMaxX + 1)
|
||||
{
|
||||
x2 = m_iMaxX + 1;
|
||||
}
|
||||
if (x1 > m_iMaxX + 1)
|
||||
{
|
||||
x1 = m_iMaxX + 1;
|
||||
}
|
||||
if (x2 < m_iMinX)
|
||||
{
|
||||
x2 = m_iMinX;
|
||||
}
|
||||
|
||||
|
||||
inpSink->Line(fx1, fx2, x1, x2, yy);
|
||||
}
|
||||
|
||||
void CSimpleTriangleRasterizer::lambertHorizlineSubpixelCorrect(float fx1, float fx2, int yy, IRasterizeSink* inpSink)
|
||||
{
|
||||
int x1 = (int)floorf(fx1 + 0.5f), x2 = (int)floorf(fx2 + 0.5f);
|
||||
// int x1=(int)floorf(fx1*1023.f/1024.f+1.f),x2=(int)floorf(fx2*1023.f/1024.f+1.f);
|
||||
|
||||
if (x1 < m_iMinX)
|
||||
{
|
||||
x1 = m_iMinX;
|
||||
}
|
||||
if (x2 > m_iMaxX)
|
||||
{
|
||||
x2 = m_iMaxX;
|
||||
}
|
||||
if (x1 > m_iMaxX)
|
||||
{
|
||||
x1 = m_iMaxX;
|
||||
}
|
||||
if (x2 < m_iMinX)
|
||||
{
|
||||
x2 = m_iMinX;
|
||||
}
|
||||
|
||||
inpSink->Line(fx1, fx2, x1, x2, yy);
|
||||
}
|
||||
|
||||
// optimizable
|
||||
void CSimpleTriangleRasterizer::CopyAndSortY(const float infX[3], const float infY[3], float outfX[3], float outfY[3])
|
||||
{
|
||||
outfX[0] = infX[0];
|
||||
outfY[0] = infY[0];
|
||||
outfX[1] = infX[1];
|
||||
outfY[1] = infY[1];
|
||||
outfX[2] = infX[2];
|
||||
outfY[2] = infY[2];
|
||||
|
||||
// Sort the coordinates, so that (x[1], y[1]) becomes the highest coord
|
||||
float tmp;
|
||||
|
||||
if (outfY[0] > outfY[1])
|
||||
{
|
||||
if (outfY[1] > outfY[2])
|
||||
{
|
||||
tmp = outfY[0];
|
||||
outfY[0] = outfY[1];
|
||||
outfY[1] = tmp;
|
||||
tmp = outfX[0];
|
||||
outfX[0] = outfX[1];
|
||||
outfX[1] = tmp;
|
||||
tmp = outfY[1];
|
||||
outfY[1] = outfY[2];
|
||||
outfY[2] = tmp;
|
||||
tmp = outfX[1];
|
||||
outfX[1] = outfX[2];
|
||||
outfX[2] = tmp;
|
||||
|
||||
if (outfY[0] > outfY[1])
|
||||
{
|
||||
tmp = outfY[0];
|
||||
outfY[0] = outfY[1];
|
||||
outfY[1] = tmp;
|
||||
tmp = outfX[0];
|
||||
outfX[0] = outfX[1];
|
||||
outfX[1] = tmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = outfY[0];
|
||||
outfY[0] = outfY[1];
|
||||
outfY[1] = tmp;
|
||||
tmp = outfX[0];
|
||||
outfX[0] = outfX[1];
|
||||
outfX[1] = tmp;
|
||||
|
||||
if (outfY[1] > outfY[2])
|
||||
{
|
||||
tmp = outfY[1];
|
||||
outfY[1] = outfY[2];
|
||||
outfY[2] = tmp;
|
||||
tmp = outfX[1];
|
||||
outfX[1] = outfX[2];
|
||||
outfX[2] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (outfY[1] > outfY[2])
|
||||
{
|
||||
tmp = outfY[1];
|
||||
outfY[1] = outfY[2];
|
||||
outfY[2] = tmp;
|
||||
tmp = outfX[1];
|
||||
outfX[1] = outfX[2];
|
||||
outfX[2] = tmp;
|
||||
|
||||
if (outfY[0] > outfY[1])
|
||||
{
|
||||
tmp = outfY[0];
|
||||
outfY[0] = outfY[1];
|
||||
outfY[1] = tmp;
|
||||
tmp = outfX[0];
|
||||
outfX[0] = outfX[1];
|
||||
outfX[1] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSimpleTriangleRasterizer::CallbackFillRectConservative(float _x[3], float _y[3], IRasterizeSink* inpSink)
|
||||
{
|
||||
inpSink->Triangle(m_iMinY);
|
||||
|
||||
float fMinX = (std::min)(_x[0], (std::min)(_x[1], _x[2]));
|
||||
float fMaxX = (std::max)(_x[0], (std::max)(_x[1], _x[2]));
|
||||
float fMinY = (std::min)(_y[0], (std::min)(_y[1], _y[2]));
|
||||
float fMaxY = (std::max)(_y[0], (std::max)(_y[1], _y[2]));
|
||||
|
||||
int iMinX = (std::max)(m_iMinX, (int)floorf(fMinX));
|
||||
int iMaxX = (std::min)(m_iMaxX + 1, (int)ceilf(fMaxX));
|
||||
int iMinY = (std::max)(m_iMinY, (int)floorf(fMinY));
|
||||
int iMaxY = (std::min)(m_iMaxY + 1, (int)ceilf(fMaxY));
|
||||
|
||||
for (int y = iMinY; y < iMaxY; y++)
|
||||
{
|
||||
inpSink->Line(fMinX, fMaxX, iMinX, iMaxX, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CSimpleTriangleRasterizer::CallbackFillConservative(float _x[3], float _y[3], IRasterizeSink* inpSink)
|
||||
{
|
||||
float x[3], y[3];
|
||||
|
||||
CopyAndSortY(_x, _y, x, y);
|
||||
|
||||
// Calculate interpolation steps
|
||||
float fX1toX2step = 0.0f;
|
||||
float fX1toX3step = 0.0f;
|
||||
float fX2toX3step = 0.0f;
|
||||
if (fabsf(y[1] - y[0]) > FLT_EPSILON)
|
||||
{
|
||||
fX1toX2step = (x[1] - x[0]) / (float)(y[1] - y[0]);
|
||||
}
|
||||
if (fabsf(y[2] - y[0]) > FLT_EPSILON)
|
||||
{
|
||||
fX1toX3step = (x[2] - x[0]) / (float)(y[2] - y[0]);
|
||||
}
|
||||
if (fabsf(y[2] - y[1]) > FLT_EPSILON)
|
||||
{
|
||||
fX2toX3step = (x[2] - x[1]) / (float)(y[2] - y[1]);
|
||||
}
|
||||
|
||||
float fX1toX2 = x[0], fX1toX3 = x[0], fX2toX3 = x[1];
|
||||
bool bFirstLine = true;
|
||||
bool bTriangleCallDone = false;
|
||||
|
||||
// Go through the scanlines of the triangle
|
||||
int yy = (int)floorf(y[0]); // was floor
|
||||
|
||||
for (; yy <= (int)floorf(y[2]); yy++)
|
||||
// for(yy=m_iMinY; yy<=m_iMaxY; yy++) // juhu
|
||||
{
|
||||
float fSubPixelYStart = 0.0f, fSubPixelYEnd = 1.0f;
|
||||
float start, end;
|
||||
|
||||
// first line
|
||||
if (bFirstLine)
|
||||
{
|
||||
fSubPixelYStart = y[0] - floorf(y[0]);
|
||||
start = x[0];
|
||||
end = x[0];
|
||||
bFirstLine = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// top part without middle corner line
|
||||
if (yy <= (int)floorf(y[1]))
|
||||
{
|
||||
start = (std::min)(fX1toX2, fX1toX3);
|
||||
end = (std::max)(fX1toX2, fX1toX3);
|
||||
}
|
||||
else
|
||||
{
|
||||
start = (std::min)(fX2toX3, fX1toX3);
|
||||
end = (std::max)(fX2toX3, fX1toX3);
|
||||
}
|
||||
}
|
||||
|
||||
// middle corner line
|
||||
if (yy == (int)floorf(y[1]))
|
||||
{
|
||||
fSubPixelYEnd = y[1] - floorf(y[1]);
|
||||
|
||||
fX1toX3 += fX1toX3step * (fSubPixelYEnd - fSubPixelYStart);
|
||||
start = (std::min)(start, fX1toX3);
|
||||
end = (std::max)(end, fX1toX3);
|
||||
start = (std::min)(start, x[1]);
|
||||
end = (std::max)(end, x[1]);
|
||||
|
||||
fSubPixelYStart = fSubPixelYEnd;
|
||||
fSubPixelYEnd = 1.0f;
|
||||
}
|
||||
|
||||
// last line
|
||||
if (yy == (int)floorf(y[2]))
|
||||
{
|
||||
start = (std::min)(start, x[2]);
|
||||
end = (std::max)(end, x[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// top part without middle corner line
|
||||
if (yy < (int)floorf(y[1]))
|
||||
{
|
||||
fX1toX2 += fX1toX2step * (fSubPixelYEnd - fSubPixelYStart);
|
||||
start = (std::min)(start, fX1toX2);
|
||||
end = (std::max)(end, fX1toX2);
|
||||
}
|
||||
else
|
||||
{
|
||||
fX2toX3 += fX2toX3step * (fSubPixelYEnd - fSubPixelYStart);
|
||||
start = (std::min)(start, fX2toX3);
|
||||
end = (std::max)(end, fX2toX3);
|
||||
}
|
||||
|
||||
fX1toX3 += fX1toX3step * (fSubPixelYEnd - fSubPixelYStart);
|
||||
start = (std::min)(start, fX1toX3);
|
||||
end = (std::max)(end, fX1toX3);
|
||||
}
|
||||
|
||||
if (yy >= m_iMinY && yy <= m_iMaxY)
|
||||
{
|
||||
if (!bTriangleCallDone)
|
||||
{
|
||||
inpSink->Triangle(yy);
|
||||
bTriangleCallDone = true;
|
||||
}
|
||||
|
||||
lambertHorizlineConservative(start, end, yy, inpSink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSimpleTriangleRasterizer::CallbackFillSubpixelCorrect(float _x[3], float _y[3], IRasterizeSink* inpSink)
|
||||
{
|
||||
float x[3], y[3];
|
||||
|
||||
CopyAndSortY(_x, _y, x, y);
|
||||
|
||||
if (fabs(y[0] - floorf(y[0])) < FLT_EPSILON)
|
||||
{
|
||||
y[0] -= FLT_EPSILON;
|
||||
}
|
||||
|
||||
// Calculate interpolation steps
|
||||
float fX1toX2step = 0.0f;
|
||||
float fX1toX3step = 0.0f;
|
||||
float fX2toX3step = 0.0f;
|
||||
if (fabsf(y[1] - y[0]) > FLT_EPSILON)
|
||||
{
|
||||
fX1toX2step = (x[1] - x[0]) / (y[1] - y[0]);
|
||||
}
|
||||
if (fabsf(y[2] - y[0]) > FLT_EPSILON)
|
||||
{
|
||||
fX1toX3step = (x[2] - x[0]) / (y[2] - y[0]);
|
||||
}
|
||||
if (fabsf(y[2] - y[1]) > FLT_EPSILON)
|
||||
{
|
||||
fX2toX3step = (x[2] - x[1]) / (y[2] - y[1]);
|
||||
}
|
||||
|
||||
float fX1toX2 = x[0], fX1toX3 = x[0], fX2toX3 = x[1];
|
||||
bool bFirstLine = true;
|
||||
bool bTriangleCallDone = false;
|
||||
|
||||
y[0] -= 0.5f;
|
||||
y[1] -= 0.5f;
|
||||
y[2] -= 0.5f;
|
||||
// y[0]=y[0]*1023.f/1024.f+1.f;
|
||||
// y[1]=y[1]*1023.f/1024.f+1.f;
|
||||
// y[2]=y[2]*1023.f/1024.f+1.f;
|
||||
|
||||
for (int yy = (int)floorf(y[0]); yy <= (int)floorf(y[2]); yy++)
|
||||
{
|
||||
float fSubPixelYStart = 0.0f, fSubPixelYEnd = 1.0f;
|
||||
float start, end;
|
||||
|
||||
// first line
|
||||
if (bFirstLine)
|
||||
{
|
||||
fSubPixelYStart = y[0] - floorf(y[0]);
|
||||
start = x[0];
|
||||
end = x[0];
|
||||
bFirstLine = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// top part without middle corner line
|
||||
if (yy <= (int)floorf(y[1]))
|
||||
{
|
||||
start = (std::min)(fX1toX2, fX1toX3);
|
||||
end = (std::max)(fX1toX2, fX1toX3);
|
||||
}
|
||||
else
|
||||
{
|
||||
start = (std::min)(fX2toX3, fX1toX3);
|
||||
end = (std::max)(fX2toX3, fX1toX3);
|
||||
}
|
||||
}
|
||||
|
||||
// middle corner line
|
||||
if (yy == (int)floorf(y[1]))
|
||||
{
|
||||
fSubPixelYEnd = y[1] - floorf(y[1]);
|
||||
|
||||
fX1toX3 += fX1toX3step * (fSubPixelYEnd - fSubPixelYStart);
|
||||
|
||||
fSubPixelYStart = fSubPixelYEnd;
|
||||
fSubPixelYEnd = 1.0f;
|
||||
}
|
||||
|
||||
// last line
|
||||
if (yy != (int)floorf(y[2]))
|
||||
{
|
||||
// top part without middle corner line
|
||||
if (yy < (int)floorf(y[1]))
|
||||
{
|
||||
fX1toX2 += fX1toX2step * (fSubPixelYEnd - fSubPixelYStart);
|
||||
}
|
||||
else
|
||||
{
|
||||
fX2toX3 += fX2toX3step * (fSubPixelYEnd - fSubPixelYStart);
|
||||
}
|
||||
|
||||
fX1toX3 += fX1toX3step * (fSubPixelYEnd - fSubPixelYStart);
|
||||
}
|
||||
|
||||
if (start != end)
|
||||
{
|
||||
if (yy >= m_iMinY && yy <= m_iMaxY)
|
||||
{
|
||||
if (!bTriangleCallDone)
|
||||
{
|
||||
inpSink->Triangle(yy);
|
||||
bTriangleCallDone = true;
|
||||
}
|
||||
|
||||
lambertHorizlineSubpixelCorrect(start, end, yy, inpSink);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// shrink triangle by n pixel, optimizable
|
||||
void CSimpleTriangleRasterizer::ShrinkTriangle(float inoutfX[3], float inoutfY[3], float infAmount)
|
||||
{
|
||||
float fX[3] = { inoutfX[0], inoutfX[1], inoutfX[2] };
|
||||
float fY[3] = { inoutfY[0], inoutfY[1], inoutfY[2] };
|
||||
|
||||
/*
|
||||
// move edge to opposing vertex
|
||||
float dx,dy,fLength;
|
||||
|
||||
for(int a=0;a<3;a++)
|
||||
{
|
||||
int b=a+1;if(b>=3)b=0;
|
||||
int c=b+1;if(c>=3)c=0;
|
||||
|
||||
dx=fX[a]-(fX[b]+fX[c])*0.5f;
|
||||
dy=fY[a]-(fY[b]+fY[c])*0.5f;
|
||||
fLength=(float)sqrt(dx*dx+dy*dy);
|
||||
if(fLength>1.0f)
|
||||
{
|
||||
dx/=fLength;dy/=fLength;
|
||||
inoutfX[b]+=dx;inoutfY[b]+=dy;
|
||||
inoutfX[c]+=dx;inoutfY[c]+=dy;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// move vertex to opposing edge
|
||||
float dx,dy,fLength;
|
||||
|
||||
for(int a=0;a<3;a++)
|
||||
{
|
||||
int b=a+1;if(b>=3)b=0;
|
||||
int c=b+1;if(c>=3)c=0;
|
||||
|
||||
dx=fX[a]-(fX[b]+fX[c])*0.5f;
|
||||
dy=fY[a]-(fY[b]+fY[c])*0.5f;
|
||||
fLength=(float)sqrt(dx*dx+dy*dy);
|
||||
if(fLength>1.0f)
|
||||
{
|
||||
dx/=fLength;dy/=fLength;
|
||||
inoutfX[a]-=dx;inoutfY[a]-=dy;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// move vertex to get edges shifted perpendicular for 1 unit
|
||||
for (int a = 0; a < 3; a++)
|
||||
{
|
||||
float dx1, dy1, dx2, dy2, fLength;
|
||||
|
||||
int b = a + 1;
|
||||
if (b >= 3)
|
||||
{
|
||||
b = 0;
|
||||
}
|
||||
int c = b + 1;
|
||||
if (c >= 3)
|
||||
{
|
||||
c = 0;
|
||||
}
|
||||
|
||||
dx1 = fX[b] - fX[a];
|
||||
dy1 = fY[b] - fY[a];
|
||||
fLength = (float)sqrt(dx1 * dx1 + dy1 * dy1);
|
||||
if (infAmount > 0)
|
||||
{
|
||||
if (fLength < infAmount)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (fLength == 0.0f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
dx1 /= fLength;
|
||||
dy1 /= fLength;
|
||||
|
||||
dx2 = fX[c] - fX[a];
|
||||
dy2 = fY[c] - fY[a];
|
||||
fLength = (float)sqrt(dx2 * dx2 + dy2 * dy2);
|
||||
if (infAmount > 0)
|
||||
{
|
||||
if (fLength < infAmount)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (fLength == 0.0f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
dx2 /= fLength;
|
||||
dy2 /= fLength;
|
||||
|
||||
inoutfX[a] += (dx1 + dx2) * infAmount;
|
||||
inoutfY[a] += (dy1 + dy2) * infAmount;
|
||||
}
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LIGHTMAPCOMPILER_SIMPLETRIANGLERASTERIZER_H
|
||||
#define CRYINCLUDE_EDITOR_LIGHTMAPCOMPILER_SIMPLETRIANGLERASTERIZER_H
|
||||
#pragma once
|
||||
|
||||
class CSimpleTriangleRasterizer
|
||||
{
|
||||
public:
|
||||
|
||||
class IRasterizeSink
|
||||
{
|
||||
public:
|
||||
|
||||
//! is called once per triangel for the first possible visible line
|
||||
//! /param iniStartY
|
||||
virtual void Triangle([[maybe_unused]] const int iniStartY)
|
||||
{
|
||||
}
|
||||
|
||||
//! callback function
|
||||
//! /param infXLeft included - not clipped against left and reight border
|
||||
//! /param infXRight excluded - not clipped against left and reight border
|
||||
//! /param iniXLeft included
|
||||
//! /param iniXRight excluded
|
||||
//! /param iniY
|
||||
virtual void Line(const float infXLeft, const float infXRight,
|
||||
const int iniXLeft, const int iniXRight, const int iniY) = 0;
|
||||
};
|
||||
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
||||
//! implementation sink sample
|
||||
class CDWORDFlatFill
|
||||
: public IRasterizeSink
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CDWORDFlatFill(DWORD* inpBuffer, const DWORD indwPitchInPixels, DWORD indwValue)
|
||||
{
|
||||
m_dwValue = indwValue;
|
||||
m_pBuffer = inpBuffer;
|
||||
m_dwPitchInPixels = indwPitchInPixels;
|
||||
}
|
||||
|
||||
virtual void Triangle(const int iniY)
|
||||
{
|
||||
m_pBufferLine = &m_pBuffer[iniY * m_dwPitchInPixels];
|
||||
}
|
||||
|
||||
virtual void Line([[maybe_unused]] const float infXLeft, [[maybe_unused]] const float infXRight,
|
||||
const int iniLeft, const int iniRight, [[maybe_unused]] const int iniY)
|
||||
{
|
||||
DWORD* mem = &m_pBufferLine[iniLeft];
|
||||
|
||||
for (int x = iniLeft; x < iniRight; x++)
|
||||
{
|
||||
*mem++ = m_dwValue;
|
||||
}
|
||||
|
||||
m_pBufferLine += m_dwPitchInPixels;
|
||||
}
|
||||
|
||||
private:
|
||||
DWORD m_dwValue; //!< fill value
|
||||
DWORD* m_pBufferLine; //!< to get rid of the multiplication per line
|
||||
|
||||
DWORD m_dwPitchInPixels; //!< in DWORDS, not in Bytes
|
||||
DWORD* m_pBuffer; //!< pointer to the buffer
|
||||
};
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
||||
//! constructor
|
||||
//! /param iniWidth excluded
|
||||
//! /param iniHeight excluded
|
||||
CSimpleTriangleRasterizer(const int iniWidth, const int iniHeight)
|
||||
{
|
||||
m_iMinX = 0;
|
||||
m_iMinY = 0;
|
||||
m_iMaxX = iniWidth - 1;
|
||||
m_iMaxY = iniHeight - 1;
|
||||
}
|
||||
/*
|
||||
//! constructor
|
||||
//! /param iniMinX included
|
||||
//! /param iniMinY included
|
||||
//! /param iniMaxX included
|
||||
//! /param iniMaxY included
|
||||
CSimpleTriangleRasterizer( const int iniMinX, const int iniMinY, const int iniMaxX, const int iniMaxY )
|
||||
{
|
||||
m_iMinX=iniMinX;
|
||||
m_iMinY=iniMinY;
|
||||
m_iMaxX=iniMaxX;
|
||||
m_iMaxY=iniMaxY;
|
||||
}
|
||||
*/
|
||||
//! simple triangle filler with clipping (optimizable), not subpixel correct
|
||||
//! /param pBuffer pointer o the color buffer
|
||||
//! /param indwWidth width of the color buffer
|
||||
//! /param indwHeight height of the color buffer
|
||||
//! /param x array of the x coordiantes of the three vertices
|
||||
//! /param y array of the x coordiantes of the three vertices
|
||||
//! /param indwValue value of the triangle
|
||||
void DWORDFlatFill(DWORD* inpBuffer, const DWORD indwPitchInPixels, float x[3], float y[3], DWORD indwValue, bool inbConservative)
|
||||
{
|
||||
CDWORDFlatFill pix(inpBuffer, indwPitchInPixels, indwValue);
|
||||
|
||||
if (inbConservative)
|
||||
{
|
||||
CallbackFillConservative(x, y, &pix);
|
||||
}
|
||||
else
|
||||
{
|
||||
CallbackFillSubpixelCorrect(x, y, &pix);
|
||||
}
|
||||
}
|
||||
|
||||
// Rectangle around triangle - more stable - use for debugging purpose
|
||||
void CallbackFillRectConservative(float x[3], float y[3], IRasterizeSink * inpSink);
|
||||
|
||||
|
||||
//! subpixel correct triangle filler (conservative or not conservative)
|
||||
//! \param pBuffer pointe to the DWORD
|
||||
//! \param indwWidth width of the buffer pBuffer pointes to
|
||||
//! \param indwHeight height of the buffer pBuffer pointes to
|
||||
//! \param x array of the x coordiantes of the three vertices
|
||||
//! \param y array of the x coordiantes of the three vertices
|
||||
//! \param inpSink pointer to the sink interface (is called per triangle and per triangle line)
|
||||
void CallbackFillConservative(float x[3], float y[3], IRasterizeSink * inpSink);
|
||||
|
||||
//! subpixel correct triangle filler (conservative or not conservative)
|
||||
//! \param pBuffer pointe to the DWORD
|
||||
//! \param indwWidth width of the buffer pBuffer pointes to
|
||||
//! \param indwHeight height of the buffer pBuffer pointes to
|
||||
//! \param x array of the x coordiantes of the three vertices
|
||||
//! \param y array of the x coordiantes of the three vertices
|
||||
//! \param inpSink pointer to the sink interface (is called per triangle and per triangle line)
|
||||
void CallbackFillSubpixelCorrect(float x[3], float y[3], IRasterizeSink * inpSink);
|
||||
|
||||
//!
|
||||
//! /param inoutfX
|
||||
//! /param inoutfY
|
||||
//! /param infAmount could be positive or negative
|
||||
static void ShrinkTriangle(float inoutfX[3], float inoutfY[3], float infAmount);
|
||||
|
||||
private:
|
||||
|
||||
// Clipping Rect;
|
||||
|
||||
int m_iMinX; //!< minimum x value included
|
||||
int m_iMinY; //!< minimum y value included
|
||||
int m_iMaxX; //!< maximum x value included
|
||||
int m_iMaxY; //!< maximum x value included
|
||||
|
||||
void lambertHorizlineConservative(float fx1, float fx2, int y, IRasterizeSink* inpSink);
|
||||
void lambertHorizlineSubpixelCorrect(float fx1, float fx2, int y, IRasterizeSink* inpSink);
|
||||
void CopyAndSortY(const float infX[3], const float infY[3], float outfX[3], float outfY[3]);
|
||||
};
|
||||
|
||||
|
||||
// extension ideas:
|
||||
// * callback with coverage mask (possible non ordered sampling)
|
||||
// * z-buffer behaviour
|
||||
// * gouraud shading
|
||||
// * texture mapping with nearest/bicubic/bilinear filter
|
||||
// * further primitives: thick line, ellipse
|
||||
// * build a template version
|
||||
// *
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_LIGHTMAPCOMPILER_SIMPLETRIANGLERASTERIZER_H
|
||||
@@ -27,6 +27,7 @@
|
||||
#define CLASS_ENVIRONMENT_LIGHT "EnvironmentLight"
|
||||
|
||||
class CEntityObject;
|
||||
class CSelectionGroup;
|
||||
class QMenu;
|
||||
|
||||
/*!
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "ErrorReport.h"
|
||||
#include <AzCore/std/containers/set.h>
|
||||
|
||||
#include <CryCommon/IXml.h>
|
||||
|
||||
class CErrorRecord;
|
||||
struct IObjectManager;
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "Util/Image.h"
|
||||
#include "ObjectManagerLegacyUndo.h"
|
||||
#include "Include/HitContext.h"
|
||||
#include "EditMode/DeepSelection.h"
|
||||
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
|
||||
|
||||
#include <AzCore/Console/Console.h>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWSEQUENCE_H
|
||||
#pragma once
|
||||
|
||||
#include <IEditor.h>
|
||||
#include "IMovieSystem.h"
|
||||
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
|
||||
@@ -408,20 +408,6 @@ void CTrackViewSequenceManager::OnSequenceRemoved(CTrackViewSequence* sequence)
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void CTrackViewSequenceManager::OnDataBaseItemEvent([[maybe_unused]] IDataBaseItem* pItem, EDataBaseItemEvent event)
|
||||
{
|
||||
if (event != EDataBaseItemEvent::EDB_ITEM_EVENT_ADD)
|
||||
{
|
||||
const size_t numSequences = m_sequences.size();
|
||||
|
||||
for (size_t i = 0; i < numSequences; ++i)
|
||||
{
|
||||
m_sequences[i]->UpdateDynamicParams();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
CTrackViewAnimNodeBundle CTrackViewSequenceManager::GetAllRelatedAnimNodes(const AZ::EntityId entityId) const
|
||||
{
|
||||
|
||||
@@ -13,13 +13,11 @@
|
||||
|
||||
|
||||
#include "TrackViewSequence.h"
|
||||
#include "IDataBaseManager.h"
|
||||
|
||||
#include <AzCore/Component/EntityBus.h>
|
||||
|
||||
class CTrackViewSequenceManager
|
||||
: public IEditorNotifyListener
|
||||
, public IDataBaseManagerListener
|
||||
, public ITrackViewSequenceManager
|
||||
, public AZ::EntitySystemBus::Handler
|
||||
{
|
||||
@@ -65,8 +63,6 @@ private:
|
||||
void OnSequenceAdded(CTrackViewSequence* pSequence);
|
||||
void OnSequenceRemoved(CTrackViewSequence* pSequence);
|
||||
|
||||
void OnDataBaseItemEvent(IDataBaseItem* pItem, EDataBaseItemEvent event) override;
|
||||
|
||||
// AZ::EntitySystemBus
|
||||
void OnEntityNameChanged(const AZ::EntityId& entityId, const AZStd::string& name) override;
|
||||
void OnEntityDestruction(const AZ::EntityId& entityId) override;
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
#include "CheckOutDialog.h"
|
||||
#include "ISourceControl.h"
|
||||
#include "Dialogs/Generic/UserOptions.h"
|
||||
#include "IAssetItem.h"
|
||||
#include "IAssetItemDatabase.h"
|
||||
#include "Include/IObjectManager.h"
|
||||
#include "UsedResources.h"
|
||||
#include "Objects/BaseObject.h"
|
||||
@@ -223,106 +221,6 @@ void CFileUtil::EditTextureFile(const char* textureFile, [[maybe_unused]] bool b
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::CalculateDccFilename(const QString& assetFilename, QString& dccFilename)
|
||||
{
|
||||
if (ExtractDccFilenameFromAssetDatabase(assetFilename, dccFilename))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ExtractDccFilenameUsingNamingConventions(assetFilename, dccFilename))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
GetIEditor()->GetEnv()->pLog->LogError("Failed to find psd file for texture: '%s'", assetFilename.toUtf8().data());
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::ExtractDccFilenameFromAssetDatabase(const QString& assetFilename, QString& dccFilename)
|
||||
{
|
||||
IAssetItemDatabase* pCurrentDatabaseInterface = nullptr;
|
||||
std::vector<IClassDesc*> assetDatabasePlugins;
|
||||
IEditorClassFactory* pClassFactory = GetIEditor()->GetClassFactory();
|
||||
pClassFactory->GetClassesByCategory("Asset Item DB", assetDatabasePlugins);
|
||||
|
||||
for (size_t i = 0; i < assetDatabasePlugins.size(); ++i)
|
||||
{
|
||||
if (assetDatabasePlugins[i]->QueryInterface(__az_uuidof(IAssetItemDatabase), (void**)&pCurrentDatabaseInterface) == S_OK)
|
||||
{
|
||||
if (!pCurrentDatabaseInterface)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QString assetDatabaseDccFilename;
|
||||
IAssetItem* pAssetItem = pCurrentDatabaseInterface->GetAsset(assetFilename.toUtf8().data());
|
||||
if (pAssetItem)
|
||||
{
|
||||
if ((pAssetItem->GetFlags() & IAssetItem::eFlag_Cached))
|
||||
{
|
||||
QVariant v = pAssetItem->GetAssetFieldValue("dccfilename");
|
||||
assetDatabaseDccFilename = v.toString();
|
||||
if (!v.isNull())
|
||||
{
|
||||
dccFilename = assetDatabaseDccFilename;
|
||||
dccFilename = Path::GetRelativePath(dccFilename, false);
|
||||
|
||||
uint32 attr = CFileUtil::GetAttributes(dccFilename.toUtf8().data());
|
||||
|
||||
if (CFileUtil::FileExists(dccFilename))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (GetIEditor()->IsSourceControlAvailable() && (attr & SCC_FILE_ATTRIBUTE_MANAGED))
|
||||
{
|
||||
return CFileUtil::GetLatestFromSourceControl(dccFilename.toUtf8().data());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::ExtractDccFilenameUsingNamingConventions(const QString& assetFilename, QString& dccFilename)
|
||||
{
|
||||
//else to try find it by naming conventions
|
||||
QString tempStr = assetFilename;
|
||||
int foundSplit = -1;
|
||||
if ((foundSplit = tempStr.lastIndexOf('.')) > 0)
|
||||
{
|
||||
QString first = tempStr.mid(0, foundSplit);
|
||||
tempStr = first + ".psd";
|
||||
}
|
||||
if (CFileUtil::FileExists(tempStr))
|
||||
{
|
||||
dccFilename = tempStr;
|
||||
return true;
|
||||
}
|
||||
|
||||
//else try to find it by replacing post fix _<description> with .psd
|
||||
tempStr = assetFilename;
|
||||
foundSplit = -1;
|
||||
if ((foundSplit = tempStr.lastIndexOf('_')) > 0)
|
||||
{
|
||||
QString first = tempStr.mid(0, foundSplit);
|
||||
tempStr = first + ".psd";
|
||||
}
|
||||
if (CFileUtil::FileExists(tempStr))
|
||||
{
|
||||
dccFilename = tempStr;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CFileUtil::FormatFilterString(QString& filter)
|
||||
{
|
||||
|
||||
@@ -29,9 +29,6 @@ public:
|
||||
static void EditTextFile(const char* txtFile, int line = 0, IFileUtil::ETextFileType fileType = IFileUtil::FILE_TYPE_SCRIPT);
|
||||
static void EditTextureFile(const char* txtureFile, bool bUseGameFolder);
|
||||
|
||||
//! dcc filename calculation and extraction sub-routines
|
||||
static bool CalculateDccFilename(const QString& assetFilename, QString& dccFilename);
|
||||
|
||||
//! Reformat filter string for (MFC) CFileDialog style file filtering
|
||||
static void FormatFilterString(QString& filter);
|
||||
|
||||
@@ -155,9 +152,6 @@ private:
|
||||
|
||||
// Keep this variant of this method private! pIsSelected is captured in a lambda, and so requires menu use exec() and never use show()
|
||||
static void PopulateQMenu(QWidget* caller, QMenu* menu, AZStd::string_view fullGamePath, bool* pIsSelected);
|
||||
|
||||
static bool ExtractDccFilenameFromAssetDatabase(const QString& assetFilename, QString& dccFilename);
|
||||
static bool ExtractDccFilenameUsingNamingConventions(const QString& assetFilename, QString& dccFilename);
|
||||
};
|
||||
|
||||
class CAutoRestorePrimaryCDRoot
|
||||
|
||||
@@ -30,11 +30,6 @@ void CFileUtil_impl::EditTextureFile(const char* txtureFile, bool bUseGameFolder
|
||||
CFileUtil::EditTextureFile(txtureFile, bUseGameFolder);
|
||||
}
|
||||
|
||||
bool CFileUtil_impl::CalculateDccFilename(const QString& assetFilename, QString& dccFilename)
|
||||
{
|
||||
return CFileUtil::CalculateDccFilename(assetFilename, dccFilename);
|
||||
}
|
||||
|
||||
void CFileUtil_impl::FormatFilterString(QString& filter)
|
||||
{
|
||||
CFileUtil::FormatFilterString(filter);
|
||||
|
||||
@@ -39,9 +39,6 @@ public:
|
||||
bool ExtractFile(QString& file, bool bMsgBoxAskForExtraction = true, const char* pDestinationFilename = nullptr) override;
|
||||
void EditTextureFile(const char* txtureFile, bool bUseGameFolder) override;
|
||||
|
||||
//! dcc filename calculation and extraction sub-routines
|
||||
bool CalculateDccFilename(const QString& assetFilename, QString& dccFilename) override;
|
||||
|
||||
//! Reformat filter string for (MFC) CFileDialog style file filtering
|
||||
void FormatFilterString(QString& filter) override;
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ struct HitContext;
|
||||
struct IRenderListener;
|
||||
class CImageEx;
|
||||
class QMenu;
|
||||
struct IDataBaseItem;
|
||||
|
||||
/** Type of viewport.
|
||||
*/
|
||||
@@ -230,8 +229,6 @@ public:
|
||||
// Drag and drop support on viewports.
|
||||
// To be overrided in derived classes.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual bool CanDrop([[maybe_unused]] const QPoint& point, [[maybe_unused]] IDataBaseItem* pItem) { return false; };
|
||||
virtual void Drop([[maybe_unused]] const QPoint& point, [[maybe_unused]] IDataBaseItem* pItem) {};
|
||||
virtual void SetGlobalDropCallback(DropCallback dropCallback, void* dropCallbackCustom)
|
||||
{
|
||||
m_dropCallback = dropCallback;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "ViewportTitleDlg.h"
|
||||
|
||||
// Qt
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QInputDialog>
|
||||
|
||||
@@ -43,6 +44,7 @@
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportSettings.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h>
|
||||
#include <AzQtComponents/Components/Widgets/CheckBox.h>
|
||||
|
||||
#include <LmbrCentral/Audio/AudioSystemComponentBus.h>
|
||||
|
||||
@@ -51,6 +53,8 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#endif //! defined(Q_MOC_RUN)
|
||||
|
||||
static constexpr int MiniumOverflowMenuWidth = 200;
|
||||
|
||||
// CViewportTitleDlg dialog
|
||||
|
||||
namespace
|
||||
@@ -257,21 +261,56 @@ void CViewportTitleDlg::SetupHelpersButton()
|
||||
|
||||
void CViewportTitleDlg::SetupOverflowMenu()
|
||||
{
|
||||
// Setup the overflow menu
|
||||
QMenu* overFlowMenu = new QMenu(this);
|
||||
// simple override of QMenu that does not respond to keyboard events
|
||||
// note: this prevents the menu from being prematurely closed
|
||||
class IgnoreKeyboardMenu : public QMenu
|
||||
{
|
||||
public:
|
||||
IgnoreKeyboardMenu(QWidget *parent = nullptr) : QMenu(parent)
|
||||
{
|
||||
}
|
||||
|
||||
m_audioMuteAction = new QAction("Mute Audio", overFlowMenu);
|
||||
private:
|
||||
void keyPressEvent(QKeyEvent* event) override
|
||||
{
|
||||
// regular escape key handling
|
||||
if (event->key() == Qt::Key_Escape)
|
||||
{
|
||||
QMenu::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// setup the overflow menu
|
||||
auto* overflowMenu = new IgnoreKeyboardMenu(this);
|
||||
overflowMenu->setMinimumWidth(MiniumOverflowMenuWidth);
|
||||
|
||||
m_audioMuteAction = new QAction("Mute Audio", overflowMenu);
|
||||
connect(m_audioMuteAction, &QAction::triggered, this, &CViewportTitleDlg::OnBnClickedMuteAudio);
|
||||
overFlowMenu->addAction(m_audioMuteAction);
|
||||
overflowMenu->addAction(m_audioMuteAction);
|
||||
|
||||
overFlowMenu->addSeparator();
|
||||
overflowMenu->addSeparator();
|
||||
|
||||
m_enableGridSnappingAction = new QAction("Enable Grid Snapping", overFlowMenu);
|
||||
connect(m_enableGridSnappingAction, &QAction::triggered, this, &CViewportTitleDlg::OnGridSnappingToggled);
|
||||
m_enableGridSnappingAction->setCheckable(true);
|
||||
overFlowMenu->addAction(m_enableGridSnappingAction);
|
||||
m_enableGridSnappingCheckBox = new QCheckBox("Enable Grid Snapping", overflowMenu);
|
||||
AzQtComponents::CheckBox::applyToggleSwitchStyle(m_enableGridSnappingCheckBox);
|
||||
auto gridSnappingWidgetAction = new QWidgetAction(overflowMenu);
|
||||
gridSnappingWidgetAction->setDefaultWidget(m_enableGridSnappingCheckBox);
|
||||
connect(m_enableGridSnappingCheckBox, &QCheckBox::stateChanged, this, &CViewportTitleDlg::OnGridSnappingToggled);
|
||||
overflowMenu->addAction(gridSnappingWidgetAction);
|
||||
|
||||
m_gridSizeActionWidget = new QWidgetAction(overFlowMenu);
|
||||
m_enableGridVisualizationCheckBox = new QCheckBox("Show Grid", overflowMenu);
|
||||
AzQtComponents::CheckBox::applyToggleSwitchStyle(m_enableGridVisualizationCheckBox);
|
||||
auto gridVisualizationWidgetAction = new QWidgetAction(overflowMenu);
|
||||
gridVisualizationWidgetAction->setDefaultWidget(m_enableGridVisualizationCheckBox);
|
||||
connect(
|
||||
m_enableGridVisualizationCheckBox, &QCheckBox::stateChanged,
|
||||
[](const int state)
|
||||
{
|
||||
SandboxEditor::SetShowingGrid(state == Qt::Checked);
|
||||
});
|
||||
overflowMenu->addAction(gridVisualizationWidgetAction);
|
||||
|
||||
m_gridSizeActionWidget = new QWidgetAction(overflowMenu);
|
||||
m_gridSpinBox = new AzQtComponents::DoubleSpinBox();
|
||||
m_gridSpinBox->setValue(SandboxEditor::GridSnappingSize());
|
||||
m_gridSpinBox->setMinimum(1e-2f);
|
||||
@@ -281,31 +320,33 @@ void CViewportTitleDlg::SetupOverflowMenu()
|
||||
m_gridSpinBox, QOverload<double>::of(&AzQtComponents::DoubleSpinBox::valueChanged), this, &CViewportTitleDlg::OnGridSpinBoxChanged);
|
||||
|
||||
m_gridSizeActionWidget->setDefaultWidget(m_gridSpinBox);
|
||||
overFlowMenu->addAction(m_gridSizeActionWidget);
|
||||
overflowMenu->addAction(m_gridSizeActionWidget);
|
||||
|
||||
overFlowMenu->addSeparator();
|
||||
overflowMenu->addSeparator();
|
||||
|
||||
m_enableAngleSnappingAction = new QAction("Enable Angle Snapping", overFlowMenu);
|
||||
connect(m_enableAngleSnappingAction, &QAction::triggered, this, &CViewportTitleDlg::OnAngleSnappingToggled);
|
||||
m_enableAngleSnappingAction->setCheckable(true);
|
||||
overFlowMenu->addAction(m_enableAngleSnappingAction);
|
||||
m_enableAngleSnappingCheckBox = new QCheckBox("Enable Angle Snapping", overflowMenu);
|
||||
AzQtComponents::CheckBox::applyToggleSwitchStyle(m_enableAngleSnappingCheckBox);
|
||||
auto angleSnappingWidgetAction = new QWidgetAction(overflowMenu);
|
||||
angleSnappingWidgetAction->setDefaultWidget(m_enableAngleSnappingCheckBox);
|
||||
connect(m_enableAngleSnappingCheckBox, &QCheckBox::stateChanged, this, &CViewportTitleDlg::OnAngleSnappingToggled);
|
||||
overflowMenu->addAction(angleSnappingWidgetAction);
|
||||
|
||||
m_angleSizeActionWidget = new QWidgetAction(overFlowMenu);
|
||||
m_angleSizeActionWidget = new QWidgetAction(overflowMenu);
|
||||
m_angleSpinBox = new AzQtComponents::DoubleSpinBox();
|
||||
m_angleSpinBox->setValue(SandboxEditor::AngleSnappingSize());
|
||||
m_angleSpinBox->setMinimum(1e-2f);
|
||||
m_angleSpinBox->setToolTip(tr("Angle Snapping"));
|
||||
m_angleSpinBox->setToolTip(tr("Angle size"));
|
||||
|
||||
QObject::connect(
|
||||
m_angleSpinBox, QOverload<double>::of(&AzQtComponents::DoubleSpinBox::valueChanged), this,
|
||||
&CViewportTitleDlg::OnAngleSpinBoxChanged);
|
||||
|
||||
m_angleSizeActionWidget->setDefaultWidget(m_angleSpinBox);
|
||||
overFlowMenu->addAction(m_angleSizeActionWidget);
|
||||
overflowMenu->addAction(m_angleSizeActionWidget);
|
||||
|
||||
m_ui->m_overflowBtn->setMenu(overFlowMenu);
|
||||
m_ui->m_overflowBtn->setMenu(overflowMenu);
|
||||
m_ui->m_overflowBtn->setPopupMode(QToolButton::InstantPopup);
|
||||
connect(overFlowMenu, &QMenu::aboutToShow, this, &CViewportTitleDlg::UpdateOverFlowMenuState);
|
||||
connect(overflowMenu, &QMenu::aboutToShow, this, &CViewportTitleDlg::UpdateOverFlowMenuState);
|
||||
|
||||
UpdateMuteActionText();
|
||||
}
|
||||
@@ -982,43 +1023,49 @@ void CViewportTitleDlg::CheckForCameraSpeedUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
void CViewportTitleDlg::OnGridSnappingToggled()
|
||||
void CViewportTitleDlg::OnGridSnappingToggled(const int state)
|
||||
{
|
||||
m_gridSizeActionWidget->setEnabled(m_enableGridSnappingAction->isChecked());
|
||||
m_gridSizeActionWidget->setEnabled(state == Qt::Checked);
|
||||
m_enableGridVisualizationCheckBox->setEnabled(state == Qt::Checked);
|
||||
MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::SnapToGrid)->trigger();
|
||||
}
|
||||
|
||||
void CViewportTitleDlg::OnAngleSnappingToggled()
|
||||
void CViewportTitleDlg::OnAngleSnappingToggled(const int state)
|
||||
{
|
||||
m_angleSizeActionWidget->setEnabled(m_enableAngleSnappingAction->isChecked());
|
||||
m_angleSizeActionWidget->setEnabled(state == Qt::Checked);
|
||||
MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::SnapAngle)->trigger();
|
||||
}
|
||||
|
||||
void CViewportTitleDlg::OnGridSpinBoxChanged(double value)
|
||||
void CViewportTitleDlg::OnGridSpinBoxChanged(const double value)
|
||||
{
|
||||
SandboxEditor::SetGridSnappingSize(static_cast<float>(value));
|
||||
SandboxEditor::SetGridSnappingSize(aznumeric_cast<float>(value));
|
||||
}
|
||||
|
||||
void CViewportTitleDlg::OnAngleSpinBoxChanged(double value)
|
||||
void CViewportTitleDlg::OnAngleSpinBoxChanged(const double value)
|
||||
{
|
||||
SandboxEditor::SetAngleSnappingSize(static_cast<float>(value));
|
||||
SandboxEditor::SetAngleSnappingSize(aznumeric_cast<float>(value));
|
||||
}
|
||||
|
||||
void CViewportTitleDlg::UpdateOverFlowMenuState()
|
||||
{
|
||||
bool gridSnappingActive = MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::SnapToGrid)->isChecked();
|
||||
const bool gridSnappingActive = MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::SnapToGrid)->isChecked();
|
||||
{
|
||||
QSignalBlocker signalBlocker(m_enableGridSnappingAction);
|
||||
m_enableGridSnappingAction->setChecked(gridSnappingActive);
|
||||
QSignalBlocker signalBlocker(m_enableGridSnappingCheckBox);
|
||||
m_enableGridSnappingCheckBox->setChecked(gridSnappingActive);
|
||||
}
|
||||
m_gridSizeActionWidget->setEnabled(gridSnappingActive);
|
||||
|
||||
bool angleSnappingActive = MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::SnapAngle)->isChecked();
|
||||
const bool angleSnappingActive = MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::SnapAngle)->isChecked();
|
||||
{
|
||||
QSignalBlocker signalBlocker(m_enableAngleSnappingAction);
|
||||
m_enableAngleSnappingAction->setChecked(angleSnappingActive);
|
||||
QSignalBlocker signalBlocker(m_enableAngleSnappingCheckBox);
|
||||
m_enableAngleSnappingCheckBox->setChecked(angleSnappingActive);
|
||||
}
|
||||
m_angleSizeActionWidget->setEnabled(angleSnappingActive);
|
||||
|
||||
{
|
||||
QSignalBlocker signalBlocker(m_enableGridVisualizationCheckBox);
|
||||
m_enableGridVisualizationCheckBox->setChecked(SandboxEditor::ShowingGrid());
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
|
||||
@@ -140,8 +140,8 @@ protected:
|
||||
|
||||
void CheckForCameraSpeedUpdate();
|
||||
|
||||
void OnGridSnappingToggled();
|
||||
void OnAngleSnappingToggled();
|
||||
void OnGridSnappingToggled(int state);
|
||||
void OnAngleSnappingToggled(int state);
|
||||
|
||||
void OnGridSpinBoxChanged(double value);
|
||||
void OnAngleSpinBoxChanged(double value);
|
||||
@@ -160,8 +160,9 @@ protected:
|
||||
QAction* m_fullInformationAction = nullptr;
|
||||
QAction* m_compactInformationAction = nullptr;
|
||||
QAction* m_audioMuteAction = nullptr;
|
||||
QAction* m_enableGridSnappingAction = nullptr;
|
||||
QAction* m_enableAngleSnappingAction = nullptr;
|
||||
QCheckBox* m_enableGridSnappingCheckBox = nullptr;
|
||||
QCheckBox* m_enableGridVisualizationCheckBox = nullptr;
|
||||
QCheckBox* m_enableAngleSnappingCheckBox = nullptr;
|
||||
QComboBox* m_cameraSpeed = nullptr;
|
||||
AzQtComponents::DoubleSpinBox* m_gridSpinBox = nullptr;
|
||||
AzQtComponents::DoubleSpinBox* m_angleSpinBox = nullptr;
|
||||
@@ -175,7 +176,7 @@ protected:
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
//! A component to reflect scriptable commands for the Editor
|
||||
//! A component to reflect scriptable commands for the Editor.
|
||||
class ViewportTitleDlgPythonFuncsHandler
|
||||
: public AZ::Component
|
||||
{
|
||||
|
||||
@@ -7,17 +7,12 @@
|
||||
#
|
||||
|
||||
set(FILES
|
||||
BaseLibrary.h
|
||||
BaseLibraryItem.h
|
||||
UsedResources.h
|
||||
UIEnumsDatabase.h
|
||||
Include/EditorCoreAPI.cpp
|
||||
Include/IErrorReport.h
|
||||
Include/IBaseLibraryManager.h
|
||||
Include/IFileUtil.h
|
||||
Include/EditorCoreAPI.h
|
||||
Include/IEditorMaterial.h
|
||||
Include/IEditorMaterialManager.h
|
||||
Include/IImageUtil.h
|
||||
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.qrc
|
||||
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp
|
||||
@@ -35,8 +30,6 @@ set(FILES
|
||||
Controls/QBitmapPreviewDialogImp.h
|
||||
Controls/QToolTipWidget.h
|
||||
Controls/QToolTipWidget.cpp
|
||||
BaseLibraryItem.cpp
|
||||
BaseLibrary.cpp
|
||||
UsedResources.cpp
|
||||
UIEnumsDatabase.cpp
|
||||
LyViewPaneNames.h
|
||||
|
||||
@@ -269,14 +269,8 @@ set(FILES
|
||||
LevelTreeModel.h
|
||||
Include/Command.h
|
||||
Include/HitContext.h
|
||||
Include/IAnimationCompressionManager.h
|
||||
Include/IAssetItem.h
|
||||
Include/IAssetItemDatabase.h
|
||||
Include/ICommandManager.h
|
||||
Include/IConsoleConnectivity.h
|
||||
Include/IDataBaseItem.h
|
||||
Include/IDataBaseLibrary.h
|
||||
Include/IDataBaseManager.h
|
||||
Include/IDisplayViewport.h
|
||||
Include/IEditorClassFactory.h
|
||||
Include/IEventLoopHook.h
|
||||
@@ -334,23 +328,12 @@ set(FILES
|
||||
Controls/ConsoleSCB.qrc
|
||||
Controls/FolderTreeCtrl.cpp
|
||||
Controls/FolderTreeCtrl.h
|
||||
Controls/HotTrackingTreeCtrl.cpp
|
||||
Controls/HotTrackingTreeCtrl.h
|
||||
Controls/ImageHistogramCtrl.cpp
|
||||
Controls/ImageHistogramCtrl.h
|
||||
Controls/ImageListCtrl.cpp
|
||||
Controls/ImageListCtrl.h
|
||||
Controls/MultiMonHelper.cpp
|
||||
Controls/MultiMonHelper.h
|
||||
Controls/NumberCtrl.cpp
|
||||
Controls/NumberCtrl.h
|
||||
Controls/NumberCtrl.h
|
||||
Controls/SplineCtrl.cpp
|
||||
Controls/SplineCtrl.h
|
||||
Controls/SplineCtrlEx.cpp
|
||||
Controls/SplineCtrlEx.h
|
||||
Controls/TextEditorCtrl.cpp
|
||||
Controls/TextEditorCtrl.h
|
||||
Controls/TimelineCtrl.cpp
|
||||
Controls/TimelineCtrl.h
|
||||
Controls/WndGridHelper.h
|
||||
@@ -383,9 +366,6 @@ set(FILES
|
||||
ActionManager.h
|
||||
ShortcutDispatcher.cpp
|
||||
ShortcutDispatcher.h
|
||||
BaseLibraryManager.cpp
|
||||
BaseLibraryItem.h
|
||||
BaseLibraryManager.h
|
||||
CheckOutDialog.cpp
|
||||
CheckOutDialog.h
|
||||
CheckOutDialog.ui
|
||||
@@ -468,18 +448,14 @@ set(FILES
|
||||
GameResourcesExporter.cpp
|
||||
GameExporter.h
|
||||
GameResourcesExporter.h
|
||||
Geometry/TriMesh.cpp
|
||||
Geometry/TriMesh.h
|
||||
AboutDialog.h
|
||||
AboutDialog.ui
|
||||
DocMultiArchive.h
|
||||
EditMode/DeepSelection.h
|
||||
FBXExporterDialog.h
|
||||
FileTypeUtils.h
|
||||
GridUtils.h
|
||||
IObservable.h
|
||||
IPostRenderer.h
|
||||
LightmapCompiler/SimpleTriangleRasterizer.h
|
||||
ToolBox.h
|
||||
TrackViewNewSequenceDialog.h
|
||||
UndoConfigSpec.h
|
||||
@@ -570,11 +546,9 @@ set(FILES
|
||||
AboutDialog.cpp
|
||||
ErrorReportTableModel.h
|
||||
ErrorReportTableModel.cpp
|
||||
EditMode/DeepSelection.cpp
|
||||
FBXExporterDialog.cpp
|
||||
FBXExporterDialog.ui
|
||||
FileTypeUtils.cpp
|
||||
LightmapCompiler/SimpleTriangleRasterizer.cpp
|
||||
ToolBox.cpp
|
||||
TrackViewNewSequenceDialog.cpp
|
||||
TrackViewNewSequenceDialog.ui
|
||||
@@ -796,9 +770,6 @@ set(FILES
|
||||
ViewportTitleDlg.h
|
||||
EditorEnvironment.cpp
|
||||
EditorEnvironment.h
|
||||
IEditorPanelUtils.h
|
||||
EditorPanelUtils.h
|
||||
EditorPanelUtils.cpp
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE Plane Plane::CreateFromNormalAndDistance(const Vector3& normal, float dist)
|
||||
{
|
||||
AZ_MATH_ASSERT(normal.IsNormalized(), "This normal is not normalized");
|
||||
Plane result;
|
||||
result.Set(normal, dist);
|
||||
return result;
|
||||
@@ -35,7 +34,6 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE Plane Plane::CreateFromCoefficients(const float a, const float b, const float c, const float d)
|
||||
{
|
||||
AZ_MATH_ASSERT(Vector3(a, b, c).IsNormalized(), "This normal is notormalized");
|
||||
Plane result;
|
||||
result.Set(a, b, c, d);
|
||||
return result;
|
||||
@@ -68,21 +66,21 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE void Plane::Set(const Vector3& normal, float d)
|
||||
{
|
||||
AZ_MATH_ASSERT(normal.IsNormalized(), "This normal is notormalized");
|
||||
AZ_MATH_ASSERT(normal.IsNormalized(), "This normal is not normalized");
|
||||
m_plane.Set(normal, d);
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE void Plane::Set(float a, float b, float c, float d)
|
||||
{
|
||||
AZ_MATH_ASSERT(Vector3(a, b, c).IsNormalized(), "This normal is notormalized");
|
||||
AZ_MATH_ASSERT(Vector3(a, b, c).IsNormalized(), "This normal is not normalized");
|
||||
m_plane.Set(a, b, c, d);
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE void Plane::SetNormal(const Vector3& normal)
|
||||
{
|
||||
AZ_MATH_ASSERT(normal.IsNormalized(), "This normal is notormalized");
|
||||
AZ_MATH_ASSERT(normal.IsNormalized(), "This normal is not normalized");
|
||||
m_plane.SetX(normal.GetX());
|
||||
m_plane.SetY(normal.GetY());
|
||||
m_plane.SetZ(normal.GetZ());
|
||||
|
||||
@@ -6,8 +6,155 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Memory/AllocatorManager.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/Memory/AllocatorManager.h>
|
||||
|
||||
#define RECORDING_ENABLED 0
|
||||
|
||||
#if RECORDING_ENABLED
|
||||
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/std/parallel/mutex.h>
|
||||
#include <AzCore/std/parallel/scoped_lock.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
class DebugAllocator
|
||||
{
|
||||
public:
|
||||
using pointer_type = void*;
|
||||
using size_type = AZStd::size_t;
|
||||
using difference_type = AZStd::ptrdiff_t;
|
||||
using allow_memory_leaks = AZStd::false_type; ///< Regular allocators should not leak.
|
||||
|
||||
AZ_FORCE_INLINE pointer_type allocate(size_t byteSize, size_t alignment, int = 0)
|
||||
{
|
||||
return AZ_OS_MALLOC(byteSize, alignment);
|
||||
}
|
||||
AZ_FORCE_INLINE size_type resize(pointer_type, size_type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
AZ_FORCE_INLINE void deallocate(pointer_type ptr, size_type, size_type)
|
||||
{
|
||||
AZ_OS_FREE(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct alignas(1) AllocatorOperation
|
||||
{
|
||||
enum OperationType : size_t
|
||||
{
|
||||
ALLOCATE,
|
||||
DEALLOCATE
|
||||
};
|
||||
OperationType m_type: 1;
|
||||
size_t m_size : 28; // Can represent up to 256Mb requests
|
||||
size_t m_alignment : 7; // Can represent up to 128 alignment
|
||||
size_t m_recordId : 28; // Can represent up to 256M simultaneous requests, we reuse ids
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(AllocatorOperation) == 8);
|
||||
|
||||
static AZStd::mutex s_operationsMutex = {};
|
||||
|
||||
static constexpr size_t s_maxNumberOfAllocationsToRecord = 16384;
|
||||
static size_t s_numberOfAllocationsRecorded = 0;
|
||||
static constexpr size_t s_allocationOperationCount = 5 * 1024;
|
||||
static AZStd::array<AllocatorOperation, s_allocationOperationCount> s_operations = {};
|
||||
static uint64_t s_operationCounter = 0;
|
||||
|
||||
static unsigned int s_nextRecordId = 1;
|
||||
using AllocatorOperationByAddress = AZStd::unordered_map<void*, AllocatorOperation, AZStd::less<void*>, DebugAllocator>;
|
||||
static AllocatorOperationByAddress s_allocatorOperationByAddress;
|
||||
using AvailableRecordIds = AZStd::vector<unsigned int, DebugAllocator>;
|
||||
AvailableRecordIds s_availableRecordIds;
|
||||
|
||||
void RecordAllocatorOperation(AllocatorOperation::OperationType type, void* ptr, size_t size = 0, size_t alignment = 0)
|
||||
{
|
||||
AZStd::scoped_lock<AZStd::mutex> lock(s_operationsMutex);
|
||||
if (s_operationCounter == s_allocationOperationCount)
|
||||
{
|
||||
AZ::IO::SystemFile file;
|
||||
int mode = AZ::IO::SystemFile::OpenMode::SF_OPEN_APPEND | AZ::IO::SystemFile::OpenMode::SF_OPEN_WRITE_ONLY;
|
||||
if (!file.Exists("memoryrecordings.bin"))
|
||||
{
|
||||
mode |= AZ::IO::SystemFile::OpenMode::SF_OPEN_CREATE;
|
||||
}
|
||||
file.Open("memoryrecordings.bin", mode);
|
||||
if (file.IsOpen())
|
||||
{
|
||||
file.Write(&s_operations, sizeof(AllocatorOperation) * s_allocationOperationCount);
|
||||
file.Close();
|
||||
}
|
||||
s_operationCounter = 0;
|
||||
}
|
||||
AllocatorOperation& operation = s_operations[s_operationCounter++];
|
||||
operation.m_type = type;
|
||||
if (type == AllocatorOperation::OperationType::ALLOCATE)
|
||||
{
|
||||
if (s_numberOfAllocationsRecorded > s_maxNumberOfAllocationsToRecord)
|
||||
{
|
||||
// reached limit of allocations, dont record anymore
|
||||
--s_operationCounter;
|
||||
return;
|
||||
}
|
||||
++s_numberOfAllocationsRecorded;
|
||||
operation.m_size = size;
|
||||
operation.m_alignment = alignment;
|
||||
unsigned int recordId = 0;
|
||||
if (!s_availableRecordIds.empty())
|
||||
{
|
||||
recordId = s_availableRecordIds.back();
|
||||
s_availableRecordIds.pop_back();
|
||||
}
|
||||
else
|
||||
{
|
||||
recordId = s_nextRecordId;
|
||||
++s_nextRecordId;
|
||||
}
|
||||
operation.m_recordId = recordId;
|
||||
auto it = s_allocatorOperationByAddress.emplace(ptr, operation);
|
||||
if (!it.second)
|
||||
{
|
||||
// double alloc or resize, leave the current record and return the id
|
||||
operation = it.first->second;
|
||||
s_availableRecordIds.emplace_back(recordId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ptr == nullptr)
|
||||
{
|
||||
// common scenario, just record the operation
|
||||
operation.m_size = 0;
|
||||
operation.m_alignment = 0;
|
||||
operation.m_recordId = 0; // recordId = 0 will flag this case
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = s_allocatorOperationByAddress.find(ptr);
|
||||
if (it != s_allocatorOperationByAddress.end())
|
||||
{
|
||||
operation.m_size = it->second.m_size;
|
||||
operation.m_alignment = it->second.m_alignment;
|
||||
operation.m_recordId = it->second.m_recordId;
|
||||
s_availableRecordIds.push_back(it->second.m_recordId);
|
||||
s_allocatorOperationByAddress.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
// just dont record this operation
|
||||
--s_operationCounter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -150,6 +297,10 @@ namespace AZ
|
||||
records->RegisterAllocation(ptr, byteSize, alignment, name, fileName, lineNum, suppressStackRecord + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#if RECORDING_ENABLED
|
||||
RecordAllocatorOperation(AllocatorOperation::ALLOCATE, ptr, byteSize, alignment);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AllocatorBase::ProfileDeallocation(void* ptr, size_t byteSize, size_t alignment, Debug::AllocationInfo* info)
|
||||
@@ -162,6 +313,9 @@ namespace AZ
|
||||
records->UnregisterAllocation(ptr, byteSize, alignment, info);
|
||||
}
|
||||
}
|
||||
#if RECORDING_ENABLED
|
||||
RecordAllocatorOperation(AllocatorOperation::DEALLOCATE, ptr, byteSize, alignment);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AllocatorBase::ProfileReallocationBegin([[maybe_unused]] void* ptr, [[maybe_unused]] size_t newSize)
|
||||
@@ -176,6 +330,10 @@ namespace AZ
|
||||
ProfileDeallocation(ptr, 0, 0, &info);
|
||||
ProfileAllocation(newPtr, newSize, newAlignment, info.m_name, info.m_fileName, info.m_lineNum, 0);
|
||||
}
|
||||
#if RECORDING_ENABLED
|
||||
RecordAllocatorOperation(AllocatorOperation::DEALLOCATE, ptr);
|
||||
RecordAllocatorOperation(AllocatorOperation::ALLOCATE, newPtr, newSize, newAlignment);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AllocatorBase::ProfileReallocation(void* ptr, void* newPtr, size_t newSize, size_t newAlignment)
|
||||
@@ -193,6 +351,9 @@ namespace AZ
|
||||
records->ResizeAllocation(ptr, newSize);
|
||||
}
|
||||
}
|
||||
#if RECORDING_ENABLED
|
||||
RecordAllocatorOperation(AllocatorOperation::ALLOCATE, ptr, newSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AllocatorBase::OnOutOfMemory(size_t byteSize, size_t alignment, int flags, const char* name, const char* fileName, int lineNum)
|
||||
|
||||
@@ -115,6 +115,7 @@ namespace AZ
|
||||
m_ownMemoryBlock[i] = false;
|
||||
}
|
||||
|
||||
AZ_Assert(m_desc.m_numMemoryBlocks > 0, "At least one memory block is required");
|
||||
for (int i = 0; i < m_desc.m_numMemoryBlocks; ++i)
|
||||
{
|
||||
if (m_desc.m_memoryBlocks[i] == nullptr) // Allocate memory block if requested!
|
||||
@@ -131,17 +132,6 @@ namespace AZ
|
||||
|
||||
m_capacity += m_desc.m_memoryBlocksByteSize[i];
|
||||
}
|
||||
|
||||
if (m_desc.m_numMemoryBlocks == 0)
|
||||
{
|
||||
// Create default memory space if we can to serve for default allocations
|
||||
m_memSpaces[0] = AZDLMalloc::create_mspace(0, m_desc.m_isMultithreadAlloc);
|
||||
if (m_memSpaces[0])
|
||||
{
|
||||
AZDLMalloc::mspace_az_set_expandable(m_memSpaces[0], true);
|
||||
m_capacity = Platform::GetHeapCapacity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HeapSchema::~HeapSchema()
|
||||
|
||||
@@ -32,17 +32,11 @@ namespace AZ
|
||||
*/
|
||||
struct Descriptor
|
||||
{
|
||||
Descriptor()
|
||||
: m_numMemoryBlocks(0)
|
||||
, m_isMultithreadAlloc(true)
|
||||
{}
|
||||
|
||||
static const int m_memoryBlockAlignment = 64 * 1024;
|
||||
static const int m_maxNumBlocks = 5;
|
||||
int m_numMemoryBlocks; ///< Number of memory blocks to use.
|
||||
void* m_memoryBlocks[m_maxNumBlocks]; ///< Pointers to provided memory blocks or NULL if you want the system to allocate them for you with the System Allocator.
|
||||
size_t m_memoryBlocksByteSize[m_maxNumBlocks]; ///< Sizes of different memory blocks, if m_memoryBlock is 0 the block will be allocated for you with the System Allocator.
|
||||
bool m_isMultithreadAlloc; ///< Set to true to enable multi threading safe allocation.
|
||||
int m_numMemoryBlocks = 1; ///< Number of memory blocks to use.
|
||||
void* m_memoryBlocks[m_maxNumBlocks] = {}; ///< Pointers to provided memory blocks or NULL if you want the system to allocate them for you with the System Allocator.
|
||||
size_t m_memoryBlocksByteSize[m_maxNumBlocks] = {4 * 1024}; ///< Sizes of different memory blocks, if m_memoryBlock is 0 the block will be allocated for you with the System Allocator.
|
||||
bool m_isMultithreadAlloc = true; ///< Set to true to enable multi threading safe allocation.
|
||||
};
|
||||
|
||||
HeapSchema(const Descriptor& desc);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#define AZCORE_SYSTEM_ALLOCATOR_HPHA 1
|
||||
#define AZCORE_SYSTEM_ALLOCATOR_MALLOC 2
|
||||
#define AZCORE_SYSTEM_ALLOCATOR_HEAP 3
|
||||
|
||||
#if !defined(AZCORE_SYSTEM_ALLOCATOR)
|
||||
// define the default
|
||||
@@ -29,8 +28,6 @@
|
||||
#include <AzCore/Memory/HphaSchema.h>
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_MALLOC
|
||||
#include <AzCore/Memory/MallocSchema.h>
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_HEAP
|
||||
#include <AzCore/Memory/HeapSchema.h>
|
||||
#else
|
||||
#error "Invalid allocator selected for SystemAllocator"
|
||||
#endif
|
||||
@@ -44,8 +41,6 @@ namespace AZ
|
||||
static AZStd::aligned_storage<sizeof(HphaSchema), AZStd::alignment_of<HphaSchema>::value>::type g_systemSchema;
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_MALLOC
|
||||
static AZStd::aligned_storage<sizeof(MallocSchema), AZStd::alignment_of<MallocSchema>::value>::type g_systemSchema;
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_HEAP
|
||||
static AZStd::aligned_storage<sizeof(HeapSchema), AZStd::alignment_of<HeapSchema>::value>::type g_systemSchema;
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -118,11 +113,6 @@ namespace AZ
|
||||
heapDesc.m_systemChunkSize = desc.m_heap.m_systemChunkSize;
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_MALLOC
|
||||
MallocSchema::Descriptor heapDesc;
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_HEAP
|
||||
HeapSchema::Descriptor heapDesc;
|
||||
memcpy(heapDesc.m_memoryBlocks, desc.m_heap.m_memoryBlocks, sizeof(heapDesc.m_memoryBlocks));
|
||||
memcpy(heapDesc.m_memoryBlocksByteSize, desc.m_heap.m_memoryBlocksByteSize, sizeof(heapDesc.m_memoryBlocksByteSize));
|
||||
heapDesc.m_numMemoryBlocks = desc.m_heap.m_numMemoryBlocks;
|
||||
#endif
|
||||
if (&AllocatorInstance<SystemAllocator>::Get() == this) // if we are the system allocator
|
||||
{
|
||||
@@ -132,8 +122,6 @@ namespace AZ
|
||||
m_allocator = new (&g_systemSchema) HphaSchema(heapDesc);
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_MALLOC
|
||||
m_allocator = new (&g_systemSchema) MallocSchema(heapDesc);
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_HEAP
|
||||
m_allocator = new (&g_systemSchema) HeapSchema(heapDesc);
|
||||
#endif
|
||||
g_isSystemSchemaUsed = true;
|
||||
isReady = true;
|
||||
@@ -149,8 +137,6 @@ namespace AZ
|
||||
m_allocator = azcreate(HphaSchema, (heapDesc), SystemAllocator);
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_MALLOC
|
||||
m_allocator = azcreate(MallocSchema, (heapDesc), SystemAllocator);
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_HEAP
|
||||
m_allocator = azcreate(HeapSchema, (heapDesc), SystemAllocator);
|
||||
#endif
|
||||
if (m_allocator == nullptr)
|
||||
{
|
||||
@@ -186,8 +172,6 @@ namespace AZ
|
||||
static_cast<HphaSchema*>(m_allocator)->~HphaSchema();
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_MALLOC
|
||||
static_cast<MallocSchema*>(m_allocator)->~MallocSchema();
|
||||
#elif AZCORE_SYSTEM_ALLOCATOR == AZCORE_SYSTEM_ALLOCATOR_HEAP
|
||||
static_cast<HeapSchema*>(m_allocator)->~HeapSchema();
|
||||
#endif
|
||||
g_isSystemSchemaUsed = false;
|
||||
}
|
||||
|
||||
@@ -45,9 +45,8 @@ namespace AZ
|
||||
}
|
||||
else
|
||||
{
|
||||
SerializerMap::const_iterator serializerIter = m_jsonSerializers.find(typeId);
|
||||
AZ_Assert(serializerIter != m_jsonSerializers.end(), "Attempting to unregister a serializer that has not been registered yet with typeid %s", typeId.ToString<AZStd::string>().c_str());
|
||||
m_jsonSerializers.erase(serializerIter);
|
||||
[[maybe_unused]] size_t erased = m_jsonSerializers.erase(typeId);
|
||||
AZ_Assert(erased == 1, "Attempting to unregister a serializer that has not been registered yet with typeid %s", typeId.ToString<AZStd::string>().c_str());
|
||||
return SerializerBuilder(this, m_jsonSerializers.end());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +146,11 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
PROPERTY COMPILE_DEFINITIONS
|
||||
VALUES AZCORETEST_DLL_NAME=\"$<TARGET_FILE_NAME:AzCore.Tests>\"
|
||||
)
|
||||
ly_add_target_files(
|
||||
TARGETS AzCore.Tests
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/Tests/Memory/AllocatorBenchmarkRecordings.bin
|
||||
OUTPUT_SUBDIRECTORY Tests/AzCore/Memory
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
|
||||
#if AZ_DEBUG_BUILD
|
||||
#define AZ_MATH_TEST_START_TRACE_SUPPRESSION AZ_TEST_START_TRACE_SUPPRESSION
|
||||
#define AZ_MATH_TEST_STOP_TRACE_SUPPRESSION(x) AZ_TEST_STOP_TRACE_SUPPRESSION(x)
|
||||
#else
|
||||
#define AZ_MATH_TEST_START_TRACE_SUPPRESSION
|
||||
#define AZ_MATH_TEST_STOP_TRACE_SUPPRESSION(x)
|
||||
#endif
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/Vector4.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <Math/MathTest.h>
|
||||
|
||||
using namespace AZ;
|
||||
|
||||
@@ -47,7 +48,9 @@ namespace UnitTest
|
||||
TEST(MATH_Plane, TestSet)
|
||||
{
|
||||
Plane pl;
|
||||
AZ_MATH_TEST_START_TRACE_SUPPRESSION;
|
||||
pl.Set(12.0f, 13.0f, 14.0f, 15.0f);
|
||||
AZ_MATH_TEST_STOP_TRACE_SUPPRESSION(1);
|
||||
AZ_TEST_ASSERT_FLOAT_CLOSE(pl.GetDistance(), 15.0f);
|
||||
AZ_TEST_ASSERT_FLOAT_CLOSE(pl.GetNormal().GetX(), 12.0f);
|
||||
AZ_TEST_ASSERT_FLOAT_CLOSE(pl.GetNormal().GetY(), 13.0f);
|
||||
@@ -57,7 +60,9 @@ namespace UnitTest
|
||||
TEST(MATH_Plane, TestSetVector3)
|
||||
{
|
||||
Plane pl;
|
||||
AZ_MATH_TEST_START_TRACE_SUPPRESSION;
|
||||
pl.Set(Vector3(22.0f, 23.0f, 24.0f), 25.0f);
|
||||
AZ_MATH_TEST_STOP_TRACE_SUPPRESSION(1);
|
||||
AZ_TEST_ASSERT_FLOAT_CLOSE(pl.GetDistance(), 25.0f);
|
||||
AZ_TEST_ASSERT_FLOAT_CLOSE(pl.GetNormal().GetX(), 22.0f);
|
||||
AZ_TEST_ASSERT_FLOAT_CLOSE(pl.GetNormal().GetY(), 23.0f);
|
||||
@@ -177,17 +182,21 @@ namespace UnitTest
|
||||
pl.Set(1.0f, 0.0f, 0.0f, 0.0f);
|
||||
AZ_TEST_ASSERT(pl.IsFinite());
|
||||
const float infinity = std::numeric_limits<float>::infinity();
|
||||
AZ_MATH_TEST_START_TRACE_SUPPRESSION;
|
||||
pl.Set(infinity, infinity, infinity, infinity);
|
||||
AZ_MATH_TEST_STOP_TRACE_SUPPRESSION(1);
|
||||
AZ_TEST_ASSERT(!pl.IsFinite());
|
||||
}
|
||||
|
||||
TEST(MATH_Plane, CreateFromVectorCoefficients_IsEquivalentToCreateFromCoefficients)
|
||||
{
|
||||
AZ_MATH_TEST_START_TRACE_SUPPRESSION;
|
||||
Plane planeFromCoefficients = Plane::CreateFromCoefficients(1.0, 2.0, 3.0, 4.0);
|
||||
|
||||
AZ_MATH_TEST_STOP_TRACE_SUPPRESSION(1);
|
||||
Vector4 coefficients(1.0, 2.0, 3.0, 4.0);
|
||||
Plane planeFromVectorCoefficients = Plane::CreateFromVectorCoefficients(coefficients);
|
||||
|
||||
|
||||
EXPECT_EQ(planeFromVectorCoefficients, planeFromCoefficients);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:281ba03e79ecba90b313a0b17bdba87c57d76b504b6e38d579b5eabd995902cc
|
||||
size 245760
|
||||
@@ -0,0 +1,591 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(HAVE_BENCHMARK)
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/Memory/BestFitExternalMapAllocator.h>
|
||||
#include <AzCore/Memory/HeapSchema.h>
|
||||
#include <AzCore/Memory/HphaSchema.h>
|
||||
#include <AzCore/Memory/MallocSchema.h>
|
||||
#include <AzCore/Memory/OSAllocator.h>
|
||||
#include <AzCore/Memory/PoolSchema.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/std/containers/array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
namespace Benchmark
|
||||
{
|
||||
namespace Platform
|
||||
{
|
||||
size_t GetProcessMemoryUsageBytes();
|
||||
size_t GetMemorySize(void* memory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test allocator wrapper that redirects the calls to the passed TAllocator by using AZ::AllocatorInstance.
|
||||
/// It also creates/destroys the TAllocator type (to reflect what happens at runtime)
|
||||
/// </summary>
|
||||
/// <typeparam name="TAllocator">Allocator type to wrap</typeparam>
|
||||
template<typename TAllocator>
|
||||
class TestAllocatorWrapper
|
||||
{
|
||||
public:
|
||||
static void SetUp()
|
||||
{
|
||||
AZ::AllocatorInstance<TAllocator>::Create();
|
||||
}
|
||||
|
||||
static void TearDown()
|
||||
{
|
||||
AZ::AllocatorInstance<TAllocator>::Destroy();
|
||||
}
|
||||
|
||||
static void* Allocate(size_t byteSize, size_t alignment)
|
||||
{
|
||||
return AZ::AllocatorInstance<TAllocator>::Get().Allocate(byteSize, alignment);
|
||||
}
|
||||
|
||||
static void DeAllocate(void* ptr, size_t byteSize = 0)
|
||||
{
|
||||
AZ::AllocatorInstance<TAllocator>::Get().DeAllocate(ptr, byteSize);
|
||||
}
|
||||
|
||||
static void* ReAllocate(void* ptr, size_t newSize, size_t newAlignment)
|
||||
{
|
||||
return AZ::AllocatorInstance<TAllocator>::Get().ReAllocate(ptr, newSize, newAlignment);
|
||||
}
|
||||
|
||||
static size_t Resize(void* ptr, size_t newSize)
|
||||
{
|
||||
return AZ::AllocatorInstance<TAllocator>::Get().Resize(ptr, newSize);
|
||||
}
|
||||
|
||||
static void GarbageCollect()
|
||||
{
|
||||
AZ::AllocatorInstance<TAllocator>::Get().GarbageCollect();
|
||||
}
|
||||
|
||||
static size_t NumAllocatedBytes()
|
||||
{
|
||||
return AZ::AllocatorInstance<TAllocator>::Get().NumAllocatedBytes() +
|
||||
AZ::AllocatorInstance<TAllocator>::Get().GetUnAllocatedMemory();
|
||||
}
|
||||
|
||||
static size_t GetSize(void* ptr)
|
||||
{
|
||||
return AZ::AllocatorInstance<TAllocator>::Get().AllocationSize(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Basic allocator used as a baseline. This allocator is the most basic allocation possible with the OS (AZ_OS_MALLOC).
|
||||
/// MallocSchema cannot be used here because it has extra logic that we don't want to use as a baseline.
|
||||
/// </summary>
|
||||
class RawMallocAllocator {};
|
||||
|
||||
template<>
|
||||
class TestAllocatorWrapper<RawMallocAllocator>
|
||||
{
|
||||
public:
|
||||
TestAllocatorWrapper()
|
||||
{
|
||||
s_numAllocatedBytes = 0;
|
||||
}
|
||||
|
||||
static void SetUp()
|
||||
{
|
||||
s_numAllocatedBytes = 0;
|
||||
}
|
||||
|
||||
static void TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
// IAllocatorAllocate
|
||||
static void* Allocate(size_t byteSize, size_t)
|
||||
{
|
||||
s_numAllocatedBytes += byteSize;
|
||||
// Don't pass an alignment since we wont be able to get the memory size without also passing the alignment
|
||||
return AZ_OS_MALLOC(byteSize, 1);
|
||||
}
|
||||
|
||||
static void DeAllocate(void* ptr, size_t = 0)
|
||||
{
|
||||
s_numAllocatedBytes -= Platform::GetMemorySize(ptr);
|
||||
AZ_OS_FREE(ptr);
|
||||
}
|
||||
|
||||
static void* ReAllocate(void* ptr, size_t newSize, size_t)
|
||||
{
|
||||
s_numAllocatedBytes -= Platform::GetMemorySize(ptr);
|
||||
AZ_OS_FREE(ptr);
|
||||
|
||||
s_numAllocatedBytes += newSize;
|
||||
return AZ_OS_MALLOC(newSize, 1);
|
||||
}
|
||||
|
||||
static size_t Resize(void* ptr, size_t newSize)
|
||||
{
|
||||
AZ_UNUSED(ptr);
|
||||
AZ_UNUSED(newSize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void GarbageCollect() {}
|
||||
|
||||
static size_t NumAllocatedBytes()
|
||||
{
|
||||
return s_numAllocatedBytes;
|
||||
}
|
||||
|
||||
static size_t GetSize(void* ptr)
|
||||
{
|
||||
return Platform::GetMemorySize(ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
static size_t s_numAllocatedBytes;
|
||||
};
|
||||
|
||||
size_t TestAllocatorWrapper<RawMallocAllocator>::s_numAllocatedBytes = 0;
|
||||
|
||||
// Some allocator are not fully declared, those we simply setup from the schema
|
||||
class MallocSchemaAllocator : public AZ::SimpleSchemaAllocator<AZ::MallocSchema>
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(MallocSchemaAllocator, "{3E68224F-E676-402C-8276-CE4B49C05E89}");
|
||||
|
||||
MallocSchemaAllocator()
|
||||
: AZ::SimpleSchemaAllocator<AZ::MallocSchema>("MallocSchemaAllocator", "")
|
||||
{}
|
||||
};
|
||||
|
||||
// We use both this HphaSchemaAllocator and the SystemAllocator configured with Hpha because the SystemAllocator
|
||||
// has extra things
|
||||
class HphaSchemaAllocator : public AZ::SimpleSchemaAllocator<AZ::HphaSchema>
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(HphaSchemaAllocator, "{6563AB4B-A68E-4499-8C98-D61D640D1F7F}");
|
||||
|
||||
HphaSchemaAllocator()
|
||||
: AZ::SimpleSchemaAllocator<AZ::HphaSchema>("TestHphaSchemaAllocator", "")
|
||||
{}
|
||||
};
|
||||
|
||||
// For the SystemAllocator we inherit so we have a different stack. The SystemAllocator is used globally so we dont want
|
||||
// to get that data affecting the benchmark
|
||||
class TestSystemAllocator : public AZ::SystemAllocator
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(TestSystemAllocator, "{360D4DAA-D65D-4D5C-A6FA-1A4C5261C35C}");
|
||||
|
||||
TestSystemAllocator()
|
||||
: AZ::SystemAllocator()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// Allocated bytes reported by the allocator
|
||||
static const char* s_counterAllocatorMemory = "Allocator_Memory";
|
||||
|
||||
// Allocated bytes as counted by the benchmark
|
||||
static const char* s_counterBenchmarkMemory = "Benchmark_Memory";
|
||||
|
||||
enum AllocationSize
|
||||
{
|
||||
SMALL,
|
||||
BIG,
|
||||
MIXED,
|
||||
COUNT
|
||||
};
|
||||
|
||||
static const size_t s_kiloByte = 1024;
|
||||
static const size_t s_megaByte = s_kiloByte * s_kiloByte;
|
||||
using AllocationSizeArray = AZStd::array<size_t, 10>;
|
||||
static const AZStd::array<AllocationSizeArray, COUNT> s_allocationSizes = {
|
||||
/* SMALL */ AllocationSizeArray{ 2, 16, 20, 59, 100, 128, 160, 250, 300, 512 },
|
||||
/* BIG */ AllocationSizeArray{ 513, s_kiloByte, 2 * s_kiloByte, 4 * s_kiloByte, 10 * s_kiloByte, 64 * s_kiloByte, 128 * s_kiloByte, 200 * s_kiloByte, s_megaByte, 2 * s_megaByte },
|
||||
/* MIXED */ AllocationSizeArray{ 2, s_kiloByte, 59, 4 * s_kiloByte, 128, 200 * s_kiloByte, 250, s_megaByte, 512, 2 * s_megaByte }
|
||||
};
|
||||
|
||||
template <typename TAllocator>
|
||||
class AllocatorBenchmarkFixture
|
||||
: public ::benchmark::Fixture
|
||||
{
|
||||
protected:
|
||||
using TestAllocatorType = TestAllocatorWrapper<TAllocator>;
|
||||
|
||||
virtual void internalSetUp(const ::benchmark::State& state)
|
||||
{
|
||||
if (state.thread_index == 0) // Only setup in the first thread
|
||||
{
|
||||
TestAllocatorType::SetUp();
|
||||
|
||||
m_allocations.resize(state.threads);
|
||||
for (auto& perThreadAllocations : m_allocations)
|
||||
{
|
||||
perThreadAllocations.resize(state.range(0), nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void internalTearDown(const ::benchmark::State& state)
|
||||
{
|
||||
if (state.thread_index == 0) // Only setup in the first thread
|
||||
{
|
||||
m_allocations.clear();
|
||||
m_allocations.shrink_to_fit();
|
||||
|
||||
TestAllocatorType::TearDown();
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::vector<void*>& GetPerThreadAllocations(size_t threadIndex)
|
||||
{
|
||||
return m_allocations[threadIndex];
|
||||
}
|
||||
|
||||
public:
|
||||
void SetUp(const ::benchmark::State& state) override
|
||||
{
|
||||
internalSetUp(state);
|
||||
}
|
||||
void SetUp(::benchmark::State& state) override
|
||||
{
|
||||
internalSetUp(state);
|
||||
}
|
||||
|
||||
void TearDown(const ::benchmark::State& state) override
|
||||
{
|
||||
internalTearDown(state);
|
||||
}
|
||||
void TearDown(::benchmark::State& state) override
|
||||
{
|
||||
internalTearDown(state);
|
||||
}
|
||||
|
||||
private:
|
||||
AZStd::vector<AZStd::vector<void*>> m_allocations;
|
||||
};
|
||||
|
||||
template <typename TAllocator, AllocationSize TAllocationSize>
|
||||
class AllocationBenchmarkFixture
|
||||
: public AllocatorBenchmarkFixture<TAllocator>
|
||||
{
|
||||
using base = AllocatorBenchmarkFixture<TAllocator>;
|
||||
using TestAllocatorType = typename base::TestAllocatorType;
|
||||
|
||||
public:
|
||||
void Benchmark(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state)
|
||||
{
|
||||
state.PauseTiming();
|
||||
|
||||
AZStd::vector<void*>& perThreadAllocations = base::GetPerThreadAllocations(state.thread_index);
|
||||
const size_t numberOfAllocations = perThreadAllocations.size();
|
||||
size_t totalAllocationSize = 0;
|
||||
for (size_t allocationIndex = 0; allocationIndex < numberOfAllocations; ++allocationIndex)
|
||||
{
|
||||
const AllocationSizeArray& allocationArray = s_allocationSizes[TAllocationSize];
|
||||
const size_t allocationSize = allocationArray[allocationIndex % allocationArray.size()];
|
||||
totalAllocationSize += allocationSize;
|
||||
|
||||
state.ResumeTiming();
|
||||
perThreadAllocations[allocationIndex] = TestAllocatorType::Allocate(allocationSize, 0);
|
||||
state.PauseTiming();
|
||||
}
|
||||
|
||||
state.counters[s_counterAllocatorMemory] = benchmark::Counter(static_cast<double>(TestAllocatorType::NumAllocatedBytes()), benchmark::Counter::kDefaults);
|
||||
state.counters[s_counterBenchmarkMemory] = benchmark::Counter(static_cast<double>(totalAllocationSize), benchmark::Counter::kDefaults);
|
||||
|
||||
for (size_t allocationIndex = 0; allocationIndex < numberOfAllocations; ++allocationIndex)
|
||||
{
|
||||
const AllocationSizeArray& allocationArray = s_allocationSizes[TAllocationSize];
|
||||
const size_t allocationSize = allocationArray[allocationIndex % allocationArray.size()];
|
||||
TestAllocatorType::DeAllocate(perThreadAllocations[allocationIndex], allocationSize);
|
||||
perThreadAllocations[allocationIndex] = nullptr;
|
||||
}
|
||||
TestAllocatorType::GarbageCollect();
|
||||
|
||||
state.SetItemsProcessed(numberOfAllocations);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TAllocator, AllocationSize TAllocationSize>
|
||||
class DeAllocationBenchmarkFixture
|
||||
: public AllocatorBenchmarkFixture<TAllocator>
|
||||
{
|
||||
using base = AllocatorBenchmarkFixture<TAllocator>;
|
||||
using TestAllocatorType = typename base::TestAllocatorType;
|
||||
|
||||
public:
|
||||
void Benchmark(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state)
|
||||
{
|
||||
state.PauseTiming();
|
||||
AZStd::vector<void*>& perThreadAllocations = base::GetPerThreadAllocations(state.thread_index);
|
||||
|
||||
const size_t numberOfAllocations = perThreadAllocations.size();
|
||||
size_t totalAllocationSize = 0;
|
||||
for (size_t allocationIndex = 0; allocationIndex < numberOfAllocations; ++allocationIndex)
|
||||
{
|
||||
const AllocationSizeArray& allocationArray = s_allocationSizes[TAllocationSize];
|
||||
const size_t allocationSize = allocationArray[allocationIndex % allocationArray.size()];
|
||||
totalAllocationSize += allocationSize;
|
||||
perThreadAllocations[allocationIndex] = TestAllocatorType::Allocate(allocationSize, 0);
|
||||
}
|
||||
|
||||
for (size_t allocationIndex = 0; allocationIndex < numberOfAllocations; ++allocationIndex)
|
||||
{
|
||||
const AllocationSizeArray& allocationArray = s_allocationSizes[TAllocationSize];
|
||||
const size_t allocationSize = allocationArray[allocationIndex % allocationArray.size()];
|
||||
state.ResumeTiming();
|
||||
TestAllocatorType::DeAllocate(perThreadAllocations[allocationIndex], allocationSize);
|
||||
state.PauseTiming();
|
||||
perThreadAllocations[allocationIndex] = nullptr;
|
||||
}
|
||||
|
||||
state.counters[s_counterAllocatorMemory] = benchmark::Counter(static_cast<double>(TestAllocatorType::NumAllocatedBytes()), benchmark::Counter::kDefaults);
|
||||
state.counters[s_counterBenchmarkMemory] = benchmark::Counter(static_cast<double>(totalAllocationSize), benchmark::Counter::kDefaults);
|
||||
|
||||
state.SetItemsProcessed(numberOfAllocations);
|
||||
|
||||
TestAllocatorType::GarbageCollect();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename TAllocator>
|
||||
class RecordedAllocationBenchmarkFixture : public ::benchmark::Fixture
|
||||
{
|
||||
using TestAllocatorType = TestAllocatorWrapper<TAllocator>;
|
||||
|
||||
virtual void internalSetUp()
|
||||
{
|
||||
TestAllocatorType::SetUp();
|
||||
}
|
||||
|
||||
void internalTearDown()
|
||||
{
|
||||
TestAllocatorType::TearDown();
|
||||
}
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct alignas(1) AllocatorOperation
|
||||
{
|
||||
enum OperationType : size_t
|
||||
{
|
||||
ALLOCATE,
|
||||
DEALLOCATE
|
||||
};
|
||||
OperationType m_type : 1;
|
||||
size_t m_size : 28; // Can represent up to 256Mb requests
|
||||
size_t m_alignment : 7; // Can represent up to 128 alignment
|
||||
size_t m_recordId : 28; // Can represent up to 256M simultaneous requests, we reuse ids
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(AllocatorOperation) == 8);
|
||||
|
||||
public:
|
||||
void SetUp(const ::benchmark::State&) override
|
||||
{
|
||||
internalSetUp();
|
||||
}
|
||||
void SetUp(::benchmark::State&) override
|
||||
{
|
||||
internalSetUp();
|
||||
}
|
||||
|
||||
void TearDown(const ::benchmark::State&) override
|
||||
{
|
||||
internalTearDown();
|
||||
}
|
||||
void TearDown(::benchmark::State&) override
|
||||
{
|
||||
internalTearDown();
|
||||
}
|
||||
|
||||
void Benchmark(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state)
|
||||
{
|
||||
state.PauseTiming();
|
||||
|
||||
AZStd::unordered_map<size_t, void*> pointerRemapping;
|
||||
constexpr size_t allocationOperationCount = 5 * 1024;
|
||||
AZStd::array<AllocatorOperation, allocationOperationCount> m_operations = {};
|
||||
[[maybe_unused]] const size_t operationSize = sizeof(AllocatorOperation);
|
||||
|
||||
size_t totalAllocationSize = 0;
|
||||
size_t itemsProcessed = 0;
|
||||
|
||||
for (size_t i = 0; i < 100; ++i) // play the recording multiple times to get a good stable sample, this way we can keep a smaller recording
|
||||
{
|
||||
AZ::IO::SystemFile file;
|
||||
AZ::IO::FixedMaxPathString filePath = AZ::Utils::GetExecutableDirectory();
|
||||
filePath += "/Tests/AzCore/Memory/AllocatorBenchmarkRecordings.bin";
|
||||
if (!file.Open(filePath.c_str(), AZ::IO::SystemFile::OpenMode::SF_OPEN_READ_ONLY))
|
||||
{
|
||||
return;
|
||||
}
|
||||
size_t elementsRead =
|
||||
file.Read(sizeof(AllocatorOperation) * allocationOperationCount, &m_operations) / sizeof(AllocatorOperation);
|
||||
itemsProcessed += elementsRead;
|
||||
|
||||
while (elementsRead > 0)
|
||||
{
|
||||
for (size_t operationIndex = 0; operationIndex < elementsRead; ++operationIndex)
|
||||
{
|
||||
const AllocatorOperation& operation = m_operations[operationIndex];
|
||||
if (operation.m_type == AllocatorOperation::ALLOCATE)
|
||||
{
|
||||
const auto it = pointerRemapping.emplace(operation.m_recordId, nullptr);
|
||||
if (it.second) // otherwise already allocated
|
||||
{
|
||||
state.ResumeTiming();
|
||||
void* ptr = TestAllocatorType::Allocate(operation.m_size, operation.m_alignment);
|
||||
state.PauseTiming();
|
||||
totalAllocationSize += operation.m_size;
|
||||
it.first->second = ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Doing a resize, dont account for this memory change, this operation is rare and we dont have
|
||||
// the size of the previous allocation
|
||||
state.ResumeTiming();
|
||||
TestAllocatorType::Resize(it.first->second, operation.m_size);
|
||||
state.PauseTiming();
|
||||
}
|
||||
}
|
||||
else // AllocatorOperation::DEALLOCATE:
|
||||
{
|
||||
if (operation.m_recordId)
|
||||
{
|
||||
const auto ptrIt = pointerRemapping.find(operation.m_recordId);
|
||||
if (ptrIt != pointerRemapping.end())
|
||||
{
|
||||
totalAllocationSize -= operation.m_size;
|
||||
state.ResumeTiming();
|
||||
TestAllocatorType::DeAllocate(
|
||||
ptrIt->second,
|
||||
/*operation.m_size*/ 0); // size is not correct after a resize, a 0 size deals with it
|
||||
state.PauseTiming();
|
||||
pointerRemapping.erase(ptrIt);
|
||||
}
|
||||
}
|
||||
else // deallocate(nullptr) are recorded
|
||||
{
|
||||
// Just to account of the call of deallocate(nullptr);
|
||||
state.ResumeTiming();
|
||||
TestAllocatorType::DeAllocate(nullptr, /*operation.m_size*/ 0);
|
||||
state.PauseTiming();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elementsRead =
|
||||
file.Read(sizeof(AllocatorOperation) * allocationOperationCount, &m_operations) / sizeof(AllocatorOperation);
|
||||
itemsProcessed += elementsRead;
|
||||
}
|
||||
file.Close();
|
||||
|
||||
// Deallocate the remainder (since we stopped the recording middle-game)(there are leaks as well)
|
||||
for (const auto& pointerMapping : pointerRemapping)
|
||||
{
|
||||
state.ResumeTiming();
|
||||
TestAllocatorType::DeAllocate(pointerMapping.second);
|
||||
state.PauseTiming();
|
||||
}
|
||||
itemsProcessed += pointerRemapping.size();
|
||||
pointerRemapping.clear();
|
||||
}
|
||||
|
||||
state.counters[s_counterAllocatorMemory] = benchmark::Counter(static_cast<double>(TestAllocatorType::NumAllocatedBytes()), benchmark::Counter::kDefaults);
|
||||
state.counters[s_counterBenchmarkMemory] = benchmark::Counter(static_cast<double>(totalAllocationSize), benchmark::Counter::kDefaults);
|
||||
|
||||
state.SetItemsProcessed(itemsProcessed);
|
||||
|
||||
TestAllocatorType::GarbageCollect();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// For non-threaded ranges, run 100, 400, 1600 amounts
|
||||
static void RunRanges(benchmark::internal::Benchmark* b)
|
||||
{
|
||||
for (int i = 0; i < 6; i += 2)
|
||||
{
|
||||
b->Arg((1 << i) * 100);
|
||||
}
|
||||
}
|
||||
static void RecordedRunRanges(benchmark::internal::Benchmark* b)
|
||||
{
|
||||
b->Iterations(1);
|
||||
}
|
||||
|
||||
// For threaded ranges, run just 200, multi-threaded will already multiply by thread
|
||||
static void ThreadedRunRanges(benchmark::internal::Benchmark* b)
|
||||
{
|
||||
b->Arg(100);
|
||||
}
|
||||
|
||||
// Test under and over-subscription of threads vs the amount of CPUs available
|
||||
static const unsigned int MaxThreadRange = 2 * AZStd::thread::hardware_concurrency();
|
||||
|
||||
#define BM_REGISTER_TEMPLATE(FIXTURE, TESTNAME, ...) \
|
||||
BENCHMARK_TEMPLATE_DEFINE_F(FIXTURE, TESTNAME, __VA_ARGS__)(benchmark::State& state) { Benchmark(state); } \
|
||||
BENCHMARK_REGISTER_F(FIXTURE, TESTNAME)
|
||||
|
||||
// We test small/big/mixed allocations in single-threaded environments. For multi-threaded environments, we test mixed since
|
||||
// the multi threaded fixture will run multiple passes (1, 2, 4, ... until 2*hardware_concurrency)
|
||||
#define BM_REGISTER_SIZE_FIXTURES(FIXTURE, TESTNAME, ALLOCATORTYPE) \
|
||||
BM_REGISTER_TEMPLATE(FIXTURE, TESTNAME##_SMALL, ALLOCATORTYPE, SMALL)->Apply(RunRanges); \
|
||||
BM_REGISTER_TEMPLATE(FIXTURE, TESTNAME##_BIG, ALLOCATORTYPE, BIG)->Apply(RunRanges); \
|
||||
BM_REGISTER_TEMPLATE(FIXTURE, TESTNAME##_MIXED, ALLOCATORTYPE, MIXED)->Apply(RunRanges); \
|
||||
BM_REGISTER_TEMPLATE(FIXTURE, TESTNAME##_MIXED_THREADED, ALLOCATORTYPE, MIXED)->ThreadRange(2, MaxThreadRange)->Apply(ThreadedRunRanges);
|
||||
|
||||
#define BM_REGISTER_ALLOCATOR(TESTNAME, ALLOCATORTYPE) \
|
||||
namespace BM_##TESTNAME \
|
||||
{ \
|
||||
BM_REGISTER_SIZE_FIXTURES(AllocationBenchmarkFixture, TESTNAME, ALLOCATORTYPE); \
|
||||
BM_REGISTER_SIZE_FIXTURES(DeAllocationBenchmarkFixture, TESTNAME, ALLOCATORTYPE); \
|
||||
BM_REGISTER_TEMPLATE(RecordedAllocationBenchmarkFixture, TESTNAME, ALLOCATORTYPE)->Apply(RecordedRunRanges); \
|
||||
}
|
||||
|
||||
/// Warm up benchmark used to prepare the OS for allocations. Most OS keep allocations for a process somehow
|
||||
/// reserved. So the first allocations run always get a bigger impact in a process. This warm up allocator runs
|
||||
/// all the benchmarks and is just used for the the next allocators to report more consistent results.
|
||||
BM_REGISTER_ALLOCATOR(WarmUpAllocator, RawMallocAllocator);
|
||||
|
||||
BM_REGISTER_ALLOCATOR(RawMallocAllocator, RawMallocAllocator);
|
||||
BM_REGISTER_ALLOCATOR(MallocSchemaAllocator, MallocSchemaAllocator);
|
||||
BM_REGISTER_ALLOCATOR(HphaSchemaAllocator, HphaSchemaAllocator);
|
||||
BM_REGISTER_ALLOCATOR(SystemAllocator, TestSystemAllocator);
|
||||
|
||||
//BM_REGISTER_ALLOCATOR(BestFitExternalMapAllocator, BestFitExternalMapAllocator); // Requires to pre-allocate blocks and cannot work as a general-purpose allocator
|
||||
//BM_REGISTER_ALLOCATOR(HeapSchemaAllocator, TestHeapSchemaAllocator); // Requires to pre-allocate blocks and cannot work as a general-purpose allocator
|
||||
//BM_REGISTER_SCHEMA(PoolSchema); // Requires special alignment requests while allocating
|
||||
|
||||
#undef BM_REGISTER_ALLOCATOR
|
||||
#undef BM_REGISTER_SIZE_FIXTURES
|
||||
#undef BM_REGISTER_TEMPLATE
|
||||
|
||||
} // Benchmark
|
||||
|
||||
#endif // HAVE_BENCHMARK
|
||||
@@ -10,10 +10,6 @@
|
||||
#include <AzCore/Memory/HphaSchema.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
#if defined(HAVE_BENCHMARK)
|
||||
#include <benchmark/benchmark.h>
|
||||
#endif // HAVE_BENCHMARK
|
||||
|
||||
class HphaSchema_TestAllocator
|
||||
: public AZ::SimpleSchemaAllocator<AZ::HphaSchema>
|
||||
{
|
||||
@@ -112,87 +108,3 @@ namespace UnitTest
|
||||
HphaSchemaTestFixture,
|
||||
::testing::ValuesIn(s_mixedInstancesParameters));
|
||||
}
|
||||
|
||||
|
||||
#if defined(HAVE_BENCHMARK)
|
||||
namespace Benchmark
|
||||
{
|
||||
class HphaSchemaBenchmarkFixture
|
||||
: public ::benchmark::Fixture
|
||||
{
|
||||
void internalSetUp()
|
||||
{
|
||||
AZ::AllocatorInstance<HphaSchema_TestAllocator>::Create();
|
||||
}
|
||||
|
||||
void internalTearDown()
|
||||
{
|
||||
AZ::AllocatorInstance<HphaSchema_TestAllocator>::Destroy();
|
||||
}
|
||||
|
||||
public:
|
||||
void SetUp(const benchmark::State&) override
|
||||
{
|
||||
internalSetUp();
|
||||
}
|
||||
void SetUp(benchmark::State&) override
|
||||
{
|
||||
internalSetUp();
|
||||
}
|
||||
void TearDown(const benchmark::State&) override
|
||||
{
|
||||
internalTearDown();
|
||||
}
|
||||
void TearDown(benchmark::State&) override
|
||||
{
|
||||
internalTearDown();
|
||||
}
|
||||
|
||||
static void BM_Allocations(benchmark::State& state, const AllocationSizeArray& allocationArray)
|
||||
{
|
||||
AZStd::vector<void*> allocations;
|
||||
while (state.KeepRunning())
|
||||
{
|
||||
state.PauseTiming();
|
||||
const size_t allocationIndex = allocations.size();
|
||||
const size_t allocationSize = allocationArray[allocationIndex % allocationArray.size()];
|
||||
|
||||
state.ResumeTiming();
|
||||
void* allocation = AZ::AllocatorInstance<HphaSchema_TestAllocator>::Get().Allocate(allocationSize, 0);
|
||||
|
||||
state.PauseTiming();
|
||||
allocations.emplace_back(allocation);
|
||||
|
||||
state.ResumeTiming();
|
||||
}
|
||||
|
||||
const size_t numberOfAllocations = allocations.size();
|
||||
state.SetItemsProcessed(numberOfAllocations);
|
||||
|
||||
for (size_t allocationIndex = 0; allocationIndex < numberOfAllocations; ++allocationIndex)
|
||||
{
|
||||
AZ::AllocatorInstance<HphaSchema_TestAllocator>::Get().DeAllocate(allocations[allocationIndex], allocationArray[allocationIndex % allocationArray.size()]);
|
||||
}
|
||||
AZ::AllocatorInstance<HphaSchema_TestAllocator>::Get().GarbageCollect();
|
||||
}
|
||||
};
|
||||
|
||||
// Small allocations, these are allocations that are going to end up in buckets in the HphaSchema
|
||||
BENCHMARK_F(HphaSchemaBenchmarkFixture, SmallAllocations)(benchmark::State& state)
|
||||
{
|
||||
BM_Allocations(state, s_smallAllocationSizes);
|
||||
}
|
||||
|
||||
BENCHMARK_F(HphaSchemaBenchmarkFixture, BigAllocations)(benchmark::State& state)
|
||||
{
|
||||
BM_Allocations(state, s_bigAllocationSizes);
|
||||
}
|
||||
|
||||
BENCHMARK_F(HphaSchemaBenchmarkFixture, MixedAllocations)(benchmark::State& state)
|
||||
{
|
||||
BM_Allocations(state, s_mixedAllocationSizes);
|
||||
}
|
||||
|
||||
|
||||
} // Benchmark
|
||||
#endif // HAVE_BENCHMARK
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
|
||||
#include <malloc.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
namespace Benchmark
|
||||
{
|
||||
namespace Platform
|
||||
{
|
||||
size_t GetProcessMemoryUsageBytes()
|
||||
{
|
||||
struct rusage rusage;
|
||||
getrusage(RUSAGE_SELF, &rusage);
|
||||
return rusage.ru_maxrss * 1024L;
|
||||
}
|
||||
|
||||
size_t GetMemorySize(void* memory)
|
||||
{
|
||||
return memory ? malloc_usable_size(memory) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,5 @@
|
||||
|
||||
set(FILES
|
||||
Tests/UtilsTests_Android.cpp
|
||||
Tests/Memory/AllocatorBenchmarks_Android.cpp
|
||||
)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
|
||||
#include <malloc.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
namespace Benchmark
|
||||
{
|
||||
namespace Platform
|
||||
{
|
||||
size_t GetProcessMemoryUsageBytes()
|
||||
{
|
||||
struct rusage rusage;
|
||||
getrusage(RUSAGE_SELF, &rusage);
|
||||
return rusage.ru_maxrss * 1024L;
|
||||
}
|
||||
|
||||
size_t GetMemorySize(void* memory)
|
||||
{
|
||||
return memory ? malloc_usable_size(memory) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,4 +9,5 @@
|
||||
set(FILES
|
||||
Tests/UtilsTests_Linux.cpp
|
||||
../Common/UnixLike/Tests/UtilsTests_UnixLike.cpp
|
||||
Tests/Memory/AllocatorBenchmarks_Linux.cpp
|
||||
)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user