summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorDániel Juhász <juhdanad@gmail.com>2017-01-04 19:18:40 +0100
committerest31 <est31@users.noreply.github.com>2017-01-04 19:18:40 +0100
commit3f8261830e0503cd59d8713d5c9aab12fc1491db (patch)
treeb49d898815a6c2e692cfe2fc0978cfedd49cd34f /src/client.cpp
parent8aadc62856cc3789ed345ddf3870e311af60afe9 (diff)
downloadminetest-3f8261830e0503cd59d8713d5c9aab12fc1491db.tar.gz
minetest-3f8261830e0503cd59d8713d5c9aab12fc1491db.tar.bz2
minetest-3f8261830e0503cd59d8713d5c9aab12fc1491db.zip
Improve getPointedThing() (#4346)
* Improved getPointedThing() The new algorithm checks every node exactly once. Now the point and normal vector of the collision is also returned in the PointedThing (currently they are not used outside of the function). Now the CNodeDefManager keeps the union of all possible nodeboxes, so the raycast won't miss any nodes. Also if there are only small nodeboxes, getPointedThing() is exceptionally fast. Also adds unit test for VoxelLineIterator. * Cleanup, code move This commit moves getPointedThing() and Client::getSelectedActiveObject() to ClientEnvironment. The map nodes now can decide which neighbors they are connecting to (MapNode::getNeighbors()).
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp39
1 files changed, 1 insertions, 38 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 1446ebad8..693a90604 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -53,6 +53,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "database-sqlite3.h"
#include "serialization.h"
#include "guiscalingfilter.h"
+#include "raycast.h"
extern gui::IGUIEnvironment* guienv;
@@ -1500,44 +1501,6 @@ void Client::inventoryAction(InventoryAction *a)
delete a;
}
-ClientActiveObject * Client::getSelectedActiveObject(
- f32 max_d,
- v3f from_pos_f_on_map,
- core::line3d<f32> shootline_on_map
- )
-{
- std::vector<DistanceSortedActiveObject> objects;
-
- m_env.getActiveObjects(from_pos_f_on_map, max_d, objects);
-
- // Sort them.
- // After this, the closest object is the first in the array.
- std::sort(objects.begin(), objects.end());
-
- for(unsigned int i=0; i<objects.size(); i++)
- {
- ClientActiveObject *obj = objects[i].obj;
-
- aabb3f *selection_box = obj->getSelectionBox();
- if(selection_box == NULL)
- continue;
-
- v3f pos = obj->getPosition();
-
- aabb3f offsetted_box(
- selection_box->MinEdge + pos,
- selection_box->MaxEdge + pos
- );
-
- if(offsetted_box.intersectsWithLine(shootline_on_map))
- {
- return obj;
- }
- }
-
- return NULL;
-}
-
float Client::getAnimationTime()
{
return m_animation_time;