RuntimeMeshLegacySerialization.cpp
Go to the documentation of this file.
1 // Copyright 2016-2018 Chris Conway (Koderz). All Rights Reserved.
2 
5 #include "RuntimeMeshCore.h"
6 
7 
9 {
10  TArray<FVector> VertexBuffer;
11  TArray<int32> IndexBuffer;
12 
13  friend FArchive& operator <<(FArchive& Ar, FRuntimeMeshCollisionSection_OLD& Section)
14  {
15  Ar << Section.VertexBuffer;
16  Ar << Section.IndexBuffer;
17  return Ar;
18  }
19 };
20 
22 {
23  TArray<FVector> VertexBuffer;
25 
26  friend FArchive& operator <<(FArchive& Ar, FRuntimeConvexCollisionSection_OLD& Section)
27  {
28  Ar << Section.VertexBuffer;
29  Ar << Section.BoundingBox;
30  return Ar;
31  }
32 };
33 
34 
36 {
37 
38  Ar.UsingCustomVersion(FRuntimeMeshVersion::GUID);
39 
40  // We bail here if this is a v3 file as the RMC doesn't serialize anything here
42  {
43  return false;
44  }
45 
46  check(Ar.IsLoading());
47 
49  {
50  SerializeV2(Ar);
51  }
52  else
53  {
54  SerializeV1(Ar);
55  }
56 
57  return true;
58 }
59 
60 
62 {
64  {
65  int32 SectionsCount;
66  Ar << SectionsCount;
67 
68  for (int32 Index = 0; Index < SectionsCount; Index++)
69  {
70  bool IsSectionValid;
71  Ar << IsSectionValid;
72 
73  if (IsSectionValid)
74  {
76  {
77  int32 NumUVChannels;
78  bool WantsHalfPrecisionUVs;
79 
80  Ar << NumUVChannels;
81  Ar << WantsHalfPrecisionUVs;
82 
83 
84  }
85  else
86  {
87  bool bWantsNormal;
88  bool bWantsTangent;
89  bool bWantsColor;
90  int32 TextureChannels;
91 
92  Ar << bWantsNormal;
93  Ar << bWantsTangent;
94  Ar << bWantsColor;
95  Ar << TextureChannels;
96  }
97 
98  SectionSerialize(Ar, false);
99  }
100  }
101  }
102 
104  {
105  // Serialize the collision data
106  TArray<FRuntimeMeshCollisionSection_OLD> MeshCollisionSections;
107  Ar << MeshCollisionSections;
108  TArray<FRuntimeConvexCollisionSection_OLD> ConvexCollisionSections;
109  Ar << ConvexCollisionSections;
110  }
111 }
112 
113 
115 {
116  bool bSerializeMeshData;
117  bool bUseComplexAsSimpleCollision;
118 
119  // Serialize basic settings
120  Ar << bSerializeMeshData;
121  Ar << bUseComplexAsSimpleCollision;
122 
123  // Serialize the number of sections...
124  int32 NumSections;
125  Ar << NumSections;
126 
127  // Next serialize all the sections...
128  for (int32 Index = 0; Index < NumSections; Index++)
129  {
130  SerializeRMCSection(Ar, Index);
131  }
132 
133 
134  // Serialize the collision data
135  TArray<FRuntimeMeshCollisionSection_OLD> MeshCollisionSections;
136  Ar << MeshCollisionSections;
137  TArray<FRuntimeConvexCollisionSection_OLD> ConvexCollisionSections;
138  Ar << ConvexCollisionSections;
139 }
140 
141 
142 
144 {
145  // Serialize the section validity (default it to section valid + type known for saving reasons)
146  bool bSectionIsValid;
147  Ar << bSectionIsValid;
148 
149  // If section is invalid, skip
150  if (!bSectionIsValid)
151  {
152  return;
153  }
154 
155  // Serialize section type info
156  FGuid TypeGuid;
157  bool bHasSeparatePositionBuffer;
158 
159  Ar << TypeGuid;
160  Ar << bHasSeparatePositionBuffer;
161 
162  // This is the raw section data, but we do nothing with it here since we don't have a good conversion path
163  TArray<uint8> SectionData;
164  Ar << SectionData;
165 }
166 
167 void FRuntimeMeshComponentLegacySerialization::SectionSerialize(FArchive& Ar, bool bNeedsPositionOnlyBuffer)
168 {
170  {
171  if (bNeedsPositionOnlyBuffer)
172  {
173  TArray<FVector> PositionVertexBuffer;
174  Ar << PositionVertexBuffer;
175  }
176  TArray<int32> IndexBuffer;
177  Ar << IndexBuffer;
178  TArray<int32> TessellationIndexBuffer;
179  Ar << TessellationIndexBuffer;
180  FBox LocalBoundingBox;
181  Ar << LocalBoundingBox;
182  bool CollisionEnabled;
183  Ar << CollisionEnabled;
184  bool bIsVisible;
185  Ar << bIsVisible;
186  bool bCastsShadow;
187  Ar << bCastsShadow;
188  bool bShouldUseAdjacencyIndexBuffer;
189  Ar << bShouldUseAdjacencyIndexBuffer;
190 
191  // Serialize the update frequency as an int32
192  int32 UpdateFreq;
193  Ar << UpdateFreq;
194 
195  bool bIsLegacySectionType;
196  Ar << bIsLegacySectionType;
197  }
198  else
199  {
201  {
202  TArray<FVector> PositionVertexBuffer;
203  Ar << PositionVertexBuffer;
204  }
205  TArray<int32> IndexBuffer;
206  Ar << IndexBuffer;
207  FBox LocalBoundingBox;
208  Ar << LocalBoundingBox;
209  bool CollisionEnabled;
210  Ar << CollisionEnabled;
211  bool bIsVisible;
212  Ar << bIsVisible;
213  int32 UpdateFreq;
214  Ar << UpdateFreq;
215  }
216 }
static void SerializeRMCSection(FArchive &Ar, int32 SectionIndex)
friend FArchive & operator<<(FArchive &Ar, FRuntimeMeshCollisionSection_OLD &Section)
static const textual_icon check
Definition: model-views.h:260
static const FGuid GUID
static void SectionSerialize(FArchive &Ar, bool bNeedsPositionOnlyBuffer)


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