// Copyright (c) Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Math/BoundingBox.h" #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Graphics/Models/Types.h" #include "Engine/Graphics/DynamicBuffer.h" /// /// The mesh deformation data container. /// struct MeshDeformationData { uint64 Key; MeshBufferType Type; uint32 DirtyMinIndex = 0; uint32 DirtyMaxIndex = MAX_uint32 - 1; bool Dirty = true; BoundingBox Bounds; DynamicVertexBuffer VertexBuffer; MeshDeformationData(uint64 key, MeshBufferType type, uint32 stride, GPUVertexLayout* layout) : Key(key) , Type(type) , VertexBuffer(0, stride, TEXT("MeshDeformation"), layout) { } NON_COPYABLE(MeshDeformationData); ~MeshDeformationData() { } bool LoadMeshAccessor(class MeshAccessor& accessor) const; }; /// /// The mesh deformation utility for editing or morphing models dynamically at runtime (eg. via Blend Shapes or Cloth). /// class FLAXENGINE_API MeshDeformation { private: Dictionary> _deformers; Array _deformations; public: ~MeshDeformation() { Clear(); } void GetBounds(int32 lodIndex, int32 meshIndex, BoundingBox& bounds) const; void Clear(); void Dirty(); void Dirty(int32 lodIndex, int32 meshIndex, MeshBufferType type); void Dirty(int32 lodIndex, int32 meshIndex, MeshBufferType type, const BoundingBox& bounds); void AddDeformer(int32 lodIndex, int32 meshIndex, MeshBufferType type, const Function& deformer); void RemoveDeformer(int32 lodIndex, int32 meshIndex, MeshBufferType type, const Function& deformer); void RunDeformers(const MeshBase* mesh, MeshBufferType type, GPUBuffer*& vertexBuffer); };