CARLA
载入中...
搜索中...
未找到
Unreal
CarlaUE4
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderCollision.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 "
CarlaRecorder.h
"
8
#include "
CarlaRecorderCollision.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
void
CarlaRecorderCollision::Read
(std::istream &InFile)
12
{
13
// id
14
ReadValue<uint32_t>(InFile, this->
Id
);
15
// actors database id
16
ReadValue<uint32_t>(InFile, this->
DatabaseId1
);
17
ReadValue<uint32_t>(InFile, this->
DatabaseId2
);
18
// is hero
19
ReadValue<bool>(InFile, this->
IsActor1Hero
);
20
ReadValue<bool>(InFile, this->
IsActor2Hero
);
21
}
22
void
CarlaRecorderCollision::Write
(std::ostream &OutFile)
const
23
{
24
// id
25
WriteValue<uint32_t>(OutFile, this->
Id
);
26
// actors database id
27
WriteValue<uint32_t>(OutFile, this->
DatabaseId1
);
28
WriteValue<uint32_t>(OutFile, this->
DatabaseId2
);
29
// is hero
30
WriteValue<bool>(OutFile, this->
IsActor1Hero
);
31
WriteValue<bool>(OutFile, this->
IsActor2Hero
);
32
}
33
bool
CarlaRecorderCollision::operator==
(
const
CarlaRecorderCollision
&
Other
)
const
34
{
35
return
(this->
DatabaseId1
== Other.
DatabaseId1
&&
36
this->DatabaseId2 ==
Other
.DatabaseId2);
37
}
38
//---------------------------------------------
39
40
void
CarlaRecorderCollisions::Clear
(
void
)
41
{
42
Collisions
.clear();
43
}
44
45
void
CarlaRecorderCollisions::Add
(
const
CarlaRecorderCollision
&
Collision
)
46
{
47
Collisions
.insert(std::move(
Collision
));
48
}
49
50
void
CarlaRecorderCollisions::Write
(std::ostream &OutFile)
51
{
52
// write the packet id
53
WriteValue<char>(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::Collision
));
54
55
// write the packet size
56
uint32_t Total = 2 +
Collisions
.size() *
sizeof
(
CarlaRecorderCollision
);
57
WriteValue<uint32_t>(OutFile, Total);
58
59
// write total records
60
Total =
Collisions
.size();
61
WriteValue<uint16_t>(OutFile, Total);
62
63
// for (uint16_t i=0; i<Total; ++i)
64
for
(
auto
&Coll :
Collisions
)
65
{
66
Coll.Write(OutFile);
67
}
68
}
ELightType::Other
@ Other
CarlaRecorderCollision.h
CarlaRecorderHelpers.h
CarlaRecorder.h
CarlaRecorderPacketId::Collision
@ Collision
CarlaRecorderCollisions::Add
void Add(const CarlaRecorderCollision &Collision)
Definition
CarlaRecorderCollision.cpp:45
CarlaRecorderCollisions::Clear
void Clear(void)
Definition
CarlaRecorderCollision.cpp:40
CarlaRecorderCollisions::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderCollision.cpp:50
CarlaRecorderCollisions::Collisions
std::unordered_set< CarlaRecorderCollision > Collisions
Definition
CarlaRecorderCollision.h:53
CarlaRecorderCollision
Definition
CarlaRecorderCollision.h:15
CarlaRecorderCollision::DatabaseId2
uint32_t DatabaseId2
Definition
CarlaRecorderCollision.h:18
CarlaRecorderCollision::IsActor1Hero
bool IsActor1Hero
Definition
CarlaRecorderCollision.h:19
CarlaRecorderCollision::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderCollision.cpp:11
CarlaRecorderCollision::Write
void Write(std::ostream &OutFile) const
Definition
CarlaRecorderCollision.cpp:22
CarlaRecorderCollision::Id
uint32_t Id
Definition
CarlaRecorderCollision.h:16
CarlaRecorderCollision::IsActor2Hero
bool IsActor2Hero
Definition
CarlaRecorderCollision.h:20
CarlaRecorderCollision::operator==
bool operator==(const CarlaRecorderCollision &Other) const
Definition
CarlaRecorderCollision.cpp:33
CarlaRecorderCollision::DatabaseId1
uint32_t DatabaseId1
Definition
CarlaRecorderCollision.h:17
制作者
1.10.0