Blender V5.0
transform_convert_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 "DNA_curve_types.h"
10#include "DNA_lattice_types.h"
11
12#include "MEM_guardedalloc.h"
13
14#include "BLI_math_matrix.h"
15#include "BLI_math_vector.h"
16
17#include "BKE_lattice.hh"
18
19#include "ED_object.hh"
20
21#include "transform.hh"
22#include "transform_snap.hh"
23
24/* Own include. */
25#include "transform_convert.hh"
26
27namespace blender::ed::transform {
28
29/* -------------------------------------------------------------------- */
32
34{
36
37 Lattice *latt = ((Lattice *)tc->obedit->data)->editlatt->latt;
38 TransData *td = nullptr;
39 BPoint *bp;
40 float mtx[3][3], smtx[3][3];
41 int a;
42 int count = 0, countsel = 0;
43 const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
44 const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0;
45
46 /* Avoid editing locked shapes. */
47 if (t->mode != TFM_DUMMY && object::shape_key_report_if_locked(tc->obedit, t->reports)) {
48 continue;
49 }
50
51 bp = latt->def;
52 a = latt->pntsu * latt->pntsv * latt->pntsw;
53 while (a--) {
54 if (bp->hide == 0) {
55 if (bp->f1 & SELECT) {
56 countsel++;
57 }
58 if (is_prop_edit) {
59 count++;
60 }
61 }
62 bp++;
63 }
64
65 /* Support other objects using proportional editing to adjust these, unless connected is
66 * enabled. */
67 if (((is_prop_edit && !is_prop_connected) ? count : countsel) == 0) {
68 tc->data_len = 0;
69 continue;
70 }
71
72 if (is_prop_edit) {
73 tc->data_len = count;
74 }
75 else {
76 tc->data_len = countsel;
77 }
78 tc->data = MEM_calloc_arrayN<TransData>(tc->data_len, "TransObData(Lattice EditMode)");
79
80 copy_m3_m4(mtx, tc->obedit->object_to_world().ptr());
82
83 td = tc->data;
84 bp = latt->def;
85 a = latt->pntsu * latt->pntsv * latt->pntsw;
86 while (a--) {
87 if (is_prop_edit || (bp->f1 & SELECT)) {
88 if (bp->hide == 0) {
89 copy_v3_v3(td->iloc, bp->vec);
90 td->loc = bp->vec;
91 copy_v3_v3(td->center, td->loc);
92 if (bp->f1 & SELECT) {
93 td->flag = TD_SELECTED;
94 }
95 else {
96 td->flag = 0;
97 }
98 copy_m3_m3(td->smtx, smtx);
99 copy_m3_m3(td->mtx, mtx);
100
101 td->val = nullptr;
102
103 td++;
104 }
105 }
106 bp++;
107 }
108 }
109}
110
112{
113 if (t->state != TRANS_CANCEL) {
115 }
116
118 Lattice *la = static_cast<Lattice *>(tc->obedit->data);
119 DEG_id_tag_update(static_cast<ID *>(tc->obedit->data), ID_RECALC_GEOMETRY);
120 if (la->editlatt->latt->flag & LT_OUTSIDE) {
122 }
123 }
124}
125
127
129 /*flags*/ (T_EDIT | T_POINTS),
130 /*create_trans_data*/ createTransLatticeVerts,
131 /*recalc_data*/ recalcData_lattice,
132 /*special_aftertrans_update*/ nullptr,
133};
134
135} // namespace blender::ed::transform
void outside_lattice(Lattice *lt)
Definition lattice.cc:401
void pseudoinverse_m3_m3(float inverse[3][3], const float mat[3][3], float epsilon)
void copy_m3_m3(float m1[3][3], const float m2[3][3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
#define PSEUDOINVERSE_EPSILON
MINLINE void copy_v3_v3(float r[3], const float a[3])
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ LT_OUTSIDE
Read Guarded memory(de)allocation.
#define SELECT
int count
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:123
bool shape_key_report_if_locked(const Object *obedit, ReportList *reports)
void transform_snap_project_individual_apply(TransInfo *t)
TransConvertTypeInfo TransConvertType_Lattice
static void recalcData_lattice(TransInfo *t)
static void createTransLatticeVerts(bContext *, TransInfo *t)
uint8_t f1
float vec[4]
struct Lattice * latt
Definition DNA_ID.h:414
struct EditLatt * editlatt
struct BPoint * def
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:42
conversion and adaptation of different datablocks to a common struct.