RuntimeMeshComponent.h
Go to the documentation of this file.
1 // Copyright 2016-2018 Chris Conway (Koderz). All Rights Reserved.
2 
3 #pragma once
4 
5 #include "Components/MeshComponent.h"
6 #include "RuntimeMeshCore.h"
7 #include "RuntimeMeshSection.h"
9 #include "PhysicsEngine/ConvexElem.h"
10 #include "RuntimeMesh.h"
11 #include "Interfaces/Interface_CollisionDataProvider.h"
12 #include "RuntimeMeshComponent.generated.h"
13 
14 UENUM(BlueprintType) //"BlueprintType" is essential to include
15 enum class ERuntimeMeshSetAction : uint8
16 {
17  Create UMETA(DisplayName = "Created new section"),
18  Update UMETA(DisplayName = "Updated section"),
19  Remove UMETA(DisplayName = "Removed section"),
20  None UMETA(DisplayName = "Did nothing")
21 };
25 UCLASS(HideCategories = (Object, LOD), Meta = (BlueprintSpawnableComponent))
26 class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, public IInterface_CollisionDataProvider
27 {
28  GENERATED_BODY()
29 
30 private:
31 
32  UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = RuntimeMesh, Meta = (AllowPrivateAccess = "true", DisplayName = "Runtime Mesh"))
33  URuntimeMesh* RuntimeMeshReference;
34 
35  void EnsureHasRuntimeMesh();
36 
37 
38 
39 
40 public:
41 
42  URuntimeMeshComponent(const FObjectInitializer& ObjectInitializer);
43 
45  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
46  FORCEINLINE URuntimeMesh* GetRuntimeMesh() const
47  {
48  return RuntimeMeshReference;
49  }
50 
52  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
53  FORCEINLINE URuntimeMesh* GetOrCreateRuntimeMesh()
54  {
55  EnsureHasRuntimeMesh();
56 
57  return RuntimeMeshReference;
58  }
59 
60  FORCEINLINE FRuntimeMeshDataRef GetRuntimeMeshData()
61  {
62  return GetRuntimeMesh() ? GetRuntimeMesh()->GetRuntimeMeshData() : FRuntimeMeshDataRef();
63  }
64 
65  FORCEINLINE FRuntimeMeshDataRef GetOrCreateRuntimeMeshData()
66  {
67  return GetOrCreateRuntimeMesh()->GetRuntimeMeshData();
68  }
69 
70  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
71  bool ShouldSerializeMeshData()
72  {
73  return GetRuntimeMesh() ? GetRuntimeMesh()->ShouldSerializeMeshData() : false;
74  }
75 
76  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
77  void SetShouldSerializeMeshData(bool bShouldSerialize)
78  {
79  GetOrCreateRuntimeMesh()->SetShouldSerializeMeshData(bShouldSerialize);
80  }
81 
82  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", Meta = (AllowPrivateAccess = "true", DisplayName = "Get Mobility"))
83  ERuntimeMeshMobility GetRuntimeMeshMobility()
84  {
85  return Mobility == EComponentMobility::Movable ? ERuntimeMeshMobility::Movable :
86  Mobility == EComponentMobility::Stationary ? ERuntimeMeshMobility::Stationary : ERuntimeMeshMobility::Static;
87  }
88 
89  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", Meta = (AllowPrivateAccess = "true", DisplayName = "Set Mobility"))
90  void SetRuntimeMeshMobility(ERuntimeMeshMobility NewMobility)
91  {
92  Super::SetMobility(
93  NewMobility == ERuntimeMeshMobility::Movable ? EComponentMobility::Movable :
94  NewMobility == ERuntimeMeshMobility::Stationary ? EComponentMobility::Stationary : EComponentMobility::Static);
95  }
96 
97  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
98  void SetRuntimeMesh(URuntimeMesh* NewMesh);
99 
100 
101  void CreateMeshSection(int32 SectionIndex, bool bWantsHighPrecisionTangents, bool bWantsHighPrecisionUVs, int32 NumUVs, bool bWants32BitIndices, bool bCreateCollision, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average)
102  {
103  GetOrCreateRuntimeMesh()->CreateMeshSection(SectionIndex, bWantsHighPrecisionTangents, bWantsHighPrecisionUVs, NumUVs, bWants32BitIndices, bCreateCollision, UpdateFrequency);
104  }
105 
108 
109  /*
110  * Creates the mesh section if it doesn't exist,
111  * Otherwise update the section.
112  * Will automatically delete the section if there are no vertices given
113  */
114  template<typename VertexType0, typename IndexType>
115  ERuntimeMeshSetAction SetMeshSection(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<IndexType>& InTriangles, bool bCreateCollision = false,
116  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
117  {
118  if (GetOrCreateRuntimeMeshData()->DoesSectionExist(SectionIndex)) {
119  if (InVertices0.Num() == 0) {
120  ClearMeshSection(SectionIndex);
121  return ERuntimeMeshSetAction::Remove;
122  }
123  else {
124  UpdateMeshSection(SectionIndex, InVertices0, InTriangles, UpdateFlags);
125  return ERuntimeMeshSetAction::Update;
126  }
127  }
128  else if (InVertices0.Num() != 0) {
129  CreateMeshSection(SectionIndex, InVertices0, InTriangles, bCreateCollision, UpdateFrequency, UpdateFlags);
130  return ERuntimeMeshSetAction::Create;
131  }
132  return ERuntimeMeshSetAction::None;
133  }
134 
135  /*
136  * Creates the mesh section if it doesn't exist,
137  * Otherwise update the section.
138  * Will automatically delete the section if there are no vertices given
139  */
140  ERuntimeMeshSetAction SetMeshSection(int32 SectionId, const TSharedPtr<FRuntimeMeshBuilder>& MeshData, bool bCreateCollision = false,
141  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
142  {
143  if (GetOrCreateRuntimeMeshData()->DoesSectionExist(SectionId)) {
144  if (MeshData->NumIndices() == 0) {
145  GetOrCreateRuntimeMeshData()->ClearMeshSection(SectionId);
146  return ERuntimeMeshSetAction::Remove;
147  }
148  else {
149  GetOrCreateRuntimeMeshData()->UpdateMeshSection(SectionId, MeshData, UpdateFlags);
150  return ERuntimeMeshSetAction::Update;
151  }
152  }
153  else if (MeshData->NumIndices() != 0) {
154  GetOrCreateRuntimeMeshData()->CreateMeshSection(SectionId, MeshData, bCreateCollision, UpdateFrequency, UpdateFlags);
155  return ERuntimeMeshSetAction::Create;
156  }
157  return ERuntimeMeshSetAction::None;
158  }
159 
160  /*
161  * Creates the mesh section if it doesn't exist,
162  * Otherwise update the section.
163  * Will automatically delete the section if there are no vertices given
164  */
165  ERuntimeMeshSetAction SetMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
166  const TArray<FVector2D>& UV0, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, bool bCreateCollision = false,
167  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None,
168  bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
169  {
170  if (GetOrCreateRuntimeMeshData()->DoesSectionExist(SectionIndex)) {
171  if (Vertices.Num() == 0) {
172  GetOrCreateRuntimeMeshData()->ClearMeshSection(SectionIndex);
173  return ERuntimeMeshSetAction::Remove;
174  }
175  else {
176  UpdateMeshSection(SectionIndex, Vertices, Triangles, Normals, UV0, Colors, Tangents, UpdateFlags);
177  return ERuntimeMeshSetAction::Update;
178  }
179  }
180  else if (Vertices.Num() != 0) {
181  CreateMeshSection(SectionIndex, Vertices, Triangles, Normals, UV0, Colors, Tangents, bCreateCollision,
182  UpdateFrequency, UpdateFlags, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
183  return ERuntimeMeshSetAction::Create;
184  }
185  return ERuntimeMeshSetAction::None;
186  }
187 
188  /*
189  * Creates the mesh section if it doesn't exist,
190  * Otherwise update the section.
191  * Will automatically delete the section if there are no vertices given
192  */
193  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", meta = (DisplayName = "Set Mesh Section", AutoCreateRefTerm = "Normals,Tangents,UV0,UV1,Colors"))
194  ERuntimeMeshSetAction SetMeshSection_Blueprint(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
195  const TArray<FRuntimeMeshTangent>& Tangents, const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, const TArray<FLinearColor>& Colors,
196  bool bCreateCollision = false, bool bCalculateNormalTangent = false, bool bShouldCreateHardTangents = false, bool bGenerateTessellationTriangles = false,
197  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
198  {
199  if (DoesSectionExist(SectionIndex)) {
200  if (Vertices.Num() == 0) {
201  ClearMeshSection(SectionIndex);
202  return ERuntimeMeshSetAction::Remove;
203  }
204  else {
205  UpdateMeshSection_Blueprint(SectionIndex, Vertices, Triangles, Normals, Tangents, UV0, UV1, Colors,
206  bCalculateNormalTangent, bShouldCreateHardTangents, bGenerateTessellationTriangles);
207  return ERuntimeMeshSetAction::Update;
208  }
209  }
210  else if (Vertices.Num() != 0) {
211  CreateMeshSection_Blueprint(SectionIndex, Vertices, Triangles, Normals, Tangents, UV0, UV1, Colors, bCreateCollision,
212  bCalculateNormalTangent, bShouldCreateHardTangents, bGenerateTessellationTriangles, UpdateFrequency, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
213  return ERuntimeMeshSetAction::Create;
214  }
215  return ERuntimeMeshSetAction::None;
216  }
217 
218  /*
219  * Creates the mesh section if it doesn't exist,
220  * Otherwise update the section.
221  * Will automatically delete the section if there are no vertices given
222  */
223  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", meta = (DisplayName = "Set Mesh Section Packed", AutoCreateRefTerm = "Normals,Tangents,UV0,UV1,Colors"))
224  ERuntimeMeshSetAction SetMeshSectionPacked_Blueprint(int32 SectionIndex, const TArray<FRuntimeMeshBlueprintVertexSimple>& Vertices, const TArray<int32>& Triangles,
225  bool bCreateCollision = false, bool bCalculateNormalTangent = false, bool bShouldCreateHardTangents = false, bool bGenerateTessellationTriangles = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average,
226  bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
227  {
228  if (DoesSectionExist(SectionIndex)) {
229  if (Vertices.Num() == 0) {
230  ClearMeshSection(SectionIndex);
231  return ERuntimeMeshSetAction::Remove;
232  }
233  else {
234  UpdateMeshSectionPacked_Blueprint(SectionIndex, Vertices, Triangles, bCalculateNormalTangent, bShouldCreateHardTangents,
235  bGenerateTessellationTriangles);
236  return ERuntimeMeshSetAction::Update;
237  }
238  }
239  else if (Vertices.Num() != 0) {
240  CreateMeshSectionPacked_Blueprint(SectionIndex, Vertices, Triangles, bCreateCollision, bCalculateNormalTangent, bShouldCreateHardTangents,
241  bGenerateTessellationTriangles, UpdateFrequency, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
242  return ERuntimeMeshSetAction::Create;
243  }
244  return ERuntimeMeshSetAction::None;
245  }
246 
249 
250  template<typename VertexType0, typename IndexType>
251  FORCEINLINE void CreateMeshSection(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<IndexType>& InTriangles, bool bCreateCollision = false,
252  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
253  {
254  GetOrCreateRuntimeMesh()->CreateMeshSection(SectionIndex, InVertices0, InTriangles, bCreateCollision, UpdateFrequency, UpdateFlags);
255  }
256 
257  template<typename VertexType0, typename IndexType>
258  FORCEINLINE void CreateMeshSection(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<IndexType>& InTriangles, const FBox& BoundingBox,
259  bool bCreateCollision = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
260  {
261  GetOrCreateRuntimeMesh()->CreateMeshSection(SectionIndex, InVertices0, InTriangles, BoundingBox, bCreateCollision, UpdateFrequency, UpdateFlags);
262  }
263 
264  template<typename VertexType0, typename VertexType1, typename IndexType>
265  FORCEINLINE void CreateMeshSectionDualBuffer(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<IndexType>& InTriangles, bool bCreateCollision = false,
266  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
267  {
268  GetOrCreateRuntimeMesh()->CreateMeshSectionDualBuffer(SectionIndex, InVertices0, InVertices1, InTriangles, bCreateCollision, UpdateFrequency, UpdateFlags);
269  }
270 
271  template<typename VertexType0, typename VertexType1, typename IndexType>
272  FORCEINLINE void CreateMeshSectionDualBuffer(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<IndexType>& InTriangles, const FBox& BoundingBox,
273  bool bCreateCollision = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
274  {
275  GetOrCreateRuntimeMesh()->CreateMeshSectionDualBuffer(SectionIndex, InVertices0, InVertices1, InTriangles, BoundingBox, bCreateCollision, UpdateFrequency, UpdateFlags);
276  }
277 
278  template<typename VertexType0, typename VertexType1, typename VertexType2, typename IndexType>
279  FORCEINLINE void CreateMeshSectionTripleBuffer(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2, TArray<IndexType>& InTriangles,
280  bool bCreateCollision = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
281  {
282  GetOrCreateRuntimeMesh()->CreateMeshSectionTripleBuffer(SectionIndex, InVertices0, InVertices1, InVertices2, InTriangles, bCreateCollision, UpdateFrequency, UpdateFlags);
283  }
284 
285  template<typename VertexType0, typename VertexType1, typename VertexType2, typename IndexType>
286  FORCEINLINE void CreateMeshSectionTripleBuffer(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2, TArray<IndexType>& InTriangles,
287  const FBox& BoundingBox, bool bCreateCollision = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
288  {
289  GetOrCreateRuntimeMesh()->CreateMeshSectionTripleBuffer(SectionIndex, InVertices0, InVertices1, InVertices2, InTriangles, BoundingBox, bCreateCollision, UpdateFrequency, UpdateFlags);
290  }
291 
292 
293 
294 
295 
296 
297 
298  template<typename VertexType0>
299  FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray<VertexType0>& InVertices0,
301  {
302  GetOrCreateRuntimeMesh()->UpdateMeshSection(SectionId, InVertices0, UpdateFlags);
303  }
304 
305  template<typename VertexType0>
306  FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray<VertexType0>& InVertices0,
307  const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
308  {
309  GetOrCreateRuntimeMesh()->UpdateMeshSection(SectionId, InVertices0, BoundingBox, UpdateFlags);
310  }
311 
312  template<typename VertexType0, typename IndexType>
313  FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<IndexType>& InTriangles,
315  {
316  GetOrCreateRuntimeMesh()->UpdateMeshSection(SectionId, InVertices0, InTriangles, UpdateFlags);
317  }
318 
319  template<typename VertexType0, typename IndexType>
320  FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<IndexType>& InTriangles,
321  const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
322  {
323  GetOrCreateRuntimeMesh()->UpdateMeshSection(SectionId, InVertices0, InTriangles, BoundingBox, UpdateFlags);
324  }
325 
326  template<typename VertexType0, typename VertexType1>
327  FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1,
329  {
330  GetOrCreateRuntimeMesh()->UpdateMeshSectionDualBuffer(SectionId, InVertices0, InVertices1, UpdateFlags);
331  }
332 
333  template<typename VertexType0, typename VertexType1>
334  FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1,
335  const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
336  {
337  GetOrCreateRuntimeMesh()->UpdateMeshSectionDualBuffer(SectionId, InVertices0, InVertices1, BoundingBox, UpdateFlags);
338  }
339 
340  template<typename VertexType0, typename VertexType1, typename IndexType>
341  FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1,
342  TArray<IndexType>& InTriangles, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
343  {
344  GetOrCreateRuntimeMesh()->UpdateMeshSectionDualBuffer(SectionId, InVertices0, InVertices1, InTriangles, UpdateFlags);
345  }
346 
347  template<typename VertexType0, typename VertexType1, typename IndexType>
348  FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<IndexType>& InTriangles,
349  const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
350  {
351  GetOrCreateRuntimeMesh()->UpdateMeshSectionDualBuffer(SectionId, InVertices0, InVertices1, InTriangles, BoundingBox, UpdateFlags);
352  }
353 
354  template<typename VertexType0, typename VertexType1, typename VertexType2>
355  FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2,
357  {
358  GetOrCreateRuntimeMesh()->UpdateMeshSectionTripleBuffer(SectionId, InVertices0, InVertices1, InVertices2, UpdateFlags);
359  }
360 
361  template<typename VertexType0, typename VertexType1, typename VertexType2>
362  FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2,
363  const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
364  {
365  GetOrCreateRuntimeMesh()->UpdateMeshSectionTripleBuffer(SectionId, InVertices0, InVertices1, InVertices2, BoundingBox, UpdateFlags);
366  }
367 
368  template<typename VertexType0, typename VertexType1, typename VertexType2, typename IndexType>
369  FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2,
370  TArray<IndexType>& InTriangles, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
371  {
372  GetOrCreateRuntimeMesh()->UpdateMeshSectionTripleBuffer(SectionId, InVertices0, InVertices1, InVertices2, InTriangles, UpdateFlags);
373  }
374 
375  template<typename VertexType0, typename VertexType1, typename VertexType2, typename IndexType>
376  FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2,
377  TArray<IndexType>& InTriangles, const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
378  {
379  GetOrCreateRuntimeMesh()->UpdateMeshSectionTripleBuffer(SectionId, InVertices0, InVertices1, InVertices2, InTriangles, BoundingBox, UpdateFlags);
380  }
381 
382 
383 
384 
386  template<typename VertexType>
387  UE_DEPRECATED(3.0, "UpdateMeshSection for dual buffer sections deprecated. Please use UpdateMeshSectionDualBuffer instead.")
388  void UpdateMeshSection(int32 SectionIndex, TArray<FVector>& VertexPositions, TArray<VertexType>& VertexData, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
389  {
390  UpdateMeshSectionDualBuffer(SectionIndex, VertexPositions, VertexData, UpdateFlags);
391  }
392 
394  template<typename VertexType>
395  UE_DEPRECATED(3.0, "UpdateMeshSection for dual buffer sections deprecated. Please use UpdateMeshSectionDualBuffer instead.")
396  void UpdateMeshSection(int32 SectionIndex, TArray<FVector>& VertexPositions, TArray<VertexType>& VertexData, const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
397  {
398  UpdateMeshSectionDualBuffer(SectionIndex, VertexPositions, VertexData, BoundingBox, UpdateFlags);
399  }
400 
402  template<typename VertexType>
403  UE_DEPRECATED(3.0, "UpdateMeshSection for dual buffer sections deprecated. Please use UpdateMeshSectionDualBuffer instead.")
404  void UpdateMeshSection(int32 SectionIndex, TArray<FVector>& VertexPositions, TArray<VertexType>& VertexData, TArray<int32>& Triangles, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
405  {
406  UpdateMeshSectionDualBuffer(SectionIndex, VertexPositions, VertexData, Triangles, UpdateFlags);
407  }
408 
410  template<typename VertexType>
411  UE_DEPRECATED(3.0, "UpdateMeshSection for dual buffer sections deprecated. Please use UpdateMeshSectionDualBuffer instead.")
412  void UpdateMeshSection(int32 SectionIndex, TArray<FVector>& VertexPositions, TArray<VertexType>& VertexData, TArray<int32>& Triangles, const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
413  {
414  UpdateMeshSectionDualBuffer(SectionIndex, VertexPositions, VertexData, Triangles, BoundingBox, UpdateFlags);
415  }
416 
417 
418 
419 
420 
421  template<typename VertexType0>
422  FORCEINLINE void UpdateMeshSectionPrimaryBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
423  {
424  GetOrCreateRuntimeMesh()->UpdateMeshSectionPrimaryBuffer(SectionId, InVertices0, UpdateFlags);
425  }
426 
427  template<typename VertexType0>
428  FORCEINLINE void UpdateMeshSectionPrimaryBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
429  {
430  GetOrCreateRuntimeMesh()->UpdateMeshSectionPrimaryBuffer(SectionId, InVertices0, BoundingBox, UpdateFlags);
431  }
432 
433  template<typename VertexType1>
434  FORCEINLINE void UpdateMeshSectionSecondaryBuffer(int32 SectionId, TArray<VertexType1>& InVertices1, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
435  {
436  GetOrCreateRuntimeMesh()->UpdateMeshSectionSecondaryBuffer(SectionId, InVertices1, UpdateFlags);
437  }
438 
439  template<typename VertexType2>
440  FORCEINLINE void UpdateMeshSectionTertiaryBuffer(int32 SectionId, TArray<VertexType2>& InVertices2, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
441  {
442  GetOrCreateRuntimeMesh()->UpdateMeshSectionTertiaryBuffer(SectionId, InVertices2, UpdateFlags);
443  }
444 
445  template<typename IndexType>
446  FORCEINLINE void UpdateMeshSectionTriangles(int32 SectionId, TArray<IndexType>& InTriangles, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
447  {
448  GetOrCreateRuntimeMesh()->UpdateMeshSectionTriangles(SectionId, InTriangles, UpdateFlags);
449  }
450 
451 
452 
453  FORCEINLINE void CreateMeshSection(int32 SectionId, const TSharedPtr<FRuntimeMeshBuilder>& MeshData, bool bCreateCollision = false,
454  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
455  {
456  GetOrCreateRuntimeMesh()->CreateMeshSection(SectionId, MeshData, bCreateCollision, UpdateFrequency, UpdateFlags);
457  }
458 
459  FORCEINLINE void CreateMeshSectionByMove(int32 SectionId, const TSharedPtr<FRuntimeMeshBuilder>& MeshData, bool bCreateCollision = false,
460  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
461  {
462  GetOrCreateRuntimeMesh()->CreateMeshSectionByMove(SectionId, MeshData, bCreateCollision, UpdateFrequency, UpdateFlags);
463  }
464 
465  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
466  void CreateMeshSectionFromBuilder(int32 SectionId, URuntimeBlueprintMeshBuilder* MeshData, bool bCreateCollision = false,
467  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average/*, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None*/)
468  {
469  GetOrCreateRuntimeMesh()->CreateMeshSectionFromBuilder(SectionId, MeshData, bCreateCollision, UpdateFrequency/*, UpdateFlags*/);
470  }
471 
472 
473 
474  FORCEINLINE void UpdateMeshSection(int32 SectionId, const TSharedPtr<FRuntimeMeshBuilder>& MeshData, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
475  {
476  GetOrCreateRuntimeMesh()->UpdateMeshSection(SectionId, MeshData, UpdateFlags);
477  }
478 
479  FORCEINLINE void UpdateMeshSectionByMove(int32 SectionId, const TSharedPtr<FRuntimeMeshBuilder>& MeshData, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
480  {
481  GetOrCreateRuntimeMesh()->UpdateMeshSectionByMove(SectionId, MeshData, UpdateFlags);
482  }
483 
484  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
485  void UpdateMeshSectionFromBuilder(int32 SectionId, URuntimeBlueprintMeshBuilder* MeshData/*, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None*/)
486  {
487  GetOrCreateRuntimeMesh()->UpdateMeshSectionFromBuilder(SectionId, MeshData/*, UpdateFlags*/);
488  }
489 
490 
491  TUniquePtr<FRuntimeMeshScopedUpdater> BeginSectionUpdate(int32 SectionId, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
492  {
493  check(IsInGameThread());
494  return GetOrCreateRuntimeMesh()->BeginSectionUpdate(SectionId, UpdateFlags);
495  }
496 
497  TUniquePtr<FRuntimeMeshScopedUpdater> GetSectionReadonly(int32 SectionId)
498  {
499  check(IsInGameThread());
500  return GetOrCreateRuntimeMesh()->GetSectionReadonly(SectionId);
501  }
502 
503 
504 
505  FORCEINLINE void CreateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
506  const TArray<FVector2D>& UV0, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, bool bCreateCollision = false,
507  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None,
508  bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
509  {
510  GetOrCreateRuntimeMesh()->CreateMeshSection(SectionIndex, Vertices, Triangles, Normals, UV0, Colors, Tangents, bCreateCollision,
511  UpdateFrequency, UpdateFlags, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
512  }
513 
514  FORCEINLINE void CreateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
515  const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents,
516  bool bCreateCollision = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None,
517  bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
518  {
519  GetOrCreateRuntimeMesh()->CreateMeshSection(SectionIndex, Vertices, Triangles, Normals, UV0, UV1, Colors, Tangents, bCreateCollision,
520  UpdateFrequency, UpdateFlags, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
521  }
522 
523 
524  FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<FVector>& Normals, const TArray<FVector2D>& UV0,
525  const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
526  {
527  GetOrCreateRuntimeMesh()->UpdateMeshSection(SectionIndex, Vertices, Normals, UV0, Colors, Tangents, UpdateFlags);
528  }
529 
530  FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<FVector>& Normals, const TArray<FVector2D>& UV0,
531  const TArray<FVector2D>& UV1, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
532  {
533  GetOrCreateRuntimeMesh()->UpdateMeshSection(SectionIndex, Vertices, Normals, UV0, UV1, Colors, Tangents, UpdateFlags);
534  }
535 
536  FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
537  const TArray<FVector2D>& UV0, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
538  {
539  GetOrCreateRuntimeMesh()->UpdateMeshSection(SectionIndex, Vertices, Triangles, Normals, UV0, Colors, Tangents, UpdateFlags);
540  }
541 
542  FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
543  const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
544  {
545  GetOrCreateRuntimeMesh()->UpdateMeshSection(SectionIndex, Vertices, Triangles, Normals, UV0, UV1, Colors, Tangents, UpdateFlags);
546  }
547 
548 
549 
550  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", meta = (DisplayName = "Create Mesh Section", AutoCreateRefTerm = "Normals,Tangents,UV0,UV1,Colors"))
551  void CreateMeshSection_Blueprint(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
552  const TArray<FRuntimeMeshTangent>& Tangents, const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, const TArray<FLinearColor>& Colors,
553  bool bCreateCollision = false, bool bCalculateNormalTangent = false, bool bShouldCreateHardTangents = false, bool bGenerateTessellationTriangles = false,
554  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
555  {
556  GetOrCreateRuntimeMesh()->CreateMeshSection_Blueprint(SectionIndex, Vertices, Triangles, Normals, Tangents, UV0, UV1, Colors, bCreateCollision,
557  bCalculateNormalTangent, bShouldCreateHardTangents, bGenerateTessellationTriangles, UpdateFrequency, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
558  }
559 
560  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", meta = (DisplayName = "Update Mesh Section", AutoCreateRefTerm = "Triangles,Normals,Tangents,UV0,UV1,Colors"))
561  void UpdateMeshSection_Blueprint(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
562  const TArray<FRuntimeMeshTangent>& Tangents, const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, const TArray<FLinearColor>& Colors,
563  bool bCalculateNormalTangent = false, bool bShouldCreateHardTangents = false, bool bGenerateTessellationTriangles = false)
564  {
565  GetOrCreateRuntimeMesh()->UpdateMeshSection_Blueprint(SectionIndex, Vertices, Triangles, Normals, Tangents, UV0, UV1, Colors, bCalculateNormalTangent, bShouldCreateHardTangents, bGenerateTessellationTriangles);
566  }
567 
568  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", meta = (DisplayName = "Create Mesh Section Packed", AutoCreateRefTerm = "Normals,Tangents,UV0,UV1,Colors"))
569  void CreateMeshSectionPacked_Blueprint(int32 SectionIndex, const TArray<FRuntimeMeshBlueprintVertexSimple>& Vertices, const TArray<int32>& Triangles,
570  bool bCreateCollision = false, bool bCalculateNormalTangent = false, bool bShouldCreateHardTangents = false, bool bGenerateTessellationTriangles = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average,
571  bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
572  {
573  GetOrCreateRuntimeMesh()->CreateMeshSectionPacked_Blueprint(SectionIndex, Vertices, Triangles, bCreateCollision, bCalculateNormalTangent, bShouldCreateHardTangents,
574  bGenerateTessellationTriangles, UpdateFrequency, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
575  }
576 
577  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", meta = (DisplayName = "Update Mesh Section Packed", AutoCreateRefTerm = "Triangles,Normals,Tangents,UV0,UV1,Colors"))
578  void UpdateMeshSectionPacked_Blueprint(int32 SectionIndex, const TArray<FRuntimeMeshBlueprintVertexSimple>& Vertices, const TArray<int32>& Triangles,
579  bool bCalculateNormalTangent = false, bool bShouldCreateHardTangents = false, bool bGenerateTessellationTriangles = false)
580  {
581  GetOrCreateRuntimeMesh()->UpdateMeshSectionPacked_Blueprint(SectionIndex, Vertices, Triangles, bCalculateNormalTangent, bShouldCreateHardTangents, bGenerateTessellationTriangles);
582  }
583 
584 
585 
586 
587 
588 
590  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
591  void ClearMeshSection(int32 SectionIndex)
592  {
593  if (URuntimeMesh* Mesh = GetRuntimeMesh())
594  {
595  Mesh->ClearMeshSection(SectionIndex);
596  }
597  }
598 
600  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
601  void ClearAllMeshSections()
602  {
603  if (URuntimeMesh* Mesh = GetRuntimeMesh())
604  {
605  Mesh->ClearAllMeshSections();
606  }
607  }
608 
609 
610 
611  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
612  void SetSectionMaterial(int32 SectionId, UMaterialInterface* Material)
613  {
614  if (URuntimeMesh* Mesh = GetRuntimeMesh())
615  {
616  Mesh->SetSectionMaterial(SectionId, Material);
617  }
618  }
619 
620  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
621  UMaterialInterface* GetSectionMaterial(int32 SectionId)
622  {
623  if (URuntimeMesh* Mesh = GetRuntimeMesh())
624  {
625  return Mesh->GetSectionMaterial(SectionId);
626  }
627  return nullptr;
628  }
629 
631  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
632  FBox GetSectionBoundingBox(int32 SectionIndex)
633  {
634  if (URuntimeMesh* Mesh = GetRuntimeMesh())
635  {
636  return Mesh->GetSectionBoundingBox(SectionIndex);
637  }
638  return FBox(EForceInit::ForceInitToZero);
639  }
640 
642  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
643  void SetMeshSectionVisible(int32 SectionIndex, bool bNewVisibility)
644  {
645  if (URuntimeMesh* Mesh = GetRuntimeMesh())
646  {
647  Mesh->SetMeshSectionVisible(SectionIndex, bNewVisibility);
648  }
649  }
650 
652  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
653  bool IsMeshSectionVisible(int32 SectionIndex) const
654  {
655  if (URuntimeMesh* Mesh = GetRuntimeMesh())
656  {
657  return Mesh->IsMeshSectionVisible(SectionIndex);
658  }
659  return false;
660  }
661 
662 
664  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
665  void SetMeshSectionCastsShadow(int32 SectionIndex, bool bNewCastsShadow)
666  {
667  if (URuntimeMesh* Mesh = GetRuntimeMesh())
668  {
669  Mesh->SetMeshSectionCastsShadow(SectionIndex, bNewCastsShadow);
670  }
671  }
672 
674  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
675  bool IsMeshSectionCastingShadows(int32 SectionIndex) const
676  {
677  if (URuntimeMesh* Mesh = GetRuntimeMesh())
678  {
679  return Mesh->IsMeshSectionCastingShadows(SectionIndex);
680  }
681  return false;
682  }
683 
684 
686  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
687  void SetMeshSectionCollisionEnabled(int32 SectionIndex, bool bNewCollisionEnabled)
688  {
689  if (URuntimeMesh* Mesh = GetRuntimeMesh())
690  {
691  Mesh->SetMeshSectionCollisionEnabled(SectionIndex, bNewCollisionEnabled);
692  }
693  }
694 
696  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
697  bool IsMeshSectionCollisionEnabled(int32 SectionIndex)
698  {
699  if (URuntimeMesh* Mesh = GetRuntimeMesh())
700  {
701  return Mesh->IsMeshSectionCollisionEnabled(SectionIndex);
702  }
703  return false;
704  }
705 
706 
708  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
709  int32 GetNumSections() const
710  {
711  if (URuntimeMesh* Mesh = GetRuntimeMesh())
712  {
713  return Mesh->GetNumSections();
714  }
715  return 0;
716  }
717 
719  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
720  bool DoesSectionExist(int32 SectionIndex) const
721  {
722  if (URuntimeMesh* Mesh = GetRuntimeMesh())
723  {
724  return Mesh->DoesSectionExist(SectionIndex);
725  }
726  return false;
727  }
728 
730  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
731  int32 GetAvailableSectionIndex() const
732  {
733  if (URuntimeMesh* Mesh = GetRuntimeMesh())
734  {
735  return Mesh->GetAvailableSectionIndex();
736  }
737  return 0;
738  }
739 
740 
741 
742 
743 
744 
745 
746 
747 
748  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
749  void SetMeshCollisionSection(int32 CollisionSectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles)
750  {
751  GetOrCreateRuntimeMesh()->SetMeshCollisionSection(CollisionSectionIndex, Vertices, Triangles);
752  }
753 
754  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
755  void ClearMeshCollisionSection(int32 CollisionSectionIndex)
756  {
757  GetOrCreateRuntimeMesh()->ClearMeshCollisionSection(CollisionSectionIndex);
758  }
759 
760  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
761  void ClearAllMeshCollisionSections()
762  {
763  GetOrCreateRuntimeMesh()->ClearAllMeshCollisionSections();
764  }
765 
766 
767 
768  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
769  int32 AddConvexCollisionSection(TArray<FVector> ConvexVerts)
770  {
771  return GetOrCreateRuntimeMesh()->AddConvexCollisionSection(ConvexVerts);
772  }
773 
774  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
775  void SetConvexCollisionSection(int32 ConvexSectionIndex, TArray<FVector> ConvexVerts)
776  {
777  GetOrCreateRuntimeMesh()->SetConvexCollisionSection(ConvexSectionIndex, ConvexVerts);
778  }
779 
780  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
781  void ClearConvexCollisionSection(int32 ConvexSectionIndex)
782  {
783  GetOrCreateRuntimeMesh()->ClearConvexCollisionSection(ConvexSectionIndex);
784  }
785 
786  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
787  void ClearAllConvexCollisionSections()
788  {
789  GetOrCreateRuntimeMesh()->ClearAllConvexCollisionSections();
790  }
791 
792  void SetCollisionConvexMeshes(const TArray<TArray<FVector>>& ConvexMeshes)
793  {
794  GetOrCreateRuntimeMesh()->SetCollisionConvexMeshes(ConvexMeshes);
795  }
796 
797 
798  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
799  int32 AddCollisionBox(const FRuntimeMeshCollisionBox& NewBox)
800  {
801  return GetOrCreateRuntimeMesh()->AddCollisionBox(NewBox);
802  }
803 
804  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
805  void RemoveCollisionBox(int32 Index)
806  {
807  GetOrCreateRuntimeMesh()->RemoveCollisionBox(Index);
808  }
809 
810  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
811  void ClearCollisionBoxes()
812  {
813  GetOrCreateRuntimeMesh()->ClearCollisionBoxes();
814  }
815 
816  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
817  void SetCollisionBoxes(const TArray<FRuntimeMeshCollisionBox>& NewBoxes)
818  {
819  GetOrCreateRuntimeMesh()->SetCollisionBoxes(NewBoxes);
820  }
821 
822 
823  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
824  int32 AddCollisionSphere(const FRuntimeMeshCollisionSphere& NewSphere)
825  {
826  return GetOrCreateRuntimeMesh()->AddCollisionSphere(NewSphere);
827  }
828 
829  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
830  void RemoveCollisionSphere(int32 Index)
831  {
832  GetOrCreateRuntimeMesh()->RemoveCollisionSphere(Index);
833  }
834 
835  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
836  void ClearCollisionSpheres()
837  {
838  GetOrCreateRuntimeMesh()->ClearCollisionSpheres();
839  }
840 
841  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
842  void SetCollisionSpheres(const TArray<FRuntimeMeshCollisionSphere>& NewSpheres)
843  {
844  GetOrCreateRuntimeMesh()->SetCollisionSpheres(NewSpheres);
845  }
846 
847 
848  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
849  int32 AddCollisionCapsule(const FRuntimeMeshCollisionCapsule& NewCapsule)
850  {
851  return GetOrCreateRuntimeMesh()->AddCollisionCapsule(NewCapsule);
852  }
853 
854  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
855  void RemoveCollisionCapsule(int32 Index)
856  {
857  GetOrCreateRuntimeMesh()->RemoveCollisionCapsule(Index);
858  }
859 
860  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
861  void ClearCollisionCapsules()
862  {
863  GetOrCreateRuntimeMesh()->ClearCollisionCapsules();
864  }
865 
866  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
867  void SetCollisionCapsules(const TArray<FRuntimeMeshCollisionCapsule>& NewCapsules)
868  {
869  GetOrCreateRuntimeMesh()->SetCollisionCapsules(NewCapsules);
870  }
871 
872 
874  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
875  void CookCollisionNow()
876  {
877  GetOrCreateRuntimeMesh()->CookCollisionNow();
878  }
879 
880  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
881  void SetCollisionUseComplexAsSimple(bool bNewValue)
882  {
883  GetOrCreateRuntimeMesh()->SetCollisionUseComplexAsSimple(bNewValue);
884  }
885 
886  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
887  bool IsCollisionUsingComplexAsSimple()
888  {
889  check(IsInGameThread());
890  return GetRuntimeMesh() != nullptr ? GetRuntimeMesh()->IsCollisionUsingComplexAsSimple() : true;
891  }
892 
893  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
894  void SetCollisionUseAsyncCooking(bool bNewValue)
895  {
896  GetOrCreateRuntimeMesh()->SetCollisionUseAsyncCooking(bNewValue);
897  }
898 
899  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
900  bool IsCollisionUsingAsyncCooking()
901  {
902  check(IsInGameThread());
903  return GetRuntimeMesh() != nullptr ? GetRuntimeMesh()->IsCollisionUsingAsyncCooking() : false;
904  }
905 
906  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
907  void SetCollisionMode(ERuntimeMeshCollisionCookingMode NewMode)
908  {
909  GetOrCreateRuntimeMesh()->SetCollisionMode(NewMode);
910  }
911 
912 
913 private:
914 
915  //~ Begin USceneComponent Interface.
916  virtual FBoxSphereBounds CalcBounds(const FTransform& LocalToWorld) const override;
917  virtual bool IsSupportedForNetworking() const override
918  {
919  return true;
920  }
921  //~ Begin USceneComponent Interface.
922 
923  //~ Begin UPrimitiveComponent Interface.
924  virtual FPrimitiveSceneProxy* CreateSceneProxy() override;
925  virtual class UBodySetup* GetBodySetup() override;
926 
927 public:
928 
929  // HORU: returns true if any async collision cooking is pending.
930  UFUNCTION(BlueprintCallable)
931  bool IsAsyncCollisionCookingPending() const;
932 
933  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
934  int32 GetSectionIdFromCollisionFaceIndex(int32 FaceIndex) const;
935 
936  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
937  void GetSectionIdAndFaceIdFromCollisionFaceIndex(int32 FaceIndex, int32& SectionIndex, int32& SectionFaceIndex) const;
938 
939  virtual UMaterialInterface* GetMaterialFromCollisionFaceIndex(int32 FaceIndex, int32& SectionIndex) const override;
940  //~ End UPrimitiveComponent Interface.
941 
942 public:
943  //~ Begin UMeshComponent Interface.
944  virtual int32 GetNumMaterials() const override;
945  virtual void GetUsedMaterials(TArray<UMaterialInterface*>& OutMaterials, bool bGetDebugMaterials = false) const override;
946  virtual UMaterialInterface* GetMaterial(int32 ElementIndex) const override;
947  virtual UMaterialInterface* GetOverrideMaterial(int32 ElementIndex) const;
948  //~ End UMeshComponent Interface.
949 
950 private:
951 
952  /* Serializes this component */
953  virtual void Serialize(FArchive& Ar) override;
954 
955 
956  /* Does post load fixups */
957  virtual void PostLoad() override;
958 
959 
960 
962  void NewCollisionMeshReceived();
963  void NewBoundsReceived();
964  void ForceProxyRecreate();
965 
966  void SendSectionCreation(int32 SectionIndex);
967  void SendSectionPropertiesUpdate(int32 SectionIndex);
968 
969  // This collision setup is only to support older engine versions where the BodySetup being owned by a non UActorComponent breaks runtime cooking
970 
972  UPROPERTY(Instanced)
973  UBodySetup* BodySetup;
974 
976  UPROPERTY(Transient)
977  TArray<UBodySetup*> AsyncBodySetupQueue;
978 
979 #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 22
980  virtual bool GetPhysicsTriMeshData(struct FTriMeshCollisionData* CollisionData, bool InUseAllTriData) override;
981  virtual bool ContainsPhysicsTriMeshData(bool InUseAllTriData) const override;
982  virtual bool WantsNegXTriMesh() override { return false; }
983  //~ End Interface_CollisionDataProvider Interface
984 #endif
985 
986 #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 21
987  UBodySetup* CreateNewBodySetup();
988  void FinishPhysicsAsyncCook(UBodySetup* FinishedBodySetup);
989 
990  void UpdateCollision(bool bForceCookNow);
991 #endif
992 
993 
994 
995  friend class URuntimeMesh;
996  friend class FRuntimeMeshComponentSceneProxy;
998 };
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
EUpdateFrequency
ERuntimeMeshMobility
TSharedRef< FRuntimeMeshData, ESPMode::ThreadSafe > FRuntimeMeshDataRef
static const textual_icon check
Definition: model-views.h:260
ESectionUpdateFlags
ERuntimeMeshCollisionCookingMode


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