aboutsummaryrefslogtreecommitdiff
path: root/pmpd3d_various.c
diff options
context:
space:
mode:
authorCyrille Henry <nusmuk@users.sourceforge.net>2014-02-18 10:59:19 +0000
committerCyrille Henry <nusmuk@users.sourceforge.net>2014-02-18 10:59:19 +0000
commita279f0b055123b98c0f216d57a895a6dbe74d5c7 (patch)
treec1dde72421103c979d2122aef899f7798cb08781 /pmpd3d_various.c
parent63ead5d63bb2322c5184cfd2f2fd13801d9ae5f6 (diff)
adding optional float for message set symbol symbol and force symbol symbol
svn path=/trunk/externals/pmpd/; revision=17266
Diffstat (limited to 'pmpd3d_various.c')
-rw-r--r--pmpd3d_various.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/pmpd3d_various.c b/pmpd3d_various.c
index 13912ea..f4d420e 100644
--- a/pmpd3d_various.c
+++ b/pmpd3d_various.c
@@ -44,6 +44,7 @@ void pmpd3d_force(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
t_garray *a;
int npoints, n;
t_word *vec;
+ t_float K;
if ( (argc == 4) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) && ( argv[3].a_type == A_FLOAT ) )
{
@@ -65,8 +66,10 @@ void pmpd3d_force(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
- else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ 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))
@@ -79,11 +82,11 @@ void pmpd3d_force(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
{
if (n >= npoints-3) break;
- x->mass[i].forceX += vec[n].w_float;
+ x->mass[i].forceX += K*vec[n].w_float;
n++;
- x->mass[i].forceY += vec[n].w_float;
+ x->mass[i].forceY += K*vec[n].w_float;
n++;
- x->mass[i].forceZ += vec[n].w_float;
+ x->mass[i].forceZ += K*vec[n].w_float;
n++;
}
}
@@ -98,6 +101,7 @@ void pmpd3d_forceX(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
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 ) )
{
@@ -115,8 +119,10 @@ void pmpd3d_forceX(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
- else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ 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))
@@ -128,7 +134,7 @@ void pmpd3d_forceX(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
{
- x->mass[i].forceX += vec[n].w_float;
+ x->mass[i].forceX += K*vec[n].w_float;
n++;
if (n >= npoints) break;
}
@@ -144,6 +150,7 @@ void pmpd3d_forceY(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
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 ) )
{
@@ -161,8 +168,10 @@ void pmpd3d_forceY(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
- else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ 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))
@@ -174,7 +183,7 @@ void pmpd3d_forceY(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
{
- x->mass[i].forceY += vec[n].w_float;
+ x->mass[i].forceY += K*vec[n].w_float;
n++;
if (n >= npoints) break;
}
@@ -190,6 +199,7 @@ void pmpd3d_forceZ(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
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 ) )
{
@@ -207,8 +217,10 @@ void pmpd3d_forceZ(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
- else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ 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))
@@ -220,7 +232,7 @@ void pmpd3d_forceZ(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
{
- x->mass[i].forceZ += vec[n].w_float;
+ x->mass[i].forceZ += K*vec[n].w_float;
n++;
if (n >= npoints) break;
}