summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_env.cpp
diff options
context:
space:
mode:
authorDániel Juhász <juhdanad@gmail.com>2016-12-01 20:15:37 +0100
committerparamat <mat.gregory@virginmedia.com>2017-12-26 21:51:32 +0000
commit2153965cf92ab61b0d7e095cf3c2755924fdc221 (patch)
tree3895bdca9684f0f94a2a9f8653e013eecc0d4e1e /src/script/lua_api/l_env.cpp
parentca64f564cd23dba45bc93b57a718dfe81df5ba27 (diff)
downloadminetest-2153965cf92ab61b0d7e095cf3c2755924fdc221.tar.gz
minetest-2153965cf92ab61b0d7e095cf3c2755924fdc221.tar.bz2
minetest-2153965cf92ab61b0d7e095cf3c2755924fdc221.zip
Line_of_sight: Improve using VoxelLineIterator
This commit rewrites line_of_sight with VoxelLineIterator. Stepsize is no longer needed, the results will be always accurate.
Diffstat (limited to 'src/script/lua_api/l_env.cpp')
-rw-r--r--src/script/lua_api/l_env.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index 870eeb1ae..237d14ab3 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -966,24 +966,19 @@ int ModApiEnvMod::l_clear_objects(lua_State *L)
return 0;
}
-// line_of_sight(pos1, pos2, stepsize) -> true/false, pos
+// line_of_sight(pos1, pos2) -> true/false, pos
int ModApiEnvMod::l_line_of_sight(lua_State *L)
{
- float stepsize = 1.0;
-
GET_ENV_PTR;
// read position 1 from lua
v3f pos1 = checkFloatPos(L, 1);
// read position 2 from lua
v3f pos2 = checkFloatPos(L, 2);
- //read step size from lua
- if (lua_isnumber(L, 3)) {
- stepsize = lua_tonumber(L, 3);
- }
v3s16 p;
- bool success = env->line_of_sight(pos1, pos2, stepsize, &p);
+
+ bool success = env->line_of_sight(pos1, pos2, &p);
lua_pushboolean(L, success);
if (!success) {
push_v3s16(L, p);