Blender  V3.3
MOD_hook.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2005 Blender Foundation. All rights reserved. */
3 
8 #include "BLI_utildefines.h"
9 
10 #include "BLI_bitmap.h"
11 #include "BLI_math.h"
12 
13 #include "BLT_translation.h"
14 
15 #include "DNA_defaults.h"
16 #include "DNA_mesh_types.h"
17 #include "DNA_meshdata_types.h"
18 #include "DNA_object_types.h"
19 #include "DNA_screen_types.h"
20 
21 #include "BKE_action.h"
22 #include "BKE_colortools.h"
23 #include "BKE_context.h"
24 #include "BKE_deform.h"
25 #include "BKE_editmesh.h"
26 #include "BKE_lib_id.h"
27 #include "BKE_lib_query.h"
28 #include "BKE_mesh.h"
29 #include "BKE_mesh_wrapper.h"
30 #include "BKE_modifier.h"
31 #include "BKE_screen.h"
32 
33 #include "UI_interface.h"
34 #include "UI_resources.h"
35 
36 #include "BLO_read_write.h"
37 
38 #include "RNA_access.h"
39 #include "RNA_prototypes.h"
40 
41 #include "DEG_depsgraph_query.h"
42 
43 #include "MEM_guardedalloc.h"
44 
45 #include "MOD_ui_common.h"
46 #include "MOD_util.h"
47 
48 static void initData(ModifierData *md)
49 {
51 
53 
55 
56  hmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
57 }
58 
59 static void copyData(const ModifierData *md, ModifierData *target, const int flag)
60 {
61  const HookModifierData *hmd = (const HookModifierData *)md;
62  HookModifierData *thmd = (HookModifierData *)target;
63 
64  BKE_modifier_copydata_generic(md, target, flag);
65 
67 
68  thmd->indexar = MEM_dupallocN(hmd->indexar);
69 }
70 
71 static void requiredDataMask(Object *UNUSED(ob),
72  ModifierData *md,
73  CustomData_MeshMasks *r_cddata_masks)
74 {
76 
77  /* ask for vertexgroups if we need them */
78  if (hmd->name[0] != '\0') {
79  r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
80  }
81  if (hmd->indexar != NULL) {
82  /* TODO: check which origindex are actually needed? */
83  r_cddata_masks->vmask |= CD_MASK_ORIGINDEX;
84  r_cddata_masks->emask |= CD_MASK_ORIGINDEX;
85  r_cddata_masks->pmask |= CD_MASK_ORIGINDEX;
86  }
87 }
88 
89 static void freeData(ModifierData *md)
90 {
92 
94 
95  MEM_SAFE_FREE(hmd->indexar);
96 }
97 
98 static bool isDisabled(const struct Scene *UNUSED(scene),
99  ModifierData *md,
100  bool UNUSED(useRenderParams))
101 {
102  HookModifierData *hmd = (HookModifierData *)md;
103 
104  return !hmd->object;
105 }
106 
107 static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
108 {
109  HookModifierData *hmd = (HookModifierData *)md;
110 
111  walk(userData, ob, (ID **)&hmd->object, IDWALK_CB_NOP);
112 }
113 
115 {
116  HookModifierData *hmd = (HookModifierData *)md;
117  if (hmd->object != NULL) {
118  if (hmd->subtarget[0]) {
120  ctx->node, hmd->object, hmd->subtarget, DEG_OB_COMP_BONE, "Hook Modifier");
121  }
122  DEG_add_object_relation(ctx->node, hmd->object, DEG_OB_COMP_TRANSFORM, "Hook Modifier");
123  }
124  /* We need own transformation as well. */
125  DEG_add_modifier_to_transform_relation(ctx->node, "Hook Modifier");
126 }
127 
128 struct HookData_cb {
130 
136 
138 
140  float falloff;
141  float falloff_sq;
142  float fac_orig;
143 
146 
147  float cent[3];
148 
149  float mat_uniform[3][3];
150  float mat[4][4];
151 
153 };
154 
155 static BLI_bitmap *hook_index_array_to_bitmap(HookModifierData *hmd, const int verts_num)
156 {
157  BLI_bitmap *indexar_used = BLI_BITMAP_NEW(verts_num, __func__);
158  int i;
159  int *index_pt;
160  for (i = 0, index_pt = hmd->indexar; i < hmd->indexar_num; i++, index_pt++) {
161  const int j = *index_pt;
162  if (j < verts_num) {
163  BLI_BITMAP_ENABLE(indexar_used, i);
164  }
165  }
166  return indexar_used;
167 }
168 
169 static float hook_falloff(const struct HookData_cb *hd, const float len_sq)
170 {
171  BLI_assert(hd->falloff_sq);
172  if (len_sq > hd->falloff_sq) {
173  return 0.0f;
174  }
175  if (len_sq > 0.0f) {
176  float fac;
177 
178  if (hd->falloff_type == eHook_Falloff_Const) {
179  fac = 1.0f;
180  goto finally;
181  }
182  else if (hd->falloff_type == eHook_Falloff_InvSquare) {
183  /* avoid sqrt below */
184  fac = 1.0f - (len_sq / hd->falloff_sq);
185  goto finally;
186  }
187 
188  fac = 1.0f - (sqrtf(len_sq) / hd->falloff);
189 
190  /* closely match PROP_SMOOTH and similar */
191  switch (hd->falloff_type) {
192 #if 0
193  case eHook_Falloff_None:
194  fac = 1.0f;
195  break;
196 #endif
197  case eHook_Falloff_Curve:
198  fac = BKE_curvemapping_evaluateF(hd->curfalloff, 0, fac);
199  break;
200  case eHook_Falloff_Sharp:
201  fac = fac * fac;
202  break;
204  fac = 3.0f * fac * fac - 2.0f * fac * fac * fac;
205  break;
206  case eHook_Falloff_Root:
207  fac = sqrtf(fac);
208  break;
210  /* pass */
211  break;
212 #if 0
213  case eHook_Falloff_Const:
214  fac = 1.0f;
215  break;
216 #endif
218  fac = sqrtf(2 * fac - fac * fac);
219  break;
220 #if 0
222  fac = fac * (2.0f - fac);
223  break;
224 #endif
225  }
226 
227  finally:
228  return fac * hd->fac_orig;
229  }
230  else {
231  return hd->fac_orig;
232  }
233 }
234 
235 static void hook_co_apply(struct HookData_cb *hd, int j, const MDeformVert *dv)
236 {
237  float *co = hd->vertexCos[j];
238  float fac;
239 
240  if (hd->use_falloff) {
241  float len_sq;
242 
243  if (hd->use_uniform) {
244  float co_uniform[3];
245  mul_v3_m3v3(co_uniform, hd->mat_uniform, co);
246  len_sq = len_squared_v3v3(hd->cent, co_uniform);
247  }
248  else {
249  len_sq = len_squared_v3v3(hd->cent, co);
250  }
251 
252  fac = hook_falloff(hd, len_sq);
253  }
254  else {
255  fac = hd->fac_orig;
256  }
257 
258  if (fac) {
259  if (dv != NULL) {
260  fac *= hd->invert_vgroup ? 1.0f - BKE_defvert_find_weight(dv, hd->defgrp_index) :
262  }
263 
264  if (fac) {
265  float co_tmp[3];
266  mul_v3_m4v3(co_tmp, hd->mat, co);
267  interp_v3_v3v3(co, co, co_tmp, fac);
268  }
269  }
270 }
271 
273  const ModifierEvalContext *UNUSED(ctx),
274  Object *ob,
275  Mesh *mesh,
276  BMEditMesh *em,
277  float (*vertexCos)[3],
278  int verts_num)
279 {
280  Object *ob_target = hmd->object;
281  bPoseChannel *pchan = BKE_pose_channel_find_name(ob_target->pose, hmd->subtarget);
282  float dmat[4][4];
283  int i, *index_pt;
284  MDeformVert *dvert;
285  struct HookData_cb hd;
286  const bool invert_vgroup = (hmd->flag & MOD_HOOK_INVERT_VGROUP) != 0;
287 
288  if (hmd->curfalloff == NULL) {
289  /* should never happen, but bad lib linking could cause it */
290  hmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
291  }
292 
293  if (hmd->curfalloff) {
295  }
296 
297  /* Generic data needed for applying per-vertex calculations (initialize all members) */
298  hd.vertexCos = vertexCos;
299 
300  MOD_get_vgroup(ob, mesh, hmd->name, &dvert, &hd.defgrp_index);
301  int cd_dvert_offset = -1;
302 
303  if (hd.defgrp_index != -1) {
304  /* Edit-mesh. */
305  if (em != NULL) {
306  cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
307  if (cd_dvert_offset == -1) {
308  hd.defgrp_index = -1;
309  }
310  }
311  else {
312  /* Regular mesh. */
313  if (dvert == NULL) {
314  hd.defgrp_index = -1;
315  }
316  }
317  }
318 
319  hd.curfalloff = hmd->curfalloff;
320 
321  hd.falloff_type = hmd->falloff_type;
322  hd.falloff = (hmd->falloff_type == eHook_Falloff_None) ? 0.0f : hmd->falloff;
323  hd.falloff_sq = square_f(hd.falloff);
324  hd.fac_orig = hmd->force;
325 
326  hd.use_falloff = (hd.falloff_sq != 0.0f);
327  hd.use_uniform = (hmd->flag & MOD_HOOK_UNIFORM_SPACE) != 0;
328 
330 
331  if (hd.use_uniform) {
332  copy_m3_m4(hd.mat_uniform, hmd->parentinv);
333  mul_v3_m3v3(hd.cent, hd.mat_uniform, hmd->cent);
334  }
335  else {
336  unit_m3(hd.mat_uniform); /* unused */
337  copy_v3_v3(hd.cent, hmd->cent);
338  }
339 
340  /* get world-space matrix of target, corrected for the space the verts are in */
341  if (hmd->subtarget[0] && pchan) {
342  /* bone target if there's a matching pose-channel */
343  mul_m4_m4m4(dmat, ob_target->obmat, pchan->pose_mat);
344  }
345  else {
346  /* just object target */
347  copy_m4_m4(dmat, ob_target->obmat);
348  }
349  invert_m4_m4(ob->imat, ob->obmat);
350  mul_m4_series(hd.mat, ob->imat, dmat, hmd->parentinv);
351  /* --- done with 'hd' init --- */
352 
353  /* Regarding index range checking below.
354  *
355  * This should always be true and I don't generally like
356  * "paranoid" style code like this, but old files can have
357  * indices that are out of range because old blender did
358  * not correct them on exit edit-mode. - zr
359  */
360 
361  if (hmd->force == 0.0f) {
362  /* do nothing, avoid annoying checks in the loop */
363  }
364  else if (hmd->indexar) { /* vertex indices? */
365  const int *origindex_ar;
366  /* if mesh is present and has original index data, use it */
367  if (mesh && (origindex_ar = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX))) {
368  int verts_orig_num = verts_num;
369  if (ob->type == OB_MESH) {
370  const Mesh *me_orig = ob->data;
371  verts_orig_num = me_orig->totvert;
372  }
373  BLI_bitmap *indexar_used = hook_index_array_to_bitmap(hmd, verts_orig_num);
374  for (i = 0; i < verts_num; i++) {
375  int i_orig = origindex_ar[i];
376  BLI_assert(i_orig < verts_orig_num);
377  if (BLI_BITMAP_TEST(indexar_used, i_orig)) {
378  hook_co_apply(&hd, i, dvert ? &dvert[i] : NULL);
379  }
380  }
381  MEM_freeN(indexar_used);
382  }
383  else { /* missing mesh or ORIGINDEX */
384  if ((em != NULL) && (hd.defgrp_index != -1)) {
385  BLI_assert(em->bm->totvert == verts_num);
386  BLI_bitmap *indexar_used = hook_index_array_to_bitmap(hmd, verts_num);
387  BMIter iter;
388  BMVert *v;
389  BM_ITER_MESH_INDEX (v, &iter, em->bm, BM_VERTS_OF_MESH, i) {
390  if (BLI_BITMAP_TEST(indexar_used, i)) {
391  const MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(v, cd_dvert_offset);
392  hook_co_apply(&hd, i, dv);
393  }
394  }
395  MEM_freeN(indexar_used);
396  }
397  else {
398  for (i = 0, index_pt = hmd->indexar; i < hmd->indexar_num; i++, index_pt++) {
399  const int j = *index_pt;
400  if (j < verts_num) {
401  hook_co_apply(&hd, j, dvert ? &dvert[j] : NULL);
402  }
403  }
404  }
405  }
406  }
407  else if (hd.defgrp_index != -1) { /* vertex group hook */
408  if (em != NULL) {
409  BLI_assert(em->bm->totvert == verts_num);
410  BMIter iter;
411  BMVert *v;
412  BM_ITER_MESH_INDEX (v, &iter, em->bm, BM_VERTS_OF_MESH, i) {
413  const MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(v, cd_dvert_offset);
414  hook_co_apply(&hd, i, dv);
415  }
416  }
417  else {
418  BLI_assert(dvert != NULL);
419  for (i = 0; i < verts_num; i++) {
420  hook_co_apply(&hd, i, &dvert[i]);
421  }
422  }
423  }
424 }
425 
426 static void deformVerts(struct ModifierData *md,
427  const struct ModifierEvalContext *ctx,
428  struct Mesh *mesh,
429  float (*vertexCos)[3],
430  int verts_num)
431 {
432  HookModifierData *hmd = (HookModifierData *)md;
433  Mesh *mesh_src = MOD_deform_mesh_eval_get(
434  ctx->object, NULL, mesh, NULL, verts_num, false, false);
435 
436  deformVerts_do(hmd, ctx, ctx->object, mesh_src, NULL, vertexCos, verts_num);
437 
438  if (!ELEM(mesh_src, NULL, mesh)) {
439  BKE_id_free(NULL, mesh_src);
440  }
441 }
442 
443 static void deformVertsEM(struct ModifierData *md,
444  const struct ModifierEvalContext *ctx,
445  struct BMEditMesh *editData,
446  struct Mesh *mesh,
447  float (*vertexCos)[3],
448  int verts_num)
449 {
450  HookModifierData *hmd = (HookModifierData *)md;
451 
452  deformVerts_do(hmd, ctx, ctx->object, mesh, mesh ? NULL : editData, vertexCos, verts_num);
453 }
454 
455 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
456 {
457  uiLayout *row, *col;
458  uiLayout *layout = panel->layout;
459 
460  PointerRNA ob_ptr;
462 
463  PointerRNA hook_object_ptr = RNA_pointer_get(ptr, "object");
464 
465  uiLayoutSetPropSep(layout, true);
466 
467  col = uiLayoutColumn(layout, false);
468  uiItemR(col, ptr, "object", 0, NULL, ICON_NONE);
469  if (!RNA_pointer_is_null(&hook_object_ptr) &&
470  RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) {
471  PointerRNA hook_object_data_ptr = RNA_pointer_get(&hook_object_ptr, "data");
473  col, ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE);
474  }
475  modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL);
476 
477  uiItemR(layout, ptr, "strength", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
478 
479  if (RNA_enum_get(&ob_ptr, "mode") == OB_MODE_EDIT) {
480  row = uiLayoutRow(layout, true);
481  uiItemO(row, IFACE_("Reset"), ICON_NONE, "OBJECT_OT_hook_reset");
482  uiItemO(row, IFACE_("Recenter"), ICON_NONE, "OBJECT_OT_hook_recenter");
483  row = uiLayoutRow(layout, true);
484  uiItemO(row, IFACE_("Select"), ICON_NONE, "OBJECT_OT_hook_select");
485  uiItemO(row, IFACE_("Assign"), ICON_NONE, "OBJECT_OT_hook_assign");
486  }
487 
488  modifier_panel_end(layout, ptr);
489 }
490 
491 static void falloff_panel_draw(const bContext *UNUSED(C), Panel *panel)
492 {
493  uiLayout *row;
494  uiLayout *layout = panel->layout;
495 
497 
498  bool use_falloff = RNA_enum_get(ptr, "falloff_type") != eWarp_Falloff_None;
499 
500  uiLayoutSetPropSep(layout, true);
501 
502  uiItemR(layout, ptr, "falloff_type", 0, IFACE_("Type"), ICON_NONE);
503 
504  row = uiLayoutRow(layout, false);
506  uiItemR(row, ptr, "falloff_radius", 0, NULL, ICON_NONE);
507 
508  uiItemR(layout, ptr, "use_falloff_uniform", 0, NULL, ICON_NONE);
509 
510  if (RNA_enum_get(ptr, "falloff_type") == eWarp_Falloff_Curve) {
511  uiTemplateCurveMapping(layout, ptr, "falloff_curve", 0, false, false, false, false);
512  }
513 }
514 
515 static void panelRegister(ARegionType *region_type)
516 {
517  PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Hook, panel_draw);
519  region_type, "falloff", "Falloff", NULL, falloff_panel_draw, panel_type);
520 }
521 
522 static void blendWrite(BlendWriter *writer, const ID *UNUSED(id_owner), const ModifierData *md)
523 {
524  const HookModifierData *hmd = (const HookModifierData *)md;
525 
526  BLO_write_struct(writer, HookModifierData, hmd);
527 
528  if (hmd->curfalloff) {
530  }
531 
532  BLO_write_int32_array(writer, hmd->indexar_num, hmd->indexar);
533 }
534 
535 static void blendRead(BlendDataReader *reader, ModifierData *md)
536 {
537  HookModifierData *hmd = (HookModifierData *)md;
538 
539  BLO_read_data_address(reader, &hmd->curfalloff);
540  if (hmd->curfalloff) {
542  }
543 
544  BLO_read_int32_array(reader, hmd->indexar_num, &hmd->indexar);
545 }
546 
548  /* name */ N_("Hook"),
549  /* structName */ "HookModifierData",
550  /* structSize */ sizeof(HookModifierData),
551  /* srna */ &RNA_HookModifier,
552  /* type */ eModifierTypeType_OnlyDeform,
555  /* icon */ ICON_HOOK,
556  /* copyData */ copyData,
557 
558  /* deformVerts */ deformVerts,
559  /* deformMatrices */ NULL,
560  /* deformVertsEM */ deformVertsEM,
561  /* deformMatricesEM */ NULL,
562  /* modifyMesh */ NULL,
563  /* modifyGeometrySet */ NULL,
564 
565  /* initData */ initData,
566  /* requiredDataMask */ requiredDataMask,
567  /* freeData */ freeData,
568  /* isDisabled */ isDisabled,
569  /* updateDepsgraph */ updateDepsgraph,
570  /* dependsOnTime */ NULL,
571  /* dependsOnNormals */ NULL,
572  /* foreachIDLink */ foreachIDLink,
573  /* foreachTexLink */ NULL,
574  /* freeRuntimeData */ NULL,
575  /* panelRegister */ panelRegister,
576  /* blendWrite */ blendWrite,
577  /* blendRead */ blendRead,
578 };
typedef float(TangentPoint)[2]
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
void BKE_curvemapping_init(struct CurveMapping *cumap)
Definition: colortools.c:1235
struct CurveMapping * BKE_curvemapping_copy(const struct CurveMapping *cumap)
float BKE_curvemapping_evaluateF(const struct CurveMapping *cumap, int cur, float value)
void BKE_curvemapping_blend_read(struct BlendDataReader *reader, struct CurveMapping *cumap)
Definition: colortools.c:1300
void BKE_curvemapping_blend_write(struct BlendWriter *writer, const struct CurveMapping *cumap)
void BKE_curvemapping_free(struct CurveMapping *cumap)
Definition: colortools.c:103
struct CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition: colortools.c:72
void * CustomData_get_layer(const struct CustomData *data, int type)
int CustomData_get_offset(const struct CustomData *data, int type)
support for deformation groups and hooks.
float BKE_defvert_find_weight(const struct MDeformVert *dvert, int defgroup)
Definition: deform.c:704
void BKE_id_free(struct Main *bmain, void *idv)
@ IDWALK_CB_NOP
Definition: BKE_lib_query.h:33
void(* IDWalkFunc)(void *userData, struct Object *ob, struct ID **idpoin, int cb_flag)
Definition: BKE_modifier.h:107
@ eModifierTypeFlag_AcceptsCVs
Definition: BKE_modifier.h:67
@ eModifierTypeFlag_SupportsEditmode
Definition: BKE_modifier.h:69
@ eModifierTypeFlag_AcceptsVertexCosOnly
Definition: BKE_modifier.h:100
void BKE_modifier_copydata_generic(const struct ModifierData *md, struct ModifierData *md_dst, int flag)
@ eModifierTypeType_OnlyDeform
Definition: BKE_modifier.h:44
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_BITMAP_NEW(_num, _alloc_string)
Definition: BLI_bitmap.h:40
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition: BLI_bitmap.h:64
#define BLI_BITMAP_ENABLE(_bitmap, _index)
Definition: BLI_bitmap.h:81
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:16
MINLINE float square_f(float a)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:259
void unit_m3(float m[3][3])
Definition: math_matrix.c:40
void copy_m3_m4(float m1[3][3], const float m2[4][4])
Definition: math_matrix.c:87
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1287
#define mul_m4_series(...)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:739
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
Definition: math_matrix.c:897
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3(float r[3], const float a[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
Definition: math_vector.c:29
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNUSED(x)
#define ELEM(...)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define BLO_read_data_address(reader, ptr_p)
void BLO_write_int32_array(BlendWriter *writer, uint num, const int32_t *data_ptr)
Definition: writefile.c:1571
void BLO_read_int32_array(BlendDataReader *reader, int array_size, int32_t **ptr_p)
Definition: readfile.c:5177
#define BLO_write_struct(writer, struct_name, data_ptr)
#define IFACE_(msgid)
void DEG_add_object_relation(struct DepsNodeHandle *node_handle, struct Object *object, eDepsObjectComponentType component, const char *description)
void DEG_add_modifier_to_transform_relation(struct DepsNodeHandle *node_handle, const char *description)
@ DEG_OB_COMP_TRANSFORM
@ DEG_OB_COMP_BONE
void DEG_add_bone_relation(struct DepsNodeHandle *handle, struct Object *object, const char *bone_name, eDepsObjectComponentType component, const char *description)
#define CD_MASK_ORIGINDEX
#define CD_MASK_MDEFORMVERT
@ CD_MDEFORMVERT
@ CD_ORIGINDEX
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:29
@ eWarp_Falloff_Curve
@ eWarp_Falloff_None
struct HookModifierData HookModifierData
@ MOD_HOOK_UNIFORM_SPACE
@ MOD_HOOK_INVERT_VGROUP
@ eModifierType_Hook
@ eHook_Falloff_Curve
@ eHook_Falloff_Sharp
@ eHook_Falloff_Smooth
@ eHook_Falloff_Sphere
@ eHook_Falloff_Root
@ eHook_Falloff_None
@ eHook_Falloff_InvSquare
@ eHook_Falloff_Const
@ eHook_Falloff_Linear
@ OB_MODE_EDIT
Object is a sort of wrapper for general info.
@ OB_ARMATURE
@ OB_MESH
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
static void hook_co_apply(struct HookData_cb *hd, int j, const MDeformVert *dv)
Definition: MOD_hook.c:235
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
Definition: MOD_hook.c:59
static void deformVerts(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh, float(*vertexCos)[3], int verts_num)
Definition: MOD_hook.c:426
static BLI_bitmap * hook_index_array_to_bitmap(HookModifierData *hmd, const int verts_num)
Definition: MOD_hook.c:155
static void falloff_panel_draw(const bContext *UNUSED(C), Panel *panel)
Definition: MOD_hook.c:491
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
Definition: MOD_hook.c:114
static void deformVertsEM(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct BMEditMesh *editData, struct Mesh *mesh, float(*vertexCos)[3], int verts_num)
Definition: MOD_hook.c:443
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
Definition: MOD_hook.c:98
static void blendRead(BlendDataReader *reader, ModifierData *md)
Definition: MOD_hook.c:535
ModifierTypeInfo modifierType_Hook
Definition: MOD_hook.c:547
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
Definition: MOD_hook.c:107
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
Definition: MOD_hook.c:455
static void initData(ModifierData *md)
Definition: MOD_hook.c:48
static float hook_falloff(const struct HookData_cb *hd, const float len_sq)
Definition: MOD_hook.c:169
static void panelRegister(ARegionType *region_type)
Definition: MOD_hook.c:515
static void deformVerts_do(HookModifierData *hmd, const ModifierEvalContext *UNUSED(ctx), Object *ob, Mesh *mesh, BMEditMesh *em, float(*vertexCos)[3], int verts_num)
Definition: MOD_hook.c:272
static void blendWrite(BlendWriter *writer, const ID *UNUSED(id_owner), const ModifierData *md)
Definition: MOD_hook.c:522
static void freeData(ModifierData *md)
Definition: MOD_hook.c:89
static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
Definition: MOD_hook.c:71
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
void modifier_panel_end(uiLayout *layout, PointerRNA *ptr)
Definition: MOD_ui_common.c:91
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
void modifier_vgroup_ui(uiLayout *layout, PointerRNA *ptr, PointerRNA *ob_ptr, const char *vgroup_prop, const char *invert_vgroup_prop, const char *text)
PanelType * modifier_subpanel_register(ARegionType *region_type, const char *name, const char *label, PanelDrawFn draw_header, PanelDrawFn draw, PanelType *parent)
Mesh * MOD_deform_mesh_eval_get(Object *ob, struct BMEditMesh *em, Mesh *mesh, const float(*vertexCos)[3], const int verts_num, const bool use_normals, const bool use_orco)
Definition: MOD_util.c:167
void MOD_get_vgroup(Object *ob, struct Mesh *mesh, const char *name, MDeformVert **dvert, int *defgrp_index)
Definition: MOD_util.c:235
#define C
Definition: RandGen.cpp:25
void uiLayoutSetActive(uiLayout *layout, bool active)
void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, bool levels, bool brush, bool neg_slope, bool tone)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
@ UI_ITEM_R_SLIDER
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
Definition: bmesh_class.h:541
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
@ BM_VERTS_OF_MESH
ATTR_WARN_UNUSED_RESULT const BMVert * v
Scene scene
uint col
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
#define sqrtf(x)
Definition: metal/compat.h:243
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5167
bool RNA_pointer_is_null(const PointerRNA *ptr)
Definition: rna_access.c:164
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
struct BMesh * bm
Definition: BKE_editmesh.h:40
int totvert
Definition: bmesh_class.h:297
CustomData vdata
Definition: bmesh_class.h:337
char falloff_type
Definition: MOD_hook.c:139
uint use_uniform
Definition: MOD_hook.c:145
float mat_uniform[3][3]
Definition: MOD_hook.c:149
float cent[3]
Definition: MOD_hook.c:147
bool invert_vgroup
Definition: MOD_hook.c:152
float fac_orig
Definition: MOD_hook.c:142
float falloff_sq
Definition: MOD_hook.c:141
float(* vertexCos)[3]
Definition: MOD_hook.c:129
float mat[4][4]
Definition: MOD_hook.c:150
uint use_falloff
Definition: MOD_hook.c:144
struct CurveMapping * curfalloff
Definition: MOD_hook.c:137
float falloff
Definition: MOD_hook.c:140
int defgrp_index
Definition: MOD_hook.c:135
struct CurveMapping * curfalloff
struct Object * object
Definition: DNA_ID.h:368
CustomData vdata
int totvert
struct Object * object
Definition: BKE_modifier.h:141
struct DepsNodeHandle * node
Definition: BKE_modifier.h:134
struct bPose * pose
float imat[4][4]
float obmat[4][4]
void * data
struct uiLayout * layout
float pose_mat[4][4]
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480