Blender  V3.3
transform_mode_edge_crease.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_string.h"
12 #include "BLI_task.h"
13 
14 #include "BKE_context.h"
15 #include "BKE_unit.h"
16 
17 #include "ED_screen.h"
18 
19 #include "UI_interface.h"
20 
21 #include "BLT_translation.h"
22 
23 #include "transform.h"
24 #include "transform_convert.h"
25 #include "transform_snap.h"
26 
27 #include "transform_mode.h"
28 
29 /* -------------------------------------------------------------------- */
37  const TransInfo *t;
39  float crease;
40 };
41 
43  const TransDataContainer *UNUSED(tc),
44  TransData *td,
45  const float crease)
46 {
47  if (td->loc == NULL) {
48  return;
49  }
50 
51  *td->loc = td->iloc[0] + crease * td->factor;
52  CLAMP(*td->loc, 0.0f, 1.0f);
53 }
54 
55 static void transdata_elem_crease_fn(void *__restrict iter_data_v,
56  const int iter,
57  const TaskParallelTLS *__restrict UNUSED(tls))
58 {
59  struct TransDataArgs_Crease *data = iter_data_v;
60  TransData *td = &data->tc->data[iter];
61  if (td->flag & TD_SKIP) {
62  return;
63  }
64  transdata_elem_crease(data->t, data->tc, td, data->crease);
65 }
66 
69 /* -------------------------------------------------------------------- */
73 static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
74 {
75  float crease;
76  int i;
77  char str[UI_MAX_DRAW_STR];
78 
79  crease = t->values[0] + t->values_modal_offset[0];
80 
81  CLAMP_MAX(crease, 1.0f);
82 
84 
85  applyNumInput(&t->num, &crease);
86 
87  t->values_final[0] = crease;
88 
89  /* header print for NumInput */
90  if (hasNumInput(&t->num)) {
91  char c[NUM_STR_REP_LEN];
92 
93  outputNumInput(&(t->num), c, &t->scene->unit);
94 
95  if (crease >= 0.0f) {
96  BLI_snprintf(str, sizeof(str), TIP_("Crease: +%s %s"), c, t->proptext);
97  }
98  else {
99  BLI_snprintf(str, sizeof(str), TIP_("Crease: %s %s"), c, t->proptext);
100  }
101  }
102  else {
103  /* default header print */
104  if (crease >= 0.0f) {
105  BLI_snprintf(str, sizeof(str), TIP_("Crease: +%.3f %s"), crease, t->proptext);
106  }
107  else {
108  BLI_snprintf(str, sizeof(str), TIP_("Crease: %.3f %s"), crease, t->proptext);
109  }
110  }
111 
114  TransData *td = tc->data;
115  for (i = 0; i < tc->data_len; i++, td++) {
116  if (td->flag & TD_SKIP) {
117  continue;
118  }
120  }
121  }
122  else {
123  struct TransDataArgs_Crease data = {
124  .t = t,
125  .tc = tc,
126  .crease = crease,
127  };
128  TaskParallelSettings settings;
131  }
132  }
133 
134  recalcData(t);
135 
136  ED_area_status_text(t->area, str);
137 }
138 
139 static void initCrease_ex(TransInfo *t, int mode)
140 {
141  t->mode = mode;
142  t->transform = applyCrease;
143 
145 
146  t->idx_max = 0;
147  t->num.idx_max = 0;
148  t->snap[0] = 0.1f;
149  t->snap[1] = t->snap[0] * 0.1f;
150 
151  copy_v3_fl(t->num.val_inc, t->snap[0]);
152  t->num.unit_sys = t->scene->unit.system;
153  t->num.unit_type[0] = B_UNIT_NONE;
154 
155  t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
156 }
157 
159 {
161 }
162 
164 {
166 }
@ B_UNIT_NONE
Definition: BKE_unit.h:100
MINLINE void copy_v3_fl(float r[3], float f)
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
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 CLAMP_MAX(a, c)
#define UNUSED(x)
#define TIP_(msgid)
void outputNumInput(NumInput *n, char *str, struct UnitSettings *unit_settings)
Definition: numinput.c:87
#define NUM_STR_REP_LEN
Definition: ED_numinput.h:13
bool applyNumInput(NumInput *n, float *vec)
Definition: numinput.c:189
bool hasNumInput(const NumInput *n)
Definition: numinput.c:170
void ED_area_status_text(ScrArea *area, const char *str)
Definition: area.c:792
@ TFM_VERT_CREASE
Definition: ED_transform.h:42
@ TFM_EDGE_CREASE
Definition: ED_transform.h:41
_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
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
#define UI_MAX_DRAW_STR
Definition: UI_interface.h:91
#define str(s)
static unsigned c
Definition: RandGen.cpp:83
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
const TransDataContainer * tc
void recalcData(TransInfo *t)
conversion and adaptation of different datablocks to a common struct.
@ TD_SKIP
#define TRANSDATA_THREAD_LIMIT
transform modes used by different operators.
static void transdata_elem_crease(const TransInfo *UNUSED(t), const TransDataContainer *UNUSED(tc), TransData *td, const float crease)
void initVertCrease(TransInfo *t)
static void initCrease_ex(TransInfo *t, int mode)
void initEgdeCrease(TransInfo *t)
static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
static void transdata_elem_crease_fn(void *__restrict iter_data_v, const int iter, const TaskParallelTLS *__restrict UNUSED(tls))
bool transform_snap_increment(const TransInfo *t, float *r_val)