summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>2011-08-01 05:59:40 -0700
committerNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>2011-08-01 05:59:40 -0700
commitf6bc6621946f019689e099a423e6bfc7bf7e2618 (patch)
treee5ce572a273a2d4fbfc13d8680f4eb470cb91a3d /src/game.cpp
parent7ece67727dcc1ff7a6634e4b911eeb82ed3eaf45 (diff)
parent7bd9e53ae630feabe42ab48369913f93beac26a7 (diff)
downloadminetest-f6bc6621946f019689e099a423e6bfc7bf7e2618.tar.gz
minetest-f6bc6621946f019689e099a423e6bfc7bf7e2618.tar.bz2
minetest-f6bc6621946f019689e099a423e6bfc7bf7e2618.zip
Merge pull request #47 from MarkTraceur/master
More better ladders
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 6c0474ee7..fb5d7cb93 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -538,6 +538,56 @@ void getPointedNode(Client *client, v3f player_position,
}
}
}
+
+ else if(n.getContent() == CONTENT_LADDER)
+ {
+ v3s16 dir = unpackDir(n.param2);
+ 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();
+
+ v3f vertices[4] =
+ {
+ v3f(BS*0.42,-BS/2,-BS/2),
+ v3f(BS*0.49, BS/2, BS/2),
+ };
+
+ for(s32 i=0; i<2; i++)
+ {
+ if(dir == v3s16(1,0,0))
+ vertices[i].rotateXZBy(0);
+ if(dir == v3s16(-1,0,0))
+ vertices[i].rotateXZBy(180);
+ if(dir == v3s16(0,0,1))
+ vertices[i].rotateXZBy(90);
+ if(dir == v3s16(0,0,-1))
+ vertices[i].rotateXZBy(-90);
+ if(dir == v3s16(0,-1,0))
+ vertices[i].rotateXYBy(-90);
+ if(dir == v3s16(0,1,0))
+ vertices[i].rotateXYBy(90);
+
+ 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;
+ }
+ }
+ }
else if(n.getContent() == CONTENT_RAIL)
{
v3s16 dir = unpackDir(n.param0);