On 05/06/2015 at 23:52, xxxxxxxx wrote:
Hi Yannick,
this one's going to be a nutter to debug. The code body concerning the spline point movements is 1500+ lines long. As far as I can tell, everything else is working - the point values are changing to their new correct values, tangents are right, point selections are right. I'm seeing that by GePrint'ing or text display in the user area (it's a custom spline gui display). Here's a segment of code that I use to print at the end of the routine in the InputEvent(), where the non-sorted error pops up:
// - Long_1 is a LONG variable
// - Spline_Holding_Point is an int/long that's set before the mouse event loop runs.
// It's set with the first selected point found. For my testing it is point 2 (index 1)
// - Spline = SplineData reference
GePrint("Pre-sorted..");
for(int i = 0; i <= Spline->GetKnotCount()-1;)
{
GePrint("Spline point " + LongToString(i) + ".x = " + RealToString(Spline->GetKnot(i)->vPos.x));
i++;
}
// at this point, the results I get are something like point 0 = 20, point 1 = 17.68
Long_1 = Spline_Holding_Point;
Spline->SortKnots(Long_1);
// as I understand it, Long_1 should now be 0, but it's still 1
GePrint("Post-sorted..");
for(int i = 0; i <= Spline->GetKnotCount()-1;)
{
GePrint("Spline point " + LongToString(i) + ".x = " + RealToString(Spline->GetKnot(i)->vPos.x));
i++;
}
// the results I still get are point 0 = 20, point 1 = 17.68
Firstly, is there anything immediately wrong with the above? Should the only thing I need to call here be SortKnots()?
I've been going through the main body of code over and over but there isn't anything sticking out that I can see. I can try posting a dumbed-down version of the main body if you like, let me know. The only thing of note so far that I can see in it, is the lack in change of the selected point index - i.e. a lack of change in the sorting of the knots.
As an aside, do splines have to have selected points before they can be sorted?
WP.