Blender  V3.3
crazyspace.cc
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 "MEM_guardedalloc.h"
9 
10 #include "DNA_mesh_types.h"
11 #include "DNA_meshdata_types.h"
12 #include "DNA_modifier_types.h"
13 #include "DNA_object_types.h"
14 #include "DNA_scene_types.h"
15 
16 #include "BLI_bitmap.h"
17 #include "BLI_linklist.h"
18 #include "BLI_utildefines.h"
19 
20 #include "BKE_DerivedMesh.h"
21 #include "BKE_crazyspace.h"
22 #include "BKE_crazyspace.hh"
23 #include "BKE_curves.hh"
24 #include "BKE_editmesh.h"
25 #include "BKE_geometry_set.hh"
26 #include "BKE_lib_id.h"
27 #include "BKE_mesh.h"
28 #include "BKE_mesh_wrapper.h"
29 #include "BKE_modifier.h"
30 #include "BKE_multires.h"
31 #include "BKE_report.h"
32 
33 #include "DEG_depsgraph_query.h"
34 
35 BLI_INLINE void tan_calc_quat_v3(float r_quat[4],
36  const float co_1[3],
37  const float co_2[3],
38  const float co_3[3])
39 {
40  float vec_u[3], vec_v[3];
41  float nor[3];
42 
43  sub_v3_v3v3(vec_u, co_1, co_2);
44  sub_v3_v3v3(vec_v, co_1, co_3);
45 
46  cross_v3_v3v3(nor, vec_u, vec_v);
47 
48  if (normalize_v3(nor) > FLT_EPSILON) {
49  const float zero_vec[3] = {0.0f};
50  tri_to_quat_ex(r_quat, zero_vec, vec_u, vec_v, nor);
51  }
52  else {
53  unit_qt(r_quat);
54  }
55 }
56 
57 static void set_crazy_vertex_quat(float r_quat[4],
58  const float co_1[3],
59  const float co_2[3],
60  const float co_3[3],
61  const float vd_1[3],
62  const float vd_2[3],
63  const float vd_3[3])
64 {
65  float q1[4], q2[4];
66 
67  tan_calc_quat_v3(q1, co_1, co_2, co_3);
68  tan_calc_quat_v3(q2, vd_1, vd_2, vd_3);
69 
70  sub_qt_qtqt(r_quat, q2, q1);
71 }
72 
74 {
75  bool disabled = false;
76  int cageIndex = BKE_modifiers_get_cage_index(scene, ob, nullptr, 1);
77 
78  ModifierData *md = static_cast<ModifierData *>(ob->modifiers.first);
79  for (int i = 0; md && i <= cageIndex; i++, md = md->next) {
80  if (md->type == eModifierType_Subsurf) {
82  disabled = true;
83  }
84  }
85 
86  return disabled;
87 }
88 
90 {
93  Object *obedit_eval = DEG_get_evaluated_object(depsgraph, obedit);
94  Mesh *mesh_eval = static_cast<Mesh *>(obedit_eval->data);
95  BMEditMesh *editmesh_eval = mesh_eval->edit_mesh;
96 
97  /* disable subsurf temporal, get mapped cos, and enable it */
98  if (modifiers_disable_subsurf_temporary(scene_eval, obedit_eval)) {
99  /* Need to make new derived-mesh. */
100  makeDerivedMesh(depsgraph, scene_eval, obedit_eval, &CD_MASK_BAREMESH);
101  }
102 
103  /* now get the cage */
104  Mesh *mesh_eval_cage = editbmesh_get_eval_cage_from_orig(
105  depsgraph, scene, obedit, &CD_MASK_BAREMESH);
106 
107  const int nverts = editmesh_eval->bm->totvert;
108  float(*vertexcos)[3] = static_cast<float(*)[3]>(
109  MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map"));
110  mesh_get_mapped_verts_coords(mesh_eval_cage, vertexcos, nverts);
111 
112  /* set back the flag, no new cage needs to be built, transform does it */
113  modifiers_disable_subsurf_temporary(scene_eval, obedit_eval);
114 
115  return vertexcos;
116 }
117 
119  float (*origcos)[3],
120  float (*mappedcos)[3],
121  float (*quats)[4],
122  const bool use_select)
123 {
124  BMFace *f;
125  BMIter iter;
126  int index;
127 
128  {
129  BMVert *v;
130  BM_ITER_MESH_INDEX (v, &iter, em->bm, BM_VERTS_OF_MESH, index) {
132  BM_elem_index_set(v, index); /* set_inline */
133  }
134  em->bm->elem_index_dirty &= ~BM_VERT;
135  }
136 
137  BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
138  BMLoop *l_iter, *l_first;
139 
140  l_iter = l_first = BM_FACE_FIRST_LOOP(f);
141  do {
142  if (BM_elem_flag_test(l_iter->v, BM_ELEM_HIDDEN) ||
143  BM_elem_flag_test(l_iter->v, BM_ELEM_TAG) ||
144  (use_select && !BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT))) {
145  continue;
146  }
147 
148  if (!BM_elem_flag_test(l_iter->v, BM_ELEM_TAG)) {
149  const float *co_prev, *co_curr, *co_next; /* orig */
150  const float *vd_prev, *vd_curr, *vd_next; /* deform */
151 
152  const int i_prev = BM_elem_index_get(l_iter->prev->v);
153  const int i_curr = BM_elem_index_get(l_iter->v);
154  const int i_next = BM_elem_index_get(l_iter->next->v);
155 
156  /* retrieve mapped coordinates */
157  vd_prev = mappedcos[i_prev];
158  vd_curr = mappedcos[i_curr];
159  vd_next = mappedcos[i_next];
160 
161  if (origcos) {
162  co_prev = origcos[i_prev];
163  co_curr = origcos[i_curr];
164  co_next = origcos[i_next];
165  }
166  else {
167  co_prev = l_iter->prev->v->co;
168  co_curr = l_iter->v->co;
169  co_next = l_iter->next->v->co;
170  }
171 
172  set_crazy_vertex_quat(quats[i_curr], co_curr, co_next, co_prev, vd_curr, vd_next, vd_prev);
173 
175  }
176  } while ((l_iter = l_iter->next) != l_first);
177  }
178 }
179 
181  float (*origcos)[3],
182  float (*mappedcos)[3],
183  float (*quats)[4])
184 {
185  BLI_bitmap *vert_tag = BLI_BITMAP_NEW(me->totvert, __func__);
186 
187  /* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */
188  MVert *mvert = me->mvert;
189  MPoly *mp = me->mpoly;
190  MLoop *mloop = me->mloop;
191 
192  for (int i = 0; i < me->totpoly; i++, mp++) {
193  MLoop *ml_next = &mloop[mp->loopstart];
194  MLoop *ml_curr = &ml_next[mp->totloop - 1];
195  MLoop *ml_prev = &ml_next[mp->totloop - 2];
196 
197  for (int j = 0; j < mp->totloop; j++) {
198  if (!BLI_BITMAP_TEST(vert_tag, ml_curr->v)) {
199  const float *co_prev, *co_curr, *co_next; /* orig */
200  const float *vd_prev, *vd_curr, *vd_next; /* deform */
201 
202  /* retrieve mapped coordinates */
203  vd_prev = mappedcos[ml_prev->v];
204  vd_curr = mappedcos[ml_curr->v];
205  vd_next = mappedcos[ml_next->v];
206 
207  if (origcos) {
208  co_prev = origcos[ml_prev->v];
209  co_curr = origcos[ml_curr->v];
210  co_next = origcos[ml_next->v];
211  }
212  else {
213  co_prev = mvert[ml_prev->v].co;
214  co_curr = mvert[ml_curr->v].co;
215  co_next = mvert[ml_next->v].co;
216  }
217 
219  quats[ml_curr->v], co_curr, co_next, co_prev, vd_curr, vd_next, vd_prev);
220 
221  BLI_BITMAP_ENABLE(vert_tag, ml_curr->v);
222  }
223 
224  ml_prev = ml_curr;
225  ml_curr = ml_next;
226  ml_next++;
227  }
228  }
229 
230  MEM_freeN(vert_tag);
231 }
232 
234  Scene *scene,
235  Object *ob,
236  BMEditMesh *em,
237  float (**deformmats)[3][3],
238  float (**deformcos)[3])
239 {
240  ModifierData *md;
241  Mesh *me_input = static_cast<Mesh *>(ob->data);
242  Mesh *me = nullptr;
243  int i, a, modifiers_left_num = 0, verts_num = 0;
244  int cageIndex = BKE_modifiers_get_cage_index(scene, ob, nullptr, 1);
245  float(*defmats)[3][3] = nullptr, (*deformedVerts)[3] = nullptr;
246  VirtualModifierData virtualModifierData;
248 
250 
251  md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData);
252 
253  /* compute the deformation matrices and coordinates for the first
254  * modifiers with on cage editing that are enabled and support computing
255  * deform matrices */
256  for (i = 0; md && i <= cageIndex; i++, md = md->next) {
257  const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type));
258 
259  if (!editbmesh_modifier_is_enabled(scene, ob, md, me != nullptr)) {
260  continue;
261  }
262 
263  if (mti->type == eModifierTypeType_OnlyDeform && mti->deformMatricesEM) {
264  if (!defmats) {
265  const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
266  CustomData_MeshMasks cd_mask_extra = CD_MASK_BAREMESH;
268  scene, ob, md, &cd_mask_extra, required_mode, nullptr, nullptr);
269  cd_mask_extra = datamasks->mask;
270  BLI_linklist_free((LinkNode *)datamasks, nullptr);
271 
272  me = BKE_mesh_wrapper_from_editmesh_with_coords(em, &cd_mask_extra, nullptr, me_input);
273  deformedVerts = editbmesh_vert_coords_alloc(em, &verts_num);
274  defmats = static_cast<float(*)[3][3]>(
275  MEM_mallocN(sizeof(*defmats) * verts_num, "defmats"));
276 
277  for (a = 0; a < verts_num; a++) {
278  unit_m3(defmats[a]);
279  }
280  }
281  mti->deformMatricesEM(md, &mectx, em, me, deformedVerts, defmats, verts_num);
282  }
283  else {
284  break;
285  }
286  }
287 
288  for (; md && i <= cageIndex; md = md->next, i++) {
289  if (editbmesh_modifier_is_enabled(scene, ob, md, me != nullptr) &&
291  modifiers_left_num++;
292  }
293  }
294 
295  if (me) {
296  BKE_id_free(nullptr, me);
297  }
298 
299  *deformmats = defmats;
300  *deformcos = deformedVerts;
301 
302  return modifiers_left_num;
303 }
304 
313  Object *object,
314  Object *object_crazy)
315 {
316  Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
317  *object_crazy = blender::dna::shallow_copy(*object_eval);
318  if (object_crazy->runtime.data_orig != nullptr) {
319  object_crazy->data = object_crazy->runtime.data_orig;
320  }
321 }
322 
324  float (**deformmats)[3][3],
325  float (**deformcos)[3])
326 {
327  int verts_num;
328  *deformcos = BKE_mesh_vert_coords_alloc(mesh, &verts_num);
329  *deformmats = static_cast<float(*)[3][3]>(
330  MEM_callocN(sizeof(**deformmats) * verts_num, "defmats"));
331  for (int a = 0; a < verts_num; a++) {
332  unit_m3((*deformmats)[a]);
333  }
334  BLI_assert(verts_num == mesh->totvert);
335 }
336 
338 {
340  return true;
341  }
342  const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type));
343  return (mti->type == eModifierTypeType_OnlyDeform);
344 }
345 
347 {
348  const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type));
349  return (mti->type == eModifierTypeType_OnlyDeform);
350 }
351 
353  Scene *scene,
354  Object *object,
355  float (**deformmats)[3][3],
356  float (**deformcos)[3])
357 {
358  ModifierData *md;
359  Mesh *me_eval = nullptr;
360  float(*defmats)[3][3] = nullptr, (*deformedVerts)[3] = nullptr;
361  int modifiers_left_num = 0;
362  VirtualModifierData virtualModifierData;
363  Object object_eval;
364  crazyspace_init_object_for_eval(depsgraph, object, &object_eval);
365  MultiresModifierData *mmd = get_multires_modifier(scene, &object_eval, 0);
366  const bool is_sculpt_mode = (object->mode & OB_MODE_SCULPT) != 0;
367  const bool has_multires = mmd != nullptr && mmd->sculptlvl > 0;
368  const ModifierEvalContext mectx = {depsgraph, &object_eval, ModifierApplyFlag(0)};
369 
370  if (is_sculpt_mode && has_multires) {
371  *deformmats = nullptr;
372  *deformcos = nullptr;
373  return modifiers_left_num;
374  }
375 
376  md = BKE_modifiers_get_virtual_modifierlist(&object_eval, &virtualModifierData);
377 
378  for (; md; md = md->next) {
380  continue;
381  }
382 
384  const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type));
385  if (defmats == nullptr) {
386  /* NOTE: Evaluated object is re-set to its original un-deformed state. */
387  Mesh *me = static_cast<Mesh *>(object_eval.data);
388  me_eval = BKE_mesh_copy_for_eval(me, true);
389  crazyspace_init_verts_and_matrices(me_eval, &defmats, &deformedVerts);
390  }
391 
392  if (mti->deformMatrices) {
393  mti->deformMatrices(md, &mectx, me_eval, deformedVerts, defmats, me_eval->totvert);
394  }
395  else {
396  /* More complex handling will continue in BKE_crazyspace_build_sculpt.
397  * Exiting the loop on a non-deform modifier causes issues - T71213. */
399  break;
400  }
401  }
402  }
403 
404  for (; md; md = md->next) {
406  continue;
407  }
408 
410  modifiers_left_num++;
411  }
412  }
413 
414  if (me_eval != nullptr) {
415  BKE_id_free(nullptr, me_eval);
416  }
417 
418  *deformmats = defmats;
419  *deformcos = deformedVerts;
420 
421  return modifiers_left_num;
422 }
423 
425  Scene *scene,
426  Object *object,
427  float (**deformmats)[3][3],
428  float (**deformcos)[3])
429 {
431  depsgraph, scene, object, deformmats, deformcos);
432 
433  if (totleft) {
434  /* There are deformation modifier which doesn't support deformation matrices calculation.
435  * Need additional crazy-space correction. */
436 
437  Mesh *mesh = (Mesh *)object->data;
438  Mesh *mesh_eval = nullptr;
439 
440  if (*deformcos == nullptr) {
441  crazyspace_init_verts_and_matrices(mesh, deformmats, deformcos);
442  }
443 
444  float(*deformedVerts)[3] = *deformcos;
445  float(*origVerts)[3] = static_cast<float(*)[3]>(MEM_dupallocN(deformedVerts));
446  float(*quats)[4];
447  int i, deformed = 0;
448  VirtualModifierData virtualModifierData;
449  Object object_eval;
450  crazyspace_init_object_for_eval(depsgraph, object, &object_eval);
451  ModifierData *md = BKE_modifiers_get_virtual_modifierlist(&object_eval, &virtualModifierData);
452  const ModifierEvalContext mectx = {depsgraph, &object_eval, ModifierApplyFlag(0)};
453 
454  for (; md; md = md->next) {
456  continue;
457  }
458 
460  const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type));
461 
462  /* skip leading modifiers which have been already
463  * handled in sculpt_get_first_deform_matrices */
464  if (mti->deformMatrices && !deformed) {
465  continue;
466  }
467 
468  if (mesh_eval == nullptr) {
469  mesh_eval = BKE_mesh_copy_for_eval(mesh, true);
470  }
471 
472  mti->deformVerts(md, &mectx, mesh_eval, deformedVerts, mesh_eval->totvert);
473  deformed = 1;
474  }
475  }
476 
477  quats = static_cast<float(*)[4]>(MEM_mallocN(mesh->totvert * sizeof(*quats), "crazy quats"));
478 
479  BKE_crazyspace_set_quats_mesh(mesh, origVerts, deformedVerts, quats);
480 
481  for (i = 0; i < mesh->totvert; i++) {
482  float qmat[3][3], tmat[3][3];
483 
484  quat_to_mat3(qmat, quats[i]);
485  mul_m3_m3m3(tmat, qmat, (*deformmats)[i]);
486  copy_m3_m3((*deformmats)[i], tmat);
487  }
488 
489  MEM_freeN(origVerts);
490  MEM_freeN(quats);
491 
492  if (mesh_eval != nullptr) {
493  BKE_id_free(nullptr, mesh_eval);
494  }
495  }
496 
497  if (*deformmats == nullptr) {
498  int a, verts_num;
499  Mesh *mesh = (Mesh *)object->data;
500 
501  *deformcos = BKE_mesh_vert_coords_alloc(mesh, &verts_num);
502  *deformmats = static_cast<float(*)[3][3]>(
503  MEM_callocN(sizeof(*(*deformmats)) * verts_num, "defmats"));
504 
505  for (a = 0; a < verts_num; a++) {
506  unit_m3((*deformmats)[a]);
507  }
508  }
509 }
510 
511 /* -------------------------------------------------------------------- */
516  Scene *scene,
517  Object *object,
518  struct ReportList *reports)
519 {
520  if (object->runtime.crazyspace_deform_imats != nullptr ||
521  object->runtime.crazyspace_deform_cos != nullptr) {
522  return;
523  }
524 
525  if (object->type != OB_MESH) {
526  BKE_report(reports,
527  RPT_ERROR,
528  "Crazyspace transformation is only available for Mesh type of objects");
529  return;
530  }
531 
532  const Mesh *mesh = (const Mesh *)object->data;
535  scene,
536  object,
538  &object->runtime.crazyspace_deform_cos);
539 }
540 
542  struct ReportList *reports,
543  int vertex_index,
544  float displacement[3],
545  float r_displacement_deformed[3])
546 {
547  if (vertex_index < 0 || vertex_index >= object->runtime.crazyspace_verts_num) {
548  BKE_reportf(reports,
549  RPT_ERROR,
550  "Invalid vertex index %d (expected to be within 0 to %d range)",
551  vertex_index,
552  object->runtime.crazyspace_verts_num);
553  return;
554  }
555 
556  mul_v3_m3v3(r_displacement_deformed,
557  object->runtime.crazyspace_deform_imats[vertex_index],
558  displacement);
559 }
560 
562  struct ReportList *reports,
563  int vertex_index,
564  float displacement_deformed[3],
565  float r_displacement[3])
566 {
567  if (vertex_index < 0 || vertex_index >= object->runtime.crazyspace_verts_num) {
568  BKE_reportf(reports,
569  RPT_ERROR,
570  "Invalid vertex index %d (expected to be within 0 to %d range))",
571  vertex_index,
572  object->runtime.crazyspace_verts_num);
573  return;
574  }
575 
576  float mat[3][3];
577  if (!invert_m3_m3(mat, object->runtime.crazyspace_deform_imats[vertex_index])) {
578  copy_v3_v3(r_displacement, displacement_deformed);
579  return;
580  }
581 
582  mul_v3_m3v3(r_displacement, mat, displacement_deformed);
583 }
584 
586 {
589 }
590 
593 namespace blender::bke::crazyspace {
594 
596  const Object &ob_orig)
597 {
598  BLI_assert(ob_orig.type == OB_CURVES);
599  const Curves &curves_id_orig = *static_cast<const Curves *>(ob_orig.data);
600  const CurvesGeometry &curves_orig = CurvesGeometry::wrap(curves_id_orig.geometry);
601  const int points_num = curves_orig.points_num();
602 
603  GeometryDeformation deformation;
604  /* Use the undeformed positions by default. */
605  deformation.positions = curves_orig.positions();
606 
607  const Object *ob_eval = DEG_get_evaluated_object(&depsgraph, const_cast<Object *>(&ob_orig));
608  if (ob_eval == nullptr) {
609  return deformation;
610  }
611  const GeometrySet *geometry_eval = ob_eval->runtime.geometry_set_eval;
612  if (geometry_eval == nullptr) {
613  return deformation;
614  }
615 
616  /* If available, use deformation information generated during evaluation. */
617  const GeometryComponentEditData *edit_component_eval =
619  bool uses_extra_positions = false;
620  if (edit_component_eval != nullptr) {
621  const CurvesEditHints *edit_hints = edit_component_eval->curves_edit_hints_.get();
622  if (edit_hints != nullptr && &edit_hints->curves_id_orig == &curves_id_orig) {
623  if (edit_hints->positions.has_value()) {
624  BLI_assert(edit_hints->positions->size() == points_num);
625  deformation.positions = *edit_hints->positions;
626  uses_extra_positions = true;
627  }
628  if (edit_hints->deform_mats.has_value()) {
629  BLI_assert(edit_hints->deform_mats->size() == points_num);
630  deformation.deform_mats = *edit_hints->deform_mats;
631  }
632  }
633  }
634 
635  /* Use the positions of the evaluated curves directly, if the number of points matches. */
636  if (!uses_extra_positions) {
637  const CurveComponent *curves_component_eval =
638  geometry_eval->get_component_for_read<CurveComponent>();
639  if (curves_component_eval != nullptr) {
640  const Curves *curves_id_eval = curves_component_eval->get_for_read();
641  if (curves_id_eval != nullptr) {
642  const CurvesGeometry &curves_eval = CurvesGeometry::wrap(curves_id_eval->geometry);
643  if (curves_eval.points_num() == points_num) {
644  deformation.positions = curves_eval.positions();
645  }
646  }
647  }
648  }
649  return deformation;
650 }
651 
652 } // namespace blender::bke::crazyspace
typedef float(TangentPoint)[2]
bool editbmesh_modifier_is_enabled(const struct Scene *scene, const struct Object *ob, struct ModifierData *md, bool has_prev_mesh)
struct Mesh * editbmesh_get_eval_cage_from_orig(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *obedit, const struct CustomData_MeshMasks *dataMask)
void mesh_get_mapped_verts_coords(struct Mesh *me_eval, float(*r_cos)[3], int totcos)
void makeDerivedMesh(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
float(* editbmesh_vert_coords_alloc(struct BMEditMesh *em, int *r_vert_len))[3]
Low-level operations for curves.
const CustomData_MeshMasks CD_MASK_BAREMESH
Definition: customdata.cc:2051
void BKE_id_free(struct Main *bmain, void *idv)
struct Mesh * BKE_mesh_copy_for_eval(const struct Mesh *source, bool reference)
float(* BKE_mesh_vert_coords_alloc(const struct Mesh *mesh, int *r_vert_len))[3]
struct Mesh * BKE_mesh_wrapper_from_editmesh_with_coords(struct BMEditMesh *em, const struct CustomData_MeshMasks *cd_mask_extra, const float(*vert_coords)[3], const struct Mesh *me_settings)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
bool BKE_modifier_is_enabled(const struct Scene *scene, struct ModifierData *md, int required_mode)
struct ModifierData * BKE_modifiers_get_virtual_modifierlist(const struct Object *ob, struct VirtualModifierData *data)
@ eModifierTypeType_OnlyDeform
Definition: BKE_modifier.h:44
bool BKE_modifier_is_correctable_deformed(struct ModifierData *md)
void BKE_modifiers_clear_errors(struct Object *ob)
struct CDMaskLink * BKE_modifier_calc_data_masks(const struct Scene *scene, struct Object *ob, struct ModifierData *md, struct CustomData_MeshMasks *final_datamask, int required_mode, ModifierData *previewmd, const struct CustomData_MeshMasks *previewmask)
ModifierApplyFlag
Definition: BKE_modifier.h:113
int BKE_modifiers_get_cage_index(const struct Scene *scene, struct Object *ob, int *r_lastPossibleCageIndex, bool is_virtual)
struct MultiresModifierData * get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first)
Definition: multires.c:317
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
#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
#define BLI_INLINE
void copy_m3_m3(float m1[3][3], const float m2[3][3])
Definition: math_matrix.c:71
void unit_m3(float m[3][3])
Definition: math_matrix.c:40
bool invert_m3_m3(float R[3][3], const float A[3][3])
Definition: math_matrix.c:1180
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
Definition: math_matrix.c:897
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
Definition: math_matrix.c:388
void sub_qt_qtqt(float q[4], const float a[4], const float b[4])
void unit_qt(float q[4])
Definition: math_rotation.c:27
void tri_to_quat_ex(float quat[4], const float v1[3], const float v2[3], const float v3[3], const float no_orig[3])
void quat_to_mat3(float mat[3][3], const float q[4])
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
@ eModifierMode_Editmode
@ eModifierMode_DisableTemporary
@ eModifierMode_Realtime
ModifierType
@ eModifierType_Subsurf
@ eModifierType_Multires
@ OB_MODE_SCULPT
Object is a sort of wrapper for general info.
@ OB_MESH
@ OB_CURVES
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
#define BM_FACE_FIRST_LOOP(p)
Definition: bmesh_class.h:622
@ BM_VERT
Definition: bmesh_class.h:383
@ BM_ELEM_HIDDEN
Definition: bmesh_class.h:472
@ BM_ELEM_SELECT
Definition: bmesh_class.h:471
@ BM_ELEM_TAG
Definition: bmesh_class.h:484
#define BM_elem_index_get(ele)
Definition: bmesh_inline.h:110
#define BM_elem_flag_disable(ele, hflag)
Definition: bmesh_inline.h:15
#define BM_elem_index_set(ele, index)
Definition: bmesh_inline.h:111
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:12
#define BM_elem_flag_enable(ele, hflag)
Definition: bmesh_inline.h:14
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
@ BM_VERTS_OF_MESH
@ BM_FACES_OF_MESH
ATTR_WARN_UNUSED_RESULT const BMVert * v
const Curves * get_for_read() const
std::unique_ptr< blender::bke::CurvesEditHints > curves_edit_hints_
std::optional< Array< float3 > > positions
Definition: BKE_curves.hh:434
std::optional< Array< float3x3 > > deform_mats
Definition: BKE_curves.hh:439
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
Definition: BKE_curves.hh:138
Span< float3 > positions() const
int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgraph, Scene *scene, Object *ob, BMEditMesh *em, float(**deformmats)[3][3], float(**deformcos)[3])
Definition: crazyspace.cc:233
static bool modifiers_disable_subsurf_temporary(struct Scene *scene, Object *ob)
Definition: crazyspace.cc:73
int BKE_sculpt_get_first_deform_matrices(struct Depsgraph *depsgraph, Scene *scene, Object *object, float(**deformmats)[3][3], float(**deformcos)[3])
Definition: crazyspace.cc:352
BLI_INLINE void tan_calc_quat_v3(float r_quat[4], const float co_1[3], const float co_2[3], const float co_3[3])
Definition: crazyspace.cc:35
float(* BKE_crazyspace_get_mapped_editverts(struct Depsgraph *depsgraph, Object *obedit))[3]
Definition: crazyspace.cc:89
void BKE_crazyspace_api_displacement_to_original(struct Object *object, struct ReportList *reports, int vertex_index, float displacement_deformed[3], float r_displacement[3])
Definition: crazyspace.cc:561
void BKE_crazyspace_api_displacement_to_deformed(struct Object *object, struct ReportList *reports, int vertex_index, float displacement[3], float r_displacement_deformed[3])
Definition: crazyspace.cc:541
void BKE_crazyspace_api_eval(Depsgraph *depsgraph, Scene *scene, Object *object, struct ReportList *reports)
Definition: crazyspace.cc:515
static void set_crazy_vertex_quat(float r_quat[4], const float co_1[3], const float co_2[3], const float co_3[3], const float vd_1[3], const float vd_2[3], const float vd_3[3])
Definition: crazyspace.cc:57
void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, Scene *scene, Object *object, float(**deformmats)[3][3], float(**deformcos)[3])
Definition: crazyspace.cc:424
static bool crazyspace_modifier_supports_deform(ModifierData *md)
Definition: crazyspace.cc:346
void BKE_crazyspace_set_quats_mesh(Mesh *me, float(*origcos)[3], float(*mappedcos)[3], float(*quats)[4])
Definition: crazyspace.cc:180
void BKE_crazyspace_set_quats_editmesh(BMEditMesh *em, float(*origcos)[3], float(*mappedcos)[3], float(*quats)[4], const bool use_select)
Definition: crazyspace.cc:118
void BKE_crazyspace_api_eval_clear(Object *object)
Definition: crazyspace.cc:585
static void crazyspace_init_verts_and_matrices(const Mesh *mesh, float(**deformmats)[3][3], float(**deformcos)[3])
Definition: crazyspace.cc:323
static void crazyspace_init_object_for_eval(struct Depsgraph *depsgraph, Object *object, Object *object_crazy)
Definition: crazyspace.cc:312
static bool crazyspace_modifier_supports_deform_matrices(ModifierData *md)
Definition: crazyspace.cc:337
Scene scene
const Depsgraph * depsgraph
uint nor
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
static unsigned a[3]
Definition: RandGen.cpp:78
GeometryDeformation get_evaluated_curves_deformation(const Depsgraph &depsgraph, const Object &ob_orig)
Definition: crazyspace.cc:595
struct BMesh * bm
Definition: BKE_editmesh.h:40
struct BMVert * v
Definition: bmesh_class.h:153
struct BMLoop * prev
Definition: bmesh_class.h:233
struct BMLoop * next
Definition: bmesh_class.h:233
float co[3]
Definition: bmesh_class.h:87
int totvert
Definition: bmesh_class.h:297
char elem_index_dirty
Definition: bmesh_class.h:305
CurvesGeometry geometry
const GeometryComponent * get_component_for_read(GeometryComponentType component_type) const
void * first
Definition: DNA_listBase.h:31
unsigned int v
float co[3]
struct BMEditMesh * edit_mesh
struct MVert * mvert
int totvert
struct MLoop * mloop
int totpoly
struct MPoly * mpoly
struct ModifierData * next
ModifierTypeType type
Definition: BKE_modifier.h:160
void(* deformVerts)(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh, float(*vertexCos)[3], int numVerts)
Definition: BKE_modifier.h:184
void(* deformMatrices)(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh, float(*vertexCos)[3], float(*defMats)[3][3], int numVerts)
Definition: BKE_modifier.h:193
void(* deformMatricesEM)(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct BMEditMesh *editData, struct Mesh *mesh, float(*vertexCos)[3], float(*defMats)[3][3], int numVerts)
Definition: BKE_modifier.h:210
float(* crazyspace_deform_imats)[3][3]
float(* crazyspace_deform_cos)[3]
struct GeometrySet * geometry_set_eval
struct ID * data_orig
ListBase modifiers
Object_Runtime runtime
void * data