Blender  V2.93
transform_mode_skin_resize.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include <stdlib.h>
25 
26 #include "BLI_math.h"
27 
28 #include "BKE_context.h"
29 #include "BKE_unit.h"
30 
31 #include "ED_screen.h"
32 
33 #include "UI_interface.h"
34 
35 #include "transform.h"
36 #include "transform_constraints.h"
37 #include "transform_mode.h"
38 #include "transform_snap.h"
39 
40 /* -------------------------------------------------------------------- */
44 static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
45 {
46  float mat[3][3];
47  int i;
48  char str[UI_MAX_DRAW_STR];
49 
50  if (t->flag & T_INPUT_IS_VALUES_FINAL) {
51  copy_v3_v3(t->values_final, t->values);
52  }
53  else {
54  copy_v3_fl(t->values_final, t->values[0]);
55 
56  transform_snap_increment(t, t->values_final);
57 
58  if (applyNumInput(&t->num, t->values_final)) {
59  constraintNumInput(t, t->values_final);
60  }
61 
62  applySnapping(t, t->values_final);
63  }
64 
65  size_to_mat3(mat, t->values_final);
66 
67  headerResize(t, t->values_final, str);
68 
70  TransData *td = tc->data;
71  for (i = 0; i < tc->data_len; i++, td++) {
72  float tmat[3][3], smat[3][3];
73  float fsize[3];
74  if (td->flag & TD_SKIP) {
75  continue;
76  }
77 
78  if (t->flag & T_EDIT) {
79  mul_m3_m3m3(smat, mat, td->mtx);
80  mul_m3_m3m3(tmat, td->smtx, smat);
81  }
82  else {
83  copy_m3_m3(tmat, mat);
84  }
85 
86  if (t->con.applySize) {
87  t->con.applySize(t, NULL, NULL, tmat);
88  }
89 
90  mat3_to_size(fsize, tmat);
91  td->loc[0] = td->iloc[0] * (1 + (fsize[0] - 1) * td->factor);
92  td->loc[1] = td->iloc[1] * (1 + (fsize[1] - 1) * td->factor);
93  }
94  }
95 
96  recalcData(t);
97 
98  ED_area_status_text(t->area, str);
99 }
100 
102 {
103  t->mode = TFM_SKIN_RESIZE;
104  t->transform = applySkinResize;
105 
107 
108  t->flag |= T_NULL_ONE;
109  t->num.val_flag[0] |= NUM_NULL_ONE;
110  t->num.val_flag[1] |= NUM_NULL_ONE;
111  t->num.val_flag[2] |= NUM_NULL_ONE;
112  t->num.flag |= NUM_AFFECT_ALL;
113  if ((t->flag & T_EDIT) == 0) {
114  t->flag |= T_NO_ZERO;
115 #ifdef USE_NUM_NO_ZERO
116  t->num.val_flag[0] |= NUM_NO_ZERO;
117  t->num.val_flag[1] |= NUM_NO_ZERO;
118  t->num.val_flag[2] |= NUM_NO_ZERO;
119 #endif
120  }
121 
122  t->idx_max = 2;
123  t->num.idx_max = 2;
124  t->snap[0] = 0.1f;
125  t->snap[1] = t->snap[0] * 0.1f;
126 
127  copy_v3_fl(t->num.val_inc, t->snap[0]);
128  t->num.unit_sys = t->scene->unit.system;
129  t->num.unit_type[0] = B_UNIT_NONE;
130  t->num.unit_type[1] = B_UNIT_NONE;
131  t->num.unit_type[2] = B_UNIT_NONE;
132 }
@ B_UNIT_NONE
Definition: BKE_unit.h:78
void size_to_mat3(float R[3][3], const float size[3])
Definition: math_matrix.c:2105
void copy_m3_m3(float m1[3][3], const float m2[3][3])
Definition: math_matrix.c:89
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
Definition: math_matrix.c:391
void mat3_to_size(float size[3], const float M[3][3])
Definition: math_matrix.c:2138
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_fl(float r[3], float f)
#define UNUSED(x)
@ NUM_NULL_ONE
Definition: ED_numinput.h:69
@ NUM_NO_ZERO
Definition: ED_numinput.h:71
@ NUM_AFFECT_ALL
Definition: ED_numinput.h:62
bool applyNumInput(NumInput *n, float *vec)
Definition: numinput.c:207
void ED_area_status_text(ScrArea *area, const char *str)
Definition: area.c:815
@ TFM_SKIN_RESIZE
Definition: ED_transform.h:49
_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:90
#define str(s)
float smtx[3][3]
float mtx[3][3]
@ INPUT_SPRING_FLIP
Definition: transform.h:730
void recalcData(TransInfo *t)
@ T_INPUT_IS_VALUES_FINAL
Definition: transform.h:129
@ T_NULL_ONE
Definition: transform.h:107
@ T_NO_ZERO
Definition: transform.h:108
@ T_EDIT
Definition: transform.h:102
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition: transform.h:813
void constraintNumInput(TransInfo *t, float vec[3])
@ TD_SKIP
void headerResize(TransInfo *t, const float vec[3], char str[UI_MAX_DRAW_STR])
transform modes used by different operators.
static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
void initSkinResize(TransInfo *t)
void applySnapping(TransInfo *t, float *vec)
bool transform_snap_increment(TransInfo *t, float *r_val)