RuntimeMesh.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 "CoreMinimal.h"
6 #include "RuntimeMeshCore.h"
7 #include "RuntimeMeshSection.h"
8 #include "RuntimeMeshData.h"
9 #include "RuntimeMeshBlueprint.h"
10 #include "RuntimeMeshCollision.h"
12 #include "RuntimeMesh.generated.h"
13 
14 class UBodySetup;
15 class URuntimeMesh;
16 class URuntimeMeshComponent;
17 
18 
19 
20 
21 /*
22 * This tick function is used to drive the collision cooker.
23 * It is enabled for one frame when we need to update collision.
24 * This keeps from cooking on each individual create/update section as the original PMC did
25 */
26 struct FRuntimeMeshCollisionCookTickObject : FTickableGameObject
27 {
28  TWeakObjectPtr<URuntimeMesh> Owner;
29 
30  FRuntimeMeshCollisionCookTickObject(TWeakObjectPtr<URuntimeMesh> InOwner) : Owner(InOwner) {}
31  virtual void Tick(float DeltaTime);
32  virtual bool IsTickable() const;
33  virtual bool IsTickableInEditor() const { return false; }
34  virtual TStatId GetStatId() const;
35 
36  virtual UWorld* GetTickableGameObjectWorld() const;
37 };
38 
39 
43 DECLARE_DYNAMIC_MULTICAST_DELEGATE(FRuntimeMeshCollisionUpdatedDelegate);
44 
45 
46 UCLASS(HideCategories = Object, BlueprintType)
47 class RUNTIMEMESHCOMPONENT_API URuntimeMesh : public UObject, public IInterface_CollisionDataProvider
48 {
49  GENERATED_UCLASS_BODY()
50 
51 private:
54 
56  UPROPERTY(EditAnywhere, Category = "RuntimeMesh")
57  TArray<UMaterialInterface*> Materials;
58 
59 
61  bool bCollisionIsDirty;
62 
64  TUniquePtr<FRuntimeMeshCollisionCookTickObject> CookTickObject;
65 
67  TArray<TWeakObjectPtr<URuntimeMeshComponent>> LinkedComponents;
68 
73  UPROPERTY(EditAnywhere, Category = "RuntimeMesh")
74  bool bUseComplexAsSimpleCollision;
75 
81  UPROPERTY(EditAnywhere, Category = "RuntimeMesh")
82  bool bUseAsyncCooking;
83 
87  UPROPERTY(EditAnywhere, Category = "RuntimeMesh")
88  bool bShouldSerializeMeshData;
89 
91  UPROPERTY(EditAnywhere, Category = "RuntimeMesh")
93 
95  UPROPERTY(Instanced)
96  UBodySetup* BodySetup;
97 
99  UPROPERTY(Transient)
100  TArray<UBodySetup*> AsyncBodySetupQueue;
101 
102 public:
103 
104  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
105  bool ShouldSerializeMeshData()
106  {
107  return bShouldSerializeMeshData;
108  }
109 
110  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
111  void SetShouldSerializeMeshData(bool bShouldSerialize)
112  {
113  bShouldSerializeMeshData = bShouldSerialize;
114  }
115 
117  UPROPERTY(BlueprintAssignable, Category = "Components|RuntimeMesh")
118  FRuntimeMeshCollisionUpdatedDelegate CollisionUpdated;
119 
121  FRuntimeMeshDataRef GetRuntimeMeshData() const
122  {
123  //check(IsInGameThread());
124  return Data;
125  }
126 
128  {
129  check(IsInGameThread());
130  return Data->GetRenderProxy();
131  }
132 
133 public:
134 
135  void CreateMeshSection(int32 SectionIndex, bool bWantsHighPrecisionTangents, bool bWantsHighPrecisionUVs, int32 NumUVs, bool bWants32BitIndices, bool bCreateCollision, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average)
136  {
137  check(IsInGameThread());
138  GetRuntimeMeshData()->CreateMeshSection(SectionIndex, bWantsHighPrecisionTangents, bWantsHighPrecisionUVs, NumUVs, bWants32BitIndices, bCreateCollision, UpdateFrequency);
139  }
140 
141  template<typename VertexType0, typename IndexType>
142  FORCEINLINE void CreateMeshSection(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<IndexType>& InTriangles, bool bCreateCollision = false,
143  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
144  {
145  check(IsInGameThread());
146  GetRuntimeMeshData()->CreateMeshSection<VertexType0, IndexType>(SectionIndex, InVertices0, InTriangles, bCreateCollision, UpdateFrequency, UpdateFlags);
147  }
148 
149  template<typename VertexType0, typename IndexType>
150  FORCEINLINE void CreateMeshSection(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<IndexType>& InTriangles, const FBox& BoundingBox,
151  bool bCreateCollision = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
152  {
153  check(IsInGameThread());
154  GetRuntimeMeshData()->CreateMeshSection<VertexType0, IndexType>(SectionIndex, InVertices0, InTriangles, BoundingBox, bCreateCollision, UpdateFrequency, UpdateFlags);
155  }
156 
157  template<typename VertexType0, typename VertexType1, typename IndexType>
158  FORCEINLINE void CreateMeshSectionDualBuffer(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<IndexType>& InTriangles, bool bCreateCollision = false,
159  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
160  {
161  check(IsInGameThread());
162  GetRuntimeMeshData()->CreateMeshSectionDualBuffer<VertexType0, VertexType1, IndexType>(SectionIndex, InVertices0,
163  InVertices1, InTriangles, bCreateCollision, UpdateFrequency, UpdateFlags);
164  }
165 
166  template<typename VertexType0, typename VertexType1, typename IndexType>
167  FORCEINLINE void CreateMeshSectionDualBuffer(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<IndexType>& InTriangles, const FBox& BoundingBox,
168  bool bCreateCollision = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
169  {
170  check(IsInGameThread());
171  GetRuntimeMeshData()->CreateMeshSectionDualBuffer<VertexType0, VertexType1, IndexType>(SectionIndex, InVertices0,
172  InVertices1, InTriangles, BoundingBox, bCreateCollision, UpdateFrequency, UpdateFlags);
173  }
174 
175  template<typename VertexType0, typename VertexType1, typename VertexType2, typename IndexType>
176  FORCEINLINE void CreateMeshSectionTripleBuffer(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2, TArray<IndexType>& InTriangles,
177  bool bCreateCollision = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
178  {
179  check(IsInGameThread());
180  GetRuntimeMeshData()->CreateMeshSectionTripleBuffer<VertexType0, VertexType1, VertexType2, IndexType>(SectionIndex,
181  InVertices0, InVertices1, InVertices2, InTriangles, bCreateCollision, UpdateFrequency, UpdateFlags);
182  }
183 
184  template<typename VertexType0, typename VertexType1, typename VertexType2, typename IndexType>
185  FORCEINLINE void CreateMeshSectionTripleBuffer(int32 SectionIndex, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2, TArray<IndexType>& InTriangles,
186  const FBox& BoundingBox, bool bCreateCollision = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
187  {
188  check(IsInGameThread());
189  GetRuntimeMeshData()->CreateMeshSectionTripleBuffer<VertexType0, VertexType1, VertexType2, IndexType>(SectionIndex,
190  InVertices0, InVertices1, InVertices2, InTriangles, BoundingBox, bCreateCollision, UpdateFrequency, UpdateFlags);
191  }
192 
193 
194 
195  template<typename VertexType0>
196  FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray<VertexType0>& InVertices0,
198  {
199  check(IsInGameThread());
200  GetRuntimeMeshData()->UpdateMeshSection<VertexType0>(SectionId, InVertices0, UpdateFlags);
201  }
202 
203  template<typename VertexType0>
204  FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray<VertexType0>& InVertices0,
205  const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
206  {
207  check(IsInGameThread());
208  GetRuntimeMeshData()->UpdateMeshSection<VertexType0>(SectionId, InVertices0, BoundingBox, UpdateFlags);
209  }
210 
211  template<typename VertexType0, typename IndexType>
212  FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<IndexType>& InTriangles,
214  {
215  check(IsInGameThread());
216  GetRuntimeMeshData()->UpdateMeshSection<VertexType0, IndexType>(SectionId, InVertices0, InTriangles, UpdateFlags);
217  }
218 
219  template<typename VertexType0, typename IndexType>
220  FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<IndexType>& InTriangles,
221  const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
222  {
223  check(IsInGameThread());
224  GetRuntimeMeshData()->UpdateMeshSection<VertexType0, IndexType>(SectionId, InVertices0, InTriangles, BoundingBox, UpdateFlags);
225  }
226 
227  template<typename VertexType0, typename VertexType1>
228  FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1,
230  {
231  check(IsInGameThread());
232  GetRuntimeMeshData()->UpdateMeshSectionDualBuffer<VertexType0, VertexType1>(SectionId, InVertices0, InVertices1, UpdateFlags);
233  }
234 
235  template<typename VertexType0, typename VertexType1>
236  FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1,
237  const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
238  {
239  check(IsInGameThread());
240  GetRuntimeMeshData()->UpdateMeshSectionDualBuffer<VertexType0, VertexType1>(SectionId, InVertices0, InVertices1, BoundingBox, UpdateFlags);
241  }
242 
243  template<typename VertexType0, typename VertexType1, typename IndexType>
244  FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1,
245  TArray<IndexType>& InTriangles, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
246  {
247  check(IsInGameThread());
248  GetRuntimeMeshData()->UpdateMeshSectionDualBuffer<VertexType0, VertexType1, IndexType>(SectionId, InVertices0, InVertices1, InTriangles, UpdateFlags);
249  }
250 
251  template<typename VertexType0, typename VertexType1, typename IndexType>
252  FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<IndexType>& InTriangles,
253  const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
254  {
255  check(IsInGameThread());
256  GetRuntimeMeshData()->UpdateMeshSectionDualBuffer<VertexType0, VertexType1, IndexType>(SectionId, InVertices0, InVertices1, InTriangles, BoundingBox, UpdateFlags);
257  }
258 
259  template<typename VertexType0, typename VertexType1, typename VertexType2>
260  FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2,
262  {
263  check(IsInGameThread());
264  GetRuntimeMeshData()->UpdateMeshSectionTripleBuffer<VertexType0, VertexType1, VertexType2>(SectionId, InVertices0, InVertices1, InVertices2, UpdateFlags);
265  }
266 
267  template<typename VertexType0, typename VertexType1, typename VertexType2>
268  FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2,
269  const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
270  {
271  check(IsInGameThread());
272  GetRuntimeMeshData()->UpdateMeshSectionTripleBuffer<VertexType0, VertexType1, VertexType2>(SectionId, InVertices0, InVertices1, InVertices2, BoundingBox, UpdateFlags);
273  }
274 
275  template<typename VertexType0, typename VertexType1, typename VertexType2, typename IndexType>
276  FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2,
277  TArray<IndexType>& InTriangles, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
278  {
279  check(IsInGameThread());
280  GetRuntimeMeshData()->UpdateMeshSectionTripleBuffer<VertexType0, VertexType1, VertexType2, IndexType>(SectionId, InVertices0, InVertices1, InVertices2, InTriangles, UpdateFlags);
281  }
282 
283  template<typename VertexType0, typename VertexType1, typename VertexType2, typename IndexType>
284  FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, TArray<VertexType1>& InVertices1, TArray<VertexType2>& InVertices2,
285  TArray<IndexType>& InTriangles, const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
286  {
287  check(IsInGameThread());
288  GetRuntimeMeshData()->UpdateMeshSectionTripleBuffer<VertexType0, VertexType1, VertexType2, IndexType>(SectionId, InVertices0, InVertices1, InVertices2, InTriangles, BoundingBox, UpdateFlags);
289  }
290 
291 
292 
293  template<typename VertexType0>
294  FORCEINLINE void UpdateMeshSectionPrimaryBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
295  {
296  check(IsInGameThread());
297  GetRuntimeMeshData()->UpdateMeshSectionPrimaryBuffer<VertexType0>(SectionId, InVertices0, UpdateFlags);
298  }
299 
300  template<typename VertexType0>
301  FORCEINLINE void UpdateMeshSectionPrimaryBuffer(int32 SectionId, TArray<VertexType0>& InVertices0, const FBox& BoundingBox, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
302  {
303  check(IsInGameThread());
304  GetRuntimeMeshData()->UpdateMeshSectionPrimaryBuffer<VertexType0>(SectionId, InVertices0, BoundingBox, UpdateFlags);
305  }
306 
307  template<typename VertexType1>
308  FORCEINLINE void UpdateMeshSectionSecondaryBuffer(int32 SectionId, TArray<VertexType1>& InVertices1, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
309  {
310  check(IsInGameThread());
311  GetRuntimeMeshData()->UpdateMeshSectionSecondaryBuffer<VertexType1>(SectionId, InVertices1, UpdateFlags);
312  }
313 
314  template<typename VertexType2>
315  FORCEINLINE void UpdateMeshSectionTertiaryBuffer(int32 SectionId, TArray<VertexType2>& InVertices2, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
316  {
317  check(IsInGameThread());
318  GetRuntimeMeshData()->UpdateMeshSectionTertiaryBuffer<VertexType2>(SectionId, InVertices2, UpdateFlags);
319  }
320 
321  template<typename IndexType>
322  FORCEINLINE void UpdateMeshSectionTriangles(int32 SectionId, TArray<IndexType>& InTriangles, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
323  {
324  check(IsInGameThread());
325  GetRuntimeMeshData()->UpdateMeshSectionTriangles<IndexType>(SectionId, InTriangles, UpdateFlags);
326  }
327 
328 
329 
330  FORCEINLINE void CreateMeshSection(int32 SectionId, const TSharedPtr<FRuntimeMeshBuilder>& MeshData, bool bCreateCollision = false,
331  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
332  {
333  check(IsInGameThread());
334  GetRuntimeMeshData()->CreateMeshSection(SectionId, MeshData, bCreateCollision, UpdateFrequency, UpdateFlags);
335  }
336 
337  FORCEINLINE void CreateMeshSectionByMove(int32 SectionId, const TSharedPtr<FRuntimeMeshBuilder>& MeshData, bool bCreateCollision = false,
338  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
339  {
340  check(IsInGameThread());
341  GetRuntimeMeshData()->CreateMeshSectionByMove(SectionId, MeshData, bCreateCollision, UpdateFrequency, UpdateFlags);
342  }
343 
344  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
345  void CreateMeshSectionFromBuilder(int32 SectionId, URuntimeBlueprintMeshBuilder* MeshData, bool bCreateCollision = false,
346  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average/*, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None*/)
347  {
348  check(IsInGameThread());
349  GetRuntimeMeshData()->CreateMeshSection(SectionId, MeshData->GetMeshBuilder(), bCreateCollision, UpdateFrequency/*, UpdateFlags*/);
350  }
351 
352 
353  FORCEINLINE void UpdateMeshSection(int32 SectionId, const TSharedPtr<FRuntimeMeshBuilder>& MeshData, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
354  {
355  check(IsInGameThread());
356  GetRuntimeMeshData()->UpdateMeshSection(SectionId, MeshData, UpdateFlags);
357  }
358 
359  FORCEINLINE void UpdateMeshSectionByMove(int32 SectionId, const TSharedPtr<FRuntimeMeshBuilder>& MeshData, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
360  {
361  check(IsInGameThread());
362  GetRuntimeMeshData()->UpdateMeshSectionByMove(SectionId, MeshData, UpdateFlags);
363  }
364 
365  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
366  void UpdateMeshSectionFromBuilder(int32 SectionId, URuntimeBlueprintMeshBuilder* MeshData/*, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None*/)
367  {
368  check(IsInGameThread());
369  GetRuntimeMeshData()->UpdateMeshSection(SectionId, MeshData->GetMeshBuilder()/*, UpdateFlags*/);
370  }
371 
372 
373  TUniquePtr<FRuntimeMeshScopedUpdater> BeginSectionUpdate(int32 SectionId, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
374  {
375  check(IsInGameThread());
376  return GetRuntimeMeshData()->BeginSectionUpdate(SectionId, UpdateFlags);
377  }
378 
379  TUniquePtr<FRuntimeMeshScopedUpdater> GetSectionReadonly(int32 SectionId)
380  {
381  check(IsInGameThread());
382  return GetRuntimeMeshData()->GetSectionReadonly(SectionId);
383  }
384 
385 
386 
387 
388  FORCEINLINE void CreateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
389  const TArray<FVector2D>& UV0, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, bool bCreateCollision = false,
390  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None,
391  bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
392  {
393  check(IsInGameThread());
394  GetRuntimeMeshData()->CreateMeshSection(SectionIndex, Vertices, Triangles, Normals, UV0, Colors, Tangents,
395  bCreateCollision, UpdateFrequency, UpdateFlags, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
396  }
397 
398  FORCEINLINE void CreateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
399  const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents,
400  bool bCreateCollision = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None,
401  bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
402  {
403  check(IsInGameThread());
404  GetRuntimeMeshData()->CreateMeshSection(SectionIndex, Vertices, Triangles, Normals, UV0, UV1, Colors, Tangents,
405  bCreateCollision, UpdateFrequency, UpdateFlags, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
406  }
407 
408 
409  FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<FVector>& Normals, const TArray<FVector2D>& UV0,
410  const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
411  {
412  check(IsInGameThread());
413  GetRuntimeMeshData()->UpdateMeshSection(SectionIndex, Vertices, Normals, UV0, Colors, Tangents, UpdateFlags);
414  }
415 
416  FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<FVector>& Normals, const TArray<FVector2D>& UV0,
417  const TArray<FVector2D>& UV1, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
418  {
419  check(IsInGameThread());
420  GetRuntimeMeshData()->UpdateMeshSection(SectionIndex, Vertices, Normals, UV0, UV1, Colors, Tangents, UpdateFlags);
421  }
422 
423  FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
424  const TArray<FVector2D>& UV0, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
425  {
426  check(IsInGameThread());
427  GetRuntimeMeshData()->UpdateMeshSection(SectionIndex, Vertices, Triangles, Normals, UV0, Colors, Tangents, UpdateFlags);
428  }
429 
430  FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
431  const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, const TArray<FColor>& Colors, const TArray<FRuntimeMeshTangent>& Tangents, ESectionUpdateFlags UpdateFlags = ESectionUpdateFlags::None)
432  {
433  check(IsInGameThread());
434  GetRuntimeMeshData()->UpdateMeshSection(SectionIndex, Vertices, Triangles, Normals, UV0, UV1, Colors, Tangents, UpdateFlags);
435  }
436 
437 
438 
439  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", meta = (DisplayName = "Create Mesh Section", AutoCreateRefTerm = "Normals,Tangents,UV0,UV1,Colors"))
440  void CreateMeshSection_Blueprint(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
441  const TArray<FRuntimeMeshTangent>& Tangents, const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, const TArray<FLinearColor>& Colors,
442  bool bCreateCollision = false, bool bCalculateNormalTangent = false, bool bShouldCreateHardTangents = false, bool bGenerateTessellationTriangles = false,
443  EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average, bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
444  {
445  check(IsInGameThread());
446  GetRuntimeMeshData()->CreateMeshSection_Blueprint(SectionIndex, Vertices, Triangles, Normals, Tangents, UV0, UV1, Colors,
447  bCreateCollision, bCalculateNormalTangent, bShouldCreateHardTangents, bGenerateTessellationTriangles, UpdateFrequency, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
448  }
449 
450  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", meta = (DisplayName = "Update Mesh Section", AutoCreateRefTerm = "Triangles,Normals,Tangents,UV0,UV1,Colors"))
451  void UpdateMeshSection_Blueprint(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals,
452  const TArray<FRuntimeMeshTangent>& Tangents, const TArray<FVector2D>& UV0, const TArray<FVector2D>& UV1, const TArray<FLinearColor>& Colors,
453  bool bCalculateNormalTangent = false, bool bShouldCreateHardTangents = false, bool bGenerateTessellationTriangles = false)
454  {
455  check(IsInGameThread());
456  GetRuntimeMeshData()->UpdateMeshSection_Blueprint(SectionIndex, Vertices, Triangles, Normals, Tangents, UV0, UV1, Colors,
457  bCalculateNormalTangent, bShouldCreateHardTangents, bGenerateTessellationTriangles);
458  }
459 
460  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", meta = (DisplayName = "Create Mesh Section Packed", AutoCreateRefTerm = "Normals,Tangents,UV0,UV1,Colors"))
461  void CreateMeshSectionPacked_Blueprint(int32 SectionIndex, const TArray<FRuntimeMeshBlueprintVertexSimple>& Vertices, const TArray<int32>& Triangles,
462  bool bCreateCollision = false, bool bCalculateNormalTangent = false, bool bShouldCreateHardTangents = false, bool bGenerateTessellationTriangles = false, EUpdateFrequency UpdateFrequency = EUpdateFrequency::Average,
463  bool bUseHighPrecisionTangents = false, bool bUseHighPrecisionUVs = true)
464  {
465  check(IsInGameThread());
466  GetRuntimeMeshData()->CreateMeshSectionPacked_Blueprint(SectionIndex, Vertices, Triangles, bCreateCollision, bCalculateNormalTangent, bShouldCreateHardTangents,
467  bGenerateTessellationTriangles, UpdateFrequency, bUseHighPrecisionTangents, bUseHighPrecisionUVs);
468  }
469 
470  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh", meta = (DisplayName = "Update Mesh Section Packed", AutoCreateRefTerm = "Triangles,Normals,Tangents,UV0,UV1,Colors"))
471  void UpdateMeshSectionPacked_Blueprint(int32 SectionIndex, const TArray<FRuntimeMeshBlueprintVertexSimple>& Vertices, const TArray<int32>& Triangles,
472  bool bCalculateNormalTangent = false, bool bShouldCreateHardTangents = false, bool bGenerateTessellationTriangles = false)
473  {
474  check(IsInGameThread());
475  GetRuntimeMeshData()->UpdateMeshSectionPacked_Blueprint(SectionIndex, Vertices, Triangles, bCalculateNormalTangent, bShouldCreateHardTangents, bGenerateTessellationTriangles);
476  }
477 
478 
479 
480 
481 
482 
483  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
484  void SetSectionTessellationTriangles(int32 SectionId, const TArray<int32>& Triangles)
485  {
486  check(IsInGameThread());
487  GetRuntimeMeshData()->SetSectionTessellationTriangles(SectionId, Triangles);
488  }
489 
490  template<typename IndexType>
491  void SetSectionTessellationTriangles(int32 SectionId, const TArray<IndexType>& Triangles)
492  {
493  check(IsInGameThread());
494  GetRuntimeMeshData()->SetSectionTessellationTriangles(SectionId, Triangles);
495  }
496 
497 
498 
500  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
501  void ClearMeshSection(int32 SectionIndex)
502  {
503  check(IsInGameThread());
504  GetRuntimeMeshData()->ClearMeshSection(SectionIndex);
505  }
506 
508  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
509  void ClearAllMeshSections()
510  {
511  check(IsInGameThread());
512  GetRuntimeMeshData()->ClearAllMeshSections();
513  }
514 
515 
516  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
517  void SetSectionMaterial(int32 SectionId, UMaterialInterface* Material)
518  {
519  check(IsInGameThread());
520  if (SectionId >= Materials.Num())
521  {
522  Materials.SetNum(SectionId + 1);
523  }
524 
525  Materials[SectionId] = Material;
526 
527  if (DoesSectionExist(SectionId))
528  {
529  ForceProxyRecreate();
530  }
531  }
532 
533  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
534  UMaterialInterface* GetSectionMaterial(int32 SectionId)
535  {
536  check(IsInGameThread());
537  if (Materials.IsValidIndex(SectionId))
538  {
539  return Materials[SectionId];
540  }
541  return nullptr;
542  }
543 
544  TArray<UMaterialInterface*> GetMaterials()
545  {
546  check(IsInGameThread());
547  return Materials;
548  }
549 
551  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
552  FBox GetSectionBoundingBox(int32 SectionIndex)
553  {
554  check(IsInGameThread());
555  return GetRuntimeMeshData()->GetSectionBoundingBox(SectionIndex);
556  }
557 
559  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
560  void SetMeshSectionVisible(int32 SectionIndex, bool bNewVisibility)
561  {
562  check(IsInGameThread());
563  GetRuntimeMeshData()->SetMeshSectionVisible(SectionIndex, bNewVisibility);
564  }
565 
567  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
568  bool IsMeshSectionVisible(int32 SectionIndex) const
569  {
570  check(IsInGameThread());
571  return GetRuntimeMeshData()->IsMeshSectionVisible(SectionIndex);
572  }
573 
574 
576  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
577  void SetMeshSectionCastsShadow(int32 SectionIndex, bool bNewCastsShadow)
578  {
579  check(IsInGameThread());
580  GetRuntimeMeshData()->SetMeshSectionCastsShadow(SectionIndex, bNewCastsShadow);
581  }
582 
584  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
585  bool IsMeshSectionCastingShadows(int32 SectionIndex) const
586  {
587  check(IsInGameThread());
588  return GetRuntimeMeshData()->IsMeshSectionCastingShadows(SectionIndex);
589  }
590 
591 
593  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
594  void SetMeshSectionCollisionEnabled(int32 SectionIndex, bool bNewCollisionEnabled)
595  {
596  check(IsInGameThread());
597  GetRuntimeMeshData()->SetMeshSectionCollisionEnabled(SectionIndex, bNewCollisionEnabled);
598  }
599 
601  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
602  bool IsMeshSectionCollisionEnabled(int32 SectionIndex)
603  {
604  check(IsInGameThread());
605  return GetRuntimeMeshData()->IsMeshSectionCollisionEnabled(SectionIndex);
606  }
607 
608 
610  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
611  int32 GetNumSections() const
612  {
613  check(IsInGameThread());
614  return GetRuntimeMeshData()->GetNumSections();
615  }
616 
618  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
619  bool DoesSectionExist(int32 SectionIndex) const
620  {
621  check(IsInGameThread());
622  return GetRuntimeMeshData()->DoesSectionExist(SectionIndex);
623  }
624 
626  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
627  int32 GetAvailableSectionIndex() const
628  {
629  check(IsInGameThread());
630  return GetRuntimeMeshData()->GetAvailableSectionIndex();
631  }
632 
633  TArray<int32> GetSectionIds() const
634  {
635  check(IsInGameThread());
636  return GetRuntimeMeshData()->GetSectionIds();
637  }
638 
639 
640 
641 
642  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
643  void SetMeshCollisionSection(int32 CollisionSectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles)
644  {
645  check(IsInGameThread());
646  GetRuntimeMeshData()->SetMeshCollisionSection(CollisionSectionIndex, Vertices, Triangles);
647  }
648 
649  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
650  void ClearMeshCollisionSection(int32 CollisionSectionIndex)
651  {
652  check(IsInGameThread());
653  GetRuntimeMeshData()->ClearMeshCollisionSection(CollisionSectionIndex);
654  }
655 
656  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
657  void ClearAllMeshCollisionSections()
658  {
659  check(IsInGameThread());
660  GetRuntimeMeshData()->ClearAllMeshCollisionSections();
661  }
662 
663 
664 
665  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
666  int32 AddConvexCollisionSection(TArray<FVector> ConvexVerts)
667  {
668  check(IsInGameThread());
669  return GetRuntimeMeshData()->AddConvexCollisionSection(ConvexVerts);
670  }
671 
672  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
673  void SetConvexCollisionSection(int32 ConvexSectionIndex, TArray<FVector> ConvexVerts)
674  {
675  check(IsInGameThread());
676  GetRuntimeMeshData()->SetConvexCollisionSection(ConvexSectionIndex, ConvexVerts);
677  }
678 
679  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
680  void ClearConvexCollisionSection(int32 ConvexSectionIndex)
681  {
682  check(IsInGameThread());
683  GetRuntimeMeshData()->RemoveConvexCollisionSection(ConvexSectionIndex);
684  }
685 
686  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
687  void ClearAllConvexCollisionSections()
688  {
689  check(IsInGameThread());
690  GetRuntimeMeshData()->ClearConvexCollisionSections();
691  }
692 
693  void SetCollisionConvexMeshes(const TArray<TArray<FVector>>& ConvexMeshes)
694  {
695  check(IsInGameThread());
696  GetRuntimeMeshData()->SetCollisionConvexMeshes(ConvexMeshes);
697  }
698 
699 
700 
701  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
702  int32 AddCollisionBox(const FRuntimeMeshCollisionBox& NewBox)
703  {
704  check(IsInGameThread());
705  return GetRuntimeMeshData()->AddCollisionBox(NewBox);
706  }
707 
708  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
709  void RemoveCollisionBox(int32 Index)
710  {
711  check(IsInGameThread());
712  GetRuntimeMeshData()->RemoveCollisionBox(Index);
713  }
714 
715  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
716  void ClearCollisionBoxes()
717  {
718  check(IsInGameThread());
719  GetRuntimeMeshData()->ClearCollisionBoxes();
720  }
721 
722  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
723  void SetCollisionBoxes(const TArray<FRuntimeMeshCollisionBox>& NewBoxes)
724  {
725  check(IsInGameThread());
726  GetRuntimeMeshData()->SetCollisionBoxes(NewBoxes);
727  }
728 
729 
730  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
731  int32 AddCollisionSphere(const FRuntimeMeshCollisionSphere& NewSphere)
732  {
733  check(IsInGameThread());
734  return GetRuntimeMeshData()->AddCollisionSphere(NewSphere);
735  }
736 
737  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
738  void RemoveCollisionSphere(int32 Index)
739  {
740  check(IsInGameThread());
741  GetRuntimeMeshData()->RemoveCollisionSphere(Index);
742  }
743 
744  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
745  void ClearCollisionSpheres()
746  {
747  check(IsInGameThread());
748  GetRuntimeMeshData()->ClearCollisionSpheres();
749  }
750 
751  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
752  void SetCollisionSpheres(const TArray<FRuntimeMeshCollisionSphere>& NewSpheres)
753  {
754  check(IsInGameThread());
755  GetRuntimeMeshData()->SetCollisionSpheres(NewSpheres);
756  }
757 
758 
759  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
760  int32 AddCollisionCapsule(const FRuntimeMeshCollisionCapsule& NewCapsule)
761  {
762  check(IsInGameThread());
763  return GetRuntimeMeshData()->AddCollisionCapsule(NewCapsule);
764  }
765 
766  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
767  void RemoveCollisionCapsule(int32 Index)
768  {
769  check(IsInGameThread());
770  GetRuntimeMeshData()->RemoveCollisionCapsule(Index);
771  }
772 
773  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
774  void ClearCollisionCapsules()
775  {
776  check(IsInGameThread());
777  GetRuntimeMeshData()->ClearCollisionCapsules();
778  }
779 
780  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
781  void SetCollisionCapsules(const TArray<FRuntimeMeshCollisionCapsule>& NewCapsules)
782  {
783  check(IsInGameThread());
784  GetRuntimeMeshData()->SetCollisionCapsules(NewCapsules);
785  }
786 
787 
789  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
790  void CookCollisionNow();
791 
792  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
793  void SetCollisionUseComplexAsSimple(bool bNewValue)
794  {
795  check(IsInGameThread());
796  bUseComplexAsSimpleCollision = bNewValue;
797  MarkCollisionDirty();
798  }
799 
800  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
801  bool IsCollisionUsingComplexAsSimple()
802  {
803  check(IsInGameThread());
804  return bUseComplexAsSimpleCollision;
805  }
806 
807  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
808  void SetCollisionUseAsyncCooking(bool bNewValue)
809  {
810  check(IsInGameThread());
811  bUseAsyncCooking = bNewValue;
812  }
813 
814  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
815  bool IsCollisionUsingAsyncCooking()
816  {
817  check(IsInGameThread());
818  return bUseAsyncCooking;
819  }
820 
821  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
822  void SetCollisionMode(ERuntimeMeshCollisionCookingMode NewMode)
823  {
824  check(IsInGameThread());
825  CollisionMode = NewMode;
826  }
827 
828  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
829  ERuntimeMeshCollisionCookingMode GetCollisionMode() const
830  {
831  check(IsInGameThread());
832  return CollisionMode;
833  }
834 
835  FBoxSphereBounds GetLocalBounds() const
836  {
837  //check(IsInGameThread());
838  return GetRuntimeMeshData()->GetLocalBounds();
839  }
840 
841  UBodySetup* GetBodySetup()
842  {
843  check(IsInGameThread());
844  return BodySetup;
845  }
846 
847 private:
848 
849  void Initialize() { GetRuntimeMeshData()->Initialize(); }
850  virtual void MarkChanged()
851  {
852 #if WITH_EDITOR
853  Modify(true);
854  PostEditChange();
855 #endif
856  }
857 
858  void RegisterLinkedComponent(URuntimeMeshComponent* NewComponent);
859  void UnRegisterLinkedComponent(URuntimeMeshComponent* ComponentToRemove);
860 
861  template<typename Function>
862  void DoForAllLinkedComponents(Function Func)
863  {
864  bool bShouldPurge = false;
865  for (TWeakObjectPtr<URuntimeMeshComponent> MeshReference : LinkedComponents)
866  {
867  if (URuntimeMeshComponent* Mesh = MeshReference.Get())
868  {
869  Func(Mesh);
870  }
871  else
872  {
873  bShouldPurge = true;
874  }
875  }
876  if (bShouldPurge)
877  {
878  LinkedComponents = LinkedComponents.FilterByPredicate([](const TWeakObjectPtr<URuntimeMeshComponent>& MeshReference)
879  {
880  return MeshReference.IsValid();
881  });
882  }
883  }
884 
885 
886  void GetUsedMaterials(TArray<UMaterialInterface*>& OutMaterials) const
887  {
888  OutMaterials.Append(Materials.FilterByPredicate([](UMaterialInterface* Mat) -> bool { return Mat != nullptr; }));
889  }
890 
891  //~ Begin Interface_CollisionDataProvider Interface
892  virtual bool GetPhysicsTriMeshData(struct FTriMeshCollisionData* CollisionData, bool InUseAllTriData) override;
893  virtual bool ContainsPhysicsTriMeshData(bool InUseAllTriData) const override;
894  virtual bool WantsNegXTriMesh() override { return false; }
895  //~ End Interface_CollisionDataProvider Interface
896 
897  virtual void Serialize(FArchive& Ar) override;
898  void PostLoad();
899 
900 
901 public:
902  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
903  UMaterialInterface* GetMaterialFromCollisionFaceIndex(int32 FaceIndex, int32& SectionIndex) const;
904 
905  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
906  int32 GetSectionIdFromCollisionFaceIndex(int32 FaceIndex) const;
907 
908  UFUNCTION(BlueprintCallable, Category = "Components|RuntimeMesh")
909  void GetSectionIdAndFaceIdFromCollisionFaceIndex(int32 FaceIndex, int32& SectionIndex, int32& SectionFaceIndex) const;
910 
911 
912 private:
914  void MarkCollisionDirty();
915 
916 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 21
917 
918  UBodySetup* CreateNewBodySetup();
919 #endif
920 
921  void CopyCollisionElementsToBodySetup(UBodySetup* Setup);
923  void SetBasicBodySetupParameters(UBodySetup* Setup);
925  void UpdateCollision(bool bForceCookNow = false);
927 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 21
928  void FinishPhysicsAsyncCook(bool bSuccess, UBodySetup* FinishedBodySetup);
930  void FinalizeNewCookedData();
931 #endif
932 
933 
935  {
936  return GetRuntimeMeshData()->EnsureProxyCreated(InFeatureLevel);
937  }
938 
939 
940  void UpdateLocalBounds();
941 
942  void ForceProxyRecreate();
943 
944  void SendSectionCreation(int32 SectionIndex);
945 
946  void SendSectionPropertiesUpdate(int32 SectionIndex);
947 
948 
949  friend class FRuntimeMeshData;
950  friend class URuntimeMeshComponent;
953 };
954 
FORCEINLINE void UpdateMeshSection(int32 SectionId, const TSharedPtr< FRuntimeMeshBuilder > &MeshData, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:353
void SetSectionTessellationTriangles(int32 SectionId, const TArray< IndexType > &Triangles)
Definition: RuntimeMesh.h:491
FORCEINLINE void UpdateMeshSectionPrimaryBuffer(int32 SectionId, TArray< VertexType0 > &InVertices0, const FBox &BoundingBox, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:301
virtual bool IsTickableInEditor() const
Definition: RuntimeMesh.h:33
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray< VertexType0 > &InVertices0, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:196
FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray< VertexType0 > &InVertices0, TArray< IndexType > &InTriangles, const FBox &BoundingBox, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:220
void CreateMeshSection(int32 SectionIndex, bool bWantsHighPrecisionTangents, bool bWantsHighPrecisionUVs, int32 NumUVs, bool bWants32BitIndices, bool bCreateCollision, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average)
Definition: RuntimeMesh.h:135
FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, TArray< IndexType > &InTriangles, const FBox &BoundingBox, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:252
FORCEINLINE void UpdateMeshSectionPrimaryBuffer(int32 SectionId, TArray< VertexType0 > &InVertices0, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:294
FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, TArray< VertexType2 > &InVertices2, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:260
FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray< FVector > &Vertices, const TArray< FVector > &Normals, const TArray< FVector2D > &UV0, const TArray< FVector2D > &UV1, const TArray< FColor > &Colors, const TArray< FRuntimeMeshTangent > &Tangents, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:416
EUpdateFrequency
FORCEINLINE void CreateMeshSection(int32 SectionIndex, TArray< VertexType0 > &InVertices0, TArray< IndexType > &InTriangles, const FBox &BoundingBox, bool bCreateCollision=false, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:150
FORCEINLINE void CreateMeshSectionDualBuffer(int32 SectionIndex, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, TArray< IndexType > &InTriangles, bool bCreateCollision=false, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:158
FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray< VertexType0 > &InVertices0, TArray< IndexType > &InTriangles, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:212
FORCEINLINE void CreateMeshSectionDualBuffer(int32 SectionIndex, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, TArray< IndexType > &InTriangles, const FBox &BoundingBox, bool bCreateCollision=false, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:167
TUniquePtr< FRuntimeMeshScopedUpdater > BeginSectionUpdate(int32 SectionId, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:373
virtual UWorld * GetTickableGameObjectWorld() const
Definition: RuntimeMesh.cpp:48
FBoxSphereBounds GetLocalBounds() const
Definition: RuntimeMesh.h:835
TSharedRef< FRuntimeMeshData, ESPMode::ThreadSafe > FRuntimeMeshDataRef
virtual void Tick(float DeltaTime)
Definition: RuntimeMesh.cpp:22
FORCEINLINE void CreateMeshSectionByMove(int32 SectionId, const TSharedPtr< FRuntimeMeshBuilder > &MeshData, bool bCreateCollision=false, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:337
FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, TArray< IndexType > &InTriangles, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:244
FORCEINLINE void CreateMeshSectionTripleBuffer(int32 SectionIndex, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, TArray< VertexType2 > &InVertices2, TArray< IndexType > &InTriangles, bool bCreateCollision=false, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:176
FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray< FVector > &Vertices, const TArray< int32 > &Triangles, const TArray< FVector > &Normals, const TArray< FVector2D > &UV0, const TArray< FVector2D > &UV1, const TArray< FColor > &Colors, const TArray< FRuntimeMeshTangent > &Tangents, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:430
TArray< int32 > GetSectionIds() const
Definition: RuntimeMesh.h:633
FORCEINLINE void CreateMeshSection(int32 SectionIndex, const TArray< FVector > &Vertices, const TArray< int32 > &Triangles, const TArray< FVector > &Normals, const TArray< FVector2D > &UV0, const TArray< FVector2D > &UV1, const TArray< FColor > &Colors, const TArray< FRuntimeMeshTangent > &Tangents, bool bCreateCollision=false, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None, bool bUseHighPrecisionTangents=false, bool bUseHighPrecisionUVs=true)
Definition: RuntimeMesh.h:398
FORCEINLINE void UpdateMeshSectionTertiaryBuffer(int32 SectionId, TArray< VertexType2 > &InVertices2, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:315
FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, TArray< VertexType2 > &InVertices2, const FBox &BoundingBox, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:268
void GetUsedMaterials(TArray< UMaterialInterface * > &OutMaterials) const
Definition: RuntimeMesh.h:886
FORCEINLINE void CreateMeshSection(int32 SectionIndex, TArray< VertexType0 > &InVertices0, TArray< IndexType > &InTriangles, bool bCreateCollision=false, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:142
FORCEINLINE void CreateMeshSectionTripleBuffer(int32 SectionIndex, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, TArray< VertexType2 > &InVertices2, TArray< IndexType > &InTriangles, const FBox &BoundingBox, bool bCreateCollision=false, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:185
static const textual_icon check
Definition: model-views.h:260
TArray< UMaterialInterface * > GetMaterials()
Definition: RuntimeMesh.h:544
FRuntimeMeshDataRef Data
Definition: RuntimeMesh.h:53
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FRuntimeMeshCollisionUpdatedDelegate)
ESectionUpdateFlags
void DoForAllLinkedComponents(Function Func)
Definition: RuntimeMesh.h:862
FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, TArray< VertexType2 > &InVertices2, TArray< IndexType > &InTriangles, const FBox &BoundingBox, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:284
TUniquePtr< FRuntimeMeshScopedUpdater > GetSectionReadonly(int32 SectionId)
Definition: RuntimeMesh.h:379
UBodySetup * GetBodySetup()
Definition: RuntimeMesh.h:841
FRuntimeMeshCollisionCookTickObject(TWeakObjectPtr< URuntimeMesh > InOwner)
Definition: RuntimeMesh.h:30
void Initialize()
Definition: RuntimeMesh.h:849
FORCEINLINE void UpdateMeshSectionTriangles(int32 SectionId, TArray< IndexType > &InTriangles, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:322
TSharedPtr< FRuntimeMeshProxy, ESPMode::ThreadSafe > FRuntimeMeshProxyPtr
FORCEINLINE void UpdateMeshSection(int32 SectionId, TArray< VertexType0 > &InVertices0, const FBox &BoundingBox, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:204
virtual TStatId GetStatId() const
Definition: RuntimeMesh.cpp:42
FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, const FBox &BoundingBox, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:236
TWeakObjectPtr< URuntimeMesh > Owner
Definition: RuntimeMesh.h:28
FORCEINLINE void UpdateMeshSectionSecondaryBuffer(int32 SectionId, TArray< VertexType1 > &InVertices1, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:308
virtual bool WantsNegXTriMesh() override
Definition: RuntimeMesh.h:894
FRuntimeMeshProxyPtr GetRuntimeMeshRenderProxy() const
Definition: RuntimeMesh.h:127
FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray< FVector > &Vertices, const TArray< int32 > &Triangles, const TArray< FVector > &Normals, const TArray< FVector2D > &UV0, const TArray< FColor > &Colors, const TArray< FRuntimeMeshTangent > &Tangents, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:423
FORCEINLINE void UpdateMeshSectionDualBuffer(int32 SectionId, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:228
FORCEINLINE void CreateMeshSection(int32 SectionId, const TSharedPtr< FRuntimeMeshBuilder > &MeshData, bool bCreateCollision=false, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:330
virtual void MarkChanged()
Definition: RuntimeMesh.h:850
FORCEINLINE void UpdateMeshSectionByMove(int32 SectionId, const TSharedPtr< FRuntimeMeshBuilder > &MeshData, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:359
void SetCollisionConvexMeshes(const TArray< TArray< FVector >> &ConvexMeshes)
Definition: RuntimeMesh.h:693
ERuntimeMeshCollisionCookingMode
FORCEINLINE void UpdateMeshSectionTripleBuffer(int32 SectionId, TArray< VertexType0 > &InVertices0, TArray< VertexType1 > &InVertices1, TArray< VertexType2 > &InVertices2, TArray< IndexType > &InTriangles, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:276
FORCEINLINE void CreateMeshSection(int32 SectionIndex, const TArray< FVector > &Vertices, const TArray< int32 > &Triangles, const TArray< FVector > &Normals, const TArray< FVector2D > &UV0, const TArray< FColor > &Colors, const TArray< FRuntimeMeshTangent > &Tangents, bool bCreateCollision=false, EUpdateFrequency UpdateFrequency=EUpdateFrequency::Average, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None, bool bUseHighPrecisionTangents=false, bool bUseHighPrecisionUVs=true)
Definition: RuntimeMesh.h:388
virtual bool IsTickable() const
Definition: RuntimeMesh.cpp:32
FRuntimeMeshProxyPtr EnsureProxyCreated(ERHIFeatureLevel::Type InFeatureLevel)
Definition: RuntimeMesh.h:934
FORCEINLINE void UpdateMeshSection(int32 SectionIndex, const TArray< FVector > &Vertices, const TArray< FVector > &Normals, const TArray< FVector2D > &UV0, const TArray< FColor > &Colors, const TArray< FRuntimeMeshTangent > &Tangents, ESectionUpdateFlags UpdateFlags=ESectionUpdateFlags::None)
Definition: RuntimeMesh.h:409


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