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

Possible issues with normal interpolation #117

Open
kkkkkom opened this issue Feb 28, 2022 · 0 comments
Open

Possible issues with normal interpolation #117

kkkkkom opened this issue Feb 28, 2022 · 0 comments

Comments

@kkkkkom
Copy link

kkkkkom commented Feb 28, 2022

Hi,

We are using path creator for our project and really liked it. But there seems to be some issue with the normal interpolation. Since we are using it for first-person view, the normal is critical for our application.

So what we noticed is that there is sometimes a glitch when spinning the normal. Below is a sample code that we used in the Unity editor to generate the curve:

    static void NormalDebug()
    {
        CurveGenerator generator = FindObjectOfType<CurveGenerator>();
        GameObject target = generator.target;
        
        List<Vector3> pointsPos = new List<Vector3>() // default constructor is modified to avoid simplification, otherwise a straight line is likely to be reduced to only two points.
        {
            new Vector3(19.8f, 0f, 0f),
            new Vector3(18.3f, 0f, 0f),
            new Vector3(16.8f, 0f, 0f),
            new Vector3(16.3f, 0f, 0f),
            new Vector3(15.6f, 0f, 0f),
            new Vector3(15.0f, 0f, 0f),
            new Vector3(14.3f, 0f, 0f),
            new Vector3(12.8f, 0f, 0f),
            new Vector3(11.3f, 0f, 0f)
        };
        List<float> pointsNormal = new List<float>() // 270 degree normal is used as the vertical forward view in our application
        {
            270,
            270,
            270,
            265,
            245,
            225,
            215,
            215,
            215
        };

        target.GetComponent<PathCreator>().bezierPath = new BezierPath(pointsPos);
        for (int i = 0; i < pointsNormal.Count; i++)
            target.GetComponent<PathCreator>().bezierPath.SetAnchorNormalAngle(i, pointsNormal[i]);
    }

Below link is a short video that shows the glitch that spins -90 degree from the expected normal direction for a short period of time.
https://youtu.be/vcGvx_TX-4E

We found usually deleting one or a few anchors around the glitch point may fix the issue, but since we are hoping to use it in an automatic scripting way without any manual intervention, thus really want to fix the issue.

We feel the issue might be coming from normal interpolation part, but haven't looked into details yet, and are wondering if you could provide some quick suggestions on where we could possibly modify the code and see if the issue could be fixed?

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

No branches or pull requests

1 participant