Blender V5.0
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}
130
131static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
132{
133 Lattice *lt = (Lattice *)id;
134
135 /* Clean up, important in undo case to reduce false detection of changed datablocks. */
136 lt->editlatt = nullptr;
137 lt->batch_cache = nullptr;
138
139 /* write LibData */
140 BLO_write_id_struct(writer, Lattice, id_address, &lt->id);
141 BKE_id_blend_write(writer, &lt->id);
142
143 /* direct data */
144 BLO_write_struct_array(writer, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def);
145
147 BKE_defvert_blend_write(writer, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
148}
149
151{
152 Lattice *lt = (Lattice *)id;
153 BLO_read_struct_array(reader, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, &lt->def);
154
155 BLO_read_struct_array(reader, MDeformVert, lt->pntsu * lt->pntsv * lt->pntsw, &lt->dvert);
156 BKE_defvert_blend_read(reader, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
158
159 lt->editlatt = nullptr;
160 lt->batch_cache = nullptr;
161}
162
164 /*id_code*/ Lattice::id_type,
165 /*id_filter*/ FILTER_ID_LT,
166 /*dependencies_id_types*/ FILTER_ID_KE,
167 /*main_listbase_index*/ INDEX_ID_LT,
168 /*struct_size*/ sizeof(Lattice),
169 /*name*/ "Lattice",
170 /*name_plural*/ N_("lattices"),
171 /*translation_context*/ BLT_I18NCONTEXT_ID_LATTICE,
173 /*asset_type_info*/ nullptr,
174
175 /*init_data*/ lattice_init_data,
176 /*copy_data*/ lattice_copy_data,
177 /*free_data*/ lattice_free_data,
178 /*make_local*/ nullptr,
179 /*foreach_id*/ lattice_foreach_id,
180 /*foreach_cache*/ nullptr,
181 /*foreach_path*/ nullptr,
182 /*foreach_working_space_color*/ nullptr,
183 /*owner_pointer_get*/ nullptr,
184
185 /*blend_write*/ lattice_blend_write,
186 /*blend_read_data*/ lattice_blend_read_data,
187 /*blend_read_after_liblink*/ nullptr,
188
189 /*blend_read_undo_preserve*/ nullptr,
190
191 /*lib_override_apply_post*/ nullptr,
192};
193
194int BKE_lattice_index_from_uvw(const Lattice *lt, const int u, const int v, const int w)
195{
196 const int totu = lt->pntsu;
197 const int totv = lt->pntsv;
198
199 return (w * (totu * totv) + (v * totu) + u);
200}
201
202void BKE_lattice_index_to_uvw(const Lattice *lt, const int index, int *r_u, int *r_v, int *r_w)
203{
204 const int totu = lt->pntsu;
205 const int totv = lt->pntsv;
206
207 *r_u = (index % totu);
208 *r_v = (index / totu) % totv;
209 *r_w = (index / (totu * totv));
210}
211
213 const Lattice *lt, const int index, const bool flip_u, const bool flip_v, const bool flip_w)
214{
215 int u, v, w;
216
217 BKE_lattice_index_to_uvw(lt, index, &u, &v, &w);
218
219 if (flip_u) {
220 u = (lt->pntsu - 1) - u;
221 }
222
223 if (flip_v) {
224 v = (lt->pntsv - 1) - v;
225 }
226
227 if (flip_w) {
228 w = (lt->pntsw - 1) - w;
229 }
230
231 return BKE_lattice_index_from_uvw(lt, u, v, w);
232}
233
235 BLI_bitmap *bitmap,
236 const uint8_t flag,
237 const bool clear,
238 const bool respecthide)
239{
240 const uint tot = lt->pntsu * lt->pntsv * lt->pntsw;
241 BPoint *bp;
242
243 bp = lt->def;
244 for (int i = 0; i < tot; i++, bp++) {
245 if ((bp->f1 & flag) && (!respecthide || !bp->hide)) {
246 BLI_BITMAP_ENABLE(bitmap, i);
247 }
248 else {
249 if (clear) {
250 BLI_BITMAP_DISABLE(bitmap, i);
251 }
252 }
253 }
254}
255
256void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
257{
258 if (res == 1) {
259 *r_fu = 0.0;
260 *r_du = 0.0;
261 }
262 else if (flag & LT_GRID) {
263 *r_fu = -0.5f * (res - 1);
264 *r_du = 1.0f;
265 }
266 else {
267 *r_fu = -1.0f;
268 *r_du = 2.0f / (res - 1);
269 }
270}
271
272void BKE_lattice_resize(Lattice *lt, int u_new, int v_new, int w_new, Object *lt_ob)
273{
274 BPoint *bp;
275 int i, u, v, w;
276 float fu, fv, fw, uc, vc, wc, du = 0.0, dv = 0.0, dw = 0.0;
277 float *co, (*vert_coords)[3] = nullptr;
278
279 /* vertex weight groups are just freed all for now */
280 if (lt->dvert) {
281 BKE_defvert_array_free(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw);
282 lt->dvert = nullptr;
283 }
284
285 while (u_new * v_new * w_new > 32000) {
286 if (u_new >= v_new && u_new >= w_new) {
287 u_new--;
288 }
289 else if (v_new >= u_new && v_new >= w_new) {
290 v_new--;
291 }
292 else {
293 w_new--;
294 }
295 }
296
297 vert_coords = MEM_malloc_arrayN<float[3]>(size_t(u_new) * size_t(v_new) * size_t(w_new),
298 "tmp_vcos");
299
300 calc_lat_fudu(lt->flag, u_new, &fu, &du);
301 calc_lat_fudu(lt->flag, v_new, &fv, &dv);
302 calc_lat_fudu(lt->flag, w_new, &fw, &dw);
303
304 /* If old size is different than resolution changed in interface,
305 * try to do clever reinitialize of points. Pretty simply idea, we just
306 * deform new verts by old lattice, but scaling them to match old
307 * size first.
308 */
309 if (lt_ob) {
310 const float default_size = 1.0;
311
312 if (u_new != 1) {
313 fu = -default_size / 2.0;
314 du = default_size / (u_new - 1);
315 }
316
317 if (v_new != 1) {
318 fv = -default_size / 2.0;
319 dv = default_size / (v_new - 1);
320 }
321
322 if (w_new != 1) {
323 fw = -default_size / 2.0;
324 dw = default_size / (w_new - 1);
325 }
326 }
327
328 co = vert_coords[0];
329 for (w = 0, wc = fw; w < w_new; w++, wc += dw) {
330 for (v = 0, vc = fv; v < v_new; v++, vc += dv) {
331 for (u = 0, uc = fu; u < u_new; u++, co += 3, uc += du) {
332 co[0] = uc;
333 co[1] = vc;
334 co[2] = wc;
335 }
336 }
337 }
338
339 if (lt_ob) {
340 float mat[4][4];
341 int typeu = lt->typeu, typev = lt->typev, typew = lt->typew;
342
343 /* works best if we force to linear type (endpoints match) */
344 lt->typeu = lt->typev = lt->typew = KEY_LINEAR;
345
346 if (lt_ob->runtime->curve_cache) {
347 /* prevent using deformed locations */
348 BKE_displist_free(&lt_ob->runtime->curve_cache->disp);
349 }
350
351 copy_m4_m4(mat, lt_ob->object_to_world().ptr());
352 unit_m4(lt_ob->runtime->object_to_world.ptr());
354 lt_ob, nullptr, vert_coords, u_new * v_new * w_new, 0, nullptr, 1.0f);
355 copy_m4_m4(lt_ob->runtime->object_to_world.ptr(), mat);
356
357 lt->typeu = typeu;
358 lt->typev = typev;
359 lt->typew = typew;
360 }
361
362 lt->fu = fu;
363 lt->fv = fv;
364 lt->fw = fw;
365 lt->du = du;
366 lt->dv = dv;
367 lt->dw = dw;
368
369 lt->pntsu = u_new;
370 lt->pntsv = v_new;
371 lt->pntsw = w_new;
372
373 lt->actbp = LT_ACTBP_NONE;
374 MEM_freeN(lt->def);
375 lt->def = MEM_calloc_arrayN<BPoint>(size_t(lt->pntsu) * size_t(lt->pntsv) * size_t(lt->pntsw),
376 "lattice bp");
377
378 bp = lt->def;
379
380 for (i = 0; i < lt->pntsu * lt->pntsv * lt->pntsw; i++, bp++) {
381 copy_v3_v3(bp->vec, vert_coords[i]);
382 }
383
384 MEM_freeN(vert_coords);
385}
386
387Lattice *BKE_lattice_add(Main *bmain, const char *name)
388{
389 Lattice *lt;
390
391 lt = BKE_id_new<Lattice>(bmain, name);
392
393 return lt;
394}
395
396static BPoint *latt_bp(Lattice *lt, int u, int v, int w)
397{
398 return &lt->def[BKE_lattice_index_from_uvw(lt, u, v, w)];
399}
400
402{
403 BPoint *bp, *bp1, *bp2;
404 int u, v, w;
405 float fac1, du = 0.0, dv = 0.0, dw = 0.0;
406
407 if (lt->flag & LT_OUTSIDE) {
408 bp = lt->def;
409
410 if (lt->pntsu > 1) {
411 du = 1.0f / float(lt->pntsu - 1);
412 }
413 if (lt->pntsv > 1) {
414 dv = 1.0f / float(lt->pntsv - 1);
415 }
416 if (lt->pntsw > 1) {
417 dw = 1.0f / float(lt->pntsw - 1);
418 }
419
420 for (w = 0; w < lt->pntsw; w++) {
421
422 for (v = 0; v < lt->pntsv; v++) {
423
424 for (u = 0; u < lt->pntsu; u++, bp++) {
425 if (u == 0 || v == 0 || w == 0 || u == lt->pntsu - 1 || v == lt->pntsv - 1 ||
426 w == lt->pntsw - 1)
427 {
428 /* pass */
429 }
430 else {
431 bp->hide = 1;
432 bp->f1 &= ~SELECT;
433
434 /* U extrema. */
435 bp1 = latt_bp(lt, 0, v, w);
436 bp2 = latt_bp(lt, lt->pntsu - 1, v, w);
437
438 fac1 = du * u;
439 bp->vec[0] = (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
440 bp->vec[1] = (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
441 bp->vec[2] = (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
442
443 /* V extrema. */
444 bp1 = latt_bp(lt, u, 0, w);
445 bp2 = latt_bp(lt, u, lt->pntsv - 1, w);
446
447 fac1 = dv * v;
448 bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
449 bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
450 bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
451
452 /* W extrema. */
453 bp1 = latt_bp(lt, u, v, 0);
454 bp2 = latt_bp(lt, u, v, lt->pntsw - 1);
455
456 fac1 = dw * w;
457 bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
458 bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
459 bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
460
461 mul_v3_fl(bp->vec, 1.0f / 3.0f);
462 }
463 }
464 }
465 }
466 }
467 else {
468 bp = lt->def;
469
470 for (w = 0; w < lt->pntsw; w++) {
471 for (v = 0; v < lt->pntsv; v++) {
472 for (u = 0; u < lt->pntsu; u++, bp++) {
473 bp->hide = 0;
474 }
475 }
476 }
477 }
478}
479
481{
482 const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
483 for (int i = 0; i < vert_len; i++) {
484 vert_coords[i] = lt->def[i].vec;
485 }
486}
487
489{
490 const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
491 Array<float3> vert_coords(vert_len);
492 BKE_lattice_vert_coords_get(lt, vert_coords);
493 return vert_coords;
494}
495
497 const Span<float3> vert_coords,
498 const float4x4 &transform)
499{
500 int i, numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
501 for (i = 0; i < numVerts; i++) {
502 mul_v3_m4v3(lt->def[i].vec, transform.ptr(), vert_coords[i]);
503 }
504}
505
507{
508 const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
509 for (int i = 0; i < vert_len; i++) {
510 copy_v3_v3(lt->def[i].vec, vert_coords[i]);
511 }
512}
513
515{
517 if (ob->runtime->curve_cache == nullptr) {
518 ob->runtime->curve_cache = MEM_callocN<CurveCache>("CurveCache for lattice");
519 }
520
521 Lattice *lt = static_cast<Lattice *>(ob->data);
522 VirtualModifierData virtual_modifier_data;
523 ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtual_modifier_data);
524 Array<float3> vert_coords;
525 const bool is_editmode = (lt->editlatt != nullptr);
526 const ModifierEvalContext mectx = {depsgraph, ob, ModifierApplyFlag(0)};
527
528 for (; md; md = md->next) {
530
532 continue;
533 }
534 if (!(md->mode & eModifierMode_Realtime)) {
535 continue;
536 }
537 if (is_editmode && !(md->mode & eModifierMode_Editmode)) {
538 continue;
539 }
540 if (mti->is_disabled && mti->is_disabled(scene, md, false)) {
541 continue;
542 }
544 continue;
545 }
546
547 if (vert_coords.is_empty()) {
548 /* Get either the edit-mode or regular lattice, whichever is in use now. */
549 const Lattice *effective_lattice = BKE_object_get_lattice(ob);
550 vert_coords = BKE_lattice_vert_coords_alloc(effective_lattice);
551 }
552
553 mti->deform_verts(md, &mectx, nullptr, vert_coords);
554 }
555
556 if (vert_coords.is_empty()) {
557 return;
558 }
559
561 if (lt_eval == nullptr) {
562 BKE_id_copy_ex(nullptr, &lt->id, (ID **)&lt_eval, LIB_ID_COPY_LOCALIZE);
563 BKE_object_eval_assign_data(ob, &lt_eval->id, true);
564 }
565
566 BKE_lattice_vert_coords_apply(lt_eval, vert_coords);
567}
568
570{
571 BLI_assert(oblatt->type == OB_LATTICE);
572 Lattice *lt = BKE_object_get_lattice(oblatt);
573 return lt->dvert;
574}
575
577{
578 BLI_assert(GS(lt->id.name) == ID_LT);
579
580 if (lt->editlatt) {
581 lt = lt->editlatt->latt;
582 }
583
584 BLI_assert(lt->actbp < lt->pntsu * lt->pntsv * lt->pntsw);
585
586 if ((lt->actbp != LT_ACTBP_NONE) && (lt->actbp < lt->pntsu * lt->pntsv * lt->pntsw)) {
587 return &lt->def[lt->actbp];
588 }
589
590 return nullptr;
591}
592
593void BKE_lattice_center_median(Lattice *lt, float cent[3])
594{
595 int i, numVerts;
596
597 if (lt->editlatt) {
598 lt = lt->editlatt->latt;
599 }
600 numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
601
602 zero_v3(cent);
603
604 for (i = 0; i < numVerts; i++) {
605 add_v3_v3(cent, lt->def[i].vec);
606 }
607
608 mul_v3_fl(cent, 1.0f / float(numVerts));
609}
610
611std::optional<blender::Bounds<blender::float3>> BKE_lattice_minmax(const Lattice *lt)
612{
613 int i, numVerts;
614
615 if (lt->editlatt) {
616 lt = lt->editlatt->latt;
617 }
618 numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
619 if (numVerts == 0) {
620 return std::nullopt;
621 }
622
623 blender::float3 min = lt->def[0].vec;
624 blender::float3 max = lt->def[0].vec;
625 for (i = 0; i < numVerts; i++) {
626 minmax_v3v3_v3(min, max, lt->def[i].vec);
627 }
629}
630
631void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
632{
633 BPoint *bp = lt->def;
634 int i = lt->pntsu * lt->pntsv * lt->pntsw;
635
636 while (i--) {
637 mul_m4_v3(mat, bp->vec);
638 bp++;
639 }
640
641 if (do_keys && lt->key) {
642 LISTBASE_FOREACH (KeyBlock *, kb, &lt->key->block) {
643 float *fp = static_cast<float *>(kb->data);
644 for (i = kb->totelem; i--; fp += 3) {
645 mul_m4_v3(mat, fp);
646 }
647 }
648 }
649}
650
651void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys)
652{
653 int i, numVerts;
654
655 numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
656
657 if (lt->def) {
658 for (i = 0; i < numVerts; i++) {
659 add_v3_v3(lt->def[i].vec, offset);
660 }
661 }
662
663 if (lt->editlatt) {
664 for (i = 0; i < numVerts; i++) {
665 add_v3_v3(lt->editlatt->latt->def[i].vec, offset);
666 }
667 }
668
669 if (do_keys && lt->key) {
670 LISTBASE_FOREACH (KeyBlock *, kb, &lt->key->block) {
671 float *fp = static_cast<float *>(kb->data);
672 for (i = kb->totelem; i--; fp += 3) {
673 add_v3_v3(fp, offset);
674 }
675 }
676 }
677}
678
680{
681 /* Intentionally don't handle 'lt->editlatt' (caller must do this). */
682 const BPoint *bp = lt->def;
683 int a = lt->pntsu * lt->pntsv * lt->pntsw;
684 while (a--) {
685 if (bp->hide == 0) {
686 if (bp->f1 & SELECT) {
687 return true;
688 }
689 }
690 bp++;
691 }
692 return false;
693}
694
695/* **** Depsgraph evaluation **** */
696
697void BKE_lattice_eval_geometry(Depsgraph * /*depsgraph*/, Lattice * /*latt*/) {}
698
699/* Draw Engine */
700
701void (*BKE_lattice_batch_cache_dirty_tag_cb)(Lattice *lt, int mode) = nullptr;
703
705{
706 if (lt->batch_cache) {
708 }
709}
711{
712 if (lt->batch_cache) {
714 }
715}
support for deformation groups and hooks.
void BKE_defvert_blend_write(BlendWriter *writer, int count, const MDeformVert *dvlist)
Definition deform.cc:1602
void BKE_defbase_blend_write(BlendWriter *writer, const ListBase *defbase)
Definition deform.cc:1595
void BKE_defvert_array_free(MDeformVert *dvert, int totvert)
Definition deform.cc:1074
void BKE_defvert_array_copy(MDeformVert *dst, const MDeformVert *src, int totvert)
Definition deform.cc:1038
void BKE_defgroup_copy_list(ListBase *outbase, const ListBase *inbase)
Definition deform.cc:73
void BKE_defvert_blend_read(BlendDataReader *reader, int count, MDeformVert *mdverts)
Definition deform.cc:1619
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:47
IDTypeInfo IDType_ID_LT
Definition lattice.cc:163
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:701
void(* BKE_lattice_batch_cache_free_cb)(Lattice *lt)
Definition lattice.cc:702
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:675
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
Definition lib_id.cc:777
void * BKE_id_new(Main *bmain, short type, const char *name)
Definition lib_id.cc:1514
@ LIB_ID_COPY_LOCALIZE
@ LIB_ID_COPY_SHAPEKEY
void BKE_id_blend_write(BlendWriter *writer, ID *id)
Definition lib_id.cc:2631
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
@ IDWALK_CB_USER
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
#define FILTER_ID_LT
Definition DNA_ID.h:1207
@ INDEX_ID_LT
Definition DNA_ID.h:1331
#define FILTER_ID_KE
Definition DNA_ID.h:1232
@ 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.
#define MEM_SAFE_FREE(v)
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:264
nullptr float
#define SELECT
#define GS(x)
void outside_lattice(Lattice *lt)
Definition lattice.cc:401
void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
Definition lattice.cc:631
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:202
void BKE_lattice_batch_cache_dirty_tag(Lattice *lt, int mode)
Definition lattice.cc:704
static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition lattice.cc:131
std::optional< blender::Bounds< blender::float3 > > BKE_lattice_minmax(const Lattice *lt)
Definition lattice.cc:611
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:212
void(* BKE_lattice_batch_cache_dirty_tag_cb)(Lattice *lt, int mode)
Definition lattice.cc:701
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
Definition lattice.cc:256
void BKE_lattice_center_median(Lattice *lt, float cent[3])
Definition lattice.cc:593
BPoint * BKE_lattice_active_point_get(Lattice *lt)
Definition lattice.cc:576
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:234
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:194
void(* BKE_lattice_batch_cache_free_cb)(Lattice *lt)
Definition lattice.cc:702
static void lattice_blend_read_data(BlendDataReader *reader, ID *id)
Definition lattice.cc:150
static void lattice_init_data(ID *id)
Definition lattice.cc:52
Lattice * BKE_lattice_add(Main *bmain, const char *name)
Definition lattice.cc:387
void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys)
Definition lattice.cc:651
bool BKE_lattice_is_any_selected(const Lattice *lt)
Definition lattice.cc:679
MDeformVert * BKE_lattice_deform_verts_get(const Object *oblatt)
Definition lattice.cc:569
static BPoint * latt_bp(Lattice *lt, int u, int v, int w)
Definition lattice.cc:396
Array< float3 > BKE_lattice_vert_coords_alloc(const Lattice *lt)
Definition lattice.cc:488
void BKE_lattice_vert_coords_apply_with_mat4(Lattice *lt, const Span< float3 > vert_coords, const float4x4 &transform)
Definition lattice.cc:496
void BKE_lattice_eval_geometry(Depsgraph *, Lattice *)
Definition lattice.cc:697
void BKE_lattice_batch_cache_free(Lattice *lt)
Definition lattice.cc:710
void BKE_lattice_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
Definition lattice.cc:514
void BKE_lattice_resize(Lattice *lt, int u_new, int v_new, int w_new, Object *lt_ob)
Definition lattice.cc:272
void BKE_lattice_vert_coords_get(const Lattice *lt, MutableSpan< float3 > vert_coords)
Definition lattice.cc:480
void BKE_lattice_vert_coords_apply(Lattice *lt, const Span< float3 > vert_coords)
Definition lattice.cc:506
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
const char * name
#define min(a, b)
Definition sort.cc:36
uint8_t f1
float vec[4]
struct Lattice * latt
Definition DNA_ID.h:414
char name[258]
Definition DNA_ID.h:432
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:145