2
0

EditorPreferencesPageViewportCamera.cpp 27 KB

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