Yasiu Spline Meshed 1
Extension of basic spline for use with meshes.
Loading...
Searching...
No Matches
SplineMeshedComponent.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Grzegorz Krug.
3 * All Rights Reserved.
4 */
5#pragma once
6
7
8#include "CoreMinimal.h"
9#include "Engine/StaticMesh.h"
10
11#include "Components/SplineComponent.h"
12#include "Components/SplineMeshComponent.h"
13
14
15/* FOverlapResult include */
16#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 4
17#include "Engine/EngineTypes.h"
18#include "Engine/OverlapResult.h"
19#elif ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 4
20#include "Engine/EngineTypes.h"
21#else
22#include "Engine/OverlapResult.h"
23#endif
24
25
26#include "SplineMeshedComponent.generated.h"
27
28
30
32UENUM(
33 BlueprintType,
34 Category="YasiuSpline",
35 meta = ( DisplayName = "Roll Method", ToolTip = "Different methods to solve rotation along spline" )
36)
37enum class ESplineRotateMode : uint8 {
40
43
48
53
58
59 //SmoothRollSnaped,
60};
61
62
64UENUM(
65 BlueprintType,
66 Category="YasiuSpline",
67 meta = ( DisplayName = "Mesh Stretching Method", ToolTip = "Method fits meshes along spline" )
68)
85
86
87// UENUM(BlueprintType, meta = ( DisplayName = "SplineType", ToolTip = "What type of spline is it." ))
88// enum class ESplineRoadType : uint8 {
89// /// Allow junctions and extension with same type.
90// AllowFullExtension,
91//
92// /// Connect other road, but don't add points.
93// JunctionsOnly,
94//
95// /// Spline can be extended with new points, but no Junctions
96// PointExtensionOnly,
97//
98// /// This spline can only have 2 points.
99// TwoPointsOnly
100// };
101
105USTRUCT(BlueprintType, Category="YasiuSpline")
107 GENERATED_BODY()
108
109
110 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="YasiuSpline")
111 float PeriodDistance = 800;
112
114 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="YasiuSpline")
115 float Amplitude = 300;
116};
117
118
122USTRUCT(BlueprintType, Category="YasiuSpline")
124 GENERATED_BODY()
125
126
127 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="YasiuSpline")
128 float PeriodDistance = 800;
129
131 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="YasiuSpline")
132 float Amplitude = 400;
133
134 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="YasiuSpline")
135 bool AlternateDirection = false;
136
138 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="YasiuSpline")
139 int Resolution = 8;
140};
141
142
144USTRUCT(BlueprintType, Category="YasiuSpline")
146 GENERATED_BODY()
147
148
149 UPROPERTY(BlueprintReadWrite, Category="YasiuSpline")
150 float tangent = 0;
151
153 UPROPERTY(BlueprintReadWrite, Category="YasiuSpline")
154 float rotation = 0;
155};
156
157
159USTRUCT(BlueprintType, Category="YasiuSpline")
160struct FSplineMeshed_PointData {
161 GENERATED_BODY()
162
163 UPROPERTY(BlueprintReadWrite, Category="YasiuSpline")
164 FVector3f location = FVector3f();
165
166 UPROPERTY(BlueprintReadWrite, Category="YasiuSpline")
168};
169
170
172USTRUCT(BlueprintType, Category="YasiuSpline")
173struct FVectorRange {
174 GENERATED_BODY()
175
176 FVectorRange() {}
177
179 FVectorRange( float value )
180 : Min(FVector(value, value, value)), Max(FVector(value, value, value)) {};
181
183 FVectorRange( float valMin, float valMax )
184 : Min(FVector(valMin, valMin, valMin)), Max(FVector(valMax, valMax, valMax)) {};
185
187 FVectorRange( float amplitudeA, float amplitudeB, float amplitudeC )
188 : Min(FVector(-amplitudeA, -amplitudeB, -amplitudeC)), Max(FVector(amplitudeA, amplitudeB, amplitudeC)) {};
189
191 bool operator!=( const double& Number ) const
192 {
193 if ( Min.X != Number || Min.Y != Number || Min.Z != Number ) {
194 return true;
195 }
196 if ( Max.X != Number || Max.Y != Number || Max.Z != Number ) {
197 return true;
198 }
199 return false;
200 }
201
202 bool operator==( const double& Number ) const
203 {
204 if ( (Min.X == Number && Min.Y == Number && Min.Z == Number) && (Max.X == Number && Max.Y == Number && Max.Z ==
205 Number) ) {
206 return true;
207 }
208 return false;
209 }
210
212 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
213 FVector Min{-1, -1, -1};
214
216 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
217 FVector Max{1, 1, 1};
218};
219
220
222USTRUCT(BlueprintType, Category="YasiuSpline")
224 GENERATED_BODY()
225
226
227 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
228 int seed{5};
229
236 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
238
244 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
246
248 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
250};
251
252
254USTRUCT(BlueprintType, Category="YasiuSpline")
256 GENERATED_BODY()
257
258
259 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Collision")
260 TEnumAsByte<ECollisionEnabled::Type> CollisionEnabled = ECollisionEnabled::Type::QueryAndPhysics;
261
263 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Collision")
264 TEnumAsByte<ECollisionChannel> CollisionType = ECC_WorldDynamic;
265
267 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Collision")
268 TEnumAsByte<ECollisionResponse> CollisionResponse = ECR_Overlap;
269};
270
271
273USTRUCT(BlueprintType, Category="YasiuSpline", meta=(DisplayName="Mesh spawn parameters"))
274struct FSplineMeshedSpawnParams {
275 GENERATED_BODY()
276
277 FSplineMeshedSpawnParams() {};
278
281 const float& spacing,
282 const bool& deformMesh,
283 const ESplineMeshAxis::Type& forwardAxis,
284 const ESplineRotateMode& RotateMethod
285 )
286 : RotationMethod(RotateMethod), ForwardAxis(forwardAxis), MeshSpacing(spacing), DeformMesh(deformMesh) {} ;
287
289 const FTransform& MeshTransf,
290 const float& MeshSpacing,
291 const bool& DeformMesh,
292 ESplineMeshStretching FitMethod,
293 ESplineRotateMode RotateMethod,
294 ESplineMeshAxis::Type ForwardAxis
295 )
296 : StretchMethod(FitMethod), RotationMethod(RotateMethod), ForwardAxis(ForwardAxis), MeshSpacing(MeshSpacing),
297 DeformMesh(DeformMesh), MeshTransform(MeshTransf) {};
298
300 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Shape")
302
304 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Orientation")
306
308 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
309 TEnumAsByte<ESplineMeshAxis::Type> ForwardAxis = ESplineMeshAxis::X;
310
313 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Spacing")
314 float MeshSpacing = 50;
315
322 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Spacing")
324
326 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Shape")
327 bool DeformMesh = true;
328
333 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Shape")
335
337 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Shape")
339
341 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Orientation")
342 FVector UpVector{0, 0, 1};
343
350 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Shape")
351 FTransform MeshTransform{};
352
354 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Randomness")
356
358 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Collision")
360};
361
362
364USTRUCT(BlueprintType, Category="YasiuSpline")
366 GENERATED_BODY()
367
368
369 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Spline")
370 int pointIndex = 0;
371
373 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Spline")
374 float smoothness = 1;
375
377 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Spline")
378 float rotationZ = 0;
379};
380
381
383USTRUCT(BlueprintType, Category="YasiuSpline")
385 GENERATED_BODY()
386
387 static FSplineDebugParams Off()
388 {
389 auto params = FSplineDebugParams();
390 params.ShowDebug = false;
391 return params;
392 }
393
394 static FSplineDebugParams On()
395 {
396 auto params = FSplineDebugParams();
397 params.ShowDebug = true;
398 return params;
399 }
400
402 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
403 bool ShowDebug = false;
404
406 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
407 float DisplayTime = 3;
408
410 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
411 bool ShowEveryOverlap = true;
412
415 float DebugSphereRadius = 1;
416
419 FVector DebugBoxSize{1, 1, 1};
420};
421
422
427USTRUCT(BlueprintType, Blueprintable, Category="YasiuSpline")
429 GENERATED_BODY()
430
431
432 FCollisionQueryParams GetQueryParams() const;
433
435 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
436 TSoftObjectPtr<UStaticMesh> TestMesh{};
437
445 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
446 FTransform MeshTransform{};
447
450 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
451 TArray<TEnumAsByte<ECollisionChannel>> ObjectTypes{ECollisionChannel::ECC_WorldStatic};
452
454 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
455 float StepDistance = 50;
456
458 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
460
462 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
463 bool CenterMesh{true};
464
466 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
467 bool SelfIgnore{true};
468
470 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
471 FVector UpVector{0, 0, 1};
472
473 // UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
474 // TEnumAsByte<ECollisionResponse> TestResponse{ECR_Overlap};
475
477 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
479
481 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
482 bool UseSphere = false;
483
487 // UPROPERTY(BlueprintReadWrite, Category="CollisionTest")
488 UPROPERTY(BlueprintReadOnly, Category="FunctionInternal")
489 FVector ShapeSize{1, 1, 1};
490
491 // /// False means testing Overlap and Block response, while true will ignore overlap
492 // UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
493 // bool TestOnlyBlocking = false;
494
496 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
498
500 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest")
502
504 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest|QueryParams")
505 bool TraceComplex{false};
506
508 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest|QueryParams")
510
512 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest|QueryParams")
513 bool IgnoreBlocks{false};
514
516 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest|QueryParams")
517 bool IgnoreTouches{false};
518
520 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest|QueryParams")
521 bool SkipNarrowPhase{false};
522
523 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest|QueryParams")
524 TArray<AActor*> IgnoredActors;
525
527 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="CollisionTest|Debug")
529
531 UPROPERTY(BlueprintReadOnly, Category="YasiuSpline")
532 FVector LocationOffset{};
533};
534
535
537USTRUCT(BlueprintType, Category="YasiuSpline")
538struct FSplineMeshedOverlapResult {
539 GENERATED_BODY()
540
541 FSplineMeshedOverlapResult() {}
542
543 FSplineMeshedOverlapResult( AActor* act )
544 {
545 Actor = act;
546 }
547
548 FSplineMeshedOverlapResult( const FOverlapResult& result )
549 {
550 Actor = result.GetActor();
551 IsBlocking = result.bBlockingHit;
552 Component = result.GetComponent();
553 }
554
556 UPROPERTY(BlueprintReadWrite, Category="YasiuSpline")
557 AActor* Actor{nullptr};
558
560 UPROPERTY(BlueprintReadWrite, Category="YasiuSpline")
561 UPrimitiveComponent* Component{nullptr};
562
564 UPROPERTY(BlueprintReadWrite, Category="YasiuSpline")
565 bool IsBlocking{false};
566};
567
568
570USTRUCT(Blueprintable, BlueprintType, Category="YasiuSpline")
572 GENERATED_BODY()
573
574
575 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
576 FVector StartPos{};
577
579 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
580 FVector EndPos{};
581
583 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
584 FVector StartTangent{};
585
587 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
588 FVector EndTangent{};
589
591 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
592 FVector2D StartScale{1, 1};
593
595 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
596 FVector2D EndScale{1, 1};
597
599 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
600 float StartRoll{0};
601
603 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
604 float EndRoll{0};
605
607 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
608 FVector2D StartOffset{0};
609
611 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
612 FVector2D EndOffset{0};
613
614 /* Additional variables */
615
617 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
618 FTransform RelativeTransform = {};
619
621 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
622 FVector UpVector{0, 0, 1};
623
625 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
627
629 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
631};
632
633
635UCLASS(BlueprintType, Blueprintable, Category="YasiuSpline", meta = ( BlueprintSpawnableComponent ))
636class YASIUSPLINEMESHED_API USplineMeshedComponent : public USplineComponent {
637 GENERATED_BODY()
638
639public:
640 USplineMeshedComponent( const FObjectInitializer& Initializer )
641 : Super(Initializer)
642 {
643 auto col = FLinearColor(0.01, 0.1, 0.35);
644 SetUnselectedSplineSegmentColor(col);
645 };
646
647
648 virtual void BeginPlay() override;
649
650 virtual void DestroyComponent( bool bPromoteChildren = false ) override;
651
652 virtual void OnComponentDestroyed( bool bDestroyingHierarchy ) override;
653
654 virtual void EndPlay( const EEndPlayReason::Type reason ) override;
655
656 virtual void UninitializeComponent() override;
657
658#if WITH_EDITOR
659 virtual void PostEditChangeProperty( struct FPropertyChangedEvent& PropertyChangedEvent ) override;
660
661 /* Override for spline point move */
662 virtual void PostEditComponentMove( bool bFinished ) override;
663
664 // virtual void OnUnregister() override;
665
666 // virtual void OnCreatePhysicsState() override;
667
668 // virtual void OnDestroyPhysicsState() override;
669
670 virtual void PreEditUndo() override;
671
672 virtual void PostEditUndo() override;
673
674#endif
675
676public:
684 UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="YasiuSpline")
685 void PlaceMeshesAlongSpline( UStaticMesh* Mesh, const FSplineMeshedSpawnParams SpawnParameters );
686
688 virtual void PlaceMeshesAlongSpline_Implementation( UStaticMesh* Mesh, const FSplineMeshedSpawnParams SpawnParameters );
689
693 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
694 static void ApplyParamsToMesh( const FYasiuSplineMeshParams& params, USplineMeshComponent* Mesh );
695
699 UFUNCTION(BlueprintCallable, Category="YasiuSpline", BlueprintPure=false)
701 TArray<FYasiuSplineMeshParams>& OutArray,
702 const UStaticMesh* Mesh,
703 const FSplineMeshedSpawnParams& paramsIn
704 ) const;
705
722 UFUNCTION(BlueprintNativeEvent, Category="YasiuSpline")
724 const FVector& ForwardVec,
725 const FVector& UpVect,
726 const int SegmentID,
727 const float DistanceA,
728 const float DistanceB,
729 // const double splineKey,
730 USplineMeshComponent* RefMesh
731 );
732
743 virtual void OnMeshSpawn_Implementation(
744 const FVector& ForwardVec,
745 // asd
746 const FVector& UpVect,
747 const int SegmentID,
748 const float DistanceA,
749 const float DistanceB,
750 USplineMeshComponent* RefMesh
751 );
752
753
755 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
756 int Num() const { return MeshesArray.Num(); }
757
758/* Functions Modifiers */
759
765 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
766 void ChangeMesh( TSoftObjectPtr<UStaticMesh> Mesh );
767
772 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
773 void GetMeshes( TArray<class USplineMeshComponent*>& OutArray ) const;
774
779 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
780 virtual void SetMaterialsByIndex( const TArray<UMaterialInterface*>& materials );
781
783 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
784 virtual void CopySplinePoints( const USplineMeshedComponent* copyFrom );
785
787 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
788 virtual void CopySplineAndMeshes( const USplineMeshedComponent* copyFrom );
789
791 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
792 static void CopyMeshMaterials( const UMeshComponent* copyFrom, UMeshComponent* copyTo );
793
795 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="YasiuSpline", SkipSerialization)
797
799 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="YasiuSpline", SkipSerialization)
801
803 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="YasiuSpline", SkipSerialization)
805
807 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
808 void MakeHelix( const FSplineHelixParams& HelixParams );
809
811 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
812 void MakeSinus( const FSplineSinusParams& SinusParams );
813
815 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
816 ASplineMeshActor* SpawnMeshStaticClone( const USplineMeshComponent* Mesh );
817
821 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
822 TArray<ASplineMeshActor*> CloneSplineToStaticActors();
823
824#if WITH_EDITOR
826 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
827 void ChangeToSinus();
828
830 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
831 void ChangeToHelix();
832
834 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
835 void Decimate();
836
839 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
840 void FixMeshes();
841
844 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
845 void ClearMeshes();
846#endif
847
855 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
856 void SetSmoothnessAtPoint( int keyIndex, float smoothness = 1.f, float ZRotationDeg = 0.f );
857
862 UFUNCTION(BlueprintCallable, Category="SplineTools")
863 void SetSmoothnessAtAllPoints( float smoothness = 1.f, float ZRotationDeg = 0.f );
864
868 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
869 void OffsetAllPoints( const FVector& RelativeOffset );
870
872 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
874
876 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
877 void Soft() { SetSmoothnessAtAllPoints(0.5, 0); }
878
880 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
881 void Smooth();
882
884 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
886
888 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
890 {
892 }
893
895 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
897
898
914 UFUNCTION(BlueprintCallable, Category="YasiuSpline", BlueprintPure=false)
916 TArray<FSplineMeshedOverlapResult>& DetectResults,
917 FSplineDetectionTestParams DetectionParams
918 // FSplineDebugParams debugParams
919 ) const;
920
921protected:
925 void UpdateWithParent( bool ForceUpdate = false );
926
927private:
931 bool DetectObjectsHelper(
932 TArray<FSplineMeshedOverlapResult>& OutOverlaps,
933 FVector& locationIn,
934 FQuat& rotationIn,
935 const FSplineDetectionTestParams& paramsIn
936 ) const;
937
938public:
953 UFUNCTION(BlueprintNativeEvent, Category="YasiuSpline")
955 TArray<FSplineMeshedOverlapResult>& DetectedObjects,
956 UWorld* World,
957 const FVector& LocationIn,
958 const FQuat& RotationIn,
959 const FSplineDetectionTestParams& ParamsIn
960 ) const;
961
979 virtual void DetectionFunction_Implementation(
980 TArray<FSplineMeshedOverlapResult>& DetectedObjects,
981 UWorld* World,
982 const FVector& LocationIn,
983 const FQuat& RotationIn,
984 const FSplineDetectionTestParams& ParamsIn
985 ) const;
986
990 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
991 FVector GetSideOffset( const FVector& Fwd, const FVector& Up, float DistanceRight, float AngleDeg ) const;
992
1001 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
1003 float distanceA,
1004 float distanceB,
1005 const TEnumAsByte<ESplineCoordinateSpace::Type>& CoordSpace = ESplineCoordinateSpace::World
1006 ) const;
1007
1009 bool WasUpdated = true;
1010
1012 UFUNCTION(BlueprintCallable, Category="YasiuSpline")
1014 ESplineRotateMode Mode,
1015 const FVector& CurrentUp,
1016 const FVector& CurrentForward,
1017 const FVector& PrevUp,
1018 const FVector& UpParameter
1019 ) const;
1020
1021protected:
1023 UPROPERTY(BlueprintReadOnly, Category="YasiuSpline")
1024 TArray<TObjectPtr<USplineMeshComponent>> MeshesArray;
1025
1029 virtual void MeshArrayReserve( const int& amount );
1030
1032 static FVector FindClosestUpVector( const FVector& previousUp, const FVector& currentForward );
1033
1035 static FVector MatchVectors( const FVector& axis, FVector properOrientedVector, FVector splineVector );
1036};
1037
1038
1042USTRUCT(BlueprintType, Blueprintable, Category="YasiuSpline")
1044 GENERATED_BODY()
1045
1046
1047 UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(Category="SplineExtended"))
1048 float PeriodDistance = 1000;
1049
1051 UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(Category="SplineExtended"))
1052 float Amplitude = 300;
1053
1055 UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(Category="SplineExtended"))
1056 float PhaseOffset = 0;
1057
1059 UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(Category="SplineExtended"))
1060 bool UseAlternate = false;
1061
1063 UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(Category="SplineExtended"))
1064 bool RotateToShape = false;
1065
1069 UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(Category="SplineExtended"))
1070 bool UniformSize = true;
1071};
1072
1073
1075UCLASS(BlueprintType, Blueprintable, Category="YasiuSpline", meta = ( BlueprintSpawnableComponent ))
1076class YASIUSPLINEMESHED_API USplineMeshedComponent_Extension : public USplineMeshedComponent {
1077 GENERATED_BODY()
1078
1079public:
1084 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="YasiuSpline")
1086};
1087
1088
1090UCLASS(BlueprintType, Blueprintable, Category="YasiuSpline", meta = ( BlueprintSpawnableComponent ))
1092 GENERATED_BODY()
1093
1094public:
1098 virtual void OnMeshSpawn_Implementation(
1099 const FVector& forwardVec,
1100 const FVector& upVect,
1101 const int segmentID,
1102 const float distanceA,
1103 const float distanceB,
1104 USplineMeshComponent* refMesh
1105 ) override;
1106};
1107
1108
1110UCLASS(BlueprintType, Blueprintable, Category="YasiuSpline", meta = ( BlueprintSpawnableComponent ))
1112 GENERATED_BODY()
1113
1114public:
1118 virtual void OnMeshSpawn_Implementation(
1119 const FVector& forwardVec,
1120 const FVector& upVect,
1121 const int segmentID,
1122 const float distanceA,
1123 const float distanceB,
1124 USplineMeshComponent* refMesh
1125 ) override;
1126};
ESplineMeshStretching
Method that decides how to place meshes.
Definition SplineMeshedComponent.h:69
@ PipeStretching
Stretch meshes to make seamless connection at offset. (Can not use randomness).
Definition SplineMeshedComponent.h:83
@ StretchOnlyLast
Last mesh will stretch to fit to end.
Definition SplineMeshedComponent.h:74
@ ItemPerSegment
Places mesh object to fill single segment from point to point.
Definition SplineMeshedComponent.h:80
@ MinimalStretchOnAll
Fit segments from start to end. Applies minimal and equal stretch to all segments.
Definition SplineMeshedComponent.h:77
@ NoStretching
Only full meshes will be spawned.
Definition SplineMeshedComponent.h:71
ESplineRotateMode
Method that solved mesh rotation along spline.
Definition SplineMeshedComponent.h:37
@ DefaultFixed
(Same as Default) Fixes rare twist artifacts when mesh is spawn on opposite spline side....
Definition SplineMeshedComponent.h:52
@ SmoothRoll
Keep side faces aligned through whole spline smoothly. Good for vertical splines, but rotates more an...
Definition SplineMeshedComponent.h:57
@ ConstantRelative
Same UpVector for all meshes. Relative to component orientation (or owning actor).
Definition SplineMeshedComponent.h:42
@ ConstantAbsolute
Same UpVector for all meshes (World orientation).
Definition SplineMeshedComponent.h:39
@ Default
Gets spline's UpVector and copies it without modification. Good for horizontal splines.
Definition SplineMeshedComponent.h:47
Modified USplineMeshedComponent that spawns meshes in helix pattern.
Definition SplineMeshedComponent.h:1111
Modified USplineMeshedComponent that spawns meshes in zigzag/sinus pattern.
Definition SplineMeshedComponent.h:1091
Abstract class that uses bridge pattern.
Definition SplineMeshedComponent.h:1076
FSplineMeshed_ExtendedParams ExtendedSpline
Parameters used for customizing extended classes. Sinus and helix.
Definition SplineMeshedComponent.h:1085
void MakeSinus(const FSplineSinusParams &SinusParams)
Function that changes points to sinus.
void DetectionFunction(TArray< FSplineMeshedOverlapResult > &DetectedObjects, UWorld *World, const FVector &LocationIn, const FQuat &RotationIn, const FSplineDetectionTestParams &ParamsIn) const
Detection function's body, (can be customized), used by DetectObjectsAlongSpline. By default,...
FSplineSmoothParams TangentToolParams
Parameter used by editor commands.
Definition SplineMeshedComponent.h:804
bool DetectObjectsAlongSpline(TArray< FSplineMeshedOverlapResult > &DetectResults, FSplineDetectionTestParams DetectionParams) const
Detection function that iterates along spline and does multiple checks. Function evaluates shape of g...
static void ApplyParamsToMesh(const FYasiuSplineMeshParams &params, USplineMeshComponent *Mesh)
Applies all parameters from struct to SplineMesh Object, without Update. Except ForwardDirection and ...
static void CopyMeshMaterials(const UMeshComponent *copyFrom, UMeshComponent *copyTo)
Copy materials between meshes.
void CustomTangents()
Function will adjust tangents of single point using TangentToolParams variable.
Definition SplineMeshedComponent.h:889
void GetMeshes(TArray< class USplineMeshComponent * > &OutArray) const
Returns Copy of array containing only valid SplineMesh objects.
void OnMeshSpawn(const FVector &ForwardVec, const FVector &UpVect, const int SegmentID, const float DistanceA, const float DistanceB, USplineMeshComponent *RefMesh)
Function that is triggered after placing each mesh with corresponding values.
void PlaceMeshesAlongSpline(UStaticMesh *Mesh, const FSplineMeshedSpawnParams SpawnParameters)
Spawn meshes along spline by given params. Override if you intend to clear/set variables before spawn...
int Num() const
Current amount of meshes stored (may count invalid).
Definition SplineMeshedComponent.h:756
void CustomTangentsAllPoints()
Function will adjust tangents of all spline points using TangentToolParams variable.
Definition SplineMeshedComponent.h:896
void Soft()
Function will adjust tangents of all points to make it look smooth.
Definition SplineMeshedComponent.h:877
void ExtraCurvy()
Function will adjust tangents of all points to make it look extra smooth and very curvy.
Definition SplineMeshedComponent.h:885
virtual void CopySplineAndMeshes(const USplineMeshedComponent *copyFrom)
Copy spline points, curve and mesh properties.
virtual void SetMaterialsByIndex(const TArray< UMaterialInterface * > &materials)
Applies materials from array to all meshes.
void SetSmoothnessAtPoint(int keyIndex, float smoothness=1.f, float ZRotationDeg=0.f)
Change single point to have given smoothness and rotation. Does not update actor!
FSplineHelixParams HelixToolParams
Parameters to create helix spline in editor.
Definition SplineMeshedComponent.h:800
void MakeHelix(const FSplineHelixParams &HelixParams)
Function that changes points to helix.
void OffsetAllPoints(const FVector &RelativeOffset)
Function used to move all spline points with given relative offset.
ASplineMeshActor * SpawnMeshStaticClone(const USplineMeshComponent *Mesh)
Spawns static actor in world and copies spline mesh properties.
TArray< TObjectPtr< USplineMeshComponent > > MeshesArray
Array of created SplineMeshes.
Definition SplineMeshedComponent.h:1024
void Smooth()
Function will set all points type to Curve (they auto update tangents).
FVector GetSideOffset(const FVector &Fwd, const FVector &Up, float DistanceRight, float AngleDeg) const
Calculate helix offset defined by forward Axis, Up axis and rotation Angle.
void ChangeMesh(TSoftObjectPtr< UStaticMesh > Mesh)
Change static mesh in all Objects. (Updates only mesh's tangents).
FVector VectorFrom2Points(float distanceA, float distanceB, const TEnumAsByte< ESplineCoordinateSpace::Type > &CoordSpace=ESplineCoordinateSpace::World) const
Get normalized vector between 2 points, points are clamped to spline length.
TArray< ASplineMeshActor * > CloneSplineToStaticActors()
clone of all meshes in spline and make them static object
FSplineSinusParams SinusToolParams
Parameters to create sinus spline in editor.
Definition SplineMeshedComponent.h:796
void Sharp()
Function will adjust tangents of all points to make it sharp.
Definition SplineMeshedComponent.h:873
void SetSmoothnessAtAllPoints(float smoothness=1.f, float ZRotationDeg=0.f)
Change spline all points to have desired params.
void GetMeshPositonsArray(TArray< FYasiuSplineMeshParams > &OutArray, const UStaticMesh *Mesh, const FSplineMeshedSpawnParams &paramsIn) const
Function that evaluates mesh position and tangent based on params passed in.
FVector CalculateSplineUpVector(ESplineRotateMode Mode, const FVector &CurrentUp, const FVector &CurrentForward, const FVector &PrevUp, const FVector &UpParameter) const
Function used to calculate UpVector from given vectors.
virtual void CopySplinePoints(const USplineMeshedComponent *copyFrom)
Copy spline points and curve.
Params for drawing collision checks.
Definition SplineMeshedComponent.h:384
bool ShowDebug
Show debug when true.
Definition SplineMeshedComponent.h:403
float DisplayTime
Render time of shape.
Definition SplineMeshedComponent.h:407
bool ShowEveryOverlap
False = Show only colliding boxes, True = shows every box with red or green color.
Definition SplineMeshedComponent.h:411
Params used for collision check along spline. Some variables are mirrored to match unreal engine's **...
Definition SplineMeshedComponent.h:428
bool CenterMesh
Should mesh be centered or use origin offset.
Definition SplineMeshedComponent.h:463
bool IgnoreBlocks
Used in C++, Whether to ignore blocking results.
Definition SplineMeshedComponent.h:513
bool SelfIgnore
Should collision test ignore self components.
Definition SplineMeshedComponent.h:467
ESplineRotateMode RotationMethod
Rotation method related to mesh spawn.
Definition SplineMeshedComponent.h:459
bool StopAtFirstCollision
Stop iterating at first valid collision.
Definition SplineMeshedComponent.h:478
FCollisionQueryParams GetQueryParams() const
Function to convert structure into FCollisionQueryParams.
bool FindInitialOverlaps
Used in C++, Whether we want to find out initial overlap or not. If true, it will return if this was ...
Definition SplineMeshedComponent.h:509
TSoftObjectPtr< UStaticMesh > TestMesh
Mesh used for collision test.
Definition SplineMeshedComponent.h:436
FVector LocationOffset
Temporary offset used for computing location on spline.
Definition SplineMeshedComponent.h:532
TArray< TEnumAsByte< ECollisionChannel > > ObjectTypes
List of collision channels for testing in USplineMeshedComponent::DetectObjectsAlongSpline.
Definition SplineMeshedComponent.h:451
FSplineDebugParams DebugParams
Debug parms used to show overlap boxes.
Definition SplineMeshedComponent.h:528
bool LastOverlapWithingSplineLimits
Compensates boundary dimension to not extend beyond spline point, otherwise half of mesh will extend....
Definition SplineMeshedComponent.h:501
bool FirstOverlapWithingSplineLimits
Compensates boundary dimension to not extend beyond spline point, otherwise half of mesh will extend....
Definition SplineMeshedComponent.h:497
bool IgnoreTouches
Used in C++, Whether to ignore touch/overlap results.
Definition SplineMeshedComponent.h:517
bool SkipNarrowPhase
Used in C++, Whether to skip narrow phase checks (only for overlaps).
Definition SplineMeshedComponent.h:521
FVector ShapeSize
Run time variable evaluated and passed to detection function Box Shape size, For Sphere X is size....
Definition SplineMeshedComponent.h:489
bool UseSphere
Use sphere instead of bounding box.
Definition SplineMeshedComponent.h:482
FTransform MeshTransform
Relative transform for collision check.
Definition SplineMeshedComponent.h:446
FVector UpVector
Up vector related to Constant rotation mode In RotationMethod.
Definition SplineMeshedComponent.h:471
bool TraceComplex
Used in C++, Whether we should trace against complex collision.
Definition SplineMeshedComponent.h:505
float StepDistance
Distance between collision checks (mesh size is ignored).
Definition SplineMeshedComponent.h:455
Parameters for helix.
Definition SplineMeshedComponent.h:123
float PeriodDistance
Distance in unreal units for whole cycle.
Definition SplineMeshedComponent.h:128
int Resolution
Number of points for 1 period.
Definition SplineMeshedComponent.h:139
float Amplitude
Helix Amplitude.
Definition SplineMeshedComponent.h:132
Parameters used to set simple collision on mesh.
Definition SplineMeshedComponent.h:255
TEnumAsByte< ECollisionChannel > CollisionType
Object collision channel.
Definition SplineMeshedComponent.h:264
TEnumAsByte< ECollisionEnabled::Type > CollisionEnabled
Should collision be enabled.
Definition SplineMeshedComponent.h:260
TEnumAsByte< ECollisionResponse > CollisionResponse
Object response to same channel only.
Definition SplineMeshedComponent.h:268
Collision results returned for use in BP.
Definition SplineMeshedComponent.h:538
AActor * Actor
Actor reference.
Definition SplineMeshedComponent.h:557
bool IsBlocking
Was test blocking or touch.
Definition SplineMeshedComponent.h:565
UPrimitiveComponent * Component
Component of colliding actor.
Definition SplineMeshedComponent.h:561
Parameters used to customize mesh spawn along spline.
Definition SplineMeshedComponent.h:274
bool FixSharpDeformations
Removes (tangents) of meshes that are spawned on very tight curves. (FixInvalidTangents must be enabl...
Definition SplineMeshedComponent.h:338
bool DeformMesh
Can meshes be deformed with tangents.
Definition SplineMeshedComponent.h:327
ESplineMeshStretching StretchMethod
How many meshes should be spawned along spline.
Definition SplineMeshedComponent.h:301
bool AddMeshSizeToSpacing
Size of mesh in spine direction will be added to spacing step.
Definition SplineMeshedComponent.h:323
FSplineMeshedSpawnParams(const float &spacing, const bool &deformMesh, const ESplineMeshAxis::Type &forwardAxis, const ESplineRotateMode &RotateMethod)
For Spaced non-deformed meshes.
Definition SplineMeshedComponent.h:280
TEnumAsByte< ESplineMeshAxis::Type > ForwardAxis
Axis of mesh to be aligned along spline.
Definition SplineMeshedComponent.h:309
FVector UpVector
Vector for use with "Constant" rotation mode, ESplineRotateMode.
Definition SplineMeshedComponent.h:342
float MeshSpacing
Spacing between meshes, Scaled with MeshTransform for easier use. see also AddMeshSizeToSpacing.
Definition SplineMeshedComponent.h:314
FSplineRandomness MeshRandomness
Values used for randomizing rotation and translation. Not used with Stretching=Pipes.
Definition SplineMeshedComponent.h:355
FTransform MeshTransform
Relative transform change.
Definition SplineMeshedComponent.h:351
FSplineMeshedCollision CollisionPreset
Collision parameters that are applied to each mesh.
Definition SplineMeshedComponent.h:359
bool FixInvalidTangents
Fix tangents that are perpendicular (prevents deforms that show mesh inside).
Definition SplineMeshedComponent.h:334
ESplineRotateMode RotationMethod
Method used for solving up vector.
Definition SplineMeshedComponent.h:305
Params used in subclasses USplineMeshedComponent_Extension.
Definition SplineMeshedComponent.h:1043
float Amplitude
How far from center does elements will be placed.
Definition SplineMeshedComponent.h:1052
bool RotateToShape
Rotate meshes to align with temp spline.
Definition SplineMeshedComponent.h:1064
bool UseAlternate
Generate alternate variant of function.
Definition SplineMeshedComponent.h:1060
float PhaseOffset
Phase offset in distance units.
Definition SplineMeshedComponent.h:1056
float PeriodDistance
Period over distance.
Definition SplineMeshedComponent.h:1048
bool UniformSize
Uniform size means all meshes are same size, but it can create gaps. This option works only with Rota...
Definition SplineMeshedComponent.h:1070
Symmetric spline point representation.
Definition SplineMeshedComponent.h:145
float rotation
Twist rotation for spline point.
Definition SplineMeshedComponent.h:154
float tangent
How sharp/straight is spline curve. 0 is sharp.
Definition SplineMeshedComponent.h:150
Params used for randomizing each mesh.
Definition SplineMeshedComponent.h:223
FVectorRange Translation
Translation relative to spline:
Definition SplineMeshedComponent.h:237
int seed
Seed that is feed into Squirrel13 RNG.
Definition SplineMeshedComponent.h:228
FVectorRange Scale
Random scale range.
Definition SplineMeshedComponent.h:249
FVectorRange Rotation
Random rotation.
Definition SplineMeshedComponent.h:245
Parameters for sinus.
Definition SplineMeshedComponent.h:106
float Amplitude
Sinus Amplitude.
Definition SplineMeshedComponent.h:115
float PeriodDistance
Distance in unreal units for whole cycle.
Definition SplineMeshedComponent.h:111
Struct used in editor tools to modify spline.
Definition SplineMeshedComponent.h:365
int pointIndex
Point index in spline.
Definition SplineMeshedComponent.h:370
float smoothness
How smooth is tangent, 0 straight line, 1 is smooth, 1+ is move curvy.
Definition SplineMeshedComponent.h:374
float rotationZ
Additional twist in Z axis.
Definition SplineMeshedComponent.h:378
Pair of 2 vectors representing Min and Max values of XYZ.
Definition SplineMeshedComponent.h:173
bool operator!=(const double &Number) const
Checks if any element in Min/Max is different than passed Number.
Definition SplineMeshedComponent.h:191
FVectorRange(float amplitudeA, float amplitudeB, float amplitudeC)
Constructor with 3 amplitudes, Min = -amplitude, Max = amplitude.
Definition SplineMeshedComponent.h:187
FVector Max
Vector of max values.
Definition SplineMeshedComponent.h:217
FVector Min
Vector of min values.
Definition SplineMeshedComponent.h:213
FVectorRange(float valMin, float valMax)
Constructor for same min and max values.
Definition SplineMeshedComponent.h:183
FVectorRange(float value)
Constructor Value = Min = Max.
Definition SplineMeshedComponent.h:179
SplineMesh parameters passed between functions.
Definition SplineMeshedComponent.h:571
FVector EndPos
End location of spline, in component space.
Definition SplineMeshedComponent.h:580
FVector2D EndScale
X and Y scale applied to mesh at end of spline.
Definition SplineMeshedComponent.h:596
float StartRoll
Roll around spline applied at start, in radians.
Definition SplineMeshedComponent.h:600
float SplineDistanceStart
Distance for me where it starts.
Definition SplineMeshedComponent.h:626
float SplineDistanceEnd
Distance for me where it ends.
Definition SplineMeshedComponent.h:630
FVector StartTangent
Start tangent of spline, in component space.
Definition SplineMeshedComponent.h:584
FVector UpVector
UpVector for that mesh.
Definition SplineMeshedComponent.h:622
FVector StartPos
Start location of spline, in component space.
Definition SplineMeshedComponent.h:576
FVector2D StartOffset
Starting offset of the mesh from the spline, in component space.
Definition SplineMeshedComponent.h:608
FVector EndTangent
End tangent of spline, in component space.
Definition SplineMeshedComponent.h:588
FTransform RelativeTransform
Calculated Transform relative to actor.
Definition SplineMeshedComponent.h:618
FVector2D EndOffset
Ending offset of the mesh from the spline, in component space.
Definition SplineMeshedComponent.h:612
FVector2D StartScale
X and Y scale applied to mesh at start of spline.
Definition SplineMeshedComponent.h:592
float EndRoll
Roll around spline applied at end, in radians.
Definition SplineMeshedComponent.h:604