Blender V5.0
transform_mode_skin_resize.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 <cstdlib>
10
11#include "BLI_math_matrix.h"
12#include "BLI_math_vector.h"
13#include "BLI_task.hh"
14
15#include "BKE_unit.hh"
16
17#include "ED_screen.hh"
18
19#include "UI_interface_types.hh"
20
21#include "transform.hh"
23#include "transform_convert.hh"
24#include "transform_snap.hh"
25
26#include "transform_mode.hh"
27
28namespace blender::ed::transform {
29
30/* -------------------------------------------------------------------- */
33
35 const TransDataContainer * /*tc*/,
36 TransData *td,
37 const float mat[3][3])
38{
39 float tmat[3][3], smat[3][3];
40 float fscale[3];
41
42 if (t->flag & T_EDIT) {
43 mul_m3_m3m3(smat, mat, td->mtx);
44 mul_m3_m3m3(tmat, td->smtx, smat);
45 }
46 else {
47 copy_m3_m3(tmat, mat);
48 }
49
50 if (t->con.applySize) {
51 t->con.applySize(t, nullptr, nullptr, tmat);
52 }
53
54 mat3_to_size(fscale, tmat);
55 td->loc[0] = td->iloc[0] * (1 + (fscale[0] - 1) * td->factor);
56 td->loc[1] = td->iloc[1] * (1 + (fscale[1] - 1) * td->factor);
57}
58
60{
61 float mat_final[3][3];
62 char str[UI_MAX_DRAW_STR];
63
66 }
67 else {
70
72
73 if (applyNumInput(&t->num, t->values_final)) {
75 }
76
78 }
79
80 size_to_mat3(mat_final, t->values_final);
81
82 headerResize(t, t->values_final, str, sizeof(str));
83
85 threading::parallel_for(IndexRange(tc->data_len), 1024, [&](const IndexRange range) {
86 for (const int i : range) {
87 TransData *td = &tc->data[i];
88 if (td->flag & TD_SKIP) {
89 continue;
90 }
91 transdata_elem_skin_resize(t, tc, td, mat_final);
92 }
93 });
94 }
95
96 recalc_data(t);
97
98 ED_area_status_text(t->area, str);
99}
100
101static void initSkinResize(TransInfo *t, wmOperator * /*op*/)
102{
104
106
107 t->flag |= T_NULL_ONE;
108 t->num.val_flag[0] |= NUM_NULL_ONE;
109 t->num.val_flag[1] |= NUM_NULL_ONE;
110 t->num.val_flag[2] |= NUM_NULL_ONE;
111 t->num.flag |= NUM_AFFECT_ALL;
112 if ((t->flag & T_EDIT) == 0) {
113#ifdef USE_NUM_NO_ZERO
114 t->num.val_flag[0] |= NUM_NO_ZERO;
115 t->num.val_flag[1] |= NUM_NO_ZERO;
116 t->num.val_flag[2] |= NUM_NO_ZERO;
117#endif
118 }
119
120 t->idx_max = 2;
121 t->num.idx_max = 2;
122 t->increment = float3(0.1f);
123 t->increment_precision = 0.1f;
124
125 copy_v3_fl(t->num.val_inc, t->increment[0]);
126 t->num.unit_sys = t->scene->unit.system;
127 t->num.unit_type[0] = B_UNIT_NONE;
128 t->num.unit_type[1] = B_UNIT_NONE;
129 t->num.unit_type[2] = B_UNIT_NONE;
130}
131
133
135 /*flags*/ 0,
136 /*init_fn*/ initSkinResize,
137 /*transform_fn*/ applySkinResize,
138 /*transform_matrix_fn*/ nullptr,
139 /*handle_event_fn*/ nullptr,
140 /*snap_distance_fn*/ nullptr,
141 /*snap_apply_fn*/ nullptr,
142 /*draw_fn*/ nullptr,
143};
144
145} // namespace blender::ed::transform
@ B_UNIT_NONE
Definition BKE_unit.hh:136
void size_to_mat3(float R[3][3], const float size[3])
void copy_m3_m3(float m1[3][3], const float m2[3][3])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void mat3_to_size(float size[3], const float M[3][3])
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])
@ NUM_AFFECT_ALL
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:190
@ NUM_NULL_ONE
@ NUM_NO_ZERO
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:851
#define UI_MAX_DRAW_STR
#define str(s)
VecBase< float, 3 > float3
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
void recalc_data(TransInfo *t)
bool transform_snap_increment(const TransInfo *t, float *r_val)
void transform_snap_mixed_apply(TransInfo *t, float *vec)
static void initSkinResize(TransInfo *t, wmOperator *)
void headerResize(TransInfo *t, const float vec[3], char *str, const int str_size)
static void transdata_elem_skin_resize(const TransInfo *t, const TransDataContainer *, TransData *td, const float mat[3][3])
void constraintNumInput(TransInfo *t, float vec[3])
static void applySkinResize(TransInfo *t)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:93
short idx_max
short val_flag[NUM_MAX_ELEMENTS]
float val_inc[NUM_MAX_ELEMENTS]
int unit_type[NUM_MAX_ELEMENTS]
short flag
struct UnitSettings unit
void(* applySize)(const TransInfo *t, const TransDataContainer *tc, const TransData *td, float r_smat[3][3])
Definition transform.hh:591
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:42
conversion and adaptation of different datablocks to a common struct.
transform modes used by different operators.