Blender V5.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
8
9#include <cmath>
10#include <cstdlib>
11#include <cstring>
12
13#include "MEM_guardedalloc.h"
14
15#include "BLI_bitmap.hh"
16#include "BLI_listbase.hh"
17#include "BLI_math_matrix_c.hh"
18#include "BLI_math_vector_c.hh"
19#include "BLI_string.hh"
20#include "BLI_utildefines.hh"
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_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
46namespace blender {
47
48static void lattice_init_data(ID *id)
49{
50 Lattice *lattice = id_cast<Lattice *>(id);
51
52 INIT_DEFAULT_STRUCT_AFTER(lattice, id);
53
54 lattice->def = MEM_new_zeroed<BPoint>("lattvert"); /* temporary */
55 BKE_lattice_resize(lattice, 2, 2, 2, nullptr); /* creates a uniform lattice */
56}
57
58static void lattice_copy_data(Main *bmain,
59 std::optional<Library *> owner_library,
60 ID *id_dst,
61 const ID *id_src,
62 const int flag)
63{
64 Lattice *lattice_dst = id_cast<Lattice *>(id_dst);
65 const Lattice *lattice_src = id_cast<const Lattice *>(id_src);
66
67 lattice_dst->def = MEM_dupalloc(lattice_src->def);
68
69 if (lattice_src->key && (flag & LIB_ID_COPY_SHAPEKEY)) {
71 owner_library,
72 &lattice_src->key->id,
73 &lattice_dst->id,
74 reinterpret_cast<ID **>(&lattice_dst->key),
75 flag);
76 /* It has one user, but its owner reference (added in #id_copy_libmanagement_cb)
77 * is the real owner, remove the reference here, see: #159691. */
78 if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
79 id_us_min(&lattice_dst->key->id);
80 }
81 }
82
84
85 if (lattice_src->dvert) {
86 int tot = lattice_src->pntsu * lattice_src->pntsv * lattice_src->pntsw;
87 lattice_dst->dvert = MEM_new_array_uninitialized<MDeformVert>(size_t(tot),
88 "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 = id_cast<Lattice *>(id);
99
101
102 lattice->vertex_group_names.free_no_destruct();
103
104 MEM_SAFE_DELETE(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_delete(editlt->def);
114 }
115 if (editlt->dvert) {
116 BKE_defvert_array_free(editlt->dvert, lattice->pntsu * lattice->pntsv * lattice->pntsw);
117 }
118
119 MEM_delete(editlt);
120 MEM_delete(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 = id_cast<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 writer->write_id_struct(id_address, lt);
141 BKE_id_blend_write(writer, &lt->id);
142
143 /* direct data */
144 writer->write_struct_array(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 = id_cast<Lattice *>(id);
153 const int64_t points_num = int64_t(lt->pntsu) * lt->pntsv * lt->pntsw;
154 if (!BLO_read_array(reader, &lt->def, points_num)) {
155 lt->pntsu = lt->pntsv = lt->pntsw = 0;
156 }
157
158 if (BLO_read_array(reader, &lt->dvert, points_num)) {
159 BKE_defvert_blend_read(reader, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
160 }
162
163 lt->editlatt = nullptr;
164 lt->batch_cache = nullptr;
165}
166
168 .id_code = Lattice::id_type,
169 .id_filter = FILTER_ID_LT,
170 .dependencies_id_types = FILTER_ID_KE,
171 .main_listbase_index = INDEX_ID_LT,
172 .struct_size = sizeof(Lattice),
173 .name = "Lattice",
174 .name_plural = N_("lattices"),
175 .translation_context = BLT_I18NCONTEXT_ID_LATTICE,
177 .asset_type_info = nullptr,
178
179 .init_data = lattice_init_data,
180 .copy_data = lattice_copy_data,
181 .free_data = lattice_free_data,
182 .make_local = nullptr,
183 .foreach_id = lattice_foreach_id,
184 .foreach_cache = nullptr,
185 .foreach_path = nullptr,
186 .foreach_working_space_color = nullptr,
187 .foreach_asset_weak_reference = 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
303 size_t(u_new) * size_t(v_new) * size_t(w_new), "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 */
354 }
355
356 copy_m4_m4(mat, lt_ob->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_delete(lt->def);
380 lt->def = MEM_new_array_zeroed<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_delete(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
401void BKE_lattice_params_copy(Lattice *lt_dst, const Lattice *lt_src)
402{
403 lt_dst->typeu = lt_src->typeu;
404 lt_dst->typev = lt_src->typev;
405 lt_dst->typew = lt_src->typew;
406 lt_dst->flag = lt_src->flag;
407 STRNCPY(lt_dst->vgroup, lt_src->vgroup);
408}
409
410static BPoint *latt_bp(Lattice *lt, int u, int v, int w)
411{
412 return &lt->def[BKE_lattice_index_from_uvw(lt, u, v, w)];
413}
414
416{
417 BPoint *bp, *bp1, *bp2;
418 int u, v, w;
419 float fac1, du = 0.0, dv = 0.0, dw = 0.0;
420
421 if (lt->flag & LT_OUTSIDE) {
422 bp = lt->def;
423
424 if (lt->pntsu > 1) {
425 du = 1.0f / float(lt->pntsu - 1);
426 }
427 if (lt->pntsv > 1) {
428 dv = 1.0f / float(lt->pntsv - 1);
429 }
430 if (lt->pntsw > 1) {
431 dw = 1.0f / float(lt->pntsw - 1);
432 }
433
434 for (w = 0; w < lt->pntsw; w++) {
435
436 for (v = 0; v < lt->pntsv; v++) {
437
438 for (u = 0; u < lt->pntsu; u++, bp++) {
439 if (u == 0 || v == 0 || w == 0 || u == lt->pntsu - 1 || v == lt->pntsv - 1 ||
440 w == lt->pntsw - 1)
441 {
442 /* pass */
443 }
444 else {
445 bp->hide = 1;
446 bp->f1 &= ~SELECT;
447
448 /* U extrema. */
449 bp1 = latt_bp(lt, 0, v, w);
450 bp2 = latt_bp(lt, lt->pntsu - 1, v, w);
451
452 fac1 = du * u;
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 /* V extrema. */
458 bp1 = latt_bp(lt, u, 0, w);
459 bp2 = latt_bp(lt, u, lt->pntsv - 1, w);
460
461 fac1 = dv * v;
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 /* W extrema. */
467 bp1 = latt_bp(lt, u, v, 0);
468 bp2 = latt_bp(lt, u, v, lt->pntsw - 1);
469
470 fac1 = dw * w;
471 bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0];
472 bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1];
473 bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2];
474
475 mul_v3_fl(bp->vec, 1.0f / 3.0f);
476 }
477 }
478 }
479 }
480 }
481 else {
482 bp = lt->def;
483
484 for (w = 0; w < lt->pntsw; w++) {
485 for (v = 0; v < lt->pntsv; v++) {
486 for (u = 0; u < lt->pntsu; u++, bp++) {
487 bp->hide = 0;
488 }
489 }
490 }
491 }
492}
493
495{
496 const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
497 for (int i = 0; i < vert_len; i++) {
498 vert_coords[i] = lt->def[i].vec;
499 }
500}
501
503{
504 const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
505 Array<float3> vert_coords(vert_len);
506 BKE_lattice_vert_coords_get(lt, vert_coords);
507 return vert_coords;
508}
509
511 const Span<float3> vert_coords,
512 const float4x4 &transform)
513{
514 int i, numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
515 for (i = 0; i < numVerts; i++) {
516 mul_v3_m4v3(lt->def[i].vec, transform.ptr(), vert_coords[i]);
517 }
518}
519
521{
522 const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
523 for (int i = 0; i < vert_len; i++) {
524 copy_v3_v3(lt->def[i].vec, vert_coords[i]);
525 }
526}
527
528void BKE_lattice_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
529{
531 if (ob->runtime->curve_cache == nullptr) {
532 ob->runtime->curve_cache = MEM_new_zeroed<CurveCache>("CurveCache for lattice");
533 }
534
535 Lattice *lt = id_cast<Lattice *>(ob->data);
536 VirtualModifierData virtual_modifier_data;
537 ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtual_modifier_data);
538 Array<float3> vert_coords;
539 const bool is_editmode = (lt->editlatt != nullptr);
540 const ModifierEvalContext mectx = {depsgraph, ob, ModifierApplyFlag(0)};
541
542 for (; md; md = md->next) {
544
546 continue;
547 }
548 if (!(md->mode & eModifierMode_Realtime)) {
549 continue;
550 }
551 if (is_editmode && !(md->mode & eModifierMode_Editmode)) {
552 continue;
553 }
554 if (mti->is_disabled && mti->is_disabled(scene, md, false)) {
555 continue;
556 }
558 continue;
559 }
560
561 if (vert_coords.is_empty()) {
562 /* Get either the edit-mode or regular lattice, whichever is in use now. */
563 const Lattice *effective_lattice = BKE_object_get_lattice(ob);
564 vert_coords = BKE_lattice_vert_coords_alloc(effective_lattice);
565 }
566
567 mti->deform_verts(md, &mectx, nullptr, vert_coords);
568 }
569
570 if (vert_coords.is_empty()) {
571 return;
572 }
573
575 if (lt_eval == nullptr) {
576 BKE_id_copy_ex(nullptr, &lt->id, reinterpret_cast<ID **>(&lt_eval), LIB_ID_COPY_LOCALIZE);
577 BKE_object_eval_assign_data(ob, &lt_eval->id, true);
578 }
579
580 BKE_lattice_vert_coords_apply(lt_eval, vert_coords);
581}
582
584{
585 BLI_assert(oblatt->type == OB_LATTICE);
586 Lattice *lt = BKE_object_get_lattice(oblatt);
587 return lt->dvert;
588}
589
591{
592 BLI_assert(GS(lt->id.name) == ID_LT);
593
594 if (lt->editlatt) {
595 lt = lt->editlatt->latt;
596 }
597
598 BLI_assert(lt->actbp < lt->pntsu * lt->pntsv * lt->pntsw);
599
600 if ((lt->actbp != LT_ACTBP_NONE) && (lt->actbp < lt->pntsu * lt->pntsv * lt->pntsw)) {
601 return &lt->def[lt->actbp];
602 }
603
604 return nullptr;
605}
606
607void BKE_lattice_center_median(Lattice *lt, float cent[3])
608{
609 int i, numVerts;
610
611 if (lt->editlatt) {
612 lt = lt->editlatt->latt;
613 }
614 numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
615
616 zero_v3(cent);
617
618 for (i = 0; i < numVerts; i++) {
619 add_v3_v3(cent, lt->def[i].vec);
620 }
621
622 mul_v3_fl(cent, 1.0f / float(numVerts));
623}
624
625std::optional<Bounds<float3>> BKE_lattice_minmax(const Lattice *lt)
626{
627 int i, numVerts;
628
629 if (lt->editlatt) {
630 lt = lt->editlatt->latt;
631 }
632 numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
633 if (numVerts == 0) {
634 return std::nullopt;
635 }
636
637 float3 min = lt->def[0].vec;
638 float3 max = lt->def[0].vec;
639 for (i = 0; i < numVerts; i++) {
640 minmax_v3v3_v3(min, max, lt->def[i].vec);
641 }
642 return Bounds<float3>{min, max};
643}
644
645void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
646{
647 BPoint *bp = lt->def;
648 int i = lt->pntsu * lt->pntsv * lt->pntsw;
649
650 while (i--) {
651 mul_m4_v3(mat, bp->vec);
652 bp++;
653 }
654
655 if (do_keys && lt->key) {
656 for (KeyBlock &kb : lt->key->block) {
657 float *fp = static_cast<float *>(kb.data);
658 for (i = kb.totelem; i--; fp += 3) {
659 mul_m4_v3(mat, fp);
660 }
661 }
662 }
663}
664
665void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys)
666{
667 int i, numVerts;
668
669 numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
670
671 if (lt->def) {
672 for (i = 0; i < numVerts; i++) {
673 add_v3_v3(lt->def[i].vec, offset);
674 }
675 }
676
677 if (lt->editlatt) {
678 for (i = 0; i < numVerts; i++) {
679 add_v3_v3(lt->editlatt->latt->def[i].vec, offset);
680 }
681 }
682
683 if (do_keys && lt->key) {
684 for (KeyBlock &kb : lt->key->block) {
685 float *fp = static_cast<float *>(kb.data);
686 for (i = kb.totelem; i--; fp += 3) {
687 add_v3_v3(fp, offset);
688 }
689 }
690 }
691}
692
694{
695 /* Intentionally don't handle 'lt->editlatt' (caller must do this). */
696 const BPoint *bp = lt->def;
697 int a = lt->pntsu * lt->pntsv * lt->pntsw;
698 while (a--) {
699 if (bp->hide == 0) {
700 if (bp->f1 & SELECT) {
701 return true;
702 }
703 }
704 bp++;
705 }
706 return false;
707}
708
709/* **** Depsgraph evaluation **** */
710
711void BKE_lattice_eval_geometry(Depsgraph * /*depsgraph*/, Lattice * /*latt*/) {}
712
713/* Draw Engine */
714
715void (*BKE_lattice_batch_cache_dirty_tag_cb)(Lattice *lt, int mode) = nullptr;
717
719{
720 if (lt->batch_cache) {
722 }
723}
725{
726 if (lt->batch_cache) {
728 }
729}
730
731} // namespace blender
support for deformation groups and hooks.
display list (or rather multi purpose list) stuff.
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
#define SELECT
Definition BKE_mask.hh:19
General operations, lookup, etc. for blender objects.
#define BLI_BITMAP_ENABLE(_bitmap, _index)
Definition BLI_bitmap.hh:80
#define BLI_BITMAP_DISABLE(_bitmap, _index)
Definition BLI_bitmap.hh:87
#define BLO_read_struct_list(reader, struct_name, list)
#define BLT_I18NCONTEXT_ID_LATTICE
#define FILTER_ID_LT
Definition DNA_ID.h:1209
#define FILTER_ID_KE
Definition DNA_ID.h:1234
#define LT_ACTBP_NONE
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
btScalar max
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
bool is_empty() const
Definition BLI_array.hh:275
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_defvert_array_free(MDeformVert *dvert, int totvert)
Definition deform.cc:1079
__int64 int64_t
Definition BKE_text.h:90
char * STRNCPY(char(&dst)[N], const char *src)
void BKE_defbase_blend_write(BlendWriter *writer, const ListBaseT< bDeformGroup > *defbase)
Definition deform.cc:1597
void BKE_lattice_resize(Lattice *lt, int u_new, int v_new, int w_new, Object *lt_ob)
Definition lattice.cc:277
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
IDTypeInfo IDType_ID_LT
Definition lattice.cc:167
void BKE_defvert_array_copy(MDeformVert *dst, const MDeformVert *src, int totvert)
Definition deform.cc:1043
void BKE_lattice_params_copy(Lattice *lt_dst, const Lattice *lt_src)
Definition lattice.cc:401
void BKE_lattice_bitmap_from_flag(const Lattice *lt, unsigned int *bitmap, uint8_t flag, bool clear, bool respecthide)
Definition lattice.cc:239
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
void BKE_displist_free(ListBaseT< DispList > *lb)
Definition displist.cc:68
static BPoint * latt_bp(Lattice *lt, int u, int v, int w)
Definition lattice.cc:410
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
static void lattice_blend_read_data(BlendDataReader *reader, ID *id)
Definition lattice.cc:150
void BKE_object_eval_assign_data(Object *object, ID *data, bool is_owned)
Definition object.cc:1786
void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
Definition lattice.cc:645
std::optional< Bounds< float3 > > BKE_lattice_minmax(const Lattice *lt)
Definition lattice.cc:625
void BKE_defvert_blend_read(BlendDataReader *reader, int count, MDeformVert *mdverts)
Definition deform.cc:1621
void BKE_defvert_blend_write(BlendWriter *writer, int count, const MDeformVert *dvlist)
Definition deform.cc:1604
Lattice * BKE_object_get_evaluated_lattice(const Object *object)
Definition object.cc:4560
ATTR_WARN_UNUSED_RESULT const BMVert * v
MatBase< float, 4, 4 > float4x4
Array< float3 > BKE_lattice_vert_coords_alloc(const Lattice *lt)
Definition lattice.cc:502
Lattice * BKE_object_get_lattice(const Object *object)
Definition object.cc:4545
void BKE_lattice_eval_geometry(Depsgraph *depsgraph, Lattice *latt)
Definition lattice.cc:711
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
Definition lattice.cc:261
void(*) BKE_lattice_batch_cache_dirty_tag_cb(Lattice *lt, int mode)
Definition lattice.cc:715
void BKE_id_blend_write(BlendWriter *writer, ID *id)
Definition lib_id.cc:2890
@ LIB_ID_CREATE_NO_USER_REFCOUNT
@ LIB_ID_COPY_LOCALIZE
@ LIB_ID_COPY_SHAPEKEY
MINLINE void mul_v3_fl(float r[3], float f)
void mul_m4_v3(const float M[4][4], float r[3])
void(*) BKE_lattice_batch_cache_free_cb(Lattice *lt)
Definition lattice.cc:716
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void BKE_object_free_derived_caches(Object *ob)
Definition object.cc:1810
void BKE_lattice_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
Definition lattice.cc:528
BMesh const char void * data
void outside_lattice(Lattice *lt)
Definition lattice.cc:415
int BKE_lattice_index_from_uvw(const Lattice *lt, int u, int v, int w)
Definition lattice.cc:199
unsigned char uint8_t
Definition BKE_text.h:79
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
MDeformVert * BKE_lattice_deform_verts_get(const Object *oblatt)
Definition lattice.cc:583
int BKE_lattice_index_flip(const Lattice *lt, int index, bool flip_u, bool flip_v, bool flip_w)
Definition lattice.cc:217
void unit_m4(float m[4][4])
BPoint * BKE_lattice_active_point_get(Lattice *lt)
Definition lattice.cc:590
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)
static void lattice_free_data(ID *id)
Definition lattice.cc:96
MINLINE void zero_v3(float r[3])
void BKE_lattice_batch_cache_free(Lattice *lt)
Definition lattice.cc:724
@ eModifierTypeFlag_AcceptsVertexCosOnly
bool BLO_read_array(BlendDataReader *reader, T **ptr_p, const SizeT array_size, const int elems=1)
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:58
void BKE_lattice_vert_coords_apply_with_mat4(Lattice *lt, Span< float3 > vert_coordss, const float4x4 &transform)
Definition lattice.cc:510
MINLINE void add_v3_v3(float r[3], const float a[3])
void BKE_lattice_index_to_uvw(const Lattice *lt, int index, int *r_u, int *r_v, int *r_w)
Definition lattice.cc:207
bool BKE_lattice_is_any_selected(const Lattice *lt)
Definition lattice.cc:693
static void lattice_init_data(ID *id)
Definition lattice.cc:48
unsigned int BLI_bitmap
Definition BLI_bitmap.hh:15
@ INDEX_ID_LT
Definition DNA_ID.h:1333
void BKE_lattice_batch_cache_dirty_tag(Lattice *lt, int mode)
Definition lattice.cc:718
ID_Type GS(const char *name)
Definition DNA_ID.h:410
void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys)
Definition lattice.cc:665
void BKE_defgroup_copy_list(ListBaseT< bDeformGroup > *outbase, const ListBaseT< bDeformGroup > *inbase)
Definition deform.cc:75
void BKE_lattice_center_median(Lattice *lt, float cent[3])
Definition lattice.cc:607
void BKE_lattice_vert_coords_get(const Lattice *lt, MutableSpan< float3 > vert_coordss)
Definition lattice.cc:494
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
Definition lib_id.cc:851
void copy_m4_m4(float m1[4][4], const float m2[4][4])
VecBase< float, 3 > float3
void BKE_lattice_vert_coords_apply(Lattice *lt, Span< float3 > vert_coordss)
Definition lattice.cc:520
void id_us_min(ID *id)
Definition lib_id.cc:441
Lattice * BKE_lattice_add(Main *bmain, const char *name)
Definition lattice.cc:392
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
void * BKE_id_new(Main *bmain, short type, const char *name)
Definition lib_id.cc:1612
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:749
static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition lattice.cc:131
static void lattice_foreach_id(ID *id, LibraryForeachIDData *data)
Definition lattice.cc:125
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
Definition BKE_idtype.hh:50
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
void write_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct_array(const int64_t array_size, const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
ListBaseT< DispList > disp
Definition BKE_curve.hh:44
struct Lattice * latt
char name[258]
Definition DNA_ID.h:433
ListBaseT< KeyBlock > block
struct EditLatt * editlatt
draw::LatticeBatchCache * batch_cache
struct MDeformVert * dvert
ListBaseT< struct bDeformGroup > vertex_group_names
struct BPoint * def
const c_style_mat & ptr() const
struct ModifierData * next
void(*) deform_verts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, MutableSpan< float3 > positions)
bool(*) is_disabled(const Scene *scene, ModifierData *md, bool use_render_params)
bke::ObjectRuntime * runtime
#define N_(msgid)