Minetest 5.9.0-dev
 
Loading...
Searching...
No Matches
raycast.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2016 juhdanad, Daniel Juhasz <juhdanad@gmail.com>
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation; either version 2.1 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public License along
16with this program; if not, write to the Free Software Foundation, Inc.,
1751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*/
19
20#pragma once
21
22#include "voxelalgorithms.h"
23#include "util/pointedthing.h"
24
27{
28 bool operator() (const PointedThing &pt1, const PointedThing &pt2) const;
29};
30
33{
34public:
40 RaycastState(const core::line3d<f32> &shootline, bool objects_pointable,
41 bool liquids_pointable, const std::optional<Pointabilities> &pointabilities);
42
44 core::line3d<f32> m_shootline;
49
54 std::priority_queue<PointedThing, std::vector<PointedThing>, RaycastSort> m_found;
55
58 const std::optional<Pointabilities> m_pointabilities;
59
61 core::aabbox3d<s16> m_search_range { 0, 0, 0, 0, 0, 0 };
62
65};
66
77bool boxLineCollision(const aabb3f &box, v3f start, v3f dir,
78 v3f *collision_point, v3f *collision_normal);
79
80bool boxLineCollision(const aabb3f &box, v3f box_rotation,
81 v3f start, v3f dir,
82 v3f *collision_point, v3f *collision_normal, v3f *raw_collision_normal);
static v2f dir(const v2f &pos_dist)
Definition: camera.cpp:204
Describes the state of a raycast.
Definition: raycast.h:33
v3s16 m_previous_node
Previous tested node during the raycast.
Definition: raycast.h:48
core::aabbox3d< s16 > m_search_range
The code needs to search these nodes around the center node.
Definition: raycast.h:61
std::priority_queue< PointedThing, std::vector< PointedThing >, RaycastSort > m_found
Definition: raycast.h:54
core::line3d< f32 > m_shootline
Shootline of the raycast.
Definition: raycast.h:44
bool m_initialization_needed
If true, the Environment will initialize this state.
Definition: raycast.h:64
bool m_objects_pointable
Definition: raycast.h:56
bool m_liquids_pointable
Definition: raycast.h:57
voxalgo::VoxelLineIterator m_iterator
Iterator to store the progress of the raycast.
Definition: raycast.h:46
const std::optional< Pointabilities > m_pointabilities
Definition: raycast.h:58
core::aabbox3d< f32 > aabb3f
Definition: irr_aabb3d.h:26
core::vector3d< s16 > v3s16
Definition: irr_v3d.h:28
core::vector3df v3f
Definition: irr_v3d.h:26
bool boxLineCollision(const aabb3f &box, v3f start, v3f dir, v3f *collision_point, v3f *collision_normal)
Definition: raycast.cpp:73
An active object or node which is selected by a ray on the map.
Definition: pointedthing.h:37
Sorts PointedThings based on their distance.
Definition: raycast.h:27
bool operator()(const PointedThing &pt1, const PointedThing &pt2) const
Definition: raycast.cpp:26
Definition: voxelalgorithms.h:89