From 3caad3f3c9e319ca67d63231e8c64b2ace855fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Juh=C3=A1sz?= Date: Sat, 23 Jul 2016 21:11:20 +0200 Subject: Expose getPointedThing to Lua This commit introduces Raycast, a Lua user object, which can be used to perform a raycast on the map. The ray is continuable, so one can also get hidden nodes (for example to see trough glass). --- src/util/pointedthing.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/util/pointedthing.h') diff --git a/src/util/pointedthing.h b/src/util/pointedthing.h index 92c33968f..f63bcad9d 100644 --- a/src/util/pointedthing.h +++ b/src/util/pointedthing.h @@ -58,6 +58,11 @@ struct PointedThing * point of the collision and the nodebox of the node. */ v3s16 node_real_undersurface; + /*! + * Only valid if type is POINTEDTHING_OBJECT. + * The ID of the object the ray hit. + */ + s16 object_id = -1; /*! * Only valid if type isn't POINTEDTHING_NONE. * First intersection point of the ray and the nodebox. @@ -71,12 +76,19 @@ struct PointedThing */ v3s16 intersection_normal; /*! - * Only valid if type is POINTEDTHING_OBJECT. - * The ID of the object the ray hit. + * Square of the distance between the pointing + * ray's start point and the intersection point. */ - s16 object_id = -1; + f32 distanceSq = 0; + //! Constructor for POINTEDTHING_NOTHING PointedThing() {}; + //! Constructor for POINTEDTHING_NODE + PointedThing(const v3s16 &under, const v3s16 &above, + const v3s16 &real_under, const v3f &point, const v3s16 &normal, + f32 distSq); + //! Constructor for POINTEDTHING_OBJECT + PointedThing(s16 id, const v3f &point, const v3s16 &normal, f32 distSq); std::string dump() const; void serialize(std::ostream &os) const; void deSerialize(std::istream &is); -- cgit v1.2.3