SplineHelp GetPosition Deformation

  • I am using the GetPosition function from the SplineHelp class to take a user fed in spline and create a new spline. I use the code below to create the new spline with a set number of points.

    AutoAlloc <SplineHelp> helperSpline;
    helperSpline->InitSpline(spline, SPLINEHELPFLAGS::NONE);
    Float offsetIncrease = 1.0 / numberPointsPerSegment;
    maxon::BaseArray< maxon::BaseArray<Vector> > vectorDoubleArray;
    maxon::BaseArray<Vector> vectorSingleArray;
    for (Int32 segmentIndex = 0; segmentIndex < helperSpline->GetSegmentCount(); segmentIndex++)
    	for (Int32 pointIndex = 0; pointIndex < numberPointsPerSegment; pointIndex++)
    		vectorSingleArray.Append(helperSpline->GetPosition(pointIndex * offsetIncrease, segmentIndex, TRUE, TRUE));

    This code works properly on single segment splines, the problem comes in when a spline is fed in that has multiple segments. From what I can tell the first segment is processed properly, subsequent segments start having issues. As the loop runs on the second segment it start becoming deformed at the end.

    Forum Post 1.png

    I know that feeding in an offset to GetPosition that is greater than 1.0 will not return proper results, I confirmed that the offset I am using does not go outside the bounds of 0->1.0. The offset value that will first trigger the issue seems to vary based on the number of points I am trying to put in the spline. This problem only happens if the number of points that I am trying to create on the new spline passes a certain number (this number seems to vary based on the size of the spline segment).

    I can seemingly correct the issue by increasing the Uniform Intermediate Points parameter on the splines that I am feeding into my plugin, this will effect the speed of the plugin and I want to avoid that if possible.

    Is there an alternative way to deal with this issue without increasing the number of Uniform Intermediate Points?

    Any help would be greatly appreciated.

    John Thomas

  • hi,

    That comes from the Smooth parameter in the function GetPosition. It's doing an interpolation from the end of the segment to the beginning of the next segment (or the first one).

    If you set the parameter to false you will have the correct position.

    GetPosition(pointIndex * offsetIncrease, segmentIndex, false, true))

    I will still open a bug entry and ask the dev. This doesn't look logical to me neither :)


  • Thanks for the response, that's exactly what I needed.

    John Thomas