[Bf-blender-cvs] [482c4d099ae] master: Cleanup: remove all BLI_utiledefines' ugly vectorial macros.

Bastien Montagne noreply at git.blender.org
Sun Jan 20 17:08:24 CET 2019


Commit: 482c4d099ae88bea018712b92b2990617ef006f8
Author: Bastien Montagne
Date:   Sun Jan 20 16:22:55 2019 +0100
Branches: master
https://developer.blender.org/rB482c4d099ae88bea018712b92b2990617ef006f8

Cleanup: remove all BLI_utiledefines' ugly vectorial macros.

Not only were those often making doublons with already existing
BLI_math's stuff, but they were also used to hide implicit type
conversions...

As usual this adds some more exotic inlined vector functions (one of
the rare cases where I really miss C++ and its templates... ;) ).

===================================================================

M	source/blender/blenkernel/intern/collision.c
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/BLI_utildefines.h
M	source/blender/blenlib/intern/math_vector_inline.c
M	source/blender/editors/armature/armature_add.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/physics/intern/implicit_blender.c

===================================================================

diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 53278d76399..e392f499b08 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -428,9 +428,9 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3
 	double tempV1[3], tempV2[3], tempV4[3];
 	double a, b, c, d, e, f;
 
-	VECSUB ( tempV1, p1, p3 );
-	VECSUB ( tempV2, p2, p3 );
-	VECSUB ( tempV4, pv, p3 );
+	sub_v3db_v3fl_v3fl(tempV1, p1, p3);
+	sub_v3db_v3fl_v3fl(tempV2, p2, p3);
+	sub_v3db_v3fl_v3fl(tempV4, pv, p3);
 
 	a = INPR ( tempV1, tempV1 );
 	b = INPR ( tempV1, tempV2 );
@@ -1131,8 +1131,8 @@ static int cloth_bvh_objcollisions_resolve(ClothModifierData * clmd, Object **co
 			for (i = 0; i < mvert_num; i++) {
 				// calculate "velocities" (just xnew = xold + v; no dt in v)
 				if (verts[i].impulse_count) {
-					VECADD ( verts[i].tv, verts[i].tv, verts[i].impulse);
-					VECADD ( verts[i].dcvel, verts[i].dcvel, verts[i].impulse);
+					add_v3_v3(verts[i].tv, verts[i].impulse);
+					add_v3_v3(verts[i].dcvel, verts[i].impulse);
 					zero_v3(verts[i].impulse);
 					verts[i].impulse_count = 0;
 
@@ -1168,8 +1168,8 @@ static int cloth_bvh_selfcollisions_resolve(ClothModifierData * clmd, CollPair *
 			for (i = 0; i < mvert_num; i++) {
 				if (verts[i].impulse_count) {
 					// VECADDMUL ( verts[i].tv, verts[i].impulse, 1.0f / verts[i].impulse_count );
-					VECADD ( verts[i].tv, verts[i].tv, verts[i].impulse);
-					VECADD ( verts[i].dcvel, verts[i].dcvel, verts[i].impulse);
+					add_v3_v3(verts[i].tv, verts[i].impulse);
+					add_v3_v3(verts[i].dcvel, verts[i].impulse);
 					zero_v3(verts[i].impulse);
 					verts[i].impulse_count = 0;
 
@@ -1305,7 +1305,7 @@ int cloth_bvh_collision(Depsgraph *depsgraph, Object *ob, ClothModifierData *clm
 					}
 				}
 
-				VECADD(verts[i].tx, verts[i].txold, verts[i].tv);
+				add_v3_v3v3(verts[i].tx, verts[i].txold, verts[i].tv);
 			}
 		}
 
@@ -1572,7 +1572,7 @@ void cloth_find_point_contacts(Depsgraph *depsgraph, Object *ob, ClothModifierDa
 			}
 		}
 
-		VECADD(verts[i].tx, verts[i].txold, verts[i].tv);
+		add_v3_v3v3(verts[i].tx, verts[i].txold, verts[i].tv);
 	}
 	////////////////////////////////////////////////////////////
 
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 3bf8d5aaa1e..4419485c4c4 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -811,7 +811,7 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
 		sds->active_fields = active_fields | cache_fields;
 		smoke_reallocate_fluid(sds, ch_dx, ch_res, 1);
 		sds->dx = ch_dx;
-		VECCOPY(sds->res, ch_res);
+		copy_v3_v3_int(sds->res, ch_res);
 		sds->total_cells = ch_res[0]*ch_res[1]*ch_res[2];
 		if (sds->flags & MOD_SMOKE_HIGHRES) {
 			smoke_reallocate_highres_fluid(sds, ch_dx, ch_res, 1);
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 3eebd125d9a..ac9c593ef65 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -296,12 +296,12 @@ static int smokeModifier_init(SmokeModifierData *smd, Object *ob, int scene_fram
 			res[0] = res[1] = res[2] = 1; /* use minimum res for adaptive init */
 		}
 		else {
-			VECCOPY(res, sds->base_res);
+			copy_v3_v3_int(res, sds->base_res);
 		}
-		VECCOPY(sds->res, res);
+		copy_v3_v3_int(sds->res, res);
 		sds->total_cells = sds->res[0] * sds->res[1] * sds->res[2];
 		sds->res_min[0] = sds->res_min[1] = sds->res_min[2] = 0;
-		VECCOPY(sds->res_max, res);
+		copy_v3_v3_int(sds->res_max, res);
 
 		/* allocate fluid */
 		smoke_reallocate_fluid(sds, sds->dx, sds->res, 0);
@@ -881,7 +881,7 @@ static void obstacles_from_mesh(
 			normal_float_to_short_v3(mvert[i].no, n);
 
 			/* vert velocity */
-			VECADD(co, mvert[i].co, sds->shift);
+			add_v3fl_v3fl_v3i(co, mvert[i].co, sds->shift);
 			if (has_velocity)
 			{
 				sub_v3_v3v3(&vert_vel[i * 3], co, &scs->verts_old[i * 3]);
@@ -1254,8 +1254,7 @@ static void emit_from_particles_task_cb(
 					                       1.0f : (1.0f - (nearest.dist - data->solid) / data->smooth);
 					/* Uses particle velocity as initial velocity for smoke */
 					if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY && (sfs->psys->part->phystype != PART_PHYS_NO)) {
-						VECADDFAC(&em->velocity[index * 3], &em->velocity[index * 3],
-						          &data->particle_vel[nearest.index * 3], sfs->vel_multi);
+						madd_v3_v3fl(&em->velocity[index * 3], &data->particle_vel[nearest.index * 3], sfs->vel_multi);
 					}
 				}
 			}
@@ -1414,7 +1413,7 @@ static void emit_from_particles(
 				/* Uses particle velocity as initial velocity for smoke */
 				if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY && (psys->part->phystype != PART_PHYS_NO))
 				{
-					VECADDFAC(&em->velocity[index * 3], &em->velocity[index * 3], &particle_vel[p * 3], sfs->vel_multi);
+					madd_v3_v3fl(&em->velocity[index * 3], &particle_vel[p * 3], sfs->vel_multi);
 				}
 			}   // particles loop
 		}
@@ -1736,7 +1735,7 @@ static void emit_from_mesh(Object *flow_ob, SmokeDomainSettings *sds, SmokeFlowS
 			/* vert velocity */
 			if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) {
 				float co[3];
-				VECADD(co, mvert[i].co, sds->shift);
+				add_v3fl_v3fl_v3i(co, mvert[i].co, sds->shift);
 				if (has_velocity) {
 					sub_v3_v3v3(&vert_vel[i * 3], co, &sfs->verts_old[i * 3]);
 					mul_v3_fl(&vert_vel[i * 3], sds->dx / dt);
@@ -2052,9 +2051,9 @@ static void adjustDomainResolution(SmokeDomainSettings *sds, int new_shift[3], E
 			smoke_turbulence_free(turb_old);
 
 		/* set new domain dimensions */
-		VECCOPY(sds->res_min, min);
-		VECCOPY(sds->res_max, max);
-		VECCOPY(sds->res, res);
+		copy_v3_v3_int(sds->res_min, min);
+		copy_v3_v3_int(sds->res_max, max);
+		copy_v3_v3_int(sds->res, res);
 		sds->total_cells = total_cells;
 	}
 }
@@ -2150,7 +2149,7 @@ static void update_flowsfluids(
 
 		mul_m4_v3(ob->obmat, ob_loc);
 
-		VECSUB(frame_shift_f, ob_loc, sds->prev_loc);
+		sub_v3_v3v3(frame_shift_f, ob_loc, sds->prev_loc);
 		copy_v3_v3(sds->prev_loc, ob_loc);
 		/* convert global space shift to local "cell" space */
 		mul_mat3_m4_v3(sds->imat, frame_shift_f);
@@ -2158,12 +2157,12 @@ static void update_flowsfluids(
 		frame_shift_f[1] = frame_shift_f[1] / sds->cell_size[1];
 		frame_shift_f[2] = frame_shift_f[2] / sds->cell_size[2];
 		/* add to total shift */
-		VECADD(sds->shift_f, sds->shift_f, frame_shift_f);
+		add_v3_v3(sds->shift_f, frame_shift_f);
 		/* convert to integer */
-		total_shift[0] = floor(sds->shift_f[0]);
-		total_shift[1] = floor(sds->shift_f[1]);
-		total_shift[2] = floor(sds->shift_f[2]);
-		VECSUB(new_shift, total_shift, sds->shift);
+		total_shift[0] = (int)(floorf(sds->shift_f[0]));
+		total_shift[1] = (int)(floorf(sds->shift_f[1]));
+		total_shift[2] = (int)(floorf(sds->shift_f[2]));
+		sub_v3_v3v3_int(new_shift, total_shift, sds->shift);
 		copy_v3_v3_int(sds->shift, total_shift);
 
 		/* calculate new domain boundary points so that smoke doesn't slide on sub-cell movement */
@@ -2689,8 +2688,8 @@ static Mesh *createDomainGeometry(SmokeDomainSettings *sds, Object *ob)
 
 	if (num_verts) {
 		/* volume bounds */
-		VECMADD(min, sds->p0, sds->cell_size, sds->res_min);
-		VECMADD(max, sds->p0, sds->cell_size, sds->res_max);
+		madd_v3fl_v3fl_v3fl_v3i(min, sds->p0, sds->cell_size, sds->res_min);
+		madd_v3fl_v3fl_v3fl_v3i(max, sds->p0, sds->cell_size, sds->res_max);
 
 		/* set vertices */
 		/* top slab */
@@ -2729,7 +2728,7 @@ static Mesh *createDomainGeometry(SmokeDomainSettings *sds, Object *ob)
 		invert_m4_m4(ob->imat, ob->obmat);
 		mul_m4_v3(ob->obmat, ob_loc);
 		mul_m4_v3(sds->obmat, ob_cache_loc);
-		VECSUB(sds->obj_shift_f, ob_cache_loc, ob_loc);
+		sub_v3_v3v3(sds->obj_shift_f, ob_cache_loc, ob_loc);
 		/* convert shift to local space and apply to vertices */
 		mul_mat3_m4_v3(ob->imat, sds->obj_shift_f);
 		/* apply */
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index dc108a7c3ec..61f24bae269 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -83,6 +83,8 @@ MINLINE void zero_v3_db(double r[3]);
 MINLINE void copy_v2_v2_db(double r[2], const double a[2]);
 MINLINE void copy_v3_v3_db(double r[3], const double a[3]);
 MINLINE void copy_v4_v4_db(double r[4], const double a[4]);
+/* short -> float */
+MINLINE void copy_v3fl_v3s(float r[3], const short a[3]);
 /* int <-> float */
 MINLINE void copy_v2fl_v2i(float r[2], const int a[2]);
 MINLINE void round_v2i_v2fl(int r[2], const float a[2]);
@@ -112,14 +114,20 @@ MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3]);
 MINLINE void add_v4_v4(float r[4], const float a[4]);
 MINLINE void add_v4_v4v4(float r[4], const float a[4], const float b[4]);
 
+MINLINE void add_v3fl_v3fl_v3i(float r[3], const float a[3], const int b[3]);
+MINLINE void add_v3fl_v3fl_v3s(float r[3], const float a[3], const short b[3]);
+
 MINLINE void sub_v2_v2(float r[2], const float a[2]);
 MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2]);
 MINLINE void sub_v2_v2v2_int(int r[2], const int a[2], const int b[2]);
 MINLINE void sub_v3_v3(float r[3], const float a[3]);
 MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3]);
+MINLINE void sub_v3_v3v3_int(int r[3], const int a[3], const int b[3]);
 MINLINE void sub_v4_v4(float r[4], const float a[4]);
 MINLINE void sub_v4_v4v4(float r[4], const float a[4], const float b[4]);
 
+MINLINE void sub_v3db_v3fl_v3fl(double r[3], const float a[3], const float b[3]);
+
 MINLINE void mul_v2_fl(float r[2], float f);
 MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f);
 MINLINE void mul_v3_fl(float r[3], float f);
@@ -150,6 +158,8 @@ MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], cons
 MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f);
 MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4]);
 
+MINLINE void madd_v3fl_v3fl_v3fl_v3i(float r[3], const

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list