summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>2011-06-08 05:27:51 +0200
committerNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>2011-06-08 05:27:55 +0200
commite261cc9e8fa67c9020fa0a82bd1a7041ecd351a0 (patch)
tree7a624279cffca4096c1e2b10cc4d0063a94f1ace /src
parent2ec160454a013dfc84b109c5c0b0901ac1055559 (diff)
downloadminetest-e261cc9e8fa67c9020fa0a82bd1a7041ecd351a0.tar.gz
minetest-e261cc9e8fa67c9020fa0a82bd1a7041ecd351a0.tar.bz2
minetest-e261cc9e8fa67c9020fa0a82bd1a7041ecd351a0.zip
+ rail block bounding box
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 7970a6ed9..bbd0a22ef 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -530,6 +530,43 @@ void getPointedNode(Client *client, v3f player_position,
}
}
}
+ else if(n.d == CONTENT_RAIL)
+ {
+ v3s16 dir = unpackDir(n.dir);
+ v3f dir_f = v3f(dir.X, dir.Y, dir.Z);
+ dir_f *= BS/2 - BS/6 - BS/20;
+ v3f cpf = npf + dir_f;
+ f32 distance = (cpf - camera_position).getLength();
+
+ float d = (float)BS/16;
+ v3f vertices[4] =
+ {
+ v3f(BS/2, -BS/2+d, -BS/2),
+ v3f(-BS/2, -BS/2, BS/2),
+ };
+
+ for(s32 i=0; i<2; i++)
+ {
+ vertices[i] += npf;
+ }
+
+ core::aabbox3d<f32> box;
+
+ box = core::aabbox3d<f32>(vertices[0]);
+ box.addInternalPoint(vertices[1]);
+
+ if(distance < mindistance)
+ {
+ if(box.intersectsWithLine(shootline))
+ {
+ nodefound = true;
+ nodepos = np;
+ neighbourpos = np;
+ mindistance = distance;
+ nodehilightbox = box;
+ }
+ }
+ }
/*
Regular blocks
*/