TheDuckCow / godot-road-generator

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

Identify container edges #128

Closed TheDuckCow closed 9 months ago

TheDuckCow commented 9 months ago

As a stepping stone to allow for the connection of different RoadContainers to other RoadContainers, this PR establishes the concept of "edge RoadPoints".

Whenever adding a new RoadPoint or updating connections of a RoadPoint, the RoadContainer.update_edges() function on the given RoadContainer instance will trigger. The result is the update of 5 parallel export var arrays. While it seems excessive, this seems to be the most stable way to ensure bidirectional fetching of data. Basically, these export vars allow the equivalent of a RoadPoint of one container to set its next_pt_init to a RoadPoint on another, but using their corresponding RoadContainers as middlemen. Relevant snippet from the code for more

## Auto generated exposed variables used to connect this RoadContainer to
## another RoadContainer.
## These should *never* be manually adjusted, they are only export vars to
## facilitate the connection of RoadContainers needing to connect to points in
## different scenes, where said connection needs to be established in the editor
export(Array, NodePath) var edge_containers # Paths to other containers, relative to this container
export(Array, NodePath) var edge_rp_targets  # Node paths within other containers, relative to the *target* container (not self here)
export(Array, String) var edge_rp_target_dirs  # Bools, true = next_init
export(Array, NodePath) var edge_rp_locals  # Node paths within this container, relative to this container
export(Array, String) var edge_rp_local_dirs  # Bools, true = next_init

Relates to #122

All tests pass, including new ones added to ensure auto updating of these export vars.