BsCamera.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsIReflectable.h"
  6. #include "BsMatrix4.h"
  7. #include "BsVector3.h"
  8. #include "BsVector2.h"
  9. #include "BsVector2I.h"
  10. #include "BsAABox.h"
  11. #include "BsQuaternion.h"
  12. #include "BsRay.h"
  13. #include "BsCoreObject.h"
  14. #include "BsConvexVolume.h"
  15. #include "BsPostProcessSettings.h"
  16. namespace BansheeEngine
  17. {
  18. /** @addtogroup Renderer-Internal
  19. * @{
  20. */
  21. /** Signals which portion of a Camera is dirty. */
  22. enum class CameraDirtyFlag
  23. {
  24. Transform = 1<<0,
  25. Everything = 1<<1,
  26. PostProcess = 1<<2
  27. };
  28. /** Projection type to use by the camera. */
  29. enum ProjectionType
  30. {
  31. PT_ORTHOGRAPHIC, /**< Projection type where object size remains constant and parallel lines remain parallel. */
  32. PT_PERSPECTIVE /**< Projection type that emulates human vision. Objects farther away appear smaller. */
  33. };
  34. /** Clip planes that form the camera frustum (visible area). */
  35. enum FrustumPlane
  36. {
  37. FRUSTUM_PLANE_NEAR = 0,
  38. FRUSTUM_PLANE_FAR = 1,
  39. FRUSTUM_PLANE_LEFT = 2,
  40. FRUSTUM_PLANE_RIGHT = 3,
  41. FRUSTUM_PLANE_TOP = 4,
  42. FRUSTUM_PLANE_BOTTOM = 5
  43. };
  44. /** Flags that describe a camera. */
  45. enum class CameraFlag
  46. {
  47. /**
  48. * This flag is a signal to the renderer that his camera will only render overlays and doesn't require depth
  49. * buffer or multi-sampled render targets. This can improve performance and memory usage.
  50. */
  51. Overlay = 1,
  52. /**
  53. * High dynamic range allows light intensity to be more correctly recorded when rendering by allowing for a larger
  54. * range of values. The stored light is then converted into visible color range using exposure and a tone mapping
  55. * operator.
  56. */
  57. HDR = 2
  58. };
  59. typedef Flags<CameraFlag> CameraFlags;
  60. BS_FLAGS_OPERATORS(CameraFlag);
  61. /** @} */
  62. /** @addtogroup Implementation
  63. * @{
  64. */
  65. /**
  66. * Camera determines how is world geometry projected onto a 2D surface. You may position and orient it in space, set
  67. * options like aspect ratio and field or view and it outputs view and projection matrices required for rendering.
  68. *
  69. * This class contains funcionality common to both core and non-core versions of the camera.
  70. */
  71. class BS_CORE_EXPORT CameraBase
  72. {
  73. public:
  74. virtual ~CameraBase() { }
  75. /**
  76. * Sets the camera horizontal field of view. This determines how wide the camera viewing angle is along the
  77. * horizontal axis. Vertical FOV is calculated from the horizontal FOV and the aspect ratio.
  78. */
  79. virtual void setHorzFOV(const Radian& fovy);
  80. /** Retrieves the camera horizontal field of view. */
  81. virtual const Radian& getHorzFOV() const;
  82. /**
  83. * Sets the distance from the frustum to the near clipping plane. Anything closer than the near clipping plane will
  84. * not be rendered. Decreasing this value decreases depth buffer precision.
  85. */
  86. virtual void setNearClipDistance(float nearDist);
  87. /**
  88. * Retrieves the distance from the frustum to the near clipping plane. Anything closer than the near clipping plane
  89. * will not be rendered. Decreasing this value decreases depth buffer precision.
  90. */
  91. virtual float getNearClipDistance() const;
  92. /**
  93. * Sets the distance from the frustum to the far clipping plane. Anything farther than the far clipping plane will
  94. * not be rendered. Increasing this value decreases depth buffer precision.
  95. */
  96. virtual void setFarClipDistance(float farDist);
  97. /**
  98. * Retrieves the distance from the frustum to the far clipping plane. Anything farther than the far clipping plane
  99. * will not be rendered. Increasing this value decreases depth buffer precision.
  100. */
  101. virtual float getFarClipDistance() const;
  102. /** Sets the current viewport aspect ratio (width / height). */
  103. virtual void setAspectRatio(float ratio);
  104. /** Returns current viewport aspect ratio (width / height). */
  105. virtual float getAspectRatio() const;
  106. /** Sets camera world space position. */
  107. virtual void setPosition(const Vector3& position);
  108. /** Retrieves camera world space position. */
  109. virtual Vector3 getPosition() const { return mPosition; }
  110. /** Sets should the camera be rendered to or not. */
  111. void setIsActive(bool active) { mIsActive = active; _markCoreDirty(); }
  112. /** Gets whether the camera be rendered to or not. */
  113. bool getIsActive() const { return mIsActive; }
  114. /**
  115. * Gets the Z (forward) axis of the object, in world space.
  116. *
  117. * @return Forward axis of the object.
  118. */
  119. Vector3 getForward() const { return getRotation().rotate(-Vector3::UNIT_Z); }
  120. /** Sets camera world space rotation. */
  121. virtual void setRotation(const Quaternion& rotation);
  122. /** Retrieves camera world space rotation. */
  123. virtual Quaternion getRotation() const { return mRotation; }
  124. /** Manually set the extents of the frustum that will be used when calculating the projection matrix. This will
  125. * prevents extents for being automatically calculated from aspect and near plane so it is up to the caller to keep
  126. * these values accurate.
  127. *
  128. * @param[in] left The position where the left clip plane intersect the near clip plane, in view space.
  129. * @param[in] right The position where the right clip plane intersect the near clip plane, in view space.
  130. * @param[in] top The position where the top clip plane intersect the near clip plane, in view space.
  131. * @param[in] bottom The position where the bottom clip plane intersect the near clip plane, in view space.
  132. */
  133. virtual void setFrustumExtents(float left, float right, float top, float bottom);
  134. /**
  135. * Resets frustum extents so they are automatically derived from other values. This is only relevant if you have
  136. * previously set custom extents.
  137. */
  138. virtual void resetFrustumExtents();
  139. /** Returns the extents of the frustum in view space at the near plane. */
  140. virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const;
  141. /**
  142. * Returns the standard projection matrix that determines how are 3D points projected to two dimensions. The layout
  143. * of this matrix depends on currently used render system.
  144. *
  145. * @note
  146. * You should use this matrix when sending the matrix to the render system to make sure everything works
  147. * consistently when other render systems are used.
  148. */
  149. virtual const Matrix4& getProjectionMatrixRS() const;
  150. /**
  151. * Returns the inverse of the render-system specific projection matrix.
  152. *
  153. * @see getProjectionMatrixRS
  154. */
  155. virtual const Matrix4& getProjectionMatrixRSInv() const;
  156. /**
  157. * Returns the standard projection matrix that determines how are 3D points projected to two dimensions. Returned
  158. * matrix is standard following right-hand rules and depth range of [-1, 1].
  159. *
  160. * @note
  161. * Different render systems will expect different projection matrix layouts, in which case use
  162. * getProjectionMatrixRS().
  163. */
  164. virtual const Matrix4& getProjectionMatrix() const;
  165. /**
  166. * Returns the inverse of the projection matrix.
  167. *
  168. * @see getProjectionMatrix
  169. */
  170. virtual const Matrix4& getProjectionMatrixInv() const;
  171. /** Gets the camera view matrix. Used for positioning/orienting the camera. */
  172. virtual const Matrix4& getViewMatrix() const;
  173. /**
  174. * Returns the inverse of the view matrix.
  175. *
  176. * @see getViewMatrix
  177. */
  178. virtual const Matrix4& getViewMatrixInv() const;
  179. /**
  180. * Sets whether the camera should use the custom view matrix. When this is enabled camera will no longer calculate
  181. * its view matrix based on position/orientation and caller will be resonsible to keep the view matrix up to date.
  182. */
  183. virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY);
  184. /** Returns true if a custom view matrix is used. */
  185. virtual bool isCustomViewMatrixEnabled() const { return mCustomViewMatrix; }
  186. /**
  187. * Sets whether the camera should use the custom projection matrix. When this is enabled camera will no longer
  188. * calculate its projection matrix based on field of view, aspect and other parameters and caller will be resonsible
  189. * to keep the projection matrix up to date.
  190. */
  191. virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY);
  192. /** Returns true if a custom projection matrix is used. */
  193. virtual bool isCustomProjectionMatrixEnabled() const { return mCustomProjMatrix; }
  194. /** Returns a convex volume representing the visible area of the camera, in local space. */
  195. virtual const ConvexVolume& getFrustum() const;
  196. /** Returns a convex volume representing the visible area of the camera, in world space. */
  197. virtual ConvexVolume getWorldFrustum() const;
  198. /** Returns the bounding of the frustum. */
  199. const AABox& getBoundingBox() const;
  200. /**
  201. * Sets the type of projection used by the camera. Projection type controls how is 3D geometry projected onto a
  202. * 2D plane.
  203. */
  204. virtual void setProjectionType(ProjectionType pt);
  205. /**
  206. * Returns the type of projection used by the camera. Projection type controls how is 3D geometry projected onto a
  207. * 2D plane.
  208. */
  209. virtual ProjectionType getProjectionType() const;
  210. /**
  211. * Sets the orthographic window height, for use with orthographic rendering only.
  212. *
  213. * @param[in] w Width of the window in world units.
  214. * @param[in] h Height of the window in world units.
  215. *
  216. * @note
  217. * Calling this method will recalculate the aspect ratio, use setOrthoWindowHeight() or setOrthoWindowWidth() alone
  218. * if you wish to preserve the aspect ratio but just fit one or other dimension to a particular size.
  219. */
  220. virtual void setOrthoWindow(float w, float h);
  221. /**
  222. * Sets the orthographic window height, for use with orthographic rendering only.
  223. *
  224. * @param[in] h Height of the window in world units.
  225. *
  226. * @note The width of the window will be calculated from the aspect ratio.
  227. */
  228. virtual void setOrthoWindowHeight(float h);
  229. /**
  230. * Sets the orthographic window width, for use with orthographic rendering only.
  231. *
  232. * @param[in] w Width of the window in world units.
  233. *
  234. * @note The height of the window will be calculated from the aspect ratio.
  235. */
  236. virtual void setOrthoWindowWidth(float w);
  237. /** Gets the orthographic window width in world units, for use with orthographic rendering only. */
  238. virtual float getOrthoWindowHeight() const;
  239. /**
  240. * Gets the orthographic window width in world units, for use with orthographic rendering only.
  241. *
  242. * @note This is calculated from the orthographic height and the aspect ratio.
  243. */
  244. virtual float getOrthoWindowWidth() const;
  245. /**
  246. * Gets a priority that determines in which orders the cameras are rendered. This only applies to cameras rendering
  247. * to the same render target.
  248. */
  249. INT32 getPriority() const { return mPriority; }
  250. /**
  251. * Sets a priority that determines in which orders the cameras are rendered. This only applies to cameras rendering
  252. * to the same render target.
  253. *
  254. * @param[in] priority The priority. Higher value means the camera will be rendered sooner.
  255. */
  256. void setPriority(INT32 priority) { mPriority = priority; _markCoreDirty(); }
  257. /** Retrieves layer bitfield that is used when determining which object should the camera render. */
  258. UINT64 getLayers() const { return mLayers; }
  259. /** Sets layer bitfield that is used when determining which object should the camera render. */
  260. void setLayers(UINT64 layers) { mLayers = layers; _markCoreDirty(); }
  261. /** Returns number of samples if the camera uses multiple samples per pixel. */
  262. UINT32 getMSAACount() const { return mMSAA; }
  263. /**
  264. * Enables or disables multi-sampled anti-aliasing. Set to zero or one to disable, or to the required number of
  265. * samples to enable.
  266. */
  267. void setMSAACount(UINT32 count) { mMSAA = count; _markCoreDirty(); }
  268. /** Returns settings that are used for controling post-process operations like tonemapping. */
  269. const SPtr<PostProcessSettings>& getPostProcessSettings() const { return mPPSettings; }
  270. /** Sets settings that are used for controling post-process operations like tonemapping. */
  271. void setPostProcessSettings(const SPtr<PostProcessSettings>& settings) { mPPSettings = settings; _markCoreDirty(CameraDirtyFlag::PostProcess); }
  272. /** Retrieves flags that define the camera. */
  273. CameraFlags getFlags() const { return mCameraFlags; }
  274. /** Enables or disables flags that define the camera's behaviour. */
  275. void setFlag(const CameraFlag& flag, bool enable);
  276. /**
  277. * Converts a point in world space to screen coordinates (in pixels corresponding to the render target attached to
  278. * the camera).
  279. */
  280. Vector2I worldToScreenPoint(const Vector3& worldPoint) const;
  281. /** Converts a point in world space to normalized device coordinates (in [-1, 1] range). */
  282. Vector2 worldToNdcPoint(const Vector3& worldPoint) const;
  283. /** Converts a point in world space to point relative to camera's coordinate system (view space). */
  284. Vector3 worldToViewPoint(const Vector3& worldPoint) const;
  285. /**
  286. * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a point in
  287. * world space.
  288. *
  289. * @param[in] screenPoint Point to transform.
  290. * @param[in] depth Depth to place the world point at. The depth is applied to the vector going from camera
  291. * origin to the point on the near plane.
  292. */
  293. Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
  294. /**
  295. * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a point
  296. * relative to camera's coordinate system (view space).
  297. *
  298. * @param[in] screenPoint Point to transform.
  299. * @param[in] depth Depth to place the world point at. The depth is applied to the vector going from camera
  300. * origin to the point on the near plane.
  301. */
  302. Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
  303. /**
  304. * Converts a point in screen space (pixels corresponding to render target attached to the camera) to normalized
  305. * device coordinates (in [-1, 1] range).
  306. */
  307. Vector2 screenToNdcPoint(const Vector2I& screenPoint) const;
  308. /** Converts a point relative to camera's coordinate system (view space) into a point in world space. */
  309. Vector3 viewToWorldPoint(const Vector3& viewPoint) const;
  310. /**
  311. * Converts a point relative to camera's coordinate system (view space) into a point in screen space (pixels
  312. * corresponding to render target attached to the camera).
  313. */
  314. Vector2I viewToScreenPoint(const Vector3& viewPoint) const;
  315. /**
  316. * Converts a point relative to camera's coordinate system (view space) into normalized device coordinates
  317. * (in [-1, 1] range).
  318. */
  319. Vector2 viewToNdcPoint(const Vector3& viewPoint) const;
  320. /**
  321. * Converts a point in normalized device coordinates ([-1, 1] range) to a point in world space.
  322. *
  323. * @param[in] ndcPoint Point to transform.
  324. * @param[in] depth Depth to place the world point at. The depth is applied to the vector going from camera
  325. * origin to the point on the near plane.
  326. */
  327. Vector3 ndcToWorldPoint(const Vector2& ndcPoint, float depth = 0.5f) const;
  328. /**
  329. * Converts a point in normalized device coordinates ([-1, 1] range) to a point relative to camera's coordinate system
  330. * (view space).
  331. *
  332. * @param[in] ndcPoint Point to transform.
  333. * @param[in] depth Depth to place the world point at. The depth is applied to the vector going from camera
  334. * origin to the point on the near plane.
  335. */
  336. Vector3 ndcToViewPoint(const Vector2& ndcPoint, float depth = 0.5f) const;
  337. /**
  338. * Converts a point in normalized device coordinates ([-1, 1] range) to a point in screen space (pixels corresponding
  339. * to render target attached to the camera).
  340. */
  341. Vector2I ndcToScreenPoint(const Vector2& ndcPoint) const;
  342. /**
  343. * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a ray in world
  344. * space originating at the selected point on the camera near plane.
  345. */
  346. Ray screenPointToRay(const Vector2I& screenPoint) const;
  347. /** Projects a point from view to normalized device space. */
  348. Vector3 projectPoint(const Vector3& point) const;
  349. /** Un-projects a point in normalized device space to view space. */
  350. Vector3 unprojectPoint(const Vector3& point) const;
  351. static const float INFINITE_FAR_PLANE_ADJUST; /**< Small constant used to reduce far plane projection to avoid inaccuracies. */
  352. protected:
  353. CameraBase();
  354. /** Calculate projection parameters that are used when constructing the projection matrix. */
  355. virtual void calcProjectionParameters(float& left, float& right, float& bottom, float& top) const;
  356. /** Recalculate frustum if dirty. */
  357. virtual void updateFrustum() const;
  358. /** Recalculate frustum planes if dirty. */
  359. virtual void updateFrustumPlanes() const;
  360. /**
  361. * Update view matrix from parent position/orientation.
  362. *
  363. * @note Does nothing when custom view matrix is set.
  364. */
  365. virtual void updateView() const;
  366. /** Checks if the frustum requires updating. */
  367. virtual bool isFrustumOutOfDate() const;
  368. /** Notify camera that the frustum requires to be updated. */
  369. virtual void invalidateFrustum() const;
  370. /** Returns a rectangle that defines the viewport position and size, in pixels. */
  371. virtual Rect2I getViewportRect() const = 0;
  372. /**
  373. * Marks the simulation thread object as dirty and notifies the system its data should be synced with its core
  374. * thread counterpart.
  375. */
  376. virtual void _markCoreDirty(CameraDirtyFlag flag = CameraDirtyFlag::Everything) { }
  377. protected:
  378. UINT64 mLayers; /**< Bitfield that can be used for filtering what objects the camera sees. */
  379. CameraFlags mCameraFlags; /**< Flags that further determine type of camera. */
  380. Vector3 mPosition; /**< World space position. */
  381. Quaternion mRotation; /**< World space rotation. */
  382. bool mIsActive; /**< Is camera being rendered to. */
  383. ProjectionType mProjType; /**< Type of camera projection. */
  384. Radian mHorzFOV; /**< Horizontal field of view represents how wide is the camera angle. */
  385. float mFarDist; /**< Clip any objects further than this. Larger value decreases depth precision at smaller depths. */
  386. float mNearDist; /**< Clip any objects close than this. Smaller value decreases depth precision at larger depths. */
  387. float mAspect; /**< Width/height viewport ratio. */
  388. float mOrthoHeight; /**< Height in world units used for orthographic cameras. */
  389. INT32 mPriority; /**< Determines in what order will the camera be rendered. Higher priority means the camera will be rendered sooner. */
  390. bool mCustomViewMatrix; /**< Is custom view matrix set. */
  391. bool mCustomProjMatrix; /**< Is custom projection matrix set. */
  392. UINT8 mMSAA; /**< Number of samples to render the scene with. */
  393. SPtr<PostProcessSettings> mPPSettings; /**< Settings used to control post-process operations. */
  394. bool mFrustumExtentsManuallySet; /**< Are frustum extents manually set. */
  395. mutable Matrix4 mProjMatrixRS; /**< Cached render-system specific projection matrix. */
  396. mutable Matrix4 mProjMatrix; /**< Cached projection matrix that determines how are 3D points projected to a 2D viewport. */
  397. mutable Matrix4 mViewMatrix; /**< Cached view matrix that determines camera position/orientation. */
  398. mutable Matrix4 mProjMatrixRSInv;
  399. mutable Matrix4 mProjMatrixInv;
  400. mutable Matrix4 mViewMatrixInv;
  401. mutable ConvexVolume mFrustum; /**< Main clipping planes describing cameras visible area. */
  402. mutable bool mRecalcFrustum : 1; /**< Should frustum be recalculated. */
  403. mutable bool mRecalcFrustumPlanes : 1; /**< Should frustum planes be recalculated. */
  404. mutable bool mRecalcView : 1; /**< Should view matrix be recalculated. */
  405. mutable float mLeft, mRight, mTop, mBottom; /**< Frustum extents. */
  406. mutable AABox mBoundingBox; /**< Frustum bounding box. */
  407. };
  408. /** @} */
  409. /** @addtogroup Renderer-Engine-Internal
  410. * @{
  411. */
  412. /** @copydoc CameraBase */
  413. class BS_CORE_EXPORT CameraCore : public CoreObjectCore, public CameraBase
  414. {
  415. public:
  416. ~CameraCore();
  417. /** Returns the viewport used by the camera. */
  418. SPtr<ViewportCore> getViewport() const { return mViewport; }
  419. protected:
  420. friend class Camera;
  421. CameraCore(SPtr<RenderTargetCore> target = nullptr,
  422. float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
  423. CameraCore(const SPtr<ViewportCore>& viewport);
  424. /** @copydoc CoreObjectCore::initialize */
  425. void initialize() override;
  426. /** @copydoc CameraBase */
  427. Rect2I getViewportRect() const override;
  428. /** @copydoc CoreObject::syncToCore */
  429. void syncToCore(const CoreSyncData& data) override;
  430. SPtr<ViewportCore> mViewport;
  431. };
  432. /** @copydoc CameraBase */
  433. class BS_CORE_EXPORT Camera : public IReflectable, public CoreObject, public CameraBase
  434. {
  435. public:
  436. /** Returns the viewport used by the camera. */
  437. SPtr<Viewport> getViewport() const { return mViewport; }
  438. /**
  439. * Determines whether this is the main application camera. Main camera controls the final render surface that is
  440. * displayed to the user.
  441. */
  442. bool isMain() const { return mMain; }
  443. /**
  444. * Marks or unmarks this camera as the main application camera. Main camera controls the final render surface that
  445. * is displayed to the user.
  446. */
  447. void setMain(bool main) { mMain = main; }
  448. /** Retrieves an implementation of a camera handler usable only from the core thread. */
  449. SPtr<CameraCore> getCore() const;
  450. /** Creates a new camera that renders to the specified portion of the provided render target. */
  451. static SPtr<Camera> create(SPtr<RenderTarget> target = nullptr,
  452. float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
  453. /** @name Internal
  454. * @{
  455. */
  456. /** Returns the hash value that can be used to identify if the internal data needs an update. */
  457. UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
  458. /** Sets the hash value that can be used to identify if the internal data needs an update. */
  459. void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
  460. /** @} */
  461. protected:
  462. Camera(SPtr<RenderTarget> target = nullptr,
  463. float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
  464. /** @copydoc CameraBase */
  465. Rect2I getViewportRect() const override;
  466. /** @copydoc CoreObject::createCore */
  467. SPtr<CoreObjectCore> createCore() const override;
  468. /** @copydoc CameraBase::_markCoreDirty */
  469. void _markCoreDirty(CameraDirtyFlag flag = CameraDirtyFlag::Everything) override;
  470. /** @copydoc CoreObject::syncToCore */
  471. CoreSyncData syncToCore(FrameAlloc* allocator) override;
  472. /** @copydoc CoreObject::getCoreDependencies */
  473. void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
  474. /** Creates a new camera without initializing it. */
  475. static SPtr<Camera> createEmpty();
  476. SPtr<Viewport> mViewport; /**< Viewport that describes 2D rendering surface. */
  477. bool mMain;
  478. UINT32 mLastUpdateHash;
  479. /************************************************************************/
  480. /* RTTI */
  481. /************************************************************************/
  482. public:
  483. friend class CameraRTTI;
  484. static RTTITypeBase* getRTTIStatic();
  485. RTTITypeBase* getRTTI() const override;
  486. };
  487. /** @} */
  488. }