Add comparison operators to geom classes
This commit is contained in:
parent
7722f112ba
commit
d5f349cfff
|
@ -48,6 +48,14 @@ namespace geom {
|
|||
return lhs;
|
||||
}
|
||||
|
||||
bool operator==(const Location &rhs) const {
|
||||
return static_cast<const Vector3D &>(*this) == rhs;
|
||||
}
|
||||
|
||||
bool operator!=(const Location &rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
#ifdef LIBCARLA_INCLUDED_FROM_UE4
|
||||
|
||||
Location(const FVector &vector) // from centimeters to meters.
|
||||
|
|
|
@ -29,6 +29,14 @@ namespace geom {
|
|||
float yaw = 0.0f;
|
||||
float roll = 0.0f;
|
||||
|
||||
bool operator==(const Rotation &rhs) const {
|
||||
return (pitch == rhs.pitch) && (yaw == rhs.yaw) && (roll == rhs.roll);
|
||||
}
|
||||
|
||||
bool operator!=(const Rotation &rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
#ifdef LIBCARLA_INCLUDED_FROM_UE4
|
||||
|
||||
Rotation(const FRotator &rotator)
|
||||
|
|
|
@ -29,6 +29,14 @@ namespace geom {
|
|||
Location location;
|
||||
Rotation rotation;
|
||||
|
||||
bool operator==(const Transform &rhs) const {
|
||||
return (location == rhs.location) && (rotation == rhs.rotation);
|
||||
}
|
||||
|
||||
bool operator!=(const Transform &rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
#ifdef LIBCARLA_INCLUDED_FROM_UE4
|
||||
|
||||
Transform(const FTransform &transform)
|
||||
|
|
|
@ -49,6 +49,14 @@ namespace geom {
|
|||
return lhs;
|
||||
}
|
||||
|
||||
bool operator==(const Vector3D &rhs) const {
|
||||
return (x == rhs.x) && (y == rhs.y) && (z == rhs.z);
|
||||
}
|
||||
|
||||
bool operator!=(const Vector3D &rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
/// @todo The following is copy-pasted from MSGPACK_DEFINE_ARRAY.
|
||||
/// This is a workaround for an issue in msgpack library. The
|
||||
|
|
|
@ -114,6 +114,8 @@ void export_blueprint() {
|
|||
.def_readwrite("g", &csd::Color::g)
|
||||
.def_readwrite("b", &csd::Color::b)
|
||||
.def_readwrite("a", &csd::Color::a)
|
||||
.def("__eq__", &csd::Color::operator==)
|
||||
.def("__ne__", &csd::Color::operator!=)
|
||||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ void export_transform() {
|
|||
.def_readwrite("x", &cg::Vector3D::x)
|
||||
.def_readwrite("y", &cg::Vector3D::y)
|
||||
.def_readwrite("z", &cg::Vector3D::z)
|
||||
.def("__eq__", &cg::Vector3D::operator==)
|
||||
.def("__ne__", &cg::Vector3D::operator!=)
|
||||
.def(self += self)
|
||||
.def(self + self)
|
||||
.def(self -= self)
|
||||
|
@ -61,6 +63,8 @@ void export_transform() {
|
|||
.add_property("x", +[](const cg::Location &self) { return self.x; }, +[](cg::Location &self, float x) { self.x = x; })
|
||||
.add_property("y", +[](const cg::Location &self) { return self.y; }, +[](cg::Location &self, float y) { self.y = y; })
|
||||
.add_property("z", +[](const cg::Location &self) { return self.z; }, +[](cg::Location &self, float z) { self.z = z; })
|
||||
.def("__eq__", &cg::Location::operator==)
|
||||
.def("__ne__", &cg::Location::operator!=)
|
||||
.def(self += self)
|
||||
.def(self + self)
|
||||
.def(self -= self)
|
||||
|
@ -73,6 +77,8 @@ void export_transform() {
|
|||
.def_readwrite("pitch", &cg::Rotation::pitch)
|
||||
.def_readwrite("yaw", &cg::Rotation::yaw)
|
||||
.def_readwrite("roll", &cg::Rotation::roll)
|
||||
.def("__eq__", &cg::Rotation::operator==)
|
||||
.def("__ne__", &cg::Rotation::operator!=)
|
||||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
||||
|
@ -81,6 +87,8 @@ void export_transform() {
|
|||
(arg("location")=cg::Location(), arg("rotation")=cg::Rotation())))
|
||||
.def_readwrite("location", &cg::Transform::location)
|
||||
.def_readwrite("rotation", &cg::Transform::rotation)
|
||||
.def("__eq__", &cg::Transform::operator==)
|
||||
.def("__ne__", &cg::Transform::operator!=)
|
||||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue