SortKnots()
-
On 04/06/2015 at 23:20, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;---------
Hi folks,
I have a spline with knots that are being 're-valued', by altering the vPos attribute in the knot as taken from the SplineData object reference. But they're not being sorted properly. I can see this by printing each knot's x value - they're not in the correct order. I'm passing a legitimate selected knot index as the SortKnots() argument, but I can see that this is not changed after the SortKnots() call either.
Is there a known issue with SortKnots() that might be at play here? Or is it one of these programmed things that doesn't work the way you (I) expect it to behind the scenes? Should I be making my own sort knots function and doing this manually myself? Other?
Cheers!
WP. -
On 05/06/2015 at 09:12, xxxxxxxx wrote:
Hi,
I can't confirm this behavior. Do you have some code showing this issue with SplineData::SortKnots()?
-
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. -
On 08/06/2015 at 03:11, xxxxxxxx wrote:
Hi,
Originally posted by xxxxxxxx
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?No, there isn't any requirement on the selection state of spline points before sorting.
The only one is a spline must have more than 2 points before it can be sorted. -
On 10/06/2015 at 13:11, xxxxxxxx wrote:
I've been going over and over this one, but simply can't see anything wrong. I remember coming across odd behaviour with sorting knots sometime ago but don't recall what the issue/fix was. I have a sneaky sus**cion it was something completely unrelated to the spline itself, but with no indication as to why that would affect the sorting. Maybe a similar thing here. So frustrating.
Will continue to fiddle about and let folks know if/when I come across the issue.
WP. -
On 05/07/2015 at 20:11, xxxxxxxx wrote:
Hi all,
I've been unable to resolve this one, and am wondering if anyone is able to explain what might cause the SortKnots() to not do it's thing. Is there something in that function that would return the function early without doing any sorting? Is support able to dig into that a little?
I've tried debugging the code, but I'm not getting anything of note from that.
WP.
-
On 05/07/2015 at 23:21, xxxxxxxx wrote:
I'm not sure how it should work, but if none of the 2 next steps work "or combination of both" , then I don't know:
1- make sure your spline got more than 2 knots "10 knots for example"
2- may be SortKnots() behaves in a different way, so if knot (7) is selected, try typing SortKnots(2) , now Knot 7 should be number 2 //I'm improvising here , as the standard way of how the function should work is failing "from your code" -
On 06/07/2015 at 00:53, xxxxxxxx wrote:
Oh, I've misread some of the posts above. You need more than 2 points. I was under the impression you needed 2 or more points.
But this begs the question, why on earth would they not sort a spline with 2 points!? What a ridiculous 'limitation'!?
So, are we suppose to sort splines with 2 points manually??
WP.
-
On 06/07/2015 at 04:14, xxxxxxxx wrote:
Hi,
Yes at the moment you've to swap the 2 knots manually:
CustomSplineKnot tmp = *data->GetKnot(0); data->SetKnot(0, *data->GetKnot(1)); data->SetKnot(1, tmp);
I agree the limitation of SorKnots() is ridiculous and it will be fixed for splines with 2 points.
-
On 06/07/2015 at 04:46, xxxxxxxx wrote:
Hi Yannick,
thanks for the clarification!
WP.