5 #include "Engine/Engine.h" 14 class UMaterialInterface;
30 void SetData(TArray<uint8>& InVertices,
bool bUseMove)
34 Data = MoveTemp(InVertices);
42 template<
typename VertexType>
43 void SetData(
const TArray<VertexType>& InVertices)
45 if (InVertices.Num() == 0)
50 check(InVertices.GetTypeSize() == GetStride());
52 Data.SetNum(InVertices.GetTypeSize() * InVertices.Num());
53 FMemory::Memcpy(Data.GetData(), InVertices.GetData(), Data.Num());
63 return Stride > 0 ? Data.Num() / Stride : 0;
82 Ar << const_cast<FRuntimeMeshVertexStreamStructure&>(VertexStructure);
84 Ar << const_cast<int32&>(Stride);
105 :
FSectionVertexBuffer(bInUseHighPrecision ? (sizeof(FPackedRGBA16N) * 2) : (sizeof(FPackedNormal) * 2))
106 , bUseHighPrecision(bInUseHighPrecision)
119 Ar << bUseHighPrecision;
121 FSectionVertexBuffer::Serialize(Ar);
134 :
FSectionVertexBuffer((bInUseHighPrecision ? sizeof(FVector2D) : sizeof(FVector2DHalf)) * InUVCount)
135 , bUseHighPrecision(bInUseHighPrecision), UVCount(InUVCount)
150 Ar << bUseHighPrecision;
153 FSectionVertexBuffer::Serialize(Ar);
173 : b32BitIndices(bIn32BitIndices)
178 void SetData(TArray<uint8>& InIndices,
bool bUseMove)
182 Data = MoveTemp(InIndices);
190 template<
typename IndexType>
191 void SetData(
const TArray<IndexType>& InIndices)
193 check(InIndices.GetTypeSize() == GetStride());
195 Data.SetNum(InIndices.GetTypeSize() * InIndices.Num());
196 FMemory::Memcpy(Data.GetData(), InIndices.GetData(), Data.Num());
201 return b32BitIndices ? 4 : 2;
206 return b32BitIndices;
211 return Data.Num() / GetStride();
266 bool ShouldRender()
const {
return IsVisible() && HasValidMeshData(); }
290 bIsVisible = bNewVisible;
294 bCastsShadow = bNewCastsShadow;
298 bCollisionEnabled = bNewCollision;
303 PositionBuffer.
SetData(InVertices, bUseMove);
307 template<
typename VertexType>
310 PositionBuffer.
SetData(InVertices);
314 LocalBoundingBox = *BoundingBox;
324 TangentsBuffer.
SetData(InVertices, bUseMove);
327 template<
typename VertexType>
330 TangentsBuffer.
SetData(InVertices);
335 UVsBuffer.
SetData(InVertices, bUseMove);
338 template<
typename VertexType>
346 ColorBuffer.
SetData(InVertices, bUseMove);
349 template<
typename VertexType>
352 ColorBuffer.
SetData(InVertices);
357 IndexBuffer.
SetData(InIndices, bUseMove);
360 template<
typename IndexType>
363 IndexBuffer.
SetData(InIndices);
366 template<
typename IndexType>
369 AdjacencyIndexBuffer.
SetData(InIndices);
386 return MakeShared<FRuntimeMeshIndicesAccessor>(AdjacencyIndexBuffer.
Is32BitIndices(), &AdjacencyIndexBuffer.
GetData());
413 TSharedPtr<struct FRuntimeMeshSectionCreationParams, ESPMode::NotThreadSafe> GetSectionCreationParams();
415 TSharedPtr<struct FRuntimeMeshSectionUpdateParams, ESPMode::NotThreadSafe> GetSectionUpdateData(
ERuntimeMeshBuffersToUpdate BuffersToUpdate);
417 TSharedPtr<struct FRuntimeMeshSectionPropertyUpdateParams, ESPMode::NotThreadSafe> GetSectionPropertyUpdateData();
419 void UpdateBoundingBox();
420 void SetBoundingBox(
const FBox& InBoundingBox) { LocalBoundingBox = InBoundingBox; }
422 int32 GetCollisionData(TArray<FVector>& OutPositions, TArray<FTriIndices>& OutIndices, TArray<FVector2D>& OutUVs);
457 TArray<FVector> NullPositions;
458 TArray<uint8> NullIndices;
481 bool bHasSection = Section.IsValid();
485 Ar << *Section.Get();
488 else if (Ar.IsLoading())
494 Section = MakeShared<FRuntimeMeshSection, ESPMode::ThreadSafe>(Ar);
FSectionIndexBuffer(bool bIn32BitIndices)
TUniquePtr< FRuntimeMeshScopedUpdater > GetSectionMeshUpdater(const FRuntimeMeshDataPtr &ParentData, int32 SectionIndex, ESectionUpdateFlags UpdateFlags, FRuntimeMeshLockProvider *LockProvider, bool bIsReadonly)
bool IsUsingHighPrecision() const
FSectionUVsVertexBuffer(bool bInUseHighPrecision, int32 InUVCount)
int32 GetNumIndices() const
void SetData(const TArray< VertexType > &InVertices)
void UpdateTangentsBuffer(const TArray< VertexType > &InVertices)
int32 GetNumVertices() const
bool IsCollisionEnabled() const
FSectionPositionVertexBuffer PositionBuffer
void UpdateIndexBuffer(TArray< uint8 > &InIndices, bool bUseMove)
static FORCEINLINE FArchive & operator<<(FArchive &Ar, FRuntimeMeshSectionPtr &Section)
void UpdatePositionBuffer(TArray< uint8 > &InVertices, bool bUseMove)
void UpdateColorBuffer(const TArray< VertexType > &InVertices)
void UpdateTangentsBuffer(TArray< uint8 > &InVertices, bool bUseMove)
bool ShouldRender() const
TSharedPtr< FRuntimeMeshAccessor > GetSectionMeshAccessor()
bool CheckUVBuffer(bool bInUseHighPrecision, int32 InNumUVs) const
void UpdateUVsBuffer(const TArray< VertexType > &InVertices)
FSectionColorVertexBuffer ColorBuffer
FSectionTangentsVertexBuffer TangentsBuffer
int32 GetNumIndices() const
void SetCastsShadow(bool bNewCastsShadow)
FSectionIndexBuffer AdjacencyIndexBuffer
FSectionUVsVertexBuffer UVsBuffer
TSharedPtr< FRuntimeMeshData, ESPMode::ThreadSafe > FRuntimeMeshDataPtr
void SetCollisionEnabled(bool bNewCollision)
FSectionTangentsVertexBuffer(bool bInUseHighPrecision)
virtual void Serialize(FArchive &Ar) override
FSectionIndexBuffer IndexBuffer
FBox GetBoundingBox() const
bool IsUsingHighPrecision() const
static const textual_icon check
const EUpdateFrequency UpdateFrequency
void SetData(TArray< uint8 > &InIndices, bool bUseMove)
void SetBoundingBox(const FBox &InBoundingBox)
TSharedPtr< FRuntimeMeshIndicesAccessor > GetTessellationIndexAccessor()
bool CheckTangentBuffer(bool bInUseHighPrecision) const
void SetData(TArray< uint8 > &InVertices, bool bUseMove)
virtual ~FSectionVertexBuffer()
void SetVisible(bool bNewVisible)
TArray< uint8 > & GetData()
virtual void Serialize(FArchive &Ar) override
ERuntimeMeshBuffersToUpdate
EUpdateFrequency GetUpdateFrequency() const
void UpdatePositionBuffer(const TArray< VertexType > &InVertices, const FBox *BoundingBox=nullptr)
TArray< uint8 > & GetData()
bool CheckIndexBufferSize(bool b32BitIndices) const
bool HasValidMeshData() const
FSectionPositionVertexBuffer()
int32 GetNumVertices() const
TSharedPtr< FRuntimeMeshSection, ESPMode::ThreadSafe > FRuntimeMeshSectionPtr
void UpdateAdjacencyIndexBuffer(const TArray< IndexType > &InIndices)
virtual void Serialize(FArchive &Ar)
void UpdateUVsBuffer(TArray< uint8 > &InVertices, bool bUseMove)
FSectionColorVertexBuffer()
bool Is32BitIndices() const
void UpdateColorBuffer(TArray< uint8 > &InVertices, bool bUseMove)
FSectionVertexBuffer(int32 InStride)
void SetData(const TArray< IndexType > &InIndices)
void UpdateIndexBuffer(const TArray< IndexType > &InIndices)