@guest (pink color): what rewrite process are you referring to?
-
Do you often use the struct objects?
-
The only time it starts to become a problem is when you try to compute visual properties-- like bounding
boxes, for example-- in Pd. So if you have a data structure visualized with, say, 20 polygons, Pd needs to
recalculate the bounding box every time the mouse is moved over the patch. That's one of the reasons why
they are so inefficient. (But that goes the same for a canvas filled with lots of object boxes.)@jancsika Could you elaborate on this problem? How does it affect regular patching (without the use of data structures)? Are the bounding boxes you mention the same as a GOP area?
-
@jancsika My own (private) rewrite process (yellow == pink).
-
Pd computes bounding boxes for every graphical object, including message boxes, object boxes, and iemguis. It needs to know the top-left and bottom-right corners of the box so that it can tell when you click inside or mouse over the object. The algorithm just walks the list of all the objects in the canvas until it finds one that includes the current mouse position, then calls that object's event handler.
For a patch with 10 objects in it, it's usually not a big deal-- at worst you compute 10 bboxes. But if there are 1000 objects and you mouse over an empty area of the patch, Pd iterates over all 1000 before deciding you didn't move the mouse over anything interesting. Open Pd with the "-d 3" flag (for debugging) and see how many "motion" messages get sent to Pd from the GUI. Each one triggers a walk across the list of objects (or some portion of it). That's bad.
I haven't changed this yet in the GUI port because I'm doing things incrementally. But doing that "hit box" computation in the GUI instead of in Pd will definitely be an improvement. (And besides, gui toolkits have all kinds of tricks for doing calculations like that efficiently.)
-
@jancsika Thanks for the detailed reply. I have been pondering this problem for a long time with regards to custom made click GUI objects using mouse data from iemguts/sendcanvas, which I have indulged in quite a lot. The more you replicate them, the more obsolete data you have. But I didn't know that this happened with every GUI object. In a way it makes me feel better, because at least the custom buttons don't create any more mess than the factory ones! But it still does make me feel uneasy, and I know the day will come when I create enough copies of the abstraction that performance starts to suffer.
-
@LiamG: Not sure what you mean about obsolete data. A patch with 1000 objects will have the correct coordinate data for the objects-- it's just that it becomes computationally expensive and causes dropouts in the audio.
But yeah, even iemguis suffer the same fate.