Blender  V3.3
transform_convert_mball.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include "DNA_meta_types.h"
9 
10 #include "MEM_guardedalloc.h"
11 
12 #include "BLI_math.h"
13 
14 #include "BKE_context.h"
15 
16 #include "transform.h"
17 #include "transform_snap.h"
18 
19 #include "transform_convert.h"
20 
21 /* -------------------------------------------------------------------- */
26 {
28  MetaBall *mb = (MetaBall *)tc->obedit->data;
29  MetaElem *ml;
30  TransData *td;
32  float mtx[3][3], smtx[3][3];
33  int count = 0, countsel = 0;
34  const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
35  const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0;
36 
37  /* count totals */
38  for (ml = mb->editelems->first; ml; ml = ml->next) {
39  if (ml->flag & SELECT) {
40  countsel++;
41  }
42  if (is_prop_edit) {
43  count++;
44  }
45  }
46 
47  /* Support other objects using PET to adjust these, unless connected is enabled. */
48  if (((is_prop_edit && !is_prop_connected) ? count : countsel) == 0) {
49  tc->data_len = 0;
50  continue;
51  }
52 
53  if (is_prop_edit) {
54  tc->data_len = count;
55  }
56  else {
57  tc->data_len = countsel;
58  }
59 
60  td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(MBall EditMode)");
61  tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension),
62  "MetaElement_TransExtension");
63 
64  copy_m3_m4(mtx, tc->obedit->obmat);
66 
67  for (ml = mb->editelems->first; ml; ml = ml->next) {
68  if (is_prop_edit || (ml->flag & SELECT)) {
69  td->loc = &ml->x;
70  copy_v3_v3(td->iloc, td->loc);
71  copy_v3_v3(td->center, td->loc);
72 
73  quat_to_mat3(td->axismtx, ml->quat);
74 
75  if (ml->flag & SELECT) {
76  td->flag = TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
77  }
78  else {
79  td->flag = TD_USEQUAT;
80  }
81 
82  copy_m3_m3(td->smtx, smtx);
83  copy_m3_m3(td->mtx, mtx);
84 
85  td->ext = tx;
86 
87  /* Radius of MetaElem (mass of MetaElem influence) */
88  if (ml->flag & MB_SCALE_RAD) {
89  td->val = &ml->rad;
90  td->ival = ml->rad;
91  }
92  else {
93  td->val = &ml->s;
94  td->ival = ml->s;
95  }
96 
97  /* expx/expy/expz determine "shape" of some MetaElem types */
98  tx->size = &ml->expx;
99  tx->isize[0] = ml->expx;
100  tx->isize[1] = ml->expy;
101  tx->isize[2] = ml->expz;
102 
103  /* quat is used for rotation of MetaElem */
104  tx->quat = ml->quat;
105  copy_qt_qt(tx->iquat, ml->quat);
106 
107  tx->rot = NULL;
108 
109  td++;
110  tx++;
111  }
112  }
113  }
114 }
115 
118 /* -------------------------------------------------------------------- */
123 {
124  if (t->state != TRANS_CANCEL) {
126  }
128  if (tc->data_len) {
129  DEG_id_tag_update(tc->obedit->data, ID_RECALC_GEOMETRY);
130  }
131  }
132 }
133 
137  /* flags */ (T_EDIT | T_POINTS),
138  /* createTransData */ createTransMBallVerts,
139  /* recalcData */ recalcData_mball,
140  /* special_aftertrans_update */ NULL,
141 };
void copy_m3_m3(float m1[3][3], const float m2[3][3])
Definition: math_matrix.c:71
void copy_m3_m4(float m1[3][3], const float m2[4][4])
Definition: math_matrix.c:87
#define PSEUDOINVERSE_EPSILON
void pseudoinverse_m3_m3(float Ainv[3][3], const float A[3][3], float epsilon)
Definition: math_matrix.c:3107
void copy_qt_qt(float q[4], const float a[4])
Definition: math_rotation.c:33
void quat_to_mat3(float mat[3][3], const float q[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define UNUSED(x)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
#define MB_SCALE_RAD
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:25
#define SELECT
int count
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
void * first
Definition: DNA_listBase.h:31
ListBase * editelems
conversion and adaptation of different datablocks to a common struct.
static void createTransMBallVerts(bContext *UNUSED(C), TransInfo *t)
TransConvertTypeInfo TransConvertType_MBall
static void recalcData_mball(TransInfo *t)
@ TD_USEQUAT
@ TD_SINGLESIZE
@ TD_SELECTED
void applySnappingIndividual(TransInfo *t)