|
9 | 9 | #include "PhysicsEngine/ConvexElem.h" |
10 | 10 | #include "RuntimeMeshComponent.generated.h" |
11 | 11 |
|
12 | | -#define RMC_VALIDATE_CREATIONPARAMETERS(SectionIndex, Vertices, Triangles) \ |
13 | | - check(SectionIndex >= 0 && "SectionIndex cannot be negative."); \ |
14 | | - check(Vertices.Num() > 0 && "Vertices length must not be 0."); \ |
15 | | - check(Triangles.Num() > 0 && "Triangles length must not be 0"); |
16 | | - |
17 | | -#define RMC_VALIDATE_CREATIONPARAMETERS_DUALBUFFER(SectionIndex, Vertices, Triangles, Positions) \ |
18 | | - RMC_VALIDATE_CREATIONPARAMETERS(SectionIndex, Vertices, Triangles) \ |
19 | | - check((Positions.Num() == Vertices.Num()) && "Positions must be the same length as Vertices"); |
20 | | - |
21 | | -#define RMC_VALIDATE_BOUNDINGBOX(BoundingBox) \ |
22 | | - check(BoundingBox.IsValid && "BoundingBox must be valid."); |
23 | | - |
24 | | -#define RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex) \ |
25 | | - check(SectionIndex >= 0 && "SectionIndex cannot be negative."); \ |
26 | | - check(SectionIndex < MeshSections.Num() && MeshSections[SectionIndex].IsValid() && "Invalid SectionIndex."); |
27 | | - |
28 | | -#define RMC_VALIDATE_UPDATEPARAMETERS_INTERNALSECTION(SectionIndex) \ |
29 | | - RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex) \ |
30 | | - check(MeshSections[SectionIndex]->bIsInternalSectionType && "Section is not of legacy type."); |
| 12 | +// This set of macros is only meant for argument validation as it will return out of whatever scope. |
| 13 | +#if WITH_EDITOR |
| 14 | +#define RMC_CHECKINGAME_LOGINEDITOR(Condition, Message, RetVal) \ |
| 15 | + { if (!(Condition)) \ |
| 16 | + { \ |
| 17 | + Log(TEXT(Message), true); \ |
| 18 | + return RetVal; \ |
| 19 | + } } |
| 20 | +#else |
| 21 | +#define RMC_CHECKINGAME_LOGINEDITOR(Condition, Message, RetVal) \ |
| 22 | + check(Condition && Message); |
| 23 | +#endif |
| 24 | + |
| 25 | + |
| 26 | +#define RMC_VALIDATE_CREATIONPARAMETERS(SectionIndex, Vertices, Triangles, RetVal) \ |
| 27 | + RMC_CHECKINGAME_LOGINEDITOR((SectionIndex >= 0), "SectionIndex cannot be negative.", RetVal); \ |
| 28 | + RMC_CHECKINGAME_LOGINEDITOR((Vertices.Num() > 0), "Vertices length must not be 0.", RetVal); \ |
| 29 | + RMC_CHECKINGAME_LOGINEDITOR((Triangles.Num() > 0), "Triangles length must not be 0", RetVal); |
| 30 | + |
| 31 | +#define RMC_VALIDATE_CREATIONPARAMETERS_DUALBUFFER(SectionIndex, Vertices, Triangles, Positions, RetVal) \ |
| 32 | + RMC_VALIDATE_CREATIONPARAMETERS(SectionIndex, Vertices, Triangles, RetVal) \ |
| 33 | + RMC_CHECKINGAME_LOGINEDITOR((Positions.Num() == Vertices.Num()), "Positions must be the same length as Vertices", RetVal); |
| 34 | + |
| 35 | +#define RMC_VALIDATE_BOUNDINGBOX(BoundingBox, RetVal) \ |
| 36 | + RMC_CHECKINGAME_LOGINEDITOR(BoundingBox.IsValid, "BoundingBox must be valid.", RetVal); |
| 37 | + |
| 38 | +#define RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex, RetVal) \ |
| 39 | + RMC_CHECKINGAME_LOGINEDITOR((SectionIndex >= 0), "SectionIndex cannot be negative.", RetVal); \ |
| 40 | + RMC_CHECKINGAME_LOGINEDITOR((SectionIndex < MeshSections.Num() && MeshSections[SectionIndex].IsValid()), "Invalid SectionIndex.", RetVal); |
| 41 | + |
| 42 | +#define RMC_VALIDATE_UPDATEPARAMETERS_INTERNALSECTION(SectionIndex, RetVal) \ |
| 43 | + RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex, RetVal) \ |
| 44 | + RMC_CHECKINGAME_LOGINEDITOR((MeshSections[SectionIndex]->bIsInternalSectionType), "Section is not of legacy type.", RetVal); |
31 | 45 |
|
32 | | -#define RMC_VALIDATE_UPDATEPARAMETERS_DUALBUFFER(SectionIndex) \ |
33 | | - RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex) \ |
34 | | - check(MeshSections[SectionIndex]->IsDualBufferSection() && "Section is not dual buffer."); |
| 46 | +#define RMC_VALIDATE_UPDATEPARAMETERS_DUALBUFFER(SectionIndex, RetVal) \ |
| 47 | + RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex, RetVal) \ |
| 48 | + RMC_CHECKINGAME_LOGINEDITOR((MeshSections[SectionIndex]->IsDualBufferSection()), "Section is not dual buffer.", RetVal); |
35 | 49 |
|
36 | 50 |
|
37 | 51 |
|
@@ -139,7 +153,7 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
139 | 153 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_CreateMeshSection_VertexType); |
140 | 154 |
|
141 | 155 | // Validate all creation parameters |
142 | | - RMC_VALIDATE_CREATIONPARAMETERS(SectionIndex, Vertices, Triangles); |
| 156 | + RMC_VALIDATE_CREATIONPARAMETERS(SectionIndex, Vertices, Triangles, /*VoidReturn*/); |
143 | 157 |
|
144 | 158 | // Create the section |
145 | 159 | TSharedPtr<FRuntimeMeshSection<VertexType>> Section = CreateOrResetSection<FRuntimeMeshSection<VertexType>>(SectionIndex, false); |
@@ -174,8 +188,8 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
174 | 188 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_CreateMeshSection_VertexType_WithBoundingBox); |
175 | 189 |
|
176 | 190 | // Validate all creation parameters |
177 | | - RMC_VALIDATE_CREATIONPARAMETERS(SectionIndex, Vertices, Triangles); |
178 | | - RMC_VALIDATE_BOUNDINGBOX(BoundingBox); |
| 191 | + RMC_VALIDATE_CREATIONPARAMETERS(SectionIndex, Vertices, Triangles, /*VoidReturn*/); |
| 192 | + RMC_VALIDATE_BOUNDINGBOX(BoundingBox, /*VoidReturn*/); |
179 | 193 |
|
180 | 194 | // Create the section |
181 | 195 | TSharedPtr<FRuntimeMeshSection<VertexType>> Section = CreateOrResetSection<FRuntimeMeshSection<VertexType>>(SectionIndex, false); |
@@ -210,7 +224,7 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
210 | 224 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_CreateMeshSectionDualBuffer_VertexType); |
211 | 225 |
|
212 | 226 | // Validate all creation parameters |
213 | | - RMC_VALIDATE_CREATIONPARAMETERS_DUALBUFFER(SectionIndex, VertexData, Triangles, VertexPositions); |
| 227 | + RMC_VALIDATE_CREATIONPARAMETERS_DUALBUFFER(SectionIndex, VertexData, Triangles, VertexPositions, /*VoidReturn*/); |
214 | 228 |
|
215 | 229 | TSharedPtr<FRuntimeMeshSection<VertexType>> Section = CreateOrResetSection<FRuntimeMeshSection<VertexType>>(SectionIndex, true); |
216 | 230 |
|
@@ -245,8 +259,8 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
245 | 259 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_CreateMeshSectionDualBuffer_VertexType_WithBoundingBox); |
246 | 260 |
|
247 | 261 | // Validate all creation parameters |
248 | | - RMC_VALIDATE_CREATIONPARAMETERS_DUALBUFFER(SectionIndex, VertexData, Triangles, VertexPositions); |
249 | | - RMC_VALIDATE_BOUNDINGBOX(BoundingBox); |
| 262 | + RMC_VALIDATE_CREATIONPARAMETERS_DUALBUFFER(SectionIndex, VertexData, Triangles, VertexPositions, /*VoidReturn*/); |
| 263 | + RMC_VALIDATE_BOUNDINGBOX(BoundingBox, /*VoidReturn*/); |
250 | 264 |
|
251 | 265 | TSharedPtr<FRuntimeMeshSection<VertexType>> Section = CreateOrResetSection<FRuntimeMeshSection<VertexType>>(SectionIndex, true); |
252 | 266 |
|
@@ -275,7 +289,7 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
275 | 289 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_UpdateMeshSection_VertexType); |
276 | 290 |
|
277 | 291 | // Validate all update parameters |
278 | | - RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex); |
| 292 | + RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex, /*VoidReturn*/); |
279 | 293 |
|
280 | 294 | // Validate section type |
281 | 295 | MeshSections[SectionIndex]->GetVertexType()->EnsureEquals<VertexType>(); |
@@ -325,8 +339,8 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
325 | 339 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_UpdateMeshSection_VertexType_WithBoundingBox); |
326 | 340 |
|
327 | 341 | // Validate all update parameters |
328 | | - RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex); |
329 | | - RMC_VALIDATE_BOUNDINGBOX(BoundingBox); |
| 342 | + RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex, /*VoidReturn*/); |
| 343 | + RMC_VALIDATE_BOUNDINGBOX(BoundingBox, /*VoidReturn*/); |
330 | 344 |
|
331 | 345 | // Validate section type |
332 | 346 | MeshSections[SectionIndex]->GetVertexType()->EnsureEquals<VertexType>(); |
@@ -376,7 +390,7 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
376 | 390 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_UpdateMeshSection_VertexType_WithTriangles); |
377 | 391 |
|
378 | 392 | // Validate all update parameters |
379 | | - RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex); |
| 393 | + RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex, /*VoidReturn*/); |
380 | 394 |
|
381 | 395 | // Validate section type |
382 | 396 | MeshSections[SectionIndex]->GetVertexType()->EnsureEquals<VertexType>(); |
@@ -439,8 +453,8 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
439 | 453 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_UpdateMeshSection_VertexType_WithTrianglesAndBoundinBox); |
440 | 454 |
|
441 | 455 | // Validate all update parameters |
442 | | - RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex); |
443 | | - RMC_VALIDATE_BOUNDINGBOX(BoundingBox); |
| 456 | + RMC_VALIDATE_UPDATEPARAMETERS(SectionIndex, /*VoidReturn*/); |
| 457 | + RMC_VALIDATE_BOUNDINGBOX(BoundingBox, /*VoidReturn*/); |
444 | 458 |
|
445 | 459 | // Validate section type |
446 | 460 | MeshSections[SectionIndex]->GetVertexType()->EnsureEquals<VertexType>(); |
@@ -503,7 +517,7 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
503 | 517 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_UpdateMeshSection_Dual_VertexType); |
504 | 518 |
|
505 | 519 | // Validate all update parameters |
506 | | - RMC_VALIDATE_UPDATEPARAMETERS_DUALBUFFER(SectionIndex); |
| 520 | + RMC_VALIDATE_UPDATEPARAMETERS_DUALBUFFER(SectionIndex, /*VoidReturn*/); |
507 | 521 |
|
508 | 522 | // Validate section type |
509 | 523 | MeshSections[SectionIndex]->GetVertexType()->EnsureEquals<VertexType>(); |
@@ -568,8 +582,8 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
568 | 582 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_UpdateMeshSection_Dual_VertexType_WithBoundingBox); |
569 | 583 |
|
570 | 584 | // Validate all update parameters |
571 | | - RMC_VALIDATE_UPDATEPARAMETERS_DUALBUFFER(SectionIndex); |
572 | | - RMC_VALIDATE_BOUNDINGBOX(BoundingBox); |
| 585 | + RMC_VALIDATE_UPDATEPARAMETERS_DUALBUFFER(SectionIndex, /*VoidReturn*/); |
| 586 | + RMC_VALIDATE_BOUNDINGBOX(BoundingBox, /*VoidReturn*/); |
573 | 587 |
|
574 | 588 | // Validate section type |
575 | 589 | MeshSections[SectionIndex]->GetVertexType()->EnsureEquals<VertexType>(); |
@@ -634,7 +648,7 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
634 | 648 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_UpdateMeshSection_Dual_VertexType_WithTriangles); |
635 | 649 |
|
636 | 650 | // Validate all update parameters |
637 | | - RMC_VALIDATE_UPDATEPARAMETERS_DUALBUFFER(SectionIndex); |
| 651 | + RMC_VALIDATE_UPDATEPARAMETERS_DUALBUFFER(SectionIndex, /*VoidReturn*/); |
638 | 652 |
|
639 | 653 | // Validate section type |
640 | 654 | MeshSections[SectionIndex]->GetVertexType()->EnsureEquals<VertexType>(); |
@@ -712,8 +726,8 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshComponent : public UMeshComponent, pu |
712 | 726 | SCOPE_CYCLE_COUNTER(STAT_RuntimeMesh_UpdateMeshSection_Dual_VertexType_WithTrianglesAndBoundinBox); |
713 | 727 |
|
714 | 728 | // Validate all update parameters |
715 | | - RMC_VALIDATE_UPDATEPARAMETERS_DUALBUFFER(SectionIndex); |
716 | | - RMC_VALIDATE_BOUNDINGBOX(BoundingBox); |
| 729 | + RMC_VALIDATE_UPDATEPARAMETERS_DUALBUFFER(SectionIndex, /*VoidReturn*/); |
| 730 | + RMC_VALIDATE_BOUNDINGBOX(BoundingBox, /*VoidReturn*/); |
717 | 731 |
|
718 | 732 | // Validate section type |
719 | 733 | MeshSections[SectionIndex]->GetVertexType()->EnsureEquals<VertexType>(); |
|
0 commit comments