Blender V5.0
transform_mode_align.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 "ED_screen.hh"
12
13#include "BLI_math_matrix.h"
14#include "BLI_math_vector.h"
15
16#include "BLT_translation.hh"
17
18#include "transform.hh"
19#include "transform_convert.hh"
20
21#include "transform_mode.hh"
22
23namespace blender::ed::transform {
24
25/* -------------------------------------------------------------------- */
28
29static void applyAlign(TransInfo *t)
30{
31 float center[3];
32 int i;
33
35 /* Saving original center. */
36 copy_v3_v3(center, tc->center_local);
37 TransData *td = tc->data;
38 for (i = 0; i < tc->data_len; i++, td++) {
39 float mat[3][3], invmat[3][3];
40
41 if (td->flag & TD_SKIP) {
42 continue;
43 }
44
45 /* Around local centers. */
46 if (t->options & (CTX_OBJECT | CTX_POSE_BONE)) {
47 copy_v3_v3(tc->center_local, td->center);
48 }
49 else {
51 copy_v3_v3(tc->center_local, td->center);
52 }
53 }
54
55 invert_m3_m3(invmat, td->axismtx);
56
57 mul_m3_m3m3(mat, t->spacemtx, invmat);
58
59 TransDataExtension *td_ext = tc->data_ext ? &tc->data_ext[i] : nullptr;
60 ElementRotation(t, tc, td, td_ext, mat, t->around);
61 }
62 /* Restoring original center. */
63 copy_v3_v3(tc->center_local, center);
64 }
65
66 recalc_data(t);
67
68 ED_area_status_text(t->area, IFACE_("Align"));
69}
70
71static void initAlign(TransInfo *t, wmOperator * /*op*/)
72{
74}
75
77
79 /*flags*/ T_NO_CONSTRAINT,
80 /*init_fn*/ initAlign,
81 /*transform_fn*/ applyAlign,
82 /*transform_matrix_fn*/ nullptr,
83 /*handle_event_fn*/ nullptr,
84 /*snap_distance_fn*/ nullptr,
85 /*snap_apply_fn*/ nullptr,
86 /*draw_fn*/ nullptr,
87};
88
89} // namespace blender::ed::transform
bool invert_m3_m3(float inverse[3][3], const float mat[3][3])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define IFACE_(msgid)
@ SCE_SELECT_FACE
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:851
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
void recalc_data(TransInfo *t)
static void initAlign(TransInfo *t, wmOperator *)
void ElementRotation(const TransInfo *t, const TransDataContainer *tc, TransData *td, TransDataExtension *td_ext, const float mat[3][3], const short around)
static void applyAlign(TransInfo *t)
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.