incrementaltp: respect physics overrides
[waspsaliva.git] / src / util / pointedthing.h
blob5b30ed03135446706883ea3a60408967368b9dd4
1 /*
2 Minetest
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.
20 #pragma once
22 #include "irrlichttypes.h"
23 #include "irr_v3d.h"
24 #include <iostream>
25 #include <string>
27 enum PointedThingType
29 POINTEDTHING_NOTHING,
30 POINTEDTHING_NODE,
31 POINTEDTHING_OBJECT
34 //! An active object or node which is selected by a ray on the map.
35 struct PointedThing
37 //! The type of the pointed object.
38 PointedThingType type = POINTEDTHING_NOTHING;
39 /*!
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;
47 /*!
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;
54 /*!
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;
60 /*!
61 * Only valid if type is POINTEDTHING_OBJECT.
62 * The ID of the object the ray hit.
64 s16 object_id = -1;
65 /*!
66 * Only valid if type isn't POINTEDTHING_NONE.
67 * First intersection point of the ray and the nodebox in irrlicht
68 * coordinates.
70 v3f intersection_point;
71 /*!
72 * Only valid if type isn't POINTEDTHING_NONE.
73 * Normal vector of the intersection.
74 * This is perpendicular to the face the ray hits,
75 * points outside of the box and it's length is 1.
77 v3s16 intersection_normal;
78 /*!
79 * Only valid if type isn't POINTEDTHING_NONE.
80 * Indicates which selection box is selected, if there are more of them.
82 u16 box_id = 0;
83 /*!
84 * Square of the distance between the pointing
85 * ray's start point and the intersection point in irrlicht coordinates.
87 f32 distanceSq = 0;
89 //! Constructor for POINTEDTHING_NOTHING
90 PointedThing() = default;
91 //! Constructor for POINTEDTHING_NODE
92 PointedThing(const v3s16 &under, const v3s16 &above,
93 const v3s16 &real_under, const v3f &point, const v3s16 &normal,
94 u16 box_id, f32 distSq);
95 //! Constructor for POINTEDTHING_OBJECT
96 PointedThing(s16 id, const v3f &point, const v3s16 &normal, f32 distSq);
97 std::string dump() const;
98 void serialize(std::ostream &os) const;
99 void deSerialize(std::istream &is);
101 * This function ignores the intersection point and normal.
103 bool operator==(const PointedThing &pt2) const;
104 bool operator!=(const PointedThing &pt2) const;