Blender V5.0
transform_mode_baketime.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
34static void applyBakeTime(TransInfo *t)
35{
36 float time;
37 int i;
38 char str[UI_MAX_DRAW_STR];
39
40 float fac = 0.1f;
41
42/* XXX, disable precision for now,
43 * this isn't even accessible by the user. */
44#if 0
45 if (t->mouse.precision) {
46 /* Calculate ratio for shift-key position, and for total, and blend these for precision. */
47 time = float(t->center2d[0] - t->mouse.precision_mval[0]) * fac;
48 time += 0.1f * (float(t->center2d[0] * fac - mval[0]) - time);
49 }
50 else
51#endif
52 {
53 time = (t->center2d[0] - t->mval[0]) * fac;
54 }
55
57
58 applyNumInput(&t->num, &time);
59
60 /* Header print for NumInput. */
61 if (hasNumInput(&t->num)) {
62 char c[NUM_STR_REP_LEN];
63
64 outputNumInput(&(t->num), c, t->scene->unit);
65
66 if (time >= 0.0f) {
67 SNPRINTF_UTF8(str, IFACE_("Time: +%s %s"), c, t->proptext);
68 }
69 else {
70 SNPRINTF_UTF8(str, IFACE_("Time: %s %s"), c, t->proptext);
71 }
72 }
73 else {
74 /* Default header print. */
75 if (time >= 0.0f) {
76 SNPRINTF_UTF8(str, IFACE_("Time: +%.3f %s"), time, t->proptext);
77 }
78 else {
79 SNPRINTF_UTF8(str, IFACE_("Time: %.3f %s"), time, t->proptext);
80 }
81 }
82
84 TransData *td = tc->data;
85 TransDataExtension *td_ext = tc->data_ext;
86 for (i = 0; i < tc->data_len; i++, td++, td_ext++) {
87 if (td->flag & TD_SKIP) {
88 continue;
89 }
90
91 float *dst, ival;
92 if (td->val) {
93 dst = td->val;
94 ival = td->ival;
95 }
96 else {
97 dst = &td->loc[0];
98 ival = td->iloc[0];
99 }
100
101 *dst = ival + time * td->factor;
102 if (td_ext->scale && *dst < *td_ext->scale) {
103 *dst = *td_ext->scale;
104 }
105 if (td_ext->quat && *dst > *td_ext->quat) {
106 *dst = *td_ext->quat;
107 }
108 }
109 }
110
111 recalc_data(t);
112
114}
115
116static void initBakeTime(TransInfo *t, wmOperator * /*op*/)
117{
119
120 t->idx_max = 0;
121 t->num.idx_max = 0;
122 t->increment[0] = 1.0f;
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; /* Don't think this uses units? */
128}
129
131
133 /*flags*/ 0,
134 /*init_fn*/ initBakeTime,
135 /*transform_fn*/ applyBakeTime,
136 /*transform_matrix_fn*/ nullptr,
137 /*handle_event_fn*/ nullptr,
138 /*snap_distance_fn*/ nullptr,
139 /*snap_apply_fn*/ nullptr,
140 /*draw_fn*/ nullptr,
141};
142
143} // 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
nullptr float
#define str(s)
static void initBakeTime(TransInfo *t, wmOperator *)
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 applyBakeTime(TransInfo *t)
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.