From d23606cba1c9094706ce978b72398efa80ac2208 Mon Sep 17 00:00:00 2001 From: Cyrille Henry Date: Wed, 16 Jan 2013 14:57:52 +0000 Subject: remove adaptLength to be replace by setL Id curent % (flaot) svn path=/trunk/externals/pmpd/; revision=16880 --- pmpd3d.c | 1 - pmpd3d_set.c | 22 +++++++++++++++++++--- pmpd3d_various.c | 41 ----------------------------------------- 3 files changed, 19 insertions(+), 45 deletions(-) diff --git a/pmpd3d.c b/pmpd3d.c index 6283ed6..fdeb225 100644 --- a/pmpd3d.c +++ b/pmpd3d.c @@ -686,7 +686,6 @@ void pmpd3d_setup(void) class_addmethod(pmpd3d_class, (t_method)pmpd3d_addPosZ, gensym("addPosZ"), A_GIMME, 0); class_addmethod(pmpd3d_class, (t_method)pmpd3d_grabMass, gensym("grabMass"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(pmpd3d_class, (t_method)pmpd3d_closestMass, gensym("closestMass"), A_GIMME, 0); - class_addmethod(pmpd3d_class, (t_method)pmpd3d_adaptLength, gensym("adaptLength"), A_GIMME, 0); class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesDistances, gensym("massesDistances"), A_GIMME, 0); class_addmethod(pmpd3d_class, (t_method)pmpd3d_enumMasses, gensym("enumMasses"), A_GIMME, 0); diff --git a/pmpd3d_set.c b/pmpd3d_set.c index 43b58a5..d6f5d2e 100644 --- a/pmpd3d_set.c +++ b/pmpd3d_set.c @@ -110,7 +110,7 @@ void pmpd3d_setL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].L = atom_getfloatarg(1, argc, argv); } - if ( ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) + else if ( ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) { for (i=0; i< x->nb_link; i++) { @@ -120,13 +120,13 @@ void pmpd3d_setL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } } - if ( ( argv[0].a_type == A_FLOAT ) && ( argc == 1 ) ) + else if ( ( argv[0].a_type == A_FLOAT ) && ( argc == 1 ) ) { tmp = atom_getfloatarg(0, argc, argv); tmp = max(0, min( x->nb_link-1, tmp)); x->link[tmp].L = x->link[tmp].mass2->posX - x->link[tmp].mass1->posX; } - if ( ( argv[0].a_type == A_SYMBOL ) && ( argc == 1 ) ) + else if ( ( argv[0].a_type == A_SYMBOL ) && ( argc == 1 ) ) { for (i=0; i< x->nb_link; i++) { @@ -136,6 +136,22 @@ void pmpd3d_setL(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } } + else if ( (argc== 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) && ( atom_getsymbolarg(1,argc,argv) == gensym("current") ) ) + { + i = atom_getfloatarg(0, argc, argv); + i = max(0, min( x->nb_link-1, i)); + x->link[i].L = mix(x->link[i].L,x->link[i].distance,atom_getfloatarg(2, argc, argv)); + } + else if ( (argc== 3) && ( argv[0].a_type == A_SYMBOL ) && ( argv[2].a_type == A_FLOAT ) && ( atom_getsymbolarg(1,argc,argv) == gensym("current") ) ) + { + for (i=0; i< x->nb_link; i++) + { + if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id) + { + x->link[i].L = mix(x->link[i].L,x->link[i].distance,atom_getfloatarg(2, argc, argv)); + } + } + } } void pmpd3d_setLKTab(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) diff --git a/pmpd3d_various.c b/pmpd3d_various.c index 0c94161..060f2d3 100644 --- a/pmpd3d_various.c +++ b/pmpd3d_various.c @@ -1,22 +1,3 @@ -t_float tabread(t_pmpd3d *x, t_int n, t_symbol *array) -{ - t_garray *a; - int npoints; - t_word *vec; - - if (!(a = (t_garray *)pd_findbyclass(array, garray_class))) - pd_error(x, "%s: no such array", array->s_name); - else if (!garray_getfloatwords(a, &npoints, &vec)) - pd_error(x, "%s: bad template for tabLink", array->s_name); - else - { - if (n >= npoints - 1) - return (0); - return ( vec[n].w_float); - } - return(0); -} - void pmpd3d_infosL(t_pmpd3d *x) { t_int i; @@ -496,28 +477,6 @@ void pmpd3d_closestMass(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } -void pmpd3d_adaptLength(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) -{ - t_int i; - - if ( ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) ) - { - i = atom_getfloatarg(0, argc, argv); - i = max(0, min( x->nb_link-1, i)); - x->link[i].L = mix(x->link[i].L,x->link[i].distance,atom_getfloatarg(1, argc, argv)); - } - if ( ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) ) - { - for (i=0; i< x->nb_link; i++) - { - if ( atom_getsymbolarg(0,argc,argv) == x->link[i].Id) - { - x->link[i].L = mix(x->link[i].L,x->link[i].distance,atom_getfloatarg(1, argc, argv)); - } - } - } -} - void pmpd3d_massesDistances_f_f(t_pmpd3d *x, t_int i, t_int j) { t_float dist, tmp; -- cgit v1.2.1