2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2020-02-14 08:42:17 -03:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup edtransform
|
|
|
|
|
* \brief transform modes used by different operators.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
struct BMVert;
|
2020-02-15 18:43:58 -03:00
|
|
|
struct LinkNode;
|
2020-02-14 08:42:17 -03:00
|
|
|
struct TransData;
|
2020-03-14 15:22:04 +11:00
|
|
|
struct TransDataContainer;
|
|
|
|
|
struct TransInfo;
|
2020-09-30 11:51:13 +10:00
|
|
|
struct bContext;
|
2020-02-21 10:42:56 -03:00
|
|
|
struct wmOperator;
|
2023-07-13 17:59:52 +02:00
|
|
|
struct wmEvent;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
struct TransModeInfo {
|
2023-06-02 14:42:27 +02:00
|
|
|
int flags; /* eTFlag */
|
|
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
void (*init_fn)(TransInfo *, wmOperator *);
|
2023-06-02 14:42:27 +02:00
|
|
|
|
|
|
|
|
/** Main transform mode function. */
|
2023-08-02 15:03:58 -03:00
|
|
|
void (*transform_fn)(TransInfo *);
|
2023-06-02 14:42:27 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Optional callback to transform a single matrix.
|
|
|
|
|
*
|
|
|
|
|
* \note used by the gizmo to transform the matrix used to position it.
|
|
|
|
|
*/
|
|
|
|
|
void (*transform_matrix_fn)(TransInfo *, float[4][4]);
|
|
|
|
|
|
|
|
|
|
/* Event handler function that determines whether the viewport needs to be redrawn. */
|
2023-07-13 17:59:52 +02:00
|
|
|
enum eRedrawFlag (*handle_event_fn)(TransInfo *, const wmEvent *);
|
2023-06-02 14:42:27 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the transform distance between two points (used by Closest snap)
|
|
|
|
|
*
|
|
|
|
|
* \note Return value can be anything,
|
|
|
|
|
* where the smallest absolute value defines what's closest.
|
|
|
|
|
*/
|
2023-07-13 17:59:52 +02:00
|
|
|
float (*snap_distance_fn)(TransInfo *t, const float p1[3], const float p2[3]);
|
|
|
|
|
void (*snap_apply_fn)(TransInfo *, float *);
|
2023-06-02 14:42:27 +02:00
|
|
|
|
|
|
|
|
/** Custom drawing. */
|
2023-07-13 17:59:52 +02:00
|
|
|
void (*draw_fn)(TransInfo *);
|
|
|
|
|
};
|
2023-06-02 14:42:27 +02:00
|
|
|
|
2020-02-15 18:43:58 -03:00
|
|
|
/* header of TransDataEdgeSlideVert, TransDataEdgeSlideEdge */
|
2023-07-13 17:59:52 +02:00
|
|
|
struct TransDataGenericSlideVert {
|
|
|
|
|
BMVert *v;
|
|
|
|
|
LinkNode **cd_loop_groups;
|
2020-02-15 18:43:58 -03:00
|
|
|
float co_orig_3d[3];
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2020-02-15 18:43:58 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
eTfmMode transform_mode_really_used(bContext *C, eTfmMode mode);
|
2021-06-29 20:13:55 +10:00
|
|
|
bool transdata_check_local_center(const TransInfo *t, short around);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Informs if the mode can be switched during modal.
|
|
|
|
|
*/
|
2022-01-07 11:38:08 +11:00
|
|
|
bool transform_mode_is_changeable(int mode);
|
2020-02-14 08:42:17 -03:00
|
|
|
void protectedTransBits(short protectflag, float vec[3]);
|
2020-12-02 09:09:26 -03:00
|
|
|
void protectedSizeBits(short protectflag, float size[3]);
|
2023-10-06 17:14:25 +02:00
|
|
|
void constraintTransLim(const TransInfo *t, const TransDataContainer *tc, TransData *td);
|
2021-06-29 20:13:55 +10:00
|
|
|
void constraintSizeLim(const TransInfo *t, TransData *td);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Used by Transform Rotation and Transform Normal Rotation.
|
|
|
|
|
*/
|
2021-05-27 10:41:40 +02:00
|
|
|
void headerRotation(TransInfo *t, char *str, int str_size, float final);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Applies values of rotation to `td->loc` and `td->ext->quat`
|
|
|
|
|
* based on a rotation matrix (mat) and a pivot (center).
|
|
|
|
|
*
|
|
|
|
|
* Protected axis and other transform settings are taken into account.
|
|
|
|
|
*/
|
2021-06-29 20:13:55 +10:00
|
|
|
void ElementRotation_ex(const TransInfo *t,
|
|
|
|
|
const TransDataContainer *tc,
|
2020-02-14 08:42:17 -03:00
|
|
|
TransData *td,
|
|
|
|
|
const float mat[3][3],
|
|
|
|
|
const float *center);
|
2021-06-29 20:13:55 +10:00
|
|
|
void ElementRotation(const TransInfo *t,
|
|
|
|
|
const TransDataContainer *tc,
|
|
|
|
|
TransData *td,
|
|
|
|
|
const float mat[3][3],
|
2022-01-07 11:38:08 +11:00
|
|
|
short around);
|
2021-05-27 10:41:40 +02:00
|
|
|
void headerResize(TransInfo *t, const float vec[3], char *str, int str_size);
|
2021-06-29 20:13:55 +10:00
|
|
|
void ElementResize(const TransInfo *t,
|
|
|
|
|
const TransDataContainer *tc,
|
|
|
|
|
TransData *td,
|
|
|
|
|
const float mat[3][3]);
|
2023-07-13 17:59:52 +02:00
|
|
|
void transform_mode_init(TransInfo *t, wmOperator *op, int mode);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* When in modal and not set, initializes a default orientation for the mode.
|
|
|
|
|
*/
|
2021-05-11 23:40:06 -03:00
|
|
|
void transform_mode_default_modal_orientation_set(TransInfo *t, int type);
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_align.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_align;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_baketime.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_baketime;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_bbone_resize.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_bboneresize;
|
2020-02-14 11:57:56 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_bend.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_bend;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_boneenvelope.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_boneenvelope;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_boneroll.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_boneroll;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_curveshrinkfatten.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_curveshrinkfatten;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_customdata.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_edgecrease;
|
|
|
|
|
extern TransModeInfo TransMode_vertcrease;
|
|
|
|
|
extern TransModeInfo TransMode_bevelweight;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_edge_rotate_normal.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_rotatenormal;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_edge_seq_slide.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_seqslide;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_edge_slide.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_edgeslide;
|
2022-08-26 13:17:30 -03:00
|
|
|
void transform_mode_edge_slide_reproject_input(TransInfo *t);
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_gpopacity.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_gpopacity;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_gpshrinkfatten.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_gpshrinkfatten;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_maskshrinkfatten.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_maskshrinkfatten;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_mirror.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_mirror;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_push_pull.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_pushpull;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_resize.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_resize;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_rotate.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_rotate;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_shear.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_shear;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_shrink_fatten.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_shrinkfatten;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_skin_resize.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_skinresize;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_snapsource.cc` */
|
Transform: new feature to edit the 'Snap Base'
This commit implements a new modifier key (`B`) for the transform
operators.
This new key allows changing the 'Snap Base' of a transform by snapping
it to a defined point in the scene.
Ref #66424
# Implementation Details
- This feature is only available in the 3D View.
- This feature is only available for the transform modes:
- `Move`,
- `Rotate`,
- `Scale`,
- `Vert Slide` and
- `Edge Slide`.
- The `Snap Base Edit` is enabled while we are transforming and we
press the key `B`
- The `Snap Base Edit` is confirmed when we press any of the keys:
`B`, `LMB`, `Enter`
- During um operation, if no snap target is set for an element in the
scene (Vertex, Edge...), the snap targets to geometry Vertex, Edge,
Face, Center of Edge and Perpendicular of Edge are set automatically.
- Constraint or similar modal features are not available during the
`Snap Base Edit` mode.
- Text input is not available during the `Snap Base Edit` mode.
- A prone snap base point is indicated with an small cursor drawing.
Pull Request: https://projects.blender.org/blender/blender/pulls/104443
2023-06-03 04:18:49 +02:00
|
|
|
|
|
|
|
|
extern TransModeInfo TransMode_snapsource;
|
2023-07-13 17:59:52 +02:00
|
|
|
void transform_mode_snap_source_init(TransInfo *t, wmOperator *op);
|
Transform: new feature to edit the 'Snap Base'
This commit implements a new modifier key (`B`) for the transform
operators.
This new key allows changing the 'Snap Base' of a transform by snapping
it to a defined point in the scene.
Ref #66424
# Implementation Details
- This feature is only available in the 3D View.
- This feature is only available for the transform modes:
- `Move`,
- `Rotate`,
- `Scale`,
- `Vert Slide` and
- `Edge Slide`.
- The `Snap Base Edit` is enabled while we are transforming and we
press the key `B`
- The `Snap Base Edit` is confirmed when we press any of the keys:
`B`, `LMB`, `Enter`
- During um operation, if no snap target is set for an element in the
scene (Vertex, Edge...), the snap targets to geometry Vertex, Edge,
Face, Center of Edge and Perpendicular of Edge are set automatically.
- Constraint or similar modal features are not available during the
`Snap Base Edit` mode.
- Text input is not available during the `Snap Base Edit` mode.
- A prone snap base point is indicated with an small cursor drawing.
Pull Request: https://projects.blender.org/blender/blender/pulls/104443
2023-06-03 04:18:49 +02:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_tilt.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_tilt;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_timescale.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_timescale;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_timeslide.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_timeslide;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_timetranslate.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_timetranslate;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_tosphere.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_tosphere;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_trackball.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_trackball;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_translate.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_translate;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `transform_mode_vert_slide.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
extern TransModeInfo TransMode_vertslide;
|
2022-08-26 13:17:30 -03:00
|
|
|
void transform_mode_vert_slide_reproject_input(TransInfo *t);
|