From 42ace7dfbc5ed1e9c23ad1c8753192f86f841a70 Mon Sep 17 00:00:00 2001 From: Cyrille Henry Date: Thu, 11 Aug 2011 09:13:11 +0000 Subject: bugfix tLink MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --Cette ligne, et les suivantes ci-dessous, seront ignorées-- M pmpd/pmpd3d-help.pd M pmpd/pmpd2d.c M pmpd/pmpd3d.c svn path=/trunk/externals/pmpd/; revision=15207 --- pmpd2d.c | 6 +++--- pmpd3d-help.pd | 13 +++++++------ pmpd3d.c | 36 +++++++++++++++++++++--------------- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/pmpd2d.c b/pmpd2d.c index d3ea690..221d5b2 100644 --- a/pmpd2d.c +++ b/pmpd2d.c @@ -368,11 +368,11 @@ void pmpd2d_tLink(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv) vecteurX /= vecteur; vecteurY /= vecteur; t_float Pow = 1; - if (argc > 7) Pow = atom_getfloatarg(5, argc, argv); + if (argc > 7) Pow = atom_getfloatarg(7, argc, argv); t_float Lmin = 0; - if (argc > 8) Lmin = atom_getfloatarg(6, argc, argv); + if (argc > 8) Lmin = atom_getfloatarg(8, argc, argv); t_float Lmax = 1000000; - if (argc > 9) Lmax = atom_getfloatarg(7, argc, argv); + if (argc > 9) Lmax = atom_getfloatarg(9, argc, argv); if ( ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) { diff --git a/pmpd3d-help.pd b/pmpd3d-help.pd index 4ce2282..b1f6a2b 100644 --- a/pmpd3d-help.pd +++ b/pmpd3d-help.pd @@ -403,16 +403,11 @@ the model. Messages create links and masses or destroy them.; #X text 527 198 \$2 : creation No/Id of mass1; #X text 527 216 \$3 : creation No/Id of mass2; #X text 527 251 \$5 : damping; -#X text 790 152 Add tangential link(s); -#X text 524 289 (\$8) : Power of the rigidity distance; -#X text 524 308 (\$9) : minimum lenght of link; -#X text 524 325 (\$10) : maximum lenght of link; +#X text 812 154 Add tangential link(s); #X text 506 102 In 2D (and 3D) there are two specials links : oriented links. They works as general links excepts their calculation is made following a vector.; -#X text 526 270 \$6 \, \$7 : tangential vector (x \, y); #X text 504 75 Oriented links :; -#X msg 507 153 tLink \$1 \$2 \$3 \$4 \$5 \$6 \$7 (\$8 \$9 \$10); #X msg 502 406 tabLink \$1 \$2 \$3 \$4 \$5 \$6 \$7; #X text 532 453 \$1 : Id (symbol); #X text 532 453 \$1 : Id (symbol); @@ -428,6 +423,12 @@ following a vector.; #X text 497 351 Table links :; #X msg 32 167 mass \$1 \$2 \$3 \$4 \$5 \$6; #X text 58 247 \$4 \, \$5 \, \$6 : initial position; +#X msg 507 153 tLink \$1 \$2 \$3 \$4 \$5 \$6 \$7 \$8 (\$9 \$10 \$11) +; +#X text 526 270 \$6 \, \$7 \, \$8 : tangential vector (x \, y); +#X text 524 289 (\$9) : Power of the rigidity distance; +#X text 524 308 (\$10) : minimum lenght of link; +#X text 524 325 (\$11) : maximum lenght of link; #X connect 27 0 29 0; #X restore 12 457 pd creation____________; #N canvas 541 24 1078 872 dynamic 0; diff --git a/pmpd3d.c b/pmpd3d.c index 6a9b326..c6142fc 100644 --- a/pmpd3d.c +++ b/pmpd3d.c @@ -394,21 +394,24 @@ void pmpd3d_tLink(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) t_float D = atom_getfloatarg(4, argc, argv); t_float vecteurX = atom_getfloatarg(5, argc, argv); t_float vecteurY = atom_getfloatarg(6, argc, argv); - t_float vecteur = sqrt( sqr(vecteurX) + sqr(vecteurY) ); + t_float vecteurZ = atom_getfloatarg(7, argc, argv); + t_float vecteur = sqrt( sqr(vecteurX) + sqr(vecteurY) + sqr(vecteurZ) ); vecteurX /= vecteur; vecteurY /= vecteur; + vecteurZ /= vecteur; t_float Pow = 1; - if (argc > 7) Pow = atom_getfloatarg(5, argc, argv); + if (argc > 8) Pow = atom_getfloatarg(8, argc, argv); t_float Lmin = 0; - if (argc > 8) Lmin = atom_getfloatarg(6, argc, argv); + if (argc > 9) Lmin = atom_getfloatarg(9, argc, argv); t_float Lmax = 1000000; - if (argc > 9) Lmax = atom_getfloatarg(7, argc, argv); + if (argc > 10) Lmax = atom_getfloatarg(10, argc, argv); if ( ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) ) { pmpd3d_create_link(x, Id, mass1, mass2, K, D, Pow, Lmin, Lmax, 1); x->link[x->nb_link-1].VX = vecteurX; x->link[x->nb_link-1].VY = vecteurY; + x->link[x->nb_link-1].VZ = vecteurZ; } else if ( ( argv[1].a_type == A_SYMBOL ) && ( argv[2].a_type == A_FLOAT ) ) @@ -419,7 +422,8 @@ void pmpd3d_tLink(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { pmpd3d_create_link(x, Id, i, mass2, K, D, Pow, Lmin, Lmax, 1); x->link[x->nb_link-1].VX = vecteurX; - x->link[x->nb_link-1].VY = vecteurY; + x->link[x->nb_link-1].VY = vecteurY; + x->link[x->nb_link-1].VZ = vecteurZ; } } } @@ -432,8 +436,9 @@ void pmpd3d_tLink(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { pmpd3d_create_link(x, Id, mass1, i, K, D, Pow, Lmin, Lmax, 1); x->link[x->nb_link-1].VX = vecteurX; - x->link[x->nb_link-1].VY = vecteurY; - } + x->link[x->nb_link-1].VY = vecteurY; + x->link[x->nb_link-1].VZ = vecteurZ; + } } } else @@ -445,14 +450,15 @@ void pmpd3d_tLink(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) { if ( (atom_getsymbolarg(1,argc,argv) == x->mass[i].Id)&(atom_getsymbolarg(2,argc,argv) == x->mass[j].Id)) { - if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) )) - // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances - { - pmpd3d_create_link(x, Id, i, j, K, D, Pow, Lmin, Lmax, 1); - x->link[x->nb_link-1].VX = vecteurX; - x->link[x->nb_link-1].VY = vecteurY; - } - } + if (!( (x->mass[i].Id == x->mass[j].Id) && (i>j) )) + // si lien entre 2 serie de masses identique entres elle, alors on ne creer qu'un lien sur 2, pour evider les redondances + { + pmpd3d_create_link(x, Id, i, j, K, D, Pow, Lmin, Lmax, 1); + x->link[x->nb_link-1].VX = vecteurX; + x->link[x->nb_link-1].VY = vecteurY; + x->link[x->nb_link-1].VZ = vecteurZ; + } + } } } } -- cgit v1.2.1