Blender V5.3
MOD_meshdeform.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_utildefines.hh"
10
11#include "BLI_array.hh"
12#include "BLI_math_matrix_c.hh"
13#include "BLI_math_vector_c.hh"
14#include "BLI_simd.hh"
15#include "BLI_task_c.hh"
16
17#include "BLT_translation.hh"
18
19#include "DNA_meshdata_types.h"
20#include "DNA_object_types.h"
21#include "DNA_screen_types.h"
22
23#include "BKE_deform.hh"
24#include "BKE_lib_query.hh"
25#include "BKE_mesh_wrapper.hh"
26#include "BKE_modifier.hh"
27
29#include "UI_resources.hh"
30
31#include "BLO_read_write.hh"
32
33#include "RNA_access.hh"
34#include "RNA_prototypes.hh"
35
36#include "MEM_guardedalloc.h"
37
38#include "DEG_depsgraph.hh"
39
40#include "MOD_ui_common.hh"
41#include "MOD_util.hh"
42
43namespace blender {
44
45static void init_data(ModifierData *md)
46{
47 MeshDeformModifierData *mmd = reinterpret_cast<MeshDeformModifierData *>(md);
49}
50
68
69static void copy_data(const ModifierData *md, ModifierData *target, const int flag)
70{
71 const MeshDeformModifierData *mmd = reinterpret_cast<const MeshDeformModifierData *>(md);
72 MeshDeformModifierData *tmmd = reinterpret_cast<MeshDeformModifierData *>(target);
73
74 BKE_modifier_copydata_generic(md, target, flag);
75
78 &tmmd->bindinfluences,
82 &tmmd->bindoffsets,
86 &tmmd->bindcagecos,
89 mmd->dyngrid, mmd->dyngrid_sharing_info, &tmmd->dyngrid, &tmmd->dyngrid_sharing_info);
92 &tmmd->dyninfluences,
96 if (mmd->bindweights) {
97 tmmd->bindweights = MEM_dupalloc(mmd->bindweights); /* deprecated */
98 }
99 if (mmd->bindcos) {
100 tmmd->bindcos = MEM_dupalloc(mmd->bindcos); /* deprecated */
101 }
102}
103
104static void required_data_mask(ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
105{
106 MeshDeformModifierData *mmd = reinterpret_cast<MeshDeformModifierData *>(md);
107
108 /* Ask for vertex-groups if we need them. */
109 if (mmd->defgrp_name[0] != '\0') {
110 r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
111 }
112}
113
114static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/)
115{
116 MeshDeformModifierData *mmd = reinterpret_cast<MeshDeformModifierData *>(md);
117
118 /* The object type check is only needed here in case we have a placeholder
119 * object assigned (because the library containing the mesh is missing).
120 *
121 * In other cases it should be impossible to have a type mismatch.
122 */
123 return !mmd->object || mmd->object->type != OB_MESH;
124}
125
126static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
127{
128 MeshDeformModifierData *mmd = reinterpret_cast<MeshDeformModifierData *>(md);
129
130 walk(user_data, ob, reinterpret_cast<ID **>(&mmd->object), IDWALK_CB_NOP);
131}
132
134{
135 MeshDeformModifierData *mmd = reinterpret_cast<MeshDeformModifierData *>(md);
136 if (mmd->object != nullptr) {
137 DEG_add_object_relation(ctx->node, mmd->object, DEG_OB_COMP_TRANSFORM, "Mesh Deform Modifier");
138 DEG_add_object_relation(ctx->node, mmd->object, DEG_OB_COMP_GEOMETRY, "Mesh Deform Modifier");
139 }
140 /* We need our own transformation as well. */
141 DEG_add_depends_on_transform_relation(ctx->node, "Mesh Deform Modifier");
142}
143
144static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3], float vec[3])
145{
146 MDefCell *cell;
147 MDefInfluence *inf;
148 float gridvec[3], dvec[3], ivec[3], wx, wy, wz;
149 float weight, cageweight, totweight, *cageco;
150 int i, j, a, x, y, z, size;
151#if BLI_HAVE_SSE2
152 __m128 co = _mm_setzero_ps();
153#else
154 float co[3] = {0.0f, 0.0f, 0.0f};
155#endif
156
157 totweight = 0.0f;
158 size = mmd->dyngridsize;
159
160 for (i = 0; i < 3; i++) {
161 gridvec[i] = (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth * 0.5f) / mmd->dyncellwidth;
162 ivec[i] = int(gridvec[i]);
163 dvec[i] = gridvec[i] - ivec[i];
164 }
165
166 for (i = 0; i < 8; i++) {
167 if (i & 1) {
168 x = ivec[0] + 1;
169 wx = dvec[0];
170 }
171 else {
172 x = ivec[0];
173 wx = 1.0f - dvec[0];
174 }
175
176 if (i & 2) {
177 y = ivec[1] + 1;
178 wy = dvec[1];
179 }
180 else {
181 y = ivec[1];
182 wy = 1.0f - dvec[1];
183 }
184
185 if (i & 4) {
186 z = ivec[2] + 1;
187 wz = dvec[2];
188 }
189 else {
190 z = ivec[2];
191 wz = 1.0f - dvec[2];
192 }
193
194 CLAMP(x, 0, size - 1);
195 CLAMP(y, 0, size - 1);
196 CLAMP(z, 0, size - 1);
197
198 a = x + y * size + z * size * size;
199 weight = wx * wy * wz;
200
201 cell = &mmd->dyngrid[a];
202 inf = mmd->dyninfluences + cell->offset;
203 for (j = 0; j < cell->influences_num; j++, inf++) {
204 cageco = dco[inf->vertex];
205 cageweight = weight * inf->weight;
206#if BLI_HAVE_SSE2
207 {
208 __m128 cageweight_r = _mm_set1_ps(cageweight);
209 /* This will load one extra element, this is ok because
210 * we ignore that part of register anyway.
211 */
212 __m128 cageco_r = _mm_loadu_ps(cageco);
213 co = _mm_add_ps(co, _mm_mul_ps(cageco_r, cageweight_r));
214 }
215#else
216 co[0] += cageweight * cageco[0];
217 co[1] += cageweight * cageco[1];
218 co[2] += cageweight * cageco[2];
219#endif
220 totweight += cageweight;
221 }
222 }
223
224#if BLI_HAVE_SSE2
225 copy_v3_v3(vec, reinterpret_cast<float *>(&co));
226#else
227 copy_v3_v3(vec, co);
228#endif
229
230 return totweight;
231}
232
242
243static void meshdeform_vert_task(void *__restrict userdata,
244 const int iter,
245 const TaskParallelTLS *__restrict /*tls*/)
246{
247 MeshdeformUserdata *data = static_cast<MeshdeformUserdata *>(userdata);
248 /*const*/ MeshDeformModifierData *mmd = data->mmd;
249 const MDeformVert *dvert = data->dvert;
250 const int defgrp_index = data->defgrp_index;
251 const int *offsets = mmd->bindoffsets;
252 const MDefInfluence *__restrict influences = mmd->bindinfluences;
253 /*const*/ float (*__restrict dco)[3] = data->dco;
254 float (*vertexCos)[3] = data->vertexCos;
255 float co[3];
256 float weight, totweight, fac = 1.0f;
257
258 if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
259 if (!mmd->dynverts[iter]) {
260 return;
261 }
262 }
263
264 if (dvert) {
265 fac = BKE_defvert_find_weight(&dvert[iter], defgrp_index);
266
267 if (mmd->flag & MOD_MDEF_INVERT_VGROUP) {
268 fac = 1.0f - fac;
269 }
270
271 if (fac <= 0.0f) {
272 return;
273 }
274 }
275
276 if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
277 /* transform coordinate into cage's local space */
278 mul_v3_m4v3(co, data->cagemat, vertexCos[iter]);
279 totweight = meshdeform_dynamic_bind(mmd, dco, co);
280 }
281 else {
282 totweight = 0.0f;
283 zero_v3(co);
284 int start = offsets[iter];
285 int end = offsets[iter + 1];
286
287 for (int a = start; a < end; a++) {
288 weight = influences[a].weight;
289 madd_v3_v3fl(co, dco[influences[a].vertex], weight);
290 totweight += weight;
291 }
292 }
293
294 if (totweight > 0.0f) {
295 mul_v3_fl(co, fac / totweight);
296 mul_m3_v3(data->icagemat, co);
297 add_v3_v3(vertexCos[iter], co);
298 }
299}
300
302 const ModifierEvalContext *ctx,
303 Mesh *mesh,
304 float (*vertexCos)[3],
305 const int verts_num)
306{
307 MeshDeformModifierData *mmd = reinterpret_cast<MeshDeformModifierData *>(md);
308 Object *ob = ctx->object;
309
310 Mesh *cagemesh;
311 const MDeformVert *dvert = nullptr;
312 float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4];
313 const float (*bindcagecos)[3];
314 int a, cage_verts_num, defgrp_index;
316
317 static int recursive_bind_sentinel = 0;
318
319 if (mmd->object == nullptr || (mmd->bindcagecos == nullptr && mmd->bindfunc == nullptr)) {
320 return;
321 }
322
323 /* Get cage mesh.
324 *
325 * Only do this is the target object is in edit mode by itself, meaning
326 * we don't allow linked edit meshes here.
327 * This is because editbmesh_get_mesh_cage_and_final() might easily
328 * conflict with the thread which evaluates object which is in the edit
329 * mode for this mesh.
330 *
331 * We'll support this case once granular dependency graph is landed.
332 */
333 Object *ob_target = mmd->object;
335 if (cagemesh == nullptr) {
336 BKE_modifier_set_error(ctx->object, md, "Cannot get mesh from cage object");
337 return;
338 }
339
340 /* compute matrices to go in and out of cage object space */
341 invert_m4_m4(imat, ob_target->object_to_world().ptr());
342 mul_m4_m4m4(cagemat, imat, ob->object_to_world().ptr());
343 mul_m4_m4m4(cmat, mmd->bindmat, cagemat);
344 invert_m4_m4(iobmat, cmat);
345 copy_m3_m4(icagemat, iobmat);
346
347 /* bind weights if needed */
348 if (!mmd->bindcagecos) {
349 /* progress bar redraw can make this recursive. */
350 if (!DEG_is_active(ctx->depsgraph)) {
351 BKE_modifier_set_error(ob, md, "Attempt to bind from inactive dependency graph");
352 return;
353 }
354 if (!recursive_bind_sentinel) {
355 recursive_bind_sentinel = 1;
356 mmd->bindfunc(ob, mmd, cagemesh, reinterpret_cast<float *>(vertexCos), verts_num, cagemat);
357 recursive_bind_sentinel = 0;
358 }
359
360 return;
361 }
362
363 /* verify we have compatible weights */
364 cage_verts_num = BKE_mesh_wrapper_vert_len(cagemesh);
365
366 if (mmd->verts_num != verts_num) {
367 BKE_modifier_set_error(ob, md, "Vertices changed from %d to %d", mmd->verts_num, verts_num);
368 return;
369 }
370 if (mmd->cage_verts_num != cage_verts_num) {
372 ob, md, "Cage vertices changed from %d to %d", mmd->cage_verts_num, cage_verts_num);
373 return;
374 }
375 if (mmd->bindcagecos == nullptr) {
376 BKE_modifier_set_error(ob, md, "Bind data missing");
377 return;
378 }
379
380 /* We allocate 1 element extra to make it possible to
381 * load the values to SSE registers, which are float4.
382 */
383 Array<float3> dco(cage_verts_num + 1);
384 zero_v3(dco[cage_verts_num]);
385
386 /* setup deformation data */
387 BKE_mesh_wrapper_vert_coords_copy(cagemesh, dco.as_mutable_span().take_front(cage_verts_num));
388 bindcagecos = reinterpret_cast<const float (*)[3]>(mmd->bindcagecos);
389
390 for (a = 0; a < cage_verts_num; a++) {
391 /* Get cage vertex in world-space with binding transform. */
392 float co[3];
393 mul_v3_m4v3(co, mmd->bindmat, dco[a]);
394 /* compute difference with world space bind coord */
395 sub_v3_v3v3(dco[a], co, bindcagecos[a]);
396 }
397
398 MOD_get_vgroup(ob, mesh, mmd->defgrp_name, &dvert, &defgrp_index);
399
400 /* Initialize data to be pass to the for body function. */
401 data.mmd = mmd;
402 data.dvert = dvert;
403 data.dco = reinterpret_cast<float (*)[3]>(dco.data());
404 data.defgrp_index = defgrp_index;
405 data.vertexCos = vertexCos;
406 data.cagemat = cagemat;
407 data.icagemat = icagemat;
408
409 /* Do deformation. */
410 TaskParallelSettings settings;
412 settings.min_iter_per_thread = 16;
413 BLI_task_parallel_range(0, verts_num, &data, meshdeform_vert_task, &settings);
414}
415
417 const ModifierEvalContext *ctx,
418 Mesh *mesh,
419 MutableSpan<float3> positions)
420{
421 /* if next modifier needs original vertices */
422 MOD_previous_vcos_store(md, reinterpret_cast<float (*)[3]>(positions.data()));
424 md, ctx, mesh, reinterpret_cast<float (*)[3]>(positions.data()), positions.size());
425}
426
427#define MESHDEFORM_MIN_INFLUENCE 0.00001f
428
430{
431 MeshDeformModifierData *mmd = reinterpret_cast<MeshDeformModifierData *>(md);
432 float weight, totweight;
433 int influences_num, verts_num, cage_verts_num, a, b;
434
435 const float *weights = mmd->bindweights;
436 if (!weights) {
437 return;
438 }
439
440 verts_num = mmd->verts_num;
441 cage_verts_num = mmd->cage_verts_num;
442
443 if (verts_num == 0) {
444 MEM_delete(mmd->bindweights);
445 mmd->bindweights = nullptr;
446 return;
447 }
448
449 /* count number of influences above threshold */
450 for (b = 0; b < verts_num; b++) {
451 for (a = 0; a < cage_verts_num; a++) {
452 weight = weights[a + b * cage_verts_num];
453
454 if (weight > MESHDEFORM_MIN_INFLUENCE) {
455 mmd->influences_num++;
456 }
457 }
458 }
459
460 /* allocate bind influences */
461 mmd->bindinfluences = MEM_new_array<MDefInfluence>(mmd->influences_num, __func__);
463 mmd->bindoffsets = MEM_new_array_zeroed<int>(size_t(verts_num) + 1, __func__);
465
466 /* write influences */
467 influences_num = 0;
468
469 for (b = 0; b < verts_num; b++) {
470 mmd->bindoffsets[b] = influences_num;
471 totweight = 0.0f;
472
473 /* sum total weight */
474 for (a = 0; a < cage_verts_num; a++) {
475 weight = weights[a + b * cage_verts_num];
476
477 if (weight > MESHDEFORM_MIN_INFLUENCE) {
478 totweight += weight;
479 }
480 }
481
482 /* assign weights normalized */
483 for (a = 0; a < cage_verts_num; a++) {
484 weight = weights[a + b * cage_verts_num];
485
486 if (weight > MESHDEFORM_MIN_INFLUENCE) {
487 mmd->bindinfluences[influences_num].weight = weight / totweight;
488 mmd->bindinfluences[influences_num].vertex = a;
489 influences_num++;
490 }
491 }
492 }
493
494 mmd->bindoffsets[b] = influences_num;
495
496 /* free */
497 MEM_delete(mmd->bindweights);
498 mmd->bindweights = nullptr;
499}
500
501static void panel_draw(const bContext * /*C*/, Panel *panel)
502{
503 ui::Layout &layout = *panel->layout;
504
505 PointerRNA ob_ptr;
507
508 bool is_bound = RNA_boolean_get(ptr, "is_bound");
509
510 layout.use_property_split_set(true);
511
512 ui::Layout *col = &layout.column(true);
513 col->enabled_set(!is_bound);
514 col->prop(ptr, "object", UI_ITEM_NONE, std::nullopt, ICON_NONE);
515
516 modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", std::nullopt);
517
518 col = &layout.column(false);
519 col->enabled_set(!is_bound);
520 col->prop(ptr, "precision", UI_ITEM_NONE, std::nullopt, ICON_NONE);
521 col->prop(ptr, "use_dynamic_bind", UI_ITEM_NONE, std::nullopt, ICON_NONE);
522
523 layout.op("OBJECT_OT_meshdeform_bind", is_bound ? IFACE_("Unbind") : IFACE_("Bind"), ICON_NONE);
524
525 modifier_error_message_draw(layout, ptr);
526}
527
528static void panel_register(ARegionType *region_type)
529{
531}
532
533static void blend_write(BlendWriter *writer, const ID *id_owner, const ModifierData *md)
534{
535 const MeshDeformModifierData *mmd = reinterpret_cast<const MeshDeformModifierData *>(md);
536 const bool is_undo = writer->is_undo();
537 const bool without_bind_data = ID_IS_OVERRIDE_LIBRARY(id_owner) && !is_undo &&
539 if (without_bind_data) {
540 /* Modifier coming from linked data cannot be bound from an override, so we can remove all
541 * binding data, can save a significant amount of memory. */
542 BLI_assert(!ID_IS_LINKED(id_owner));
543 writer->write_struct(mmd, [](BlendStructWriter<MeshDeformModifierData> &struct_writer) {
544 auto &shallow_mmd = struct_writer.shallow_data;
545 shallow_mmd.influences_num = 0;
546 shallow_mmd.bindinfluences = nullptr;
547 shallow_mmd.bindinfluences_sharing_info = nullptr;
548 shallow_mmd.verts_num = 0;
549 shallow_mmd.bindoffsets = nullptr;
550 shallow_mmd.bindoffsets_sharing_info = nullptr;
551 shallow_mmd.cage_verts_num = 0;
552 shallow_mmd.bindcagecos = nullptr;
553 shallow_mmd.bindcagecos_sharing_info = nullptr;
554 shallow_mmd.dyngridsize = 0;
555 shallow_mmd.dyngrid = nullptr;
556 shallow_mmd.dyngrid_sharing_info = nullptr;
557 shallow_mmd.influences_num = 0;
558 shallow_mmd.dyninfluences = nullptr;
559 shallow_mmd.dyninfluences_sharing_info = nullptr;
560 shallow_mmd.dynverts = nullptr;
561 shallow_mmd.dynverts_sharing_info = nullptr;
562 });
563 return;
564 }
565
566 const int size = mmd->dyngridsize;
567
568 writer->write_shared(
569 mmd->bindinfluences,
570 sizeof(MDefInfluence) * mmd->influences_num,
572 [&]() { writer->write_struct_array(mmd->influences_num, mmd->bindinfluences); });
573
574 /* NOTE: `bindoffset` is abusing `verts_num + 1` as its size, this becomes an incorrect value in
575 * case `verts_num == 0`, since `bindoffset` is then nullptr, not a size 1 allocated array. */
576 if (mmd->verts_num > 0) {
577 writer->write_shared(
578 mmd->bindoffsets,
579 sizeof(int) * (mmd->verts_num + 1),
581 [&]() { writer->write_int32_array(mmd->verts_num + 1, mmd->bindoffsets); });
582 }
583 else {
584 BLI_assert(mmd->bindoffsets == nullptr);
585 }
586
587 writer->write_shared(
588 mmd->bindcagecos,
589 sizeof(float[3]) * mmd->cage_verts_num,
591 [&]() { writer->write_float3_array(mmd->cage_verts_num, mmd->bindcagecos); });
592 writer->write_shared(mmd->dyngrid,
593 sizeof(MDefCell) * size * size * size,
595 [&]() { writer->write_struct_array(size * size * size, mmd->dyngrid); });
596 writer->write_shared(
597 mmd->dyninfluences,
598 sizeof(MDefInfluence) * mmd->influences_num,
600 [&]() { writer->write_struct_array(mmd->influences_num, mmd->dyninfluences); });
601 writer->write_shared(mmd->dynverts,
602 sizeof(MDefInfluence) * mmd->verts_num,
604 [&]() { writer->write_int32_array(mmd->verts_num, mmd->dynverts); });
605
606 writer->write_struct(mmd);
607}
608
609static void blend_read(BlendDataReader *reader, ModifierData *md)
610{
611 MeshDeformModifierData *mmd = reinterpret_cast<MeshDeformModifierData *>(md);
612 const int size = mmd->dyngridsize;
613
614 if (mmd->bindinfluences) {
616 BLO_read_array_and_validate_size(reader, &mmd->bindinfluences, &mmd->influences_num);
617 return mmd->bindinfluences ? implicit_sharing::info_for_mem_free(mmd->bindinfluences) :
618 nullptr;
619 });
620 }
621
622 /* NOTE: `bindoffset` is abusing `verts_num + 1` as its size, this becomes an incorrect value in
623 * case `verts_num == 0`, since `bindoffset` is then nullptr, not a size 1 allocated array. */
624 if (mmd->verts_num > 0) {
625 if (mmd->bindoffsets) {
626 mmd->bindoffsets_sharing_info = BLO_read_shared(reader, &mmd->bindoffsets, [&]() {
627 (void)BLO_read_array(reader, &mmd->bindoffsets, int64_t(mmd->verts_num) + 1);
628 return mmd->bindoffsets ? implicit_sharing::info_for_mem_free(mmd->bindoffsets) : nullptr;
629 });
630 }
631 }
632
633 if (mmd->bindcagecos) {
634 mmd->bindcagecos_sharing_info = BLO_read_shared(reader, &mmd->bindcagecos, [&]() {
635 BLO_read_array_and_validate_size(reader, &mmd->bindcagecos, &mmd->cage_verts_num, 3);
636 return mmd->bindcagecos ? implicit_sharing::info_for_mem_free(mmd->bindcagecos) : nullptr;
637 });
638 }
639 if (mmd->dyngrid) {
640 mmd->dyngrid_sharing_info = BLO_read_shared(reader, &mmd->dyngrid, [&]() {
641 (void)BLO_read_array(reader, &mmd->dyngrid, int64_t(size) * size * size);
642 return mmd->dyngrid ? implicit_sharing::info_for_mem_free(mmd->dyngrid) : nullptr;
643 });
644 }
645 if (mmd->dyninfluences) {
646 mmd->dyninfluences_sharing_info = BLO_read_shared(reader, &mmd->dyninfluences, [&]() {
647 BLO_read_array_and_validate_size(reader, &mmd->dyninfluences, &mmd->influences_num);
648 return mmd->dyninfluences ? implicit_sharing::info_for_mem_free(mmd->dyninfluences) :
649 nullptr;
650 });
651 }
652 if (mmd->dynverts) {
653 mmd->dynverts_sharing_info = BLO_read_shared(reader, &mmd->dynverts, [&]() {
654 BLO_read_array_and_validate_size(reader, &mmd->dynverts, &mmd->verts_num);
655 return mmd->dynverts ? implicit_sharing::info_for_mem_free(mmd->dynverts) : nullptr;
656 });
657 }
658
659 /* Deprecated storage. */
660 if (mmd->bindweights) {
662 }
663 if (mmd->bindcos) {
665 }
666}
667
669 /*idname*/ "MeshDeform",
670 /*name*/ N_("MeshDeform"),
671 /*struct_name*/ "MeshDeformModifierData",
672 /*struct_size*/ sizeof(MeshDeformModifierData),
673 /*srna*/ &RNA_MeshDeformModifier,
677 /*icon*/ ICON_MOD_MESHDEFORM,
678
679 /*copy_data*/ copy_data,
680
681 /*deform_verts*/ deform_verts,
682 /*deform_matrices*/ nullptr,
683 /*deform_verts_EM*/ nullptr,
684 /*deform_matrices_EM*/ nullptr,
685 /*modify_mesh*/ nullptr,
686 /*modify_geometry_set*/ nullptr,
687
688 /*init_data*/ init_data,
689 /*required_data_mask*/ required_data_mask,
690 /*free_data*/ free_data,
691 /*is_disabled*/ is_disabled,
692 /*update_depsgraph*/ update_depsgraph,
693 /*depends_on_time*/ nullptr,
694 /*depends_on_normals*/ nullptr,
695 /*foreach_ID_link*/ foreach_ID_link,
696 /*foreach_tex_link*/ nullptr,
697 /*free_runtime_data*/ nullptr,
698 /*panel_register*/ panel_register,
699 /*blend_write*/ blend_write,
700 /*blend_read*/ blend_read,
701 /*foreach_cache*/ nullptr,
702 /*foreach_working_space_color*/ nullptr,
703};
704
705} // namespace blender
support for deformation groups and hooks.
#define IFACE_(msgid)
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define UI_ITEM_NONE
#define CLAMP(a, b, c)
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
#define CD_MASK_MDEFORMVERT
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
MutableSpan< T > as_mutable_span()
Definition BLI_array.hh:259
const T * data() const
Definition BLI_array.hh:323
constexpr int64_t size() const
Definition BLI_span.hh:499
constexpr T * data() const
Definition BLI_span.hh:545
#define vertex
#define MESHDEFORM_MIN_INFLUENCE
void copy_shared_pointer(T *src_ptr, const ImplicitSharingInfo *src_sharing_info, T **r_dst_ptr, const ImplicitSharingInfo **r_dst_sharing_info)
void free_shared_data(T **data, const ImplicitSharingInfo **sharing_info)
const ImplicitSharingInfo * info_for_mem_free(T *data)
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void mul_m3_v3(const float M[3][3], float r[3])
static void copy_data(const ModifierData *md, ModifierData *target, const int flag)
const ImplicitSharingInfo * BLO_read_shared(BlendDataReader *reader, T **data_ptr, FunctionRef< const ImplicitSharingInfo *()> read_fn)
static void blend_write(BlendWriter *writer, const ID *, const ModifierData *md)
Definition MOD_bevel.cc:454
void BKE_modifier_set_error(const Object *ob, ModifierData *md, const char *format,...) ATTR_PRINTF_FORMAT(3
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
bool DEG_is_active(const Depsgraph *depsgraph)
Definition depsgraph.cc:324
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void MOD_get_vgroup(const Object *ob, const Mesh *mesh, const char *name, const MDeformVert **dvert, int *defgrp_index)
Definition MOD_util.cc:158
static void meshdeform_vert_task(void *__restrict userdata, const int iter, const TaskParallelTLS *__restrict)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
static void init_data(ModifierData *md)
void(*)(void *user_data, Object *ob, ID **idpoin, LibraryForeachIDCallbackFlag cb_flag) IDWalkFunc
static void update_depsgraph(tGraphSliderOp *gso)
static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void BKE_mesh_wrapper_vert_coords_copy(const Mesh *mesh, MutableSpan< float3 > positions)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
void DEG_add_object_relation(DepsNodeHandle *node_handle, Object *object, eDepsObjectComponentType component, const char *description)
void DEG_add_depends_on_transform_relation(DepsNodeHandle *node_handle, const char *description)
MINLINE void mul_v3_fl(float r[3], float f)
static void required_data_mask(ModifierData *, CustomData_MeshMasks *r_cddata_masks)
ModifierTypeInfo modifierType_MeshDeform
Mesh * BKE_modifier_get_evaluated_mesh_from_evaluated_object(Object *ob_eval)
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
void modifier_error_message_draw(ui::Layout &layout, PointerRNA *ptr)
float BKE_defvert_find_weight(const MDeformVert *dvert, int defgroup)
Definition deform.cc:779
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)
static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float(*dco)[3], float vec[3])
BMesh const char void * data
static void free_data(ModifierData *md)
static void panel_register(ARegionType *region_type)
int BKE_mesh_wrapper_vert_len(const Mesh *mesh)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
MINLINE void zero_v3(float r[3])
@ eModifierTypeFlag_AcceptsCVs
@ eModifierTypeFlag_SupportsEditmode
@ eModifierTypeFlag_AcceptsVertexCosOnly
void BLO_read_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size, const int elems=1)
static void blend_read(BlendDataReader *, ModifierData *md)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
static void meshdeformModifier_do(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float(*vertexCos)[3], const int verts_num)
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
@ eModifierFlag_OverrideLibrary_Local
void MOD_previous_vcos_store(ModifierData *md, const float(*vert_coords)[3])
Definition MOD_util.cc:144
static void panel_draw(const bContext *, Panel *panel)
static void deform_verts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, MutableSpan< float3 > positions)
static bool is_disabled(const Scene *, ModifierData *md, bool)
void BKE_modifier_mdef_compact_influences(ModifierData *md)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BKE_modifier_copydata_generic(const ModifierData *md, ModifierData *md_dst, int flag)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void write_shared(const void *data, size_t approximate_size_in_bytes, const ImplicitSharingInfo *sharing_info, FunctionRef< void()> write_fn)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
bool is_undo() const
const ImplicitSharingInfoHandle * bindcagecos_sharing_info
const ImplicitSharingInfoHandle * bindoffsets_sharing_info
const ImplicitSharingInfoHandle * dyngrid_sharing_info
void(*) bindfunc(struct Object *object, struct MeshDeformModifierData *mmd, struct Mesh *cagemesh, float *vertexcos, int verts_num, float cagemat[4][4])
const ImplicitSharingInfoHandle * bindinfluences_sharing_info
const ImplicitSharingInfoHandle * dynverts_sharing_info
const ImplicitSharingInfoHandle * dyninfluences_sharing_info
MeshDeformModifierData * mmd
ui::Layout * layout
void enabled_set(bool enabled)
void use_property_split_set(bool is_sep)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
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)
Layout & column(bool align)
#define N_(msgid)