TheDuckCow / godot-road-generator

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

Restructure points and segments #74

Closed TheDuckCow closed 9 months ago

TheDuckCow commented 1 year ago

Right now, we have RoadPoints as children of a points node which needs to be added as a spatial to the scene.

However, there are new oddities introduced if the player then tries to move/rotate/etc the "points". Furthermore, this points node would have to remain as a Spatial if RoadPoints are to be parented to it, otherwise we can't get the benefit of chained parent-child transform chaining.

The proposal, which is not backwards compatible:

TheDuckCow commented 11 months ago

Update to this task: We are going to go down this route described below, as it will better serve many details later. Instead of the initial proposal above which keeps a Segments spatial, everything will be hierarchical to RoadPoints instead.

So the idea is that in a formed scene, you might have a structure like this:

Some rationales for this structure:

I'll update this task as I refine it further, but it is the first major work to take on to get this all working.

TheDuckCow commented 11 months ago

This task is in progress, and arguably done.. however the result has exasperated underlying issues that have to do how geo is transformed from local to global space.

Due to RoadSegments now being children of RoadPoints, which are themselves rotated by the user, we have cascading transforms to inverse and undo. I made an initial quick fix that seemed to undo rotation and was evidently working well, but upon further review I found that connecting road segments with non-xz flat orientations created weird twisting that was not present before. Additionally, when it comes to intersections and prefab scenes, we know it will be important to be able to rotate and translate entire road networks without consequences. Right now translation is fine, but rotation has long been a no-go (in fact, the very original version of the RoadNetwork class actually had it as a base Node object, not a spatial, to try and prevent any transformations).

So, instead of continuing to build on a stack of cards, I'm rolling up my sleeves and trying to get my head around the particular points of issues. What I've come up with is the following areas needing fixing

  1. Where we calculate the normal used to extrude geometry from a single loop within the middle of a road segment generation (need to fix this first! Cascading effects otherwise)
  2. Where we se the handle in-out points of the RoadSegment's curve
    • (simplified for now by zeroing them out, always straight lines now, zero magnitude)
  3. Where we calculate the last loop within a road to ensure things are connected
    • (simplified for now by not generating that loop, to avoid further confusion)

These changes are all going into the 74-restructure-points-and-segments because I don't want to merge this branch if it creates new quirks that weren't present before. Stay tuned as I wrap my head around the right sequence of xform and xform_inv's...

TheDuckCow commented 10 months ago

The good news is this branch is just about ready finally! I was able to resolve the last of the consistency issues yesterday. However with some QA playing around with it today, there's one annoyance now with the new structure:

When you select a roadpoint, you see a bounding box around the road segment contained within it. While in one way this is actually nice as it clearly indicates which roadpoint owns that segment of road, it's rather distracting especially as you rotate or move the roadpoint around (since the box continually is resizing). It would be nice to have control over how we visualize the owned roadsegment by disabling this selection box outline.

Screen Shot 2023-09-18 at 7 27 34 AM