RuntimeMeshCore.cpp
Go to the documentation of this file.
1 // Copyright 2016-2018 Chris Conway (Koderz). All Rights Reserved.
2 
3 #include "RuntimeMeshCore.h"
5 
6 
8 // FRuntimeMeshVertexStreamStructureElement
9 
11 {
12  return Offset == Other.Offset && Stride == Other.Stride && Type == Other.Type;
13 }
14 
16 {
17  return !(*this == Other);
18 }
19 
20 
22 // FRuntimeMeshVertexStreamStructure
23 
25 {
26  // First check the UVs
27  if (UVs.Num() != Other.UVs.Num())
28  {
29  return false;
30  }
31 
32  for (int32 Index = 0; Index < UVs.Num(); Index++)
33  {
34  if (UVs[Index] != Other.UVs[Index])
35  {
36  return false;
37  }
38  }
39 
40  // Then check the other components
41  return Position == Other.Position &&
42  Normal == Other.Normal &&
43  Tangent == Other.Tangent &&
44  Color == Other.Color;
45 }
46 
48 {
49  return !(*this == Other);
50 }
51 
53 {
54  static const auto IsElementValid = [](const FRuntimeMeshVertexStreamStructureElement& Element) -> bool
55  {
56  return Element.Type != EVertexElementType::VET_None;
57  };
58 
59  for (const auto& Elem : UVs)
60  {
61  if (IsElementValid(Elem))
62  {
63  return true;
64  }
65  }
66 
67  return IsElementValid(Position) || IsElementValid(Normal) || IsElementValid(Tangent) || IsElementValid(Color);
68 }
69 
71 {
72  return UVs.Num() > 0;
73 }
74 
76 {
77  uint8 MaxStride = 0;
78  const auto AddElement = [&MaxStride](const FRuntimeMeshVertexStreamStructureElement& Element)
79  {
80  if (Element.Type != EVertexElementType::VET_None)
81  {
82  check(MaxStride == 0 || Element.Stride == MaxStride || Element.Stride == 0);
83  MaxStride = FMath::Max(MaxStride, Element.Stride);
84  }
85  };
86 
87  AddElement(Position);
88  AddElement(Normal);
89  AddElement(Tangent);
90  for (const auto& Elem : UVs)
91  {
92  AddElement(Elem);
93  }
94  AddElement(Color);
95 
96 
97  return MaxStride;
98 }
99 
101 {
102  static const auto IsElementValid = [](const FRuntimeMeshVertexStreamStructureElement& Element) -> bool
103  {
104  return Element.Type == EVertexElementType::VET_None || Element.Stride > 0;
105  };
106 
107  for (const auto& Elem : UVs)
108  {
109  if (!IsElementValid(Elem))
110  {
111  return false;
112  }
113  }
114 
115  return IsElementValid(Position) && IsElementValid(Normal) && IsElementValid(Tangent) && IsElementValid(Color);
116 }
117 
119 {
120  static const auto HasNoOverlap = [](const FRuntimeMeshVertexStreamStructureElement& Left, const FRuntimeMeshVertexStreamStructureElement& Right) -> bool
121  {
122  return Left.Type == EVertexElementType::VET_None || Right.Type == EVertexElementType::VET_None;
123  };
124 
125  // two streams can't have UVs
126  if (UVs.Num() > 0 && Other.UVs.Num() > 0)
127  {
128  return false;
129  }
130 
131  // Now check overlap of the other components
132  return HasNoOverlap(Position, Other.Position) && HasNoOverlap(Normal, Other.Normal) && HasNoOverlap(Tangent, Other.Tangent) && HasNoOverlap(Color, Other.Color);
133 }
134 
136 {
137  return Stream1.IsValid() && Stream2.IsValid() && Stream3.IsValid() &&
138  Stream1.HasNoOverlap(Stream2) && Stream1.HasNoOverlap(Stream3) && Stream2.HasNoOverlap(Stream3) &&
139  Stream1.HasAnyElements() && Stream1.Position.IsValid() &&
140  (!Stream3.HasAnyElements() || Stream2.HasAnyElements());
141 }
FRuntimeMeshVertexStreamStructureElement Position
bool operator==(const FRuntimeMeshVertexStreamStructureElement &Other) const
FRuntimeMeshVertexStreamStructureElement Normal
bool operator!=(const FRuntimeMeshVertexStreamStructureElement &Other) const
static bool ValidTripleStream(const FRuntimeMeshVertexStreamStructure &Stream1, const FRuntimeMeshVertexStreamStructure &Stream2, const FRuntimeMeshVertexStreamStructure &Stream3)
bool HasNoOverlap(const FRuntimeMeshVertexStreamStructure &Other) const
TArray< FRuntimeMeshVertexStreamStructureElement, TInlineAllocator< RUNTIMEMESH_MAXTEXCOORDS > > UVs
static const textual_icon check
Definition: model-views.h:260
bool operator==(const FRuntimeMeshVertexStreamStructure &Other) const
bool operator!=(const FRuntimeMeshVertexStreamStructure &Other) const
FRuntimeMeshVertexStreamStructureElement Color
FRuntimeMeshVertexStreamStructureElement Tangent


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:41