DeskSim v2 0.1
Train simulator prototype created for Lokførerskolen
SplineActor.h
Go to the documentation of this file.
1// Copyright 2022 Thomas Arinesalingam, John Ole Bjerke, Endre Heksum & Henrik Markengbakken Karlsen . All Rights Reserved.
2
3/*****************************************************************/
10#pragma once
11
12#include "CoreMinimal.h"
13#include "GameFramework/Actor.h"
14#include "Components/SplineComponent.h"
15#include "Components/SplineMeshComponent.h"
16#include <DeskSimV2/SaveGame/IsSaveableInterface.h>
17#include "DrawDebugHelpers.h"
18#include "SplineActor.generated.h"
19
20UCLASS()
21class DESKSIMV2_API ASplineActor : public AActor, public IIsSaveableInterface
22{
23 GENERATED_BODY()
24
25public:
26 // Sets default values for this actor's properties
28
29 void OnConstruction(const FTransform& Transform) override;
30
31protected:
32 // Called when the game starts or when spawned
33 virtual void BeginPlay() override;
34
35public:
36 // Called every frame
37 virtual void Tick(float DeltaTime) override;
38
39public:
40 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Spline")
41 USplineComponent* SplineComponent;
42
43 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spline")
44 UStaticMesh* RailwayMesh;
45
46 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spline")
47 UStaticMesh* BufferStopStartMesh;
48
49 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spline")
50 UStaticMesh* BufferStopEndMesh;
51
52 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spline")
53 TEnumAsByte<ESplineMeshAxis::Type> ForwardAxis;
54
55 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spline")
56 int DistanceBetweenSplinePoints;
57
58 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spline")
59 float MaxHeightAllowed;
60
61 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spline")
62 float MaxAngleAllowed;
63
64 UPROPERTY(VisibleAnywhere, Category = "Spline")
65 bool bTrackTooSteep;
66
67 UPROPERTY(VisibleAnywhere, Category = "Spline")
68 bool bTrackTooWinding;
69
70private:
71 float GetMeshAxisLength(UStaticMesh* Mesh, ESplineMeshAxis::Type Axis) const;
72
73 FHitResult GetTerrainHitFromLineTrace(FVector Position) const;
74
75 void CheckSplineCurvature();
76
77 FCollisionQueryParams TerrainTraceParams;
78
79 TArray<FVector> UpdatedSplinePoints;
80};
Definition: SplineActor.h:22
Definition: IsSaveableInterface.h:20