diff --git a/game/modules/example/class/Player.lua b/game/modules/example/class/Player.lua index 4182b135a95fa1e0c4b7ae48fcfb4cbcb08ca7fe..7ec5bee734ef86f2095b7a5a1ba68f6acc649db4 100644 --- a/game/modules/example/class/Player.lua +++ b/game/modules/example/class/Player.lua @@ -80,12 +80,18 @@ function _M:act() end end +-- Precompute FOV form, for speed +local fovdist = {} +for i = 0, 30 * 30 do + fovdist[i] = math.max((20 - math.sqrt(i)) / 14, 0.6) +end + function _M:playerFOV() -- Clean FOV before computing it game.level.map:cleanFOV() -- Compute both the normal and the lite FOV, using cache self:computeFOV(self.sight or 20, "block_sight", function(x, y, dx, dy, sqdist) - game.level.map:apply(x, y, math.max((20 - math.sqrt(sqdist)) / 14, 0.6)) + game.level.map:apply(x, y, fovdist[sqdist]) end, true, false, true) self:computeFOV(self.lite, "block_sight", function(x, y, dx, dy, sqdist) game.level.map:applyLite(x, y) end, true, true, true) end diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 90daf0455dbb1c4a158a08defd30b840c0c8b0c3..612b2cfbeae09e60f3d45f6fd7bcc7b05606e979 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -182,7 +182,7 @@ function _M:act() end end --- Precompute FOV form +-- Precompute FOV form, for speed local fovdist = {} for i = 0, 30 * 30 do fovdist[i] = math.max((20 - math.sqrt(i)) / 14, 0.6)