On 05/19/2018 11:56 AM, Roman Haefeli wrote:
> Yeah. It's not very elegant and gets expensive pretty quickly. I was
> wondering about alternative strategies, like moving non-used scalars
> out-of-the-way and later re-use them. It's cumbersome to implement, but
> probably less drastic than the clear-all-and-rebuild method. 
Can only answer to this: There are several methods to make scalars
invisible. Anyhow, in my experience the method to clear the subpatch and
recreate everything works quite well and is imho the clean approach to
do it, as all the scalars are redrawn every frame any way.

There are other limits to the use of data structures. Depending on your
computer, when you get above 800 scalars or so, the patch becomes laggy.

Consider the attached patch: On load 1050 scalars are created, which is
already quite heavy on my computer. Anyhow, deleting a scalar by
clicking on it works fine, using the clear and redraw method.

Hiding scalars by making them invisible doesn't help with the lagging
problem. Therefore i would recommend the clear and redraw method any day. ;)

best wishes, ingo
#N canvas 142 116 1107 655 12;
#N canvas 1 88 450 300 \$0-display 0;
#X coords 0 0 422 362 422 362 2 0 0;
#X restore 48 42 pd \$0-display;
#X msg 655 376 clear;
#X obj 655 399 s pd-\$0-display;
#X obj 677 560 pointer;
#X msg 677 537 traverse pd-\$1-display \, bang;
#X obj 677 514 \$0;
#N canvas 523 298 476 332 \$0-square 0;
#X obj 36 57 struct \$0-square float x float y float id;
#X obj 36 34 filledpolygon 778 338 1 0 0 0 10 10 10 10 0;
#X obj 36 80 unpack s p f;
#X obj 36 149 get \$0-square id;
#X obj 59 218 array set \$0-state;
#X obj 36 172 t b b f;
#X obj 59 195 0;
#X obj 36 264 s \$0-create;
#X obj 36 103 sel click;
#X obj 36 126 pointer;
#X obj 36 241 del;
#X text 70 241 <- Without this delay the patch crashes quite often...
;
#X connect 0 0 2 0;
#X connect 2 0 8 0;
#X connect 2 1 9 1;
#X connect 3 0 5 0;
#X connect 5 0 10 0;
#X connect 5 1 6 0;
#X connect 5 2 4 1;
#X connect 6 0 4 0;
#X connect 8 0 9 0;
#X connect 9 0 3 0;
#X connect 10 0 7 0;
#X restore 519 54 pd \$0-square;
#X obj 519 264 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X obj 519 376 array get \$0-state;
#N canvas 1 115 211 251 list-drip 0;
#X obj 42 39 inlet;
#X obj 42 154 list store;
#X obj 42 85 until;
#X obj 42 108 f;
#X obj 72 108 + 1;
#X msg 42 131 get \$1 1;
#X obj 85 86 0;
#X obj 42 177 outlet;
#X obj 109 177 outlet;
#X obj 42 62 t b b a;
#X connect 0 0 9 0;
#X connect 1 0 7 0;
#X connect 1 1 8 0;
#X connect 1 1 2 1;
#X connect 2 0 3 0;
#X connect 3 0 5 0;
#X connect 3 0 4 0;
#X connect 4 0 3 1;
#X connect 5 0 1 0;
#X connect 6 0 3 1;
#X connect 9 0 2 0;
#X connect 9 1 6 0;
#X connect 9 2 1 1;
#X restore 519 399 pd list-drip;
#X obj 563 445 f;
#X obj 593 445 + 1;
#X obj 623 445 0;
#X obj 519 353 t b b b;
#X obj 519 422 t f b;
#X obj 519 445 sel 1;
#X obj 519 468 f;
#X msg 542 169 const 1;
#X obj 519 491 t f f f;
#X obj 519 583 append \$0-square x y id;
#X obj 519 100 loadbang;
#X obj 519 537 * 12;
#X obj 571 537 * 12;
#X obj 519 514 mod 35;
#X obj 571 514 div 35;
#X obj 519 560 + 2;
#X obj 571 560 + 2;
#X obj 519 330 r \$0-create;
#X obj 519 284 s \$0-create;
#X obj 519 215 s \$0-create;
#X obj 609 264 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X obj 609 284 s \$0-clear;
#X obj 655 353 r \$0-clear;
#X obj 584 100 r \$0-reset;
#X obj 691 264 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X obj 691 284 s \$0-reset;
#X msg 606 169 resize \$1;
#X obj 519 146 t b b f;
#X obj 542 192 array define \$0-state;
#X obj 519 123 1050;
#X floatatom 604 124 5 0 0 0 - - -, f 5;
#X text 621 55 <- Deleting happends inside here;
#X text 655 123 <- Changing the number of squares also clears and redraws
\, so it happends really fast.;
#X connect 1 0 2 0;
#X connect 3 0 19 3;
#X connect 4 0 3 0;
#X connect 5 0 4 0;
#X connect 7 0 28 0;
#X connect 8 0 9 0;
#X connect 9 0 14 0;
#X connect 10 0 11 0;
#X connect 10 0 16 1;
#X connect 11 0 10 1;
#X connect 12 0 10 1;
#X connect 13 0 8 0;
#X connect 13 1 5 0;
#X connect 13 2 1 0;
#X connect 13 2 12 0;
#X connect 14 0 15 0;
#X connect 14 1 10 0;
#X connect 15 0 16 0;
#X connect 16 0 18 0;
#X connect 17 0 38 0;
#X connect 18 0 23 0;
#X connect 18 1 24 0;
#X connect 18 2 19 2;
#X connect 20 0 39 0;
#X connect 21 0 25 0;
#X connect 22 0 26 0;
#X connect 23 0 21 0;
#X connect 24 0 22 0;
#X connect 25 0 19 0;
#X connect 26 0 19 1;
#X connect 27 0 13 0;
#X connect 30 0 31 0;
#X connect 32 0 1 0;
#X connect 33 0 39 0;
#X connect 34 0 35 0;
#X connect 36 0 38 0;
#X connect 37 0 29 0;
#X connect 37 1 17 0;
#X connect 37 2 36 0;
#X connect 39 0 37 0;
#X connect 40 0 37 0;

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list

Reply via email to