Blender V5.3
crazyspace.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 "MEM_guardedalloc.h"
10
11#include "DNA_mesh_types.h"
12#include "DNA_modifier_types.h"
13#include "DNA_object_types.h"
14
15#include "BLI_linklist.hh"
16#include "BLI_math_matrix_c.hh"
19#include "BLI_span.hh"
20#include "BLI_utildefines.hh"
21
22#include "BKE_crazyspace.hh"
23#include "BKE_curves.hh"
24#include "BKE_editmesh.hh"
25#include "BKE_geometry_set.hh"
26#include "BKE_grease_pencil.hh"
27#include "BKE_lib_id.hh"
28#include "BKE_mesh.hh"
29#include "BKE_mesh_runtime.hh"
30#include "BKE_mesh_wrapper.hh"
31#include "BKE_modifier.hh"
32#include "BKE_multires.hh"
33#include "BKE_object_types.hh"
34#include "BKE_report.hh"
35
37
38namespace blender {
39
40BLI_INLINE void tan_calc_quat_v3(float r_quat[4],
41 const float co_1[3],
42 const float co_2[3],
43 const float co_3[3])
44{
45 float vec_u[3], vec_v[3];
46 float nor[3];
47
48 sub_v3_v3v3(vec_u, co_1, co_2);
49 sub_v3_v3v3(vec_v, co_1, co_3);
50
51 cross_v3_v3v3(nor, vec_u, vec_v);
52
53 if (normalize_v3(nor) > FLT_EPSILON) {
54 const float zero_vec[3] = {0.0f};
55 tri_to_quat_ex(r_quat, zero_vec, vec_u, vec_v, nor);
56 }
57 else {
58 unit_qt(r_quat);
59 }
60}
61
62static void set_crazy_vertex_quat(float r_quat[4],
63 const float co_1[3],
64 const float co_2[3],
65 const float co_3[3],
66 const float vd_1[3],
67 const float vd_2[3],
68 const float vd_3[3])
69{
70 float q1[4], q2[4];
71
72 tan_calc_quat_v3(q1, co_1, co_2, co_3);
73 tan_calc_quat_v3(q2, vd_1, vd_2, vd_3);
74
75 sub_qt_qtqt(r_quat, q2, q1);
76}
77
78static bool modifiers_disable_subsurf_temporary(Object *ob, const int cageIndex)
79{
80 bool changed = false;
81
82 ModifierData *md = ob->modifiers.first();
83 for (int i = 0; md && i <= cageIndex; i++, md = md->next) {
84 if (md->type == eModifierType_Subsurf) {
86 changed = true;
87 }
88 }
89
90 return changed;
91}
92
94{
95 Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
96 Object *obedit_eval = DEG_get_evaluated(depsgraph, obedit);
97 const int cageIndex = BKE_modifiers_get_cage_index(scene_eval, obedit_eval, nullptr, true);
98
99 /* Disable subsurf temporal, get mapped cos, and enable it. */
100 if (modifiers_disable_subsurf_temporary(obedit_eval, cageIndex)) {
101 /* Need to make new cage.
102 * TODO: Avoid losing original evaluated geometry. */
103 bke::mesh_data_update(*depsgraph, *scene_eval, *obedit_eval, CD_MASK_BAREMESH);
104 }
105
106 /* Now get the cage. */
107 const Mesh *mesh_eval_cage = bke::editbmesh_get_eval_cage(
108 depsgraph, scene_eval, obedit_eval, &CD_MASK_BAREMESH);
109
110 const BMesh *bm = BKE_editmesh_bmesh_get(obedit);
111 const int nverts = bm->totvert;
112 Array<float3> vertexcos(nverts);
113 bke::mesh_get_mapped_verts_coords(mesh_eval_cage, vertexcos);
114
115 /* Set back the flag, and ensure new cage needs to be built. */
116 if (modifiers_disable_subsurf_temporary(obedit_eval, cageIndex)) {
118 }
119
120 return vertexcos;
121}
122
124 const Span<float3> origcos,
125 const Span<float3> mappedcos,
126 float (*quats)[4],
127 const bool use_select)
128{
129 BMFace *f;
130 BMIter iter;
131 int index;
132 const bool has_origcos = !origcos.is_empty();
133
134 {
135 BMVert *v;
138 BM_elem_index_set(v, index); /* set_inline */
139 }
141 }
142
143 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
144 BMLoop *l_iter, *l_first;
145
146 l_iter = l_first = BM_FACE_FIRST_LOOP(f);
147 do {
148 if (BM_elem_flag_test(l_iter->v, BM_ELEM_HIDDEN) ||
149 BM_elem_flag_test(l_iter->v, BM_ELEM_TAG) ||
150 (use_select && !BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)))
151 {
152 continue;
153 }
154
155 if (!BM_elem_flag_test(l_iter->v, BM_ELEM_TAG)) {
156 const float *co_prev, *co_curr, *co_next; /* orig */
157
158 const int vert_prev = BM_elem_index_get(l_iter->prev->v);
159 const int vert = BM_elem_index_get(l_iter->v);
160 const int vert_next = BM_elem_index_get(l_iter->next->v);
161
162 /* Retrieve mapped coordinates. */
163 const float3 &vd_prev = mappedcos[vert_prev];
164 const float3 &vd_curr = mappedcos[vert];
165 const float3 &vd_next = mappedcos[vert_next];
166
167 if (has_origcos) {
168 co_prev = origcos[vert_prev];
169 co_curr = origcos[vert];
170 co_next = origcos[vert_next];
171 }
172 else {
173 co_prev = l_iter->prev->v->co;
174 co_curr = l_iter->v->co;
175 co_next = l_iter->next->v->co;
176 }
177
178 set_crazy_vertex_quat(quats[vert], co_curr, co_next, co_prev, vd_curr, vd_next, vd_prev);
179
181 }
182 } while ((l_iter = l_iter->next) != l_first);
183 }
184}
185
187 const Span<float3> origcos,
188 const Span<float3> mappedcos,
189 float (*quats)[4])
190{
191 using namespace blender::bke;
192 BitVector<> vert_tag(mesh->verts_num);
193
194 /* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */
195 const Span<float3> positions = origcos.is_empty() ? mesh->vert_positions() : origcos;
196 const OffsetIndices<int> faces = mesh->faces();
197 const Span<int> corner_verts = mesh->corner_verts();
198
199 for (const int i : faces.index_range()) {
200 const IndexRange face = faces[i];
201
202 for (const int corner : face) {
203 const int vert = corner_verts[corner];
204 if (vert_tag[vert]) {
205 continue;
206 }
207 const int vert_prev = corner_verts[mesh::face_corner_prev(face, corner)];
208 const int vert_next = corner_verts[mesh::face_corner_next(face, corner)];
209
210 const float3 &vd_prev = mappedcos[vert_prev];
211 const float3 &vd_curr = mappedcos[vert];
212 const float3 &vd_next = mappedcos[vert_next];
213
214 const float3 &co_prev = positions[vert_prev];
215 const float3 &co_curr = positions[vert];
216 const float3 &co_next = positions[vert_next];
217
218 set_crazy_vertex_quat(quats[vert], co_curr, co_next, co_prev, vd_curr, vd_next, vd_prev);
219
220 vert_tag[vert].set();
221 }
222 }
223}
224
226 Scene *scene,
227 Object *ob,
228 BMEditMesh *em,
229 Array<float3x3, 0> &deformmats,
230 Array<float3, 0> &deformcos)
231{
232 ModifierData *md;
233 Mesh *me_input = id_cast<Mesh *>(ob->data);
234 Mesh *mesh = nullptr;
235 int i, modifiers_left_num = 0;
236 /* The evaluated mesh may not have an edit-mesh, use the original. */
238 const int verts_num = bm->totvert;
239 int cageIndex = BKE_modifiers_get_cage_index(scene, ob, nullptr, true);
240 VirtualModifierData virtual_modifier_data;
241 ModifierEvalContext mectx = {depsgraph, ob, ModifierApplyFlag(0)};
242
244
245 md = BKE_modifiers_get_virtual_modifierlist(ob, &virtual_modifier_data);
246
247 /* compute the deformation matrices and coordinates for the first
248 * modifiers with on cage editing that are enabled and support computing
249 * deform matrices */
250 for (i = 0; md && i <= cageIndex; i++, md = md->next) {
252
253 if (!bke::editbmesh_modifier_is_enabled(scene, ob, md, mesh != nullptr)) {
254 continue;
255 }
256
258 if (deformmats.is_empty()) {
259 const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
262 scene, md, &cd_mask_extra, required_mode);
263 cd_mask_extra = datamasks->mask;
264 BLI_linklist_free(reinterpret_cast<LinkNode *>(datamasks), nullptr);
265
267 std::make_shared<BMEditMesh>(*em), &cd_mask_extra, me_input);
268 deformcos.reinitialize(verts_num);
270 deformmats.reinitialize(verts_num);
271 deformmats.fill(float3x3::identity());
272 }
273 mti->deform_matrices_EM(md, &mectx, mesh, deformcos, deformmats);
274 }
275 else {
276 break;
277 }
278 }
279
280 for (; md && i <= cageIndex; md = md->next, i++) {
281 if (bke::editbmesh_modifier_is_enabled(scene, ob, md, mesh != nullptr) &&
283 {
284 modifiers_left_num++;
285 }
286 }
287
288 if (mesh) {
289 BKE_id_free(nullptr, mesh);
290 }
291
292 return modifiers_left_num;
293}
294
302static void crazyspace_init_object_for_eval(Depsgraph *depsgraph,
303 Object *object,
304 Object *object_crazy)
305{
306 Object *object_eval = DEG_get_evaluated(depsgraph, object);
307 *object_crazy = dna::shallow_copy(*object_eval);
308 object_crazy->runtime = MEM_new<bke::ObjectRuntime>(__func__, *object_eval->runtime);
309 if (object_crazy->runtime->data_orig != nullptr) {
310 object_crazy->data = object_crazy->runtime->data_orig;
311 }
312}
313
315{
317 return true;
318 }
320 return (mti->type == ModifierTypeType::OnlyDeform);
321}
322
328
330 Scene *scene,
331 Object *object,
332 Array<float3x3, 0> &deformmats,
333 Array<float3, 0> &deformcos)
334{
335 ModifierData *md;
336 Mesh *mesh_eval = nullptr;
337 int modifiers_left_num = 0;
338 VirtualModifierData virtual_modifier_data;
339 Object object_eval;
340 crazyspace_init_object_for_eval(depsgraph, object, &object_eval);
341 BLI_SCOPED_DEFER([&]() { MEM_delete(object_eval.runtime); });
342 MultiresModifierData *mmd = get_multires_modifier(scene, &object_eval, false);
343 const bool is_sculpt_mode = (object->mode & OB_MODE_SCULPT) != 0;
344 const bool has_multires = mmd != nullptr && mmd->sculptlvl > 0;
345 const bool is_sculpt_base_mesh = mmd != nullptr &&
347 const ModifierEvalContext mectx = {depsgraph, &object_eval, ModifierApplyFlag(0)};
348
349 if (is_sculpt_mode && has_multires && !is_sculpt_base_mesh) {
350 deformcos = {};
351 deformmats = {};
352 return modifiers_left_num;
353 }
354
355 md = BKE_modifiers_get_virtual_modifierlist(&object_eval, &virtual_modifier_data);
356
357 for (; md; md = md->next) {
359 continue;
360 }
361
362 if (is_sculpt_base_mesh && md->type == eModifierType_Multires) {
363 continue;
364 }
365
368 if (deformmats.is_empty()) {
369 /* NOTE: Evaluated object is re-set to its original un-deformed state. */
370 Mesh *mesh = id_cast<Mesh *>(object_eval.data);
371 mesh_eval = BKE_mesh_copy_for_eval(*mesh);
372 deformcos = mesh->vert_positions();
373 deformmats.reinitialize(mesh->verts_num);
374 deformmats.fill(float3x3::identity());
375 }
376
377 if (mti->deform_matrices) {
378 mti->deform_matrices(md, &mectx, mesh_eval, deformcos, deformmats);
379 }
380 else {
381 /* More complex handling will continue in BKE_crazyspace_build_sculpt.
382 * Exiting the loop on a non-deform modifier causes issues - #71213. */
384 break;
385 }
386 }
387 }
388
389 for (; md; md = md->next) {
391 continue;
392 }
393
395 modifiers_left_num++;
396 }
397 }
398
399 if (mesh_eval != nullptr) {
400 BKE_id_free(nullptr, mesh_eval);
401 }
402
403 return modifiers_left_num;
404}
405
406void BKE_crazyspace_build_sculpt(Depsgraph *depsgraph,
407 Scene *scene,
408 Object *object,
409 Array<float3x3, 0> &deformmats,
410 Array<float3, 0> &deformcos)
411{
413 depsgraph, scene, object, deformmats, deformcos);
414
415 if (totleft) {
416 /* There are deformation modifier which doesn't support deformation matrices calculation.
417 * Need additional crazy-space correction. */
418
419 Mesh *mesh = id_cast<Mesh *>(object->data);
420 Mesh *mesh_eval = nullptr;
421
422 if (deformcos.is_empty()) {
423 deformcos = mesh->vert_positions();
424 deformmats.reinitialize(mesh->verts_num);
425 deformmats.fill(float3x3::identity());
426 }
427
428 Array<float3, 0> origVerts = deformcos;
429 float (*quats)[4];
430 int i, deformed = 0;
431 VirtualModifierData virtual_modifier_data;
432 Object object_eval;
433 crazyspace_init_object_for_eval(depsgraph, object, &object_eval);
434 BLI_SCOPED_DEFER([&]() { MEM_delete(object_eval.runtime); });
436 &virtual_modifier_data);
437 const ModifierEvalContext mectx = {depsgraph, &object_eval, ModifierApplyFlag(0)};
438
439 for (; md; md = md->next) {
441 continue;
442 }
443
445 const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
446
447 /* skip leading modifiers which have been already
448 * handled in sculpt_get_first_deform_matrices */
449 if (mti->deform_matrices && !deformed) {
450 continue;
451 }
452
453 if (mesh_eval == nullptr) {
454 mesh_eval = BKE_mesh_copy_for_eval(*mesh);
455 }
456
457 mti->deform_verts(md, &mectx, mesh_eval, deformcos);
458 deformed = 1;
459 }
460 }
461
462 quats = MEM_new_array_uninitialized<float[4]>(size_t(mesh->verts_num), "crazy quats");
463
464 BKE_crazyspace_set_quats_mesh(mesh, origVerts, deformcos, quats);
465
466 for (i = 0; i < mesh->verts_num; i++) {
467 float qmat[3][3], tmat[3][3];
468
469 quat_to_mat3(qmat, quats[i]);
470 mul_m3_m3m3(tmat, qmat, deformmats[i].ptr());
471 copy_m3_m3(deformmats[i].ptr(), tmat);
472 }
473
474 MEM_delete(quats);
475
476 if (mesh_eval != nullptr) {
477 BKE_id_free(nullptr, mesh_eval);
478 }
479 }
480
481 if (deformmats.is_empty()) {
482 Mesh *mesh = id_cast<Mesh *>(object->data);
483
484 deformcos = mesh->vert_positions();
485 deformmats.reinitialize(mesh->verts_num);
486 deformmats.fill(float3x3::identity());
487 }
488}
489
490/* -------------------------------------------------------------------- */
493
494void BKE_crazyspace_api_eval(Depsgraph *depsgraph,
495 Scene *scene,
496 Object *object,
497 ReportList *reports)
498{
499 if (!object->runtime->crazyspace_deform_imats.is_empty() ||
500 !object->runtime->crazyspace_deform_cos.is_empty())
501 {
502 return;
503 }
504
505 if (object->type != OB_MESH) {
506 BKE_report(reports,
507 RPT_ERROR,
508 "Crazyspace transformation is only available for Mesh type of objects");
509 return;
510 }
511
513 scene,
514 object,
515 object->runtime->crazyspace_deform_imats,
516 object->runtime->crazyspace_deform_cos);
517}
518
520 ReportList *reports,
521 int vert,
522 const float displacement[3],
523 float r_displacement_deformed[3])
524{
525 if (vert < 0 || vert >= object->runtime->crazyspace_deform_imats.size()) {
526 BKE_reportf(reports,
527 RPT_ERROR,
528 "Invalid vertex index %d (expected to be within 0 to %d range)",
529 vert,
530 int(object->runtime->crazyspace_deform_imats.size()));
531 return;
532 }
533
535 r_displacement_deformed, object->runtime->crazyspace_deform_imats[vert].ptr(), displacement);
536}
537
539 ReportList *reports,
540 int vert,
541 const float displacement_deformed[3],
542 float r_displacement[3])
543{
544 if (vert < 0 || vert >= object->runtime->crazyspace_deform_imats.size()) {
545 BKE_reportf(reports,
546 RPT_ERROR,
547 "Invalid vertex index %d (expected to be within 0 to %d range)",
548 vert,
549 int(object->runtime->crazyspace_deform_imats.size()));
550 return;
551 }
552
553 float mat[3][3];
554 if (!invert_m3_m3(mat, object->runtime->crazyspace_deform_imats[vert].ptr())) {
555 copy_v3_v3(r_displacement, displacement_deformed);
556 return;
557 }
558
559 mul_v3_m3v3(r_displacement, mat, displacement_deformed);
560}
561
563{
564 object->runtime->crazyspace_deform_imats = {};
565 object->runtime->crazyspace_deform_cos = {};
566}
567
569
570namespace bke::crazyspace {
571
573{
574 BLI_assert(ob_orig.type == OB_CURVES);
575 const Curves &curves_id_orig = *id_cast<const Curves *>(ob_orig.data);
576 const CurvesGeometry &curves_orig = curves_id_orig.geometry.wrap();
577 const int points_num = curves_orig.points_num();
578
579 GeometryDeformation deformation;
580 /* Use the undeformed positions by default. */
581 deformation.positions = curves_orig.positions();
582
583 if (ob_eval == nullptr) {
584 return deformation;
585 }
586 const GeometrySet *geometry_eval = ob_eval->runtime->geometry_set_eval;
587 if (geometry_eval == nullptr) {
588 return deformation;
589 }
590
591 /* If available, use deformation information generated during evaluation. */
592 const GeometryComponentEditData *edit_component_eval =
594 bool uses_extra_positions = false;
595 if (edit_component_eval != nullptr) {
596 const CurvesEditHints *edit_hints = edit_component_eval->curves_edit_hints_.get();
597 if (edit_hints != nullptr && &edit_hints->curves_id_orig == &curves_id_orig) {
598 if (const std::optional<Span<float3>> positions = edit_hints->positions()) {
599 BLI_assert(positions->size() == points_num);
600 deformation.positions = *positions;
601 uses_extra_positions = true;
602 }
603 if (edit_hints->deform_mats.has_value()) {
604 BLI_assert(edit_hints->deform_mats->size() == points_num);
605 deformation.deform_mats = *edit_hints->deform_mats;
606 }
607 }
608 }
609
610 /* Use the positions of the evaluated curves directly, if the number of points matches. */
611 if (!uses_extra_positions) {
612 const CurveComponent *curves_component_eval = geometry_eval->get_component<CurveComponent>();
613 if (curves_component_eval != nullptr) {
614 const Curves *curves_id_eval = curves_component_eval->get();
615 if (curves_id_eval != nullptr) {
616 const CurvesGeometry &curves_eval = curves_id_eval->geometry.wrap();
617 if (curves_eval.points_num() == points_num) {
618 deformation.positions = curves_eval.positions();
619 }
620 }
621 }
622 }
623 return deformation;
624}
625
627 const Object &ob_orig)
628{
629 const Object *ob_eval = DEG_get_evaluated(&depsgraph, &ob_orig);
630 return get_evaluated_curves_deformation(ob_eval, ob_orig);
631}
632
634 const GreasePencilEditHints *edit_hints, const bke::greasepencil::Drawing &drawing_orig)
635{
636 for (const GreasePencilDrawingEditHints &drawing_hint : *edit_hints->drawing_hints) {
637 if (drawing_hint.drawing_orig == &drawing_orig) {
638 return &drawing_hint;
639 }
640 }
641 return {};
642}
643
645 const Object *ob_eval, const Object &ob_orig, const bke::greasepencil::Drawing &drawing_orig)
646{
647 BLI_assert(ob_orig.type == OB_GREASE_PENCIL);
648 const GreasePencil &grease_pencil_orig = *id_cast<const GreasePencil *>(ob_orig.data);
649
650 GeometryDeformation deformation;
651 /* Use the undeformed positions by default. */
652 deformation.positions = drawing_orig.strokes().positions();
653
654 if (ob_eval == nullptr) {
655 return deformation;
656 }
657 const GeometrySet *geometry_eval = ob_eval->runtime->geometry_set_eval;
658 if (geometry_eval == nullptr) {
659 return deformation;
660 }
661
662 bool uses_drawing_hints = false;
663
664 /* If there are edit hints, use the positions of those. */
665 if (geometry_eval->has<GeometryComponentEditData>()) {
666 const GeometryComponentEditData &edit_component_eval =
667 *geometry_eval->get_component<GeometryComponentEditData>();
668 const GreasePencilEditHints *edit_hints = edit_component_eval.grease_pencil_edit_hints_.get();
669 if (edit_hints != nullptr && &edit_hints->grease_pencil_id_orig == &grease_pencil_orig &&
670 edit_hints->drawing_hints.has_value())
671 {
672 if (const GreasePencilDrawingEditHints *drawing_hints =
673 get_drawing_edit_hint_for_original_drawing(edit_hints, drawing_orig))
674 {
675 if (drawing_hints->positions()) {
676 deformation.positions = *drawing_hints->positions();
677 }
678 if (drawing_hints->deform_mats.has_value()) {
679 deformation.deform_mats = *drawing_hints->deform_mats;
680 }
681 uses_drawing_hints = true;
682 }
683 }
684 }
685 if (uses_drawing_hints) {
686 return deformation;
687 }
688
689 /* Use the positions of the evaluated drawing that corresponds to the original drawing, if the
690 * number of points matches. */
691 const GreasePencil *grease_pencil_eval = geometry_eval->get_grease_pencil();
692 if (grease_pencil_eval == nullptr) {
693 return deformation;
694 }
695
696 const Span<const greasepencil::Layer *> orig_layers = grease_pencil_orig.layers();
697 for (const greasepencil::Layer *layer_eval : grease_pencil_eval->layers()) {
698 const int orig_layer_index = layer_eval->runtime->orig_layer_index_;
699 if (!orig_layers.index_range().contains(orig_layer_index)) {
700 continue;
701 }
702 const greasepencil::Drawing *drawing_orig_at_frame = grease_pencil_orig.get_drawing_at(
703 *orig_layers[orig_layer_index], grease_pencil_eval->runtime->eval_frame);
704 if (drawing_orig_at_frame != &drawing_orig) {
705 continue;
706 }
707 const greasepencil::Drawing *drawing_eval = grease_pencil_eval->get_eval_drawing(*layer_eval);
708 if (drawing_eval != nullptr &&
709 drawing_eval->strokes().points_num() == drawing_orig.strokes().points_num())
710 {
711 deformation.positions = drawing_eval->strokes().positions();
712 }
713 break;
714 }
715
716 return deformation;
717}
718
720 const Depsgraph &depsgraph,
721 const Object &ob_orig,
722 const bke::greasepencil::Drawing &drawing_orig)
723{
724 const Object *ob_eval = DEG_get_evaluated(&depsgraph, &ob_orig);
725 return get_evaluated_grease_pencil_drawing_deformation(ob_eval, ob_orig, drawing_orig);
726}
727
728} // namespace bke::crazyspace
729} // namespace blender
Low-level operations for curves.
Low-level operations for grease pencil.
#define BLI_SCOPED_DEFER(function_to_defer)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define BLI_INLINE
#define ELEM(...)
#define BM_FACE_FIRST_LOOP(p)
#define BM_elem_index_get(ele)
#define BM_elem_flag_disable(ele, hflag)
#define BM_elem_index_set(ele, index)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_enable(ele, hflag)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
void fill(const T &value) const
Definition BLI_array.hh:283
void reinitialize(const int64_t new_size)
Definition BLI_array.hh:430
bool is_empty() const
Definition BLI_array.hh:275
constexpr bool contains(int64_t value) const
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
constexpr bool is_empty() const
Definition BLI_span.hh:264
std::optional< Span< float3 > > positions() const
std::optional< Array< float3x3 > > deform_mats
Span< float3 > positions() const
std::unique_ptr< GreasePencilEditHints > grease_pencil_edit_hints_
std::unique_ptr< CurvesEditHints > curves_edit_hints_
std::optional< Array< GreasePencilDrawingEditHints > > drawing_hints
const bke::CurvesGeometry & strokes() const
#define FLT_EPSILON
GeometryDeformation get_evaluated_grease_pencil_drawing_deformation(const Object *ob_eval, const Object &ob_orig, const bke::greasepencil::Drawing &drawing_orig)
GeometryDeformation get_evaluated_curves_deformation(const Object *ob_eval, const Object &ob_orig)
static const GreasePencilDrawingEditHints * get_drawing_edit_hint_for_original_drawing(const GreasePencilEditHints *edit_hints, const bke::greasepencil::Drawing &drawing_orig)
int face_corner_prev(const IndexRange face, const int corner)
Definition BKE_mesh.hh:306
int face_corner_next(const IndexRange face, const int corner)
Definition BKE_mesh.hh:315
void mesh_get_mapped_verts_coords(const Mesh *mesh_eval, MutableSpan< float3 > r_cos)
bool editbmesh_modifier_is_enabled(const Scene *scene, const Object *ob, ModifierData *md, bool has_prev_mesh)
void mesh_data_update(Depsgraph &depsgraph, const Scene &scene, Object &ob, const CustomData_MeshMasks &dataMask)
const Mesh * editbmesh_get_eval_cage(Depsgraph *depsgraph, const Scene *scene, Object *obedit, const CustomData_MeshMasks *dataMask)
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
Definition DNA_defs.h:147
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
CDMaskLink * BKE_modifier_calc_data_masks(const Scene *scene, ModifierData *md, CustomData_MeshMasks *final_datamask, int required_mode)
int BKE_crazyspace_get_first_deform_matrices_editbmesh(Depsgraph *depsgraph, Scene *, Object *, BMEditMesh *em, Array< float3x3, 0 > &deformmats, Array< float3, 0 > &deformcos)
const CustomData_MeshMasks CD_MASK_BAREMESH
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static void crazyspace_init_object_for_eval(Depsgraph *depsgraph, Object *object, Object *object_crazy)
void copy_m3_m3(float m1[3][3], const float m2[3][3])
Mesh * BKE_mesh_copy_for_eval(const Mesh &source)
bool invert_m3_m3(float inverse[3][3], const float mat[3][3])
void BKE_crazyspace_set_quats_editmesh(BMesh *bm, Span< float3 > origcos, Span< float3 > mappedcos, float(*quats)[4], bool use_select)
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:40
void BKE_mesh_wrapper_vert_coords_copy(const Mesh *mesh, MutableSpan< float3 > positions)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void unit_qt(float q[4])
void quat_to_mat3(float m[3][3], const float q[4])
void BKE_crazyspace_api_displacement_to_original(Object *object, ReportList *reports, int vertex_index, const float displacement_deformed[3], float r_displacement[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
@ eModifierMode_DisableTemporary
void DEG_id_tag_update(ID *id, unsigned int flags)
MultiresModifierData * get_multires_modifier(Scene *scene, Object *ob, bool use_first)
Definition multires.cc:185
void sub_qt_qtqt(float q[4], const float a[4], const float b[4])
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void BKE_crazyspace_set_quats_mesh(Mesh *mesh, Span< float3 > origcos, Span< float3 > mappedcos, float(*quats)[4])
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
void BKE_crazyspace_api_eval(Depsgraph *depsgraph, Scene *scene, Object *object, ReportList *reports)
int BKE_sculpt_get_first_deform_matrices(Depsgraph *depsgraph, Scene *scene, Object *ob, Array< float3x3, 0 > &deformmats, Array< float3, 0 > &deformcos)
void BKE_crazyspace_api_displacement_to_deformed(Object *object, ReportList *reports, int vertex_index, const float displacement[3], float r_displacement_deformed[3])
static bool crazyspace_modifier_supports_deform(ModifierData *md)
static bool crazyspace_modifier_supports_deform_matrices(ModifierData *md)
int BKE_modifiers_get_cage_index(const Scene *scene, Object *ob, int *r_lastPossibleCageIndex, bool is_virtual)
void BKE_modifiers_clear_errors(Object *ob)
void BKE_id_free(Main *bmain, void *idv)
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:62
MINLINE float normalize_v3(float n[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
T * DEG_get_original(T *id)
void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc)
bool BKE_modifier_is_correctable_deformed(ModifierData *md)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ eMultiresModifierFlag_UseSculptBaseMesh
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
Definition editmesh.cc:65
Array< float3 > BKE_crazyspace_get_mapped_editverts(Depsgraph *depsgraph, Object *obedit)
Definition crazyspace.cc:93
Mesh * BKE_mesh_wrapper_from_editmesh(std::shared_ptr< BMEditMesh > em, const CustomData_MeshMasks *cd_mask_extra, const Mesh *me_settings)
void BKE_crazyspace_api_eval_clear(Object *object)
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
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])
VecBase< float, 3 > float3
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
bool BKE_modifier_is_enabled(const Scene *scene, ModifierData *md, int required_mode)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
void BKE_crazyspace_build_sculpt(Depsgraph *depsgraph, Scene *scene, Object *ob, Array< float3x3, 0 > &deformmats, Array< float3, 0 > &deformcos)
static bool modifiers_disable_subsurf_temporary(Object *ob, const int cageIndex)
Definition crazyspace.cc:78
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct BMLoop * next
struct BMLoop * prev
struct BMVert * v
struct ModifierData * next
void(*) deform_verts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, MutableSpan< float3 > positions)
void(*) deform_matrices_EM(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, MutableSpan< float3 > positions, MutableSpan< float3x3 > matrices)
void(*) deform_matrices(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, MutableSpan< float3 > positions, MutableSpan< float3x3 > matrices)
ListBaseT< ModifierData > modifiers
bke::ObjectRuntime * runtime
const GreasePencil * get_grease_pencil() const
bool has(const GeometryComponent::Type component_type) const
const GeometryComponent * get_component(GeometryComponent::Type component_type) const