aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Henry <nusmuk@users.sourceforge.net>2014-05-25 16:07:19 +0000
committerCyrille Henry <nusmuk@users.sourceforge.net>2014-05-25 16:07:19 +0000
commit1746b067d0e786b3d59d0e11ec59a43eb6cbaf79 (patch)
tree96a64c5ab0baeafeb9bc0e53a48d1fecd411da8e
parent6395184c7d0180c4defbe3f8efae8ee0e67b57da (diff)
add massNumber and linkNumber messages
svn path=/trunk/externals/pmpd/; revision=17316
-rw-r--r--pmpd.c2
-rw-r--r--pmpd2d.c2
-rw-r--r--pmpd2d_stat.c68
-rw-r--r--pmpd3d.c2
-rw-r--r--pmpd3d_stat.c70
-rw-r--r--pmpd_stat.c70
6 files changed, 168 insertions, 46 deletions
diff --git a/pmpd.c b/pmpd.c
index 2d3e013..459dec4 100644
--- a/pmpd.c
+++ b/pmpd.c
@@ -206,6 +206,8 @@ void pmpd_setup(void)
class_addmethod(pmpd_class, (t_method)pmpd_massInfo, gensym("massInfo"), A_GIMME, 0);
class_addmethod(pmpd_class, (t_method)pmpd_linkInfo, gensym("linkInfo"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_massNumber, gensym("massNumber"), A_GIMME, 0);
+ class_addmethod(pmpd_class, (t_method)pmpd_linkNumber, gensym("linkNumber"), A_GIMME, 0);
/*
pmpd_various
diff --git a/pmpd2d.c b/pmpd2d.c
index 013c29b..eb0bdd9 100644
--- a/pmpd2d.c
+++ b/pmpd2d.c
@@ -271,6 +271,8 @@ void pmpd2d_setup(void)
class_addmethod(pmpd2d_class, (t_method)pmpd2d_massInfo, gensym("massInfo"), A_GIMME, 0);
class_addmethod(pmpd2d_class, (t_method)pmpd2d_linkInfo, gensym("linkInfo"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_massNumber, gensym("massNumber"), A_GIMME, 0);
+ class_addmethod(pmpd2d_class, (t_method)pmpd2d_linkNumber, gensym("linkNumber"), A_GIMME, 0);
/*
pmpd2d_interactor
diff --git a/pmpd2d_stat.c b/pmpd2d_stat.c
index 260b14d..86dfff0 100644
--- a/pmpd2d_stat.c
+++ b/pmpd2d_stat.c
@@ -892,7 +892,7 @@ void pmpd2d_linkLengthSpeedStd(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
void pmpd2d_massInfo(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
{
t_atom info[11];
- int i, j;
+ int i;
if (argc==0)
{
@@ -911,15 +911,12 @@ void pmpd2d_massInfo(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
SETFLOAT(&(info[10]), x->mass[i].forceY);
outlet_anything(x->main_outlet, gensym("massInfo"), 11, info);
}
- SETFLOAT(&(info[0]), x->nb_mass);
- outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
{
- j=0;
for(i=0; i < x->nb_mass; i++)
{
- if (atom_getsymbolarg(0,argc,argv) == x->mass[j].Id)
+ if (atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
{
SETFLOAT(&(info[0]), i);
SETSYMBOL(&(info[1]), x->mass[i].Id);
@@ -933,11 +930,8 @@ void pmpd2d_massInfo(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
SETFLOAT(&(info[9]), x->mass[i].forceX);
SETFLOAT(&(info[10]), x->mass[i].forceY);
outlet_anything(x->main_outlet, gensym("massInfo"), 11, info);
- j++;
}
}
- SETFLOAT(&(info[0]), j);
- outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_FLOAT))
{
@@ -963,7 +957,7 @@ void pmpd2d_massInfo(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
void pmpd2d_linkInfo(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
{
t_atom info[14];
- int i, j, k;
+ int i, k;
if (argc==0)
{
@@ -1011,10 +1005,9 @@ void pmpd2d_linkInfo(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
}
else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
{
- j=0;
for(i=0; i < x->nb_link; i++)
{
- if (atom_getsymbolarg(0,argc,argv) == x->link[j].Id)
+ if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
{
SETFLOAT(&(info[1]), i);
SETSYMBOL(&(info[2]), x->link[i].Id);
@@ -1053,10 +1046,7 @@ void pmpd2d_linkInfo(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
}
}
- j++;
}
- SETFLOAT(&(info[0]), j);
- outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_FLOAT))
{
@@ -1102,3 +1092,53 @@ void pmpd2d_linkInfo(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+
+void pmpd2d_massNumber(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[1];
+ int i, j;
+
+ if (argc==0)
+ {
+ SETFLOAT(&(info[0]), x->nb_mass);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_mass; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->mass[j].Id)
+ {
+ j++;
+ }
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+}
+
+void pmpd2d_linkNumber(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[1];
+ int i, j ;
+
+ if (argc==0)
+ {
+ SETFLOAT(&(info[0]), x->nb_link);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_link; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->link[j].Id)
+ {
+ j++;
+ }
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+}
diff --git a/pmpd3d.c b/pmpd3d.c
index 38fefb1..82de7dd 100644
--- a/pmpd3d.c
+++ b/pmpd3d.c
@@ -300,6 +300,8 @@ void pmpd3d_setup(void)
class_addmethod(pmpd3d_class, (t_method)pmpd3d_massInfo, gensym("massInfo"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkInfo, gensym("linkInfo"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_massNumber, gensym("massNumber"), A_GIMME, 0);
+ class_addmethod(pmpd3d_class, (t_method)pmpd3d_linkNumber, gensym("linkNumber"), A_GIMME, 0);
/*
pmpd3d_interactor
--
diff --git a/pmpd3d_stat.c b/pmpd3d_stat.c
index 3e03c05..4316835 100644
--- a/pmpd3d_stat.c
+++ b/pmpd3d_stat.c
@@ -1028,7 +1028,7 @@ void pmpd3d_linkLengthSpeedStd(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
void pmpd3d_massInfo(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
t_atom info[14];
- int i, j;
+ int i;
if (argc==0)
{
@@ -1050,15 +1050,12 @@ void pmpd3d_massInfo(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
SETFLOAT(&(info[13]), x->mass[i].forceZ);
outlet_anything(x->main_outlet, gensym("massInfo"), 14, info);
}
- SETFLOAT(&(info[0]), x->nb_mass);
- outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
{
- j=0;
for(i=0; i < x->nb_mass; i++)
{
- if (atom_getsymbolarg(0,argc,argv) == x->mass[j].Id)
+ if (atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
{
SETFLOAT(&(info[0]), i);
SETSYMBOL(&(info[1]), x->mass[i].Id);
@@ -1075,11 +1072,8 @@ void pmpd3d_massInfo(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
SETFLOAT(&(info[12]), x->mass[i].forceY);
SETFLOAT(&(info[13]), x->mass[i].forceZ);
outlet_anything(x->main_outlet, gensym("massInfo"), 14, info);
- j++;
}
}
- SETFLOAT(&(info[0]), j);
- outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_FLOAT))
{
@@ -1108,7 +1102,7 @@ void pmpd3d_massInfo(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
void pmpd3d_linkInfo(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
t_atom info[14];
- int i, j, k;
+ int i, k;
if (argc==0)
{
@@ -1151,15 +1145,12 @@ void pmpd3d_linkInfo(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
}
}
- SETFLOAT(&(info[0]), x->nb_link);
- outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
{
- j=0;
for(i=0; i < x->nb_link; i++)
{
- if (atom_getsymbolarg(0,argc,argv) == x->link[j].Id)
+ if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
{
SETFLOAT(&(info[1]), i);
SETSYMBOL(&(info[2]), x->link[i].Id);
@@ -1198,10 +1189,7 @@ void pmpd3d_linkInfo(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
}
}
- j++;
}
- SETFLOAT(&(info[0]), j);
- outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_FLOAT))
{
@@ -1247,3 +1235,53 @@ void pmpd3d_linkInfo(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+
+void pmpd3d_massNumber(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[1];
+ int i, j;
+
+ if (argc==0)
+ {
+ SETFLOAT(&(info[0]), x->nb_mass);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_mass; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->mass[j].Id)
+ {
+ j++;
+ }
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+}
+
+void pmpd3d_linkNumber(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[1];
+ int i, j ;
+
+ if (argc==0)
+ {
+ SETFLOAT(&(info[0]), x->nb_link);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_link; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->link[j].Id)
+ {
+ j++;
+ }
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+}
diff --git a/pmpd_stat.c b/pmpd_stat.c
index f41a956..222ccb6 100644
--- a/pmpd_stat.c
+++ b/pmpd_stat.c
@@ -683,7 +683,7 @@ void pmpd_linkLengthSpeedStd(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
void pmpd_massInfo(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
{
t_atom info[8];
- int i, j;
+ int i;
if (argc==0)
{
@@ -699,15 +699,12 @@ void pmpd_massInfo(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
SETFLOAT(&(info[7]), x->mass[i].forceX);
outlet_anything(x->main_outlet, gensym("massInfo"), 8, info);
}
- SETFLOAT(&(info[0]), x->nb_mass);
- outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
{
- j=0;
for(i=0; i < x->nb_mass; i++)
{
- if (atom_getsymbolarg(0,argc,argv) == x->mass[j].Id)
+ if (atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
{
SETFLOAT(&(info[0]), i);
SETSYMBOL(&(info[1]), x->mass[i].Id);
@@ -718,11 +715,8 @@ void pmpd_massInfo(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
SETFLOAT(&(info[6]), x->mass[i].speedX);
SETFLOAT(&(info[7]), x->mass[i].forceX);
outlet_anything(x->main_outlet, gensym("massInfo"), 8, info);
- j++;
}
}
- SETFLOAT(&(info[0]), j);
- outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_FLOAT))
{
@@ -745,7 +739,7 @@ void pmpd_massInfo(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
void pmpd_linkInfo(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
{
t_atom info[14];
- int i, j, k;
+ int i, k;
if (argc==0)
{
@@ -778,15 +772,12 @@ void pmpd_linkInfo(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
}
}
- SETFLOAT(&(info[0]), x->nb_link);
- outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
{
- j=0;
for(i=0; i < x->nb_link; i++)
{
- if (atom_getsymbolarg(0,argc,argv) == x->link[j].Id)
+ if (atom_getsymbolarg(0,argc,argv) == x->link[i].Id)
{
SETFLOAT(&(info[1]), i);
SETSYMBOL(&(info[2]), x->link[i].Id);
@@ -815,10 +806,7 @@ void pmpd_linkInfo(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
outlet_anything(x->main_outlet, gensym("linkInfo"), 12, info);
}
}
- j++;
}
- SETFLOAT(&(info[0]), j);
- outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
}
else if ((argc==1) && (argv[0].a_type == A_FLOAT))
{
@@ -854,3 +842,53 @@ void pmpd_linkInfo(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+
+void pmpd_massNumber(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[1];
+ int i, j;
+
+ if (argc==0)
+ {
+ SETFLOAT(&(info[0]), x->nb_mass);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_mass; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->mass[j].Id)
+ {
+ j++;
+ }
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("massNumber"), 1, info);
+ }
+}
+
+void pmpd_linkNumber(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_atom info[1];
+ int i, j ;
+
+ if (argc==0)
+ {
+ SETFLOAT(&(info[0]), x->nb_link);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+ else if ((argc==1) && (argv[0].a_type == A_SYMBOL))
+ {
+ j=0;
+ for(i=0; i < x->nb_link; i++)
+ {
+ if (atom_getsymbolarg(0,argc,argv) == x->link[j].Id)
+ {
+ j++;
+ }
+ }
+ SETFLOAT(&(info[0]), j);
+ outlet_anything(x->main_outlet, gensym("linkNumber"), 1, info);
+ }
+}