From 2153965cf92ab61b0d7e095cf3c2755924fdc221 Mon Sep 17 00:00:00 2001 From: Dániel Juhász Date: Thu, 1 Dec 2016 20:15:37 +0100 Subject: 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. --- src/script/lua_api/l_env.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/script/lua_api/l_env.cpp') 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); -- cgit v1.2.3