SkinnedMeshRenderProxy.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <SkinnedMesh/SkinnedMeshDispatchItem.h>
  10. #include <MorphTargets/MorphTargetDispatchItem.h>
  11. #include <Atom/Feature/SkinnedMesh/SkinnedMeshFeatureProcessorInterface.h>
  12. #include <Atom/Feature/SkinnedMesh/SkinnedMeshShaderOptions.h>
  13. #include <Atom/RPI.Reflect/Model/ModelLodAsset.h>
  14. #include <Atom/Utils/StableDynamicArray.h>
  15. #include <AzCore/base.h>
  16. #include <AzCore/Math/Vector3.h>
  17. namespace AZ
  18. {
  19. namespace RPI
  20. {
  21. class Model;
  22. class Scene;
  23. }
  24. namespace Render
  25. {
  26. class SkinnedMeshFeatureProcessor;
  27. class SkinnedMeshRenderProxy final
  28. {
  29. friend SkinnedMeshFeatureProcessor;
  30. public:
  31. AZ_RTTI(AZ::Render::SkinnedMeshRenderProxy, "{C77A21E7-113A-4DC9-972F-923E1BEFBC9A}");
  32. explicit SkinnedMeshRenderProxy(const SkinnedMeshFeatureProcessorInterface::SkinnedMeshHandleDescriptor& desc);
  33. void SetSkinningMatrices(const AZStd::vector<float>& data);
  34. void SetMorphTargetWeights(uint32_t lodIndex, const AZStd::vector<float>& weights);
  35. void EnableSkinning(uint32_t lodIndex, uint32_t meshIndex);
  36. void DisableSkinning(uint32_t lodIndex, uint32_t meshIndex);
  37. uint32_t GetLodCount() const;
  38. AZStd::span<const AZStd::unique_ptr<SkinnedMeshDispatchItem>> GetDispatchItems(uint32_t lodIndex) const;
  39. private:
  40. AZ_DISABLE_COPY_MOVE(SkinnedMeshRenderProxy);
  41. bool Init(const RPI::Scene& scene, SkinnedMeshFeatureProcessor* featureProcessor);
  42. bool BuildDispatchItem(const RPI::Scene& scene, uint32_t modelLodIndex, const SkinnedMeshShaderOptions& shaderOptions);
  43. AZStd::fixed_vector<AZStd::vector<AZStd::unique_ptr<SkinnedMeshDispatchItem>>, RPI::ModelLodAsset::LodCountMax> m_dispatchItemsByLod;
  44. AZStd::fixed_vector<AZStd::vector<AZStd::unique_ptr<MorphTargetDispatchItem>>, RPI::ModelLodAsset::LodCountMax> m_morphTargetDispatchItemsByLod;
  45. Data::Instance<SkinnedMeshInputBuffers> m_inputBuffers;
  46. AZStd::intrusive_ptr<SkinnedMeshInstance> m_instance;
  47. AZStd::shared_ptr<MeshFeatureProcessorInterface::MeshHandle> m_meshHandle;
  48. SkinnedMeshShaderOptions m_shaderOptions;
  49. Data::Instance<RPI::Buffer> m_boneTransforms;
  50. SkinnedMeshFeatureProcessor* m_featureProcessor = nullptr;
  51. };
  52. } // namespace Render
  53. } // namespace AZ