From 719e782f2c790aab7a822ad9e01a4fa8c93b5620 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 1 Jun 2018 11:02:54 +0200 Subject: Modifiers: tiny optimizations for mesh deform, lattice, kdop. --- source/blender/blenkernel/intern/lattice.c | 5 +++-- source/blender/blenlib/intern/BLI_kdopbvh.c | 10 ++++++---- source/blender/modifiers/intern/MOD_meshdeform.c | 9 +++++---- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 381f140ecf6..0fa20f00823 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -420,10 +420,11 @@ void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float int defgrp_index = -1; float co_prev[3], weight_blend = 0.0f; MDeformVert *dvert = BKE_lattice_deform_verts_get(ob); + float *__restrict latticedata = lattice_deform_data->latticedata; if (lt->editlatt) lt = lt->editlatt->latt; - if (lattice_deform_data->latticedata == NULL) return; + if (latticedata == NULL) return; if (lt->vgroup[0] && dvert) { defgrp_index = defgroup_name_index(ob, lt->vgroup); @@ -504,7 +505,7 @@ void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float idx_u = idx_v; } - madd_v3_v3fl(co, &lattice_deform_data->latticedata[idx_u * 3], u); + madd_v3_v3fl(co, &latticedata[idx_u * 3], u); if (defgrp_index != -1) weight_blend += (u * defvert_find_weight(dvert + idx_u, defgrp_index)); diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index b3adf3106c1..c6daae97688 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -513,25 +513,27 @@ static void create_kdop_hull(const BVHTree *tree, BVHNode *node, const float *co } /** - * \note depends on the fact that the BVH's for each face is already build + * \note depends on the fact that the BVH's for each face is already built */ static void refit_kdop_hull(const BVHTree *tree, BVHNode *node, int start, int end) { float newmin, newmax; - float *bv = node->bv; + float *__restrict bv = node->bv; int j; axis_t axis_iter; node_minmax_init(tree, node); for (j = start; j < end; j++) { + float *__restrict node_bv = tree->nodes[j]->bv; + /* for all Axes. */ for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) { - newmin = tree->nodes[j]->bv[(2 * axis_iter)]; + newmin = node_bv[(2 * axis_iter)]; if ((newmin < bv[(2 * axis_iter)])) bv[(2 * axis_iter)] = newmin; - newmax = tree->nodes[j]->bv[(2 * axis_iter) + 1]; + newmax = node_bv[(2 * axis_iter) + 1]; if ((newmax > bv[(2 * axis_iter) + 1])) bv[(2 * axis_iter) + 1] = newmax; } diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 0cd73d0ca16..4fe8942a194 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -225,8 +225,8 @@ static void meshdeform_vert_task( const MDeformVert *dvert = data->dvert; const int defgrp_index = data->defgrp_index; const int *offsets = mmd->bindoffsets; - const MDefInfluence *influences = mmd->bindinfluences; - /*const*/ float (*dco)[3] = data->dco; + const MDefInfluence *__restrict influences = mmd->bindinfluences; + /*const*/ float (*__restrict dco)[3] = data->dco; float (*vertexCos)[3] = data->vertexCos; float co[3]; float weight, totweight, fac = 1.0f; @@ -253,11 +253,12 @@ static void meshdeform_vert_task( totweight = meshdeform_dynamic_bind(mmd, dco, co); } else { - int a; totweight = 0.0f; zero_v3(co); + int start = offsets[iter]; + int end = offsets[iter + 1]; - for (a = offsets[iter]; a < offsets[iter + 1]; a++) { + for (int a = start; a < end; a++) { weight = influences[a].weight; madd_v3_v3fl(co, dco[influences[a].vertex], weight); totweight += weight; -- cgit v1.2.3