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