BsRendererScene.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsRenderBeastPrerequisites.h"
  5. #include "BsObjectRendering.h"
  6. #include "BsSamplerOverrides.h"
  7. #include "BsLightRendering.h"
  8. #include "BsRendererView.h"
  9. namespace bs
  10. {
  11. struct RendererAnimationData;
  12. namespace ct
  13. {
  14. /** @addtogroup RenderBeast
  15. * @{
  16. */
  17. /** Contains most scene objects relevant to the renderer. */
  18. struct SceneInfo
  19. {
  20. // Cameras and render targets
  21. Vector<RendererRenderTarget> renderTargets;
  22. UnorderedMap<const Camera*, RendererView*> views;
  23. // Renderables
  24. Vector<RendererObject*> renderables;
  25. Vector<CullInfo> renderableCullInfos;
  26. // Lights
  27. Vector<RendererLight> directionalLights;
  28. Vector<RendererLight> radialLights;
  29. Vector<RendererLight> spotLights;
  30. Vector<Sphere> radialLightWorldBounds;
  31. Vector<Sphere> spotLightWorldBounds;
  32. // Reflection probes
  33. Vector<RendererReflectionProbe> reflProbes;
  34. Vector<Sphere> reflProbeWorldBounds;
  35. };
  36. /** Contains information about the scene (e.g. renderables, lights, cameras) required by the renderer. */
  37. class RendererScene
  38. {
  39. public:
  40. RendererScene(const SPtr<RenderBeastOptions>& options);
  41. ~RendererScene();
  42. /** Registers a new camera in the scene. */
  43. void registerCamera(const Camera* camera);
  44. /** Updates information about a previously registered camera. */
  45. void updateCamera(const Camera* camera, UINT32 updateFlag);
  46. /** Removes a camera from the scene. */
  47. void unregisterCamera(const Camera* camera);
  48. /** Registers a new light in the scene. */
  49. void registerLight(Light* light);
  50. /** Updates information about a previously registered light. */
  51. void updateLight(Light* light);
  52. /** Removes a light from the scene. */
  53. void unregisterLight(Light* light);
  54. /** Registers a new renderable object in the scene. */
  55. void registerRenderable(Renderable* renderable);
  56. /** Updates information about a previously registered renderable object. */
  57. void updateRenderable(Renderable* renderable);
  58. /** Removes a renderable object from the scene. */
  59. void unregisterRenderable(Renderable* renderable);
  60. /** Registers a new reflection probe in the scene. */
  61. void registerReflectionProbe(ReflectionProbe* probe);
  62. /** Updates information about a previously registered reflection probe. */
  63. void updateReflectionProbe(ReflectionProbe* probe);
  64. /** Removes a reflection probe from the scene. */
  65. void unregisterReflectionProbe(ReflectionProbe* probe);
  66. /** Updates or replaces the filtered reflection texture of the probe at the specified index. */
  67. void setReflectionProbeTexture(UINT32 probeIdx, const SPtr<Texture>& texture);
  68. /** Updates the index at which the reflection probe's texture is stored at, in the global array. */
  69. void setReflectionProbeArrayIndex(UINT32 probeIdx, UINT32 arrayIdx, bool markAsClean);
  70. /** Returns a container with all relevant scene objects. */
  71. const SceneInfo& getSceneInfo() const { return mInfo; }
  72. /** Updates scene according to the newly provided renderer options. */
  73. void setOptions(const SPtr<RenderBeastOptions>& options);
  74. /**
  75. * Checks all sampler overrides in case material sampler states changed, and updates them.
  76. *
  77. * @param[in] force If true, all sampler overrides will be updated, regardless of a change in the material
  78. * was detected or not.
  79. */
  80. void refreshSamplerOverrides(bool force = false);
  81. private:
  82. /**
  83. * Updates (or adds) renderer specific data for the specified camera. Should be called whenever camera properties
  84. * change.
  85. *
  86. * @param[in] camera Camera whose data to update.
  87. * @param[in] forceRemove If true, the camera data will be removed instead of updated.
  88. * @return Renderer view object that represents the camera. Null if camera was removed.
  89. */
  90. RendererView* updateCameraData(const Camera* camera, bool forceRemove = false);
  91. SceneInfo mInfo;
  92. UnorderedMap<SamplerOverrideKey, MaterialSamplerOverrides*> mSamplerOverrides;
  93. DefaultMaterial* mDefaultMaterial = nullptr;
  94. SPtr<RenderBeastOptions> mOptions;
  95. };
  96. /** @} */
  97. }}