From dfdfa3d51b48a6bffd90779a1778dcf0e9a751e4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Mar 2012 06:04:17 +0000 Subject: 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. --- source/blender/blenkernel/intern/collision.c | 174 ++++++++++----------- source/blender/blenkernel/intern/constraint.c | 3 +- source/blender/blenkernel/intern/implicit.c | 123 ++++++++------- source/blender/blenkernel/intern/mesh.c | 12 +- source/blender/blenkernel/intern/particle.c | 4 +- source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/sketch.c | 5 +- 7 files changed, 160 insertions(+), 163 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index ce0de3216d3..f19226cedf0 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -82,10 +82,10 @@ void collision_move_object ( CollisionModifierData *collmd, float step, float pr 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 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM 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 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM // 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 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli 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 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli 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 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM // 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 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM 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 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM // 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 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM 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 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, 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 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo 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 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo 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 int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo 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 @@ static void calculateEENormal(float *np1, float *np2, float *np3, float *np4,flo 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 @@ static void calculateEENormal(float *np1, float *np2, float *np3, float *np4,flo 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 @@ static void findClosestPointsEE(float *x1, float *x2, float *x3, float *x4, floa 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 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float 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); cross_v3_v3v3(cross, line1, line2); - length = INPR(cross, cross); + length = dot_v3v3(cross, cross); if (length < FLT_EPSILON) { @@ -1748,11 +1748,11 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float { *out_a1 = 0; calculateEENormal(np11, np12, np21, np22, out_normal); - VECSUB(temp, np22, np21); + sub_v3_v3v3(temp, np22, np21); mul_v3_fl(temp, *out_a2); VECADD(temp2, temp, np21); VECADD(temp2, temp2, np11); - return INPR(temp2, temp2); + return dot_v3v3(temp2, temp2); } CLAMP(*out_a2, 0.0, 1.0); @@ -1764,11 +1764,11 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float calculateEENormal(np11, np12, np21, np22, out_normal); // return (np22 - (np11 + (np12 - np11) * out_a1)).lengthSquared(); - VECSUB(temp, np12, np11); + sub_v3_v3v3(temp, np12, np11); mul_v3_fl(temp, *out_a1); VECADD(temp2, temp, np11); - VECSUB(temp2, np22, temp2); - return INPR(temp2, temp2); + sub_v3_v3v3(temp2, np22, temp2); + return dot_v3v3(temp2, temp2); } } else @@ -1779,11 +1779,11 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float calculateEENormal(np11, np11, np21, np22, out_normal); // return (np21 - (np11 + (np12 - np11) * out_a1)).lengthSquared(); - VECSUB(temp, np12, np11); + sub_v3_v3v3(temp, np12, np11); mul_v3_fl(temp, *out_a1); VECADD(temp2, temp, np11); - VECSUB(temp2, np21, temp2); - return INPR(temp2, temp2); + sub_v3_v3v3(temp2, np21, temp2); + return dot_v3v3(temp2, temp2); } } @@ -1793,26 +1793,26 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float { if(*out_a2 > .5) { - VECSUB(temp, np12, np22); + sub_v3_v3v3(temp, np12, np22); } else { - VECSUB(temp, np12, np21); + sub_v3_v3v3(temp, np12, np21); } } else { if(*out_a2 > .5) { - VECSUB(temp, np11, np22); + sub_v3_v3v3(temp, np11, np22); } else { - VECSUB(temp, np11, np21); + sub_v3_v3v3(temp, np11, np21); } } - return INPR(temp, temp); + return dot_v3v3(temp, temp); } else { @@ -1827,18 +1827,18 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float float p1[3], p2[3]; // p1= np11 + (np12 - np11) * out_a1; - VECSUB(temp, np12, np11); + sub_v3_v3v3(temp, np12, np11); mul_v3_fl(temp, *out_a1); VECADD(p1, np11, temp); // p2 = np21 + (np22 - np21) * out_a2; - VECSUB(temp, np22, np21); + sub_v3_v3v3(temp, np22, np21); mul_v3_fl(temp, *out_a2); VECADD(p2, np21, temp); calculateEENormal(np11, np12, np21, np22, out_normal); - VECSUB(temp, p1, p2); - return INPR(temp, temp); + sub_v3_v3v3(temp, p1, p2); + return dot_v3v3(temp, temp); } @@ -1858,7 +1858,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float float p1[3]; // p1 = np11 + (np12 - np11) * out_a1; - VECSUB(temp, np12, np11); + sub_v3_v3v3(temp, np12, np11); mul_v3_fl(temp, *out_a1); VECADD(p1, np11, temp); @@ -1868,11 +1868,11 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float calculateEENormal(np11, np12, np21, np22, out_normal); // return (p1 - (np21 + (np22 - np21) * out_a2)).lengthSquared(); - VECSUB(temp, np22, np21); + sub_v3_v3v3(temp, np22, np21); mul_v3_fl(temp, *out_a2); VECADD(temp, temp, np21); - VECSUB(temp, p1, temp); - return INPR(temp, temp); + sub_v3_v3v3(temp, p1, temp); + return dot_v3v3(temp, temp); } else { @@ -1880,7 +1880,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float float p2[3]; // p2 = np21 + (np22 - np21) * out_a2; - VECSUB(temp, np22, np21); + sub_v3_v3v3(temp, np22, np21); mul_v3_fl(temp, *out_a2); VECADD(p2, np21, temp); @@ -1890,11 +1890,11 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float calculateEENormal(np11, np12, np21, np22, out_normal); // return ((np11 + (np12 - np11) * out_a1) - p2).lengthSquared(); - VECSUB(temp, np12, np11); + sub_v3_v3v3(temp, np12, np11); mul_v3_fl(temp, *out_a1); VECADD(temp, temp, np11); - VECSUB(temp, temp, p2); - return INPR(temp, temp); + sub_v3_v3v3(temp, temp, p2); + return dot_v3v3(temp, temp); } } @@ -2006,14 +2006,14 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi // if ( !cloth_are_edges_adjacent ( clmd, collmd, &edgecollpair ) ) { // always put coll points in p21/p22 - VECSUB ( x1, verts1[edgecollpair.p12].txold, verts1[edgecollpair.p11].txold ); - VECSUB ( v1, verts1[edgecollpair.p12].tv, verts1[edgecollpair.p11].tv ); + sub_v3_v3v3 ( x1, verts1[edgecollpair.p12].txold, verts1[edgecollpair.p11].txold ); + sub_v3_v3v3 ( v1, verts1[edgecollpair.p12].tv, verts1[edgecollpair.p11].tv ); - VECSUB ( x2, verts2[edgecollpair.p21].co, verts1[edgecollpair.p11].txold ); - VECSUB ( v2, velocity2[edgecollpair.p21].co, verts1[edgecollpair.p11].tv ); + sub_v3_v3v3 ( x2, verts2[edgecollpair.p21].co, verts1[edgecollpair.p11].txold ); + sub_v3_v3v3 ( v2, velocity2[edgecollpair.p21].co, verts1[edgecollpair.p11].tv ); - VECSUB ( x3, verts2[edgecollpair.p22].co, verts1[edgecollpair.p11].txold ); - VECSUB ( v3, velocity2[edgecollpair.p22].co, verts1[edgecollpair.p11].tv ); + sub_v3_v3v3 ( x3, verts2[edgecollpair.p22].co, verts1[edgecollpair.p11].txold ); + sub_v3_v3v3 ( v3, velocity2[edgecollpair.p22].co, verts1[edgecollpair.p11].tv ); numsolutions = cloth_get_collision_time ( x1, v1, x2, v2, x3, v3, solution ); @@ -2048,27 +2048,27 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi // TODO: check for collisions distance = edgedge_distance(triA[0], triA[1], triB[0], triB[1], &a, &b, out_normal); - if ((distance <= clmd->coll_parms->epsilon + BLI_bvhtree_getepsilon ( collmd->bvhtree ) + ALMOST_ZERO) && (INPR(out_normal, out_normal) > 0)) + if ((distance <= clmd->coll_parms->epsilon + BLI_bvhtree_getepsilon ( collmd->bvhtree ) + ALMOST_ZERO) && (dot_v3v3(out_normal, out_normal) > 0)) { float vrel_1_to_2[3], temp[3], temp2[3], out_normalVelocity; float desiredVn; - VECCOPY(vrel_1_to_2, verts1[edgecollpair.p11].tv); + copy_v3_v3(vrel_1_to_2, verts1[edgecollpair.p11].tv); mul_v3_fl(vrel_1_to_2, 1.0 - a); - VECCOPY(temp, verts1[edgecollpair.p12].tv); + copy_v3_v3(temp, verts1[edgecollpair.p12].tv); mul_v3_fl(temp, a); VECADD(vrel_1_to_2, vrel_1_to_2, temp); - VECCOPY(temp, verts1[edgecollpair.p21].tv); + copy_v3_v3(temp, verts1[edgecollpair.p21].tv); mul_v3_fl(temp, 1.0 - b); - VECCOPY(temp2, verts1[edgecollpair.p22].tv); + copy_v3_v3(temp2, verts1[edgecollpair.p22].tv); mul_v3_fl(temp2, b); VECADD(temp, temp, temp2); - VECSUB(vrel_1_to_2, vrel_1_to_2, temp); + sub_v3_v3v3(vrel_1_to_2, vrel_1_to_2, temp); - out_normalVelocity = INPR(vrel_1_to_2, out_normal); + out_normalVelocity = dot_v3v3(vrel_1_to_2, out_normal); /* // this correction results in wrong normals sometimes? if(out_normalVelocity < 0.0) @@ -2507,7 +2507,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl } } - VECSUB ( temp, verts[i].tx, verts[j].tx ); + sub_v3_v3v3 ( temp, verts[i].tx, verts[j].tx ); if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue; @@ -2538,7 +2538,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl mul_v3_fl( temp, correction * -0.5 ); VECADD ( verts[j].tx, verts[j].tx, temp ); - VECSUB ( verts[i].tx, verts[i].tx, temp ); + sub_v3_v3v3 ( verts[i].tx, verts[i].tx, temp ); } ret = 1; ret2 += ret; @@ -2564,7 +2564,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl { if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) ) { - VECSUB ( verts[i].tv, verts[i].tx, verts[i].txold ); + sub_v3_v3v3 ( verts[i].tv, verts[i].tx, verts[i].txold ); } } } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index cad354e451a..e0125891e86 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3507,8 +3507,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) no[1] = 1.0f; if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) no[2] = 1.0f; - if(INPR(no,no) < FLT_EPSILON) - { + if (dot_v3v3(no, no) < FLT_EPSILON) { fail = TRUE; break; } 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; inumverts; 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"); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 9017d4b3808..446f1502020 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2622,9 +2622,9 @@ static void mesh_calc_ngon_normal(MPoly *mpoly, MLoop *loopstart, v2 = mvert + loopstart[(i+1)%mpoly->totloop].v; v3 = mvert + loopstart[(i+2)%mpoly->totloop].v; - VECCOPY(u, v1->co); - VECCOPY(v, v2->co); - VECCOPY(w, v3->co); + copy_v3db_v3fl(u, v1->co); + copy_v3db_v3fl(v, v2->co); + copy_v3db_v3fl(w, v3->co); /*this fixes some weird numerical error*/ if (i==0) { @@ -2712,9 +2712,9 @@ static void mesh_calc_ngon_normal_coords(MPoly *mpoly, MLoop *loopstart, v2 = (const float *)(vertex_coords + loopstart[(i+1)%mpoly->totloop].v); v3 = (const float *)(vertex_coords + loopstart[(i+2)%mpoly->totloop].v); - VECCOPY(u, v1); - VECCOPY(v, v2); - VECCOPY(w, v3); + copy_v3db_v3fl(u, v1); + copy_v3db_v3fl(v, v2); + copy_v3db_v3fl(w, v3); /*this fixes some weird numerical error*/ if (i==0) { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index d86b3c7a9d3..590c307f549 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2370,7 +2370,7 @@ void psys_find_parents(ParticleSimulationData *sim) BLI_kdtree_free(tree); } -static void get_strand_normal(Material *ma, float *surfnor, float surfdist, float *nor) +static void get_strand_normal(Material *ma, const float surfnor[3], float surfdist, float nor[3]) { float cross[3], nstrand[3], vnor[3], blend; @@ -2381,7 +2381,7 @@ static void get_strand_normal(Material *ma, float *surfnor, float surfdist, floa cross_v3_v3v3(cross, surfnor, nor); cross_v3_v3v3(nstrand, nor, cross); - blend= INPR(nstrand, surfnor); + blend = dot_v3v3(nstrand, surfnor); CLAMP(blend, 0.0f, 1.0f); interp_v3_v3v3(vnor, nstrand, surfnor, blend); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 22968583d33..8d50d3d69cf 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2411,7 +2411,7 @@ static void sph_particle_courant(SPHData *sphdata, SPHRangeData *pfr) mul_v3_v3fl(sphdata->flow, flow, 1.0f / pfr->tot_neighbors); } else { sphdata->element_size = MAXFLOAT; - VECCOPY(sphdata->flow, flow); + copy_v3_v3(sphdata->flow, flow); } } static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, float *UNUSED(impulse)) diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index b05188e7183..90d530cb239 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -258,8 +258,7 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f float delta = (float)i / (float)total; float *p = stk->points[start + 1 + i].p; - VECCOPY(p, delta_p); - mul_v3_fl(p, delta); + mul_v3_v3fl(p, delta_p, delta); add_v3_v3(p, p_start); } } @@ -333,7 +332,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) sub_v3_v3v3(distance, p, stk->points[start].p); project_v3_v3v3(distance, distance, normal); - VECCOPY(offset, normal); + copy_v3_v3(offset, normal); mul_v3_fl(offset, d); sub_v3_v3(p, distance); -- cgit v1.2.3