CARLA
 
载入中...
搜索中...
未找到
BaseVegetationActor.cpp
浏览该文件的文档.
1// Copyright (c) 2022 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
8
9#include "Carla/Carla.h"
10
11
13{
14 TRACE_CPUPROFILER_EVENT_SCOPE(ABaseVegetationActor::BeginPlay);
15 Super::BeginPlay();
16}
17
19{
20 UActorComponent* Component =
21 GetComponentByClass(USpringBasedVegetationComponent::StaticClass());
22 USpringBasedVegetationComponent* SpringComponent =
23 Cast<USpringBasedVegetationComponent>(Component);
24
25 if (!SpringComponent)
26 {
27 UE_LOG(LogCarla, Error,
28 TEXT("ABaseVegetationActor::GetParametersFromComponent Component not found"));
29 return;
30 }
31
32 SpringParameters.Beta = SpringComponent->Beta;
33 SpringParameters.Alpha = SpringComponent->Alpha;
34 SpringParameters.Gravity = SpringComponent->Gravity;
35 SpringParameters.BaseSpringStrength = SpringComponent->BaseSpringStrength;
36 SpringParameters.MinSpringStrength = SpringComponent->MinSpringStrength;
37 SpringParameters.HorizontalFallof = SpringComponent->HorizontalFallof;
38 SpringParameters.VerticalFallof = SpringComponent->VerticalFallof;
39 SpringParameters.RestFactor = SpringComponent->RestFactor;
40 SpringParameters.DeltaTimeOverride = SpringComponent->DeltaTimeOverride;
41 SpringParameters.CollisionForceParameter = SpringComponent->CollisionForceParameter;
42 SpringParameters.CollisionForceMinVel = SpringComponent->CollisionForceMinVel;
43 SpringParameters.ForceDistanceFalloffExponent = SpringComponent->ForceDistanceFalloffExponent;
44 SpringParameters.ForceMaxDistance = SpringComponent->ForceMaxDistance;
45 SpringParameters.MinForceFactor = SpringComponent->MinForceFactor;
46 SpringParameters.LineTraceMaxDistance = SpringComponent->LineTraceMaxDistance;
47 SpringParameters.CapsuleRadius = SpringComponent->CapsuleRadius;
48 SpringParameters.MinBoneLength = SpringComponent->MinBoneLength;
49 SpringParameters.SpringStrengthMulFactor = SpringComponent->SpringStrengthMulFactor;
50 SpringParameters.VehicleCenterZOffset = SpringComponent->VehicleCenterZOffset;
51 SpringParameters.Skeleton = SpringComponent->Skeleton;
52 SpringParameters.bAutoComputeStrength = SpringComponent->bAutoComputeStrength;
53
54 UE_LOG(LogCarla, Log,
55 TEXT("ABaseVegetationActor::GetParametersFromComponent Copy successful"));
56}
57
59{
60 UActorComponent* Component =
61 GetComponentByClass(USpringBasedVegetationComponent::StaticClass());
62 USpringBasedVegetationComponent* SpringComponent =
63 Cast<USpringBasedVegetationComponent>(Component);
64 if (!SpringComponent)
65 {
66 UE_LOG(LogCarla, Error, TEXT("ABaseVegetationActor::SetParametersToComponent Component not found"));
67 return;
68 }
69
70 SpringComponent->Beta = SpringParameters.Beta;
71 SpringComponent->Alpha = SpringParameters.Alpha;
72 SpringComponent->Gravity = SpringParameters.Gravity;
73 SpringComponent->BaseSpringStrength = SpringParameters.BaseSpringStrength;
74 SpringComponent->MinSpringStrength = SpringParameters.MinSpringStrength;
75 SpringComponent->HorizontalFallof = SpringParameters.HorizontalFallof;
76 SpringComponent->VerticalFallof = SpringParameters.VerticalFallof;
77 SpringComponent->RestFactor = SpringParameters.RestFactor;
78 SpringComponent->DeltaTimeOverride = SpringParameters.DeltaTimeOverride;
79 SpringComponent->CollisionForceParameter = SpringParameters.CollisionForceParameter;
80 SpringComponent->CollisionForceMinVel = SpringParameters.CollisionForceMinVel;
81 SpringComponent->ForceDistanceFalloffExponent = SpringParameters.ForceDistanceFalloffExponent;
82 SpringComponent->ForceMaxDistance = SpringParameters.ForceMaxDistance;
83 SpringComponent->MinForceFactor = SpringParameters.MinForceFactor;
84 SpringComponent->LineTraceMaxDistance = SpringParameters.LineTraceMaxDistance;
85 SpringComponent->CapsuleRadius = SpringParameters.CapsuleRadius;
86 SpringComponent->MinBoneLength = SpringParameters.MinBoneLength;
87 SpringComponent->SpringStrengthMulFactor = SpringParameters.SpringStrengthMulFactor;
88 SpringComponent->VehicleCenterZOffset = SpringParameters.VehicleCenterZOffset;
89 SpringComponent->Skeleton = SpringParameters.Skeleton;
90 SpringComponent->bAutoComputeStrength = SpringParameters.bAutoComputeStrength;
91
92}
93
95{
96 UActorComponent* Component =
97 GetComponentByClass(USpringBasedVegetationComponent::StaticClass());
98 USpringBasedVegetationComponent* SpringComponent =
99 Cast<USpringBasedVegetationComponent>(Component);
100 if (!SpringComponent)
101 {
102 UE_LOG(LogCarla, Error, TEXT("ABaseVegetationActor::UpdateSkeletonAndParameters Component not found"));
103 return;
104 }
106 SpringComponent->GenerateSkeletonHierarchy();
107 SpringComponent->ComputeSpringStrengthForBranches();
109}
virtual void BeginPlay() override
FSpringBasedVegetationParameters SpringParameters