aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pmpd2d-help.pd7
-rw-r--r--pmpd2d_core.c13
-rw-r--r--pmpd2d_set.c84
-rw-r--r--pmpd_test.c4
4 files changed, 52 insertions, 56 deletions
diff --git a/pmpd2d-help.pd b/pmpd2d-help.pd
index 28450e9..c8c5bb9 100644
--- a/pmpd2d-help.pd
+++ b/pmpd2d-help.pd
@@ -1,4 +1,4 @@
-#N canvas 261 239 572 750 10;
+#N canvas 257 249 572 750 10;
#X declare -lib Gem;
#X obj 4 309 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
0;
@@ -828,7 +828,7 @@ a table;
#X text 794 523 \$3 : y position;
#X text 794 537 \$4 : none or Id;
#X restore 12 447 pd masses_attributes___;
-#N canvas 252 263 751 772 tests 0;
+#N canvas 120 246 751 772 tests 0;
#X obj 5 3 cnv 15 700 15 empty empty empty 20 12 0 14 -233017 -66577
0;
#X text 17 2 TESTS Messages;
@@ -866,7 +866,6 @@ tests:;
on whether it passes all tests or not;
#X text 346 508 Put in a table 0 or 1 depending on whether links pass
all tests;
-#X msg 15 205 testMassN massnumber filterId filter_parametter ...;
#X text 346 556 output : testLinkN \, link_id \, link_number \, 0 or
1 (test result);
#X text 346 207 output : testMassN \, mass_id \, mass_number \, 0 or
@@ -891,6 +890,8 @@ forceXSup \$1 / forceXInf \$1 / forceYSup \$1 / forceYInf \$1 / lengthSup
#X text 347 247 output : testMassN \, testId \, float;
#X text 347 597 output : testMassN \, testId \, float;
#X msg 15 595 testLinkN testId filterId filter_parametter ...;
+#X msg 15 205 testMassN testId massnumber filterId filter_parametter
+...;
#X restore 12 486 pd tests ______________;
#N canvas 1081 499 709 556 interactors 0;
#X obj 30 11 cnv 15 600 15 empty empty empty 20 12 0 14 -233017 -66577
diff --git a/pmpd2d_core.c b/pmpd2d_core.c
index 78c7629..22c8f03 100644
--- a/pmpd2d_core.c
+++ b/pmpd2d_core.c
@@ -69,14 +69,11 @@ void *pmpd2d_new()
}
void pmpd2d_bang(t_pmpd2d *x)
-{
-// this part is doing all the PM
+{ // this part is doing all the PM
t_float F, L, Lx,Ly, Fx, Fy, tmp, tmpX, tmpY,speed;
t_int i;
- // post("bang");
- for (i=0; i<x->nb_mass; i++)
- // compute new masses position
+ for (i=0; i<x->nb_mass; i++) // compute new masses position
if (x->mass[i].mobile > 0) // only if mobile
{
// amplify force that opose to movement
@@ -125,9 +122,8 @@ void pmpd2d_bang(t_pmpd2d *x)
}
}
- for (i=0; i<x->nb_link; i++)
- { // compute link forces
- if (x->link[i].active == 1)
+ for (i=0; i<x->nb_link; i++) // compute link forces
+ if (x->link[i].active > 0)
{
Lx = x->link[i].mass1->posX - x->link[i].mass2->posX;
Ly = x->link[i].mass1->posY - x->link[i].mass2->posY;
@@ -165,7 +161,6 @@ void pmpd2d_bang(t_pmpd2d *x)
}
x->link[i].distance=L;
}
- }
}
void pmpd2d_mass(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
diff --git a/pmpd2d_set.c b/pmpd2d_set.c
index eecf730..a74a7ca 100644
--- a/pmpd2d_set.c
+++ b/pmpd2d_set.c
@@ -16,11 +16,11 @@ void pmpd2d_setK(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_link-1, tmp));
+ tmp = max(0, min( x->nb_link, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_link-1, end));
+ end = max(tmp, min( x->nb_link, end));
valeur = atom_getfloatarg(2, argc, argv);
- for (i=tmp; i<=end; i++)
+ for (i=tmp; i<end; i++)
x->link[i].K = valeur;
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
@@ -93,11 +93,11 @@ void pmpd2d_setD(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_link-1, tmp));
+ tmp = max(0, min( x->nb_link, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_link-1, end));
+ end = max(tmp, min( x->nb_link, end));
valeur = atom_getfloatarg(2, argc, argv);
- for (i=tmp; i<=end; i++)
+ for (i=tmp; i<end; i++)
x->link[i].D = valeur;
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
@@ -171,11 +171,11 @@ void pmpd2d_setPow(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_link-1, tmp));
+ tmp = max(0, min( x->nb_link, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_link-1, end));
+ end = max(tmp, min( x->nb_link, end));
valeur = atom_getfloatarg(2, argc, argv);
- for (i=tmp; i<=end; i++)
+ for (i=tmp; i<end; i++)
x->link[i].Pow = valeur;
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
@@ -248,11 +248,11 @@ void pmpd2d_setDEnv(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_mass-1, tmp));
+ tmp = max(0, min( x->nb_mass, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_mass-1, end));
+ end = max(tmp, min( x->nb_mass, end));
valeur = atom_getfloatarg(2, argc, argv);
- for (i=tmp; i<=end; i++)
+ for (i=tmp; i<end; i++)
x->mass[i].D2 = valeur;
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
@@ -332,11 +332,11 @@ void pmpd2d_setDEnvOffset(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_mass-1, tmp));
+ tmp = max(0, min( x->nb_mass, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_mass-1, end));
+ end = max(tmp, min( x->nb_mass, end));
valeur = atom_getfloatarg(2, argc, argv);
- for (i=tmp; i<=end; i++)
+ for (i=tmp; i<end; i++)
x->mass[i].D2offset = valeur;
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
@@ -416,11 +416,11 @@ void pmpd2d_setL(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_link-1, tmp));
+ tmp = max(0, min( x->nb_link, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_link-1, end));
+ end = max(tmp, min( x->nb_link, end));
valeur = atom_getfloatarg(2, argc, argv);
- for (i=tmp; i<=end; i++)
+ for (i=tmp; i<end; i++)
x->link[i].L = valeur;
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
@@ -509,11 +509,11 @@ void pmpd2d_addL(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_link-1, tmp));
+ tmp = max(0, min( x->nb_link, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_link-1, end));
+ end = max(tmp, min( x->nb_link, end));
valeur = atom_getfloatarg(2, argc, argv);
- for (i=tmp; i<=end; i++)
+ for (i=tmp; i<end; i++)
x->link[i].L += valeur;
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
@@ -649,12 +649,12 @@ void pmpd2d_setLKTab(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_link-1, tmp));
+ tmp = max(0, min( x->nb_link, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_link-1, end));
+ end = max(tmp, min( x->nb_link, end));
valeur = atom_getfloatarg(2, argc, argv);
if (valeur <= 0) valeur = 1;
- for (i=tmp; i<=end; i++)
+ for (i=tmp; i<end; i++)
x->link[i].K_L = valeur;
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
@@ -685,12 +685,12 @@ void pmpd2d_setLDTab(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_link-1, tmp));
+ tmp = max(0, min( x->nb_link, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_link-1, end));
+ end = max(tmp, min( x->nb_link, end));
valeur = atom_getfloatarg(2, argc, argv);
if (valeur <= 0) valeur = 1;
- for (i=tmp; i<=end; i++)
+ for (i=tmp; i<end; i++)
x->link[i].D_L = valeur;
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
@@ -718,10 +718,10 @@ void pmpd2d_setLinkId(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_SYMBOL ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_link-1, tmp));
+ tmp = max(0, min( x->nb_link, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_link-1, end));
- for (i=tmp; i<=end; i++)
+ end = max(tmp, min( x->nb_link, end));
+ for (i=tmp; i<end; i++)
x->link[i].Id = atom_getsymbolarg(1, argc, argv);
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
@@ -749,10 +749,10 @@ void pmpd2d_setMassId(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_SYMBOL ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_mass-1, tmp));
+ tmp = max(0, min( x->nb_mass, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_mass-1, end));
- for (i=tmp; i<=end; i++)
+ end = max(tmp, min( x->nb_mass, end));
+ for (i=tmp; i<end; i++)
x->mass[i].Id = atom_getsymbolarg(1, argc, argv);
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
@@ -811,10 +811,10 @@ void pmpd2d_setMobile(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_mass-1, tmp));
+ tmp = max(0, min( x->nb_mass, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_mass-1, end));
- for (i=tmp; i<=end; i++)
+ end = max(tmp, min( x->nb_mass, end));
+ for (i=tmp; i<end; i++)
x->mass[i].mobile = 0;
}
else if ( (argc == 1) && (argv[0].a_type == A_SYMBOL ) )
@@ -1026,10 +1026,10 @@ void pmpd2d_setInactive(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_link-1, tmp));
+ tmp = max(0, min( x->nb_link, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_link-1, end));
- for (i=tmp; i<=end; i++)
+ end = max(tmp, min( x->nb_link, end));
+ for (i=tmp; i<end; i++)
x->link[i].active = 0;
}
else if ( (argc == 1) && ( argv[0].a_type == A_SYMBOL ) )
@@ -1311,11 +1311,11 @@ void pmpd2d_overdamp(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
else if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
- tmp = max(0, min( x->nb_mass-1, tmp));
+ tmp = max(0, min( x->nb_mass, tmp));
end = atom_getfloatarg(1, argc, argv);
- end = max(tmp, min( x->nb_mass-1, end));
+ end = max(tmp, min( x->nb_mass, end));
valeur = atom_getfloatarg(2, argc, argv);
- for (i=tmp; i<=end; i++)
+ for (i=tmp; i<end; i++)
x->mass[i].overdamp = valeur;
}
else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
diff --git a/pmpd_test.c b/pmpd_test.c
index 1fb50a3..eb753bc 100644
--- a/pmpd_test.c
+++ b/pmpd_test.c
@@ -464,7 +464,7 @@ void pmpd_testLinkNumber(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
nb=0;
for (i=0; i < x->nb_link; i++)
{
- tmp=test_link(i,x,argc,argv);
+ tmp=test_1d_link(i,x,argc,argv);
if (tmp == -1)
{
break;
@@ -488,7 +488,7 @@ void pmpd_testMassNumber(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
nb = 0;
for (i=0; i < x->nb_mass; i++)
{
- tmp=test_mass(i,x,argc,argv);
+ tmp=test_1d_mass(i,x,argc,argv);
if (tmp == -1)
{
break;