Blender V5.3
object_data_transform.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
14
15#include <cstdlib>
16#include <cstring>
17
18#include "DNA_armature_types.h"
20#include "DNA_lattice_types.h"
21#include "DNA_mesh_types.h"
22#include "DNA_meta_types.h"
23#include "DNA_object_types.h"
25
26#include "BLI_listbase.hh"
27#include "BLI_math_matrix_c.hh"
29#include "BLI_math_vector_c.hh"
30#include "BLI_task.hh"
31
32#include "BKE_armature.hh"
33#include "BKE_curve.hh"
34#include "BKE_curves_utils.hh"
35#include "BKE_editmesh.hh"
36#include "BKE_grease_pencil.hh"
37#include "BKE_key.hh"
38#include "BKE_lattice.hh"
39#include "BKE_mball.hh"
40#include "BKE_mesh_types.hh"
41
42#include "bmesh.hh"
43
44#include "DEG_depsgraph.hh"
45
46#include "ED_armature.hh"
47#include "ED_curves.hh"
48#include "ED_mesh.hh"
49#include "ED_object.hh"
50
51namespace blender::ed::object {
52
53/* -------------------------------------------------------------------- */
60
61/* Armature */
62
64 float tail[3];
65 float head[3];
66 float roll;
67 float arm_tail[3];
68 float arm_head[3];
69 float arm_roll;
70 float rad_tail;
71 float rad_head;
72 float dist;
73 float xwidth;
74 float zwidth;
75};
76
77static ElemData_Armature *armature_coords_and_quats_get_recurse(const ListBaseT<Bone> *bone_base,
78 ElemData_Armature *elem_array)
79{
80 ElemData_Armature *elem = elem_array;
81 for (const Bone &bone : *bone_base) {
82
83#define COPY_PTR(member) memcpy(elem->member, bone.member, sizeof(bone.member))
84#define COPY_VAL(member) memcpy(&elem->member, &bone.member, sizeof(bone.member))
85 COPY_PTR(head);
86 COPY_PTR(tail);
87 COPY_VAL(roll);
88 COPY_PTR(arm_head);
89 COPY_PTR(arm_tail);
90 COPY_VAL(arm_roll);
91 COPY_VAL(rad_tail);
92 COPY_VAL(rad_head);
93 COPY_VAL(dist);
94 COPY_VAL(xwidth);
95 COPY_VAL(zwidth);
96#undef COPY_PTR
97#undef COPY_VAL
98
99 elem = armature_coords_and_quats_get_recurse(&bone.childbase, elem + 1);
100 }
101 return elem;
102}
103
106{
108}
109
111 ListBaseT<Bone> *bone_base, const ElemData_Armature *elem_array, const float4x4 &transform)
112{
113 const ElemData_Armature *elem = elem_array;
114 for (Bone &bone : *bone_base) {
115
116#define COPY_PTR(member) memcpy(bone.member, elem->member, sizeof(bone.member))
117#define COPY_VAL(member) memcpy(&bone.member, &elem->member, sizeof(bone.member))
118 COPY_PTR(head);
119 COPY_PTR(tail);
120 COPY_VAL(roll);
121 COPY_PTR(arm_head);
122 COPY_PTR(arm_tail);
123 COPY_VAL(arm_roll);
124 COPY_VAL(rad_tail);
125 COPY_VAL(rad_head);
126 COPY_VAL(dist);
127 COPY_VAL(xwidth);
128 COPY_VAL(zwidth);
129#undef COPY_PTR
130#undef COPY_VAL
131
132 elem = armature_coords_and_quats_apply_with_mat4_recurse(&bone.childbase, elem + 1, transform);
133 }
134 return elem;
135}
136
144
146 const Span<ElemData_Armature> elem_array)
147{
148 /* Avoid code duplication by using a unit matrix. */
150}
151
152/* Edit Armature */
155{
156 ElemData_Armature *elem = elem_array.data();
157 for (EditBone *ebone = arm->edbo->first(); ebone; ebone = ebone->next, elem++) {
158
159#define COPY_PTR(member) memcpy(elem->member, ebone->member, sizeof(ebone->member))
160#define COPY_VAL(member) memcpy(&elem->member, &ebone->member, sizeof(ebone->member))
161 /* Unused for edit bones: arm_head, arm_tail, arm_roll */
162 COPY_PTR(head);
163 COPY_PTR(tail);
164 COPY_VAL(roll);
165 COPY_VAL(rad_tail);
166 COPY_VAL(rad_head);
167 COPY_VAL(dist);
168 COPY_VAL(xwidth);
169 COPY_VAL(zwidth);
170#undef COPY_PTR
171#undef COPY_VAL
172 }
173}
174
176 bArmature *arm, const Span<ElemData_Armature> elem_array, const float4x4 &transform)
177{
178 const ElemData_Armature *elem = elem_array.data();
179 for (EditBone *ebone = arm->edbo->first(); ebone; ebone = ebone->next, elem++) {
180
181#define COPY_PTR(member) memcpy(ebone->member, elem->member, sizeof(ebone->member))
182#define COPY_VAL(member) memcpy(&ebone->member, &elem->member, sizeof(ebone->member))
183 /* Unused for edit bones: arm_head, arm_tail, arm_roll */
184 COPY_PTR(head);
185 COPY_PTR(tail);
186 COPY_VAL(roll);
187 COPY_VAL(rad_tail);
188 COPY_VAL(rad_head);
189 COPY_VAL(dist);
190 COPY_VAL(xwidth);
191 COPY_VAL(zwidth);
192#undef COPY_PTR
193#undef COPY_VAL
194 }
195 ED_armature_edit_transform(arm, transform.ptr(), true);
196}
197
199 const Span<ElemData_Armature> elem_array)
200{
201 /* Avoid code duplication by using a unit matrix. */
203}
204
205/* MetaBall */
206
208 float co[3];
209 float quat[4];
210 float exp[3];
211 float rad;
212};
213
216{
217 ElemData_MetaBall *elem = elem_array.data();
218 for (const MetaElem *ml = mb->elems.first(); ml; ml = ml->next, elem++) {
219 copy_v3_v3(elem->co, &ml->x);
220 copy_qt_qt(elem->quat, ml->quat);
221 copy_v3_v3(elem->exp, &ml->expx);
222 elem->rad = ml->rad;
223 }
224}
225
227 const Span<ElemData_MetaBall> elem_array,
228 const float4x4 &transform)
229{
230 const ElemData_MetaBall *elem = elem_array.data();
231 for (MetaElem *ml = mb->elems.first(); ml; ml = ml->next, elem++) {
232 copy_v3_v3(&ml->x, elem->co);
233 copy_qt_qt(ml->quat, elem->quat);
234 copy_v3_v3(&ml->expx, elem->exp);
235 ml->rad = elem->rad;
236 }
237 BKE_mball_transform(mb, transform.ptr(), true);
238}
239
241{
242 /* Avoid code duplication by using a unit matrix. */
244}
245
247
248/* -------------------------------------------------------------------- */
255
257 /* Optional data for shape keys. */
260 bool is_edit_mode = false;
261 ~XFormObjectData_Mesh() override = default;
262};
263
265 /* Optional data for shape keys. */
268 bool is_edit_mode = false;
269 ~XFormObjectData_Lattice() override = default;
270};
271
273 /* Optional data for shape keys. */
276 bool is_edit_mode = false;
277 ~XFormObjectData_Curve() override = default;
278};
279
285
291
297
303
309
310static std::unique_ptr<XFormObjectData> data_xform_create_ex(ID *id, bool is_edit_mode)
311{
312 if (id == nullptr) {
313 return {};
314 }
315
316 switch (GS(id->name)) {
317 case ID_ME: {
318 Mesh *mesh = id_cast<Mesh *>(id);
319 Key *key = mesh->key;
320 const int key_index = -1;
321
322 if (is_edit_mode) {
324 /* Always operate on all keys for the moment. */
325 // key_index = bm->shapenr - 1;
326 auto xod = std::make_unique<XFormObjectData_Mesh>();
327 xod->id = id;
328 xod->is_edit_mode = is_edit_mode;
329 xod->positions.reinitialize(bm->totvert);
330
331 BM_mesh_vert_coords_get(bm, xod->positions.as_mutable_span());
332
333 if (key != nullptr) {
334 const size_t key_size = BKE_keyblock_element_calc_size_from_shape(key, key_index);
335 if (key_size) {
336 xod->key_data.reinitialize(key_size);
337 BKE_keyblock_data_get_from_shape(key, xod->key_data, key_index);
338 }
339 }
340 return xod;
341 }
342
343 auto xod = std::make_unique<XFormObjectData_Mesh>();
344 xod->id = id;
345 xod->is_edit_mode = is_edit_mode;
346 xod->positions = mesh->vert_positions();
347
348 if (key != nullptr) {
349 const size_t key_size = BKE_keyblock_element_calc_size_from_shape(key, key_index);
350 if (key_size) {
351 xod->key_data.reinitialize(key_size);
352 BKE_keyblock_data_get_from_shape(key, xod->key_data, key_index);
353 }
354 }
355 return xod;
356 }
357 case ID_LT: {
358 Lattice *lt_orig = id_cast<Lattice *>(id);
359 Lattice *lt = is_edit_mode ? lt_orig->editlatt->latt : lt_orig;
360 Key *key = lt->key;
361 const int key_index = -1;
362
363 if (is_edit_mode) {
364 /* Always operate on all keys for the moment. */
365 // key_index = lt_orig->editlatt->shapenr - 1;
366 }
367
368 auto xod = std::make_unique<XFormObjectData_Lattice>();
369 xod->id = id;
370 xod->is_edit_mode = is_edit_mode;
371 xod->positions = BKE_lattice_vert_coords_alloc(lt);
372
373 if (key != nullptr) {
374 const size_t key_size = BKE_keyblock_element_calc_size_from_shape(key, key_index);
375 if (key_size) {
376 xod->key_data.reinitialize(key_size);
377 BKE_keyblock_data_get_from_shape(key, xod->key_data, key_index);
378 }
379 }
380
381 return xod;
382 }
383 case ID_CU_LEGACY: {
384 Curve *cu = id_cast<Curve *>(id);
385 Key *key = cu->key;
386
387 if (cu->ob_type == OB_FONT) {
388 /* We could support translation. */
389 break;
390 }
391
392 const int key_index = -1;
393 ListBaseT<Nurb> *nurbs;
394 if (is_edit_mode) {
395 EditNurb *editnurb = cu->editnurb;
396 nurbs = &editnurb->nurbs;
397 /* Always operate on all keys for the moment. */
398 // key_index = editnurb->shapenr - 1;
399 }
400 else {
401 nurbs = &cu->nurb;
402 }
403
404 auto xod = std::make_unique<XFormObjectData_Curve>();
405 xod->id = id;
406 xod->is_edit_mode = is_edit_mode;
407 xod->positions = BKE_curve_nurbs_vert_coords_alloc(nurbs);
408
409 if (key != nullptr) {
410 const size_t key_size = BKE_keyblock_element_calc_size_from_shape(key, key_index);
411 if (key_size) {
412 xod->key_data.reinitialize(key_size);
413 BKE_keyblock_data_get_from_shape(key, xod->key_data, key_index);
414 }
415 }
416
417 return xod;
418 }
419 case ID_AR: {
420 bArmature *arm = id_cast<bArmature *>(id);
421 if (is_edit_mode) {
422 auto xod = std::make_unique<XFormObjectData_Armature>();
423 xod->id = id;
424 xod->is_edit_mode = is_edit_mode;
425 xod->elems.reinitialize(arm->edbo->count());
426 edit_armature_coords_and_quats_get(arm, xod->elems);
427 return xod;
428 }
429 auto xod = std::make_unique<XFormObjectData_Armature>();
430 xod->id = id;
431 xod->is_edit_mode = is_edit_mode;
432 xod->elems.reinitialize(BKE_armature_bonelist_count(&arm->bonebase));
433 armature_coords_and_quats_get(arm, xod->elems);
434 return xod;
435 }
436 case ID_MB: {
437 /* Edit mode and object mode are shared. */
438 MetaBall *mb = id_cast<MetaBall *>(id);
439 auto xod = std::make_unique<XFormObjectData_MetaBall>();
440 xod->id = id;
441 xod->is_edit_mode = is_edit_mode;
442 xod->elems.reinitialize(mb->elems.count());
444 return xod;
445 }
446 case ID_GP: {
447 GreasePencil *grease_pencil = id_cast<GreasePencil *>(id);
448 const int elem_array_len = BKE_grease_pencil_stroke_point_count(*grease_pencil);
449 auto xod = std::make_unique<XFormObjectData_GreasePencil>();
450 xod->id = id;
452 xod->positions.reinitialize(elem_array_len);
453 }
454 else {
455 xod->positions.reinitialize(elem_array_len * 3);
456 }
457 xod->radii.reinitialize(elem_array_len);
458 BKE_grease_pencil_point_coords_get(*grease_pencil, xod->positions, xod->radii);
459 return xod;
460 }
461 case ID_CV: {
462 Curves *curves_id = reinterpret_cast<Curves *>(id);
463 const bke::CurvesGeometry &curves = curves_id->geometry.wrap();
464 auto xod = std::make_unique<XFormObjectData_Curves>();
465 xod->id = id;
466
467 if (!curves.has_curve_with_type(CURVE_TYPE_BEZIER)) {
468 xod->positions = curves.positions();
469 }
470 else {
472 curves.curves_range());
473 }
474
475 xod->radii.reinitialize(curves.points_num());
476 curves.radius().materialize(xod->radii);
477 return xod;
478 }
479 case ID_PT: {
480 PointCloud *pointcloud = reinterpret_cast<PointCloud *>(id);
481 auto xod = std::make_unique<XFormObjectData_PointCloud>();
482 xod->id = id;
483 xod->positions = pointcloud->positions();
484 xod->radii.reinitialize(pointcloud->totpoint);
485 pointcloud->radius().materialize(xod->radii);
486 return xod;
487 }
488 default: {
489 return {};
490 }
491 }
492 return {};
493}
494
495std::unique_ptr<XFormObjectData> data_xform_create(ID *id)
496{
497 return data_xform_create_ex(id, false);
498}
499
500std::unique_ptr<XFormObjectData> data_xform_create_from_edit_mode(ID *id)
501{
502 return data_xform_create_ex(id, true);
503}
504
506 const float4x4 &transform,
508{
509 const float scale = mat4_to_scale(transform.ptr());
510 threading::parallel_for(src.index_range(), 1024, [&](const IndexRange range) {
511 for (const int i : range) {
512 dst[i] = src[i] * scale;
513 }
514 });
515}
516
518{
519 switch (GS(xod_base.id->name)) {
520 case ID_ME: {
521 Mesh *mesh = id_cast<Mesh *>(xod_base.id);
522
523 Key *key = mesh->key;
524 const int key_index = -1;
525
526 const auto &xod = reinterpret_cast<XFormObjectData_Mesh &>(xod_base);
527 if (xod.is_edit_mode) {
530 /* Always operate on all keys for the moment. */
531 // key_index = bm->shapenr - 1;
532 }
533 else {
534 math::transform_points(xod.positions, transform, mesh->vert_positions_for_write());
535 mesh->tag_positions_changed();
536 }
537
538 if (key != nullptr) {
539 BKE_keyblock_data_set_with_mat4(key, key_index, xod.key_data, transform);
540 }
541
542 break;
543 }
544 case ID_LT: {
545 const auto &xod = reinterpret_cast<XFormObjectData_Lattice &>(xod_base);
546 Lattice *lt_orig = id_cast<Lattice *>(xod_base.id);
547 Lattice *lt = xod.is_edit_mode ? lt_orig->editlatt->latt : lt_orig;
548
549 Key *key = lt->key;
550 const int key_index = -1;
551
553 if (xod.is_edit_mode) {
554 /* Always operate on all keys for the moment. */
555 // key_index = lt_orig->editlatt->shapenr - 1;
556 }
557
558 if ((key != nullptr) && !xod.key_data.is_empty()) {
559 BKE_keyblock_data_set_with_mat4(key, key_index, xod.key_data, transform);
560 }
561
562 break;
563 }
564 case ID_CU_LEGACY: {
565 const auto &xod = reinterpret_cast<XFormObjectData_Curve &>(xod_base);
566 BLI_assert(xod.is_edit_mode == false); /* Not used currently. */
567 Curve *cu = id_cast<Curve *>(xod_base.id);
568
569 Key *key = cu->key;
570 const int key_index = -1;
571 const ListBaseT<Nurb> *nurb = nullptr;
572
573 if (xod.is_edit_mode) {
574 EditNurb *editnurb = cu->editnurb;
575 nurb = &editnurb->nurbs;
577 &editnurb->nurbs, xod.positions, transform, CU_IS_2D(cu));
578 /* Always operate on all keys for the moment. */
579 // key_index = editnurb->shapenr - 1;
580 }
581 else {
582 nurb = &cu->nurb;
584 &cu->nurb, xod.positions, transform, CU_IS_2D(cu));
585 }
586
587 if ((key != nullptr) && !xod.key_data.is_empty()) {
589 key, nurb, key_index, xod.key_data.data(), transform);
590 }
591
592 break;
593 }
594 case ID_AR: {
595 const auto &xod = reinterpret_cast<XFormObjectData_Armature &>(xod_base);
596 BLI_assert(xod.is_edit_mode == false); /* Not used currently. */
597 bArmature *arm = id_cast<bArmature *>(xod_base.id);
598 if (xod.is_edit_mode) {
600 }
601 else {
603 }
604 break;
605 }
606 case ID_MB: {
607 /* Meta-balls are a special case, edit-mode and object mode data is shared. */
608 MetaBall *mb = id_cast<MetaBall *>(xod_base.id);
609 const auto &xod = reinterpret_cast<XFormObjectData_MetaBall &>(xod_base);
611 break;
612 }
613 case ID_GP: {
614 GreasePencil *grease_pencil = id_cast<GreasePencil *>(xod_base.id);
615 const auto &xod = reinterpret_cast<XFormObjectData_GreasePencil &>(xod_base);
617 *grease_pencil, xod.positions, xod.radii, transform);
618 break;
619 }
620 case ID_CV: {
621 Curves *curves_id = reinterpret_cast<Curves *>(xod_base.id);
622 bke::CurvesGeometry &curves = curves_id->geometry.wrap();
623 const auto &xod = reinterpret_cast<const XFormObjectData_Curves &>(xod_base);
624 if (!curves.has_curve_with_type(CURVE_TYPE_BEZIER)) {
625 math::transform_points(xod.positions, transform, curves.positions_for_write());
626 }
627 else {
628 Array<float3> transformed_positions(xod.positions.size());
629 math::transform_points(xod.positions, transform, transformed_positions);
631 curves, curves.curves_range(), transformed_positions);
632 }
633 copy_transformed_radii(xod.radii, transform, curves.radius_for_write());
634 break;
635 }
636 case ID_PT: {
637 PointCloud *pointcloud = reinterpret_cast<PointCloud *>(xod_base.id);
638 const auto &xod = reinterpret_cast<const XFormObjectData_PointCloud &>(xod_base);
639 math::transform_points(xod.positions, transform, pointcloud->positions_for_write());
640 copy_transformed_radii(xod.radii, transform, pointcloud->radius_for_write());
641 break;
642 }
643 default: {
644 break;
645 }
646 }
647}
648
650{
651 switch (GS(xod_base.id->name)) {
652 case ID_ME: {
653 Mesh *mesh = id_cast<Mesh *>(xod_base.id);
654
655 Key *key = mesh->key;
656 const int key_index = -1;
657
658 const auto &xod = reinterpret_cast<XFormObjectData_Mesh &>(xod_base);
659 if (xod.is_edit_mode) {
661 BM_mesh_vert_coords_apply(bm, xod.positions);
662 /* Always operate on all keys for the moment. */
663 // key_index = bm->shapenr - 1;
664 }
665 else {
666 mesh->vert_positions_for_write().copy_from(xod.positions);
667 mesh->tag_positions_changed();
668 }
669
670 if ((key != nullptr) && !xod.key_data.is_empty()) {
671 BKE_keyblock_data_set(key, key_index, xod.key_data.data());
672 }
673
674 break;
675 }
676 case ID_LT: {
677 const auto &xod = reinterpret_cast<XFormObjectData_Lattice &>(xod_base);
678 Lattice *lt_orig = id_cast<Lattice *>(xod_base.id);
679 Lattice *lt = xod.is_edit_mode ? lt_orig->editlatt->latt : lt_orig;
680
681 Key *key = lt->key;
682 const int key_index = -1;
683
684 BKE_lattice_vert_coords_apply(lt, xod.positions);
685 if (xod.is_edit_mode) {
686 /* Always operate on all keys for the moment. */
687 // key_index = lt_orig->editlatt->shapenr - 1;
688 }
689
690 if ((key != nullptr) && !xod.key_data.is_empty()) {
691 BKE_keyblock_data_set(key, key_index, xod.key_data.data());
692 }
693
694 break;
695 }
696 case ID_CU_LEGACY: {
697 Curve *cu = id_cast<Curve *>(xod_base.id);
698
699 Key *key = cu->key;
700 const int key_index = -1;
701
702 const auto &xod = reinterpret_cast<XFormObjectData_Curve &>(xod_base);
703 if (xod.is_edit_mode) {
704 EditNurb *editnurb = cu->editnurb;
705 BKE_curve_nurbs_vert_coords_apply(&editnurb->nurbs, xod.positions, CU_IS_2D(cu));
706 /* Always operate on all keys for the moment. */
707 // key_index = editnurb->shapenr - 1;
708 }
709 else {
710 BKE_curve_nurbs_vert_coords_apply(&cu->nurb, xod.positions, CU_IS_2D(cu));
711 }
712
713 if ((key != nullptr) && !xod.key_data.is_empty()) {
714 BKE_keyblock_data_set(key, key_index, xod.key_data.data());
715 }
716
717 break;
718 }
719 case ID_AR: {
720 bArmature *arm = id_cast<bArmature *>(xod_base.id);
721 const auto &xod = reinterpret_cast<XFormObjectData_Armature &>(xod_base);
722 if (xod.is_edit_mode) {
724 }
725 else {
726 armature_coords_and_quats_apply(arm, xod.elems);
727 }
728 break;
729 }
730 case ID_MB: {
731 /* Meta-balls are a special case, edit-mode and object mode data is shared. */
732 MetaBall *mb = id_cast<MetaBall *>(xod_base.id);
733 const auto &xod = reinterpret_cast<XFormObjectData_MetaBall &>(xod_base);
735 break;
736 }
737 case ID_GP: {
738 GreasePencil *grease_pencil = id_cast<GreasePencil *>(xod_base.id);
739 const auto &xod = reinterpret_cast<XFormObjectData_GreasePencil &>(xod_base);
740 BKE_grease_pencil_point_coords_apply(*grease_pencil, xod.positions, xod.radii);
741 break;
742 }
743 case ID_CV: {
744 Curves *curves_id = reinterpret_cast<Curves *>(xod_base.id);
745 bke::CurvesGeometry &curves = curves_id->geometry.wrap();
746 const auto &xod = reinterpret_cast<const XFormObjectData_Curves &>(xod_base);
747 if (!curves.has_curve_with_type(CURVE_TYPE_BEZIER)) {
748 curves.positions_for_write().copy_from(xod.positions);
749 }
750 else {
751 bke::curves::bezier::write_all_positions(curves, curves.curves_range(), xod.positions);
752 }
753 curves.radius_for_write().copy_from(xod.radii);
754 break;
755 }
756 case ID_PT: {
757 PointCloud *pointcloud = reinterpret_cast<PointCloud *>(xod_base.id);
758 const auto &xod = reinterpret_cast<const XFormObjectData_PointCloud &>(xod_base);
759 pointcloud->positions_for_write().copy_from(xod.positions);
760 pointcloud->radius_for_write().copy_from(xod.radii);
761 break;
762 }
763 default: {
764 break;
765 }
766 }
767}
768
770{
771 switch (GS(xod_base.id->name)) {
772 case ID_ME: {
773 Mesh *mesh = id_cast<Mesh *>(xod_base.id);
774 const auto &xod = reinterpret_cast<XFormObjectData_Mesh &>(xod_base);
775 if (xod.is_edit_mode) {
776 EDBMUpdate_Params params{};
777 params.calc_looptris = true;
778 params.calc_normals = true;
779 params.is_destructive = false;
780 EDBM_update(mesh, &params);
781 }
783 break;
784 }
785 case ID_LT: {
786 /* Generic update. */
787 Lattice *lt = id_cast<Lattice *>(xod_base.id);
789 break;
790 }
791 case ID_CU_LEGACY: {
792 /* Generic update. */
793 Curve *cu = id_cast<Curve *>(xod_base.id);
795 break;
796 }
797 case ID_AR: {
798 /* Generic update. */
799 bArmature *arm = id_cast<bArmature *>(xod_base.id);
800 /* XXX, zero is needed, no other flags properly update this. */
801 DEG_id_tag_update(&arm->id, 0);
802 break;
803 }
804 case ID_MB: {
805 /* Generic update. */
806 MetaBall *mb = id_cast<MetaBall *>(xod_base.id);
808 break;
809 }
810 case ID_GD_LEGACY: {
811 /* Generic update. */
812 bGPdata *gpd = id_cast<bGPdata *>(xod_base.id);
814 break;
815 }
816 case ID_GP: {
817 /* Generic update. */
818 GreasePencil *grease_pencil = id_cast<GreasePencil *>(xod_base.id);
820 break;
821 }
822 case ID_CV: {
823 Curves *curves_id = reinterpret_cast<Curves *>(xod_base.id);
824 bke::CurvesGeometry &curves = curves_id->geometry.wrap();
825 curves.tag_positions_changed();
826 curves.tag_radii_changed();
828 break;
829 }
830 case ID_PT: {
831 PointCloud *pointcloud = reinterpret_cast<PointCloud *>(xod_base.id);
832 pointcloud->tag_positions_changed();
833 pointcloud->tag_radii_changed();
835 break;
836 }
837 default: {
838 break;
839 }
840 }
841}
842
844
845} // namespace blender::ed::object
#define CU_IS_2D(cu)
Definition BKE_curve.hh:93
Low-level operations for curves.
Low-level operations for grease pencil.
Object is a sort of wrapper for general info.
constexpr T * data() const
Definition BLI_span.hh:545
constexpr const T * data() const
Definition BLI_span.hh:219
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
float3x3 scale(float3x3 mat, float2 scale)
Array< float3 > retrieve_all_positions(const bke::CurvesGeometry &curves, const IndexMask &curves_selection)
void write_all_positions(bke::CurvesGeometry &curves, const IndexMask &curves_selection, Span< float3 > all_positions)
static void edit_armature_coords_and_quats_apply_with_mat4(bArmature *arm, const Span< ElemData_Armature > elem_array, const float4x4 &transform)
static void metaball_coords_and_quats_apply_with_mat4(MetaBall *mb, const Span< ElemData_MetaBall > elem_array, const float4x4 &transform)
static void edit_armature_coords_and_quats_get(const bArmature *arm, MutableSpan< ElemData_Armature > elem_array)
static ElemData_Armature * armature_coords_and_quats_get_recurse(const ListBaseT< Bone > *bone_base, ElemData_Armature *elem_array)
static void copy_transformed_radii(const Span< float > src, const float4x4 &transform, MutableSpan< float > dst)
static void armature_coords_and_quats_apply(bArmature *arm, const Span< ElemData_Armature > elem_array)
static void metaball_coords_and_quats_apply(MetaBall *mb, const Span< ElemData_MetaBall > elem_array)
void data_xform_by_mat4(XFormObjectData &xod, const float4x4 &transform)
std::unique_ptr< XFormObjectData > data_xform_create(ID *id)
void data_xform_restore(XFormObjectData &xod)
std::unique_ptr< XFormObjectData > data_xform_create_from_edit_mode(ID *id)
static void metaball_coords_and_quats_get(const MetaBall *mb, MutableSpan< ElemData_MetaBall > elem_array)
void data_xform_tag_update(XFormObjectData &xod)
static std::unique_ptr< XFormObjectData > data_xform_create_ex(ID *id, bool is_edit_mode)
static void armature_coords_and_quats_get(const bArmature *arm, MutableSpan< ElemData_Armature > elem_array)
static const ElemData_Armature * armature_coords_and_quats_apply_with_mat4_recurse(ListBaseT< Bone > *bone_base, const ElemData_Armature *elem_array, const float4x4 &transform)
static void armature_coords_and_quats_apply_with_mat4(bArmature *arm, const Span< ElemData_Armature > elem_array, const float4x4 &transform)
static void edit_armature_coords_and_quats_apply(bArmature *arm, const Span< ElemData_Armature > elem_array)
void transform_points(const float4x4 &transform, MutableSpan< float3 > points, bool use_threading=true)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_keyblock_data_set_with_mat4(Key *key, int shape_index, Span< float3 > coords, const float4x4 &transform)
Definition key.cc:1196
void BKE_keyblock_data_get_from_shape(const Key *key, MutableSpan< float3 > arr, int shape_index)
Definition key.cc:1176
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
Definition editmesh.cc:79
bool BKE_grease_pencil_has_curve_with_type(const GreasePencil &grease_pencil, CurveType type)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BM_mesh_vert_coords_apply_with_mat4(BMesh *bm, const Span< float3 > vert_coords, const float4x4 &transform)
void BM_mesh_vert_coords_apply(BMesh *bm, const Span< float3 > vert_coords)
float mat4_to_scale(const float mat[4][4])
void EDBM_update(Mesh *mesh, const EDBMUpdate_Params *params)
void BKE_keyblock_curve_data_set_with_mat4(Key *key, const ListBaseT< Nurb > *nurb, int shape_index, const void *data, const float4x4 &transform)
Definition key.cc:1222
void BKE_grease_pencil_point_coords_get(const GreasePencil &grease_pencil, MutableSpan< float3 > all_positions, MutableSpan< float > all_radii)
MatBase< float, 4, 4 > float4x4
Array< float3 > BKE_lattice_vert_coords_alloc(const Lattice *lt)
Definition lattice.cc:502
void ED_armature_edit_transform(bArmature *arm, const float mat[4][4], const bool do_props)
void BM_mesh_vert_coords_get(const BMesh *bm, MutableSpan< float3 > positions)
void BKE_grease_pencil_point_coords_apply_with_mat4(GreasePencil &grease_pencil, Span< float3 > all_positions, Span< float > all_radii, const float4x4 &mat)
void copy_qt_qt(float q[4], const float a[4])
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_curve_nurbs_vert_coords_apply(ListBaseT< Nurb > *lb, const Span< float3 > vert_coords, bool constrain_2d)
Definition curve.cc:4635
void BKE_curve_nurbs_vert_coords_apply_with_mat4(ListBaseT< Nurb > *lb, const Span< float3 >, const float4x4 &transform, bool constrain_2d)
Definition curve.cc:4599
void BKE_mball_transform(MetaBall *mb, const float mat[4][4], bool do_props)
Definition mball.cc:523
void BKE_lattice_vert_coords_apply_with_mat4(Lattice *lt, Span< float3 > vert_coordss, const float4x4 &transform)
Definition lattice.cc:510
Array< float3 > BKE_curve_nurbs_vert_coords_alloc(const ListBaseT< Nurb > *lb)
Definition curve.cc:4592
void BKE_grease_pencil_point_coords_apply(GreasePencil &grease_pencil, Span< float3 > all_positions, Span< float > all_radii)
void BKE_keyblock_data_set(Key *key, int shape_index, const void *data)
Definition key.cc:1239
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
ID_Type GS(const char *name)
Definition DNA_ID.h:410
int BKE_armature_bonelist_count(const ListBaseT< Bone > *lb)
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
Definition editmesh.cc:65
size_t BKE_keyblock_element_calc_size_from_shape(const Key *key, int shape_index)
Definition key.cc:1159
void BKE_lattice_vert_coords_apply(Lattice *lt, Span< float3 > vert_coordss)
Definition lattice.cc:520
void BKE_armature_transform(bArmature *arm, const float mat[4][4], bool do_props)
int BKE_grease_pencil_stroke_point_count(const GreasePencil &grease_pencil)
#define COPY_PTR(member)
#define COPY_VAL(member)
ListBaseT< Nurb > nurb
EditNurb * editnurb
struct Key * key
struct Lattice * latt
ListBaseT< Nurb > nurbs
char name[258]
Definition DNA_ID.h:433
struct EditLatt * editlatt
ListBaseT< MetaElem > elems
ListBaseT< EditBone > * edbo
ListBaseT< Bone > bonebase