OpenXcom Forum

Contributions => Programming => Topic started by: Nikita_Sadkov on December 06, 2015, 11:32:11 am

Title: Field of Vision
Post by: Nikita_Sadkov on December 06, 2015, 11:32:11 am
How did the original X-Com managed to calculated field of vision back in 1994? The only way I know is spherecasting - an expensive calculation to do in realtime.
Title: Re: Field of Vision
Post by: Warboy1982 on December 07, 2015, 01:56:02 pm
raycasting in voxel space.
Title: Re: Field of Vision
Post by: DeltaEpsilon on December 08, 2015, 02:00:31 am
Seems like your average raycasting. There is a reason for 20 tiles vision limit, probably. If you download and use Real Vision mode (which expands this limit to 100 tiles), you'll find it lags even on fairly modern computers let alone PCs of 90x.
Title: Re: Field of Vision
Post by: Warboy1982 on December 08, 2015, 07:38:30 am
yeah, that's cause it multiplies the number of rays being cast exponentially, as well as the length of the individual rays themselves, leading to massive amounts of calculations
Title: Re: Field of Vision
Post by: Nikita_Sadkov on December 08, 2015, 10:11:00 am
Seems like your average raycasting. There is a reason for 20 tiles vision limit, probably. If you download and use Real Vision mode (which expands this limit to 100 tiles), you'll find it lags even on fairly modern computers let alone PCs of 90x.
I'm surprised nobody has reverse engineered the most important part of the engine

The https://www.ufopaedia.org/index.php?title=Line_of_sight article points that some hacks were used, resulting in blind spots, circles being not-perfect and objects like UFOs having holes in them.

Although AI turn really took way too long when I played the game back then on PlayStation.
Title: Re: Field of Vision
Post by: DeltaEpsilon on December 08, 2015, 10:18:48 am
Quote
The https://www.ufopaedia.org/index.php?title=Line_of_sight article points that some hacks were used, resulting in blind spots, circles being not-perfect and objects like UFOs having holes in them.
It's possible with raycasting. You either should increase resolution of raycasting (easier, laggier) or change raycasting in the way where such problem are not happening (extremely hard, lag-free).
Title: Re: Field of Vision
Post by: Nikita_Sadkov on December 08, 2015, 02:28:58 pm
It's possible with raycasting. You either should increase resolution of raycasting (easier, laggier) or change raycasting in the way where such problem are not happening (extremely hard, lag-free).
What about X-Com Apocalypse?  The realtime nature of the game requires fast FOV. But I guess machines running Apocalypse can precompute it. A few bytes per cell would be enough to cache visibility bitmap of nearby cells.
Title: Re: Field of Vision
Post by: Solarius Scorch on December 12, 2015, 12:54:52 pm
What about X-Com Apocalypse?  The realtime nature of the game requires fast FOV. But I guess machines running Apocalypse can precompute it. A few bytes per cell would be enough to cache visibility bitmap of nearby cells.

What do you mean by "precompute"? You mean that it's still done on the battlefield, or that the information is somehow stored in the game files (which would help explain the lack of random maps)? I guess the latter takes it a bit far though :)
Title: Re: Field of Vision
Post by: Nikita_Sadkov on December 13, 2015, 04:22:57 pm
What do you mean by "precompute"? You mean that it's still done on the battlefield, or that the information is somehow stored in the game files (which would help explain the lack of random maps)? I guess the latter takes it a bit far though :)
I mean, when terrain changes, for each cell store a bitmap of nearby cells visible from it. Alternatively, one can use a diffusion map and check that gas concentration is equivalent to the straight line (i.e. flow had no obstacles in the way). Diffusion could possible run fast in 3d with octrees. Although algorithm for getting neigbors inside of octree is a little involved.
Title: Re: Field of Vision
Post by: Dioxine on December 15, 2015, 03:53:29 am
So you'd go from computing-intensive raycasting to cell automata? Sounds very promising. Cell automata are fast and not that hard to write once you know how to do it. Gas flow sounds more arcane, but it can also be done on cells.