Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/deform.cc
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| else { | else { | ||||
| copy_vn_fl(r_weights, edges_num, 0.0f); | copy_vn_fl(r_weights, edges_num, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| void BKE_defvert_extract_vgroup_to_loopweights(const MDeformVert *dvert, | void BKE_defvert_extract_vgroup_to_loopweights(const MDeformVert *dvert, | ||||
| const int defgroup, | const int defgroup, | ||||
| const int verts_num, | const int verts_num, | ||||
| const MLoop *loops, | const int *corner_verts, | ||||
| const int loops_num, | const int loops_num, | ||||
| const bool invert_vgroup, | const bool invert_vgroup, | ||||
| float *r_weights) | float *r_weights) | ||||
| { | { | ||||
| if (dvert && defgroup != -1) { | if (dvert && defgroup != -1) { | ||||
| int i = loops_num; | int i = loops_num; | ||||
| float *tmp_weights = static_cast<float *>( | float *tmp_weights = static_cast<float *>( | ||||
| MEM_mallocN(sizeof(*tmp_weights) * size_t(verts_num), __func__)); | MEM_mallocN(sizeof(*tmp_weights) * size_t(verts_num), __func__)); | ||||
| BKE_defvert_extract_vgroup_to_vertweights( | BKE_defvert_extract_vgroup_to_vertweights( | ||||
| dvert, defgroup, verts_num, invert_vgroup, tmp_weights); | dvert, defgroup, verts_num, invert_vgroup, tmp_weights); | ||||
| while (i--) { | while (i--) { | ||||
| const MLoop *ml = &loops[i]; | r_weights[i] = tmp_weights[corner_verts[i]]; | ||||
| r_weights[i] = tmp_weights[ml->v]; | |||||
| } | } | ||||
| MEM_freeN(tmp_weights); | MEM_freeN(tmp_weights); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_vn_fl(r_weights, loops_num, 0.0f); | copy_vn_fl(r_weights, loops_num, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| void BKE_defvert_extract_vgroup_to_polyweights(const MDeformVert *dvert, | void BKE_defvert_extract_vgroup_to_polyweights(const MDeformVert *dvert, | ||||
| const int defgroup, | const int defgroup, | ||||
| const int verts_num, | const int verts_num, | ||||
| const MLoop *loops, | const int *corner_verts, | ||||
| const int /*loops_num*/, | const int /*loops_num*/, | ||||
| const MPoly *polys, | const MPoly *polys, | ||||
| const int polys_num, | const int polys_num, | ||||
| const bool invert_vgroup, | const bool invert_vgroup, | ||||
| float *r_weights) | float *r_weights) | ||||
| { | { | ||||
| if (dvert && defgroup != -1) { | if (dvert && defgroup != -1) { | ||||
| int i = polys_num; | int i = polys_num; | ||||
| float *tmp_weights = static_cast<float *>( | float *tmp_weights = static_cast<float *>( | ||||
| MEM_mallocN(sizeof(*tmp_weights) * size_t(verts_num), __func__)); | MEM_mallocN(sizeof(*tmp_weights) * size_t(verts_num), __func__)); | ||||
| BKE_defvert_extract_vgroup_to_vertweights( | BKE_defvert_extract_vgroup_to_vertweights( | ||||
| dvert, defgroup, verts_num, invert_vgroup, tmp_weights); | dvert, defgroup, verts_num, invert_vgroup, tmp_weights); | ||||
| while (i--) { | while (i--) { | ||||
| const MPoly *mp = &polys[i]; | const MPoly *mp = &polys[i]; | ||||
| const MLoop *ml = &loops[mp->loopstart]; | const int *corner_vert = &corner_verts[mp->loopstart]; | ||||
| int j = mp->totloop; | int j = mp->totloop; | ||||
| float w = 0.0f; | float w = 0.0f; | ||||
| for (; j--; ml++) { | for (; j--; corner_vert++) { | ||||
| w += tmp_weights[ml->v]; | w += tmp_weights[*corner_vert]; | ||||
| } | } | ||||
| r_weights[i] = w / float(mp->totloop); | r_weights[i] = w / float(mp->totloop); | ||||
| } | } | ||||
| MEM_freeN(tmp_weights); | MEM_freeN(tmp_weights); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_vn_fl(r_weights, polys_num, 0.0f); | copy_vn_fl(r_weights, polys_num, 0.0f); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||