diff options
Diffstat (limited to 'source/blender/editors/armature/meshlaplacian.c')
-rw-r--r-- | source/blender/editors/armature/meshlaplacian.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index c0177d41d4a..4e31fcc7a11 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -94,7 +94,7 @@ struct LaplacianSystem { float *H; /* diagonal H matrix */ float *p; /* values from all p vectors */ float *mindist; /* minimum distance to a bone for all vertices */ - + BVHTree *bvhtree; /* ray tracing acceleration structure */ const MLoopTri **vltree; /* a looptri that the vertex belongs to */ } heat; @@ -259,7 +259,7 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) if (sys->areaweights) for (a = 0, face = sys->faces; a < sys->totface; a++, face++) laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]); - + for (a = 0; a < totvert; a++) { if (sys->areaweights) { if (sys->varea[a] != 0.0f) @@ -275,7 +275,7 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) if (sys->storeweights) sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight"); - + for (a = 0, face = sys->faces; a < totface; a++, face++) laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]); @@ -403,7 +403,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys) const MLoopTri *lt = &looptri[a]; float bb[6]; int vtri[3]; - + vtri[0] = mloop[lt->tri[0]].v; vtri[1] = mloop[lt->tri[1]].v; vtri[2] = mloop[lt->tri[2]].v; @@ -414,14 +414,14 @@ static void heat_ray_tree_create(LaplacianSystem *sys) minmax_v3v3_v3(bb, bb + 3, verts[vtri[2]]); BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2); - + //Setup inverse pointers to use on isect.orig sys->heat.vltree[vtri[0]] = lt; sys->heat.vltree[vtri[1]] = lt; sys->heat.vltree[vtri[2]] = lt; } - BLI_bvhtree_balance(sys->heat.bvhtree); + BLI_bvhtree_balance(sys->heat.bvhtree); } static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) @@ -457,7 +457,7 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) static float heat_source_distance(LaplacianSystem *sys, int vertex, int source) { float closest[3], d[3], dist, cosine; - + /* compute euclidian distance */ closest_to_line_segment_v3(closest, sys->heat.verts[vertex], sys->heat.root[source], sys->heat.tip[source]); @@ -479,7 +479,7 @@ static int heat_source_closest(LaplacianSystem *sys, int vertex, int source) if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON)) if (heat_ray_source_visible(sys, vertex, source)) return 1; - + return 0; } @@ -514,7 +514,7 @@ static void heat_set_H(LaplacianSystem *sys, int vertex) } else h = 0.0f; - + sys->heat.H[vertex] = h; } @@ -531,7 +531,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys) v3 = (*face)[2]; normal_tri_v3(fnor, sys->verts[v1], sys->verts[v2], sys->verts[v3]); - + add_v3_v3(sys->heat.vnors[v1], fnor); add_v3_v3(sys->heat.vnors[v2], fnor); add_v3_v3(sys->heat.vnors[v3], fnor); @@ -677,7 +677,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, for (a = 0; a < me->totvert; a++) vertsflipped[a] = mesh_get_x_mirror_vert(ob, NULL, a, use_topology); } - + /* compute weights per bone */ for (j = 0; j < numsource; j++) { if (!selected[j]) @@ -715,7 +715,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, continue; solution = laplacian_system_get_solution(sys, a); - + if (bbone) { if (solution > 0.0f) ED_vgroup_vert_add(ob, dgrouplist[j], a, solution, @@ -850,7 +850,7 @@ typedef struct MeshDeformBind { /* direct solver */ int *varidx; - + BVHTree *bvhtree; BVHTreeFromMesh bvhdata; @@ -871,7 +871,7 @@ typedef struct MeshDeformIsect { bool isect; float u, v; - + } MeshDeformIsect; /* ray intersection */ @@ -891,9 +891,9 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r MeshDeformIsect *isec = data->isec; float no[3], co[3], dist; float *face[3]; - + lt = &looptri[index]; - + face[0] = mdb->cagecos[mloop[lt->tri[0]].v]; face[1] = mdb->cagecos[mloop[lt->tri[1]].v]; face[2] = mdb->cagecos[mloop[lt->tri[2]].v]; @@ -917,7 +917,7 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r hit->index = index; hit->dist = dist; copy_v3_v3(hit->co, co); - + isec->isect = (dot_v3v3(no, ray->direction) <= 0.0f); isec->lambda = dist; } @@ -1000,7 +1000,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) copy_v3_v3(start, co); sub_v3_v3v3(dir, outside, start); normalize_v3(dir); - + isect = meshdeform_ray_tree_intersect(mdb, start, outside); if (isect && !isect->facing) return 1; @@ -1014,7 +1014,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) BLI_INLINE int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n) { int size = mdb->size; - + x += MESHDEFORM_OFFSET[n][0]; y += MESHDEFORM_OFFSET[n][1]; z += MESHDEFORM_OFFSET[n][2]; @@ -1118,7 +1118,7 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb) if (mdb->semibound[a]) ts++; } - + printf("interior %d exterior %d boundary %d semi-boundary %d\n", ti, te, tb, ts); } #endif @@ -1227,7 +1227,7 @@ static void meshdeform_matrix_add_cell(MeshDeformBind *mdb, LinearSolver *contex return; EIG_linear_solver_matrix_add(context, mdb->varidx[acenter], mdb->varidx[acenter], 1.0f); - + totweight = meshdeform_boundary_total_weight(mdb, x, y, z); for (i = 1; i <= 6; i++) { a = meshdeform_index(mdb, x, y, z, i); @@ -1277,7 +1277,7 @@ static void meshdeform_matrix_add_semibound_phi(MeshDeformBind *mdb, int x, int a = meshdeform_index(mdb, x, y, z, 0); if (!mdb->semibound[a]) return; - + mdb->phi[a] = 0.0f; totweight = meshdeform_boundary_total_weight(mdb, x, y, z); @@ -1415,7 +1415,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind printf("totalphi deficiency [%s|%d] %d: %.10f\n", (mdb->tag[b] == MESHDEFORM_TAG_INTERIOR) ? "interior" : "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]); #endif - + /* free */ MEM_freeN(mdb->varidx); @@ -1501,7 +1501,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa /* start with all cells untyped */ for (a = 0; a < mdb->size3; a++) mdb->tag[a] = MESHDEFORM_TAG_UNTYPED; - + /* detect intersections and tag boundary cells */ for (z = 0; z < mdb->size; z++) for (y = 0; y < mdb->size; y++) @@ -1588,7 +1588,7 @@ void ED_mesh_deform_bind_callback( /* get mesh and cage mesh */ mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, "MeshDeformCos"); mdb.totvert = totvert; - + mdb.cagedm = cagedm; mdb.totcagevert = mdb.cagedm->getNumVerts(mdb.cagedm); mdb.cagecos = MEM_callocN(sizeof(*mdb.cagecos) * mdb.totcagevert, "MeshDeformBindCos"); |