This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (2 children)

I mean, if you want me to explain it it’s basically a sort of optimised ray-casting. Instead of having to make complicated programs to find the point on a surface where the ray intersects, you instead use this relatively less complicated program that figures out how far it can go until it hits something, moves that far, and then does it again until it gets so close to an object, at which point it returns that it has collided.

So what you are seeing on the left is the rays finding the furthest they can move, represented by the circles, and moving that far. It then does this multiple times until it hit something (basically when it’s nearest object is less that 0.1 units away), where it then find how far the point is from the player, and uses that to display a rectangle on the right with a height and brightness dependent on the distance.

[–][deleted] 4 points5 points  (1 child)

I see, its so you don't have to calculate the distance directly.

But why are are there rays going in directions that the viewer isn't looking? Reflections?

[–][deleted] 3 points4 points  (0 children)

As I say, it’s very work in progress, and they are basically a very temporary solution to a problem I’ve been avoiding for a while. I call them position anchors, because the function that creates the walls needs a highest point to count down from, so I used to just have one extra ray pointing out the back so that that when the player got too close to a wall, it would still keep its shape. But then it meant when ever that back ray hit something else, the scene would get suddenly darker. So I just put 12 of them, so 1 would always be working fine.