SDK. Refine Segment - update shape


#1

How can I update a shape node after refining a spline segment?
All works fine except for segments. I get the new knot but the segment where it lies isn’t subdivided.
If I tape “updateShape $” into the listener, the segment subdivision is created. But I can’t get to do it via SDK.
I have:

  • ComputeBezPoints() for the Spline3D
  • UpdateSels(), UpdateEdgeDists(), UpdateVertexDists() and UpdateBindList() for the BezierShape (sorting the order of them).
  • UpdateVertexDist(), UpdateEdgeDists() too for the SplineShape.
    Nothing, nor isolated nor all together seems to work.
    What am I doing wrong?

#2

OK, I missed “InvalidateGeomCache()”.


#3

Then I take this to a new question:
is there a way to avoid double call to topology_changed and geometry_changed if both handlers are set?


#4

actually it’s good when you send both change messages. You send it not for yourself but for your plugin’s dependents. And you don’t know what messages they wait.


#5

The problem is that my code does a lot of recalculations when the spline changes.
If user deletes a knot, Topology changes and does the calculation. OK.
If user undoes the action, both Topology and Geometry are triggered and thus the code does twice the same heavy calculation.


#6

It’s a familiar situation for me. I calculate a HASH of spline first, and check if it matches the last recalculation. If it’s not I do recalculation again.

My HASH includes: curve length, number knots, points params (in, out, pos). Sometimes I add number steps and normalization flag


#7

Great idea, as always. Thanks!.. But you make me work :rage:


#8

you are welcome :sunglasses:


#9

Just one more question:
when you say a HASH, are you talking of a real HASH (a number that indentifies an object’ state) or do you simply make a comparison between object’s values?
In the first case, can you show me an example of how do you combine these data (number of knots, lengths…) in a single number?
Thanks.


#10

see https://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode/263416#263416

safe, quick and cheap


#11

OK. Thanks a lot.
I’ll implement it and, I suppose, cache the value after every calculation in a new object field.