aliens

Author Topic: Inconsistency between tile- and unit-visibility  (Read 3178 times)

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Inconsistency between tile- and unit-visibility
« on: May 12, 2023, 09:11:53 am »
I'm curious what other people think about the discrepancy between unit-visibility and tile-visibility. I just watched a stream where the streamer was fighting spiders in a jungle. The spiders would hide in the shadows and weren't really visible to the player. But they were visible to his units and he could aim at them.

It was a lot of aiming into the dark to be able to shoot them.

I did some research and found out that tile-visibility is determined by the "Stop_LOS"-flag in MCD-file of the object. Whereas unit-visibility is determined by an actual 3D-voxel-check.

A lot of the trees in the jungle have the Stop_LOS-flag set and should be vision-blocking while their LOFTs (3D-Voxel model) are usually quite a bit thinner than the tile.

So I was wondering whether it shouldn't be a requirement for units to see each other that the tile they are residing on is also visible.

Offline Vakrug

  • Colonel
  • ****
  • Posts: 320
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #1 on: May 12, 2023, 09:21:33 am »
I'm curious what other people think about the discrepancy between unit-visibility and tile-visibility.
Very annoying, but what can be done?
So I was wondering whether it shouldn't be a requirement for units to see each other that the tile they are residing on is also visible.
That would be a disaster. If one unit is elevated and covered with half slab (like in Osiron Hasienda mission in XComFiles) it will be invisible but able to shoot anyone below.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #2 on: May 12, 2023, 12:04:22 pm »
What can be done? Well, it's an open-source-game. I already have a separate client anyways. I'd like to add an advanced-battlescape-option called "consistent visibility" or something along those lines, where I make tile-visibility a prerequisite for unit visibility (not for psi-vision of course).

I don't think that the disaster you predict would happen. The reason for that is that tile-visibility generally works the same in both directions. So a unit that cannot be seen at a tile that cannot be seen should also not be able to see anyone from there.

But it would of course require quite a bit of play-testing to make sure this doesn't cause any issues. I'm in particular concerned about elevators. As far as I know those also have this inconsistency. If someone could just block them and you also can't target them that would obviously be pretty bad.

Offline Yankes

  • Commander
  • *****
  • Posts: 3328
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #3 on: May 12, 2023, 12:10:26 pm »
First thing would be that it would tank perforce, right now Tile visiblity can lag game if you have 60+ range and this is calucalte on tile-level.
Unit visibility is done on voxel-level, your solder "shoot" from eye and if he "hit" something it will be visible. this is around 20 more costly that
calculations on tile-level.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #4 on: May 12, 2023, 12:28:45 pm »
First thing would be that it would tank perforce, right now Tile visiblity can lag game if you have 60+ range and this is calucalte on tile-level.
Unit visibility is done on voxel-level, your solder "shoot" from eye and if he "hit" something it will be visible. this is around 20 more costly that
calculations on tile-level.
The tile-visibility is done anyways and it is done before the unit-visibility-check as UpdateTilesInFOW is called before UpdateUnitsInFOW.
The unit-visibility-check only is done for tiles that actually contain units in a method called "visible".
Just adding an "if(!currentUnit->hasVisibleTile(tile)) return false;" would only access the cached tile-visibility that has already been done anyways. I'm not seeing how that would impact performance in a negative way. If anything it would actually save time because the more expensive unit-visibility check on the voxel-level could be skipped.

Reading your reply again, it seems you misunderstood my intention and got it backwards. I don't want to create consistency by elevating the tile-visibility-checks to use voxel-logic. The opposite is the case: I want to create consistency by making units not visibile when the tile isn't visible.
The logic being: "If I can't see there's a tree behind the tree, I also shouldn't be able to see the spider behind the tree."

Offline psavola

  • Commander
  • *****
  • Posts: 817
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #5 on: May 12, 2023, 12:39:22 pm »
As Vakrug mentioned an XCF example of "half-height fence" (which I suppose you could kneel behind and be out of sight), I'm not sure how the modders have used tile visility. Are they using it to kind of mean "the view to the tile is at least partially obstructed". I suppose stop-LOS has not been used to mean that anything (regardless of height) is always invisible if it's on that tile. Also, if you changed this, would it apply both ways (you also can't see out from the tile) which would likely break some maps but not as badly as the visibility would be gone while the enemies on the tile could still shoot you.

Offline Vakrug

  • Colonel
  • ****
  • Posts: 320
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #6 on: May 12, 2023, 12:44:31 pm »
I don't think that the disaster you predict would happen. The reason for that is that tile-visibility generally works the same in both directions.
No. As soon as one unit is standing above another, tile visibility no longer are the same in both directions. And I remember quite a few maps like that. So disaster.
The logic being: "If I can't see there's a tree behind the tree, I also shouldn't be able to see the spider behind the tree."
Tiles are not trees! If you don't see a tile, then you probably don't see foots of a an enemy that is standing on that tile. Everything else is visible. Including you.

Offline Yankes

  • Commander
  • *****
  • Posts: 3328
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #7 on: May 12, 2023, 01:01:42 pm »
As Vakrug mentioned an XCF example of "half-height fence" (which I suppose you could kneel behind and be out of sight), I'm not sure how the modders have used tile visility. Are they using it to kind of mean "the view to the tile is at least partially obstructed". I suppose stop-LOS has not been used to mean that anything (regardless of height) is always invisible if it's on that tile. Also, if you changed this, would it apply both ways (you also can't see out from the tile) which would likely break some maps but not as badly as the visibility would be gone while the enemies on the tile could still shoot you.
Right, if you want to limit unit visibility to visible tiles then performance concerns would be very low.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #8 on: May 12, 2023, 01:03:43 pm »
As Vakrug mentioned an XCF example of "half-height fence" (which I suppose you could kneel behind and be out of sight), I'm not sure how the modders have used tile visility. Are they using it to kind of mean "the view to the tile is at least partially obstructed". I suppose stop-LOS has not been used to mean that anything (regardless of height) is always invisible if it's on that tile. Also, if you changed this, would it apply both ways (you also can't see out from the tile) which would likely break some maps but not as badly as the visibility would be gone while the enemies on the tile could still shoot you.
It's pretty easy to see how tile-visibility works and thus would also be pretty easy to predict how it would affect unit-visibility if it became an additional prerequisite for it. If someone had set a half-height-fence to be LOS-blocking, this would  already have lead to complaints about that kind of map because of how weird that would look. Kneeling behind them blocks visibility of units due to the voxel-check. That one would of course still remain in place ontop of the tile-visibility-check.

I think that intuitively you'd assume that if you can't see a tile you also can't see if a unit is on it and that modders would mostly use it accordingly. I'm currently bedding on that it would work both ways. The way the check is done is just going through the tiles in a line and check if they contain something that has the los-blocking flag set. If this is the case any further tile in the same direction is considered as not visible. One thing that I'm not 100% sure about is how it would work with slopes and 2x2 units. Those have been shown to be a bit tricky. My assumption is that for the tile-visibility for a unit on a slope it checks at what tile it's eyes are on and does the visibility-check starting from there. But the unit is basically on several tiles and seeing one of them should qualify for seeing the unit. So for a 2x2-unit on a slope up to 8 tiles would have to be checked. This may already happen anyways for the voxel-checks but I need to make sure to put my check at the right location.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #9 on: May 12, 2023, 01:24:39 pm »
No. As soon as one unit is standing above another, tile visibility no longer are the same in both directions. And I remember quite a few maps like that. So disaster.Tiles are not trees! If you don't see a tile, then you probably don't see foots of a an enemy that is standing on that tile. Everything else is visible. Including you.
I guess I really need to see examples of what you are talking about. It would be much easier to comprehend it by actually seeing it.

If everything else should be visible, then my question would be why it was deliberately decided to be rendered in complete blackness. Including units that are visible according to the little colored squares in the bottom right. This would be the other way to solve the discrepancy. If you see the unit, let the engine draw it so you don't have to press the alt-key or search it with your crosshair. However, since I thought it would look weird if the environment is still black but you see units standing on black environment that the other way around would be preferable.

Well, to be honest it is mostly because my AI uses tile-visibility-logic to find hiding-spots and I was a bit pissed, when I saw that they could be targeted despite having hidden exactly as intended. And as yankes said, predictive-voxel-visibility-checks would be way too expensive to be usable for that purpose without massively tanking performance. So that's not really an option.

Offline Vakrug

  • Colonel
  • ****
  • Posts: 320
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #10 on: May 12, 2023, 03:39:05 pm »
If everything else should be visible, then my question would be why it was deliberately decided to be rendered in complete blackness.
Oh, that is actually a very good idea! Visible units should be visible.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #11 on: May 12, 2023, 04:50:04 pm »
I just tried out my idea and sadly there have been a lot of issues of "not working as intended" in the sense that units couldn't see enemies where I thought they clearly should be able to. Where the tile was visible but the unit somehow wasn't.

I'll try a bit to figure out how that could be but it's not as easy as I thought with "add 2 lines of code and voila, consistent visibility".

Offline Yankes

  • Commander
  • *****
  • Posts: 3328
    • View Profile
Re: Inconsistency between tile- and unit-visibility
« Reply #12 on: May 12, 2023, 11:45:52 pm »
I think this functionality could be implemented by scripts, we can already change visibility of any unit, and we only need add check if given tile is visible to script.