TheDuckCow / godot-road-generator

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

Allow users to select roadpoints from the 3D view #49

Closed TheDuckCow closed 1 year ago

TheDuckCow commented 1 year ago

We want to add a clickable 3D handler to jump our current selection based on a widget in the center of a RoadPoint prior to selection. This is a properly of the 3D gizmo.

Some requirements, but can be further discussed:

TheDuckCow commented 1 year ago

@bdog2112 let me know what you think of this!

bdog2112 commented 1 year ago

This sounds great! It will really help the overall user experience.

TheDuckCow commented 1 year ago

Great, if this looks ok for you, I'll happily assign it for you to tackle next or concurrently (your choice of how you want to break that down).

bdog2112 commented 1 year ago

I'll weave it into the current work effort. I already have a working prototype using spheres. It raises a few questions:

select-mesh-widgets-800

bdog2112 commented 1 year ago

Kind of answered some of these questions already.

Does the widget size need to remain constant when the user zooms in/out?

This doesn't appear to have a workable solution. There's no way to get the zoom level of the 3D viewport in order to scale the collider accordingly. Also, it's not possible to draw 2D over the 3D viewport in the editor. It only works at runtime. For what it's worth, the collider is reasonably easy to click at various zoom levels if it's two units wide.

Do you want to use the same two-tone clever culling material that we discussed the other day?

This culling material doesn't work well for overlapping geometry. For example, a collider that intersects a Segment. The collider's outer surface is white. But, you see the Segment in the space between the outer surface and the inner surface . This could be remedied by moving the collider above the Segment. But, it inherits its position from the RoadPoint. Hence, the only practical way to move it up is to manually create geometry where the origin is some distance below the actual geo.

Before diving much deeper into potential solutions, it would be good to know what geo we want to use. Cubes provide a low point density, which is good for performance, and they can be easily manipulated to simulate the material we'd like to use.

The following two examples show materials using "culling" vs. "overlapping geometry". In the overlapping approach, the blue geo is slightly taller than the white geo. Hence, it sticks out a little bit. Thus, becoming visible.

"Culling" material cube-culling-800

"Overlapping Geometry" material cube-overlapping-800

TheDuckCow commented 1 year ago

Nice, it's great to see this already! Some quick responses:

Does the widget size need to remain constant when the user zooms in/out?

I was going to suggest not worrying about that now anyways, so no worries it's not even possible.

Do you want to use the same two-tone clever culling material that we discussed the other day?

I did a little searching to see if we could find a better way. Using a shader like this does remove the need for duplicate meshes, but still falls victim to the same issue of the intersection getting between the mesh and the outline rim.

I did some searching and found an example like here which shows nicely an alternative. Here it's just a semi transparent mesh with a solid color. Our blue will likely always stand out quite nicely from the rest of the mesh anyways. So, let's just do a solid cube, solid color, still shadeless, and just move along for now. We can toy in the future with transparency or other approaches.

bdog2112 commented 1 year ago

Just uploaded the basic RoadPoint selection collider. There is still much to do in terms of showing hiding handles and so forth. But, it's a start. ;-)

We don't have to do this right now. But, we could change the color of selected items to provide an additional visual cue. Ideally, I'd like to see handles on the main selection and alt colors on any additional selections (out of scope for now).

Also, it would be good to do a pass over ALL RoadPoints, reset colors and hide handles whenever the selection changes. Currently, the handles are not cleared when a deselection is made. Additionally, if multiple selections are made, it's a bit unpredictable where the handles will end up.

On a positive note, now you can create a drag box around segments to select them! It doesn't work well in Orthographic view. But, it works great in Perspective.