EditorViewportSettings.cpp 32 KB

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