ofs | hex dump | ascii |
---|
0000 | 42 42 33 44 0e 9c 00 00 01 00 00 00 42 52 55 53 2e 00 00 00 01 00 00 00 42 72 75 73 68 2e 30 30 | BB3D........BRUS........Brush.00 |
0020 | 31 00 00 00 80 3f 00 00 80 3f 00 00 80 3f 00 00 80 3f 00 00 00 00 01 00 00 00 00 00 00 00 ff ff | 1....?...?...?...?.............. |
0040 | ff ff 4e 4f 44 45 cc 9b 00 00 64 74 72 61 63 6b 5f 73 77 6c 73 74 5f 33 30 00 00 00 00 00 00 00 | ..NODE....dtrack_swlst_30....... |
0060 | 00 bf 00 00 00 00 00 00 80 3f 00 00 80 3f 00 00 80 3f 7e b3 6a 3e 00 00 00 00 64 2f 79 3f 00 00 | .........?...?...?~.j>....d/y?.. |
0080 | 00 00 4d 45 53 48 8c 9b 00 00 ff ff ff ff 56 52 54 53 8c 83 00 00 01 00 00 00 01 00 00 00 02 00 | ..MESH........VRTS.............. |
00a0 | 00 00 fc ca f3 be 29 5c 0f 3e 11 27 37 be 65 9b 32 bf 6d 79 36 3f 25 91 92 bd a5 ff 00 3e 24 e4 | ......)\.>.'7.e.2.my6?%......>$. |
00c0 | 04 3f 20 93 de be 29 5c 0f 3e b0 35 3d be 6c f9 35 3f 68 f7 33 3f 61 81 b0 bc 4b 1f 37 3e 27 e4 | .?....)\.>.5=.l.5?h.3?a...K.7>'. |
00e0 | 04 3f 3a 06 de be 29 5c 0f 3e 8a 94 c3 bd 69 75 34 3f 6b 89 35 3f e5 81 72 bc 4c 1f 37 3e 34 13 | .?:...)\.>....iu4?k.5?..r.L.7>4. |
0100 | dd 3e 46 13 fa be 29 5c 0f 3e ac fb a9 bd 66 0d 33 bf 6b 5f 35 3f 80 41 c0 bd a4 ff 00 3e 2e 13 | .>F...)\.>....f.3.k_5?.A.....>.. |
0120 | dd 3e c4 b5 ef be 29 5c 0f 3e 8e 66 90 be 69 71 34 bf 6a 0f 35 3f ba 01 5d bd a7 ff 00 3e b1 3e | .>....)\.>.f..iq4.j.5?..]....>.> |
0140 | 1b 3f 51 f7 e0 be 29 5c 0f 3e b4 ce 8f be 6d 55 36 3f 66 09 33 3f e6 41 73 bd 4a 1f 37 3e b3 3e | .?Q...)\.>....mU6?f.3?.As.J.7>.> |
0160 | 1b 3f 20 93 de be 29 5c 0f 3e b0 35 3d be 6c f9 35 3f 68 f7 33 3f 61 81 b0 bc 4b 1f 37 3e 27 e4 | .?....)\.>.5=.l.5?h.3?a...K.7>'. |
0180 | 04 3f fc ca f3 be 29 5c 0f 3e 11 27 37 be 65 9b 32 bf 6d 79 36 3f 25 91 92 bd a5 ff 00 3e 24 e4 | .?....)\.>.'7.e.2.my6?%......>$. |
01a0 | 04 3f fb d1 ea be c8 ba 22 3d 61 e4 d0 be f5 79 fa be 24 f5 11 bf 52 f3 28 bf ca 00 96 3e 3c 99 | .?......"=a....y..$...R.(....><. |
01c0 | 31 3f c4 b5 ef be c8 ba 22 3d 8e 66 90 be 69 71 34 bf 6a 0f 35 bf ba 01 5d bd cb 00 96 3e af 3e | 1?......"=.f..iq4.j.5...]....>.> |
01e0 | 1b 3f 51 f7 e0 be c8 ba 22 3d b4 ce 8f be 6d 55 36 3f 66 09 33 bf e6 41 73 bd e4 e1 75 3e b3 3e | .?Q....."=....mU6?f.3..As...u>.> |
/*
Minetest
Copyright (C) 2016 juhdanad, Daniel Juhasz <juhdanad@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "raycast.h"
#include "irr_v3d.h"
#include "irr_aabb3d.h"
#include "constants.h"
bool RaycastSort::operator() (const PointedThing &pt1,
const PointedThing &pt2) const
{
// "nothing" can not be sorted
assert(pt1.type != POINTEDTHING_NOTHING);
assert(pt2.type != POINTEDTHING_NOTHING);
f32 pt1_distSq = pt1.distanceSq;
// Add some bonus when one of them is an object
if (pt1.type != pt2.type) {
if (pt1.type == POINTEDTHING_OBJECT)
pt1_distSq -= BS * BS;
else if (pt2.type == POINTEDTHING_OBJECT)
pt1_distSq += BS * BS;
}
// returns false if pt1 is nearer than pt2
if (pt1_distSq < pt2.distanceSq) {
return false;
}
if (pt1_distSq == pt2.distanceSq) {
// Sort them to allow only one order
if (pt1.type == POINTEDTHING_OBJECT)
return (pt2.type == POINTEDTHING_OBJECT
&& pt1.object_id < pt2.object_id);
return (pt2.type == POINTEDTHING_OBJECT
|| pt1.node_undersurface < pt2.node_undersurface);
}
return true;
}
RaycastState::RaycastState(const core::line3d<f32> &shootline,
bool objects_pointable, bool liquids_pointable) :
m_shootline(shootline),
m_iterator(shootline.start / BS, shootline.getVector() / BS),
m_previous_node(m_iterator.m_current_node_pos),
m_objects_pointable(objects_pointable),
m_liquids_pointable(liquids_pointable)
{
}
bool boxLineCollision(const aabb3f &box, const v3f &start,
const v3f &dir, v3f *collision_point, v3s16 *collision_normal)
{
if (box.isPointInside(start)) {
*collision_point = start;
collision_normal->set(0, 0, 0);
return true;
}
float m = 0;
// Test X collision
if (dir.X != 0) {
if (dir.X > 0)
m = (box.MinEdge.X - start.X) / dir.X;
else
m = (box.MaxEdge.X - start.X) / dir.X;
if (m >= 0 && m <= 1) {
*collision_point = start + dir * m;
if ((collision_point->Y >= box.MinEdge.Y)
&& (collision_point->Y <= box.MaxEdge.Y)
&& (collision_point->Z >= box.MinEdge.Z)
&& (collision_point->Z <= box.MaxEdge.Z)) {
collision_normal->set((dir.X > 0) ? -1 : 1, 0, 0);
return true;
}
}
}
// Test Y collision
if (dir.Y != 0) {
if (dir.Y > 0)
m = (box.MinEdge.Y - start.Y) / dir.Y;
else
m = (box.MaxEdge.Y - start.Y) / dir.Y;
if (m >= 0 && m <= 1) {
*collision_point = start + dir * m;
if ((collision_point->X >= box.MinEdge.X)
&& (collision_point->X <= box.MaxEdge.X)
&& (collision_point->Z >= box.MinEdge.Z)
&& (collision_point->Z <= box.MaxEdge.Z)) {
collision_normal->set(0, (dir.Y > 0) ? -1 : 1, 0);
return true;
}
}
}
// Test Z collision
if (dir.Z != 0) {
if (dir.Z > 0)
m = (box.MinEdge.Z - start.Z) / dir.Z;
else
m = (box.MaxEdge.Z - start.Z) / dir.Z;
if (m >= 0 && m <= 1) {
*collision_point = start + dir * m;
if ((collision_point->X >= box.MinEdge.X)
&& (collision_point->X <= box.MaxEdge.X)
&& (collision_point->Y >= box.MinEdge.Y)
&& (collision_point->Y <= box.MaxEdge.Y)) {
collision_normal->set(0, 0, (dir.Z > 0) ? -1 : 1);
return true;
}
}
}
return false;
}