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