3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "../irrlichttypes.h"
23 #include "../irr_v3d.h"
34 //! An active object or node which is selected by a ray on the map.
37 //! The type of the pointed object.
38 PointedThingType type = POINTEDTHING_NOTHING;
40 * Only valid if type is POINTEDTHING_NODE.
41 * The coordinates of the node which owns the
42 * nodebox that the ray hits first.
43 * This may differ from node_real_undersurface if
44 * a nodebox exceeds the limits of its node.
46 v3s16 node_undersurface;
48 * Only valid if type is POINTEDTHING_NODE.
49 * The coordinates of the last node the ray intersects
50 * before node_undersurface. Same as node_undersurface
51 * if the ray starts in a nodebox.
53 v3s16 node_abovesurface;
55 * Only valid if type is POINTEDTHING_NODE.
56 * The coordinates of the node which contains the
57 * point of the collision and the nodebox of the node.
59 v3s16 node_real_undersurface;
61 * Only valid if type is POINTEDTHING_OBJECT.
62 * The ID of the object the ray hit.
66 * Only valid if type isn't POINTEDTHING_NONE.
67 * First intersection point of the ray and the nodebox.
69 v3f intersection_point;
71 * Only valid if type isn't POINTEDTHING_NONE.
72 * Normal vector of the intersection.
73 * This is perpendicular to the face the ray hits,
74 * points outside of the box and it's length is 1.
76 v3s16 intersection_normal;
78 * Square of the distance between the pointing
79 * ray's start point and the intersection point.
83 //! Constructor for POINTEDTHING_NOTHING
84 PointedThing() = default;
85 //! Constructor for POINTEDTHING_NODE
86 PointedThing(const v3s16 &under, const v3s16 &above,
87 const v3s16 &real_under, const v3f &point, const v3s16 &normal,
89 //! Constructor for POINTEDTHING_OBJECT
90 PointedThing(s16 id, const v3f &point, const v3s16 &normal, f32 distSq);
91 std::string dump() const;
92 void serialize(std::ostream &os) const;
93 void deSerialize(std::istream &is);
95 * This function ignores the intersection point and normal.
97 bool operator==(const PointedThing &pt2) const;
98 bool operator!=(const PointedThing &pt2) const;