Modifiers: tiny optimizations for mesh deform, lattice, kdop.

This commit is contained in:
Brecht Van Lommel 2018-06-01 11:02:54 +02:00
parent bcbee4b9a3
commit 719e782f2c
3 changed files with 14 additions and 10 deletions

View File

@ -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));

View File

@ -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;
}

View File

@ -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;