diff options
Diffstat (limited to 'src/util/pointedthing.cpp')
-rw-r--r-- | src/util/pointedthing.cpp | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/src/util/pointedthing.cpp b/src/util/pointedthing.cpp index 89cf91f22..b906264d0 100644 --- a/src/util/pointedthing.cpp +++ b/src/util/pointedthing.cpp @@ -24,20 +24,26 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <sstream> PointedThing::PointedThing(const v3s16 &under, const v3s16 &above, - const v3s16 &real_under, const v3f &point, const v3s16 &normal, - u16 box_id, f32 distSq) : - type(POINTEDTHING_NODE), - node_undersurface(under), node_abovesurface(above), - node_real_undersurface(real_under), intersection_point(point), - intersection_normal(normal), box_id(box_id), distanceSq(distSq) -{ -} + const v3s16 &real_under, const v3f &point, const v3s16 &normal, + u16 box_id, f32 distSq): + type(POINTEDTHING_NODE), + node_undersurface(under), + node_abovesurface(above), + node_real_undersurface(real_under), + intersection_point(point), + intersection_normal(normal), + box_id(box_id), + distanceSq(distSq) +{} -PointedThing::PointedThing(s16 id, const v3f &point, const v3s16 &normal, f32 distSq) : - type(POINTEDTHING_OBJECT), object_id(id), intersection_point(point), - intersection_normal(normal), distanceSq(distSq) -{ -} +PointedThing::PointedThing(s16 id, const v3f &point, const v3s16 &normal, + f32 distSq) : + type(POINTEDTHING_OBJECT), + object_id(id), + intersection_point(point), + intersection_normal(normal), + distanceSq(distSq) +{} std::string PointedThing::dump() const { @@ -46,12 +52,14 @@ std::string PointedThing::dump() const case POINTEDTHING_NOTHING: os << "[nothing]"; break; - case POINTEDTHING_NODE: { + case POINTEDTHING_NODE: + { const v3s16 &u = node_undersurface; const v3s16 &a = node_abovesurface; - os << "[node under=" << u.X << "," << u.Y << "," << u.Z - << " above=" << a.X << "," << a.Y << "," << a.Z << "]"; - } break; + os << "[node under=" << u.X << "," << u.Y << "," << u.Z << " above=" + << a.X << "," << a.Y << "," << a.Z << "]"; + } + break; case POINTEDTHING_OBJECT: os << "[object " << object_id << "]"; break; @@ -81,9 +89,9 @@ void PointedThing::serialize(std::ostream &os) const void PointedThing::deSerialize(std::istream &is) { int version = readU8(is); - if (version != 0) - throw SerializationError("unsupported PointedThing version"); - type = (PointedThingType)readU8(is); + if (version != 0) throw SerializationError( + "unsupported PointedThing version"); + type = (PointedThingType) readU8(is); switch (type) { case POINTEDTHING_NOTHING: break; @@ -101,15 +109,19 @@ void PointedThing::deSerialize(std::istream &is) bool PointedThing::operator==(const PointedThing &pt2) const { - if (type != pt2.type) { + if (type != pt2.type) + { return false; } - if (type == POINTEDTHING_NODE) { - if ((node_undersurface != pt2.node_undersurface) || - (node_abovesurface != pt2.node_abovesurface) || - (node_real_undersurface != pt2.node_real_undersurface)) + if (type == POINTEDTHING_NODE) + { + if ((node_undersurface != pt2.node_undersurface) + || (node_abovesurface != pt2.node_abovesurface) + || (node_real_undersurface != pt2.node_real_undersurface)) return false; - } else if (type == POINTEDTHING_OBJECT) { + } + else if (type == POINTEDTHING_OBJECT) + { if (object_id != pt2.object_id) return false; } |