Blender  V3.3
transform_mode_skin_resize.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 <stdlib.h>
9 
10 #include "BLI_math.h"
11 #include "BLI_task.h"
12 
13 #include "BKE_context.h"
14 #include "BKE_unit.h"
15 
16 #include "ED_screen.h"
17 
18 #include "UI_interface.h"
19 
20 #include "transform.h"
21 #include "transform_constraints.h"
22 #include "transform_convert.h"
23 #include "transform_snap.h"
24 
25 #include "transform_mode.h"
26 
27 /* -------------------------------------------------------------------- */
35  const TransInfo *t;
37  float mat_final[3][3];
38 };
39 
41  const TransDataContainer *UNUSED(tc),
42  TransData *td,
43  const float mat[3][3])
44 {
45  float tmat[3][3], smat[3][3];
46  float fsize[3];
47 
48  if (t->flag & T_EDIT) {
49  mul_m3_m3m3(smat, mat, td->mtx);
50  mul_m3_m3m3(tmat, td->smtx, smat);
51  }
52  else {
53  copy_m3_m3(tmat, mat);
54  }
55 
56  if (t->con.applySize) {
57  t->con.applySize(t, NULL, NULL, tmat);
58  }
59 
60  mat3_to_size(fsize, tmat);
61  td->loc[0] = td->iloc[0] * (1 + (fsize[0] - 1) * td->factor);
62  td->loc[1] = td->iloc[1] * (1 + (fsize[1] - 1) * td->factor);
63 }
64 
65 static void transdata_elem_skin_resize_fn(void *__restrict iter_data_v,
66  const int iter,
67  const TaskParallelTLS *__restrict UNUSED(tls))
68 {
69  struct TransDataArgs_SkinResize *data = iter_data_v;
70  TransData *td = &data->tc->data[iter];
71  if (td->flag & TD_SKIP) {
72  return;
73  }
74  transdata_elem_skin_resize(data->t, data->tc, td, data->mat_final);
75 }
76 
79 /* -------------------------------------------------------------------- */
83 static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
84 {
85  float mat_final[3][3];
86  int i;
87  char str[UI_MAX_DRAW_STR];
88 
89  if (t->flag & T_INPUT_IS_VALUES_FINAL) {
90  copy_v3_v3(t->values_final, t->values);
91  }
92  else {
93  copy_v3_fl(t->values_final, t->values[0]);
94  add_v3_v3(t->values_final, t->values_modal_offset);
95 
96  transform_snap_increment(t, t->values_final);
97 
98  if (applyNumInput(&t->num, t->values_final)) {
99  constraintNumInput(t, t->values_final);
100  }
101 
102  applySnappingAsGroup(t, t->values_final);
103  }
104 
105  size_to_mat3(mat_final, t->values_final);
106 
107  headerResize(t, t->values_final, str, sizeof(str));
108 
111  TransData *td = tc->data;
112  for (i = 0; i < tc->data_len; i++, td++) {
113  if (td->flag & TD_SKIP) {
114  continue;
115  }
117  }
118  }
119  else {
120  struct TransDataArgs_SkinResize data = {
121  .t = t,
122  .tc = tc,
123  };
124  copy_m3_m3(data.mat_final, mat_final);
125  TaskParallelSettings settings;
128  }
129  }
130 
131  recalcData(t);
132 
133  ED_area_status_text(t->area, str);
134 }
135 
137 {
138  t->mode = TFM_SKIN_RESIZE;
139  t->transform = applySkinResize;
140 
142 
143  t->flag |= T_NULL_ONE;
144  t->num.val_flag[0] |= NUM_NULL_ONE;
145  t->num.val_flag[1] |= NUM_NULL_ONE;
146  t->num.val_flag[2] |= NUM_NULL_ONE;
147  t->num.flag |= NUM_AFFECT_ALL;
148  if ((t->flag & T_EDIT) == 0) {
149 #ifdef USE_NUM_NO_ZERO
150  t->num.val_flag[0] |= NUM_NO_ZERO;
151  t->num.val_flag[1] |= NUM_NO_ZERO;
152  t->num.val_flag[2] |= NUM_NO_ZERO;
153 #endif
154  }
155 
156  t->idx_max = 2;
157  t->num.idx_max = 2;
158  t->snap[0] = 0.1f;
159  t->snap[1] = t->snap[0] * 0.1f;
160 
161  copy_v3_fl(t->num.val_inc, t->snap[0]);
162  t->num.unit_sys = t->scene->unit.system;
163  t->num.unit_type[0] = B_UNIT_NONE;
164  t->num.unit_type[1] = B_UNIT_NONE;
165  t->num.unit_type[2] = B_UNIT_NONE;
166 }
167 
@ B_UNIT_NONE
Definition: BKE_unit.h:100
void size_to_mat3(float R[3][3], const float size[3])
Definition: math_matrix.c:2098
void copy_m3_m3(float m1[3][3], const float m2[3][3])
Definition: math_matrix.c:71
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
Definition: math_matrix.c:388
void mat3_to_size(float size[3], const float M[3][3])
Definition: math_matrix.c:2131
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
Definition: task_range.cc:94
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
Definition: BLI_task.h:293
#define UNUSED(x)
@ NUM_NULL_ONE
Definition: ED_numinput.h:55
@ NUM_NO_ZERO
Definition: ED_numinput.h:57
@ NUM_AFFECT_ALL
Definition: ED_numinput.h:48
bool applyNumInput(NumInput *n, float *vec)
Definition: numinput.c:189
void ED_area_status_text(ScrArea *area, const char *str)
Definition: area.c:792
@ TFM_SKIN_RESIZE
Definition: ED_transform.h:33
_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
#define UI_MAX_DRAW_STR
Definition: UI_interface.h:91
#define str(s)
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
const TransDataContainer * tc
float smtx[3][3]
float mtx[3][3]
void constraintNumInput(TransInfo *t, float vec[3])
void recalcData(TransInfo *t)
conversion and adaptation of different datablocks to a common struct.
@ TD_SKIP
#define TRANSDATA_THREAD_LIMIT
void headerResize(TransInfo *t, const float vec[3], char *str, const int str_size)
transform modes used by different operators.
static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
void initSkinResize(TransInfo *t)
static void transdata_elem_skin_resize(const TransInfo *t, const TransDataContainer *UNUSED(tc), TransData *td, const float mat[3][3])
static void transdata_elem_skin_resize_fn(void *__restrict iter_data_v, const int iter, const TaskParallelTLS *__restrict UNUSED(tls))
bool transform_snap_increment(const TransInfo *t, float *r_val)
void applySnappingAsGroup(TransInfo *t, float *vec)