EditorViewportSettings.cpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  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 <EditorViewportSettings.h>
  9. #include <AzToolsFramework/Viewport/ViewportMessages.h>
  10. #include <AzCore/Casting/numeric_cast.h>
  11. #include <AzCore/Math/MathUtils.h>
  12. #include <AzCore/Settings/SettingsRegistry.h>
  13. #include <AzCore/Settings/SettingsRegistryMergeUtils.h>
  14. #include <AzCore/std/string/string_view.h>
  15. #include <AzToolsFramework/Viewport/ViewportSettings.h>
  16. namespace SandboxEditor
  17. {
  18. constexpr AZStd::string_view AssetBrowserMaxItemsShownInSearchSetting = "/Amazon/Preferences/Editor/AssetBrowser/MaxItemsShowInSearch";
  19. constexpr AZStd::string_view GridSnappingSetting = "/Amazon/Preferences/Editor/GridSnapping";
  20. constexpr AZStd::string_view GridSizeSetting = "/Amazon/Preferences/Editor/GridSize";
  21. constexpr AZStd::string_view AngleSnappingSetting = "/Amazon/Preferences/Editor/AngleSnapping";
  22. constexpr AZStd::string_view AngleSizeSetting = "/Amazon/Preferences/Editor/AngleSize";
  23. constexpr AZStd::string_view ShowGridSetting = "/Amazon/Preferences/Editor/ShowGrid";
  24. constexpr AZStd::string_view StickySelectSetting = "/Amazon/Preferences/Editor/StickySelect";
  25. constexpr AZStd::string_view ManipulatorLineBoundWidthSetting = "/Amazon/Preferences/Editor/Manipulator/LineBoundWidth";
  26. constexpr AZStd::string_view ManipulatorCircleBoundWidthSetting = "/Amazon/Preferences/Editor/Manipulator/CircleBoundWidth";
  27. constexpr AZStd::string_view CameraSpeedScaleSetting = "/Amazon/Preferences/Editor/Camera/SpeedScale";
  28. constexpr AZStd::string_view CameraTranslateSpeedSetting = "/Amazon/Preferences/Editor/Camera/TranslateSpeed";
  29. constexpr AZStd::string_view CameraBoostMultiplierSetting = "/Amazon/Preferences/Editor/Camera/BoostMultiplier";
  30. constexpr AZStd::string_view CameraRotateSpeedSetting = "/Amazon/Preferences/Editor/Camera/RotateSpeed";
  31. constexpr AZStd::string_view CameraScrollSpeedSetting = "/Amazon/Preferences/Editor/Camera/DollyScrollSpeed";
  32. constexpr AZStd::string_view CameraDollyMotionSpeedSetting = "/Amazon/Preferences/Editor/Camera/DollyMotionSpeed";
  33. constexpr AZStd::string_view CameraOrbitYawRotationInvertedSetting = "/Amazon/Preferences/Editor/Camera/YawRotationInverted";
  34. constexpr AZStd::string_view CameraPanInvertedXSetting = "/Amazon/Preferences/Editor/Camera/PanInvertedX";
  35. constexpr AZStd::string_view CameraPanInvertedYSetting = "/Amazon/Preferences/Editor/Camera/PanInvertedY";
  36. constexpr AZStd::string_view CameraPanSpeedSetting = "/Amazon/Preferences/Editor/Camera/PanSpeed";
  37. constexpr AZStd::string_view CameraRotateSmoothnessSetting = "/Amazon/Preferences/Editor/Camera/RotateSmoothness";
  38. constexpr AZStd::string_view CameraTranslateSmoothnessSetting = "/Amazon/Preferences/Editor/Camera/TranslateSmoothness";
  39. constexpr AZStd::string_view CameraTranslateSmoothingSetting = "/Amazon/Preferences/Editor/Camera/TranslateSmoothing";
  40. constexpr AZStd::string_view CameraRotateSmoothingSetting = "/Amazon/Preferences/Editor/Camera/RotateSmoothing";
  41. constexpr AZStd::string_view CameraCaptureCursorLookSetting = "/Amazon/Preferences/Editor/Camera/CaptureCursorLook";
  42. constexpr AZStd::string_view CameraDefaultOrbitDistanceSetting = "/Amazon/Preferences/Editor/Camera/DefaultOrbitDistance";
  43. constexpr AZStd::string_view CameraTranslateForwardIdSetting = "/Amazon/Preferences/Editor/Camera/CameraTranslateForwardId";
  44. constexpr AZStd::string_view CameraTranslateBackwardIdSetting = "/Amazon/Preferences/Editor/Camera/CameraTranslateBackwardId";
  45. constexpr AZStd::string_view CameraTranslateLeftIdSetting = "/Amazon/Preferences/Editor/Camera/CameraTranslateLeftId";
  46. constexpr AZStd::string_view CameraTranslateRightIdSetting = "/Amazon/Preferences/Editor/Camera/CameraTranslateRightId";
  47. constexpr AZStd::string_view CameraTranslateUpIdSetting = "/Amazon/Preferences/Editor/Camera/CameraTranslateUpId";
  48. constexpr AZStd::string_view CameraTranslateDownIdSetting = "/Amazon/Preferences/Editor/Camera/CameraTranslateUpDownId";
  49. constexpr AZStd::string_view CameraTranslateBoostIdSetting = "/Amazon/Preferences/Editor/Camera/TranslateBoostId";
  50. constexpr AZStd::string_view CameraOrbitIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitId";
  51. constexpr AZStd::string_view CameraFreeLookIdSetting = "/Amazon/Preferences/Editor/Camera/FreeLookId";
  52. constexpr AZStd::string_view CameraFreePanIdSetting = "/Amazon/Preferences/Editor/Camera/FreePanId";
  53. constexpr AZStd::string_view CameraOrbitLookIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitLookId";
  54. constexpr AZStd::string_view CameraOrbitDollyIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitDollyId";
  55. constexpr AZStd::string_view CameraOrbitPanIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitPanId";
  56. constexpr AZStd::string_view CameraFocusIdSetting = "/Amazon/Preferences/Editor/Camera/FocusId";
  57. constexpr AZStd::string_view CameraDefaultStartingPositionX = "/Amazon/Preferences/Editor/Camera/DefaultStartingPosition/x";
  58. constexpr AZStd::string_view CameraDefaultStartingPositionY = "/Amazon/Preferences/Editor/Camera/DefaultStartingPosition/y";
  59. constexpr AZStd::string_view CameraDefaultStartingPositionZ = "/Amazon/Preferences/Editor/Camera/DefaultStartingPosition/z";
  60. constexpr AZStd::string_view CameraDefaultStartingPitch = "/Amazon/Preferences/Editor/Camera/DefaultStartingPitch";
  61. constexpr AZStd::string_view CameraDefaultStartingYaw = "/Amazon/Preferences/Editor/Camera/DefaultStartingYaw";
  62. constexpr AZStd::string_view CameraNearPlaneDistanceSetting = "/Amazon/Preferences/Editor/Camera/NearPlaneDistance";
  63. constexpr AZStd::string_view CameraFarPlaneDistanceSetting = "/Amazon/Preferences/Editor/Camera/FarPlaneDistance";
  64. constexpr AZStd::string_view CameraFovDegreesSetting = "/Amazon/Preferences/Editor/Camera/FovDegrees";
  65. constexpr AZStd::string_view CameraGoToPositionInstantlySetting = "/Amazon/Preferences/Editor/Camera/GoToPositionInstantly";
  66. constexpr AZStd::string_view CameraGoToPositionDurationSetting = "/Amazon/Preferences/Editor/Camera/GoToPositionDuration";
  67. struct EditorViewportSettingsCallbacksImpl : public EditorViewportSettingsCallbacks
  68. {
  69. EditorViewportSettingsCallbacksImpl()
  70. {
  71. if (auto* registry = AZ::SettingsRegistry::Get())
  72. {
  73. using AZ::SettingsRegistryMergeUtils::IsPathAncestorDescendantOrEqual;
  74. m_angleSnappingNotifyEventHandler = registry->RegisterNotifier(
  75. [this](const AZ::SettingsRegistryInterface::NotifyEventArgs& notifyEventArgs)
  76. {
  77. if (IsPathAncestorDescendantOrEqual(AngleSnappingSetting, notifyEventArgs.m_jsonKeyPath))
  78. {
  79. m_angleSnappingChanged.Signal(AngleSnappingEnabled());
  80. }
  81. }
  82. );
  83. m_cameraSpeedScaleNotifyEventHandler = registry->RegisterNotifier(
  84. [this](const AZ::SettingsRegistryInterface::NotifyEventArgs& notifyEventArgs)
  85. {
  86. if (IsPathAncestorDescendantOrEqual(CameraSpeedScaleSetting, notifyEventArgs.m_jsonKeyPath))
  87. {
  88. m_cameraSpeedScaleChanged.Signal(CameraSpeedScale());
  89. }
  90. }
  91. );
  92. m_gridSnappingNotifyEventHandler = registry->RegisterNotifier(
  93. [this](const AZ::SettingsRegistryInterface::NotifyEventArgs& notifyEventArgs)
  94. {
  95. if (IsPathAncestorDescendantOrEqual(GridSnappingSetting, notifyEventArgs.m_jsonKeyPath))
  96. {
  97. m_gridSnappingChanged.Signal(GridSnappingEnabled());
  98. }
  99. }
  100. );
  101. m_farPlaneDistanceNotifyEventHandler = registry->RegisterNotifier(
  102. [this](const AZ::SettingsRegistryInterface::NotifyEventArgs& notifyEventArgs)
  103. {
  104. if (IsPathAncestorDescendantOrEqual(CameraFarPlaneDistanceSetting, notifyEventArgs.m_jsonKeyPath))
  105. {
  106. m_farPlaneChanged.Signal(CameraDefaultFarPlaneDistance());
  107. }
  108. }
  109. );
  110. m_nearPlaneDistanceNotifyEventHandler = registry->RegisterNotifier(
  111. [this](const AZ::SettingsRegistryInterface::NotifyEventArgs& notifyEventArgs)
  112. {
  113. if (IsPathAncestorDescendantOrEqual(CameraNearPlaneDistanceSetting, notifyEventArgs.m_jsonKeyPath))
  114. {
  115. m_nearPlaneChanged.Signal(CameraDefaultNearPlaneDistance());
  116. }
  117. }
  118. );
  119. m_perspectiveNotifyEventHandler = registry->RegisterNotifier(
  120. [this](const AZ::SettingsRegistryInterface::NotifyEventArgs& notifyEventArgs)
  121. {
  122. if (IsPathAncestorDescendantOrEqual(CameraFovDegreesSetting, notifyEventArgs.m_jsonKeyPath))
  123. {
  124. m_perspectiveChanged.Signal(CameraDefaultFovRadians());
  125. }
  126. }
  127. );
  128. }
  129. }
  130. void SetAngleSnappingChangedEvent(AngleSnappingChangedEvent::Handler& handler) override
  131. {
  132. handler.Connect(m_angleSnappingChanged);
  133. }
  134. void SetCameraSpeedScaleChangedEvent(CameraSpeedScaleChangedEvent::Handler& handler) override
  135. {
  136. handler.Connect(m_cameraSpeedScaleChanged);
  137. }
  138. void SetGridShowingChangedEvent(GridShowingChangedEvent::Handler& handler) override
  139. {
  140. handler.Connect(m_gridShowingChanged);
  141. }
  142. void SetGridSnappingChangedEvent(GridSnappingChangedEvent::Handler& handler) override
  143. {
  144. handler.Connect(m_gridSnappingChanged);
  145. }
  146. void SetFarPlaneDistanceChangedEvent(NearFarPlaneChangedEvent::Handler& handler) override
  147. {
  148. handler.Connect(m_farPlaneChanged);
  149. }
  150. void SetNearPlaneDistanceChangedEvent(NearFarPlaneChangedEvent::Handler& handler) override
  151. {
  152. handler.Connect(m_nearPlaneChanged);
  153. }
  154. void SetPerspectiveChangedEvent(PerspectiveChangedEvent::Handler& handler) override
  155. {
  156. handler.Connect(m_perspectiveChanged);
  157. }
  158. AngleSnappingChangedEvent m_angleSnappingChanged;
  159. CameraSpeedScaleChangedEvent m_cameraSpeedScaleChanged;
  160. GridSnappingChangedEvent m_gridShowingChanged;
  161. GridSnappingChangedEvent m_gridSnappingChanged;
  162. PerspectiveChangedEvent m_perspectiveChanged;
  163. NearFarPlaneChangedEvent m_farPlaneChanged;
  164. NearFarPlaneChangedEvent m_nearPlaneChanged;
  165. AZ::SettingsRegistryInterface::NotifyEventHandler m_angleSnappingNotifyEventHandler;
  166. AZ::SettingsRegistryInterface::NotifyEventHandler m_cameraSpeedScaleNotifyEventHandler;
  167. AZ::SettingsRegistryInterface::NotifyEventHandler m_farPlaneDistanceNotifyEventHandler;
  168. AZ::SettingsRegistryInterface::NotifyEventHandler m_gridShowingNotifyEventHandler;
  169. AZ::SettingsRegistryInterface::NotifyEventHandler m_gridSnappingNotifyEventHandler;
  170. AZ::SettingsRegistryInterface::NotifyEventHandler m_nearPlaneDistanceNotifyEventHandler;
  171. AZ::SettingsRegistryInterface::NotifyEventHandler m_perspectiveNotifyEventHandler;
  172. };
  173. AZStd::unique_ptr<EditorViewportSettingsCallbacks> CreateEditorViewportSettingsCallbacks()
  174. {
  175. return AZStd::make_unique<EditorViewportSettingsCallbacksImpl>();
  176. }
  177. AZ::Vector3 CameraDefaultEditorPosition()
  178. {
  179. return AZ::Vector3(
  180. aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraDefaultStartingPositionX, 0.0)),
  181. aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraDefaultStartingPositionY, -10.0)),
  182. aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraDefaultStartingPositionZ, 4.0)));
  183. }
  184. void SetCameraDefaultEditorPosition(const AZ::Vector3& position)
  185. {
  186. AzToolsFramework::SetRegistry(CameraDefaultStartingPositionX, position.GetX());
  187. AzToolsFramework::SetRegistry(CameraDefaultStartingPositionY, position.GetY());
  188. AzToolsFramework::SetRegistry(CameraDefaultStartingPositionZ, position.GetZ());
  189. }
  190. AZ::Vector2 CameraDefaultEditorOrientation()
  191. {
  192. return AZ::Vector2(
  193. aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraDefaultStartingPitch, 0.0)),
  194. aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraDefaultStartingYaw, 0.0)));
  195. }
  196. void SetCameraDefaultEditorOrientation(const AZ::Vector2& pitchYaw)
  197. {
  198. AzToolsFramework::SetRegistry(CameraDefaultStartingPitch, pitchYaw.GetX());
  199. AzToolsFramework::SetRegistry(CameraDefaultStartingYaw, pitchYaw.GetY());
  200. }
  201. AZ::u64 MaxItemsShownInAssetBrowserSearch()
  202. {
  203. return AzToolsFramework::GetRegistry(AssetBrowserMaxItemsShownInSearchSetting, aznumeric_cast<AZ::u64>(50));
  204. }
  205. void SetMaxItemsShownInAssetBrowserSearch(const AZ::u64 numberOfItemsShown)
  206. {
  207. AzToolsFramework::SetRegistry(AssetBrowserMaxItemsShownInSearchSetting, numberOfItemsShown);
  208. }
  209. bool GridSnappingEnabled()
  210. {
  211. return AzToolsFramework::GetRegistry(GridSnappingSetting, false);
  212. }
  213. void SetGridSnapping(const bool enabled)
  214. {
  215. AzToolsFramework::SetRegistry(GridSnappingSetting, enabled);
  216. }
  217. float GridSnappingSize()
  218. {
  219. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(GridSizeSetting, 0.1));
  220. }
  221. void SetGridSnappingSize(const float size)
  222. {
  223. AzToolsFramework::SetRegistry(GridSizeSetting, size);
  224. }
  225. bool AngleSnappingEnabled()
  226. {
  227. return AzToolsFramework::GetRegistry(AngleSnappingSetting, false);
  228. }
  229. void SetAngleSnapping(const bool enabled)
  230. {
  231. AzToolsFramework::SetRegistry(AngleSnappingSetting, enabled);
  232. }
  233. float AngleSnappingSize()
  234. {
  235. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(AngleSizeSetting, 5.0));
  236. }
  237. void SetAngleSnappingSize(const float size)
  238. {
  239. AzToolsFramework::SetRegistry(AngleSizeSetting, size);
  240. }
  241. bool ShowingGrid()
  242. {
  243. return AzToolsFramework::GetRegistry(ShowGridSetting, false);
  244. }
  245. void SetShowingGrid(const bool showing)
  246. {
  247. AzToolsFramework::SetRegistry(ShowGridSetting, showing);
  248. }
  249. bool StickySelectEnabled()
  250. {
  251. return AzToolsFramework::GetRegistry(StickySelectSetting, false);
  252. }
  253. void SetStickySelectEnabled(const bool enabled)
  254. {
  255. AzToolsFramework::SetRegistry(StickySelectSetting, enabled);
  256. }
  257. float ManipulatorLineBoundWidth()
  258. {
  259. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(ManipulatorLineBoundWidthSetting, 0.1));
  260. }
  261. void SetManipulatorLineBoundWidth(const float lineBoundWidth)
  262. {
  263. AzToolsFramework::SetRegistry(ManipulatorLineBoundWidthSetting, lineBoundWidth);
  264. }
  265. float ManipulatorCircleBoundWidth()
  266. {
  267. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(ManipulatorCircleBoundWidthSetting, 0.1));
  268. }
  269. void SetManipulatorCircleBoundWidth(const float circleBoundWidth)
  270. {
  271. AzToolsFramework::SetRegistry(ManipulatorCircleBoundWidthSetting, circleBoundWidth);
  272. }
  273. float CameraSpeedScale()
  274. {
  275. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraSpeedScaleSetting, 1.0));
  276. }
  277. void SetCameraSpeedScale(float speedScale)
  278. {
  279. AzToolsFramework::SetRegistry(CameraSpeedScaleSetting, speedScale);
  280. }
  281. float CameraTranslateSpeed()
  282. {
  283. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraTranslateSpeedSetting, 10.0));
  284. }
  285. float CameraTranslateSpeedScaled()
  286. {
  287. return CameraTranslateSpeed() * CameraSpeedScale();
  288. }
  289. void SetCameraTranslateSpeed(const float speed)
  290. {
  291. AzToolsFramework::SetRegistry(CameraTranslateSpeedSetting, speed);
  292. }
  293. float CameraBoostMultiplier()
  294. {
  295. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraBoostMultiplierSetting, 3.0));
  296. }
  297. void SetCameraBoostMultiplier(const float multiplier)
  298. {
  299. AzToolsFramework::SetRegistry(CameraBoostMultiplierSetting, multiplier);
  300. }
  301. float CameraRotateSpeed()
  302. {
  303. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraRotateSpeedSetting, 0.005));
  304. }
  305. void SetCameraRotateSpeed(const float speed)
  306. {
  307. AzToolsFramework::SetRegistry(CameraRotateSpeedSetting, speed);
  308. }
  309. float CameraScrollSpeed()
  310. {
  311. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraScrollSpeedSetting, 0.02));
  312. }
  313. float CameraScrollSpeedScaled()
  314. {
  315. return CameraScrollSpeed() * CameraSpeedScale();
  316. }
  317. void SetCameraScrollSpeed(const float speed)
  318. {
  319. AzToolsFramework::SetRegistry(CameraScrollSpeedSetting, speed);
  320. }
  321. float CameraDollyMotionSpeed()
  322. {
  323. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraDollyMotionSpeedSetting, 0.01));
  324. }
  325. float CameraDollyMotionSpeedScaled()
  326. {
  327. return CameraDollyMotionSpeed() * CameraSpeedScale();
  328. }
  329. void SetCameraDollyMotionSpeed(const float speed)
  330. {
  331. AzToolsFramework::SetRegistry(CameraDollyMotionSpeedSetting, speed);
  332. }
  333. bool CameraOrbitYawRotationInverted()
  334. {
  335. return AzToolsFramework::GetRegistry(CameraOrbitYawRotationInvertedSetting, false);
  336. }
  337. void SetCameraOrbitYawRotationInverted(const bool inverted)
  338. {
  339. AzToolsFramework::SetRegistry(CameraOrbitYawRotationInvertedSetting, inverted);
  340. }
  341. bool CameraPanInvertedX()
  342. {
  343. return AzToolsFramework::GetRegistry(CameraPanInvertedXSetting, true);
  344. }
  345. void SetCameraPanInvertedX(const bool inverted)
  346. {
  347. AzToolsFramework::SetRegistry(CameraPanInvertedXSetting, inverted);
  348. }
  349. bool CameraPanInvertedY()
  350. {
  351. return AzToolsFramework::GetRegistry(CameraPanInvertedYSetting, true);
  352. }
  353. void SetCameraPanInvertedY(const bool inverted)
  354. {
  355. AzToolsFramework::SetRegistry(CameraPanInvertedYSetting, inverted);
  356. }
  357. float CameraPanSpeed()
  358. {
  359. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraPanSpeedSetting, 0.01));
  360. }
  361. float CameraPanSpeedScaled()
  362. {
  363. return CameraPanSpeed() * CameraSpeedScale();
  364. }
  365. void SetCameraPanSpeed(float speed)
  366. {
  367. AzToolsFramework::SetRegistry(CameraPanSpeedSetting, speed);
  368. }
  369. float CameraRotateSmoothness()
  370. {
  371. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraRotateSmoothnessSetting, 5.0));
  372. }
  373. void SetCameraRotateSmoothness(const float smoothness)
  374. {
  375. AzToolsFramework::SetRegistry(CameraRotateSmoothnessSetting, smoothness);
  376. }
  377. float CameraTranslateSmoothness()
  378. {
  379. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraTranslateSmoothnessSetting, 5.0));
  380. }
  381. void SetCameraTranslateSmoothness(const float smoothness)
  382. {
  383. AzToolsFramework::SetRegistry(CameraTranslateSmoothnessSetting, smoothness);
  384. }
  385. bool CameraRotateSmoothingEnabled()
  386. {
  387. return AzToolsFramework::GetRegistry(CameraRotateSmoothingSetting, true);
  388. }
  389. void SetCameraRotateSmoothingEnabled(const bool enabled)
  390. {
  391. AzToolsFramework::SetRegistry(CameraRotateSmoothingSetting, enabled);
  392. }
  393. bool CameraTranslateSmoothingEnabled()
  394. {
  395. return AzToolsFramework::GetRegistry(CameraTranslateSmoothingSetting, true);
  396. }
  397. void SetCameraTranslateSmoothingEnabled(const bool enabled)
  398. {
  399. AzToolsFramework::SetRegistry(CameraTranslateSmoothingSetting, enabled);
  400. }
  401. bool CameraCaptureCursorForLook()
  402. {
  403. return AzToolsFramework::GetRegistry(CameraCaptureCursorLookSetting, true);
  404. }
  405. void SetCameraCaptureCursorForLook(const bool capture)
  406. {
  407. AzToolsFramework::SetRegistry(CameraCaptureCursorLookSetting, capture);
  408. }
  409. float CameraDefaultOrbitDistance()
  410. {
  411. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraDefaultOrbitDistanceSetting, 20.0));
  412. }
  413. void SetCameraDefaultOrbitDistance(const float distance)
  414. {
  415. AzToolsFramework::SetRegistry(CameraDefaultOrbitDistanceSetting, distance);
  416. }
  417. bool CameraGoToPositionInstantlyEnabled()
  418. {
  419. return AzToolsFramework::GetRegistry(CameraGoToPositionInstantlySetting, false);
  420. }
  421. void SetCameraGoToPositionInstantlyEnabled(const bool instant)
  422. {
  423. AzToolsFramework::SetRegistry(CameraGoToPositionInstantlySetting, instant);
  424. }
  425. float CameraGoToPositionDuration()
  426. {
  427. return aznumeric_cast<float>(AzToolsFramework::GetRegistry(CameraGoToPositionDurationSetting, 1.0));
  428. }
  429. void SetCameraGoToPositionDuration(const float duration)
  430. {
  431. AzToolsFramework::SetRegistry(CameraGoToPositionDurationSetting, duration);
  432. }
  433. AzFramework::InputChannelId CameraTranslateForwardChannelId()
  434. {
  435. return AzFramework::InputChannelId(
  436. AzToolsFramework::GetRegistry(CameraTranslateForwardIdSetting, AZStd::string("keyboard_key_alphanumeric_W")).c_str());
  437. }
  438. void SetCameraTranslateForwardChannelId(AZStd::string_view cameraTranslateForwardId)
  439. {
  440. AzToolsFramework::SetRegistry(CameraTranslateForwardIdSetting, cameraTranslateForwardId);
  441. }
  442. AzFramework::InputChannelId CameraTranslateBackwardChannelId()
  443. {
  444. return AzFramework::InputChannelId(
  445. AzToolsFramework::GetRegistry(CameraTranslateBackwardIdSetting, AZStd::string("keyboard_key_alphanumeric_S")).c_str());
  446. }
  447. void SetCameraTranslateBackwardChannelId(AZStd::string_view cameraTranslateBackwardId)
  448. {
  449. AzToolsFramework::SetRegistry(CameraTranslateBackwardIdSetting, cameraTranslateBackwardId);
  450. }
  451. AzFramework::InputChannelId CameraTranslateLeftChannelId()
  452. {
  453. return AzFramework::InputChannelId(
  454. AzToolsFramework::GetRegistry(CameraTranslateLeftIdSetting, AZStd::string("keyboard_key_alphanumeric_A")).c_str());
  455. }
  456. void SetCameraTranslateLeftChannelId(AZStd::string_view cameraTranslateLeftId)
  457. {
  458. AzToolsFramework::SetRegistry(CameraTranslateLeftIdSetting, cameraTranslateLeftId);
  459. }
  460. AzFramework::InputChannelId CameraTranslateRightChannelId()
  461. {
  462. return AzFramework::InputChannelId(
  463. AzToolsFramework::GetRegistry(CameraTranslateRightIdSetting, AZStd::string("keyboard_key_alphanumeric_D")).c_str());
  464. }
  465. void SetCameraTranslateRightChannelId(AZStd::string_view cameraTranslateRightId)
  466. {
  467. AzToolsFramework::SetRegistry(CameraTranslateRightIdSetting, cameraTranslateRightId);
  468. }
  469. AzFramework::InputChannelId CameraTranslateUpChannelId()
  470. {
  471. return AzFramework::InputChannelId(
  472. AzToolsFramework::GetRegistry(CameraTranslateUpIdSetting, AZStd::string("keyboard_key_alphanumeric_E")).c_str());
  473. }
  474. void SetCameraTranslateUpChannelId(AZStd::string_view cameraTranslateUpId)
  475. {
  476. AzToolsFramework::SetRegistry(CameraTranslateUpIdSetting, cameraTranslateUpId);
  477. }
  478. AzFramework::InputChannelId CameraTranslateDownChannelId()
  479. {
  480. return AzFramework::InputChannelId(
  481. AzToolsFramework::GetRegistry(CameraTranslateDownIdSetting, AZStd::string("keyboard_key_alphanumeric_Q")).c_str());
  482. }
  483. void SetCameraTranslateDownChannelId(AZStd::string_view cameraTranslateDownId)
  484. {
  485. AzToolsFramework::SetRegistry(CameraTranslateDownIdSetting, cameraTranslateDownId);
  486. }
  487. AzFramework::InputChannelId CameraTranslateBoostChannelId()
  488. {
  489. return AzFramework::InputChannelId(
  490. AzToolsFramework::GetRegistry(CameraTranslateBoostIdSetting, AZStd::string("keyboard_key_modifier_shift_l")).c_str());
  491. }
  492. void SetCameraTranslateBoostChannelId(AZStd::string_view cameraTranslateBoostId)
  493. {
  494. AzToolsFramework::SetRegistry(CameraTranslateBoostIdSetting, cameraTranslateBoostId);
  495. }
  496. AzFramework::InputChannelId CameraOrbitChannelId()
  497. {
  498. return AzFramework::InputChannelId(
  499. AzToolsFramework::GetRegistry(CameraOrbitIdSetting, AZStd::string("keyboard_key_modifier_alt_l")).c_str());
  500. }
  501. void SetCameraOrbitChannelId(AZStd::string_view cameraOrbitId)
  502. {
  503. AzToolsFramework::SetRegistry(CameraOrbitIdSetting, cameraOrbitId);
  504. }
  505. AzFramework::InputChannelId CameraFreeLookChannelId()
  506. {
  507. return AzFramework::InputChannelId(
  508. AzToolsFramework::GetRegistry(CameraFreeLookIdSetting, AZStd::string("mouse_button_right")).c_str());
  509. }
  510. void SetCameraFreeLookChannelId(AZStd::string_view cameraFreeLookId)
  511. {
  512. AzToolsFramework::SetRegistry(CameraFreeLookIdSetting, cameraFreeLookId);
  513. }
  514. AzFramework::InputChannelId CameraFreePanChannelId()
  515. {
  516. return AzFramework::InputChannelId(
  517. AzToolsFramework::GetRegistry(CameraFreePanIdSetting, AZStd::string("mouse_button_middle")).c_str());
  518. }
  519. void SetCameraFreePanChannelId(AZStd::string_view cameraFreePanId)
  520. {
  521. AzToolsFramework::SetRegistry(CameraFreePanIdSetting, cameraFreePanId);
  522. }
  523. AzFramework::InputChannelId CameraOrbitLookChannelId()
  524. {
  525. return AzFramework::InputChannelId(
  526. AzToolsFramework::GetRegistry(CameraOrbitLookIdSetting, AZStd::string("mouse_button_left")).c_str());
  527. }
  528. void SetCameraOrbitLookChannelId(AZStd::string_view cameraOrbitLookId)
  529. {
  530. AzToolsFramework::SetRegistry(CameraOrbitLookIdSetting, cameraOrbitLookId);
  531. }
  532. AzFramework::InputChannelId CameraOrbitDollyChannelId()
  533. {
  534. return AzFramework::InputChannelId(
  535. AzToolsFramework::GetRegistry(CameraOrbitDollyIdSetting, AZStd::string("mouse_button_right")).c_str());
  536. }
  537. void SetCameraOrbitDollyChannelId(AZStd::string_view cameraOrbitDollyId)
  538. {
  539. AzToolsFramework::SetRegistry(CameraOrbitDollyIdSetting, cameraOrbitDollyId);
  540. }
  541. AzFramework::InputChannelId CameraOrbitPanChannelId()
  542. {
  543. return AzFramework::InputChannelId(
  544. AzToolsFramework::GetRegistry(CameraOrbitPanIdSetting, AZStd::string("mouse_button_middle")).c_str());
  545. }
  546. void SetCameraOrbitPanChannelId(AZStd::string_view cameraOrbitPanId)
  547. {
  548. AzToolsFramework::SetRegistry(CameraOrbitPanIdSetting, cameraOrbitPanId);
  549. }
  550. AzFramework::InputChannelId CameraFocusChannelId()
  551. {
  552. return AzFramework::InputChannelId(
  553. AzToolsFramework::GetRegistry(CameraFocusIdSetting, AZStd::string("keyboard_key_alphanumeric_X")).c_str());
  554. }
  555. void SetCameraFocusChannelId(AZStd::string_view cameraFocusId)
  556. {
  557. AzToolsFramework::SetRegistry(CameraFocusIdSetting, cameraFocusId);
  558. }
  559. float CameraDefaultNearPlaneDistance()
  560. {
  561. return aznumeric_caster(AzToolsFramework::GetRegistry(CameraNearPlaneDistanceSetting, 0.1));
  562. }
  563. void SetCameraDefaultNearPlaneDistance(const float distance)
  564. {
  565. AzToolsFramework::SetRegistry(CameraNearPlaneDistanceSetting, aznumeric_cast<double>(distance));
  566. }
  567. float CameraDefaultFarPlaneDistance()
  568. {
  569. return aznumeric_caster(AzToolsFramework::GetRegistry(CameraFarPlaneDistanceSetting, 100.0));
  570. }
  571. void SetCameraDefaultFarPlaneDistance(const float distance)
  572. {
  573. AzToolsFramework::SetRegistry(CameraFarPlaneDistanceSetting, aznumeric_cast<double>(distance));
  574. }
  575. float CameraDefaultFovRadians()
  576. {
  577. return AZ::DegToRad(CameraDefaultFovDegrees());
  578. }
  579. void SetCameraDefaultFovRadians(const float fovRadians)
  580. {
  581. SetCameraDefaultFovDegrees(AZ::RadToDeg(fovRadians));
  582. }
  583. float CameraDefaultFovDegrees()
  584. {
  585. return aznumeric_caster(AzToolsFramework::GetRegistry(CameraFovDegreesSetting, aznumeric_cast<double>(60.0)));
  586. }
  587. void SetCameraDefaultFovDegrees(const float fovDegrees)
  588. {
  589. AzToolsFramework::SetRegistry(CameraFovDegreesSetting, aznumeric_cast<double>(fovDegrees));
  590. }
  591. void ResetCameraSpeedScale()
  592. {
  593. AzToolsFramework::ClearRegistry(CameraSpeedScaleSetting);
  594. }
  595. void ResetCameraTranslateSpeed()
  596. {
  597. AzToolsFramework::ClearRegistry(CameraTranslateSpeedSetting);
  598. }
  599. void ResetCameraRotateSpeed()
  600. {
  601. AzToolsFramework::ClearRegistry(CameraRotateSpeedSetting);
  602. }
  603. void ResetCameraBoostMultiplier()
  604. {
  605. AzToolsFramework::ClearRegistry(CameraBoostMultiplierSetting);
  606. }
  607. void ResetCameraScrollSpeed()
  608. {
  609. AzToolsFramework::ClearRegistry(CameraScrollSpeedSetting);
  610. }
  611. void ResetCameraDollyMotionSpeed()
  612. {
  613. AzToolsFramework::ClearRegistry(CameraDollyMotionSpeedSetting);
  614. }
  615. void ResetCameraPanSpeed()
  616. {
  617. AzToolsFramework::ClearRegistry(CameraPanSpeedSetting);
  618. }
  619. void ResetCameraRotateSmoothness()
  620. {
  621. AzToolsFramework::ClearRegistry(CameraRotateSmoothnessSetting);
  622. }
  623. void ResetCameraRotateSmoothingEnabled()
  624. {
  625. AzToolsFramework::ClearRegistry(CameraRotateSmoothingSetting);
  626. }
  627. void ResetCameraTranslateSmoothness()
  628. {
  629. AzToolsFramework::ClearRegistry(CameraTranslateSmoothnessSetting);
  630. }
  631. void ResetCameraTranslateSmoothingEnabled()
  632. {
  633. AzToolsFramework::ClearRegistry(CameraTranslateSmoothingSetting);
  634. }
  635. void ResetCameraCaptureCursorForLook()
  636. {
  637. AzToolsFramework::ClearRegistry(CameraCaptureCursorLookSetting);
  638. }
  639. void ResetCameraOrbitYawRotationInverted()
  640. {
  641. AzToolsFramework::ClearRegistry(CameraOrbitYawRotationInvertedSetting);
  642. }
  643. void ResetCameraPanInvertedX()
  644. {
  645. AzToolsFramework::ClearRegistry(CameraPanInvertedXSetting);
  646. }
  647. void ResetCameraPanInvertedY()
  648. {
  649. AzToolsFramework::ClearRegistry(CameraPanInvertedYSetting);
  650. }
  651. void ResetCameraDefaultEditorPosition()
  652. {
  653. AzToolsFramework::ClearRegistry(CameraDefaultStartingPositionX);
  654. AzToolsFramework::ClearRegistry(CameraDefaultStartingPositionY);
  655. AzToolsFramework::ClearRegistry(CameraDefaultStartingPositionZ);
  656. }
  657. void ResetCameraDefaultOrbitDistance()
  658. {
  659. AzToolsFramework::ClearRegistry(CameraDefaultOrbitDistanceSetting);
  660. }
  661. void ResetCameraDefaultEditorOrientation()
  662. {
  663. AzToolsFramework::ClearRegistry(CameraDefaultStartingPitch);
  664. AzToolsFramework::ClearRegistry(CameraDefaultStartingYaw);
  665. }
  666. void ResetCameraGoToPositionInstantlyEnabled()
  667. {
  668. AzToolsFramework::ClearRegistry(CameraGoToPositionInstantlySetting);
  669. }
  670. void ResetCameraGoToPositionDuration()
  671. {
  672. AzToolsFramework::ClearRegistry(CameraGoToPositionDurationSetting);
  673. }
  674. void ResetCameraTranslateForwardChannelId()
  675. {
  676. AzToolsFramework::ClearRegistry(CameraTranslateForwardIdSetting);
  677. }
  678. void ResetCameraTranslateBackwardChannelId()
  679. {
  680. AzToolsFramework::ClearRegistry(CameraTranslateBackwardIdSetting);
  681. }
  682. void ResetCameraTranslateLeftChannelId()
  683. {
  684. AzToolsFramework::ClearRegistry(CameraTranslateLeftIdSetting);
  685. }
  686. void ResetCameraTranslateRightChannelId()
  687. {
  688. AzToolsFramework::ClearRegistry(CameraTranslateRightIdSetting);
  689. }
  690. void ResetCameraTranslateUpChannelId()
  691. {
  692. AzToolsFramework::ClearRegistry(CameraTranslateUpIdSetting);
  693. }
  694. void ResetCameraTranslateDownChannelId()
  695. {
  696. AzToolsFramework::ClearRegistry(CameraTranslateDownIdSetting);
  697. }
  698. void ResetCameraTranslateBoostChannelId()
  699. {
  700. AzToolsFramework::ClearRegistry(CameraTranslateBoostIdSetting);
  701. }
  702. void ResetCameraOrbitChannelId()
  703. {
  704. AzToolsFramework::ClearRegistry(CameraOrbitIdSetting);
  705. }
  706. void ResetCameraFreeLookChannelId()
  707. {
  708. AzToolsFramework::ClearRegistry(CameraFreeLookIdSetting);
  709. }
  710. void ResetCameraFreePanChannelId()
  711. {
  712. AzToolsFramework::ClearRegistry(CameraFreePanIdSetting);
  713. }
  714. void ResetCameraOrbitLookChannelId()
  715. {
  716. AzToolsFramework::ClearRegistry(CameraOrbitLookIdSetting);
  717. }
  718. void ResetCameraOrbitDollyChannelId()
  719. {
  720. AzToolsFramework::ClearRegistry(CameraOrbitDollyIdSetting);
  721. }
  722. void ResetCameraOrbitPanChannelId()
  723. {
  724. AzToolsFramework::ClearRegistry(CameraOrbitPanIdSetting);
  725. }
  726. void ResetCameraFocusChannelId()
  727. {
  728. AzToolsFramework::ClearRegistry(CameraFocusIdSetting);
  729. }
  730. } // namespace SandboxEditor