2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2001-2002 NaN Holding BV. All rights reserved. */
|
2020-02-14 08:42:17 -03:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup edtransform
|
|
|
|
|
* \brief transform modes used by different operators.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
struct AnimData;
|
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;
|
2020-02-14 08:42:17 -03:00
|
|
|
|
2020-02-15 18:43:58 -03:00
|
|
|
/* header of TransDataEdgeSlideVert, TransDataEdgeSlideEdge */
|
|
|
|
|
typedef struct TransDataGenericSlideVert {
|
|
|
|
|
struct BMVert *v;
|
|
|
|
|
struct LinkNode **cd_loop_groups;
|
|
|
|
|
float co_orig_3d[3];
|
|
|
|
|
} TransDataGenericSlideVert;
|
|
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
/* transform_mode.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
Refactor: Snap-related. Clarified attribute names and refactored #defines into enums
The transformation snapping code contains a bunch of `#define`s, some ambiguously or incorrectly named attributes. This patch contains refactored code to improve this. This patch does (should) not change functionality of snapping.
Clarified ambiguously / incorrectly named attributes.
- "Target" is used to refer to the part of the source that is to be snapped (Active, Median, Center, Closest), but several other areas of Blender use the term "target" to refer to the thing being snapped to and "source" to refer to the thing getting snapped. Moreover, the implications of the previous terms do not match the descriptions. For example: `SCE_SNAP_TARGET_CENTER` does not snap the grabbed geometry to the center of the target, but instead "Snap transforamtion center onto target".
- "Select" refers to the condition for an object to be a possible target for snapping.
- `SCE_SNAP_MODE_FACE` is renamed to `SCE_SNAP_MODE_FACE_RAYCAST` to better describe its affect and to make way for other face snapping methods (ex: nearest).
Refactored related `#define` into `enum`s. In particular, constants relating to...
- `ToolSettings.snap_flag` are now in `enum eSnapFlag`
- `ToolSettings.snap_mode` are now in `enum eSnapMode`
- `ToolSettings.snap_source` (was `snap_target`) are now in `enum eSnapSourceSelect`
- `ToolSettings.snap_flag` (`SCE_SNAP_NO_SELF`) and `TransSnap.target_select` are now in `enum eSnapTargetSelect`
As the terms became more consistent and the constants were packed together into meaningful enumerations, some of the attribute names seemed ambiguous. For example, it is unclear whether `SnapObjectParams.snap_select` referred to the target or the source. This patch also adds a small amount of clarity.
This patch also swaps out generic types (ex: `char`, `short`, `ushort`) and unclear hard coded numbers (ex: `0`) used with snap-related enumerations with the actual `enum`s and values.
Note: I did leave myself some comments to follow-up with further refactoring. Specifically, using "target" and "source" consistently will mean the Python API will need to change (ex: `ToolSettings.snap_target` is not `ToolSettings.snap_source`). If the API is going to change, it would be good to make sure that the used terms are descriptive enough. For example, `bpy.ops.transform.translate` uses a `snap` argument to determine if snapping should be enabled while transforming. Perhaps `use_snap` might be an improvement that's more consistent with other conventions.
This patch is (mostly) a subset of D14591, as suggested by @mano-wii.
Task T69342 proposes to separate the `Absolute Grid Snap` option out from `Increment` snapping method into its own method. Also, there might be reason to create additional snapping methods or options. (Indeed, D14591 heads in this direction). This patch can work along with these suggestions, as this patch is trying to clarify the snapping code and to prompt more work in this area.
Reviewed By: mano-wii
Differential Revision: https://developer.blender.org/D15037
2022-06-06 10:28:14 -04:00
|
|
|
eTfmMode transform_mode_really_used(struct 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]);
|
2021-06-29 20:13:55 +10:00
|
|
|
void constraintTransLim(const TransInfo *t, TransData *td);
|
|
|
|
|
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]);
|
2022-01-07 11:38:08 +11:00
|
|
|
void transform_mode_init(TransInfo *t, struct 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
|
|
|
|
|
|
|
|
/* transform_mode_align.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initAlign(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_baketime.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initBakeTime(TransInfo *t);
|
|
|
|
|
|
2020-02-14 11:57:56 -03:00
|
|
|
/* transform_mode_bbone_resize.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 11:57:56 -03:00
|
|
|
void initBoneSize(TransInfo *t);
|
|
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
/* transform_mode_bend.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initBend(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_boneenvelope.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initBoneEnvelope(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_boneroll.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initBoneRoll(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_curveshrinkfatten.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initCurveShrinkFatten(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_edge_bevelweight.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initBevelWeight(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_edge_crease.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
Subdivision: add support for vertex creasing
This adds vertex creasing support for OpenSubDiv for modeling, rendering,
Alembic and USD I/O.
For modeling, vertex creasing follows the edge creasing implementation with an
operator accessible through the Vertex menu in Edit Mode, and some parameter in
the properties panel. The option in the Subsurf and Multires to use edge
creasing also affects vertex creasing.
The vertex crease data is stored as a CustomData layer, unlike edge creases
which for now are stored in `MEdge`, but will in the future also be moved to
a `CustomData` layer. See comments for details on the difference in behavior
for the `CD_CREASE` layer between egdes and vertices.
For Cycles this adds sockets on the Mesh node to hold data about which vertices
are creased (one socket for the indices, one for the weigths).
Viewport rendering of vertex creasing reuses the same color scheme as for edges
and creased vertices are drawn bigger than uncreased vertices.
For Alembic and USD, vertex crease support follows the edge crease
implementation, they are always read, but only exported if a `Subsurf` modifier
is present on the Mesh.
Reviewed By: brecht, fclem, sergey, sybren, campbellbarton
Differential Revision: https://developer.blender.org/D10145
2022-01-20 12:20:30 +01:00
|
|
|
void initEgdeCrease(TransInfo *t);
|
|
|
|
|
void initVertCrease(TransInfo *t);
|
2020-02-14 08:42:17 -03:00
|
|
|
|
|
|
|
|
/* transform_mode_edge_rotate_normal.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initNormalRotation(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_edge_seq_slide.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initSeqSlide(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_edge_slide.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void drawEdgeSlide(TransInfo *t);
|
|
|
|
|
void initEdgeSlide_ex(
|
|
|
|
|
TransInfo *t, bool use_double_side, bool use_even, bool flipped, bool use_clamp);
|
|
|
|
|
void initEdgeSlide(TransInfo *t);
|
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
|
|
|
|
|
|
|
|
/* transform_mode_gpopacity.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initGPOpacity(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_gpshrinkfatten.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initGPShrinkFatten(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_maskshrinkfatten.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initMaskShrinkFatten(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_mirror.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initMirror(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_push_pull.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initPushPull(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_resize.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2021-10-08 12:09:27 +02:00
|
|
|
void initResize(TransInfo *t, float mouse_dir_constraint[3]);
|
2020-02-14 08:42:17 -03:00
|
|
|
|
|
|
|
|
/* transform_mode_rotate.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initRotation(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_shear.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initShear(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_shrink_fatten.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initShrinkFatten(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_skin_resize.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initSkinResize(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_tilt.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initTilt(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_timescale.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initTimeScale(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_timeslide.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initTimeSlide(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_timetranslate.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initTimeTranslate(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_tosphere.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initToSphere(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_trackball.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initTrackball(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_translate.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void initTranslation(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* transform_mode_vert_slide.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-14 08:42:17 -03:00
|
|
|
void drawVertSlide(TransInfo *t);
|
|
|
|
|
void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp);
|
|
|
|
|
void initVertSlide(TransInfo *t);
|
2022-08-26 13:17:30 -03:00
|
|
|
void transform_mode_vert_slide_reproject_input(TransInfo *t);
|