Skip to content
Snippets Groups Projects
Commit 8565ba29 authored by dg's avatar dg
Browse files

fix

git-svn-id: http://svn.net-core.org/repos/t-engine4@3114 51575b47-30f0-44d4-a5cc-537603b46e54
parent 12b611a5
No related branches found
No related tags found
No related merge requests found
......@@ -315,7 +315,7 @@ function _M:projectDoStop(typ, tg, damtype, dam, particles, lx, ly, tmp, rx, ry)
game.level.map.w,
game.level.map.h,
typ.cone,
initial_dir,
dir_angle,
typ.cone_angle,
function(_, px, py)
if typ.block_radius and typ:block_radius(px, py) then return true end
......
......@@ -855,11 +855,12 @@ function core.fov.circle_grids(x, y, radius, block)
if radius == 0 then return {[x]={[y]=true}} end
local grids = {}
core.fov.calc_circle(x, y, game.level.map.w, game.level.map.h, radius, function(_, lx, ly)
if block and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then return true end
end,
function()
if not grids[lx] then grids[lx] = {} end
grids[lx][ly] = true
if block and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then return true end
end, function()end, nil)
end, nil)
-- point of origin
if not grids[x] then grids[x] = {} end
......@@ -872,11 +873,12 @@ function core.fov.beam_grids(x, y, radius, dir, angle, block)
if radius == 0 then return {[x]={[y]=true}} end
local grids = {}
core.fov.calc_beam(x, y, game.level.map.w, game.level.map.h, radius, dir, angle, function(_, lx, ly)
if block and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then return true end
end,
function()
if not grids[lx] then grids[lx] = {} end
grids[lx][ly] = true
if block and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then return true end
end, function()end, nil)
end, nil)
-- point of origin
if not grids[x] then grids[x] = {} end
......
......@@ -123,7 +123,7 @@ void fov_settings_set_apply_lighting_function(fov_settings_type *settings,
unsigned *result = (unsigned *)malloc((maxdist+2)*sizeof(unsigned));
if (result) {
for (i = 0; i <= maxdist; ++i) {
result[i] = (unsigned)sqrtf((float)(maxdist*maxdist - i*i));
result[i] = (unsigned)sqrtf((float)(maxdist*maxdist + maxdist - i*i));
}
result[maxdist+1] = 0;
}
......@@ -217,7 +217,6 @@ static float fov_slope(float dx, float dy) {
dy1 = (int)(0.5f + ((float)dx)*end_slope); \
\
rx = data->source_##rx signx dx; \
ry = data->source_##ry signy dy0; \
\
if (!apply_diag && dy1 == dx) { \
/* We do diagonal lines on every second octant, so they don't get done twice. */ \
......@@ -225,6 +224,7 @@ static float fov_slope(float dx, float dy) {
\
/* But, we still need to check if we can see past it if the slopes are similar */ \
if (dy1 < dy0) { \
ry = data->source_##ry signy dy0; \
if (settings->opaque(data->map, x, y)) { \
return; \
} \
......@@ -234,11 +234,12 @@ static float fov_slope(float dx, float dy) {
\
/* we also need to check if the previous spot is blocked */ \
if (dy0 > 0) { \
ry -= 1; \
ry = data->source_##ry signy (dy0-1); \
if (settings->opaque(data->map, x, y)) { \
prev_blocked = 1; \
} else { \
prev_blocked = 0; \
} \
ry += 1; \
} \
\
switch (settings->shape) { \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment