TheDuckCow / godot-road-generator

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

12 initial gizmo handle jumps on cursor press 1 #20

Closed bdog2112 closed 1 year ago

bdog2112 commented 1 year ago

Re-configured handle logic to work as follows:

-Use the handle's magnitude as a local Z-value and create a new vector.
-Use the road point to convert the vector to global space.
-Combine the result with the camera basis to create a plane.
-Calculate the intersection between the plane and a camera ray.
-Use the road point to convert the intersection point to local space.
-And, finally, use the point's local Z-value as the handle's new magnitude.

Some of these steps were already being done. The missing element was probably the conversion of the magnitude to a point in global space.

Logic seems to tell us that the handle is aligned to the road point. Therefore, we can use the road point as our reference for creating the plane. But, in actuality, we have to use the handle's location. (This was a challenging realization.)

The clue was the fact that the handle jumped only a little bit, which meant that we were looking for something that was only slightly off. The handle and the road point were only offset by a little bit and the jumping increased as the handle moved further away from the center of the road point.

Ran GUT and all tests passed.

TheDuckCow commented 1 year ago

The change is working well, and thanks for explaining the fix! It's always something how the hard changes are but a few lines of code. For the record, see the demo before and after video here; will finish code review shortly

https://user-images.githubusercontent.com/2958461/200723778-639f665c-c57c-4273-a39d-1b79d6e361fa.mp4