Blender V4.3
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
9#include <cstdlib>
10
11#include "BLI_math_vector.h"
12#include "BLI_string.h"
13
14#include "BKE_unit.hh"
15
16#include "ED_screen.hh"
17
18#include "UI_interface.hh"
19
20#include "BLT_translation.hh"
21
22#include "transform.hh"
23#include "transform_convert.hh"
24#include "transform_snap.hh"
25
26#include "transform_mode.hh"
27
28/* -------------------------------------------------------------------- */
32static void applyBakeTime(TransInfo *t)
33{
34 float time;
35 int i;
36 char str[UI_MAX_DRAW_STR];
37
38 float fac = 0.1f;
39
40/* XXX, disable precision for now,
41 * this isn't even accessible by the user. */
42#if 0
43 if (t->mouse.precision) {
44 /* Calculate ratio for shift-key position, and for total, and blend these for precision. */
45 time = float(t->center2d[0] - t->mouse.precision_mval[0]) * fac;
46 time += 0.1f * (float(t->center2d[0] * fac - mval[0]) - time);
47 }
48 else
49#endif
50 {
51 time = (t->center2d[0] - t->mval[0]) * fac;
52 }
53
55
56 applyNumInput(&t->num, &time);
57
58 /* Header print for NumInput. */
59 if (hasNumInput(&t->num)) {
60 char c[NUM_STR_REP_LEN];
61
62 outputNumInput(&(t->num), c, &t->scene->unit);
63
64 if (time >= 0.0f) {
65 SNPRINTF(str, IFACE_("Time: +%s %s"), c, t->proptext);
66 }
67 else {
68 SNPRINTF(str, IFACE_("Time: %s %s"), c, t->proptext);
69 }
70 }
71 else {
72 /* Default header print. */
73 if (time >= 0.0f) {
74 SNPRINTF(str, IFACE_("Time: +%.3f %s"), time, t->proptext);
75 }
76 else {
77 SNPRINTF(str, IFACE_("Time: %.3f %s"), time, t->proptext);
78 }
79 }
80
82 TransData *td = tc->data;
83 for (i = 0; i < tc->data_len; i++, td++) {
84 if (td->flag & TD_SKIP) {
85 continue;
86 }
87
88 float *dst, ival;
89 if (td->val) {
90 dst = td->val;
91 ival = td->ival;
92 }
93 else {
94 dst = &td->loc[0];
95 ival = td->iloc[0];
96 }
97
98 *dst = ival + time * td->factor;
99 if (td->ext->size && *dst < *td->ext->size) {
100 *dst = *td->ext->size;
101 }
102 if (td->ext->quat && *dst > *td->ext->quat) {
103 *dst = *td->ext->quat;
104 }
105 }
106 }
107
108 recalc_data(t);
109
111}
112
113static void initBakeTime(TransInfo *t, wmOperator * /*op*/)
114{
116
117 t->idx_max = 0;
118 t->num.idx_max = 0;
119 t->snap[0] = 1.0f;
120 t->snap[1] = t->snap[0] * 0.1f;
121
122 copy_v3_fl(t->num.val_inc, t->snap[0]);
123 t->num.unit_sys = t->scene->unit.system;
124 t->num.unit_type[0] = B_UNIT_NONE; /* Don't think this uses units? */
125}
126
130 /*flags*/ 0,
131 /*init_fn*/ initBakeTime,
132 /*transform_fn*/ applyBakeTime,
133 /*transform_matrix_fn*/ nullptr,
134 /*handle_event_fn*/ nullptr,
135 /*snap_distance_fn*/ nullptr,
136 /*snap_apply_fn*/ nullptr,
137 /*draw_fn*/ nullptr,
138};
@ B_UNIT_NONE
Definition BKE_unit.hh:106
MINLINE void copy_v3_fl(float r[3], float f)
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:597
#define IFACE_(msgid)
#define NUM_STR_REP_LEN
void outputNumInput(NumInput *n, char *str, const UnitSettings *unit_settings)
Definition numinput.cc:88
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:190
bool hasNumInput(const NumInput *n)
Definition numinput.cc:171
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:803
#define UI_MAX_DRAW_STR
double time
draw_view in_light_buf[] float
#define str(s)
bool precision
Definition transform.hh:387
short idx_max
float val_inc[NUM_MAX_ELEMENTS]
int unit_type[NUM_MAX_ELEMENTS]
struct UnitSettings unit
TransDataExtension * ext
float snap[2]
Definition transform.hh:561
float center2d[2]
Definition transform.hh:557
char proptext[20]
Definition transform.hh:548
short idx_max
Definition transform.hh:559
NumInput num
Definition transform.hh:540
Scene * scene
Definition transform.hh:654
MouseInput mouse
Definition transform.hh:543
blender::float2 mval
Definition transform.hh:663
ScrArea * area
Definition transform.hh:651
@ INPUT_NONE
Definition transform.hh:741
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:854
void recalc_data(TransInfo *t)
conversion and adaptation of different datablocks to a common struct.
@ TD_SKIP
transform modes used by different operators.
static void applyBakeTime(TransInfo *t)
static void initBakeTime(TransInfo *t, wmOperator *)
TransModeInfo TransMode_baketime
bool transform_snap_increment(const TransInfo *t, float *r_val)