BsRendererObject.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 "BsRenderableElement.h"
  6. #include "BsRenderable.h"
  7. #include "BsParamBlocks.h"
  8. #include "BsMaterialParam.h"
  9. namespace bs
  10. {
  11. /** @addtogroup RenderBeast
  12. * @{
  13. */
  14. BS_PARAM_BLOCK_BEGIN(PerObjectParamBuffer)
  15. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatWorld)
  16. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatInvWorld)
  17. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatWorldNoScale)
  18. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatInvWorldNoScale)
  19. BS_PARAM_BLOCK_ENTRY(float, gWorldDeterminantSign)
  20. BS_PARAM_BLOCK_END
  21. BS_PARAM_BLOCK_BEGIN(PerCallParamBuffer)
  22. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatWorldViewProj)
  23. BS_PARAM_BLOCK_END
  24. struct MaterialSamplerOverrides;
  25. /**
  26. * @copydoc RenderableElement
  27. *
  28. * Contains additional data specific to RenderBeast renderer.
  29. */
  30. class BeastRenderableElement : public RenderableElement
  31. {
  32. public:
  33. /**
  34. * Optional overrides for material sampler states. Used when renderer wants to override certain sampling properties
  35. * on a global scale (for example filtering most commonly).
  36. */
  37. MaterialSamplerOverrides* samplerOverrides;
  38. /** All GPU parameters from the material used by the renderable. */
  39. SPtr<GpuParamsSetCore> params;
  40. /** Identifier of the owner renderable. */
  41. UINT32 renderableId;
  42. /** Identifier of the animation running on the renderable's mesh. -1 if no animation. */
  43. UINT64 animationId;
  44. /** Type of animation applied to this element, if any. */
  45. RenderableAnimType animType;
  46. /** Index of the technique in the material to render the element with. */
  47. UINT32 techniqueIdx;
  48. /** Index to which should the per-camera param block buffer be bound to. */
  49. UINT32 perCameraBindingIdx;
  50. /** GPU buffer containing element's bone matrices, if it requires any. */
  51. SPtr<GpuBufferCore> boneMatrixBuffer;
  52. /** Vertex buffer containing element's morph shape vertices, if it has any. */
  53. SPtr<VertexBufferCore> morphShapeBuffer;
  54. /** Vertex declaration used for rendering meshes containing morph shape information. */
  55. SPtr<VertexDeclarationCore> morphVertexDeclaration;
  56. /** Version of the morph shape vertices in the buffer. */
  57. mutable UINT32 morphShapeVersion;
  58. };
  59. /** Contains information about a Renderable, used by the Renderer. */
  60. struct RendererObject
  61. {
  62. /** Updates the per-object GPU buffer according to the currently set properties. */
  63. void updatePerObjectBuffer();
  64. /**
  65. * Updates the per-call GPU buffer according to the provided parameters.
  66. *
  67. * @param[in] viewProj Combined view-projection matrix of the current camera.
  68. * @param[in] flush True if the buffer contents should be immediately flushed to the GPU.
  69. */
  70. void updatePerCallBuffer(const Matrix4& viewProj, bool flush = true);
  71. RenderableCore* renderable;
  72. Vector<BeastRenderableElement> elements;
  73. PerObjectParamBuffer perObjectParams;
  74. PerCallParamBuffer perCallParams;
  75. };
  76. /** @} */
  77. }