Blender V4.3
transform_convert_mball.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_meta_types.h"
10
11#include "MEM_guardedalloc.h"
12
13#include "BLI_math_matrix.h"
14#include "BLI_math_rotation.h"
15#include "BLI_math_vector.h"
16
17#include "BKE_context.hh"
18
19#include "transform.hh"
20#include "transform_snap.hh"
21
22#include "transform_convert.hh"
23
24/* -------------------------------------------------------------------- */
29{
31 MetaBall *mb = (MetaBall *)tc->obedit->data;
32 TransData *td;
34 float mtx[3][3], smtx[3][3];
35 int count = 0, countsel = 0;
36 const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
37 const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0;
38
39 /* Count totals. */
41 if (ml->flag & SELECT) {
42 countsel++;
43 }
44 if (is_prop_edit) {
45 count++;
46 }
47 }
48
49 /* Support other objects using proportional editing to adjust these, unless connected is
50 * enabled. */
51 if (((is_prop_edit && !is_prop_connected) ? count : countsel) == 0) {
52 tc->data_len = 0;
53 continue;
54 }
55
56 if (is_prop_edit) {
57 tc->data_len = count;
58 }
59 else {
60 tc->data_len = countsel;
61 }
62
63 td = tc->data = static_cast<TransData *>(
64 MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(MBall EditMode)"));
65 tx = tc->data_ext = static_cast<TransDataExtension *>(
66 MEM_callocN(tc->data_len * sizeof(TransDataExtension), "MetaElement_TransExtension"));
67
68 copy_m3_m4(mtx, tc->obedit->object_to_world().ptr());
70
72 if (is_prop_edit || (ml->flag & SELECT)) {
73 td->loc = &ml->x;
74 copy_v3_v3(td->iloc, td->loc);
75 copy_v3_v3(td->center, td->loc);
76
77 quat_to_mat3(td->axismtx, ml->quat);
78
79 if (ml->flag & SELECT) {
81 }
82 else {
83 td->flag = TD_USEQUAT;
84 }
85
86 copy_m3_m3(td->smtx, smtx);
87 copy_m3_m3(td->mtx, mtx);
88
89 td->ext = tx;
90
91 /* Radius of MetaElem (mass of MetaElem influence). */
92 if (ml->flag & MB_SCALE_RAD) {
93 td->val = &ml->rad;
94 td->ival = ml->rad;
95 }
96 else {
97 td->val = &ml->s;
98 td->ival = ml->s;
99 }
100
101 /* `expx/expy/expz` determine "shape" of some MetaElem types. */
102 tx->size = &ml->expx;
103 tx->isize[0] = ml->expx;
104 tx->isize[1] = ml->expy;
105 tx->isize[2] = ml->expz;
106
107 /* `quat` is used for rotation of #MetaElem. */
108 tx->quat = ml->quat;
109 copy_qt_qt(tx->iquat, ml->quat);
110
111 tx->rot = nullptr;
112
113 td++;
114 tx++;
115 }
116 }
117 }
118}
119
122/* -------------------------------------------------------------------- */
127{
128 if (t->state != TRANS_CANCEL) {
130 }
132 if (tc->data_len) {
133 DEG_id_tag_update(static_cast<ID *>(tc->obedit->data), ID_RECALC_GEOMETRY);
134 }
135 }
136}
137
141 /*flags*/ (T_EDIT | T_POINTS),
142 /*create_trans_data*/ createTransMBallVerts,
143 /*recalc_data*/ recalcData_mball,
144 /*special_aftertrans_update*/ nullptr,
145};
#define LISTBASE_FOREACH(type, var, list)
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
void quat_to_mat3(float m[3][3], const float q[4])
void copy_qt_qt(float q[4], const float a[4])
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
@ MB_SCALE_RAD
Read Guarded memory(de)allocation.
#define SELECT
int count
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
Definition DNA_ID.h:413
ListBase * editelems
float smtx[3][3]
float axismtx[3][3]
float mtx[3][3]
TransDataExtension * ext
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 createTransMBallVerts(bContext *, TransInfo *t)
TransConvertTypeInfo TransConvertType_MBall
static void recalcData_mball(TransInfo *t)
@ TD_USEQUAT
@ TD_SINGLESIZE
@ TD_SELECTED
void transform_snap_project_individual_apply(TransInfo *t)