BsGizmoManager.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "Utility/BsModule.h"
  6. #include "Image/BsColor.h"
  7. #include "Math/BsVector2I.h"
  8. #include "Math/BsMatrix4.h"
  9. #include "RenderAPI/BsGpuParam.h"
  10. #include "Utility/BsDrawHelper.h"
  11. #include "Renderer/BsParamBlocks.h"
  12. #include "Renderer/BsRendererExtension.h"
  13. namespace bs
  14. {
  15. /** @addtogroup Scene-Editor
  16. * @{
  17. */
  18. namespace ct { class GizmoRenderer; }
  19. /** Type of mesh that can be drawn by the gizmo renderer. */
  20. enum class GizmoMeshType
  21. {
  22. Solid, Line, Wire, Text, Count
  23. };
  24. /** Settings that control gizmo drawing. */
  25. struct BS_SCRIPT_EXPORT(api:bed,pl:true) GizmoDrawSettings
  26. {
  27. /** Scale to apply to gizmo icons, controlling their size. */
  28. float iconScale = 1.0f;
  29. /** Maximum range at which gizmo icons will be rendered, in world units. */
  30. float iconRange = 500.0f;
  31. /**
  32. * Icons smaller than this size will be faded out. The value represents the size of the icon relative to viewport
  33. * size (e.g. 1 means the icons fully covers the viewport). In range [0, 1], should be smaller than maximum size
  34. * value.
  35. */
  36. float iconSizeMin = 0.05f;
  37. /**
  38. * Icons larger than this size will be faded out. The value represents the size of the icon relative to viewport
  39. * size (e.g. 1 means the icons fully covers the viewport). In range [0, 1], should be larger than minimum size
  40. * value.
  41. */
  42. float iconSizeMax = 0.15f;
  43. /**
  44. * Icons larger than this size will not be shown. The value represents the size of the icon relative to viewport
  45. * size (e.g. 1 means the icons fully covers the viewport). In range [0, 1], should be larger than maximum size
  46. * value.
  47. */
  48. float iconSizeCull = 0.25f;
  49. };
  50. /**
  51. * Handles the rendering and picking of gizmo elements. Gizmos are icons and 3D objects usually rendered in scene view
  52. * for various visualization purposes (for example a Camera component will have a gizmo that draws a Camera icon since
  53. * otherwise it has no visual representation). Aside from being rendered, gizmos can also be selected by the user as if
  54. * they were normal scene elements.
  55. */
  56. class BS_ED_EXPORT GizmoManager : public Module<GizmoManager>
  57. {
  58. public:
  59. GizmoManager();
  60. ~GizmoManager();
  61. /**
  62. * Starts gizmo creation. All further call will be referencing this gizmo. Must be followed by a matching
  63. * endGizmo().
  64. *
  65. * @param gizmoParent Scene object this gizmo is attached to. Selecting the gizmo will select this scene object.
  66. */
  67. void startGizmo(const HSceneObject& gizmoParent);
  68. /** Ends gizmo creation. Must be called after a matching startGizmo(). */
  69. void endGizmo();
  70. /** Changes the color of any further gizmo draw calls. */
  71. void setColor(const Color& color);
  72. /** Changes the transform that will be applied to meshes of any further gizmo draw calls. */
  73. void setTransform(const Matrix4& transform);
  74. /**
  75. * If pickable is set to true, gizmo can be selected by the user, otherwise it will be drawn but cannot be
  76. * interacted with.
  77. *
  78. * @note Must be called between startGizmo/endGizmo calls.
  79. */
  80. void setPickable(bool pickable) { mPickable = pickable; }
  81. /** Returns the currently set gizmo color. */
  82. Color getColor() const { return mColor; }
  83. /** Returns the currently set gizmo transform. */
  84. Matrix4 getTransform() const { return mTransform; }
  85. /**
  86. * Draws an axis aligned cuboid.
  87. *
  88. * @param[in] position Center of the cuboid.
  89. * @param[in] extents Radius of the cuboid in each axis.
  90. *
  91. * @note Must be called between startGizmo/endGizmo calls.
  92. */
  93. void drawCube(const Vector3& position, const Vector3& extents);
  94. /**
  95. * Draws a sphere.
  96. *
  97. * @note Must be called between startGizmo/endGizmo calls.
  98. */
  99. void drawSphere(const Vector3& position, float radius);
  100. /**
  101. * Draws a solid cone.
  102. *
  103. * @param[in] base Position of the center of the base of the cone.
  104. * @param[in] normal Orientation of the cone, pointing from center base to the tip of the cone.
  105. * @param[in] height Height of the cone (along the normal).
  106. * @param[in] radius Radius of the base of the cone.
  107. * @param[in] scale Scale applied to cone's disc width & height. Allows you to create elliptical cones.
  108. */
  109. void drawCone(const Vector3& base, const Vector3& normal, float height, float radius,
  110. const Vector2& scale = Vector2::ONE);
  111. /**
  112. * Draws a solid disc.
  113. *
  114. * @param[in] position Center of the disc.
  115. * @param[in] normal Orientation of the disc, pointing in the direction the disc is visible in.
  116. * @param[in] radius Radius of the disc.
  117. */
  118. void drawDisc(const Vector3& position, const Vector3& normal, float radius);
  119. /**
  120. * Draws a wireframe axis aligned cuboid.
  121. *
  122. * @param[in] position Center of the cuboid.
  123. * @param[in] extents Radius of the cuboid in each axis.
  124. *
  125. * @note Must be called between startGizmo/endGizmo calls.
  126. */
  127. void drawWireCube(const Vector3& position, const Vector3& extents);
  128. /**
  129. * Draws a wireframe sphere represented by three discs.
  130. *
  131. * @note Must be called between startGizmo/endGizmo calls.
  132. */
  133. void drawWireSphere(const Vector3& position, float radius);
  134. /**
  135. * Draws a wireframe hemisphere represented by three arcs.
  136. *
  137. * @note Must be called between startGizmo/endGizmo calls.
  138. */
  139. void drawWireHemisphere(const Vector3& position, float radius);
  140. /**
  141. * Draws a wireframe capsule.
  142. *
  143. * @param[in] position World coordinates of the center of the capsule.
  144. * @param[in] height Distance between the centers of the capsule's hemispheres.
  145. * @param[in] radius Distance of each point from the capsule's center-line.
  146. */
  147. void drawWireCapsule(const Vector3& position, float height, float radius);
  148. /**
  149. * Draws a wireframe cone.
  150. *
  151. * @param[in] base Position of the center of the base of the cone.
  152. * @param[in] normal Orientation of the cone, pointing from center base to the tip of the cone.
  153. * @param[in] height Height of the cone (along the normal).
  154. * @param[in] radius Radius of the base of the cone.
  155. * @param[in] scale Scale applied to cone's disc width & height. Allows you to create elliptical cones.
  156. */
  157. void drawWireCone(const Vector3& base, const Vector3& normal, float height, float radius,
  158. const Vector2& scale = Vector2::ONE);
  159. /**
  160. * Draws a line between two points.
  161. *
  162. * @note Must be called between startGizmo/endGizmo calls.
  163. */
  164. void drawLine(const Vector3& start, const Vector3& end);
  165. /**
  166. * Draws a list of lines. Provided array must contain pairs of the line start point followed by an end point.
  167. *
  168. * @note Must be called between startGizmo/endGizmo calls.
  169. */
  170. void drawLineList(const Vector<Vector3>& linePoints);
  171. /**
  172. * Draws a wireframe disc.
  173. *
  174. * @param[in] position Center of the disc.
  175. * @param[in] normal Orientation of the disc, pointing in the direction the disc is visible in.
  176. * @param[in] radius Radius of the disc.
  177. */
  178. void drawWireDisc(const Vector3& position, const Vector3& normal, float radius);
  179. /**
  180. * Draws a wireframe arc.
  181. *
  182. * @param[in] position Center of the arc.
  183. * @param[in] normal Orientation of the arc, pointing in the direction the arc is visible in.
  184. * @param[in] radius Radius of the arc.
  185. * @param[in] startAngle Angle at which to start the arc.
  186. * @param[in] amountAngle Length of the arc.
  187. */
  188. void drawWireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle);
  189. /**
  190. * Draws a wireframe mesh.
  191. *
  192. * @param[in] meshData Object containing mesh vertices and indices. Vertices must be Vertex3 and indices
  193. * 32-bit.
  194. */
  195. void drawWireMesh(const SPtr<MeshData>& meshData);
  196. /**
  197. * Draws a wireframe frustum.
  198. *
  199. * @param[in] position Origin of the frustum, or the eye point.
  200. * @param[in] aspect Ratio of frustum width over frustum height.
  201. * @param[in] FOV Horizontal field of view in degrees.
  202. * @param[in] near Distance to the near frustum plane.
  203. * @param[in] far Distance to the far frustum plane.
  204. *
  205. * @note Must be called between startGizmo/endGizmo calls.
  206. */
  207. void drawFrustum(const Vector3& position, float aspect, Degree FOV, float near, float far);
  208. /**
  209. * Draws an icon that always faces the camera.
  210. *
  211. * @param[in] position Position of the center of the icon.
  212. * @param[in] image Sprite image for the icon to draw.
  213. * @param[in] fixedScale If true then the icon will remain the same size regardless of the distance from camera.
  214. *
  215. * @note Must be called between startGizmo/endGizmo calls.
  216. */
  217. void drawIcon(Vector3 position, HSpriteTexture image, bool fixedScale);
  218. /**
  219. * Draws a mesh representing 2D text with the specified properties.
  220. *
  221. * @param[in] position Position to render the text at. Text will be centered around this point.
  222. * @param[in] text Text to draw.
  223. * @param[in] font Font to use for rendering the text's characters.
  224. * @param[in] fontSize Size of the characters, in points.
  225. */
  226. void drawText(const Vector3& position, const String& text, const HFont& font, UINT32 fontSize = 16);
  227. /**
  228. * Clears all gizmo data, but doesn't update the meshes or the render data. (Calling update would create empty
  229. * meshes, but before calling update gizmos will still be drawn).
  230. */
  231. void clearGizmos();
  232. /**
  233. * Clears gizmo render data like meshes, but doesn't clear the original gizmo data (Calling update would just
  234. * recreate the render data).
  235. */
  236. void clearRenderData();
  237. /**
  238. * Returns a scene object that was attached to a specific gizmo.
  239. *
  240. * @param[in] gizmoIdx Index of the gizmo to look for.
  241. */
  242. HSceneObject getSceneObject(UINT32 gizmoIdx);
  243. /** @name Internal
  244. * @{
  245. */
  246. /**
  247. * Updates all the gizmo meshes to reflect all draw calls submitted since clearGizmos().
  248. *
  249. * @note Internal method.
  250. */
  251. void update(const SPtr<Camera>& camera, const GizmoDrawSettings& drawSettings);
  252. /**
  253. * Queues all gizmos to be rendered for picking. Each gizmo is draw with a separate color so we can identify them
  254. * later.
  255. *
  256. * @param[in] camera Camera to draw the gizmos on.
  257. * @param[in] drawSettings Settings used to control icon drawing.
  258. * @param[in] idxToColorCallback Callback that assigns a unique color to each gizmo index.
  259. *
  260. * @note Internal method.
  261. */
  262. void renderForPicking(const SPtr<Camera>& camera, const GizmoDrawSettings& drawSettings,
  263. std::function<Color(UINT32)> idxToColorCallback);
  264. /** @} */
  265. private:
  266. friend class ct::GizmoRenderer;
  267. /** Supported types of gizmo materials (shaders) */
  268. enum class GizmoMaterial
  269. {
  270. Solid, Wire, Line, Picking, PickingAlpha, Text
  271. };
  272. /** Common data shared by all gizmo types. */
  273. struct CommonData
  274. {
  275. UINT32 idx;
  276. Color color;
  277. Matrix4 transform;
  278. HSceneObject sceneObject;
  279. bool pickable;
  280. };
  281. /** Data required for rendering a cuboid gizmo. */
  282. struct CubeData : CommonData
  283. {
  284. Vector3 position;
  285. Vector3 extents;
  286. };
  287. /** Data required for rendering a sphere gizmo. */
  288. struct SphereData : CommonData
  289. {
  290. Vector3 position;
  291. float radius;
  292. };
  293. /** Data required for rendering a cone gizmo. */
  294. struct ConeData : CommonData
  295. {
  296. Vector3 base;
  297. Vector3 normal;
  298. float radius;
  299. float height;
  300. Vector2 scale;
  301. };
  302. /** Data required for rendering a line gizmo. */
  303. struct LineData : CommonData
  304. {
  305. Vector3 start;
  306. Vector3 end;
  307. };
  308. /** Data required for rendering a list of lines. */
  309. struct LineListData : CommonData
  310. {
  311. Vector<Vector3> linePoints;
  312. };
  313. /** Data required for rendering a disc gizmo. */
  314. struct DiscData : CommonData
  315. {
  316. Vector3 position;
  317. Vector3 normal;
  318. float radius;
  319. };
  320. /** Data required for rendering a wireframe arc gizmo. */
  321. struct WireArcData : CommonData
  322. {
  323. Vector3 position;
  324. Vector3 normal;
  325. float radius;
  326. Degree startAngle;
  327. Degree amountAngle;
  328. };
  329. /** Data required for rendering a wireframe mesh gizmo. */
  330. struct WireMeshData : CommonData
  331. {
  332. SPtr<MeshData> meshData;
  333. };
  334. /** Data required for rendering a frustum gizmo. */
  335. struct FrustumData : CommonData
  336. {
  337. Vector3 position;
  338. float aspect;
  339. Degree FOV;
  340. float near;
  341. float far;
  342. };
  343. /** Data required for rendering an icon gizmo. */
  344. struct IconData : CommonData
  345. {
  346. Vector3 position;
  347. bool fixedScale;
  348. HSpriteTexture texture;
  349. };
  350. /** Data required for rendering text. */
  351. struct TextData : CommonData
  352. {
  353. Vector3 position;
  354. String text;
  355. HFont font;
  356. UINT32 fontSize;
  357. };
  358. /** Stores how many icons use a specific texture. */
  359. struct IconRenderData
  360. {
  361. UINT32 count;
  362. SPtr<ct::Texture> texture;
  363. UINT32 paramsIdx;
  364. };
  365. /** Data about a mesh rendered by the draw manager. */
  366. struct MeshRenderData
  367. {
  368. MeshRenderData(const SPtr<ct::Mesh>& mesh, const SubMesh& subMesh, SPtr<ct::Texture> texture, GizmoMeshType type)
  369. :mesh(mesh), subMesh(subMesh), texture(texture), type(type), paramsIdx(0)
  370. { }
  371. SPtr<ct::Mesh> mesh;
  372. SubMesh subMesh;
  373. SPtr<ct::Texture> texture;
  374. GizmoMeshType type;
  375. UINT32 paramsIdx;
  376. };
  377. /** Data used for initializing the core thread equivalent of the gizmo manager. */
  378. struct CoreInitData
  379. {
  380. SPtr<ct::Material> solidMat;
  381. SPtr<ct::Material> wireMat;
  382. SPtr<ct::Material> lineMat;
  383. SPtr<ct::Material> iconMat;
  384. SPtr<ct::Material> textMat;
  385. SPtr<ct::Material> pickingMat;
  386. SPtr<ct::Material> alphaPickingMat;
  387. };
  388. typedef Vector<IconRenderData> IconRenderDataVec;
  389. typedef SPtr<IconRenderDataVec> IconRenderDataVecPtr;
  390. /**
  391. * Builds a brand new mesh that can be used for rendering all icon gizmos.
  392. *
  393. * @param[in] camera Camera the mesh will be rendered to.
  394. * @param[in] drawSettings Settings used to control icon drawing.
  395. * @param[in] iconData A list of all icons and their properties.
  396. * @param[in] forPicking Whether the icons will be rendered normally, or with a special material for picking.
  397. * @param[in] renderData Output data that outlines the structure of the returned mesh. It tells us which
  398. * portions of the mesh use which icon texture.
  399. *
  400. * @return A mesh containing all of the visible icons.
  401. */
  402. SPtr<Mesh> buildIconMesh(const SPtr<Camera>& camera, const GizmoDrawSettings& drawSettings,
  403. const Vector<IconData>& iconData, bool forPicking, IconRenderDataVecPtr& renderData);
  404. /** Resizes the icon width/height so it is always scaled to optimal size (with preserved aspect). */
  405. void limitIconSize(UINT32& width, UINT32& height);
  406. /** Converts mesh data from DrawHelper into mesh data usable by the gizmo renderer. */
  407. Vector<MeshRenderData> createMeshProxyData(const Vector<DrawHelper::ShapeMeshData>& meshData);
  408. /**
  409. * Calculates colors for an icon based on its position in the camera. For example icons too close to too far might
  410. * be faded.
  411. *
  412. * @param[in] tint Primary tint for the icon.
  413. * @param[in] camera Camera in which the icon will be rendered in.
  414. * @param[in] drawSettings Settings used to control icon drawing.
  415. * @param[in] iconHeight Height of the icon in pixels.
  416. * @param[in] fixedScale Whether the icon size changes depending on distance from the camera.
  417. * @param[in] normalColor Normal color of the icon.
  418. * @param[in] fadedColor Faded color to be used when icon is occluded by geometry.
  419. */
  420. void calculateIconColors(const Color& tint, const SPtr<Camera>& camera, const GizmoDrawSettings& drawSettings,
  421. UINT32 iconHeight, bool fixedScale, Color& normalColor, Color& fadedColor);
  422. static const UINT32 VERTEX_BUFFER_GROWTH;
  423. static const UINT32 INDEX_BUFFER_GROWTH;
  424. static const UINT32 SPHERE_QUALITY;
  425. static const UINT32 WIRE_SPHERE_QUALITY;
  426. static const float MAX_ICON_RANGE;
  427. static const UINT32 OPTIMAL_ICON_SIZE;
  428. static const float ICON_TEXEL_WORLD_SIZE;
  429. typedef Set<IconData, std::function<bool(const IconData&, const IconData&)>> IconSet;
  430. Color mColor;
  431. Matrix4 mTransform;
  432. HSceneObject mActiveSO;
  433. bool mPickable = false;
  434. UINT32 mCurrentIdx = 0;
  435. bool mTransformDirty = false;
  436. bool mColorDirty = false;
  437. DrawHelper* mDrawHelper = nullptr;
  438. DrawHelper* mPickingDrawHelper = nullptr;
  439. Vector<CubeData> mSolidCubeData;
  440. Vector<CubeData> mWireCubeData;
  441. Vector<SphereData> mSolidSphereData;
  442. Vector<SphereData> mWireSphereData;
  443. Vector<SphereData> mWireHemisphereData;
  444. Vector<ConeData> mSolidConeData;
  445. Vector<ConeData> mWireConeData;
  446. Vector<LineData> mLineData;
  447. Vector<LineListData> mLineListData;
  448. Vector<DiscData> mSolidDiscData;
  449. Vector<DiscData> mWireDiscData;
  450. Vector<WireArcData> mWireArcData;
  451. Vector<WireMeshData> mWireMeshData;
  452. Vector<FrustumData> mFrustumData;
  453. Vector<IconData> mIconData;
  454. Vector<TextData> mTextData;
  455. Map<UINT32, HSceneObject> mIdxToSceneObjectMap;
  456. Vector<DrawHelper::ShapeMeshData> mActiveMeshes;
  457. SPtr<Mesh> mIconMesh;
  458. SPtr<ct::GizmoRenderer> mGizmoRenderer;
  459. // Immutable
  460. SPtr<VertexDataDesc> mIconVertexDesc;
  461. // Transient
  462. struct SortedIconData
  463. {
  464. float distance;
  465. Vector2I screenPosition;
  466. UINT32 iconIdx;
  467. };
  468. Vector<SortedIconData> mSortedIconData;
  469. };
  470. /** @} */
  471. namespace ct
  472. {
  473. /** @addtogroup Scene-Editor-Internal
  474. * @{
  475. */
  476. BS_PARAM_BLOCK_BEGIN(GizmoParamBlockDef)
  477. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatViewProj)
  478. BS_PARAM_BLOCK_ENTRY(Vector4, gViewDir)
  479. BS_PARAM_BLOCK_ENTRY(float, gInvViewportWidth)
  480. BS_PARAM_BLOCK_ENTRY(float, gInvViewportHeight)
  481. BS_PARAM_BLOCK_ENTRY(float, gViewportYFlip)
  482. BS_PARAM_BLOCK_END
  483. extern GizmoParamBlockDef gGizmoParamBlockDef;
  484. BS_PARAM_BLOCK_BEGIN(GizmoPickingParamBlockDef)
  485. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatViewProj)
  486. BS_PARAM_BLOCK_ENTRY(float, gAlphaCutoff)
  487. BS_PARAM_BLOCK_END
  488. extern GizmoPickingParamBlockDef gGizmoPickingParamBlockDef;
  489. /** Performs rendering of gizmos on the core thread, as managed by the GizmoManager. */
  490. class GizmoRenderer : public RendererExtension
  491. {
  492. friend class bs::GizmoManager;
  493. public:
  494. GizmoRenderer();
  495. private:
  496. /** @copydoc RendererExtension::initialize */
  497. void initialize(const Any& data) override;
  498. /** @copydoc RendererExtension::check */
  499. RendererExtensionRequest check(const Camera& camera) override;
  500. /** @copydoc RendererExtension::render */
  501. void render(const Camera& camera, const RendererViewContext& viewContext) override;
  502. /**
  503. * Renders all provided meshes using the provided camera.
  504. *
  505. * @param[in] camera Sets the camera all rendering will be performed to.
  506. * @param[in] meshes Meshes to render.
  507. * @param[in] iconMesh Mesh containing icon meshes.
  508. * @param[in] iconRenderData Icon render data outlining which parts of the icon mesh use which textures.
  509. * @param[in] usePickingMaterial If true, meshes will be rendered using a special picking materials, otherwise
  510. * they'll be rendered using normal drawing materials.
  511. */
  512. void renderData(const SPtr<Camera>& camera, Vector<GizmoManager::MeshRenderData>& meshes,
  513. const SPtr<MeshBase>& iconMesh, const GizmoManager::IconRenderDataVecPtr& iconRenderData,
  514. bool usePickingMaterial);
  515. /**
  516. * Renders the icon gizmo mesh using the provided parameters.
  517. *
  518. * @param[in] screenArea Area of the viewport to render the gizmos in, in pixels.
  519. * @param[in] mesh Mesh containing the icons.
  520. * @param[in] renderData Icon render data outlining which parts of the icon mesh use which textures.
  521. * @param[in] usePickingMaterial Should the icons be rendered normally or for picking.
  522. */
  523. void renderIconGizmos(Rect2I screenArea, SPtr<MeshBase> mesh, GizmoManager::IconRenderDataVecPtr renderData,
  524. bool usePickingMaterial);
  525. /**
  526. * Updates the internal data that is used for rendering. Normally you would call this after updating the camera or
  527. * meshes on the sim thread.
  528. *
  529. * @param[in] camera Sets the camera all rendering will be performed to.
  530. * @param[in] meshes Meshes to render.
  531. * @param[in] iconMesh Mesh containing icon meshes.
  532. * @param[in] iconRenderData Icon render data outlining which parts of the icon mesh use which textures.
  533. */
  534. void updateData(const SPtr<Camera>& camera, const Vector<GizmoManager::MeshRenderData>& meshes,
  535. const SPtr<MeshBase>& iconMesh, const GizmoManager::IconRenderDataVecPtr& iconRenderData);
  536. static const float PICKING_ALPHA_CUTOFF;
  537. SPtr<Camera> mCamera;
  538. Vector<GizmoManager::MeshRenderData> mMeshes;
  539. SPtr<MeshBase> mIconMesh;
  540. GizmoManager::IconRenderDataVecPtr mIconRenderData;
  541. Vector<SPtr<GpuParamsSet>> mMeshParamSets[(UINT32)GizmoMeshType::Count];
  542. Vector<SPtr<GpuParamsSet>> mIconParamSets;
  543. Vector<SPtr<GpuParamsSet>> mPickingParamSets[2];
  544. SPtr<GpuParamBlockBuffer> mMeshGizmoBuffer;
  545. SPtr<GpuParamBlockBuffer> mIconGizmoBuffer;
  546. SPtr<GpuParamBlockBuffer> mMeshPickingParamBuffer;
  547. SPtr<GpuParamBlockBuffer> mIconPickingParamBuffer;
  548. // Immutable
  549. SPtr<Material> mMeshMaterials[(UINT32)GizmoMeshType::Count];
  550. SPtr<Material> mIconMaterial;
  551. SPtr<Material> mPickingMaterials[2];
  552. };
  553. /** @} */
  554. }
  555. }