[PD] Request - Deleting struct instances, progress?

Christof Ressi christof.ressi at gmx.at
Wed Jan 4 01:05:48 CET 2017


> which can be dangerous in case you use your scalars just to store (and not display) data

even if you don't really want to display your data, it doesn't hurt to create a dummy drawing instruction (could be a polygon with a single constant point).
When appending scalars, just keep track of the index with a counter and set the x or y value to some multiple of the current index. this way, all scalars are seperated nicely (given that the polygon is small enough so scalars don't overlap).

By the way, I usually try to avoid deleting scalars because it invalidates all pointers. I rather do the following: In the template I have a special field which tells if a scalar is active. drawing instructions use this field to toggle its visibility. If I want to 'construct' a new scalar, I just search the subpatch for the first inactive scalar. If there is none, I append a new scalar. When I want to 'destruct' a scalar, I just set the field to zero (false). Basically it works like an object pool. You could also store pointers to recently 'destructed' scalars in a kind of free-list, so that finding available scalars is easier and more efficient. 
Obviously, the pool never shrinks but that little bit of extra memory doesn't really matter.

Christof


> Gesendet: Dienstag, 03. Januar 2017 um 23:13 Uhr
> Von: "Derek Kwan" <derek.x.kwan at gmail.com>
> An: "Christof Ressi" <christof.ressi at gmx.at>, jmmmpais at gmail.com
> Cc: pd-list at lists.iem.at
> Betreff: Re: [PD] Request - Deleting struct instances, progress?
>
> Thanks! Didn't think about simulating motion and deleting the GUI way
> 
> And thanks about [scalar]. Seems like it might be a good way of doing
> multidim arrays.
> 
> > yeah, "vis 1" and "vis 0" is necessary if the window is not visible. Forget to mention that. Thanks!
> >  
> 
> And it needs to be in edit mode, correct? So editmode 1 after vis 1,
> editmode 0 before vis 0. Doesn't seem to work otherwise...
> 
> > regarding the drawing instruction, don't all scalars have the x y coordinates, even if they're not defined in the template? in that case, the scalars without a drawing should be automatically at the coordinates 0 0 - which can be dangerous in case you use your scalars just to store (and not display) data, because all of them will be positioned at 0 0.
> 
> if you're not using them to display, there's no drawing commands so it
> wouldn't do anything anyways. If there is a draw command, then it looks
> like you can't specify any particular element since they're all being
> drawn on 0 0 and deleting at 0 0 deletes the head of the list since it's
> at the top. So not particularly dangerous,... but not particularly
> directable either =)
> 
> Derek
> 
> 
> -- 
> Derek Kwan
> www.derekxkwan.com
>



More information about the Pd-list mailing list