fa icon indicating copy to clipboard operation
fa copied to clipboard

Building morphs terrain into an unwalkable plateau

Open ChessBerry opened this issue 3 years ago • 9 comments

In this https://replay.faforever.com/15623430 unrusting game of mine I manage to place a quantum gate in such a weird way that it transforms the terrain around it into a plateau that all Sacus produced from it are stuck on.

I place the gate at around min 20:30. And realize the weirdness at around 24:30, after which I spend a couple minutes experimenting with the bug.

The terrain changes seem to take place immediately after building construction starts, as is typical, but in this case the entire ground region around the gate is elevated to a large degree. From the air, that is hard to see, but if you zoom in and use free cam to change the camera angle, it's very obvious.

Besides just looking weird, the gate is now on a plateau that can't be entered or left by walking, Strangely though, the units maybe think that they can walk up or down the cliff, as e.g. transporters don't come pick them up as they usually do when units are on a plateau or an island.

The terrain changes are not permanent, as buildings I placed later could level it to the correct height again. Strange stuff, and first time I'm seeing it.

ChessBerry avatar Nov 01 '21 21:11 ChessBerry

Not sure how this would be solved without making the flattening procedure more involved. Which doesn't solve the issue necessarily - as smaller structures can cause the same terrain morphing when build on a ramp.

Garanas avatar Nov 07 '21 15:11 Garanas

I don't have a solution, or know if a feasible solution even exists.

I posted it because, compared to the normal, kinda glitchy, terrain morphing weirdness that you sometimes see, in this case the entire building area is lifted far above all surrounding land.

In that sense it's different than the terrain morphing that makes only some sides of buildings untraversable, as you can e.g. see for many buildings on steep ramps. Here all sides became untraversable.

It looks to me like the mean height for the flattened terrain was calculated to incorrectly be much higher than it was supposed to.

It's certainly a low priority bug, considering that I have never seen or heard of it in my 2 years playing faf before this. I just found it too weird not to share

ChessBerry avatar Nov 07 '21 18:11 ChessBerry

image

This is the hill you build it on. It takes the center of the building as its height. We can fix this by sampling the terrain more - but not sure if it is worth it.

image

What we could do instead is sample the outer corners of the building and use that as the elevation height instead. But I'm not sure if we'd promote various glitches with that approach.

image

You made a mess of it.

Garanas avatar Nov 07 '21 19:11 Garanas

This is the hill you build it on. It takes the center of the building as its height. We can fix this by sampling the terrain more - but not sure if it is worth it.

Oh wow! I'm surprised that the hill is all it took to cause the weirdness, but I guess having a single, kinda steep hill like that in the middle of the landscape just doesn't really happen on most maps.

What we could do instead is sample the outer corners of the building and use that as the elevation height instead. But I'm not sure if we'd promote various glitches with that approach.

Yeah it's probably not worth it. If anyone wants to adopt the bug as a hobby project, why not, but realistically, there is much more significant stuff to be done.

You made a mess of it.

😢

ChessBerry avatar Nov 08 '21 12:11 ChessBerry

The bug is not difficult to solve - I'm not sure that if by doing so we don't just cause new unexpected issues on other terrain formations. And that would require a bit of testing. That is time consuming.

It involves this function: https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/defaultunits.lua#L163 Where instead of using the position of the structure, we sample the outer skirts of the structure (in constant time - independent on structure size) and average that. As an example: we sample each outer corner.

Garanas avatar Nov 08 '21 13:11 Garanas

Well in that case I'd suggest just adding it to fafdevelop with no testing whatsoever and let people scream at us if it doesn't work as intended :)

ChessBerry avatar Nov 08 '21 13:11 ChessBerry

I'm going to keep this one as a good first issue 😄

Garanas avatar Nov 08 '21 14:11 Garanas

@MrRowey

MrRowey avatar Nov 22 '21 10:11 MrRowey

I'm using

FlattenSkirt = function(self)
    local x0, z0, x1, z1 = self:GetSkirtRect()
    x0, z0, x1, z1 = math.floor(x0), math.floor(z0), math.ceil(x1), math.ceil(z1)
    local xm, zm = (x0 + x1) / 2, (z0 + z1) / 2
    local y = GetTerrainHeight(x0, z0) + GetTerrainHeight(x0, zm) + GetTerrainHeight(x0, z1)
            + GetTerrainHeight(xm, z0)                            + GetTerrainHeight(xm, z1)
            + GetTerrainHeight(x1, z0) + GetTerrainHeight(x1, zm) + GetTerrainHeight(x1, z1)
    FlattenMapRect(x0, z0, x1 - x0, z1 - z0, y / 8)
end;

and can't tell a difference. Mathematically, there's only a difference when the second degree of change of the height map is non-zero, and even then, only a big one when the skirt contains the inflection point (i.e. a hill or valley), which is what we're trying to fix. Of course, I haven't done any vigorous testing. I wish I could load replays into my dev environment, but I understand why that shouldn't make sense.

Hdt80bro avatar Jun 17 '22 17:06 Hdt80bro