Skip to content

Commit

Permalink
Merge pull request #698 from 32blit/patch-raycaster
Browse files Browse the repository at this point in the history
Raycaster improvements, cleanup and working bug spray
  • Loading branch information
Gadgetoid authored Aug 9, 2021
2 parents 780e23b + 6cbfaee commit e6dc0db
Show file tree
Hide file tree
Showing 4 changed files with 257 additions and 368 deletions.
11 changes: 5 additions & 6 deletions 32blit/graphics/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,20 +534,19 @@ namespace blit {
float v = uv.y;
float vs = float(sc) / float(dc);

if (p.y < 0) {
dc += p.y;
v += (vs * float(-p.y));
p.y = 0;
if (p.y < clip.y) {
dc += clip.y - p.y;
v += (vs * float(-(p.y - clip.y)));
p.y = clip.y;
}

if (dc <= 0) {
return;
}

int16_t max_y = std::min(p.y + dc, bounds.h);
int16_t max_y = std::min(p.y + dc, clip.y + clip.h);
for (; p.y < max_y; p.y++) {
bbf(src, src->offset(Point(uv.x, v)), this, offset(p), 1, 1);

v += vs;
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/raycaster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ find_package (32BLIT CONFIG REQUIRED PATHS ../..)
blit_executable (raycaster raycaster.cpp)
blit_assets_yaml(raycaster assets.yml)
blit_metadata (raycaster metadata.yml)
target_compile_definitions(raycaster PRIVATE ALLOW_HIRES=0)
Loading

0 comments on commit e6dc0db

Please sign in to comment.