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

[3.x] CSGPolygon fixes and features: Angle simplification, UV tiling distance, interval type. #52509

Merged

Conversation

jitspoe
Copy link
Contributor

@jitspoe jitspoe commented Sep 9, 2021

This is to address new issues introduced in 3.4: #52179
Namely the removal of distance-based intervals and the way UV tiles. I needed these for creating cables in my game.

I also added an option for simplifying geometry (In my game, it reduced the polycount of a cable from around 2900 triangles to 600).

I'm submitting this directly to 3.x because of changes to the class names, removal of pool vector, etc. mean this can't be merged cleanly from master, and it might be nice to get these fixed before 3.4 rolls out. I'll do a separate pull request for master.

@jitspoe
Copy link
Contributor Author

jitspoe commented Sep 9, 2021

Here's the pull request for master: #52512

@jitspoe jitspoe force-pushed the 3.x.csg_fixes_and_simplification branch from 1f184c3 to 066e3be Compare September 9, 2021 12:34
@mhilbrunner mhilbrunner modified the milestones: 4.0, 3.4 Sep 9, 2021
@BastiaanOlij
Copy link
Contributor

Reading the original PR that changed the behavior it has no mention that the way UVs are calculated in this way, shame nobody caught it because I know a number of people who rely on the old behavior.

Having the UV increase over the length of a path according to distance is paramount to anyone who uses CSG path extrusions to create roads, paths, etc. and want to use tiling textures that consistently tile over distance.

So I'm all for this change.

Comment on lines 1883 to 1884
switch (path_rotation) {
case PATH_ROTATION_POLYGON:
Copy link
Member

Choose a reason for hiding this comment

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

There are style issues with the lack of indentation for switch cases:
https://github.com/godotengine/godot/pull/52509/checks?check_run_id=3556178843

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I fixed everything up for the master version: #52512 Figured it'd be best to get that approved first then come back to this one. Not sure if that should be cherry-picked back into 3.x and this PR should be closed or if it's better to be independent, since the class names and stuff changed, likely making a merge problematic.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah finalizing the master PR before updating this one sounds good.

@@ -50,6 +56,9 @@
<member name="spin_sides" type="int" setter="set_spin_sides" getter="get_spin_sides">
When [member mode] is [constant MODE_SPIN], the number of extrusions made.
</member>
<member name="uv_distance" type="float" setter="set_uv_distance" getter="get_uv_distance" default="1.0">
When [member mode] is [constant MODE_PATH], this is the distance along the path, in meters, the texture coordinates will tile. When set to 0, texture coordinates will match geometry exactly with no tiling.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
When [member mode] is [constant MODE_PATH], this is the distance along the path, in meters, the texture coordinates will tile. When set to 0, texture coordinates will match geometry exactly with no tiling.
When [member mode] is [constant MODE_PATH], this is the distance along the path, in meters, the texture coordinates will tile. When set to 0, texture coordinates will match geometry exactly with no tiling.

@BastiaanOlij
Copy link
Contributor

Ok, I need to find some time to do a proper code review, I know @akien-mga already did some, but just played around with these fixes and I'm duly impressed.

The Angle Simplify option works a treat.

There is some strangeness in the calculated Us for the width of my track so it took a bit of trial and error to get the right values and I need to dive into that a bit more to discover the why and if they make sense. Otherwise though the Uv Distance property works exactly as I expect it too. I even finally have my finish line UVs make sense:
image

@jitspoe
Copy link
Contributor Author

jitspoe commented Sep 16, 2021

There is some strangeness in the calculated Us for the width of my track

Ah, right. The UV only uses 50% of the texture so the other half can be used for the caps. I was contemplating adding an option for that, but I didn't want to make the CSG stuff TOO complicated. If you're going to review, check the master one, as I've done some cleanup and variable renames: #52512

@BastiaanOlij
Copy link
Contributor

There is some strangeness in the calculated Us for the width of my track

Ah, right. The UV only uses 50% of the texture so the other half can be used for the caps. I was contemplating adding an option for that, but I didn't want to make the CSG stuff TOO complicated. If you're going to review, check the master one, as I've done some cleanup and variable renames: #52512

Ah yes that makes sense I guess. So with 4 sides to the polygon being extruded adding up to have of the width of the texture my road section U width is 0.125. Hence * 8 brings it back to 1.0.

@Zireael07
Copy link
Contributor

Please edit the PR title to make it clear it's for 3.x (I was confused why there are two identical PRs sitting open in my notifications)

@akien-mga akien-mga changed the title CSGPolygon fixes and features: Angle simplification, UV tiling distance, interval type. [3.x] CSGPolygon fixes and features: Angle simplification, UV tiling distance, interval type. Sep 16, 2021
@akien-mga
Copy link
Member

I'm happy merging the master PR now, so this should be updated to match its changes.

@akien-mga
Copy link
Member

I'm happy merging the master PR now, so this should be updated to match its changes.

Bump :)

@jitspoe
Copy link
Contributor Author

jitspoe commented Sep 29, 2021

I'm happy merging the master PR now, so this should be updated to match its changes.

Bump :)

Sorry, out of town for a few days. Will try to address this next week.

@akien-mga akien-mga force-pushed the 3.x.csg_fixes_and_simplification branch from 066e3be to cbf855d Compare October 4, 2021 10:01
@akien-mga
Copy link
Member

I went ahead and amended your PR to do the same changes (renames, reordering) as in #52512.

…distance option, and interval type, which allows distance-based intervals (old) and subdivision-based intervals (new to 3.4).
@akien-mga akien-mga force-pushed the 3.x.csg_fixes_and_simplification branch from cbf855d to d7af7a9 Compare October 4, 2021 10:14
@akien-mga akien-mga merged commit 87feb57 into godotengine:3.x Oct 4, 2021
@akien-mga
Copy link
Member

Thanks!

stebulba added a commit to stebulba/godot that referenced this pull request Oct 6, 2021
[3.x] Quick fix on path_simplify_angle introduce here godotengine#52509 (comment)
after merging godotengine#52509
sairam4123 pushed a commit to sairam4123/godot that referenced this pull request Nov 10, 2021
[3.x] Quick fix on path_simplify_angle introduce here godotengine#52509 (comment)
after merging godotengine#52509
lekoder pushed a commit to KoderaSoftwareUnlimited/godot that referenced this pull request Dec 18, 2021
[3.x] Quick fix on path_simplify_angle introduce here godotengine#52509 (comment)
after merging godotengine#52509
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants