aboutsummaryrefslogtreecommitdiff
path: root/pmpd3d_set.c
diff options
context:
space:
mode:
Diffstat (limited to 'pmpd3d_set.c')
-rw-r--r--pmpd3d_set.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/pmpd3d_set.c b/pmpd3d_set.c
index 296c94b..b84010f 100644
--- a/pmpd3d_set.c
+++ b/pmpd3d_set.c
@@ -516,6 +516,70 @@ void pmpd3d_setL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
+void pmpd3d_addL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int tmp, i, offset;
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+ t_float K;
+
+ if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
+ { // set a link to a specific size
+ tmp = atom_getfloatarg(0, argc, argv);
+ tmp = max(0, min( x->nb_link-1, tmp));
+ x->link[tmp].L += atom_getfloatarg(1, argc, argv);
+ }
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
+ { // set a class of link to a specific size
+ for (i=0; i< x->nb_link; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
+ {
+ x->link[i].L += atom_getfloatarg(1, argc, argv);
+ }
+ }
+ }
+ else if ( (argc == 1) && ( argv[0].a_type == A_FLOAT ) )
+ { // set a link to it's curent size
+ tmp = atom_getfloatarg(0, argc, argv);
+ tmp = max(0, min( x->nb_link-1, tmp));
+ x->link[tmp].L += x->link[tmp].distance;
+ }
+ else if ( (argc == 1) && ( argv[0].a_type == A_SYMBOL ) )
+ { // set a class of link to there curent size
+ for (i=0; i< x->nb_link; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
+ {
+ x->link[i].L += x->link[i].distance;
+ }
+ }
+ }
+ else if ( (argc >= 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ {
+ K=1;
+ if ((argc >= 3) && ( argv[2].a_type == A_FLOAT )) K=atom_getfloatarg(2, argc, argv);
+ if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class)))
+ pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name);
+ else if (!garray_getfloatwords(a, &npoints, &vec))
+ pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
+ else
+ {
+ n=0;
+ for (i=0; i < x->nb_link; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
+ {
+ x->link[i].L += K*vec[n].w_float;
+ n++;
+ if (n >= npoints) break;
+ }
+ }
+ }
+ }
+}
+
void pmpd3d_setLCurrent(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
int tmp, i;