Blender V5.0
transform_mode_boneenvelope.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_vector.h"
12#include "BLI_string_utf8.h"
13
14#include "BKE_unit.hh"
15
16#include "ED_screen.hh"
17
18#include "BLT_translation.hh"
19
20#include "UI_interface_types.hh"
21
22#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{
36 float ratio;
37 int i;
38 char str[UI_MAX_DRAW_STR];
39
40 ratio = t->values[0] + t->values_modal_offset[0];
41
42 transform_snap_increment(t, &ratio);
43
44 applyNumInput(&t->num, &ratio);
45
46 t->values_final[0] = ratio;
47
48 /* Header print for NumInput. */
49 if (hasNumInput(&t->num)) {
50 char c[NUM_STR_REP_LEN];
51
52 outputNumInput(&(t->num), c, t->scene->unit);
53 SNPRINTF_UTF8(str, IFACE_("Envelope: %s"), c);
54 }
55 else {
56 SNPRINTF_UTF8(str, IFACE_("Envelope: %3f"), ratio);
57 }
58
60 TransData *td = tc->data;
61 for (i = 0; i < tc->data_len; i++, td++) {
62 if (td->flag & TD_SKIP) {
63 continue;
64 }
65
66 if (td->val) {
67 /* If the old/original value was 0.0f, then just use ratio. */
68 if (td->ival) {
69 *td->val = td->ival * ratio;
70 }
71 else {
72 *td->val = ratio;
73 }
74 }
75 }
76 }
77
78 recalc_data(t);
79
81}
82
83static void initBoneEnvelope(TransInfo *t, wmOperator * /*op*/)
84{
86
87 t->idx_max = 0;
88 t->num.idx_max = 0;
89 t->increment[0] = 0.1f;
90 t->increment_precision = 0.1f;
91
93 t->num.unit_sys = t->scene->unit.system;
95}
96
98
100 /*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
101 /*init_fn*/ initBoneEnvelope,
102 /*transform_fn*/ applyBoneEnvelope,
103 /*transform_matrix_fn*/ nullptr,
104 /*handle_event_fn*/ nullptr,
105 /*snap_distance_fn*/ nullptr,
106 /*snap_apply_fn*/ nullptr,
107 /*draw_fn*/ nullptr,
108};
109
110} // namespace blender::ed::transform
@ B_UNIT_NONE
Definition BKE_unit.hh:136
MINLINE void copy_v3_fl(float r[3], float f)
#define SNPRINTF_UTF8(dst, format,...)
#define IFACE_(msgid)
#define NUM_STR_REP_LEN
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:190
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:88
bool hasNumInput(const NumInput *n)
Definition numinput.cc:171
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:851
#define UI_MAX_DRAW_STR
#define str(s)
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
void recalc_data(TransInfo *t)
bool transform_snap_increment(const TransInfo *t, float *r_val)
static void applyBoneEnvelope(TransInfo *t)
static void initBoneEnvelope(TransInfo *t, wmOperator *)
short idx_max
float val_inc[NUM_MAX_ELEMENTS]
int unit_type[NUM_MAX_ELEMENTS]
struct UnitSettings unit
i
Definition text_draw.cc:230
#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.