Skip to content
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

Implement slope sculpting tool #297

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

tcoxon
Copy link
Contributor

@tcoxon tcoxon commented Jan 9, 2024

Admin edit:
Fixes #96


This PR implements the slope sculpting feature discussed in #96.

Screencast.from.2024-01-09.17-18-00-edit.webm

Quick word on naming first: I've used both 'Gradient' and 'Slope' here, but to mean different things. A slope is a gradient applied to the height map, whereas a gradient operation could theoretically apply to other maps like color and roughness (if implemented).

UI is shown in the above video. Click two points, then if drawable is unchecked there's a little pause as it builds a straight-line slope. If drawable is unchecked you can click and drag to make wiggly slopes. If you selected the wrong point, you can use the dropper buttons in the tool settings bar to pick a different one.

Figuring out how to implement the non-drawable gradient was pretty difficult because the flow is significantly different from other tools that are already present. I've created an OperationBuilder abstraction to avoid turning editor.gd, ui.gd, and toolbar_settings.gd into spaghetti. Gradient operations are the only ones that use this currently.

The gradient operation in terrain_3d_editor.cpp uses the direction of movement of the brush as well as its position. This to keep winding slopes from having one edge higher than another. The following screenshots demonstrate the difference this makes:

Screenshot from 2024-01-09 18-34-16

Screenshot from 2024-01-09 18-32-14

@Saul2022
Copy link

Saul2022 commented Jan 10, 2024

tested and it works well, though it freezing when painting a slop when drawable is off. Specifically after you pinned the first pin , when you try to position the second one the engine freezes, which doesn't happen when drawable is on.

Also when you have terrain 3d with other build already enabled, and then you replace it with this one, at first the function doesn't appear unless you re enable it again in the project sethings

Copy link
Owner

@TokisanGames TokisanGames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR. Excellent work.

Some notes:

  • The insta-slope is obviously slow. 10-50x slower than just using the drawable brush, so I looked into why. In gradient_operation_builder.gd:apply_operation the movement dir of 1 is unnecessarily small, especially on large brushes. I found that the movement can be 1/3rd the brush size for optimal speed without gaps. So a 60m brush can move 20 each iteration. And a 9m brush, 3m brush, 1.

    This makes the tool much more usable. It's more than 10x faster. It makes long slopes across many regions possible. And now opacity makes more of a difference. At 100% it has a similar appearance as when movement is 1, but at 10%, it has only a subtle effect as it should.

  • If 2 points are selected with drawable on, then drawable is turned off, the 2 points are still selected. On the next click it draws another slope between the two points. I think it should clear the points when drawable is turned off.

  • Pressing Escape, switching to another tool, or deselecting Terrain3D should cancel picking. Currently:

    • Escape deselects Terrain3D (as it does for all nodes) and whenever Terrain3D is reselected, it's still picking
    • If you pick, then click another tool, say flatten, the picker decal is still there. If you click the terrain, the pick happens and flattening doesn't until another click.

@tcoxon
Copy link
Contributor Author

tcoxon commented Jan 22, 2024

Thanks for the great feedback. I've implemented your suggestions.

@TokisanGames
Copy link
Owner

Excellent, thank you. I increased the frequency from .333 to .2 for now.

@TokisanGames TokisanGames merged commit 48f27c9 into TokisanGames:main Jan 25, 2024
@tcoxon tcoxon deleted the feature/slope_sculpting branch July 12, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Slope Sculpting Tool
3 participants