8 template<
typename TYPE>
11 int32 StartPosition = (Index * Stride + Offset);
12 return *((TYPE*)&(*Data)[StartPosition]);
17 int32 StartPosition = (Index * Stride + Offset);
18 return &(*Data)[StartPosition];
21 template<
typename TYPE>
24 TStaticArray<TYPE, 8>
UVs;
35 : bIsInitialized(false)
36 , bIsReadonly(bInIsReadonly)
37 , PositionStream(PositionStreamData)
38 , TangentStream(TangentStreamData), bTangentHighPrecision(false), TangentSize(0), TangentStride(0)
39 , UVStream(UVStreamData), bUVHighPrecision(false), UVChannelCount(0), UVSize(0), UVStride(0)
40 , ColorStream(ColorStreamData)
45 TArray<uint8>* PositionStreamData, TArray<uint8>* TangentStreamData, TArray<uint8>* UVStreamData, TArray<uint8>* ColorStreamData,
bool bInIsReadonly)
53 Initialize(bInTangentsHighPrecision, bInUVsHighPrecision, bInUVCount);
128 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 20 136 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 20 149 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 20 157 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 20 181 return GetStreamAccess<FRuntimeMeshEightUV<FVector2DHalf>>(
UVStream,
Index,
UVStride, 0).UVs[Channel];
193 int32 CountClamped = FMath::Clamp(Count, 0, Positions.Num());
194 return SetPositions(InsertAtIndex, Positions.GetData(), CountClamped, bSizeToFit);
252 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 20 253 FVector4 NewNormal = Tangents.
Normal.ToFVector4();
255 FVector4 NewNormal = Tangents.
Normal;
258 Tangents.
Normal = NewNormal;
264 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 20 265 FVector4 NewNormal = Tangents.
Normal.ToFVector4();
267 FVector4 NewNormal = Tangents.
Normal;
270 Tangents.
Normal = NewNormal;
284 int32 CountClamped = FMath::Clamp(Count, 0, Colors.Num());
285 return SetColors(InsertAtIndex, Colors.GetData(), CountClamped, bSizeToFit);
334 GetStreamAccess<FRuntimeMeshEightUV<FVector2DHalf>>(
UVStream,
Index,
UVStride, 0).UVs[Channel] = Value;
341 int32 CountClamped = FMath::Clamp(CountVertices, 0, UVs.Num());
342 return SetUVs(InsertAtVertexIndex, UVs.GetData(), CountClamped, bSizeToFit);
349 int32 CountClamped = FMath::Clamp(CountVertices, 0, UVs.Num());
350 return SetUVs(InsertAtVertexIndex, UVs.GetData(), CountClamped, bSizeToFit);
359 if (InsertAtVertexIndex + CountVertices >
NumVertices())
380 if (InsertAtVertexIndex + CountVertices >
NumVertices())
421 Tangents.
Normal = FVector4(TangentZ, GetBasisDeterminantSign(TangentX, TangentY, TangentZ));
427 Tangents.
Normal = FVector4(TangentZ, GetBasisDeterminantSign(TangentX, TangentY, TangentZ));
446 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 20 457 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 20 472 for (int32 UVIndex = 0; UVIndex < Vertex.
UVs.Num(); UVIndex++)
474 Vertex.
UVs[UVIndex] = UVs.
UVs[UVIndex];
480 for (int32 UVIndex = 0; UVIndex < Vertex.
UVs.Num(); UVIndex++)
482 Vertex.
UVs[UVIndex] = UVs.
UVs[UVIndex];
514 for (int32 UVIndex = 0; UVIndex < Vertex.
UVs.Num(); UVIndex++)
516 UVs.
UVs[UVIndex] = Vertex.
UVs[UVIndex];
522 for (int32 UVIndex = 0; UVIndex < Vertex.
UVs.Num(); UVIndex++)
524 UVs.
UVs[UVIndex] = Vertex.
UVs[UVIndex];
562 , IndexStream(IndexStreamData), b32BitIndices(false)
657 int32 CountClamped = FMath::Clamp(Count, 0, Indices.Num());
658 return SetIndices(InsertAtIndex, Indices.GetData(), CountClamped, bSizeToFit);
684 int32 CountClamped = FMath::Clamp(Count, 0, Indices.Num());
685 return SetIndices(InsertAtIndex, Indices.GetData(), CountClamped, bSizeToFit);
713 TArray<uint8>* TangentStreamData, TArray<uint8>* UVStreamData, TArray<uint8>* ColorStreamData, TArray<uint8>* IndexStreamData,
bool bInIsReadonly)
714 :
FRuntimeMeshVerticesAccessor(bInTangentsHighPrecision, bInUVsHighPrecision, bInUVCount, PositionStreamData, TangentStreamData, UVStreamData, ColorStreamData, bInIsReadonly)
724 FRuntimeMeshAccessor::FRuntimeMeshAccessor(TArray<uint8>* PositionStreamData, TArray<uint8>* TangentStreamData, TArray<uint8>* UVStreamData, TArray<uint8>* ColorStreamData, TArray<uint8>* IndexStreamData,
bool bInIsReadonly)
742 if (bClearDestination)
750 int32 StartVertex = Other->NumVertices();
752 int32 NumUVs = FMath::Min(
NumUVChannels(), Other->NumUVChannels());
760 for (int32 UVIndex = 0; UVIndex < NumUVs; UVIndex++)
762 Other->SetUV(NewIndex, UVIndex,
GetUV(
Index, UVIndex));
792 TArray<uint8>* PositionStreamData, TArray<uint8>* TangentStreamData, TArray<uint8>* UVStreamData, TArray<uint8>* ColorStreamData, TArray<uint8>* IndexStreamData,
FRuntimeMeshLockProvider* InSyncObject,
bool bIsReadonly)
793 :
FRuntimeMeshAccessor(bInTangentsHighPrecision, bInUVsHighPrecision, bInUVCount, bIn32BitIndices, PositionStreamData, TangentStreamData, UVStreamData, ColorStreamData, IndexStreamData, bIsReadonly)
795 , LinkedMeshData(InLinkedMeshData), SectionIndex(InSectionIndex), UpdateFlags(InUpdateFlags)
823 void FRuntimeMeshScopedUpdater::Commit(
const FBox& BoundingBox,
bool bNeedsPositionUpdate,
bool bNeedsNormalTangentUpdate,
bool bNeedsColorUpdate,
bool bNeedsUVUpdate,
bool bNeedsIndexUpdate)
834 LinkedMeshData->EndSectionUpdate(
this, BuffersToUpdate, &BoundingBox);
TArray< uint8 > * UVStream
TArray< uint8 > * TangentStream
void CopyTo(const TSharedPtr< FRuntimeMeshAccessor > &Other, bool bClearDestination=false) const
FRuntimeMeshVerticesAccessor(bool bInTangentsHighPrecision, bool bInUVsHighPrecision, int32 bInUVCount, TArray< uint8 > *PositionStreamData, TArray< uint8 > *TangentStreamData, TArray< uint8 > *UVStreamData, TArray< uint8 > *ColorStreamData, bool bInIsReadonly=false)
FVector GetPosition(int32 Index) const
void SetNumIndices(int32 NewNum)
int32 AddVertex(FVector InPosition)
TArray< uint8 > * ColorStream
int32 GetIndex(int32 Index) const
void EmptyIndices(int32 Slack=0)
void Initialize(bool bIn32BitIndices)
FVector4 GetNormal(int32 Index) const
bool SetColors(const int32 InsertAtIndex, const TArray< FColor > &Colors, const int32 Count, const bool bSizeToFit)
void Initialize(bool bInTangentsHighPrecision, bool bInUVsHighPrecision, int32 bInUVCount, bool bIn32BitIndices)
FRuntimeMeshIndicesAccessor(bool bIn32BitIndices, TArray< uint8 > *IndexStreamData, bool bInIsReadonly=false)
FORCEINLINE int32 GetIndexStride() const
static const int32 ColorStride
void SetVertex(int32 Index, const FRuntimeMeshAccessorVertex &Vertex)
virtual ~FRuntimeMeshIndicesAccessor()
void EmptyVertices(int32 Slack=0)
FColor GetColor(int32 Index) const
static FORCEINLINE TYPE & GetStreamAccess(TArray< uint8 > *Data, int32 Index, int32 Stride, int32 Offset)
void SetNumVertices(int32 NewNum)
void Initialize(bool bInTangentsHighPrecision, bool bInUVsHighPrecision, int32 bInUVCount)
TSharedPtr< FRuntimeMeshData, ESPMode::ThreadSafe > FRuntimeMeshDataPtr
const bool bTangentHighPrecision
void SetColor(int32 Index, const FColor &Value)
~FRuntimeMeshScopedUpdater()
void SetNormal(int32 Index, const FVector4 &Value)
TStaticArray< TYPE, 8 > UVs
static const int32 PositionStride
static const textual_icon check
void SetTangent(int32 Index, const FVector &Value)
void SetNormalTangent(int32 Index, FVector Normal, FRuntimeMeshTangent Tangent)
IMGUI_API void Value(const char *prefix, bool b)
TArray< uint8 > * IndexStream
void SetUV(int32 Index, const FVector2D &Value)
int32 AddTriangle(int32 Index0, int32 Index1, int32 Index2)
TArray< FVector2D, TInlineAllocator< RUNTIMEMESH_MAXTEXCOORDS > > UVs
void Commit(bool bNeedsPositionUpdate=true, bool bNeedsNormalTangentUpdate=true, bool bNeedsColorUpdate=true, bool bNeedsUVUpdate=true, bool bNeedsIndexUpdate=true)
FRuntimeMeshScopedUpdater(const FRuntimeMeshDataPtr &InLinkedMeshData, int32 InSectionIndex, ESectionUpdateFlags InUpdateFlags, bool bInTangentsHighPrecision, bool bInUVsHighPrecision, int32 bInUVCount, bool bIn32BitIndices, TArray< uint8 > *PositionStreamData, TArray< uint8 > *TangentStreamData, TArray< uint8 > *UVStreamData, TArray< uint8 > *ColorStreamData, TArray< uint8 > *IndexStreamData, FRuntimeMeshLockProvider *InSyncObject, bool bIsReadonly)
static FORCEINLINE uint8 * GetStreamAccessPointer(TArray< uint8 > *Data, int32 Index, int32 Stride, int32 Offset)
FRuntimeMeshAccessor(bool bInTangentsHighPrecision, bool bInUVsHighPrecision, int32 bInUVCount, bool bIn32BitIndices, TArray< uint8 > *PositionStreamData, TArray< uint8 > *TangentStreamData, TArray< uint8 > *UVStreamData, TArray< uint8 > *ColorStreamData, TArray< uint8 > *IndexStreamData, bool bInIsReadonly=false)
void SetPosition(int32 Index, const FVector &Value)
bool SetUVs(const int32 InsertAtVertexIndex, const TArray< FVector2D > &UVs, const int32 CountVertices, const bool bSizeToFit)
void SetIndex(int32 Index, int32 Value)
FVector2D GetUV(int32 Index, int32 Channel=0) const
virtual ~FRuntimeMeshAccessor() override
TArray< uint8 > * PositionStream
ERuntimeMeshBuffersToUpdate
virtual ~FRuntimeMeshVerticesAccessor()
bool SetPositions(const int32 InsertAtIndex, const TArray< FVector > &Positions, const int32 Count, const bool bSizeToFit)
const int32 UVChannelCount
FRuntimeMeshDataPtr LinkedMeshData
const bool bUVHighPrecision
void SetTangents(int32 Index, FVector TangentX, FVector TangentY, FVector TangentZ)
FVector GetTangent(int32 Index) const
FRuntimeMeshBuilder(bool bInTangentsHighPrecision, bool bInUVsHighPrecision, int32 bInUVCount, bool bIn32BitIndices)
const int32 TangentStride
bool SetIndices(const int32 InsertAtIndex, const TArray< uint16 > &Indices, const int32 Count, const bool bSizeToFit)
FRuntimeMeshAccessorVertex GetVertex(int32 Index) const
int32 NumUVChannels() const
int32 AddIndex(int32 NewIndex)
int32 NumVertices() const
virtual ~FRuntimeMeshBuilder() override