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 */
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edtransform
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2023-07-25 10:53:08 -03:00
|
|
|
#include "BLI_math_vector_types.hh"
|
|
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_numinput.hh"
|
|
|
|
|
#include "ED_transform.hh"
|
|
|
|
|
#include "ED_view3d.hh"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-12-01 18:26:18 +00:00
|
|
|
#include "DNA_listBase.h"
|
2020-06-07 18:36:01 -03:00
|
|
|
#include "DNA_object_enums.h"
|
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
|
|
|
#include "DNA_scene_types.h"
|
2009-12-01 18:26:18 +00:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph.hh"
|
2018-02-06 16:34:11 +11:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
#include "transform_data.hh"
|
2022-10-11 18:01:08 -05:00
|
|
|
|
2020-11-06 10:29:01 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Types/
|
|
|
|
|
* \{ */
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2019-01-28 21:08:24 +11:00
|
|
|
struct ARegion;
|
2018-01-18 15:58:02 +01:00
|
|
|
struct Depsgraph;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
struct NumInput;
|
|
|
|
|
struct Object;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct RNG;
|
|
|
|
|
struct ReportList;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
struct Scene;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct ScrArea;
|
|
|
|
|
struct SnapObjectContext;
|
2022-07-21 23:44:39 -03:00
|
|
|
struct TransConvertTypeInfo;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct TransDataContainer;
|
|
|
|
|
struct TransInfo;
|
2023-07-13 17:59:52 +02:00
|
|
|
struct TransModeInfo;
|
|
|
|
|
struct TransSeqSnapData;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct TransSnap;
|
2017-11-22 10:52:39 -02:00
|
|
|
struct ViewLayer;
|
2023-05-19 23:45:27 +02:00
|
|
|
struct ViewOpsData;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
struct bContext;
|
|
|
|
|
struct wmEvent;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct wmKeyConfig;
|
|
|
|
|
struct wmKeyMap;
|
2023-07-13 17:59:52 +02:00
|
|
|
struct wmMsgBus;
|
2020-12-16 16:19:04 +11:00
|
|
|
struct wmOperator;
|
2009-02-16 03:01:56 +00:00
|
|
|
struct wmTimer;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2021-02-03 19:25:16 -03:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Enums and Flags
|
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
|
|
/** #TransInfo.options */
|
2023-07-13 17:59:52 +02:00
|
|
|
enum eTContext {
|
2021-02-03 19:25:16 -03:00
|
|
|
CTX_NONE = 0,
|
2021-02-05 11:56:43 -03:00
|
|
|
|
|
|
|
|
/* These are similar to TransInfo::data_type. */
|
|
|
|
|
CTX_CAMERA = (1 << 0),
|
|
|
|
|
CTX_CURSOR = (1 << 1),
|
|
|
|
|
CTX_EDGE_DATA = (1 << 2),
|
|
|
|
|
CTX_GPENCIL_STROKES = (1 << 3),
|
|
|
|
|
CTX_MASK = (1 << 4),
|
|
|
|
|
CTX_MOVIECLIP = (1 << 5),
|
|
|
|
|
CTX_OBJECT = (1 << 6),
|
|
|
|
|
CTX_PAINT_CURVE = (1 << 7),
|
|
|
|
|
CTX_POSE_BONE = (1 << 8),
|
|
|
|
|
CTX_TEXTURE_SPACE = (1 << 9),
|
2021-09-21 09:38:30 +02:00
|
|
|
CTX_SEQUENCER_IMAGE = (1 << 10),
|
2021-02-05 11:56:43 -03:00
|
|
|
|
2021-09-21 09:38:30 +02:00
|
|
|
CTX_NO_PET = (1 << 11),
|
|
|
|
|
CTX_AUTOCONFIRM = (1 << 12),
|
2021-02-03 19:25:16 -03:00
|
|
|
/** When transforming object's, adjust the object data so it stays in the same place. */
|
2021-09-21 09:38:30 +02:00
|
|
|
CTX_OBMODE_XFORM_OBDATA = (1 << 13),
|
2021-02-03 19:25:16 -03:00
|
|
|
/** Transform object parents without moving their children. */
|
2021-09-21 09:38:30 +02:00
|
|
|
CTX_OBMODE_XFORM_SKIP_CHILDREN = (1 << 14),
|
2021-08-24 17:45:40 +01:00
|
|
|
/** Enable edge scrolling in 2D views */
|
2021-09-21 09:38:30 +02:00
|
|
|
CTX_VIEW2D_EDGE_PAN = (1 << 15),
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
|
|
|
|
ENUM_OPERATORS(eTContext, CTX_VIEW2D_EDGE_PAN)
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** #TransInfo.flag */
|
2023-07-13 17:59:52 +02:00
|
|
|
enum eTFlag {
|
2021-02-03 19:25:16 -03:00
|
|
|
/** \note We could remove 'T_EDIT' and use 'obedit_type', for now ensure they're in sync. */
|
2021-02-05 11:56:43 -03:00
|
|
|
T_EDIT = 1 << 0,
|
2021-02-03 19:25:16 -03:00
|
|
|
/** Transform points, having no rotation/scale. */
|
2021-02-05 11:56:43 -03:00
|
|
|
T_POINTS = 1 << 1,
|
2021-02-03 19:25:16 -03:00
|
|
|
/** restrictions flags */
|
2021-02-05 11:56:43 -03:00
|
|
|
T_NO_CONSTRAINT = 1 << 2,
|
|
|
|
|
T_NULL_ONE = 1 << 3,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
2021-04-24 11:34:02 -03:00
|
|
|
T_PROP_EDIT = 1 << 4,
|
|
|
|
|
T_PROP_CONNECTED = 1 << 5,
|
|
|
|
|
T_PROP_PROJECTED = 1 << 6,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
2021-04-24 11:34:02 -03:00
|
|
|
T_V3D_ALIGN = 1 << 7,
|
2021-02-03 19:25:16 -03:00
|
|
|
/** For 2D views such as UV or f-curve. */
|
2021-04-24 11:34:02 -03:00
|
|
|
T_2D_EDIT = 1 << 8,
|
|
|
|
|
T_CLIP_UV = 1 << 9,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** Auto-IK is on. */
|
2021-04-24 11:34:02 -03:00
|
|
|
T_AUTOIK = 1 << 10,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** Don't use mirror even if the data-block option is set. */
|
2021-04-24 11:34:02 -03:00
|
|
|
T_NO_MIRROR = 1 << 11,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** To indicate that the value set in the `value` parameter is the final
|
|
|
|
|
* value of the transformation, modified only by the constrain. */
|
2021-04-24 11:34:02 -03:00
|
|
|
T_INPUT_IS_VALUES_FINAL = 1 << 12,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** To specify if we save back settings at the end. */
|
2021-04-24 11:34:02 -03:00
|
|
|
T_MODAL = 1 << 13,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** No re-topology (projection). */
|
2021-04-24 11:34:02 -03:00
|
|
|
T_NO_PROJECT = 1 << 14,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
2021-04-24 11:34:02 -03:00
|
|
|
T_RELEASE_CONFIRM = 1 << 15,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** Alternative transformation. used to add offset to tracking markers. */
|
2021-04-24 11:34:02 -03:00
|
|
|
T_ALT_TRANSFORM = 1 << 16,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** #TransInfo.center has been set, don't change it. */
|
2021-04-24 11:34:02 -03:00
|
|
|
T_OVERRIDE_CENTER = 1 << 17,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
2021-04-24 11:34:02 -03:00
|
|
|
T_MODAL_CURSOR_SET = 1 << 18,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
2021-04-24 11:34:02 -03:00
|
|
|
T_CLNOR_REBUILD = 1 << 19,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** Merges unselected into selected after transforming (runs after transforming). */
|
2021-04-24 11:34:02 -03:00
|
|
|
T_AUTOMERGE = 1 << 20,
|
2021-02-03 19:25:16 -03:00
|
|
|
/** Runs auto-merge & splits. */
|
2021-04-24 11:34:02 -03:00
|
|
|
T_AUTOSPLIT = 1 << 21,
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2022-03-09 08:36:36 +11:00
|
|
|
/** Use drag-start position of the event, otherwise use the cursor coordinates (unmodified). */
|
2022-04-25 12:35:43 -03:00
|
|
|
T_EVENT_DRAG_START = 1 << 22,
|
2022-03-09 08:36:36 +11:00
|
|
|
|
2021-06-16 18:17:07 +01:00
|
|
|
/** No cursor wrapping on region bounds */
|
|
|
|
|
T_NO_CURSOR_WRAP = 1 << 23,
|
2023-01-26 07:54:04 -03:00
|
|
|
|
|
|
|
|
/** Do not display Xform gizmo even though it is available. */
|
|
|
|
|
T_NO_GIZMO = 1 << 24,
|
2023-06-09 14:12:15 +02:00
|
|
|
|
|
|
|
|
T_DRAW_SNAP_SOURCE = 1 << 25,
|
2023-09-11 14:43:35 +02:00
|
|
|
|
|
|
|
|
/** Special flag for when the transform code is called after keys have been duplicated. */
|
|
|
|
|
T_DUPLICATED_KEYFRAMES = 1 << 26,
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2023-09-11 14:43:35 +02:00
|
|
|
ENUM_OPERATORS(eTFlag, T_DUPLICATED_KEYFRAMES);
|
2021-02-03 19:25:16 -03:00
|
|
|
|
2022-04-25 12:35:43 -03:00
|
|
|
#define T_ALL_RESTRICTIONS (T_NO_CONSTRAINT | T_NULL_ONE)
|
|
|
|
|
#define T_PROP_EDIT_ALL (T_PROP_EDIT | T_PROP_CONNECTED | T_PROP_PROJECTED)
|
|
|
|
|
|
2021-02-03 19:25:16 -03:00
|
|
|
/** #TransInfo.modifiers */
|
2023-07-13 17:59:52 +02:00
|
|
|
enum eTModifier {
|
2021-05-24 11:35:33 -03:00
|
|
|
MOD_CONSTRAINT_SELECT_AXIS = 1 << 0,
|
2021-02-03 19:25:16 -03:00
|
|
|
MOD_PRECISION = 1 << 1,
|
|
|
|
|
MOD_SNAP = 1 << 2,
|
|
|
|
|
MOD_SNAP_INVERT = 1 << 3,
|
2021-11-18 14:19:59 -03:00
|
|
|
MOD_CONSTRAINT_SELECT_PLANE = 1 << 4,
|
2022-12-15 14:03:28 -06:00
|
|
|
MOD_NODE_ATTACH = 1 << 5,
|
2023-02-06 11:04:07 -03:00
|
|
|
MOD_SNAP_FORCED = 1 << 6,
|
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
|
|
|
MOD_EDIT_SNAP_SOURCE = 1 << 7,
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2022-12-15 14:03:28 -06:00
|
|
|
ENUM_OPERATORS(eTModifier, MOD_NODE_ATTACH)
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** #TransSnap.status */
|
2023-07-13 17:59:52 +02:00
|
|
|
enum eTSnap {
|
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
|
|
|
SNAP_RESETTED = 0,
|
2023-02-06 11:04:07 -03:00
|
|
|
SNAP_SOURCE_FOUND = 1 << 0,
|
2021-02-05 11:01:30 -03:00
|
|
|
/* Special flag for snap to grid. */
|
2023-02-06 11:04:07 -03:00
|
|
|
SNAP_TARGET_GRID_FOUND = 1 << 1,
|
|
|
|
|
SNAP_TARGET_FOUND = 1 << 2,
|
|
|
|
|
SNAP_MULTI_POINTS = 1 << 3,
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2023-01-12 10:16:25 -03:00
|
|
|
ENUM_OPERATORS(eTSnap, SNAP_MULTI_POINTS)
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** #TransCon.mode, #TransInfo.con.mode */
|
2023-07-13 17:59:52 +02:00
|
|
|
enum eTConstraint {
|
2021-02-03 19:25:16 -03:00
|
|
|
/** When set constraints are in use. */
|
|
|
|
|
CON_APPLY = 1 << 0,
|
|
|
|
|
/** These are only used for modal execution. */
|
|
|
|
|
CON_AXIS0 = 1 << 1,
|
|
|
|
|
CON_AXIS1 = 1 << 2,
|
|
|
|
|
CON_AXIS2 = 1 << 3,
|
|
|
|
|
CON_SELECT = 1 << 4,
|
|
|
|
|
/** Does not reorient vector to face viewport when on. */
|
|
|
|
|
CON_NOFLIP = 1 << 5,
|
|
|
|
|
CON_USER = 1 << 6,
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
|
|
|
|
ENUM_OPERATORS(eTConstraint, CON_USER)
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** #TransInfo.state */
|
2023-07-13 17:59:52 +02:00
|
|
|
enum eTState {
|
2021-02-03 19:25:16 -03:00
|
|
|
TRANS_STARTING = 0,
|
|
|
|
|
TRANS_RUNNING = 1,
|
|
|
|
|
TRANS_CONFIRM = 2,
|
|
|
|
|
TRANS_CANCEL = 3,
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2021-02-03 19:25:16 -03:00
|
|
|
|
2020-11-06 10:29:01 +11:00
|
|
|
/** #TransInfo.redraw */
|
2023-07-13 17:59:52 +02:00
|
|
|
enum eRedrawFlag {
|
2013-10-23 06:48:36 +00:00
|
|
|
TREDRAW_NOTHING = 0,
|
2022-03-28 13:54:59 -03:00
|
|
|
TREDRAW_SOFT = (1 << 0),
|
|
|
|
|
TREDRAW_HARD = (1 << 1) | TREDRAW_SOFT,
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2022-11-17 17:13:38 +01:00
|
|
|
ENUM_OPERATORS(eRedrawFlag, TREDRAW_HARD)
|
2013-10-23 06:48:36 +00:00
|
|
|
|
2021-02-03 19:25:16 -03:00
|
|
|
/** #TransInfo.helpline */
|
2023-07-13 17:59:52 +02:00
|
|
|
enum eTHelpline {
|
2021-02-03 19:25:16 -03:00
|
|
|
HLP_NONE = 0,
|
|
|
|
|
HLP_SPRING = 1,
|
|
|
|
|
HLP_ANGLE = 2,
|
|
|
|
|
HLP_HARROW = 3,
|
|
|
|
|
HLP_VARROW = 4,
|
|
|
|
|
HLP_CARROW = 5,
|
|
|
|
|
HLP_TRACKBALL = 6,
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2021-02-03 19:25:16 -03:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
enum eTOType {
|
2023-02-11 15:20:38 -03:00
|
|
|
O_DEFAULT = 0,
|
|
|
|
|
O_SCENE,
|
|
|
|
|
O_SET,
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2023-02-11 15:20:38 -03:00
|
|
|
|
2021-02-03 19:25:16 -03:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Keymap Modal Items
|
|
|
|
|
*
|
|
|
|
|
* \note these values are saved in key-map files, do not change then but just add new ones.
|
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
TFM_MODAL_CANCEL = 1,
|
|
|
|
|
TFM_MODAL_CONFIRM = 2,
|
|
|
|
|
TFM_MODAL_TRANSLATE = 3,
|
|
|
|
|
TFM_MODAL_ROTATE = 4,
|
|
|
|
|
TFM_MODAL_RESIZE = 5,
|
|
|
|
|
TFM_MODAL_SNAP_INV_ON = 6,
|
|
|
|
|
TFM_MODAL_SNAP_INV_OFF = 7,
|
|
|
|
|
TFM_MODAL_SNAP_TOGGLE = 8,
|
|
|
|
|
TFM_MODAL_AXIS_X = 9,
|
|
|
|
|
TFM_MODAL_AXIS_Y = 10,
|
|
|
|
|
TFM_MODAL_AXIS_Z = 11,
|
|
|
|
|
TFM_MODAL_PLANE_X = 12,
|
|
|
|
|
TFM_MODAL_PLANE_Y = 13,
|
|
|
|
|
TFM_MODAL_PLANE_Z = 14,
|
|
|
|
|
TFM_MODAL_CONS_OFF = 15,
|
|
|
|
|
TFM_MODAL_ADD_SNAP = 16,
|
|
|
|
|
TFM_MODAL_REMOVE_SNAP = 17,
|
|
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
/* 18 and 19 used by number-input, defined in `ED_numinput.hh`. */
|
2021-02-03 19:25:16 -03:00
|
|
|
// NUM_MODAL_INCREMENT_UP = 18,
|
|
|
|
|
// NUM_MODAL_INCREMENT_DOWN = 19,
|
|
|
|
|
|
|
|
|
|
TFM_MODAL_PROPSIZE_UP = 20,
|
|
|
|
|
TFM_MODAL_PROPSIZE_DOWN = 21,
|
|
|
|
|
TFM_MODAL_AUTOIK_LEN_INC = 22,
|
|
|
|
|
TFM_MODAL_AUTOIK_LEN_DEC = 23,
|
|
|
|
|
|
2022-12-15 14:03:28 -06:00
|
|
|
TFM_MODAL_NODE_ATTACH_ON = 24,
|
|
|
|
|
TFM_MODAL_NODE_ATTACH_OFF = 25,
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** For analog input, like track-pad. */
|
|
|
|
|
TFM_MODAL_PROPSIZE = 26,
|
|
|
|
|
/** Node editor insert offset (also called auto-offset) direction toggle. */
|
|
|
|
|
TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27,
|
|
|
|
|
|
|
|
|
|
TFM_MODAL_AUTOCONSTRAINT = 28,
|
|
|
|
|
TFM_MODAL_AUTOCONSTRAINTPLANE = 29,
|
2021-02-09 12:28:51 -03:00
|
|
|
|
|
|
|
|
TFM_MODAL_PRECISION = 30,
|
2022-12-22 18:41:44 -03:00
|
|
|
|
|
|
|
|
TFM_MODAL_VERT_EDGE_SLIDE = 31,
|
|
|
|
|
TFM_MODAL_TRACKBALL = 32,
|
2023-03-27 14:38:47 -03:00
|
|
|
TFM_MODAL_ROTATE_NORMALS = 33,
|
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
|
|
|
|
|
|
|
|
TFM_MODAL_EDIT_SNAP_SOURCE_ON = 34,
|
|
|
|
|
TFM_MODAL_EDIT_SNAP_SOURCE_OFF = 35,
|
2021-02-03 19:25:16 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
2021-12-14 15:49:31 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Transform Types
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
struct TransSnapPoint {
|
|
|
|
|
TransSnapPoint *next, *prev;
|
2009-12-01 18:26:18 +00:00
|
|
|
float co[3];
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2009-12-01 18:26:18 +00:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
struct TransSnap {
|
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
|
|
|
/* Snapping options stored as flags */
|
|
|
|
|
eSnapFlag flag;
|
|
|
|
|
/* Method(s) used for snapping source to target */
|
|
|
|
|
eSnapMode mode;
|
|
|
|
|
/* Part of source to snap to target */
|
2023-01-12 10:16:25 -03:00
|
|
|
eSnapSourceOP source_operation;
|
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
|
|
|
/* Determines which objects are possible target */
|
2023-01-12 10:16:25 -03:00
|
|
|
eSnapTargetOP target_operation;
|
Transform Snap: nearest face snap mode, snapping options, refactoring.
This commit adds a new face nearest snapping mode, adds new snapping
options, and (lightly) refactors code around snapping.
The new face nearest snapping mode will snap transformed geometry to the
nearest surface in world space. In contrast, the original face snapping
mode uses projection (raycasting) to snap source to target geometry.
Face snapping therefore only works with what is visible, while nearest
face snapping can snap geometry to occluded parts of the scene. This new
mode is critical for retopology work, where some of the target mesh
might be occluded (ex: sliding an edge loop that wraps around the
backside of target mesh).
The nearest face snapping mode has two options: "Snap to Same Target"
and "Face Nearest Steps". When the Snap to Same Object option is
enabled, the selected source geometry will stay near the target that it
is nearest before editing started, which prevents the source geometry
from snapping to other targets. The Face Nearest Steps divides the
overall transformation for each vertex into n smaller transformations,
then applies those n transformations with surface snapping interlacing
each step. This steps option handles transformations that cross U-shaped
targets better.
The new snapping options allow the artist to better control which target
objects (objects to which the edited geometry is snapped) are considered
when snapping. In particular, the only option for filtering target
objects was a "Project onto Self", which allowed the currently edited
mesh to be considered as a target. Now, the artist can choose any
combination of the following to be considered as a target: the active
object, any edited object that isn't active (see note below), any non-
edited object. Additionally, the artist has another snapping option to
exclude objects that are not selectable as potential targets.
The Snapping Options dropdown has been lightly reorganized to allow for
the additional options.
Included in this patch:
- Snap target selection is more controllable for artist with additional
snapping options.
- Renamed a few of the snap-related functions to better reflect what
they actually do now. For example, `applySnapping` implies that this
handles the snapping, while `applyProject` implies something entirely
different is done there. However, better names would be
`applySnappingAsGroup` and `applySnappingIndividual`, respectively,
where `applySnappingIndividual` previously only does Face snapping.
- Added an initial coordinate parameter to snapping functions so that
the nearest target before transforming can be determined(for "Snap to
Same Object"), and so the transformation can be broken into smaller
steps (for "Face Nearest Steps").
- Separated the BVH Tree getter code from mesh/edit mesh to its own
function to reduce code duplication.
- Added icon for nearest face snapping.
- The original "Project onto Self" was actually not correct! This option
should be called "Project onto Active" instead, but that only matters
when editing multiple meshes at the same time. This patch makes this
change in the UI.
Reviewed By: Campbell Barton, Germano Cavalcante
Differential Revision: https://developer.blender.org/D14591
2022-06-29 20:52:00 -04:00
|
|
|
short face_nearest_steps;
|
2021-02-03 19:25:16 -03:00
|
|
|
eTSnap status;
|
2019-08-23 15:20:25 -03:00
|
|
|
/* Snapped Element Type (currently for objects only). */
|
2023-09-27 16:25:55 -03:00
|
|
|
eSnapMode source_type;
|
2023-06-23 15:36:57 -03:00
|
|
|
eSnapMode target_type;
|
2019-01-08 10:28:20 +11:00
|
|
|
/** snapping from this point (in global-space). */
|
2023-01-12 10:16:25 -03:00
|
|
|
float snap_source[3];
|
2021-11-12 15:53:36 -03:00
|
|
|
/** to this point (in global-space). */
|
2023-01-12 10:16:25 -03:00
|
|
|
float snap_target[3];
|
|
|
|
|
float snap_target_grid[3];
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
float snapNormal[3];
|
2012-06-29 14:34:46 +00:00
|
|
|
char snapNodeBorder;
|
2009-12-01 18:26:18 +00:00
|
|
|
ListBase points;
|
2011-12-26 20:23:07 +00:00
|
|
|
TransSnapPoint *selectedPoint;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
double last;
|
2023-07-13 17:59:52 +02:00
|
|
|
void (*snap_target_fn)(TransInfo *, float *);
|
|
|
|
|
void (*snap_source_fn)(TransInfo *);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-04-21 11:29:32 +10:00
|
|
|
/**
|
|
|
|
|
* Re-usable snap context data.
|
|
|
|
|
*/
|
2021-06-29 20:12:19 +02:00
|
|
|
union {
|
2023-07-13 17:59:52 +02:00
|
|
|
SnapObjectContext *object_context;
|
|
|
|
|
TransSeqSnapData *seq_context;
|
2021-06-29 20:12:19 +02:00
|
|
|
};
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
struct TransCon {
|
2019-03-01 10:45:22 +11:00
|
|
|
/** Description of the constraint for header_print. */
|
2019-01-08 10:28:20 +11:00
|
|
|
char text[50];
|
2019-03-01 10:45:22 +11:00
|
|
|
/** Projection constraint matrix (same as #imtx with some axis == 0). */
|
2019-01-08 10:28:20 +11:00
|
|
|
float pmtx[3][3];
|
2019-03-01 10:45:22 +11:00
|
|
|
/** Mode flags of the constraint. */
|
2021-02-03 19:25:16 -03:00
|
|
|
eTConstraint mode;
|
2023-07-13 17:59:52 +02:00
|
|
|
void (*drawExtra)(TransInfo *t);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-03 23:08:40 +10:00
|
|
|
/* NOTE: if 'tc' is NULL, 'td' must also be NULL.
|
2019-01-08 10:28:20 +11:00
|
|
|
* For constraints that needs to draw differently from the other
|
|
|
|
|
* uses this instead of the generic draw function. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-08 10:28:20 +11:00
|
|
|
/** Apply function pointer for linear vectorial transformation
|
|
|
|
|
* The last three parameters are pointers to the in/out/printable vectors. */
|
2023-07-13 17:59:52 +02:00
|
|
|
void (*applyVec)(const TransInfo *t,
|
|
|
|
|
const TransDataContainer *tc,
|
|
|
|
|
const TransData *td,
|
2018-04-16 16:27:55 +02:00
|
|
|
const float in[3],
|
2021-06-29 20:13:55 +10:00
|
|
|
float r_out[3]);
|
2019-01-08 10:28:20 +11:00
|
|
|
/** Apply function pointer for size transformation. */
|
2023-07-13 17:59:52 +02:00
|
|
|
void (*applySize)(const TransInfo *t,
|
|
|
|
|
const TransDataContainer *tc,
|
|
|
|
|
const TransData *td,
|
2021-06-29 20:13:55 +10:00
|
|
|
float r_smat[3][3]);
|
2019-01-08 10:28:20 +11:00
|
|
|
/** Apply function pointer for rotation transformation */
|
2023-07-13 17:59:52 +02:00
|
|
|
void (*applyRot)(const TransInfo *t,
|
|
|
|
|
const TransDataContainer *tc,
|
|
|
|
|
const TransData *td,
|
2021-06-29 20:13:55 +10:00
|
|
|
float r_axis[3],
|
|
|
|
|
float *r_angle);
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
struct MouseInput {
|
|
|
|
|
void (*apply)(TransInfo *t, MouseInput *mi, const double mval[2], float output[3]);
|
|
|
|
|
void (*post)(TransInfo *t, float values[3]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-08 10:28:20 +11:00
|
|
|
/** Initial mouse position. */
|
2023-07-25 10:53:08 -03:00
|
|
|
blender::float2 imval;
|
|
|
|
|
blender::float2 center;
|
2008-12-29 20:37:54 +00:00
|
|
|
float factor;
|
2022-08-26 13:17:30 -03:00
|
|
|
float precision_factor;
|
|
|
|
|
bool precision;
|
|
|
|
|
|
2019-01-08 10:28:20 +11:00
|
|
|
/** Additional data, if needed by the particular function. */
|
|
|
|
|
void *data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-10-30 17:31:07 +11:00
|
|
|
/**
|
2015-11-07 17:31:28 +11:00
|
|
|
* Use virtual cursor, which takes precision into account
|
2015-10-30 17:31:07 +11:00
|
|
|
* keeping track of the cursors 'virtual' location,
|
|
|
|
|
* to avoid jumping values when its toggled.
|
|
|
|
|
*
|
|
|
|
|
* This works well for scaling drag motion,
|
2020-09-06 01:45:38 +10:00
|
|
|
* but not for rotating around a point (rotation needs its own custom accumulator)
|
2015-10-30 17:31:07 +11:00
|
|
|
*/
|
|
|
|
|
bool use_virtual_mval;
|
|
|
|
|
struct {
|
|
|
|
|
double prev[2];
|
|
|
|
|
double accum[2];
|
|
|
|
|
} virtual_mval;
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2008-12-29 20:37:54 +00:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
struct TransCustomData {
|
2016-02-01 15:15:10 +11:00
|
|
|
void *data;
|
2023-07-13 17:59:52 +02:00
|
|
|
void (*free_cb)(TransInfo *, TransDataContainer *tc, TransCustomData *custom_data);
|
2016-02-01 15:15:10 +11:00
|
|
|
unsigned int use_free : 1;
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2016-02-01 15:15:10 +11:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
/**
|
|
|
|
|
* Rule of thumb for choosing between mode/type:
|
|
|
|
|
* - If transform mode uses the data, assign to `mode`
|
2023-07-31 11:50:54 +10:00
|
|
|
* (typically in `transform.cc`).
|
2018-04-16 16:27:55 +02:00
|
|
|
* - If conversion uses the data as an extension to the #TransData, assign to `type`
|
|
|
|
|
* (typically in transform_conversion.c).
|
|
|
|
|
*/
|
2023-07-13 17:59:52 +02:00
|
|
|
struct TransCustomDataContainer {
|
2021-06-26 21:35:18 +10:00
|
|
|
/** Owned by the mode (grab, scale, bend... ). */
|
2018-04-16 16:27:55 +02:00
|
|
|
union {
|
|
|
|
|
TransCustomData mode, first_elem;
|
|
|
|
|
};
|
|
|
|
|
TransCustomData type;
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2018-04-16 16:27:55 +02:00
|
|
|
#define TRANS_CUSTOM_DATA_ELEM_MAX (sizeof(TransCustomDataContainer) / sizeof(TransCustomData))
|
|
|
|
|
|
2021-03-13 03:12:24 +11:00
|
|
|
/**
|
|
|
|
|
* Container for Transform Data
|
|
|
|
|
*
|
2021-05-21 22:19:46 +10:00
|
|
|
* Used to implement multi-object modes, so each object can have its
|
2021-03-13 03:12:24 +11:00
|
|
|
* own data array as well as object matrix, local center etc.
|
|
|
|
|
*
|
|
|
|
|
* Anything that can't be shared between all objects
|
|
|
|
|
* and doesn't make sense to store for every vertex (in the #TransDataContainer.data).
|
|
|
|
|
*
|
|
|
|
|
* \note at some point this could be used to store non object containers
|
2021-05-21 22:19:46 +10:00
|
|
|
* although this only makes sense if each container has its own matrices,
|
2021-03-13 03:12:24 +11:00
|
|
|
* otherwise all elements may as well be stored in one array (#TransDataContainer.data),
|
|
|
|
|
* as is already done for curve-objects, f-curves. etc.
|
|
|
|
|
*/
|
2023-07-13 17:59:52 +02:00
|
|
|
struct TransDataContainer {
|
2018-04-16 16:27:55 +02:00
|
|
|
/** Transformed data (array). */
|
|
|
|
|
TransData *data;
|
|
|
|
|
/** Transformed data extension (array). */
|
|
|
|
|
TransDataExtension *data_ext;
|
|
|
|
|
/** Transformed data for 2d (array). */
|
|
|
|
|
TransData2D *data_2d;
|
2020-06-08 08:23:04 -03:00
|
|
|
/** Transformed data for mirror elements (array). */
|
|
|
|
|
TransDataMirror *data_mirror;
|
|
|
|
|
|
|
|
|
|
/** Total number of transformed data, data_ext, data_2d. */
|
|
|
|
|
int data_len;
|
|
|
|
|
/** Total number of transformed data_mirror. */
|
|
|
|
|
int data_mirror_len;
|
Animation: Add GP layers in regular Dopesheet
Grease Pencil animation channels are now also shown in the Dopesheet
mode of the Dopesheet editor and in the Timeline.
Grease pencil related events are now listened not only by container
`SACTCONT_GPENCIL` (Grease Pencil Dopesheet), but also
`SACTCONT_DOPESHEET` (main Dopesheet), and `SACTCONT_TIMELINE`
(timeline).
A new Animation Filter flag was added: `ANIMFILTER_FCURVESONLY`. For now
this only filters out Grease Pencil Layer channels.
**Implemented:**
- Preview range set: now only considers selected Grease Pencil keyframes
when `onlySel` parameter is true. Not only this allows the operator to
work with grease pencil keyframes in main dopesheet, but it also fixes
the operator in the Grease Pencil dopesheet.
- Translation: allocation (and freeing) of specific memory for
translation of Grease Pencil keyframes.
- Copy/Paste: call to both Fcurve and GPencil operators, to allow for
mixed selection. Errors are only reported when both the FCurve and
GPencil functions fail to paste anything.
- Keyframe Type change and Insert Keyframe: removed some code here to
unify Grease Pencil dopesheet and main dopesheet code.
- Jump, Snap, Mirror, Select all/box/lasso/circle, Select left/right,
Clickselect: account for Grease Pencil channels within the channels
loop, no need for `ANIMFILTER_FCURVESONLY` there.
**Not Implemented:**
- Graph-related operators. The filter `ANIMFILTER_FCURVESONLY` is
naively added to all graph-related operators, meaning more-or-less all
operators that used `ANIMFILTER_CURVE_VISIBLE`.
- Select linked: is for F-curves channel only
- Select more/less: not yet implemented for grease pencil layers.
- Clean Keys, Sample, Extrapolation, Interpolation, Easing, and Handle
type change: work on Fcurve-channels only, so the
`ANIMFILTER_FCURVESONLY` filter is activated
Graying out these operators (when no fcurve keyframe is selected) can be
done with custom poll functions BUT may affect performance. This is NOT
done in this patch.
**Dopesheet Summary Selection:**
The main summary of the dopesheet now also takes into account Grease
Pencil keyframes, using some nasty copy/pasting of code, as explained
[on devtalk](https://devtalk.blender.org/t/gpencil-layers-integration-in-main-dopesheet-selection-issue/24527).
It works, but may be improved, providing some deeper changes.
Reviewed By: mendio, pepeland, sybren
Maniphest Tasks: T97477
Differential Revision: https://developer.blender.org/D15003
2022-06-30 15:16:05 +02:00
|
|
|
/** Total number of transformed gp-frames. */
|
|
|
|
|
int data_gpf_len;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
Object *obedit;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-04 14:41:51 +02:00
|
|
|
float mat[4][4];
|
|
|
|
|
float imat[4][4];
|
|
|
|
|
/** 3x3 copies of matrices above. */
|
|
|
|
|
float mat3[3][3];
|
|
|
|
|
float imat3[3][3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-04 14:41:51 +02:00
|
|
|
/** Normalized 'mat3' */
|
|
|
|
|
float mat3_unit[3][3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
/** if 't->flag & T_POSE', this denotes pose object */
|
2023-07-13 17:59:52 +02:00
|
|
|
Object *poseobj;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
/** Center of transformation (in local-space), Calculated from #TransInfo.center_global. */
|
|
|
|
|
float center_local[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-14 14:59:18 +11:00
|
|
|
/**
|
2020-06-08 08:23:04 -03:00
|
|
|
* Use for cases we care about the active, eg: active vert of active mesh.
|
|
|
|
|
* if set this will _always_ be the first item in the array.
|
2019-01-14 14:59:18 +11:00
|
|
|
*/
|
2020-06-08 08:23:04 -03:00
|
|
|
bool is_active;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Store matrix, this avoids having to have duplicate check all over
|
2022-10-24 14:16:37 +02:00
|
|
|
* Typically: 'obedit->object_to_world' or 'poseobj->object_to_world', but may be used elsewhere
|
|
|
|
|
* too.
|
2020-06-08 08:23:04 -03:00
|
|
|
*/
|
|
|
|
|
bool use_local_mat;
|
|
|
|
|
|
2021-03-21 13:18:20 +11:00
|
|
|
/** Mirror option. */
|
2020-06-08 08:23:04 -03:00
|
|
|
union {
|
|
|
|
|
struct {
|
|
|
|
|
uint use_mirror_axis_x : 1;
|
|
|
|
|
uint use_mirror_axis_y : 1;
|
|
|
|
|
uint use_mirror_axis_z : 1;
|
2019-09-11 13:48:42 -03:00
|
|
|
};
|
2020-06-08 08:23:04 -03:00
|
|
|
/* For easy checking. */
|
|
|
|
|
char use_mirror_axis_any;
|
|
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
TransCustomDataContainer custom;
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2018-04-16 16:27:55 +02:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
struct TransInfo {
|
2018-04-16 16:27:55 +02:00
|
|
|
TransDataContainer *data_container;
|
|
|
|
|
int data_container_len;
|
2020-06-07 18:48:33 -03:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
/** Combine length of all #TransDataContainer.data_len
|
|
|
|
|
* Use to check if nothing is selected or if we have a single selection. */
|
|
|
|
|
int data_len_all;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-03 19:25:16 -03:00
|
|
|
/** TODO: It should be a member of #TransDataContainer. */
|
2023-07-13 17:59:52 +02:00
|
|
|
TransConvertTypeInfo *data_type;
|
2021-02-03 19:25:16 -03:00
|
|
|
|
2023-06-02 14:42:27 +02:00
|
|
|
/** Mode indicator as set for the operator.
|
|
|
|
|
* NOTE: A same `mode_info` can have different `mode`s. */
|
|
|
|
|
eTfmMode mode;
|
2023-07-13 17:59:52 +02:00
|
|
|
TransModeInfo *mode_info;
|
2023-06-02 14:42:27 +02:00
|
|
|
|
2021-02-03 19:25:16 -03:00
|
|
|
/** Current context/options for transform. */
|
|
|
|
|
eTContext options;
|
2019-01-08 10:28:20 +11:00
|
|
|
/** Generic flags for special behaviors. */
|
2021-02-03 19:25:16 -03:00
|
|
|
eTFlag flag;
|
2019-01-08 10:28:20 +11:00
|
|
|
/** Special modifiers, by function, not key. */
|
2021-02-03 19:25:16 -03:00
|
|
|
eTModifier modifiers;
|
2019-01-08 10:28:20 +11:00
|
|
|
/** Current state (running, canceled. */
|
2021-02-03 19:25:16 -03:00
|
|
|
eTState state;
|
|
|
|
|
/** Redraw flag. */
|
|
|
|
|
eRedrawFlag redraw;
|
|
|
|
|
/** Choice of custom cursor with or without a help line from the gizmo to the mouse position. */
|
|
|
|
|
eTHelpline helpline;
|
2022-06-05 23:09:33 +10:00
|
|
|
|
2021-02-03 19:25:16 -03:00
|
|
|
/** Constraint Data. */
|
2019-01-08 10:28:20 +11:00
|
|
|
TransCon con;
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** Snap Data. */
|
2010-03-22 09:30:00 +00:00
|
|
|
TransSnap tsnap;
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** Numerical input. */
|
2019-01-08 10:28:20 +11:00
|
|
|
NumInput num;
|
2021-02-03 19:25:16 -03:00
|
|
|
|
|
|
|
|
/** Mouse input. */
|
2019-01-08 10:28:20 +11:00
|
|
|
MouseInput mouse;
|
2021-02-03 19:25:16 -03:00
|
|
|
|
2019-01-08 10:28:20 +11:00
|
|
|
/** proportional circle radius. */
|
|
|
|
|
float prop_size;
|
|
|
|
|
/** proportional falloff text. */
|
|
|
|
|
char proptext[20];
|
|
|
|
|
/**
|
2023-07-16 15:50:02 +10:00
|
|
|
* Spaces using non 1:1 aspect, (UV's, F-curve, movie-clip... etc).
|
2019-01-08 10:28:20 +11:00
|
|
|
* use for conversion and snapping.
|
|
|
|
|
*/
|
|
|
|
|
float aspect[3];
|
|
|
|
|
/** center of transformation (in global-space) */
|
|
|
|
|
float center_global[3];
|
|
|
|
|
/** center in screen coordinates. */
|
|
|
|
|
float center2d[2];
|
|
|
|
|
/** maximum index on the input vector. */
|
|
|
|
|
short idx_max;
|
|
|
|
|
/** Snapping Gears. */
|
2020-10-08 09:45:45 -03:00
|
|
|
float snap[2];
|
2019-01-08 10:28:20 +11:00
|
|
|
/** Spatial snapping gears(even when rotating, scaling... etc). */
|
2022-10-22 12:00:01 -03:00
|
|
|
float snap_spatial[3];
|
|
|
|
|
/**
|
|
|
|
|
* Precision factor that is multiplied to snap_spatial when precision
|
|
|
|
|
* modifier is enabled for snap to grid or incremental snap.
|
|
|
|
|
*/
|
|
|
|
|
float snap_spatial_precision;
|
2020-09-06 01:45:38 +10:00
|
|
|
/** Mouse side of the current frame, 'L', 'R' or 'B' */
|
2019-01-08 10:28:20 +11:00
|
|
|
char frame_side;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-02-04 16:06:15 +11:00
|
|
|
/** copy from #RegionView3D, prevents feedback. */
|
2019-01-08 10:28:20 +11:00
|
|
|
float viewmat[4][4];
|
|
|
|
|
/** and to make sure we don't have to. */
|
|
|
|
|
float viewinv[4][4];
|
2022-02-04 16:06:15 +11:00
|
|
|
/** Access #RegionView3D from other space types. */
|
2019-01-08 10:28:20 +11:00
|
|
|
float persmat[4][4];
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
float persinv[4][4];
|
|
|
|
|
short persp;
|
|
|
|
|
short around;
|
2020-11-06 10:29:01 +11:00
|
|
|
/** space-type where transforming is. */
|
2019-01-08 10:28:20 +11:00
|
|
|
char spacetype;
|
2021-08-06 11:44:15 -03:00
|
|
|
/** Type of active object being edited. */
|
2019-01-08 10:28:20 +11:00
|
|
|
short obedit_type;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-08 10:28:20 +11:00
|
|
|
/** translation, to show for widget. */
|
|
|
|
|
float vec[3];
|
2020-11-06 10:29:01 +11:00
|
|
|
/** Rotate/re-scale, to show for widget. */
|
2019-01-08 10:28:20 +11:00
|
|
|
float mat[3][3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-08 10:28:20 +11:00
|
|
|
/** orientation matrix of the current space. */
|
|
|
|
|
float spacemtx[3][3];
|
2020-05-20 16:22:10 -03:00
|
|
|
float spacemtx_inv[3][3];
|
2019-01-08 10:28:20 +11:00
|
|
|
/** name of the current space, MAX_NAME. */
|
|
|
|
|
char spacename[64];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
/*************** NEW STUFF *********************/
|
2019-01-08 10:28:20 +11:00
|
|
|
/** event type used to launch transform. */
|
2020-12-04 10:35:26 -03:00
|
|
|
short launch_event;
|
2022-03-02 14:53:15 +11:00
|
|
|
/**
|
|
|
|
|
* Is the actual launch event a drag event?
|
|
|
|
|
* (`launch_event` is set to the corresponding mouse button then.)
|
|
|
|
|
*/
|
|
|
|
|
bool is_launch_event_drag;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-11-26 10:45:28 -03:00
|
|
|
bool is_orient_default_overwrite;
|
2021-05-11 23:40:06 -03:00
|
|
|
|
2018-11-28 10:01:16 +11:00
|
|
|
struct {
|
2020-05-22 12:34:29 -03:00
|
|
|
short type;
|
|
|
|
|
float matrix[3][3];
|
|
|
|
|
} orient[3];
|
2021-05-11 22:40:56 -03:00
|
|
|
|
2023-02-11 15:20:38 -03:00
|
|
|
eTOType orient_curr;
|
2020-05-22 12:34:29 -03:00
|
|
|
|
2021-11-11 21:14:10 +11:00
|
|
|
/**
|
|
|
|
|
* All values from `TransInfo.orient[].type` converted into a flag
|
|
|
|
|
* to allow quickly checking which orientation types are used.
|
|
|
|
|
*/
|
|
|
|
|
int orient_type_mask;
|
|
|
|
|
|
2009-03-06 15:50:15 +00:00
|
|
|
short prop_mode;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-02 01:15:33 -03:00
|
|
|
/** Value taken as input, either through mouse coordinates or entered as a parameter. */
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
float values[4];
|
2019-08-02 01:15:33 -03:00
|
|
|
|
2020-11-06 10:29:01 +11:00
|
|
|
/** Offset applied on top of modal input. */
|
2019-01-08 10:28:20 +11:00
|
|
|
float values_modal_offset[4];
|
2019-08-02 01:15:33 -03:00
|
|
|
|
|
|
|
|
/** Final value of the transformation (displayed in the redo panel).
|
|
|
|
|
* If the operator is executed directly (not modal), this value is usually the
|
|
|
|
|
* value of the input parameter, except when a constrain is entered. */
|
|
|
|
|
float values_final[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-08-27 16:51:53 +12:00
|
|
|
/** Cache safe value for constraints that require iteration or are slow to calculate. */
|
|
|
|
|
float values_inside_constraints[4];
|
|
|
|
|
|
2019-03-01 10:12:26 +11:00
|
|
|
/* Axis members for modes that use an axis separate from the orientation (rotate & shear). */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-01 10:12:26 +11:00
|
|
|
/** Primary axis, rotate only uses this. */
|
2019-02-26 20:22:54 +11:00
|
|
|
int orient_axis;
|
2019-03-01 10:12:26 +11:00
|
|
|
/** Secondary axis, shear uses this. */
|
2019-02-26 20:22:54 +11:00
|
|
|
int orient_axis_ortho;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-08 10:28:20 +11:00
|
|
|
/** remove elements if operator is canceled. */
|
|
|
|
|
bool remove_on_cancel;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
void *view;
|
2019-01-08 10:28:20 +11:00
|
|
|
/** Only valid (non null) during an operator called function. */
|
2023-07-13 17:59:52 +02:00
|
|
|
bContext *context;
|
|
|
|
|
wmMsgBus *mbus;
|
|
|
|
|
ScrArea *area;
|
|
|
|
|
ARegion *region;
|
|
|
|
|
Depsgraph *depsgraph;
|
|
|
|
|
Scene *scene;
|
|
|
|
|
ViewLayer *view_layer;
|
|
|
|
|
ToolSettings *settings;
|
|
|
|
|
wmTimer *animtimer;
|
2020-11-06 10:29:01 +11:00
|
|
|
/** Needed so we can perform a look up for header text. */
|
2023-07-13 17:59:52 +02:00
|
|
|
wmKeyMap *keymap;
|
2019-01-08 10:28:20 +11:00
|
|
|
/** assign from the operator, or can be NULL. */
|
2023-07-13 17:59:52 +02:00
|
|
|
ReportList *reports;
|
2019-01-08 10:28:20 +11:00
|
|
|
/** current mouse position. */
|
2023-08-02 15:00:47 -03:00
|
|
|
blender::float2 mval;
|
2019-01-08 10:28:20 +11:00
|
|
|
/** use for 3d view. */
|
|
|
|
|
float zfac;
|
2010-03-22 09:30:00 +00:00
|
|
|
void *draw_handle_view;
|
|
|
|
|
void *draw_handle_pixel;
|
|
|
|
|
void *draw_handle_cursor;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-12 17:00:07 +02:00
|
|
|
/** Currently only used for random curve of proportional editing. */
|
2023-07-13 17:59:52 +02:00
|
|
|
RNG *rng;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
ViewOpsData *vod;
|
2023-05-19 23:45:27 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
/** Typically for mode settings. */
|
|
|
|
|
TransCustomDataContainer custom;
|
2022-08-15 14:52:02 -07:00
|
|
|
|
|
|
|
|
/* Needed for sculpt transform. */
|
|
|
|
|
const char *undo_name;
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2020-11-06 10:29:01 +11:00
|
|
|
/** \} */
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2020-11-06 10:29:01 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Public Transform API
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
2023-10-19 18:53:16 +11:00
|
|
|
* \note Caller needs to free `t` on a 0 return.
|
2021-12-09 00:55:11 +11:00
|
|
|
* \warning \a event might be NULL (when tweaking from redo panel)
|
|
|
|
|
* \see #saveTransform which writes these values back.
|
|
|
|
|
*/
|
2023-07-13 17:59:52 +02:00
|
|
|
bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* \see #initTransform which reads values from the operator.
|
|
|
|
|
*/
|
2023-07-13 17:59:52 +02:00
|
|
|
void saveTransform(bContext *C, TransInfo *t, wmOperator *op);
|
|
|
|
|
int transformEvent(TransInfo *t, const wmEvent *event);
|
|
|
|
|
void transformApply(bContext *C, TransInfo *t);
|
|
|
|
|
int transformEnd(bContext *C, TransInfo *t);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
|
void setTransformViewMatrices(TransInfo *t);
|
2015-06-26 15:45:09 +10:00
|
|
|
void setTransformViewAspect(TransInfo *t, float r_aspect[3]);
|
2015-10-30 17:31:07 +11:00
|
|
|
void convertViewVec(TransInfo *t, float r_vec[3], double dx, double dy);
|
2022-01-07 11:38:08 +11:00
|
|
|
void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], eV3DProjTest flag);
|
2012-03-12 06:53:47 +00:00
|
|
|
void projectIntView(TransInfo *t, const float vec[3], int adr[2]);
|
2022-01-07 11:38:08 +11:00
|
|
|
void projectFloatViewEx(TransInfo *t, const float vec[3], float adr[2], eV3DProjTest flag);
|
2012-03-12 06:53:47 +00:00
|
|
|
void projectFloatView(TransInfo *t, const float vec[3], float adr[2]);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2014-03-30 11:08:33 +11:00
|
|
|
void applyAspectRatio(TransInfo *t, float vec[2]);
|
|
|
|
|
void removeAspectRatio(TransInfo *t, float vec[2]);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
2023-07-31 11:50:54 +10:00
|
|
|
* Called in `transform_ops.cc`, on each regeneration of key-maps.
|
2021-12-09 00:55:11 +11:00
|
|
|
*/
|
2023-07-13 17:59:52 +02:00
|
|
|
wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf);
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
|
2022-06-05 23:09:33 +10:00
|
|
|
/**
|
|
|
|
|
* Transform a single matrix using the current `t->final_values`.
|
|
|
|
|
*/
|
|
|
|
|
bool transform_apply_matrix(TransInfo *t, float mat[4][4]);
|
|
|
|
|
void transform_final_value_get(const TransInfo *t, float *value, int value_num);
|
|
|
|
|
|
2020-11-06 10:29:01 +11:00
|
|
|
/** \} */
|
2017-04-07 00:35:57 +10:00
|
|
|
|
2020-11-06 10:29:01 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name TransData Creation and General Handling
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2014-11-27 21:37:42 +01:00
|
|
|
bool transdata_check_local_islands(TransInfo *t, short around);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2020-11-06 10:29:01 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Mouse Input
|
|
|
|
|
* \{ */
|
2008-12-29 20:37:54 +00:00
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
enum MouseInputMode {
|
2008-12-29 20:37:54 +00:00
|
|
|
INPUT_NONE,
|
|
|
|
|
INPUT_VECTOR,
|
|
|
|
|
INPUT_SPRING,
|
|
|
|
|
INPUT_SPRING_FLIP,
|
2014-06-03 22:02:02 +06:00
|
|
|
INPUT_SPRING_DELTA,
|
2008-12-29 20:37:54 +00:00
|
|
|
INPUT_ANGLE,
|
2013-10-13 01:09:23 +00:00
|
|
|
INPUT_ANGLE_SPRING,
|
2008-12-29 20:37:54 +00:00
|
|
|
INPUT_TRACKBALL,
|
|
|
|
|
INPUT_HORIZONTAL_RATIO,
|
|
|
|
|
INPUT_HORIZONTAL_ABSOLUTE,
|
|
|
|
|
INPUT_VERTICAL_RATIO,
|
2009-09-21 00:48:36 +00:00
|
|
|
INPUT_VERTICAL_ABSOLUTE,
|
2013-01-31 22:18:37 +00:00
|
|
|
INPUT_CUSTOM_RATIO,
|
2014-06-03 22:02:02 +06:00
|
|
|
INPUT_CUSTOM_RATIO_FLIP,
|
2023-07-13 17:59:52 +02:00
|
|
|
};
|
2008-12-29 20:37:54 +00:00
|
|
|
|
2023-07-25 10:53:08 -03:00
|
|
|
void initMouseInput(TransInfo *t,
|
|
|
|
|
MouseInput *mi,
|
|
|
|
|
const blender::float2 ¢er,
|
|
|
|
|
const blender::float2 &mval,
|
|
|
|
|
bool precision);
|
2008-12-29 20:37:54 +00:00
|
|
|
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode);
|
2023-08-02 15:00:47 -03:00
|
|
|
void applyMouseInput(TransInfo *t, MouseInput *mi, const blender::float2 &mval, float output[3]);
|
2022-08-26 13:17:30 -03:00
|
|
|
void transform_input_update(TransInfo *t, const float fac);
|
2023-05-25 11:34:25 -03:00
|
|
|
void transform_input_virtual_mval_reset(TransInfo *t);
|
2023-07-25 10:53:08 -03:00
|
|
|
void transform_input_reset(TransInfo *t, const blender::float2 &mval);
|
2008-12-29 20:37:54 +00:00
|
|
|
|
2013-01-15 03:35:31 +00:00
|
|
|
void setCustomPoints(TransInfo *t, MouseInput *mi, const int start[2], const int end[2]);
|
2023-07-25 10:53:08 -03:00
|
|
|
void setCustomPointsFromDirection(TransInfo *t, MouseInput *mi, const blender::float2 &dir);
|
2023-07-13 17:59:52 +02:00
|
|
|
void setInputPostFct(MouseInput *mi, void (*post)(TransInfo *t, float values[3]));
|
2009-09-21 00:48:36 +00:00
|
|
|
|
2020-11-06 10:29:01 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Generics
|
|
|
|
|
* \{ */
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Setup internal data, mouse, vectors
|
|
|
|
|
*
|
|
|
|
|
* \note \a op and \a event can be NULL
|
|
|
|
|
*
|
|
|
|
|
* \see #saveTransform does the reverse.
|
|
|
|
|
*/
|
2023-07-13 17:59:52 +02:00
|
|
|
void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Needed for mode switching.
|
|
|
|
|
*/
|
2018-04-26 10:08:41 +02:00
|
|
|
void freeTransCustomDataForMode(TransInfo *t);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Here I would suggest only #TransInfo related issues, like free data & reset vars. Not redraws.
|
|
|
|
|
*/
|
2023-07-13 17:59:52 +02:00
|
|
|
void postTrans(bContext *C, TransInfo *t);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Free data before switching to another mode.
|
|
|
|
|
*/
|
2013-04-24 15:15:01 +00:00
|
|
|
void resetTransModal(TransInfo *t);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
void resetTransRestrictions(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
/* DRAWLINE options flags */
|
|
|
|
|
#define DRAWLIGHT 1
|
|
|
|
|
|
|
|
|
|
void applyTransObjects(TransInfo *t);
|
|
|
|
|
void restoreTransObjects(TransInfo *t);
|
|
|
|
|
|
|
|
|
|
void calculateCenter2D(TransInfo *t);
|
2018-04-16 16:27:55 +02:00
|
|
|
void calculateCenterLocal(TransInfo *t, const float center_global[3]);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2014-05-09 16:52:09 +10:00
|
|
|
void calculateCenter(TransInfo *t);
|
2023-03-29 14:16:31 +11:00
|
|
|
/**
|
|
|
|
|
* Called every time the view changes due to navigation.
|
|
|
|
|
* Adjusts the mouse position relative to the object.
|
|
|
|
|
*/
|
2022-08-26 13:17:30 -03:00
|
|
|
void tranformViewUpdate(TransInfo *t);
|
2014-05-09 16:52:09 +10:00
|
|
|
|
|
|
|
|
/* API functions for getting center points */
|
|
|
|
|
void calculateCenterBound(TransInfo *t, float r_center[3]);
|
|
|
|
|
void calculateCenterMedian(TransInfo *t, float r_center[3]);
|
|
|
|
|
void calculateCenterCursor(TransInfo *t, float r_center[3]);
|
|
|
|
|
void calculateCenterCursor2D(TransInfo *t, float r_center[2]);
|
|
|
|
|
void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2]);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* \param select_only: only get active center from data being transformed.
|
|
|
|
|
*/
|
2014-05-09 16:52:09 +10:00
|
|
|
bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]);
|
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
void calculatePropRatio(TransInfo *t);
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Rotate an element, low level code, ignore protected channels.
|
|
|
|
|
* (use for objects or pose-bones)
|
|
|
|
|
* Similar to #ElementRotation.
|
|
|
|
|
*/
|
2015-07-14 04:27:32 +10:00
|
|
|
void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot);
|
|
|
|
|
|
2023-07-13 17:59:52 +02:00
|
|
|
Object *transform_object_deform_pose_armature_get(const TransInfo *t, Object *ob);
|
2021-02-10 12:27:01 -03:00
|
|
|
|
2018-06-05 23:21:08 +05:30
|
|
|
void freeCustomNormalArray(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data);
|
2018-05-25 22:24:24 +05:30
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/* TODO: move to: `transform_query.c`. */
|
2013-05-01 05:26:10 +00:00
|
|
|
bool checkUseAxisMatrix(TransInfo *t);
|
2013-02-18 16:35:13 +00:00
|
|
|
|
2016-04-21 11:29:32 +10:00
|
|
|
#define TRANSFORM_SNAP_MAX_PX 100.0f
|
|
|
|
|
#define TRANSFORM_DIST_INVALID -FLT_MAX
|
|
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
/* Temp macros. */
|
|
|
|
|
|
|
|
|
|
#define TRANS_DATA_CONTAINER_FIRST_OK(t) (&(t)->data_container[0])
|
|
|
|
|
/* For cases we _know_ there is only one handle. */
|
|
|
|
|
#define TRANS_DATA_CONTAINER_FIRST_SINGLE(t) \
|
|
|
|
|
(BLI_assert((t)->data_container_len == 1), (&(t)->data_container[0]))
|
|
|
|
|
|
|
|
|
|
#define FOREACH_TRANS_DATA_CONTAINER(t, th) \
|
2020-04-05 13:53:24 +10:00
|
|
|
for (TransDataContainer *tc = (t)->data_container, \
|
|
|
|
|
*tc_end = (t)->data_container + (t)->data_container_len; \
|
2018-04-16 16:27:55 +02:00
|
|
|
th != tc_end; \
|
|
|
|
|
th++)
|
|
|
|
|
|
|
|
|
|
#define FOREACH_TRANS_DATA_CONTAINER_INDEX(t, th, i) \
|
2020-04-05 13:53:24 +10:00
|
|
|
for (TransDataContainer *tc = ((i = 0), (t)->data_container), \
|
|
|
|
|
*tc_end = (t)->data_container + (t)->data_container_len; \
|
2018-04-16 16:27:55 +02:00
|
|
|
th != tc_end; \
|
|
|
|
|
th++, i++)
|
2020-11-06 10:29:01 +11:00
|
|
|
|
|
|
|
|
/** \} */
|