Blender V4.3
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
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
27/* -------------------------------------------------------------------- */
32{
34
35 Lattice *latt = ((Lattice *)tc->obedit->data)->editlatt->latt;
36 TransData *td = nullptr;
37 BPoint *bp;
38 float mtx[3][3], smtx[3][3];
39 int a;
40 int count = 0, countsel = 0;
41 const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
42 const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0;
43
44 /* Avoid editing locked shapes. */
45 if (t->mode != TFM_DUMMY &&
47 {
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 = static_cast<TransData *>(
79 MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Lattice EditMode)"));
80
81 copy_m3_m4(mtx, tc->obedit->object_to_world().ptr());
83
84 td = tc->data;
85 bp = latt->def;
86 a = latt->pntsu * latt->pntsv * latt->pntsw;
87 while (a--) {
88 if (is_prop_edit || (bp->f1 & SELECT)) {
89 if (bp->hide == 0) {
90 copy_v3_v3(td->iloc, bp->vec);
91 td->loc = bp->vec;
92 copy_v3_v3(td->center, td->loc);
93 if (bp->f1 & SELECT) {
94 td->flag = TD_SELECTED;
95 }
96 else {
97 td->flag = 0;
98 }
99 copy_m3_m3(td->smtx, smtx);
100 copy_m3_m3(td->mtx, mtx);
101
102 td->ext = nullptr;
103 td->val = nullptr;
104
105 td++;
106 }
107 }
108 bp++;
109 }
110 }
111}
112
114{
115 if (t->state != TRANS_CANCEL) {
117 }
118
120 Lattice *la = static_cast<Lattice *>(tc->obedit->data);
121 DEG_id_tag_update(static_cast<ID *>(tc->obedit->data), ID_RECALC_GEOMETRY);
122 if (la->editlatt->latt->flag & LT_OUTSIDE) {
124 }
125 }
126}
127
131 /*flags*/ (T_EDIT | T_POINTS),
132 /*create_trans_data*/ createTransLatticeVerts,
133 /*recalc_data*/ recalcData_lattice,
134 /*special_aftertrans_update*/ nullptr,
135};
void outside_lattice(Lattice *lt)
Definition lattice.cc:402
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:1041
@ LT_OUTSIDE
@ TFM_DUMMY
Read Guarded memory(de)allocation.
#define SELECT
int count
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
bool shape_key_report_if_locked(const Object *obedit, ReportList *reports)
uint8_t f1
float vec[4]
struct Lattice * latt
Definition DNA_ID.h:413
struct EditLatt * editlatt
struct BPoint * def
float smtx[3][3]
float mtx[3][3]
TransDataExtension * ext
eTfmMode mode
Definition transform.hh:517
ReportList * reports
Definition transform.hh:661
eTState state
Definition transform.hh:527
eTFlag flag
Definition transform.hh:523
@ T_PROP_CONNECTED
Definition transform.hh:99
@ T_PROP_EDIT
Definition transform.hh:98
@ T_POINTS
Definition transform.hh:93
@ T_EDIT
Definition transform.hh:91
@ TRANS_CANCEL
Definition transform.hh:210
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:854
conversion and adaptation of different datablocks to a common struct.
static void createTransLatticeVerts(bContext *, TransInfo *t)
TransConvertTypeInfo TransConvertType_Lattice
static void recalcData_lattice(TransInfo *t)
@ TD_SELECTED
void transform_snap_project_individual_apply(TransInfo *t)