CARLA
ActorWithRandomEngine.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017 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 
7 #include "Carla.h"
9 
10 #include "Util/RandomEngine.h"
11 
12 AActorWithRandomEngine::AActorWithRandomEngine(const FObjectInitializer& ObjectInitializer) :
13  Super(ObjectInitializer)
14 {
15  RandomEngine = CreateDefaultSubobject<URandomEngine>(TEXT("RandomEngine"));
16 }
17 
19 {
20  Super::OnConstruction(Transform);
21  check(RandomEngine != nullptr);
23 }
24 
25 #if WITH_EDITOR
26 void AActorWithRandomEngine::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
27 {
28  Super::PostEditChangeProperty(PropertyChangedEvent);
29  if (PropertyChangedEvent.Property) {
30  if (bGenerateRandomSeed) {
32  bGenerateRandomSeed = false;
33  }
34  check(RandomEngine != nullptr);
36  }
37 }
38 #endif // WITH_EDITOR
39 
40 void AActorWithRandomEngine::SetSeed(const int32 InSeed)
41 {
42  check(RandomEngine != nullptr);
43  Seed = InSeed;
44  RandomEngine->Seed(InSeed);
45 }
AActorWithRandomEngine(const FObjectInitializer &ObjectInitializer)
virtual void OnConstruction(const FTransform &Transform) override
bool bGenerateRandomSeed
Set a random seed.
void Seed(int32 InSeed)
Seed the random engine.
Definition: RandomEngine.h:44
static int32 GenerateRandomSeed()
Generate a non-deterministic random seed.
geom::Transform Transform
Definition: rpc/Transform.h:16
int32 Seed
Seed of the pseudo-random engine.