CARLA
 
载入中...
搜索中...
未找到
ActorWithRandomEngine.cpp
浏览该文件的文档.
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
12AActorWithRandomEngine::AActorWithRandomEngine(const FObjectInitializer& ObjectInitializer) :
13 Super(ObjectInitializer)
14{
15 RandomEngine = CreateDefaultSubobject<URandomEngine>(TEXT("RandomEngine"));
16}
17
18void AActorWithRandomEngine::OnConstruction(const FTransform &Transform)
19{
20 Super::OnConstruction(Transform);
21 check(RandomEngine != nullptr);
23}
24
25#if WITH_EDITOR
26void AActorWithRandomEngine::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
27{
28 Super::PostEditChangeProperty(PropertyChangedEvent);
29 if (PropertyChangedEvent.Property) {
32 bGenerateRandomSeed = false;
33 }
34 check(RandomEngine != nullptr);
36 }
37}
38#endif // WITH_EDITOR
39
40void AActorWithRandomEngine::SetSeed(const int32 InSeed)
41{
42 check(RandomEngine != nullptr);
43 Seed = InSeed;
44 RandomEngine->Seed(InSeed);
45}
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.
void Seed(int32 InSeed)
Seed the random engine.
static int32 GenerateRandomSeed()
Generate a non-deterministic random seed.