From 3caad3f3c9e319ca67d63231e8c64b2ace855fff Mon Sep 17 00:00:00 2001 From: Dániel Juhász 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/content_cao.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/content_cao.cpp') diff --git a/src/content_cao.cpp b/src/content_cao.cpp index aff143bf2..49c2049eb 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -283,8 +283,14 @@ public: void initialize(const std::string &data); - aabb3f *getSelectionBox() - {return &m_selection_box;} + + virtual bool getSelectionBox(aabb3f *toset) const + { + *toset = m_selection_box; + return true; + } + + v3f getPosition() {return m_position;} inline float getYaw() const @@ -605,11 +611,14 @@ GenericCAO::~GenericCAO() removeFromScene(true); } -aabb3f *GenericCAO::getSelectionBox() +bool GenericCAO::getSelectionBox(aabb3f *toset) const { - if(!m_prop.is_visible || !m_is_visible || m_is_local_player || getParent() != NULL) - return NULL; - return &m_selection_box; + if (!m_prop.is_visible || !m_is_visible || m_is_local_player + || getParent() != NULL){ + return false; + } + *toset = m_selection_box; + return true; } v3f GenericCAO::getPosition() @@ -658,7 +667,7 @@ void GenericCAO::setAttachments() updateAttachments(); } -ClientActiveObject* GenericCAO::getParent() +ClientActiveObject* GenericCAO::getParent() const { ClientActiveObject *obj = NULL; -- cgit v1.2.3