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

Create an "auto" direction for ease of connections #178

Open
TheDuckCow opened this issue Aug 29, 2024 · 0 comments
Open

Create an "auto" direction for ease of connections #178

TheDuckCow opened this issue Aug 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@TheDuckCow
Copy link
Owner

Right now, if you want to manually construct RoadPoints into the scene and then later connect them together, you have the connect_roadpoint function on the RoadPoint class per here.

func connect_roadpoint(this_direction: int, target_rp: Node, target_direction: int) -> bool:

So if you have, say, RPA at the origin and another RPB at (0, 0, 20) you might do a call like:

RPA.connect_roadpoint( # arbitrarily starting "from" the first roadpoint A
    RoadPoint.PointInit.NEXT, # presume RPA is rotated such that the "next" side is facing RPB
    RPB, # the one we want to connect to
    RoadPoint.PointInit.PRIOR # if RPB is facing the same way as RPA, then it would be it's PRIOR side that is closest/facing RPA
)

That's all good and dandy, but it's a quite a bit of extra work on each developer to try and figure out which ones to connect. In many cases, the road generator could probably easily guess which one the user wants by doing a simple dot product comparison of which way each one is facing relative to the other and then pick PRIOR/NEXT appropriate for each roadpoint.

We could accomplish this by introducing a new direction type, though we'd have to be very clear where this is allowed to be used or not:

RPA.connect_roadpoint( # arbitrarily starting "from" the first roadpoint A
    RoadPoint.PointInit.AUTO, # let the road generator figure out which direction of RPA is facing RPB
    RPB, # the one we want to connect to
    RoadPoint.PointInit.AUTO # let the road generator figure out which direction of RPB is facing RPA
)
  • If RPA is entirely unconnected, then it would check whether the -z or +z basis is more oriented towards PRB to decide PRIOR vs NEXT
  • If RPA is connected on one side e.g. it already has a "next" connection, then it should just directly use the other direction ie "prior"
  • Ditto checks for PRB

With the above, it also adds flexibility: maybe you know that on RPA that it's the "next" that needs connecting or has a more ambiguous orientation, you could specify that one specifically but still let the other side be auto-figured out.

Alternatively, we could just provide the simplest possible function like connect_roadpoint_auto which only lets you pass in another roadpoint. This function itself could call connect_roadpoint internally after determining the right orientations.

@TheDuckCow TheDuckCow added the enhancement New feature or request label Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant