CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Util
RandomEngine.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
7
#include "
Carla/Util/RandomEngine.h
"
8
#include "
Carla.h
"
9
10
#include <
util/disable-ue4-macros.h
>
11
#include <
carla/multigpu/sensorSync.h
>
12
#include <
util/enable-ue4-macros.h
>
13
14
#include <limits>
15
16
uint64
URandomEngine::GenerateRandomId
()
17
{
18
// Tuned to be fast as this function might get called relatively often.
19
static
thread_local
std::mt19937_64
Engine
((std::random_device())());
20
std::uniform_int_distribution<uint64> Distribution(
21
std::numeric_limits<uint64>::lowest(),
22
std::numeric_limits<uint64>::max());
23
return
Distribution(
Engine
);
24
}
25
26
int32
URandomEngine::GenerateRandomSeed
()
27
{
28
std::random_device RandomDevice;
29
std::uniform_int_distribution<int32> Distribution(
30
std::numeric_limits<int32>::lowest(),
31
std::numeric_limits<int32>::max());
32
return
Distribution(RandomDevice);
33
}
34
35
int32
URandomEngine::GenerateSeed
()
36
{
37
return
GetUniformIntInRange
(
38
std::numeric_limits<int32>::lowest(),
39
std::numeric_limits<int32>::max());
40
}
41
42
uint32
URandomEngine::GetState
()
const
43
{
44
return
carla::multigpu::GetEngineState
(
Engine
);
45
}
46
47
void
URandomEngine::SetState
(uint32 State)
48
{
49
carla::multigpu::SetEngineState
(
Engine
,
State
);
50
}
CarlaRecorderPacketId::State
@ State
Definition
CarlaRecorder.h:58
Carla.h
RandomEngine.h
URandomEngine::GetState
uint32 GetState() const
The engine's state, to continue its exact sequence elsewhere (a Multi-GPU secondary's mirror of a sen...
Definition
RandomEngine.cpp:42
URandomEngine::Engine
std::minstd_rand Engine
Definition
RandomEngine.h:166
URandomEngine::GetUniformIntInRange
int32 GetUniformIntInRange(int32 Minimum, int32 Maximum)
Definition
RandomEngine.h:68
URandomEngine::GenerateRandomId
static uint64 GenerateRandomId()
Generate a non-deterministic random id.
Definition
RandomEngine.cpp:16
URandomEngine::SetState
void SetState(uint32 State)
Continue from State, as GetState returned it; an impossible value is ignored.
Definition
RandomEngine.cpp:47
URandomEngine::GenerateRandomSeed
static int32 GenerateRandomSeed()
Generate a non-deterministic random seed.
Definition
RandomEngine.cpp:26
URandomEngine::GenerateSeed
int32 GenerateSeed()
Generate a seed derived from previous seed.
Definition
RandomEngine.cpp:35
disable-ue4-macros.h
enable-ue4-macros.h
carla::multigpu::GetEngineState
uint32_t GetEngineState(const std::minstd_rand &engine)
The state of a minstd_rand: the value its next draw is computed from.
Definition
sensorSync.h:254
carla::multigpu::SetEngineState
bool SetEngineState(std::minstd_rand &engine, uint32_t state)
Makes engine continue from state, as GetEngineState returned it.
Definition
sensorSync.h:264
sensorSync.h
Generated by
1.18.0