CytopiaTeam / Cytopia

:deciduous_tree::house_with_garden::office::evergreen_tree: A city building simulation game
https://www.cytopia.net
GNU General Public License v3.0
1.97k stars 105 forks source link

Implemented "level terrain" feature, fix #28 #1017

Closed DanielMowitz closed 2 years ago

DanielMowitz commented 2 years ago

This is an overall naïve implementation, in the sense that it copies the height of the initial selected node and applies it to the whole area.

The main factors for code complexity stem from:

The first point might be mitigated though by deciding on only having rectangular selection for levelling (see #1016).

Sloped node behavior

Slopes should lower the terrain when the selection is pulled from the lower side:

image levels to image

They should raise the terrain when the selection goes the other way:

image levels to image

Edged slopes should behave the same:

image levels to image

In all screenshots the rectangle was dragged up from the lowest edge (I couldn't more meaningful screenshots, sorry).

lizzyd710 commented 2 years ago

Oh wow, this is awesome, thank you! I don't know why sonarcloud is throwing a fit, but all the checks pass so that's the key part. I'll play around with it and give a review.

DanielMowitz commented 2 years ago

As an aside, the format-files.sh script changed 16 additional files that I haven't touched at all. Maybe the Shell script/clang handles formatting a bit differently to the windows/js one?

DanielMowitz commented 2 years ago

… and with this commit it even compiles :+1:

sonarcloud[bot] commented 2 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 8 Code Smells

1.2% 1.2% Coverage
0.0% 0.0% Duplication

lizzyd710 commented 2 years ago

As an aside, the format-files.sh script changed 16 additional files that I haven't touched at all. Maybe the Shell script/clang handles formatting a bit differently to the windows/js one?

Maybe. It's also possible that those files were formatted wrong. (As you saw in some other files you changed in this PR someone was doing weird formatting so that's entirely possible.)