Author Topic: Field of Vision  (Read 7415 times)

Offline Nikita_Sadkov

  • Colonel
  • ****
  • Posts: 286
    • View Profile
Field of Vision
« 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.
« Last Edit: December 06, 2015, 11:36:34 am by Nikita_Sadkov »

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Field of Vision
« Reply #1 on: December 07, 2015, 01:56:02 pm »
raycasting in voxel space.

Offline DeltaEpsilon

  • Captain
  • ***
  • Posts: 86
    • View Profile
Re: Field of Vision
« Reply #2 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.

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Field of Vision
« Reply #3 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

Offline Nikita_Sadkov

  • Colonel
  • ****
  • Posts: 286
    • View Profile
Re: Field of Vision
« Reply #4 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.

Offline DeltaEpsilon

  • Captain
  • ***
  • Posts: 86
    • View Profile
Re: Field of Vision
« Reply #5 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).

Offline Nikita_Sadkov

  • Colonel
  • ****
  • Posts: 286
    • View Profile
Re: Field of Vision
« Reply #6 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.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11730
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Field of Vision
« Reply #7 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 :)

Offline Nikita_Sadkov

  • Colonel
  • ****
  • Posts: 286
    • View Profile
Re: Field of Vision
« Reply #8 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.

Offline Dioxine

  • Commander
  • *****
  • Posts: 5458
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: Field of Vision
« Reply #9 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.