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

sample_baked_with_rotation in Curve3D gives wrong rotation near first and last points #100590

Open
AstroStucky opened this issue Dec 19, 2024 · 4 comments

Comments

@AstroStucky
Copy link
Contributor

AstroStucky commented Dec 19, 2024

Tested versions

Reproducible in

  • 4.4.dev.custom_build.fafc07335
  • 4.3.stable.official.77dcf97d8
  • 4.2.2.stable.official.15073afe3

System information

Godot v4.3.stable - Ubuntu 22.04.5 LTS 22.04 - X11 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3080 (nvidia; 550.120) - Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz (6 Threads)

Issue description

Curve3D's sample_baked_with_rotation returns strange rotation values near the first point and the last point of a curve.

Steps to reproduce

  1. Construct a Curve3D with at least 3 points.
  2. Give the middle point a non-zero in and out vector.
  3. Sample the curve with rotation using sample_baked_with_rotation at regular intervals to see that the rotation value veers off in a weird direction as the first and the final points are approached.

Minimal reproduction project (MRP)

mrp_curve3d-edge-rotation.zip

The attached MRP is a 3D scene with a Camera3D, a Path3D, and a MeshInstance3D. The Path3D has a script attached to it that draws basis provided by sample_baked_with_rotation along the entire length of the Path3D. This is not a tool script, so the project must be ran to see the basis drawn. The Path3D script has some exported parameters to help the user investigate this issue: count is the number of samples of the curve taken and drawn in the 3D viewport as basis gizmos, size is the length of the vector that represents a basis in a gizmo, and cubic changes whether sample_baked_with_rotation is called with cubic = true or cubic = false (the issue behavior does not appear to change based on this).

Examples from MRP

The following is the 3D scene with only 50 samples taken so the basis gizmo can be more easily seen.
Image

As the number of samples increases so does the number of problematic rotation samples near the first and last points.
Image

When the middle point has zero in and out vectors, there are only straight lines and this issue does not occur.
Image

@AstroStucky
Copy link
Contributor Author

sample_baked_with_rotation unit tests are only ever performed with a straight line. My 3rd MRP example implies this issue cannot be caught by the existing tests.

// Sampling over a simple straight line to make assertions simpler

@AThousandShips
Copy link
Member

@AstroStucky
Copy link
Contributor Author

They appear to be the same issue, only that one is reporting on Curve2D. Perhaps the underline cause is the same?

@AThousandShips
Copy link
Member

Probably, let's keep this open until we know for sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants