CARLA
ActorWithRandomEngine.h
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 #pragma once
8 
9 #include "GameFramework/Actor.h"
10 
11 #include "ActorWithRandomEngine.generated.h"
12 
13 class URandomEngine;
14 
15 /// Base class for actors containing a random engine with a fixed seed.
16 UCLASS(Abstract)
17 class CARLA_API AActorWithRandomEngine : public AActor
18 {
19  GENERATED_BODY()
20 
21 public:
22 
23  AActorWithRandomEngine(const FObjectInitializer& ObjectInitializer);
24 
25 protected:
26 
27  virtual void OnConstruction(const FTransform &Transform) override;
28 
29 #if WITH_EDITOR
30  virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
31 #endif // WITH_EDITOR
32 
33 public:
34 
35  UFUNCTION(BlueprintCallable)
36  URandomEngine *GetRandomEngine()
37  {
38  return RandomEngine;
39  }
40 
41  UFUNCTION(BlueprintCallable)
42  int32 GetSeed() const
43  {
44  return Seed;
45  }
46 
47  UFUNCTION(BlueprintCallable)
48  void SetSeed(int32 InSeed);
49 
50 private:
51 
52  /** Set a random seed. */
53  UPROPERTY(Category = "Random Engine", EditAnywhere)
54  bool bGenerateRandomSeed = false;
55 
56  /** Seed of the pseudo-random engine. */
57  UPROPERTY(Category = "Random Engine", EditAnywhere)
58  int32 Seed = 123456789;
59 
60  UPROPERTY()
61  URandomEngine *RandomEngine;
62 };
Base class for actors containing a random engine with a fixed seed.
void Seed(int32 InSeed)
Seed the random engine.
Definition: RandomEngine.h:44
std::minstd_rand Engine
Definition: RandomEngine.h:158
geom::Transform Transform
Definition: rpc/Transform.h:16