Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOV leakage from between diagonal tiles #2

Open
Stakker opened this issue Jun 8, 2021 · 2 comments
Open

FOV leakage from between diagonal tiles #2

Stakker opened this issue Jun 8, 2021 · 2 comments

Comments

@Stakker
Copy link

Stakker commented Jun 8, 2021

Hi and thanks for sharing your shadowcasting implementation! I overall like its results better than other routines I've tried, but it has this funky feature that the visibility "leaks" from in between diagonal tiles. The previous routine I had in my current project also saw through diagonal corners, but it did it in a more natural way so that it had the more realistic outward widening sector. Your routine for some reason draws a one tile wide infinite "streak".

Basically I can get around this by just not having diagonal corners like this :-P But optimally, it would be great if the routine did not see through diagonal corners at all... I'm just wondering if you would have an easy solution to tweak it this way?

Attached a screenshot to illustrate. I also tweaked your routine a bit for my use so that you also see the tiles (the walls) that block your vision.

Thanks!
Leakage

@AndyStobirski
Copy link
Owner

Hi there and thanks for the message. It's been a while since I looked at this code to be honest.

Seeing through diagonal corners is intended behaviour due to how the rays emanate from the observer. I suppose if one where to check diagonal rays as they are emitted and look for the presence of two filled cells and stop building the ray at that point. The position of the filled cells would obviously vary depending upon the direction of the emitted ray.

That's all I've got at the moment, but I'll revisit this when I have more time.

@Stakker
Copy link
Author

Stakker commented Jun 9, 2021

Hey, thanks for the reply! Yeah... guess I'll dig into it and see if there's an easy (enough) tweak/hack I can figure out.

When it's close to 45 degrees, it's actually not so bad. Especially if instead of these square wall block graphics I have trees or similar objects that make more sense standing alone or diagonally and are not exactly square shaped. (So there's a visual gap in between the tile graphics.)

I guess the worst case is when the view angle gets close to 90 degrees. Seeing a monster at "X" feels a bit weird, for example. Buuut yeah, it's not a show stopper :-)

Leakage2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants