[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44760] trunk/blender/source/blender: code cleanup: replace macros VECCOPY, VECADD, VECSUB, INPR - with BLI_math funcs.
Campbell Barton
ideasman42 at gmail.com
Fri Mar 9 07:04:28 CET 2012
Revision: 44760
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44760
Author: campbellbarton
Date: 2012-03-09 06:04:17 +0000 (Fri, 09 Mar 2012)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/collision.c
trunk/blender/source/blender/blenkernel/intern/constraint.c
trunk/blender/source/blender/blenkernel/intern/implicit.c
trunk/blender/source/blender/blenkernel/intern/mesh.c
trunk/blender/source/blender/blenkernel/intern/particle.c
trunk/blender/source/blender/blenkernel/intern/particle_system.c
trunk/blender/source/blender/blenkernel/intern/sketch.c
trunk/blender/source/blender/blenlib/BLI_math_vector.h
trunk/blender/source/blender/blenlib/BLI_utildefines.h
trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
trunk/blender/source/blender/blenlib/intern/scanfill.c
trunk/blender/source/blender/bmesh/intern/bmesh_interp.c
trunk/blender/source/blender/editors/armature/editarmature_generate.c
trunk/blender/source/blender/editors/armature/reeb.c
trunk/blender/source/blender/editors/mesh/meshtools.c
trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
trunk/blender/source/blender/editors/space_view3d/view3d_view.c
trunk/blender/source/blender/editors/transform/transform_conversions.c
trunk/blender/source/blender/editors/transform/transform_manipulator.c
trunk/blender/source/blender/nodes/composite/nodes/node_composite_normal.c
trunk/blender/source/blender/nodes/shader/nodes/node_shader_normal.c
trunk/blender/source/blender/render/intern/source/shadeoutput.c
Modified: trunk/blender/source/blender/blenkernel/intern/collision.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/collision.c 2012-03-09 04:10:19 UTC (rev 44759)
+++ trunk/blender/source/blender/blenkernel/intern/collision.c 2012-03-09 06:04:17 UTC (rev 44760)
@@ -82,10 +82,10 @@
for ( i = 0; i < collmd->numverts; i++ )
{
- VECSUB ( tv, collmd->xnew[i].co, collmd->x[i].co );
+ sub_v3_v3v3 ( tv, collmd->xnew[i].co, collmd->x[i].co );
VECADDS ( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep );
VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step );
- VECSUB ( collmd->current_v[i].co, collmd->current_xnew[i].co, collmd->current_x[i].co );
+ sub_v3_v3v3 ( collmd->current_v[i].co, collmd->current_xnew[i].co, collmd->current_x[i].co );
}
bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 );
@@ -529,10 +529,10 @@
collision_interpolateOnTriangle ( v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3 );
- VECSUB ( relativeVelocity, v2, v1 );
+ sub_v3_v3v3 ( relativeVelocity, v2, v1 );
// Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal').
- magrelVel = INPR ( relativeVelocity, collpair->normal );
+ magrelVel = dot_v3v3( relativeVelocity, collpair->normal );
// printf("magrelVel: %f\n", magrelVel);
@@ -551,11 +551,11 @@
// calculate tangential velocity
copy_v3_v3 ( temp, collpair->normal );
mul_v3_fl( temp, magrelVel );
- VECSUB ( vrel_t_pre, relativeVelocity, temp );
+ sub_v3_v3v3 ( vrel_t_pre, relativeVelocity, temp );
// Decrease in magnitude of relative tangential velocity due to coulomb friction
// in original formula "magrelVel" should be the "change of relative velocity in normal direction"
- magtangent = MIN2 ( clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf( INPR ( vrel_t_pre,vrel_t_pre ) ) );
+ magtangent = MIN2 ( clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf( dot_v3v3( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
@@ -859,10 +859,10 @@
VECADDFAC(v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, w1);
VECADDFAC(v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, w2);
- VECSUB ( relativeVelocity, v2, v1);
+ sub_v3_v3v3 ( relativeVelocity, v2, v1);
// Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal').
- magrelVel = INPR ( relativeVelocity, collpair->normal );
+ magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
// If v_n_mag < 0 the edges are approaching each other.
if ( magrelVel > ALMOST_ZERO )
@@ -876,13 +876,13 @@
zero_v3(pimpulse);
// calculate tangential velocity
- VECCOPY ( temp, collpair->normal );
+ copy_v3_v3 ( temp, collpair->normal );
mul_v3_fl( temp, magrelVel );
- VECSUB ( vrel_t_pre, relativeVelocity, temp );
+ sub_v3_v3v3 ( vrel_t_pre, relativeVelocity, temp );
// Decrease in magnitude of relative tangential velocity due to coulomb friction
// in original formula "magrelVel" should be the "change of relative velocity in normal direction"
- magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( INPR ( vrel_t_pre,vrel_t_pre ) ) );
+ magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
@@ -961,10 +961,10 @@
// Calculate relative "velocity".
collision_interpolateOnTriangle ( v1, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, w1, w2, w3);
- VECSUB ( relativeVelocity, v1, cloth1->verts[collpair->collp].tv);
+ sub_v3_v3v3 ( relativeVelocity, v1, cloth1->verts[collpair->collp].tv);
// Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal').
- magrelVel = INPR ( relativeVelocity, collpair->normal );
+ magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
// If v_n_mag < 0 the edges are approaching each other.
if ( magrelVel > ALMOST_ZERO )
@@ -976,13 +976,13 @@
float temp[3], spf;
// calculate tangential velocity
- VECCOPY ( temp, collpair->normal );
+ copy_v3_v3 ( temp, collpair->normal );
mul_v3_fl( temp, magrelVel );
- VECSUB ( vrel_t_pre, relativeVelocity, temp );
+ sub_v3_v3v3 ( vrel_t_pre, relativeVelocity, temp );
// Decrease in magnitude of relative tangential velocity due to coulomb friction
// in original formula "magrelVel" should be the "change of relative velocity in normal direction"
- magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( INPR ( vrel_t_pre,vrel_t_pre ) ) );
+ magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
@@ -1027,10 +1027,10 @@
// Calculate relative "velocity".
collision_interpolateOnTriangle ( v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3 );
- VECSUB ( relativeVelocity, collmd->current_v[collpair->collp].co, v1);
+ sub_v3_v3v3 ( relativeVelocity, collmd->current_v[collpair->collp].co, v1);
// Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal').
- magrelVel = INPR ( relativeVelocity, collpair->normal );
+ magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
// If v_n_mag < 0 the edges are approaching each other.
if ( magrelVel > ALMOST_ZERO )
@@ -1042,13 +1042,13 @@
float temp[3], spf;
// calculate tangential velocity
- VECCOPY ( temp, collpair->normal );
+ copy_v3_v3 ( temp, collpair->normal );
mul_v3_fl( temp, magrelVel );
- VECSUB ( vrel_t_pre, relativeVelocity, temp );
+ sub_v3_v3v3 ( vrel_t_pre, relativeVelocity, temp );
// Decrease in magnitude of relative tangential velocity due to coulomb friction
// in original formula "magrelVel" should be the "change of relative velocity in normal direction"
- magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( INPR ( vrel_t_pre,vrel_t_pre ) ) );
+ magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
@@ -1545,9 +1545,9 @@
collision_interpolateOnTriangle ( v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3 );
- VECSUB ( relativeVelocity, v2, v1 );
+ sub_v3_v3v3 ( relativeVelocity, v2, v1 );
- if(sqrt(INPR(relativeVelocity, relativeVelocity)) >= distance)
+ if(sqrt(dot_v3v3(relativeVelocity, relativeVelocity)) >= distance)
{
// check for collision in the future
collpair->flag |= COLLISION_IN_FUTURE;
@@ -1592,10 +1592,10 @@
collision_interpolateOnTriangle ( v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3 );
- VECSUB ( relativeVelocity, v2, v1 );
+ sub_v3_v3v3 ( relativeVelocity, v2, v1 );
// Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal').
- magrelVel = INPR ( relativeVelocity, collpair->normal );
+ magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
// printf("magrelVel: %f\n", magrelVel);
@@ -1612,13 +1612,13 @@
float temp[3];
// calculate tangential velocity
- VECCOPY ( temp, collpair->normal );
+ copy_v3_v3 ( temp, collpair->normal );
mul_v3_fl( temp, magrelVel );
- VECSUB ( vrel_t_pre, relativeVelocity, temp );
+ sub_v3_v3v3 ( vrel_t_pre, relativeVelocity, temp );
// Decrease in magnitude of relative tangential velocity due to coulomb friction
// in original formula "magrelVel" should be the "change of relative velocity in normal direction"
- magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( INPR ( vrel_t_pre,vrel_t_pre ) ) );
+ magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
@@ -1675,9 +1675,9 @@
static float projectPointOntoLine(float *p, float *a, float *b)
{
float ba[3], pa[3];
- VECSUB(ba, b, a);
- VECSUB(pa, p, a);
- return INPR(pa, ba) / INPR(ba, ba);
+ sub_v3_v3v3(ba, b, a);
+ sub_v3_v3v3(pa, p, a);
+ return dot_v3v3(pa, ba) / dot_v3v3(ba, ba);
}
static void calculateEENormal(float *np1, float *np2, float *np3, float *np4,float *out_normal)
@@ -1685,8 +1685,8 @@
float line1[3], line2[3];
float length;
- VECSUB(line1, np2, np1);
- VECSUB(line2, np3, np1);
+ sub_v3_v3v3(line1, np2, np1);
+ sub_v3_v3v3(line2, np3, np1);
// printf("l1: %f, l1: %f, l2: %f, l2: %f\n", line1[0], line1[1], line2[0], line2[1]);
@@ -1697,7 +1697,7 @@
length = normalize_v3(out_normal);
if (length <= FLT_EPSILON)
{ // lines are collinear
- VECSUB(out_normal, np2, np1);
+ sub_v3_v3v3(out_normal, np2, np1);
normalize_v3(out_normal);
}
}
@@ -1708,19 +1708,19 @@
double a, b, c, e, f;
- VECSUB(temp, x2, x1);
- a = INPR(temp, temp);
+ sub_v3_v3v3(temp, x2, x1);
+ a = dot_v3v3(temp, temp);
- VECSUB(temp2, x4, x3);
- b = -INPR(temp, temp2);
+ sub_v3_v3v3(temp2, x4, x3);
+ b = -dot_v3v3(temp, temp2);
- c = INPR(temp2, temp2);
+ c = dot_v3v3(temp2, temp2);
- VECSUB(temp2, x3, x1);
- e = INPR(temp, temp2);
+ sub_v3_v3v3(temp2, x3, x1);
+ e = dot_v3v3(temp, temp2);
- VECSUB(temp, x4, x3);
- f = -INPR(temp, temp2);
+ sub_v3_v3v3(temp, x4, x3);
+ f = -dot_v3v3(temp, temp2);
*w1 = (e * c - b * f) / (a * c - b * b);
*w2 = (f - b * *w1) / c;
@@ -1735,11 +1735,11 @@
float temp[3], temp2[3];
float dist_a1, dist_a2;
- VECSUB(line1, np12, np11);
- VECSUB(line2, np22, np21);
+ sub_v3_v3v3(line1, np12, np11);
+ sub_v3_v3v3(line2, np22, np21);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list