TheDuckCow / godot-road-generator

A godot plugin for creating 3D highways and streets.
MIT License
377 stars 19 forks source link

Road tilt contains little 'kinks' #14

Closed TheDuckCow closed 1 year ago

TheDuckCow commented 1 year ago

The tilting of roads via road segments is working much better, but I notice now that there is some 'kinking' right around the roadpoint itself. Almost seems like we're not effectively setting the falloff of the underyinging curves.

Screen Shot 2022-10-27 at 9 17 57 PM

In the wheel steal project, this is how the updated road generator looks. In this video in particular, it seems interesting how it's almost like the tilt of one curve before isn't mapping to the ends of the other one. It's possible that this is a limitation of using the curve tilts of the non-connected curve segments under the hood for tilting.

https://user-images.githubusercontent.com/2958461/198502027-2884a6f0-ba7c-42c1-bc1f-b6c7e73a0518.mp4

TheDuckCow commented 1 year ago

Comment from Bret, sharing some initial thoughts (copied as-is):


Sorry, I don't have any quick fixes for the quirk. The gizmo handles can help smooth that out a bit. But, the first idea that comes to my mind is to put a flat buffer or additional flat segment between the two quirky segments. When I say "flat buffer" I really mean "use additional code to do some sort of smoothing or flattening within a certain distance of the start/end points."

Here is something potentially odd that I noticed on or around line 108 of road_segment.gd:

    global_transform.origin = (
        start_point.global_transform.origin + start_point.global_transform.origin) / 2.0

That line sets the origin for the segment and it uses the start_point and the start_point to determine the center. Should the end_point be used as the second point? I don't think it'll fix the quirk. But, it would be good to make sure it's doing what you want. Please let me know.

TheDuckCow commented 1 year ago

Hey @bdog2112 FYI this is the pre-existing issue I mentioned, and the comments above about prior evaluation of it. I do still wonder if we can inspect the current vs next roadpoint to over-correct tilt as necessary. Keeping it opened and unassigned, nice to fix for the initial public release.

bdog2112 commented 1 year ago

It appears that the end points of the curves are not rotated to match their associated RoadPoints. This condition is currently hidden from view because the drawing code uses the ROADPOINT rotation for drawing Segment start and end loops and various CURVE values for drawing the rest of the Segment loops.

If we change the code to use the CURVE values for drawing the start and end loops, then we can clearly see the rotation isn't quite right on those loops.

Curve points don't have an explicit rotation property. Hence, I'm investigating whether we can even set the curve start/end rotation more accurately. If that's not possible, then I'll look at interpolating between the RoadPoints and the curve points.