diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-01-20 18:22:55 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-01-20 18:27:06 +0300 |
commit | 482c4d099ae88bea018712b92b2990617ef006f8 (patch) | |
tree | cdc6dd9d345da7a6edb2106ecb63d314d14b7a61 /source/blender/blenkernel | |
parent | b0dee09a6d5531fb3bc7bbb00069c75e18dfbd1d (diff) |
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... ;) ).
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/collision.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/smoke.c | 39 |
3 files changed, 29 insertions, 30 deletions
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 */ |