EditorPreferencesPageViewportCamera.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "EditorDefs.h"
  9. #include "EditorPreferencesPageViewportCamera.h"
  10. #include <AzCore/std/sort.h>
  11. #include <AzFramework/Input/Buses/Requests/InputDeviceRequestBus.h>
  12. #include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
  13. #include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
  14. #include <AzQtComponents/Components/StyleManager.h>
  15. #include <EditorModularViewportCameraComposerBus.h>
  16. // Editor
  17. #include "EditorViewportSettings.h"
  18. #include "Settings.h"
  19. static AZStd::vector<AZStd::string> GetInputNamesByDevice(const AzFramework::InputDeviceId inputDeviceId)
  20. {
  21. AzFramework::InputDeviceRequests::InputChannelIdSet availableInputChannelIds;
  22. AzFramework::InputDeviceRequestBus::Event(
  23. inputDeviceId, &AzFramework::InputDeviceRequests::GetInputChannelIds, availableInputChannelIds);
  24. AZStd::vector<AZStd::string> inputChannelNames;
  25. for (const AzFramework::InputChannelId& inputChannelId : availableInputChannelIds)
  26. {
  27. inputChannelNames.push_back(inputChannelId.GetName());
  28. }
  29. AZStd::sort(inputChannelNames.begin(), inputChannelNames.end());
  30. return inputChannelNames;
  31. }
  32. static AZStd::vector<AZStd::string> GetEditorInputNames()
  33. {
  34. // function static to defer having to call GetInputNamesByDevice for every CameraInputSettings member
  35. static bool inputNamesGenerated = false;
  36. static AZStd::vector<AZStd::string> inputNames;
  37. if (!inputNamesGenerated)
  38. {
  39. AZStd::vector<AZStd::string> keyboardInputNames = GetInputNamesByDevice(AzFramework::InputDeviceKeyboard::Id);
  40. AZStd::vector<AZStd::string> mouseInputNames = GetInputNamesByDevice(AzFramework::InputDeviceMouse::Id);
  41. inputNames.insert(inputNames.end(), mouseInputNames.begin(), mouseInputNames.end());
  42. inputNames.insert(inputNames.end(), keyboardInputNames.begin(), keyboardInputNames.end());
  43. inputNamesGenerated = true;
  44. }
  45. return inputNames;
  46. }
  47. void CEditorPreferencesPage_ViewportCamera::CameraMovementSettings::Reflect(AZ::SerializeContext& serialize)
  48. {
  49. serialize.Class<CameraMovementSettings>()
  50. ->Version(6)
  51. ->Field("TranslateSpeed", &CameraMovementSettings::m_translateSpeed)
  52. ->Field("RotateSpeed", &CameraMovementSettings::m_rotateSpeed)
  53. ->Field("BoostMultiplier", &CameraMovementSettings::m_boostMultiplier)
  54. ->Field("ScrollSpeed", &CameraMovementSettings::m_scrollSpeed)
  55. ->Field("DollySpeed", &CameraMovementSettings::m_dollySpeed)
  56. ->Field("PanSpeed", &CameraMovementSettings::m_panSpeed)
  57. ->Field("RotateSmoothing", &CameraMovementSettings::m_rotateSmoothing)
  58. ->Field("RotateSmoothness", &CameraMovementSettings::m_rotateSmoothness)
  59. ->Field("TranslateSmoothing", &CameraMovementSettings::m_translateSmoothing)
  60. ->Field("TranslateSmoothness", &CameraMovementSettings::m_translateSmoothness)
  61. ->Field("CaptureCursorLook", &CameraMovementSettings::m_captureCursorLook)
  62. ->Field("OrbitYawRotationInverted", &CameraMovementSettings::m_orbitYawRotationInverted)
  63. ->Field("PanInvertedX", &CameraMovementSettings::m_panInvertedX)
  64. ->Field("PanInvertedY", &CameraMovementSettings::m_panInvertedY)
  65. ->Field("DefaultPosition", &CameraMovementSettings::m_defaultPosition)
  66. ->Field("DefaultOrientation", &CameraMovementSettings::m_defaultPitchYaw)
  67. ->Field("DefaultOrbitDistance", &CameraMovementSettings::m_defaultOrbitDistance)
  68. ->Field("SpeedScale", &CameraMovementSettings::m_speedScale)
  69. ->Field("GoToPositionInstantly", &CameraMovementSettings::m_goToPositionInstantly)
  70. ->Field("GoToPositionDuration", &CameraMovementSettings::m_goToPositionDuration)
  71. ->Field("Reset", &CameraMovementSettings::m_resetButton);
  72. if (AZ::EditContext* editContext = serialize.GetEditContext())
  73. {
  74. const float minValue = 0.0001f;
  75. editContext->Class<CameraMovementSettings>("Camera Movement Settings", "")
  76. ->DataElement(
  77. AZ::Edit::UIHandlers::SpinBox,
  78. &CameraMovementSettings::m_speedScale,
  79. "Camera Speed Scale",
  80. "Overall scale applied to all camera movements")
  81. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  82. ->DataElement(
  83. AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_translateSpeed, "Camera Movement Speed", "Camera movement speed")
  84. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  85. ->DataElement(
  86. AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_rotateSpeed, "Camera Rotation Speed", "Camera rotation speed")
  87. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  88. ->DataElement(
  89. AZ::Edit::UIHandlers::SpinBox,
  90. &CameraMovementSettings::m_boostMultiplier,
  91. "Camera Boost Multiplier",
  92. "Camera boost multiplier to apply to movement speed")
  93. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  94. ->DataElement(
  95. AZ::Edit::UIHandlers::SpinBox,
  96. &CameraMovementSettings::m_scrollSpeed,
  97. "Camera Scroll Speed",
  98. "Camera movement speed while using scroll/wheel input")
  99. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  100. ->DataElement(
  101. AZ::Edit::UIHandlers::SpinBox,
  102. &CameraMovementSettings::m_dollySpeed,
  103. "Camera Dolly Speed",
  104. "Camera movement speed while using mouse motion to move in and out")
  105. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  106. ->DataElement(
  107. AZ::Edit::UIHandlers::SpinBox,
  108. &CameraMovementSettings::m_panSpeed,
  109. "Camera Pan Speed",
  110. "Camera movement speed while panning using the mouse")
  111. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  112. ->DataElement(
  113. AZ::Edit::UIHandlers::CheckBox,
  114. &CameraMovementSettings::m_rotateSmoothing,
  115. "Camera Rotate Smoothing",
  116. "Is camera rotation smoothing enabled or disabled")
  117. ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
  118. ->DataElement(
  119. AZ::Edit::UIHandlers::SpinBox,
  120. &CameraMovementSettings::m_rotateSmoothness,
  121. "Camera Rotate Smoothness",
  122. "Amount of camera smoothing to apply while rotating the camera")
  123. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  124. ->Attribute(AZ::Edit::Attributes::ReadOnly, &CameraMovementSettings::RotateSmoothingReadOnly)
  125. ->DataElement(
  126. AZ::Edit::UIHandlers::CheckBox,
  127. &CameraMovementSettings::m_translateSmoothing,
  128. "Camera Translate Smoothing",
  129. "Is camera translation smoothing enabled or disabled")
  130. ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::AttributesAndValues)
  131. ->DataElement(
  132. AZ::Edit::UIHandlers::SpinBox,
  133. &CameraMovementSettings::m_translateSmoothness,
  134. "Camera Translate Smoothness",
  135. "Amount of camera smoothing to apply while translating the camera")
  136. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  137. ->Attribute(AZ::Edit::Attributes::ReadOnly, &CameraMovementSettings::TranslateSmoothingReadOnly)
  138. ->DataElement(
  139. AZ::Edit::UIHandlers::CheckBox,
  140. &CameraMovementSettings::m_orbitYawRotationInverted,
  141. "Camera Orbit Yaw Inverted",
  142. "Inverted yaw rotation while orbiting")
  143. ->DataElement(
  144. AZ::Edit::UIHandlers::CheckBox,
  145. &CameraMovementSettings::m_panInvertedX,
  146. "Invert Pan X",
  147. "Invert direction of pan in local X axis")
  148. ->DataElement(
  149. AZ::Edit::UIHandlers::CheckBox,
  150. &CameraMovementSettings::m_panInvertedY,
  151. "Invert Pan Y",
  152. "Invert direction of pan in local Y axis")
  153. ->DataElement(
  154. AZ::Edit::UIHandlers::CheckBox,
  155. &CameraMovementSettings::m_captureCursorLook,
  156. "Camera Capture Look Cursor",
  157. "Should the cursor be captured (hidden) while performing free look")
  158. ->DataElement(
  159. AZ::Edit::UIHandlers::Vector3,
  160. &CameraMovementSettings::m_defaultPosition,
  161. "Default Camera Position",
  162. "Default Camera Position when a level is first opened")
  163. ->DataElement(
  164. AZ::Edit::UIHandlers::Vector2,
  165. &CameraMovementSettings::m_defaultPitchYaw,
  166. "Default Camera Orientation",
  167. "Default Camera Orientation when a level is first opened (X - Pitch value (degrees), Y - Yaw value (degrees)")
  168. ->DataElement(
  169. AZ::Edit::UIHandlers::SpinBox,
  170. &CameraMovementSettings::m_defaultOrbitDistance,
  171. "Default Orbit Distance",
  172. "The default distance to orbit about when there is no entity selected")
  173. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  174. ->DataElement(
  175. AZ::Edit::UIHandlers::SpinBox,
  176. &CameraMovementSettings::m_goToPositionDuration,
  177. "Camera Go To Position Duration",
  178. "Time it takes for the camera to interpolate to a given position")
  179. ->Attribute(AZ::Edit::Attributes::ReadOnly, &CameraMovementSettings::GoToPositionDurationReadOnly)
  180. ->Attribute(AZ::Edit::Attributes::Min, minValue)
  181. ->DataElement(
  182. AZ::Edit::UIHandlers::CheckBox,
  183. &CameraMovementSettings::m_goToPositionInstantly,
  184. "Camera Go To Position Instantly",
  185. "Camera will instantly go to the set position and won't interpolate there")
  186. ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::AttributesAndValues)
  187. ->DataElement(
  188. AZ::Edit::UIHandlers::Button, &CameraMovementSettings::m_resetButton, "", "Restore camera movement settings to defaults")
  189. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &CameraMovementSettings::Reset)
  190. ->Attribute(AZ::Edit::Attributes::ButtonText, "Restore defaults")
  191. ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::AttributesAndValues);
  192. }
  193. }
  194. void CEditorPreferencesPage_ViewportCamera::CameraInputSettings::Reflect(AZ::SerializeContext& serialize)
  195. {
  196. serialize.Class<CameraInputSettings>()
  197. ->Version(2)
  198. ->Field("TranslateForward", &CameraInputSettings::m_translateForwardChannelId)
  199. ->Field("TranslateBackward", &CameraInputSettings::m_translateBackwardChannelId)
  200. ->Field("TranslateLeft", &CameraInputSettings::m_translateLeftChannelId)
  201. ->Field("TranslateRight", &CameraInputSettings::m_translateRightChannelId)
  202. ->Field("TranslateUp", &CameraInputSettings::m_translateUpChannelId)
  203. ->Field("TranslateDown", &CameraInputSettings::m_translateDownChannelId)
  204. ->Field("Boost", &CameraInputSettings::m_boostChannelId)
  205. ->Field("Orbit", &CameraInputSettings::m_orbitChannelId)
  206. ->Field("FreeLook", &CameraInputSettings::m_freeLookChannelId)
  207. ->Field("FreePan", &CameraInputSettings::m_freePanChannelId)
  208. ->Field("OrbitLook", &CameraInputSettings::m_orbitLookChannelId)
  209. ->Field("OrbitDolly", &CameraInputSettings::m_orbitDollyChannelId)
  210. ->Field("OrbitPan", &CameraInputSettings::m_orbitPanChannelId)
  211. ->Field("Focus", &CameraInputSettings::m_focusChannelId)
  212. ->Field("Reset", &CameraInputSettings::m_resetButton);
  213. if (AZ::EditContext* editContext = serialize.GetEditContext())
  214. {
  215. editContext->Class<CameraInputSettings>("Camera Input Settings", "")
  216. ->DataElement(
  217. AZ::Edit::UIHandlers::ComboBox,
  218. &CameraInputSettings::m_translateForwardChannelId,
  219. "Translate Forward",
  220. "Key/button to move the camera forward")
  221. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  222. ->DataElement(
  223. AZ::Edit::UIHandlers::ComboBox,
  224. &CameraInputSettings::m_translateBackwardChannelId,
  225. "Translate Backward",
  226. "Key/button to move the camera backward")
  227. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  228. ->DataElement(
  229. AZ::Edit::UIHandlers::ComboBox,
  230. &CameraInputSettings::m_translateLeftChannelId,
  231. "Translate Left",
  232. "Key/button to move the camera left")
  233. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  234. ->DataElement(
  235. AZ::Edit::UIHandlers::ComboBox,
  236. &CameraInputSettings::m_translateRightChannelId,
  237. "Translate Right",
  238. "Key/button to move the camera right")
  239. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  240. ->DataElement(
  241. AZ::Edit::UIHandlers::ComboBox,
  242. &CameraInputSettings::m_translateUpChannelId,
  243. "Translate Up",
  244. "Key/button to move the camera up")
  245. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  246. ->DataElement(
  247. AZ::Edit::UIHandlers::ComboBox,
  248. &CameraInputSettings::m_translateDownChannelId,
  249. "Translate Down",
  250. "Key/button to move the camera down")
  251. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  252. ->DataElement(
  253. AZ::Edit::UIHandlers::ComboBox,
  254. &CameraInputSettings::m_boostChannelId,
  255. "Boost",
  256. "Key/button to move the camera more quickly")
  257. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  258. ->DataElement(
  259. AZ::Edit::UIHandlers::ComboBox,
  260. &CameraInputSettings::m_orbitChannelId,
  261. "Orbit",
  262. "Key/button to begin the camera orbit behavior")
  263. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  264. ->DataElement(
  265. AZ::Edit::UIHandlers::ComboBox,
  266. &CameraInputSettings::m_freeLookChannelId,
  267. "Free Look",
  268. "Key/button to begin camera free look")
  269. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  270. ->DataElement(
  271. AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_freePanChannelId, "Free Pan", "Key/button to begin camera free pan")
  272. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  273. ->DataElement(
  274. AZ::Edit::UIHandlers::ComboBox,
  275. &CameraInputSettings::m_orbitLookChannelId,
  276. "Orbit Look",
  277. "Key/button to begin camera orbit look")
  278. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  279. ->DataElement(
  280. AZ::Edit::UIHandlers::ComboBox,
  281. &CameraInputSettings::m_orbitDollyChannelId,
  282. "Orbit Dolly",
  283. "Key/button to begin camera orbit dolly")
  284. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  285. ->DataElement(
  286. AZ::Edit::UIHandlers::ComboBox,
  287. &CameraInputSettings::m_orbitPanChannelId,
  288. "Orbit Pan",
  289. "Key/button to begin camera orbit pan")
  290. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  291. ->DataElement(
  292. AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_focusChannelId, "Focus", "Key/button to focus camera orbit")
  293. ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames)
  294. ->DataElement(
  295. AZ::Edit::UIHandlers::Button, &CameraInputSettings::m_resetButton, "", "Restore camera input settings to defaults")
  296. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &CameraInputSettings::Reset)
  297. ->Attribute(AZ::Edit::Attributes::ButtonText, "Restore defaults")
  298. ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::AttributesAndValues);
  299. }
  300. }
  301. void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serialize)
  302. {
  303. CameraMovementSettings::Reflect(serialize);
  304. CameraInputSettings::Reflect(serialize);
  305. serialize.Class<CEditorPreferencesPage_ViewportCamera>()
  306. ->Version(1)
  307. ->Field("CameraMovementSettings", &CEditorPreferencesPage_ViewportCamera::m_cameraMovementSettings)
  308. ->Field("CameraInputSettings", &CEditorPreferencesPage_ViewportCamera::m_cameraInputSettings);
  309. if (AZ::EditContext* editContext = serialize.GetEditContext())
  310. {
  311. editContext->Class<CEditorPreferencesPage_ViewportCamera>("Viewport Preferences", "Viewport Preferences")
  312. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  313. ->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC_CE("PropertyVisibility_ShowChildrenOnly"))
  314. ->DataElement(
  315. AZ::Edit::UIHandlers::Default,
  316. &CEditorPreferencesPage_ViewportCamera::m_cameraMovementSettings,
  317. "Camera Movement Settings",
  318. "Camera Movement Settings")
  319. ->DataElement(
  320. AZ::Edit::UIHandlers::Default,
  321. &CEditorPreferencesPage_ViewportCamera::m_cameraInputSettings,
  322. "Camera Input Settings",
  323. "Camera Input Settings");
  324. }
  325. }
  326. CEditorPreferencesPage_ViewportCamera::CEditorPreferencesPage_ViewportCamera()
  327. {
  328. InitializeSettings();
  329. m_icon = QIcon(":/res/Camera.svg");
  330. }
  331. const char* CEditorPreferencesPage_ViewportCamera::GetCategory()
  332. {
  333. return "Viewports";
  334. }
  335. const char* CEditorPreferencesPage_ViewportCamera::GetTitle()
  336. {
  337. return "Camera";
  338. }
  339. QIcon& CEditorPreferencesPage_ViewportCamera::GetIcon()
  340. {
  341. return m_icon;
  342. }
  343. void CEditorPreferencesPage_ViewportCamera::OnCancel()
  344. {
  345. // noop
  346. }
  347. bool CEditorPreferencesPage_ViewportCamera::OnQueryCancel()
  348. {
  349. return true;
  350. }
  351. void CEditorPreferencesPage_ViewportCamera::OnApply()
  352. {
  353. SandboxEditor::SetCameraSpeedScale(m_cameraMovementSettings.m_speedScale);
  354. SandboxEditor::SetCameraTranslateSpeed(m_cameraMovementSettings.m_translateSpeed);
  355. SandboxEditor::SetCameraRotateSpeed(m_cameraMovementSettings.m_rotateSpeed);
  356. SandboxEditor::SetCameraBoostMultiplier(m_cameraMovementSettings.m_boostMultiplier);
  357. SandboxEditor::SetCameraScrollSpeed(m_cameraMovementSettings.m_scrollSpeed);
  358. SandboxEditor::SetCameraDollyMotionSpeed(m_cameraMovementSettings.m_dollySpeed);
  359. SandboxEditor::SetCameraPanSpeed(m_cameraMovementSettings.m_panSpeed);
  360. SandboxEditor::SetCameraRotateSmoothness(m_cameraMovementSettings.m_rotateSmoothness);
  361. SandboxEditor::SetCameraRotateSmoothingEnabled(m_cameraMovementSettings.m_rotateSmoothing);
  362. SandboxEditor::SetCameraTranslateSmoothness(m_cameraMovementSettings.m_translateSmoothness);
  363. SandboxEditor::SetCameraTranslateSmoothingEnabled(m_cameraMovementSettings.m_translateSmoothing);
  364. SandboxEditor::SetCameraCaptureCursorForLook(m_cameraMovementSettings.m_captureCursorLook);
  365. SandboxEditor::SetCameraOrbitYawRotationInverted(m_cameraMovementSettings.m_orbitYawRotationInverted);
  366. SandboxEditor::SetCameraPanInvertedX(m_cameraMovementSettings.m_panInvertedX);
  367. SandboxEditor::SetCameraPanInvertedY(m_cameraMovementSettings.m_panInvertedY);
  368. SandboxEditor::SetCameraDefaultEditorPosition(m_cameraMovementSettings.m_defaultPosition);
  369. SandboxEditor::SetCameraDefaultOrbitDistance(m_cameraMovementSettings.m_defaultOrbitDistance);
  370. SandboxEditor::SetCameraDefaultEditorOrientation(m_cameraMovementSettings.m_defaultPitchYaw);
  371. SandboxEditor::SetCameraGoToPositionInstantlyEnabled(m_cameraMovementSettings.m_goToPositionInstantly);
  372. SandboxEditor::SetCameraGoToPositionDuration(m_cameraMovementSettings.m_goToPositionDuration);
  373. SandboxEditor::SetCameraTranslateForwardChannelId(m_cameraInputSettings.m_translateForwardChannelId);
  374. SandboxEditor::SetCameraTranslateBackwardChannelId(m_cameraInputSettings.m_translateBackwardChannelId);
  375. SandboxEditor::SetCameraTranslateLeftChannelId(m_cameraInputSettings.m_translateLeftChannelId);
  376. SandboxEditor::SetCameraTranslateRightChannelId(m_cameraInputSettings.m_translateRightChannelId);
  377. SandboxEditor::SetCameraTranslateUpChannelId(m_cameraInputSettings.m_translateUpChannelId);
  378. SandboxEditor::SetCameraTranslateDownChannelId(m_cameraInputSettings.m_translateDownChannelId);
  379. SandboxEditor::SetCameraTranslateBoostChannelId(m_cameraInputSettings.m_boostChannelId);
  380. SandboxEditor::SetCameraOrbitChannelId(m_cameraInputSettings.m_orbitChannelId);
  381. SandboxEditor::SetCameraFreeLookChannelId(m_cameraInputSettings.m_freeLookChannelId);
  382. SandboxEditor::SetCameraFreePanChannelId(m_cameraInputSettings.m_freePanChannelId);
  383. SandboxEditor::SetCameraOrbitLookChannelId(m_cameraInputSettings.m_orbitLookChannelId);
  384. SandboxEditor::SetCameraOrbitDollyChannelId(m_cameraInputSettings.m_orbitDollyChannelId);
  385. SandboxEditor::SetCameraOrbitPanChannelId(m_cameraInputSettings.m_orbitPanChannelId);
  386. SandboxEditor::SetCameraFocusChannelId(m_cameraInputSettings.m_focusChannelId);
  387. SandboxEditor::EditorModularViewportCameraComposerNotificationBus::Broadcast(
  388. &SandboxEditor::EditorModularViewportCameraComposerNotificationBus::Events::OnEditorModularViewportCameraComposerSettingsChanged);
  389. }
  390. void CEditorPreferencesPage_ViewportCamera::InitializeSettings()
  391. {
  392. m_cameraMovementSettings.Initialize();
  393. m_cameraInputSettings.Initialize();
  394. }
  395. void CEditorPreferencesPage_ViewportCamera::CameraMovementSettings::Reset()
  396. {
  397. SandboxEditor::ResetCameraSpeedScale();
  398. SandboxEditor::ResetCameraTranslateSpeed();
  399. SandboxEditor::ResetCameraRotateSpeed();
  400. SandboxEditor::ResetCameraBoostMultiplier();
  401. SandboxEditor::ResetCameraScrollSpeed();
  402. SandboxEditor::ResetCameraDollyMotionSpeed();
  403. SandboxEditor::ResetCameraPanSpeed();
  404. SandboxEditor::ResetCameraRotateSmoothness();
  405. SandboxEditor::ResetCameraRotateSmoothingEnabled();
  406. SandboxEditor::ResetCameraTranslateSmoothness();
  407. SandboxEditor::ResetCameraTranslateSmoothingEnabled();
  408. SandboxEditor::ResetCameraCaptureCursorForLook();
  409. SandboxEditor::ResetCameraOrbitYawRotationInverted();
  410. SandboxEditor::ResetCameraPanInvertedX();
  411. SandboxEditor::ResetCameraPanInvertedY();
  412. SandboxEditor::ResetCameraDefaultEditorPosition();
  413. SandboxEditor::ResetCameraDefaultOrbitDistance();
  414. SandboxEditor::ResetCameraDefaultEditorOrientation();
  415. SandboxEditor::ResetCameraGoToPositionInstantlyEnabled();
  416. SandboxEditor::ResetCameraGoToPositionDuration();
  417. Initialize();
  418. }
  419. void CEditorPreferencesPage_ViewportCamera::CameraMovementSettings::Initialize()
  420. {
  421. m_speedScale = SandboxEditor::CameraSpeedScale();
  422. m_translateSpeed = SandboxEditor::CameraTranslateSpeed();
  423. m_rotateSpeed = SandboxEditor::CameraRotateSpeed();
  424. m_boostMultiplier = SandboxEditor::CameraBoostMultiplier();
  425. m_scrollSpeed = SandboxEditor::CameraScrollSpeed();
  426. m_dollySpeed = SandboxEditor::CameraDollyMotionSpeed();
  427. m_panSpeed = SandboxEditor::CameraPanSpeed();
  428. m_rotateSmoothness = SandboxEditor::CameraRotateSmoothness();
  429. m_rotateSmoothing = SandboxEditor::CameraRotateSmoothingEnabled();
  430. m_translateSmoothness = SandboxEditor::CameraTranslateSmoothness();
  431. m_translateSmoothing = SandboxEditor::CameraTranslateSmoothingEnabled();
  432. m_captureCursorLook = SandboxEditor::CameraCaptureCursorForLook();
  433. m_orbitYawRotationInverted = SandboxEditor::CameraOrbitYawRotationInverted();
  434. m_panInvertedX = SandboxEditor::CameraPanInvertedX();
  435. m_panInvertedY = SandboxEditor::CameraPanInvertedY();
  436. m_defaultPosition = SandboxEditor::CameraDefaultEditorPosition();
  437. m_defaultOrbitDistance = SandboxEditor::CameraDefaultOrbitDistance();
  438. m_defaultPitchYaw = SandboxEditor::CameraDefaultEditorOrientation();
  439. m_goToPositionInstantly = SandboxEditor::CameraGoToPositionInstantlyEnabled();
  440. m_goToPositionDuration = SandboxEditor::CameraGoToPositionDuration();
  441. }
  442. void CEditorPreferencesPage_ViewportCamera::CameraInputSettings::Reset()
  443. {
  444. SandboxEditor::ResetCameraTranslateForwardChannelId();
  445. SandboxEditor::ResetCameraTranslateBackwardChannelId();
  446. SandboxEditor::ResetCameraTranslateLeftChannelId();
  447. SandboxEditor::ResetCameraTranslateRightChannelId();
  448. SandboxEditor::ResetCameraTranslateUpChannelId();
  449. SandboxEditor::ResetCameraTranslateDownChannelId();
  450. SandboxEditor::ResetCameraTranslateBoostChannelId();
  451. SandboxEditor::ResetCameraOrbitChannelId();
  452. SandboxEditor::ResetCameraFreeLookChannelId();
  453. SandboxEditor::ResetCameraFreePanChannelId();
  454. SandboxEditor::ResetCameraOrbitLookChannelId();
  455. SandboxEditor::ResetCameraOrbitDollyChannelId();
  456. SandboxEditor::ResetCameraOrbitPanChannelId();
  457. SandboxEditor::ResetCameraFocusChannelId();
  458. Initialize();
  459. }
  460. void CEditorPreferencesPage_ViewportCamera::CameraInputSettings::Initialize()
  461. {
  462. m_translateForwardChannelId = SandboxEditor::CameraTranslateForwardChannelId().GetName();
  463. m_translateBackwardChannelId = SandboxEditor::CameraTranslateBackwardChannelId().GetName();
  464. m_translateLeftChannelId = SandboxEditor::CameraTranslateLeftChannelId().GetName();
  465. m_translateRightChannelId = SandboxEditor::CameraTranslateRightChannelId().GetName();
  466. m_translateUpChannelId = SandboxEditor::CameraTranslateUpChannelId().GetName();
  467. m_translateDownChannelId = SandboxEditor::CameraTranslateDownChannelId().GetName();
  468. m_boostChannelId = SandboxEditor::CameraTranslateBoostChannelId().GetName();
  469. m_orbitChannelId = SandboxEditor::CameraOrbitChannelId().GetName();
  470. m_freeLookChannelId = SandboxEditor::CameraFreeLookChannelId().GetName();
  471. m_freePanChannelId = SandboxEditor::CameraFreePanChannelId().GetName();
  472. m_orbitLookChannelId = SandboxEditor::CameraOrbitLookChannelId().GetName();
  473. m_orbitDollyChannelId = SandboxEditor::CameraOrbitDollyChannelId().GetName();
  474. m_orbitPanChannelId = SandboxEditor::CameraOrbitPanChannelId().GetName();
  475. m_focusChannelId = SandboxEditor::CameraFocusChannelId().GetName();
  476. }