Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-09 10:04:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-09 10:04:17 +0400
commitdfdfa3d51b48a6bffd90779a1778dcf0e9a751e4 (patch)
treef51a4ea8668ee41182a5d60942e96804004d3c7a /source/blender/blenkernel/intern/implicit.c
parent42517463821d0d0bbebe7c45bf40c06f4d8e9261 (diff)
code cleanup: replace macros VECCOPY, VECADD, VECSUB, INPR - with BLI_math funcs.
added copy float/double funcs: copy_v3fl_v3db(), copy_v3db_v3fl(). 2d & 4d too.
Diffstat (limited to 'source/blender/blenkernel/intern/implicit.c')
-rw-r--r--source/blender/blenkernel/intern/implicit.c123
1 files changed, 61 insertions, 62 deletions
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index cb2c077d14d..a271513afc0 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -210,7 +210,7 @@ DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned
unsigned int i = 0;
for(i = 0; i < verts; i++)
{
- VECCOPY(fLongVector[i], vector);
+ copy_v3_v3(fLongVector[i], vector);
}
}
/* zero long vector with float[3] */
@@ -248,9 +248,8 @@ DO_INLINE float dot_lfvector(float (*fLongVectorA)[3], float (*fLongVectorB)[3],
// different results each time you run it!
// schedule(guided, 2)
//#pragma omp parallel for reduction(+: temp) if(verts > CLOTH_OPENMP_LIMIT)
- for(i = 0; i < (long)verts; i++)
- {
- temp += INPR(fLongVectorA[i], fLongVectorB[i]);
+ for(i = 0; i < (long)verts; i++) {
+ temp += dot_v3v3(fLongVectorA[i], fLongVectorB[i]);
}
return temp;
}
@@ -303,7 +302,7 @@ DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
for(i = 0; i < verts; i++)
{
- VECSUB(to[i], fLongVectorA[i], fLongVectorB[i]);
+ sub_v3_v3v3(to[i], fLongVectorA[i], fLongVectorB[i]);
}
}
@@ -324,9 +323,9 @@ static void print_fmatrix(float m3[3][3])
DO_INLINE void cp_fmatrix(float to[3][3], float from[3][3])
{
// memcpy(to, from, sizeof (float) * 9);
- VECCOPY(to[0], from[0]);
- VECCOPY(to[1], from[1]);
- VECCOPY(to[2], from[2]);
+ copy_v3_v3(to[0], from[0]);
+ copy_v3_v3(to[1], from[1]);
+ copy_v3_v3(to[2], from[2]);
}
/* copy 3x3 matrix */
@@ -397,11 +396,11 @@ DO_INLINE void mul_fvector_fmatrix(float *to, float *from, float matrix[3][3])
/* 3x3 matrix multiplied by a vector */
/* STATUS: verified */
-DO_INLINE void mul_fmatrix_fvector(float *to, float matrix[3][3], float *from)
+DO_INLINE void mul_fmatrix_fvector(float *to, float matrix[3][3], float from[3])
{
- to[0] = INPR(matrix[0],from);
- to[1] = INPR(matrix[1],from);
- to[2] = INPR(matrix[2],from);
+ to[0] = dot_v3v3(matrix[0],from);
+ to[1] = dot_v3v3(matrix[1],from);
+ to[2] = dot_v3v3(matrix[2],from);
}
/* 3x3 matrix multiplied by a 3x3 matrix */
/* STATUS: verified */
@@ -449,9 +448,9 @@ DO_INLINE void subadd_fmatrixS_fmatrixS(float to[3][3], float matrixA[3][3], flo
/* A = B - C (3x3 matrix subtraction with 3x3 matrix) */
DO_INLINE void sub_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float matrixB[3][3])
{
- VECSUB(to[0], matrixA[0], matrixB[0]);
- VECSUB(to[1], matrixA[1], matrixB[1]);
- VECSUB(to[2], matrixA[2], matrixB[2]);
+ sub_v3_v3v3(to[0], matrixA[0], matrixB[0]);
+ sub_v3_v3v3(to[1], matrixA[1], matrixB[1]);
+ sub_v3_v3v3(to[2], matrixA[2], matrixB[2]);
}
/* A += B - C (3x3 matrix add-subtraction with 3x3 matrix) */
DO_INLINE void addsub_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float matrixB[3][3])
@@ -495,16 +494,16 @@ DO_INLINE void mulsub_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float
/* STATUS: verified */
DO_INLINE void muladd_fmatrix_fvector(float to[3], float matrix[3][3], float from[3])
{
- to[0] += INPR(matrix[0],from);
- to[1] += INPR(matrix[1],from);
- to[2] += INPR(matrix[2],from);
+ to[0] += dot_v3v3(matrix[0], from);
+ to[1] += dot_v3v3(matrix[1], from);
+ to[2] += dot_v3v3(matrix[2], from);
}
/* 3x3 matrix multiplied+sub'ed by a vector */
DO_INLINE void mulsub_fmatrix_fvector(float to[3], float matrix[3][3], float from[3])
{
- to[0] -= INPR(matrix[0],from);
- to[1] -= INPR(matrix[1],from);
- to[2] -= INPR(matrix[2],from);
+ to[0] -= dot_v3v3(matrix[0], from);
+ to[1] -= dot_v3v3(matrix[1], from);
+ to[2] -= dot_v3v3(matrix[2], from);
}
/////////////////////////////////////////////////////////////////
@@ -813,7 +812,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
for(i = 0; i < cloth->numverts; i++)
{
- VECCOPY(id->X[i], verts[i].x);
+ copy_v3_v3(id->X[i], verts[i].x);
}
return 1;
@@ -1218,7 +1217,7 @@ DO_INLINE void dfdx_damp(float to[3][3], float dir[3],float length,const float
// return (I-outerprod(dir,dir)) * (-damping * -(dot(dir,vel)/Max(length,rest)));
mul_fvectorT_fvector(to, dir, dir);
sub_fmatrix_fmatrix(to, I, to);
- mul_fmatrix_S(to, (-damping * -(INPR(dir,vel)/MAX2(length,rest))));
+ mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir,vel)/MAX2(length,rest))));
}
@@ -1244,14 +1243,14 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
int no_compress = clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS;
- VECCOPY(s->f, nullf);
+ copy_v3_v3(s->f, nullf);
cp_fmatrix(s->dfdx, nulldfdx);
cp_fmatrix(s->dfdv, nulldfdx);
// calculate elonglation
- VECSUB(extent, X[s->kl], X[s->ij]);
- VECSUB(vel, V[s->kl], V[s->ij]);
- dot = INPR(extent, extent);
+ sub_v3_v3v3(extent, X[s->kl], X[s->ij]);
+ sub_v3_v3v3(vel, V[s->kl], V[s->ij]);
+ dot = dot_v3v3(extent, extent);
length = sqrt(dot);
s->flags &= ~CLOTH_SPRING_FLAG_NEEDED;
@@ -1296,7 +1295,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
// Ascher & Boxman, p.21: Damping only during elonglation
// something wrong with it...
- mul_fvector_S(damping_force, dir, clmd->sim_parms->Cdis * INPR(vel,dir));
+ mul_fvector_S(damping_force, dir, clmd->sim_parms->Cdis * dot_v3v3(vel, dir));
VECADD(s->f, s->f, damping_force);
/* VERIFIED */
@@ -1313,14 +1312,14 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
// current_position = xold + t * (newposition - xold)
- VECSUB(tvect, verts[s->ij].xconst, verts[s->ij].xold);
+ sub_v3_v3v3(tvect, verts[s->ij].xconst, verts[s->ij].xold);
mul_fvector_S(tvect, tvect, time);
VECADD(tvect, tvect, verts[s->ij].xold);
- VECSUB(extent, X[s->ij], tvect);
+ sub_v3_v3v3(extent, X[s->ij], tvect);
// SEE MSG BELOW (these are UNUSED)
- // dot = INPR(extent, extent);
+ // dot = dot_v3v3(extent, extent);
// length = sqrt(dot);
k = clmd->sim_parms->goalspring;
@@ -1331,7 +1330,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
VECADDS(s->f, s->f, extent, -k);
- mul_fvector_S(damping_force, dir, clmd->sim_parms->goalfrict * 0.01 * INPR(vel,dir));
+ mul_fvector_S(damping_force, dir, clmd->sim_parms->goalfrict * 0.01 * dot_v3v3(vel, dir));
VECADD(s->f, s->f, damping_force);
// HERE IS THE PROBLEM!!!!
@@ -1371,7 +1370,7 @@ DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSp
VECADD(lF[s->ij], lF[s->ij], s->f);
if(!(s->type & CLOTH_SPRING_TYPE_GOAL))
- VECSUB(lF[s->kl], lF[s->kl], s->f);
+ sub_v3_v3v3(lF[s->kl], lF[s->kl], s->f);
sub_fmatrix_fmatrix(dFdX[s->kl].m, dFdX[s->kl].m, s->dfdx);
sub_fmatrix_fmatrix(dFdX[s->ij].m, dFdX[s->ij].m, s->dfdx);
@@ -1415,7 +1414,7 @@ static void CalcFloat4( float *v1, float *v2, float *v3, float *v4, float *n)
static float calculateVertexWindForce(float wind[3], float vertexnormal[3])
{
- return (INPR(wind, vertexnormal));
+ return dot_v3v3(wind, vertexnormal);
}
typedef struct HairGridVert {
@@ -1503,7 +1502,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
k = HAIR_GRID_INDEX(loc1->co, gmin, gmax, 2);
if(k>=0 && k<10) {
- VECSUB(vel, loc1->co, loc0->co);
+ sub_v3_v3v3(vel, loc1->co, loc0->co);
colg[i][j][k].velocity[0] += vel[0];
colg[i][j][k].velocity[1] += vel[1];
@@ -1577,7 +1576,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
/* global acceleration (gravitation) */
if(clmd->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
- VECCOPY(gravity, clmd->scene->physics_settings.gravity);
+ copy_v3_v3(gravity, clmd->scene->physics_settings.gravity);
mul_fvector_S(gravity, gravity, 0.001f * clmd->sim_parms->effector_weights->global_gravity); /* scale gravity force */
}
@@ -1597,7 +1596,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
for(i = 0; i < numverts; i++)
{
float temp[3];
- VECCOPY(temp, lF[i]);
+ copy_v3_v3(temp, lF[i]);
mul_fmatrix_fvector(lF[i], M[i].m, temp);
}
@@ -1636,24 +1635,24 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
normalize_v3_v3(trinormal, triunnormal);
// add wind from v1
- VECCOPY(tmp, trinormal);
+ copy_v3_v3(tmp, trinormal);
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v1], triunnormal));
VECADDS(lF[mfaces[i].v1], lF[mfaces[i].v1], tmp, factor);
// add wind from v2
- VECCOPY(tmp, trinormal);
+ copy_v3_v3(tmp, trinormal);
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v2], triunnormal));
VECADDS(lF[mfaces[i].v2], lF[mfaces[i].v2], tmp, factor);
// add wind from v3
- VECCOPY(tmp, trinormal);
+ copy_v3_v3(tmp, trinormal);
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v3], triunnormal));
VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor);
// add wind from v4
if(mfaces[i].v4)
{
- VECCOPY(tmp, trinormal);
+ copy_v3_v3(tmp, trinormal);
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal));
VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor);
}
@@ -1672,15 +1671,15 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
spring = search->link;
if(spring->type == CLOTH_SPRING_TYPE_STRUCTURAL) {
- VECSUB(edgevec, (float*)lX[spring->ij], (float*)lX[spring->kl]);
+ sub_v3_v3v3(edgevec, (float*)lX[spring->ij], (float*)lX[spring->kl]);
project_v3_v3v3(tmp, winvec[spring->ij], edgevec);
- VECSUB(edgeunnormal, winvec[spring->ij], tmp);
+ sub_v3_v3v3(edgeunnormal, winvec[spring->ij], tmp);
/* hair doesn't stretch too much so we can use restlen pretty safely */
VECADDS(lF[spring->ij], lF[spring->ij], edgeunnormal, spring->restlen * factor);
project_v3_v3v3(tmp, winvec[spring->kl], edgevec);
- VECSUB(edgeunnormal, winvec[spring->kl], tmp);
+ sub_v3_v3v3(edgeunnormal, winvec[spring->kl], tmp);
VECADDS(lF[spring->kl], lF[spring->kl], edgeunnormal, spring->restlen * factor);
}
@@ -1843,7 +1842,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
// update velocities with constrained velocities from pinned verts
if(verts [i].flags & CLOTH_VERT_FLAG_PINNED)
{
- VECSUB(id->V[i], verts[i].xconst, verts[i].xold);
+ sub_v3_v3v3(id->V[i], verts[i].xconst, verts[i].xold);
// mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame);
}
}
@@ -1871,14 +1870,14 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
if(verts [i].flags & CLOTH_VERT_FLAG_PINNED)
{
float tvect[3] = {.0,.0,.0};
- VECSUB(tvect, verts[i].xconst, verts[i].xold);
+ sub_v3_v3v3(tvect, verts[i].xconst, verts[i].xold);
mul_fvector_S(tvect, tvect, step+dt);
VECADD(tvect, tvect, verts[i].xold);
- VECCOPY(id->Xnew[i], tvect);
+ copy_v3_v3(id->Xnew[i], tvect);
}
}
- VECCOPY(verts[i].txold, id->X[i]);
+ copy_v3_v3(verts[i].txold, id->X[i]);
}
if(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree)
@@ -1889,10 +1888,10 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
// update verts to current positions
for(i = 0; i < numverts; i++)
{
- VECCOPY(verts[i].tx, id->Xnew[i]);
+ copy_v3_v3(verts[i].tx, id->Xnew[i]);
- VECSUB(verts[i].tv, verts[i].tx, verts[i].txold);
- VECCOPY(verts[i].v, verts[i].tv);
+ sub_v3_v3v3(verts[i].tv, verts[i].tx, verts[i].txold);
+ copy_v3_v3(verts[i].v, verts[i].tv);
}
for (i=0, cv=cloth->verts; i<cloth->numverts; i++, cv++) {
@@ -1907,7 +1906,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
for(i = 0; i < numverts; i++)
{
// correct velocity again, just to be sure we had to change it due to adaptive collisions
- VECSUB(verts[i].tv, verts[i].tx, id->X[i]);
+ sub_v3_v3v3(verts[i].tv, verts[i].tx, id->X[i]);
}
//if (do_extra_solve)
@@ -1922,8 +1921,8 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
if((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
continue;
- VECCOPY(id->Xnew[i], verts[i].tx);
- VECCOPY(id->Vnew[i], verts[i].tv);
+ copy_v3_v3(id->Xnew[i], verts[i].tx);
+ copy_v3_v3(id->Vnew[i], verts[i].tv);
mul_v3_fl(id->Vnew[i], spf);
}
}
@@ -1963,15 +1962,15 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
{
if((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
{
- VECCOPY(verts[i].txold, verts[i].xconst); // TODO: test --> should be .x
- VECCOPY(verts[i].x, verts[i].xconst);
- VECCOPY(verts[i].v, id->V[i]);
+ copy_v3_v3(verts[i].txold, verts[i].xconst); // TODO: test --> should be .x
+ copy_v3_v3(verts[i].x, verts[i].xconst);
+ copy_v3_v3(verts[i].v, id->V[i]);
}
else
{
- VECCOPY(verts[i].txold, id->X[i]);
- VECCOPY(verts[i].x, id->X[i]);
- VECCOPY(verts[i].v, id->V[i]);
+ copy_v3_v3(verts[i].txold, id->X[i]);
+ copy_v3_v3(verts[i].x, id->X[i]);
+ copy_v3_v3(verts[i].v, id->V[i]);
}
}
@@ -1989,8 +1988,8 @@ void implicit_set_positions (ClothModifierData *clmd)
for(i = 0; i < numverts; i++)
{
- VECCOPY(id->X[i], verts[i].x);
- VECCOPY(id->V[i], verts[i].v);
+ copy_v3_v3(id->X[i], verts[i].x);
+ copy_v3_v3(id->V[i], verts[i].v);
}
if(G.rt > 0)
printf("implicit_set_positions\n");