Blender V4.5
lattice.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
8
9#include <cmath>
10#include <cstdlib>
11#include <cstring>
12
13#include "MEM_guardedalloc.h"
14
15#include "BLI_bitmap.h"
16#include "BLI_listbase.h"
17#include "BLI_math_matrix.h"
18#include "BLI_math_vector.h"
19#include "BLI_utildefines.h"
20
21#include "BLT_translation.hh"
22
23/* Allow using deprecated functionality for .blend file I/O. */
24#define DNA_DEPRECATED_ALLOW
25
26#include "DNA_curve_types.h"
27#include "DNA_defaults.h"
28#include "DNA_key_types.h"
29#include "DNA_lattice_types.h"
30#include "DNA_meshdata_types.h"
31#include "DNA_object_types.h"
32
33#include "BKE_curve.hh"
34#include "BKE_deform.hh"
35#include "BKE_displist.h"
36#include "BKE_idtype.hh"
37#include "BKE_lattice.hh"
38#include "BKE_lib_id.hh"
39#include "BKE_lib_query.hh"
40#include "BKE_modifier.hh"
41#include "BKE_object.hh"
42#include "BKE_object_types.hh"
43
44#include "BLO_read_write.hh"
45
46using blender::Array;
47using blender::float3;
50using blender::Span;
51
52static void lattice_init_data(ID *id)
53{
54 Lattice *lattice = (Lattice *)id;
55
57
59
60 lattice->def = MEM_callocN<BPoint>("lattvert"); /* temporary */
61 BKE_lattice_resize(lattice, 2, 2, 2, nullptr); /* creates a uniform lattice */
62}
63
64static void lattice_copy_data(Main *bmain,
65 std::optional<Library *> owner_library,
66 ID *id_dst,
67 const ID *id_src,
68 const int flag)
69{
70 Lattice *lattice_dst = (Lattice *)id_dst;
71 const Lattice *lattice_src = (const Lattice *)id_src;
72
73 lattice_dst->def = static_cast<BPoint *>(MEM_dupallocN(lattice_src->def));
74
75 if (lattice_src->key && (flag & LIB_ID_COPY_SHAPEKEY)) {
77 owner_library,
78 &lattice_src->key->id,
79 &lattice_dst->id,
80 reinterpret_cast<ID **>(&lattice_dst->key),
81 flag);
82 }
83
85
86 if (lattice_src->dvert) {
87 int tot = lattice_src->pntsu * lattice_src->pntsv * lattice_src->pntsw;
88 lattice_dst->dvert = MEM_malloc_arrayN<MDeformVert>(size_t(tot), "Lattice MDeformVert");
89 BKE_defvert_array_copy(lattice_dst->dvert, lattice_src->dvert, tot);
90 }
91
92 lattice_dst->editlatt = nullptr;
93 lattice_dst->batch_cache = nullptr;
94}
95
96static void lattice_free_data(ID *id)
97{
98 Lattice *lattice = (Lattice *)id;
99
101
103
104 MEM_SAFE_FREE(lattice->def);
105 if (lattice->dvert) {
106 BKE_defvert_array_free(lattice->dvert, lattice->pntsu * lattice->pntsv * lattice->pntsw);
107 lattice->dvert = nullptr;
108 }
109 if (lattice->editlatt) {
110 Lattice *editlt = lattice->editlatt->latt;
111
112 if (editlt->def) {
113 MEM_freeN(editlt->def);
114 }
115 if (editlt->dvert) {
116 BKE_defvert_array_free(editlt->dvert, lattice->pntsu * lattice->pntsv * lattice->pntsw);
117 }
118
119 MEM_freeN(editlt);
120 MEM_freeN(lattice->editlatt);
121 lattice->editlatt = nullptr;
122 }
123}
124
126{
127 Lattice *lattice = reinterpret_cast<Lattice *>(id);
129
131
134 }
135}
136
137static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
138{
139 Lattice *lt = (Lattice *)id;
140
141 /* Clean up, important in undo case to reduce false detection of changed datablocks. */
142 lt->editlatt = nullptr;
143 lt->batch_cache = nullptr;
144
145 /* write LibData */
146 BLO_write_id_struct(writer, Lattice, id_address, &lt->id);
147 BKE_id_blend_write(writer, &lt->id);
148
149 /* direct data */
150 BLO_write_struct_array(writer, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def);
151
153 BKE_defvert_blend_write(writer, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
154}
155
157{
158 Lattice *lt = (Lattice *)id;
159 BLO_read_struct_array(reader, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, &lt->def);
160
161 BLO_read_struct_array(reader, MDeformVert, lt->pntsu * lt->pntsv * lt->pntsw, &lt->dvert);
162 BKE_defvert_blend_read(reader, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
164
165 lt->editlatt = nullptr;
166 lt->batch_cache = nullptr;
167}
168
170 /*id_code*/ Lattice::id_type,
171 /*id_filter*/ FILTER_ID_LT,
172 /*dependencies_id_types*/ FILTER_ID_KE,
173 /*main_listbase_index*/ INDEX_ID_LT,
174 /*struct_size*/ sizeof(Lattice),
175 /*name*/ "Lattice",
176 /*name_plural*/ N_("lattices"),
177 /*translation_context*/ BLT_I18NCONTEXT_ID_LATTICE,
179 /*asset_type_info*/ nullptr,
180
181 /*init_data*/ lattice_init_data,
182 /*copy_data*/ lattice_copy_data,
183 /*free_data*/ lattice_free_data,
184 /*make_local*/ nullptr,
185 /*foreach_id*/ lattice_foreach_id,
186 /*foreach_cache*/ nullptr,
187 /*foreach_path*/ nullptr,
188 /*owner_pointer_get*/ nullptr,
189
190 /*blend_write*/ lattice_blend_write,
191 /*blend_read_data*/ lattice_blend_read_data,
192 /*blend_read_after_liblink*/ nullptr,
193
194 /*blend_read_undo_preserve*/ nullptr,
195
196 /*lib_override_apply_post*/ nullptr,
197};
198
199int BKE_lattice_index_from_uvw(const Lattice *lt, const int u, const int v, const int w)
200{
201 const int totu = lt->pntsu;
202 const int totv = lt->pntsv;
203
204 return (w * (totu * totv) + (v * totu) + u);
205}
206
207void BKE_lattice_index_to_uvw(const Lattice *lt, const int index, int *r_u, int *r_v, int *r_w)
208{
209 const int totu = lt->pntsu;
210 const int totv = lt->pntsv;
211
212 *r_u = (index % totu);
213 *r_v = (index / totu) % totv;
214 *r_w = (index / (totu * totv));
215}
216
218 const Lattice *lt, const int index, const bool flip_u, const bool flip_v, const bool flip_w)
219{
220 int u, v, w;
221
222 BKE_lattice_index_to_uvw(lt, index, &u, &v, &w);
223
224 if (flip_u) {
225 u = (lt->pntsu - 1) - u;
226 }
227
228 if (flip_v) {
229 v = (lt->pntsv - 1) - v;
230 }
231
232 if (flip_w) {
233 w = (lt->pntsw - 1) - w;
234 }
235
236 return BKE_lattice_index_from_uvw(lt, u, v, w);
237}
238
240 BLI_bitmap *bitmap,
241 const uint8_t flag,
242 const bool clear,
243 const bool respecthide)
244{
245 const uint tot = lt->pntsu * lt->pntsv * lt->pntsw;
246 BPoint *bp;
247
248 bp = lt->def;
249 for (int i = 0; i < tot; i++, bp++) {
250 if ((bp->f1 & flag) && (!respecthide || !bp->hide)) {
251 BLI_BITMAP_ENABLE(bitmap, i);
252 }
253 else {
254 if (clear) {
255 BLI_BITMAP_DISABLE(bitmap, i);
256 }
257 }
258 }
259}
260
261void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
262{
263 if (res == 1) {
264 *r_fu = 0.0;
265 *r_du = 0.0;
266 }
267 else if (flag & LT_GRID) {
268 *r_fu = -0.5f * (res - 1);
269 *r_du = 1.0f;
270 }
271 else {
272 *r_fu = -1.0f;
273 *r_du = 2.0f / (res - 1);
274 }
275}
276
277void BKE_lattice_resize(Lattice *lt, int u_new, int v_new, int w_new, Object *lt_ob)
278{
279 BPoint *bp;
280 int i, u, v, w;
281 float fu, fv, fw, uc, vc, wc, du = 0.0, dv = 0.0, dw = 0.0;
282 float *co, (*vert_coords)[3] = nullptr;
283
284 /* vertex weight groups are just freed all for now */
285 if (lt->dvert) {
286 BKE_defvert_array_free(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw);
287 lt->dvert = nullptr;
288 }
289
290 while (u_new * v_new * w_new > 32000) {
291 if (u_new >= v_new && u_new >= w_new) {
292 u_new--;
293 }
294 else if (v_new >= u_new && v_new >= w_new) {
295 v_new--;
296 }
297 else {
298 w_new--;
299 }
300 }
301
302 vert_coords = MEM_malloc_arrayN<float[3]>(size_t(u_new) * size_t(v_new) * size_t(w_new),
303 "tmp_vcos");
304
305 calc_lat_fudu(lt->flag, u_new, &fu, &du);
306 calc_lat_fudu(lt->flag, v_new, &fv, &dv);
307 calc_lat_fudu(lt->flag, w_new, &fw, &dw);
308
309 /* If old size is different than resolution changed in interface,
310 * try to do clever reinitialize of points. Pretty simply idea, we just
311 * deform new verts by old lattice, but scaling them to match old
312 * size first.
313 */
314 if (lt_ob) {
315 const float default_size = 1.0;
316
317 if (u_new != 1) {
318 fu = -default_size / 2.0;
319 du = default_size / (u_new - 1);
320 }
321
322 if (v_new != 1) {
323 fv = -default_size / 2.0;
324 dv = default_size / (v_new - 1);
325 }
326
327 if (w_new != 1) {
328 fw = -default_size / 2.0;
329 dw = default_size / (w_new - 1);
330 }
331 }
332
333 co = vert_coords[0];
334 for (w = 0, wc = fw; w < w_new; w++, wc += dw) {
335 for (v = 0, vc = fv; v < v_new; v++, vc += dv) {
336 for (u = 0, uc = fu; u < u_new; u++, co += 3, uc += du) {
337 co[0] = uc;
338 co[1] = vc;
339 co[2] = wc;
340 }
341 }
342 }
343
344 if (lt_ob) {
345 float mat[4][4];
346 int typeu = lt->typeu, typev = lt->typev, typew = lt->typew;
347
348 /* works best if we force to linear type (endpoints match) */
349 lt->typeu = lt->typev = lt->typew = KEY_LINEAR;
350
351 if (lt_ob->runtime->curve_cache) {
352 /* prevent using deformed locations */
353 BKE_displist_free(&lt_ob->runtime->curve_cache->disp);
354 }
355
356 copy_m4_m4(mat, lt_ob->object_to_world().ptr());
357 unit_m4(lt_ob->runtime->object_to_world.ptr());
359 lt_ob, nullptr, vert_coords, u_new * v_new * w_new, 0, nullptr, 1.0f);
360 copy_m4_m4(lt_ob->runtime->object_to_world.ptr(), mat);
361
362 lt->typeu = typeu;
363 lt->typev = typev;
364 lt->typew = typew;
365 }
366
367 lt->fu = fu;
368 lt->fv = fv;
369 lt->fw = fw;
370 lt->du = du;
371 lt->dv = dv;
372 lt->dw = dw;
373
374 lt->pntsu = u_new;
375 lt->pntsv = v_new;
376 lt->pntsw = w_new;
377
378 lt->actbp = LT_ACTBP_NONE;
379 MEM_freeN(lt->def);
380 lt->def = MEM_calloc_arrayN<BPoint>(size_t(lt->pntsu) * size_t(lt->pntsv) * size_t(lt->pntsw),
381 "lattice bp");
382
383 bp = lt->def;
384
385 for (i = 0; i < lt->pntsu * lt->pntsv * lt->pntsw; i++, bp++) {
386 copy_v3_v3(bp->vec, vert_coords[i]);
387 }
388
389 MEM_freeN(vert_coords);
390}
391
392Lattice *BKE_lattice_add(Main *bmain, const char *name)
393{
394 Lattice *lt;
395
396 lt = BKE_id_new<Lattice>(bmain, name);
397
398 return lt;
399}
400
401static BPoint *latt_bp(Lattice *lt, int u, int v, int w)
402{
403 return &lt->def[BKE_lattice_index_from_uvw(lt, u, v, w)];
404}
405
407{
408 BPoint *bp, *bp1, *bp2;
409 int u, v, w;
410 float fac1, du = 0.0, dv = 0.0, dw = 0.0;
411
412 if (lt->flag & LT_OUTSIDE) {
413 bp = lt->def;
414
415 if (lt->pntsu > 1) {
416 du = 1.0f / float(lt->pntsu - 1);
417 }
418 if (lt->pntsv > 1) {
419 dv = 1.0f / float(lt->pntsv - 1);
420 }
421 if (lt->pntsw > 1) {
422 dw = 1.0f / float(lt->pntsw - 1);
423 }
424
425 for (w = 0; w < lt->pntsw; w++) {
426
427 for (v = 0; v < lt->pntsv; v++) {
428
429 for (u = 0; u < lt->pntsu; u++, bp++) {
430 if (u == 0 || v == 0 || w == 0 || u == lt->pntsu - 1 || v == lt->pntsv - 1 ||
431 w == lt->pntsw - 1)
432 {
433 /* pass */
434 }
435 else {
436 bp->hide = 1;
437 bp->f1 &= ~SELECT;
438
439 /* U extrema. */
440 bp1 = latt_bp(lt, 0, v, w);
441 bp2 = latt_bp(lt, lt->pntsu - 1, v, w);
442
443 fac1 = du * u;
444 bp->vec[0] = (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
445 bp->vec[1] = (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
446 bp->vec[2] = (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
447
448 /* V extrema. */
449 bp1 = latt_bp(lt, u, 0, w);
450 bp2 = latt_bp(lt, u, lt->pntsv - 1, w);
451
452 fac1 = dv * v;
453 bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
454 bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
455 bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
456
457 /* W extrema. */
458 bp1 = latt_bp(lt, u, v, 0);
459 bp2 = latt_bp(lt, u, v, lt->pntsw - 1);
460
461 fac1 = dw * w;
462 bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
463 bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
464 bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
465
466 mul_v3_fl(bp->vec, 1.0f / 3.0f);
467 }
468 }
469 }
470 }
471 }
472 else {
473 bp = lt->def;
474
475 for (w = 0; w < lt->pntsw; w++) {
476 for (v = 0; v < lt->pntsv; v++) {
477 for (u = 0; u < lt->pntsu; u++, bp++) {
478 bp->hide = 0;
479 }
480 }
481 }
482 }
483}
484
486{
487 const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
488 for (int i = 0; i < vert_len; i++) {
489 vert_coords[i] = lt->def[i].vec;
490 }
491}
492
494{
495 const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
496 Array<float3> vert_coords(vert_len);
497 BKE_lattice_vert_coords_get(lt, vert_coords);
498 return vert_coords;
499}
500
502 const Span<float3> vert_coords,
503 const float4x4 &transform)
504{
505 int i, numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
506 for (i = 0; i < numVerts; i++) {
507 mul_v3_m4v3(lt->def[i].vec, transform.ptr(), vert_coords[i]);
508 }
509}
510
512{
513 const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
514 for (int i = 0; i < vert_len; i++) {
515 copy_v3_v3(lt->def[i].vec, vert_coords[i]);
516 }
517}
518
520{
522 if (ob->runtime->curve_cache == nullptr) {
523 ob->runtime->curve_cache = MEM_callocN<CurveCache>("CurveCache for lattice");
524 }
525
526 Lattice *lt = static_cast<Lattice *>(ob->data);
527 VirtualModifierData virtual_modifier_data;
528 ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtual_modifier_data);
529 Array<float3> vert_coords;
530 const bool is_editmode = (lt->editlatt != nullptr);
531 const ModifierEvalContext mectx = {depsgraph, ob, ModifierApplyFlag(0)};
532
533 for (; md; md = md->next) {
535
537 continue;
538 }
539 if (!(md->mode & eModifierMode_Realtime)) {
540 continue;
541 }
542 if (is_editmode && !(md->mode & eModifierMode_Editmode)) {
543 continue;
544 }
545 if (mti->is_disabled && mti->is_disabled(scene, md, false)) {
546 continue;
547 }
549 continue;
550 }
551
552 if (vert_coords.is_empty()) {
553 /* Get either the edit-mode or regular lattice, whichever is in use now. */
554 const Lattice *effective_lattice = BKE_object_get_lattice(ob);
555 vert_coords = BKE_lattice_vert_coords_alloc(effective_lattice);
556 }
557
558 mti->deform_verts(md, &mectx, nullptr, vert_coords);
559 }
560
561 if (vert_coords.is_empty()) {
562 return;
563 }
564
566 if (lt_eval == nullptr) {
567 BKE_id_copy_ex(nullptr, &lt->id, (ID **)&lt_eval, LIB_ID_COPY_LOCALIZE);
568 BKE_object_eval_assign_data(ob, &lt_eval->id, true);
569 }
570
571 BKE_lattice_vert_coords_apply(lt_eval, vert_coords);
572}
573
575{
576 BLI_assert(oblatt->type == OB_LATTICE);
577 Lattice *lt = BKE_object_get_lattice(oblatt);
578 return lt->dvert;
579}
580
582{
583 BLI_assert(GS(lt->id.name) == ID_LT);
584
585 if (lt->editlatt) {
586 lt = lt->editlatt->latt;
587 }
588
589 BLI_assert(lt->actbp < lt->pntsu * lt->pntsv * lt->pntsw);
590
591 if ((lt->actbp != LT_ACTBP_NONE) && (lt->actbp < lt->pntsu * lt->pntsv * lt->pntsw)) {
592 return &lt->def[lt->actbp];
593 }
594
595 return nullptr;
596}
597
598void BKE_lattice_center_median(Lattice *lt, float cent[3])
599{
600 int i, numVerts;
601
602 if (lt->editlatt) {
603 lt = lt->editlatt->latt;
604 }
605 numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
606
607 zero_v3(cent);
608
609 for (i = 0; i < numVerts; i++) {
610 add_v3_v3(cent, lt->def[i].vec);
611 }
612
613 mul_v3_fl(cent, 1.0f / float(numVerts));
614}
615
616std::optional<blender::Bounds<blender::float3>> BKE_lattice_minmax(const Lattice *lt)
617{
618 int i, numVerts;
619
620 if (lt->editlatt) {
621 lt = lt->editlatt->latt;
622 }
623 numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
624 if (numVerts == 0) {
625 return std::nullopt;
626 }
627
628 blender::float3 min = lt->def[0].vec;
629 blender::float3 max = lt->def[0].vec;
630 for (i = 0; i < numVerts; i++) {
631 minmax_v3v3_v3(min, max, lt->def[i].vec);
632 }
634}
635
636void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
637{
638 BPoint *bp = lt->def;
639 int i = lt->pntsu * lt->pntsv * lt->pntsw;
640
641 while (i--) {
642 mul_m4_v3(mat, bp->vec);
643 bp++;
644 }
645
646 if (do_keys && lt->key) {
647 LISTBASE_FOREACH (KeyBlock *, kb, &lt->key->block) {
648 float *fp = static_cast<float *>(kb->data);
649 for (i = kb->totelem; i--; fp += 3) {
650 mul_m4_v3(mat, fp);
651 }
652 }
653 }
654}
655
656void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys)
657{
658 int i, numVerts;
659
660 numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
661
662 if (lt->def) {
663 for (i = 0; i < numVerts; i++) {
664 add_v3_v3(lt->def[i].vec, offset);
665 }
666 }
667
668 if (lt->editlatt) {
669 for (i = 0; i < numVerts; i++) {
670 add_v3_v3(lt->editlatt->latt->def[i].vec, offset);
671 }
672 }
673
674 if (do_keys && lt->key) {
675 LISTBASE_FOREACH (KeyBlock *, kb, &lt->key->block) {
676 float *fp = static_cast<float *>(kb->data);
677 for (i = kb->totelem; i--; fp += 3) {
678 add_v3_v3(fp, offset);
679 }
680 }
681 }
682}
683
685{
686 /* Intentionally don't handle 'lt->editlatt' (caller must do this). */
687 const BPoint *bp = lt->def;
688 int a = lt->pntsu * lt->pntsv * lt->pntsw;
689 while (a--) {
690 if (bp->hide == 0) {
691 if (bp->f1 & SELECT) {
692 return true;
693 }
694 }
695 bp++;
696 }
697 return false;
698}
699
700/* **** Depsgraph evaluation **** */
701
702void BKE_lattice_eval_geometry(Depsgraph * /*depsgraph*/, Lattice * /*latt*/) {}
703
704/* Draw Engine */
705
706void (*BKE_lattice_batch_cache_dirty_tag_cb)(Lattice *lt, int mode) = nullptr;
708
710{
711 if (lt->batch_cache) {
713 }
714}
716{
717 if (lt->batch_cache) {
719 }
720}
support for deformation groups and hooks.
void BKE_defvert_blend_write(BlendWriter *writer, int count, const MDeformVert *dvlist)
Definition deform.cc:1639
void BKE_defbase_blend_write(BlendWriter *writer, const ListBase *defbase)
Definition deform.cc:1632
void BKE_defvert_array_free(MDeformVert *dvert, int totvert)
Definition deform.cc:1063
void BKE_defvert_array_copy(MDeformVert *dst, const MDeformVert *src, int totvert)
Definition deform.cc:1027
void BKE_defgroup_copy_list(ListBase *outbase, const ListBase *inbase)
Definition deform.cc:71
void BKE_defvert_blend_read(BlendDataReader *reader, int count, MDeformVert *mdverts)
Definition deform.cc:1656
display list (or rather multi purpose list) stuff.
void BKE_displist_free(struct ListBase *lb)
Definition displist.cc:64
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
Definition BKE_idtype.hh:44
IDTypeInfo IDType_ID_LT
Definition lattice.cc:169
void BKE_lattice_deform_coords(const Object *ob_lattice, const Object *ob_target, float(*vert_coords)[3], int vert_coords_len, short flag, const char *defgrp_name, float fac)
void(* BKE_lattice_batch_cache_dirty_tag_cb)(Lattice *lt, int mode)
Definition lattice.cc:706
void(* BKE_lattice_batch_cache_free_cb)(Lattice *lt)
Definition lattice.cc:707
struct ID * BKE_id_copy_in_lib(Main *bmain, std::optional< Library * > owner_library, const ID *id, std::optional< const ID * > new_owner_id, ID **new_id_p, int flag)
Definition lib_id.cc:663
@ LIB_ID_COPY_LOCALIZE
@ LIB_ID_COPY_SHAPEKEY
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
Definition lib_id.cc:767
void * BKE_id_new(Main *bmain, short type, const char *name)
Definition lib_id.cc:1495
void BKE_id_blend_write(BlendWriter *writer, ID *id)
Definition lib_id.cc:2611
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
@ IDWALK_CB_USER
LibraryForeachIDFlag BKE_lib_query_foreachid_process_flags_get(const LibraryForeachIDData *data)
Definition lib_query.cc:129
@ IDWALK_DO_DEPRECATED_POINTERS
#define BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data_, id_, cb_flag_)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
@ eModifierTypeFlag_AcceptsVertexCosOnly
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
ModifierApplyFlag
General operations, lookup, etc. for blender objects.
Lattice * BKE_object_get_lattice(const Object *object)
Lattice * BKE_object_get_evaluated_lattice(const Object *object)
void BKE_object_eval_assign_data(Object *object, ID *data, bool is_owned)
void BKE_object_free_derived_caches(Object *ob)
#define BLI_assert(a)
Definition BLI_assert.h:46
#define BLI_BITMAP_ENABLE(_bitmap, _index)
Definition BLI_bitmap.h:78
#define BLI_BITMAP_DISABLE(_bitmap, _index)
Definition BLI_bitmap.h:85
unsigned int BLI_bitmap
Definition BLI_bitmap.h:13
#define LISTBASE_FOREACH(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:497
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void unit_m4(float m[4][4])
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
unsigned int uint
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct_array(reader, struct_name, array_size, ptr_p)
#define BLT_I18NCONTEXT_ID_LATTICE
@ INDEX_ID_LT
Definition DNA_ID.h:1240
@ ID_LT
#define DNA_struct_default_get(struct_name)
@ KEY_LINEAR
#define LT_ACTBP_NONE
@ LT_OUTSIDE
@ LT_GRID
@ eModifierMode_Editmode
@ eModifierMode_Realtime
Object is a sort of wrapper for general info.
@ OB_LATTICE
Read Guarded memory(de)allocation.
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
BPy_StructRNA * depsgraph
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
bool is_empty() const
Definition BLI_array.hh:253
#define SELECT
#define MEM_SAFE_FREE(v)
#define FILTER_ID_LT
#define FILTER_ID_KE
#define GS(a)
void outside_lattice(Lattice *lt)
Definition lattice.cc:406
void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
Definition lattice.cc:636
static void lattice_copy_data(Main *bmain, std::optional< Library * > owner_library, ID *id_dst, const ID *id_src, const int flag)
Definition lattice.cc:64
void BKE_lattice_index_to_uvw(const Lattice *lt, const int index, int *r_u, int *r_v, int *r_w)
Definition lattice.cc:207
void BKE_lattice_batch_cache_dirty_tag(Lattice *lt, int mode)
Definition lattice.cc:709
static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition lattice.cc:137
std::optional< blender::Bounds< blender::float3 > > BKE_lattice_minmax(const Lattice *lt)
Definition lattice.cc:616
int BKE_lattice_index_flip(const Lattice *lt, const int index, const bool flip_u, const bool flip_v, const bool flip_w)
Definition lattice.cc:217
void(* BKE_lattice_batch_cache_dirty_tag_cb)(Lattice *lt, int mode)
Definition lattice.cc:706
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
Definition lattice.cc:261
void BKE_lattice_center_median(Lattice *lt, float cent[3])
Definition lattice.cc:598
BPoint * BKE_lattice_active_point_get(Lattice *lt)
Definition lattice.cc:581
void BKE_lattice_bitmap_from_flag(const Lattice *lt, BLI_bitmap *bitmap, const uint8_t flag, const bool clear, const bool respecthide)
Definition lattice.cc:239
static void lattice_free_data(ID *id)
Definition lattice.cc:96
int BKE_lattice_index_from_uvw(const Lattice *lt, const int u, const int v, const int w)
Definition lattice.cc:199
void(* BKE_lattice_batch_cache_free_cb)(Lattice *lt)
Definition lattice.cc:707
static void lattice_blend_read_data(BlendDataReader *reader, ID *id)
Definition lattice.cc:156
static void lattice_init_data(ID *id)
Definition lattice.cc:52
Lattice * BKE_lattice_add(Main *bmain, const char *name)
Definition lattice.cc:392
void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys)
Definition lattice.cc:656
bool BKE_lattice_is_any_selected(const Lattice *lt)
Definition lattice.cc:684
MDeformVert * BKE_lattice_deform_verts_get(const Object *oblatt)
Definition lattice.cc:574
static BPoint * latt_bp(Lattice *lt, int u, int v, int w)
Definition lattice.cc:401
Array< float3 > BKE_lattice_vert_coords_alloc(const Lattice *lt)
Definition lattice.cc:493
void BKE_lattice_vert_coords_apply_with_mat4(Lattice *lt, const Span< float3 > vert_coords, const float4x4 &transform)
Definition lattice.cc:501
void BKE_lattice_eval_geometry(Depsgraph *, Lattice *)
Definition lattice.cc:702
void BKE_lattice_batch_cache_free(Lattice *lt)
Definition lattice.cc:715
void BKE_lattice_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
Definition lattice.cc:519
void BKE_lattice_resize(Lattice *lt, int u_new, int v_new, int w_new, Object *lt_ob)
Definition lattice.cc:277
void BKE_lattice_vert_coords_get(const Lattice *lt, MutableSpan< float3 > vert_coords)
Definition lattice.cc:485
void BKE_lattice_vert_coords_apply(Lattice *lt, const Span< float3 > vert_coords)
Definition lattice.cc:511
static void lattice_foreach_id(ID *id, LibraryForeachIDData *data)
Definition lattice.cc:125
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:123
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:133
void * MEM_dupallocN(const void *vmemh)
Definition mallocn.cc:143
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
static void clear(Message &msg)
Definition msgfmt.cc:213
MatBase< float, 4, 4 > float4x4
VecBase< float, 3 > float3
#define min(a, b)
Definition sort.cc:36
uint8_t f1
float vec[4]
struct Lattice * latt
Definition DNA_ID.h:404
char name[66]
Definition DNA_ID.h:415
ListBase block
ListBase vertex_group_names
struct Key * key
void * batch_cache
struct MDeformVert * dvert
struct EditLatt * editlatt
struct BPoint * def
struct ModifierData * next
void(* deform_verts)(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, blender::MutableSpan< blender::float3 > positions)
bool(* is_disabled)(const Scene *scene, ModifierData *md, bool use_render_params)
ModifierTypeFlag flags
ModifierTypeType type
ObjectRuntimeHandle * runtime
i
Definition text_draw.cc:230
max
Definition text_draw.cc:251
#define N_(msgid)
uint8_t flag
Definition wm_window.cc:139