CARLA
Loading...
Searching...
No Matches
ActorWithRandomEngine.cpp
Go to the documentation of this file.
1// Copyright (c) 2026 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#include "Carla.h"
10
11AActorWithRandomEngine::AActorWithRandomEngine(const FObjectInitializer& ObjectInitializer) :
12 Super(ObjectInitializer)
13{
14 RandomEngine = CreateDefaultSubobject<URandomEngine>(TEXT("RandomEngine"));
15}
16
18{
19 Super::OnConstruction(Transform);
20 check(RandomEngine != nullptr);
22}
23
24#if WITH_EDITOR
25void AActorWithRandomEngine::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
26{
27 Super::PostEditChangeProperty(PropertyChangedEvent);
28 if (PropertyChangedEvent.Property) {
31 bGenerateRandomSeed = false;
32 }
33 check(RandomEngine != nullptr);
35 }
36}
37#endif // WITH_EDITOR
38
39void AActorWithRandomEngine::SetSeed(const int32 InSeed)
40{
41 check(RandomEngine != nullptr);
42 Seed = InSeed;
43 RandomEngine->Seed(InSeed);
44}
int32 Seed
Seed of the pseudo-random engine.
virtual void OnConstruction(const FTransform &Transform) override
AActorWithRandomEngine(const FObjectInitializer &ObjectInitializer)
bool bGenerateRandomSeed
Set a random seed.
A rigid transform in CARLA's / Unreal's left-handed frame: x forward, y right, z up,...
void Seed(int32 InSeed)
Seed the random engine.
static int32 GenerateRandomSeed()
Generate a non-deterministic random seed.