TheDuckCow / godot-road-generator

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

RoadLane offset approx algorithm #155

Closed bdog2112 closed 4 months ago

bdog2112 commented 4 months ago

Curve offsets are nicely drawn. However, something must be done about Lane Transitions. They plot perfectly fine. But, the IDE freezes when the "+Next RoadPoint" and "+Prior RoadPoint" buttons are used. Said buttons don't freeze the IDE when there are no Lane Transitions.

TheDuckCow commented 4 months ago

Thanks for making the PR, see my response here - if it is just due to small/0-angle continuity, perhaps we can do some very light check to see if the angles are so small that we can forgo the approximation altogether. Just an idea

bdog2112 commented 4 months ago

The latest update fixes the IDE freezing issue and it should also fix problems where RoadLanes doubled back on themselves. It is believed that both issues were caused by the projected angles being too close to 90 degrees, which can result in point positions that are too large.

One way to re-create the problem scenario is to simply add a new RoadPoint using the buttons in the Inspector panel. The default distance and handle values are such that the resulting segment's prev and next mag handles are very close to overlapping and it doesn't take much to move them into a 90 degree orientation with one another.

Validation logic was added to see if the handles were close to 90 degrees. If the angle is 90 degrees +/- a certain "margin", then the old handle projection method is used. Otherwise, the new algorithm is used. Currently, the margin is set to 10 degrees, which prevents exceedingly high point values. But, the margin can always be increased, if needed.

bdog2112 commented 4 months ago

Oh, and Transition Lanes should work fine!

TheDuckCow commented 4 months ago

Great, this is working well on my side, thanks for the quick work to address this. Do you see any outstanding work on this one @bdog2112? Feel free to flip to ready for review and add me once you do.

bdog2112 commented 4 months ago

These changes are ready to go.

Ran GUT and 1 test failed. Traced the history of the test failure back to checkin ed79d21. All tests passed prior to that checkin. Failure doesn't appear to be related to this PR.

TheDuckCow commented 4 months ago

Thanks @bdog2112, yup I'm aware of that failing test in my other PR as well, I'll take care of that one when I have a moment. Will mark this as review ready and see if I have any comments to add.