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

Redo Vision #6432

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft

Redo Vision #6432

wants to merge 11 commits into from

Conversation

kphoenix137
Copy link
Collaborator

@kphoenix137 kphoenix137 commented Aug 2, 2023

Creates a more consistent and realistic area of vision. Makes the vision radius as close to a circle as we can get, which also fixes the bug with the player turning invisible with lowest achievable light radius.

vision

Before:
image
After:
image

Before:
image
After:
image

Before:
image
After:
image

@julealgon
Copy link
Contributor

Just one comment based on the comparisons.

I prefer the behavior here (original):
image

Than the new one:
image

The former looks a lot more natural to me.

@kphoenix137
Copy link
Collaborator Author

kphoenix137 commented Aug 2, 2023

Just one comment based on the comparisons.

I prefer the behavior here (original): image

Than the new one: image

The former looks a lot more natural to me.

Because it doesn't discriminate based on the actual shape of the dungeon tile. It behaves as if the entire tile is filled with solid, which in that case you would not be able to see many of the tiles the vanilla one covers. Should I add special handling for every type of solid tile based on how wide the graphic is? Or maybe change how it "looks" in a direction by ignoring a solid tile if it's in the outer ~50% space of the solid tile

@julealgon
Copy link
Contributor

Should I add special handling for every type of solid tile based on how wide the graphic is? Or maybe change how it "looks" in a direction by ignoring a solid tile if it's in the outer ~50% space of the solid tile

To be fair I'm not sure either. I just think it needs to be a cone (or since we are dealing 2d, triangle) shape from the character to model the idea that you see more further ahead than you do nearby.

A simple "line" won't work well I think because of this.

@qndel
Copy link
Member

qndel commented Aug 2, 2023

image
not that I care but this would make pulling single monsters trivial in ironman by just poking them with the protruding 1 tile part

@kphoenix137
Copy link
Collaborator Author

kphoenix137 commented Aug 2, 2023

Should I add special handling for every type of solid tile based on how wide the graphic is? Or maybe change how it "looks" in a direction by ignoring a solid tile if it's in the outer ~50% space of the solid tile

To be fair I'm not sure either. I just think it needs to be a cone (or since we are dealing 2d, triangle) shape from the character to model the idea that you see more further ahead than you do nearby.

A simple "line" won't work well I think because of this.

Desktop.2023.08.02.-.17.21.12.08.mp4

I modified the function and now it casts 360 rays, utmost realism and precision

@julealgon
Copy link
Contributor

A bit hard to judge compared to the original (or even to what one would consider "perfect", which I actually don't know), but that's looking good to me at least.

Is there a significant performance implication with the change?

@kphoenix137
Copy link
Collaborator Author

A bit hard to judge compared to the original (or even to what one would consider "perfect", which I actually don't know), but that's looking good to me at least.

Is there a significant performance implication with the change?

Not sure. someone with a low end system will have to test

@kphoenix137
Copy link
Collaborator Author

image not that I care but this would make pulling single monsters trivial in ironman by just poking them with the protruding 1 tile part

Check OP again

@kphoenix137
Copy link
Collaborator Author

A bit hard to judge compared to the original (or even to what one would consider "perfect", which I actually don't know), but that's looking good to me at least.

Is there a significant performance implication with the change?

I was able to reduce the amount of rays to 64 from 360 and still maintain a good level of accuracy

@AJenbo AJenbo added this to the 1.6.0 milestone Aug 29, 2023
@Gerwin2k
Copy link

Gerwin2k commented Sep 2, 2023

float dx = std::cos(angle * M_PI / 180.0f);
float dy = std::sin(angle * M_PI / 180.0f);

For your consideration. In the past, like 20 years ago, it was common to pre-calculate all possible answers at game startup and store these results in an array. Then when the game was running; lookup the answers from the array to avoid doing sin and cos when timing is critical.
example.txt

@AJenbo
Copy link
Member

AJenbo commented Mar 28, 2024

Title is misleading :(

"Refactoring" in programming refers to the process of restructuring existing computer code without changing its external behavior. It's like tidying up your code to make it more readable, maintainable, and efficient without altering what it actually does.

@kphoenix137 kphoenix137 changed the title Refactor Vision Redo Vision Mar 28, 2024
@kphoenix137
Copy link
Collaborator Author

Gotta redo time demo probably 😅

I incorrectly named the tables so I'll need to revise those.

@kphoenix137 kphoenix137 marked this pull request as draft September 17, 2024 22:16
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

Successfully merging this pull request may close these issues.

6 participants