Blender V5.0
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
8
9#include "DNA_meta_types.h"
10
11#include "MEM_guardedalloc.h"
12
13#include "BLI_listbase.h"
14#include "BLI_math_matrix.h"
15#include "BLI_math_rotation.h"
16#include "BLI_math_vector.h"
17
18#include "BKE_context.hh"
19
20#include "transform.hh"
21#include "transform_snap.hh"
22
23#include "transform_convert.hh"
24
25namespace blender::ed::transform {
26
27/* -------------------------------------------------------------------- */
30
32{
34 MetaBall *mb = (MetaBall *)tc->obedit->data;
35 TransData *td;
37 float mtx[3][3], smtx[3][3];
38 int count = 0, countsel = 0;
39 const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
40 const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0;
41
42 /* Count totals. */
44 if (ml->flag & SELECT) {
45 countsel++;
46 }
47 if (is_prop_edit) {
48 count++;
49 }
50 }
51
52 /* Support other objects using proportional editing to adjust these, unless connected is
53 * enabled. */
54 if (((is_prop_edit && !is_prop_connected) ? count : countsel) == 0) {
55 tc->data_len = 0;
56 continue;
57 }
58
59 if (is_prop_edit) {
60 tc->data_len = count;
61 }
62 else {
63 tc->data_len = countsel;
64 }
65
66 td = tc->data = MEM_calloc_arrayN<TransData>(tc->data_len, "TransObData(MBall EditMode)");
67 tx = tc->data_ext = MEM_calloc_arrayN<TransDataExtension>(tc->data_len,
68 "MetaElement_TransExtension");
69
70 copy_m3_m4(mtx, tc->obedit->object_to_world().ptr());
72
74 if (is_prop_edit || (ml->flag & SELECT)) {
75 td->loc = &ml->x;
76 copy_v3_v3(td->iloc, td->loc);
77 copy_v3_v3(td->center, td->loc);
78
79 quat_to_mat3(td->axismtx, ml->quat);
80
81 if (ml->flag & SELECT) {
83 }
84 else {
85 td->flag = TD_USEQUAT;
86 }
87
88 copy_m3_m3(td->smtx, smtx);
89 copy_m3_m3(td->mtx, mtx);
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->scale = &ml->expx;
103 tx->iscale[0] = ml->expx;
104 tx->iscale[1] = ml->expy;
105 tx->iscale[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
121
122/* -------------------------------------------------------------------- */
125
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
139
141 /*flags*/ (T_EDIT | T_POINTS),
142 /*create_trans_data*/ createTransMBallVerts,
143 /*recalc_data*/ recalcData_mball,
144 /*special_aftertrans_update*/ nullptr,
145};
146
147} // namespace blender::ed::transform
#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:1074
@ MB_SCALE_RAD
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
void transform_snap_project_individual_apply(TransInfo *t)
TransConvertTypeInfo TransConvertType_MBall
static void recalcData_mball(TransInfo *t)
static void createTransMBallVerts(bContext *, TransInfo *t)
Definition DNA_ID.h:414
ListBase * editelems
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:42
conversion and adaptation of different datablocks to a common struct.