BsRendererObject.h 3.2 KB

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