67 if (
mesh ==
nullptr) {
72 if (!accumulated_vecs) {
77 if (!accumulated_vecs_count) {
78 MEM_delete(accumulated_vecs);
82 const float fac_new = smd->
fac;
83 const float fac_orig = 1.0f - fac_new;
92 for (
int j = 0; j < smd->
repeat; j++) {
94 memset(accumulated_vecs, 0,
sizeof(*accumulated_vecs) *
size_t(verts_num));
95 memset(accumulated_vecs_count, 0,
sizeof(*accumulated_vecs_count) *
size_t(verts_num));
100 const uint idx1 = edges[i][0];
101 const uint idx2 = edges[i][1];
103 mid_v3_v3v3(fvec, vertexCos[idx1], vertexCos[idx2]);
105 accumulated_vecs_count[idx1]++;
108 accumulated_vecs_count[idx2]++;
112 const short flag = smd->
flag;
115 for (
int i = 0; i < verts_num; i++, dv++) {
116 float *vco_orig = vertexCos[i];
117 if (accumulated_vecs_count[i] > 0) {
118 mul_v3_fl(accumulated_vecs[i], 1.0f /
float(accumulated_vecs_count[i]));
120 float *vco_new = accumulated_vecs[i];
124 if (f_vgroup <= 0.0f) {
127 const float f_new = f_vgroup * fac_new;
128 const float f_orig = 1.0f - f_new;
131 vco_orig[0] = f_orig * vco_orig[0] + f_new * vco_new[0];
134 vco_orig[1] = f_orig * vco_orig[1] + f_new * vco_new[1];
137 vco_orig[2] = f_orig * vco_orig[2] + f_new * vco_new[2];
142 for (
int i = 0; i < verts_num; i++) {
143 float *vco_orig = vertexCos[i];
144 if (accumulated_vecs_count[i] > 0) {
145 mul_v3_fl(accumulated_vecs[i], 1.0f /
float(accumulated_vecs_count[i]));
147 float *vco_new = accumulated_vecs[i];
150 vco_orig[0] = fac_orig * vco_orig[0] + fac_new * vco_new[0];
153 vco_orig[1] = fac_orig * vco_orig[1] + fac_new * vco_new[1];
156 vco_orig[2] = fac_orig * vco_orig[2] + fac_new * vco_new[2];
162 MEM_delete(accumulated_vecs);
163 MEM_delete(accumulated_vecs_count);
187 row.
prop(ptr,
"use_x", toggles_flag, std::nullopt, ICON_NONE);
188 row.
prop(ptr,
"use_y", toggles_flag, std::nullopt, ICON_NONE);
189 row.
prop(ptr,
"use_z", toggles_flag, std::nullopt, ICON_NONE);
195 modifier_vgroup_ui(layout, ptr, &ob_ptr,
"vertex_group",
"invert_vertex_group", std::nullopt);
void modifier_vgroup_ui(ui::Layout &layout, PointerRNA *ptr, PointerRNA *ob_ptr, const StringRefNull vgroup_prop, const std::optional< StringRefNull > invert_vgroup_prop, const std::optional< StringRefNull > text)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)