New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Account for slopes in Map.DistanceAboveTerrain. #17990
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very good in-game and I can't spot regressions.
Updated. |
A bigger concern is that Other than that it all looks good and seems to work pretty well. 👍 |
TODO:
|
739f3c4
to
8bc704a
Compare
Updated. Fixing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good as far as I can tell, didn't notice any in-game regressions
Rebased. |
@@ -89,7 +90,8 @@ void ConvertBridgeToActor(World w, CPos cell) | |||
var subtile = new CPos(ni + ind % template.Size.X, nj + ind / template.Size.X); | |||
|
|||
// This isn't the bridge you're looking for | |||
if (!mapTiles.Contains(subtile) || mapTiles[subtile].Type != tile || mapTiles[subtile].Index != ind) | |||
var subti = mapTiles[subtile]; | |||
if (!mapTiles.Contains(subtile) || subti.Type != tile || subti.Index != ind) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This moved the lookup before the Contains
check!
This PR implements the slightly delayed followup to #8866. Actors now follow the terrain height as they move over slopes, instead of floating above or clipping below the map as they interpolate between cell centers. This should completely fix infantry movement, but vehicle artwork will obviously still clip until actor orientations have been implemented and the voxel rendering fixed.
Wikipedia explains the maths, and walkmap.c has my original implementation that was adapted for this PR. Knowing the geometry of the cells allows us to do some tricks, such as hardcoding the determinant as a constant and allowing u,v to extend outside their formal range to evaluate the height over the full square for
RampSplit.Flat
. As usual, calculations are done as integers between 0-1024 instead of floats between 0-1.Closes #17219 and is one of the prerequisites to properly integrating vehicle tilting. Future PRs will further expand
CellRamp
to expose the ramp normal (for voxel shadow calculation) and rotation (for actor orientation).