From bc2819cab2978c61b2ca1d7b68a5d1f223e8647a Mon Sep 17 00:00:00 2001 From: Mark Holmquist Date: Wed, 27 Jul 2011 10:18:09 -0700 Subject: Added ladders--they don't have any use yet, though --- src/game.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 6c0474ee7..d8ea45fb1 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.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(); + + 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 box; + + box = core::aabbox3d(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); -- cgit v1.2.3 From 8e67f4c4e617a8fcbb9176de1bf0b267acfc6e2f Mon Sep 17 00:00:00 2001 From: Mark Holmquist Date: Sat, 30 Jul 2011 17:26:13 -0700 Subject: Fixed a few problems in the ladder update, and changed the speed to account for gravity --- src/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index d8ea45fb1..fb5d7cb93 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -541,7 +541,7 @@ void getPointedNode(Client *client, v3f player_position, else if(n.getContent() == CONTENT_LADDER) { - v3s16 dir = unpackDir(n.dir); + 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; -- cgit v1.2.3