Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <mano-wii>2021-11-17 17:02:54 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-11-18 19:14:18 +0300
commitf19bd637e2c38b8b967944a88609a190b5179439 (patch)
tree88c9adba987a194e1f59f1e22210c684d4839c6b /source/blender/editors/space_view3d/view3d_cursor_snap.c
parent67b4eecac9311ab677dadb7b8bd1c54031dd3589 (diff)
Transform: interactive mode for editing a 'Snap Source'
This patch implements part of what was stated in {T66484}, with respect to `Base Point`. ## Introduction The snapping feature of the transform tools has a variety of applications: - Organization of nodes. - Positioning of frames in precise time units. - Retopology with snap to face - Creation of armatures with bone positioning through the snap to volume - Precise positioning of 3D or 2D objects in the surrounding geometry (CAD modeling) The goal of this document is to make it more powerful for precision modeling and still supporting the old use cases without extra complexity. The main topic addressed here is the introduction of a **interactive mode for setting a snap source** (See terminology). ## Terminology * **Snap Source**: 3d coordinate * we want to snap from. (Currently defined by the `Snap With` options: `Closest`, `Center`, `Median` and `Active`). * **Snap Target**: 3d coordinate* we want to snap to. (Vertices, Edges, Faces, Grid...) ## Interactive Mode for Editing a Snap Source Currently the fixed snap point can only be obtained through the `Snap With` options. So it's a little tricky for the user to define a snap source point having so much geometry on an object. Because of this, the user needs to resort to impractical solutions to get a point in the geometry. See example of an impractical use: {F11714181, layout=left, width=960, alt="The user used the cursor (which can be snapped) to choose the snap origin point."} The user used the cursor (which can be snapped) to choose the snap source point. While it is possible to work around this current limitation, it is important to reduce the number of steps and allow the user to set a snap source point through an optional interactive mode during a transformation. The proposed solution is to be able to move the current snap source point through a modal modifier activated with a key (eg. B). The snap source point can thus "snap" to the elements in the scene (vertex, mid-edge, Lamp, …) during this mode. {F9122814, layout=left, width=960, alt="Base Point Snap, example of transform operation via the shortcut (not the tool). After pressing g and the snap base change shortcut (e.g., shift + ctrl) the user set the base point. The base point is then visible until the end of the operation. The z axis constrains the final position."} ## Implementation Details - The feature will only be available in 3D View. - The feature will only be available for `Move`, `Rotate` and `Scale` transform modes. - The snap source editing will be enabled with a single click on the modifier key (B). - Having a snap point indicated, the new snap origin point will be confirmed with the same buttons that confirms the transformation (but the transformation will not be concluded). - The snap source editing can be canceled with the same key that activated it (B). - If the transformation is done with "release_confirm" (common for gizmos), the new feature cannot be enabled. - During the transformation, when enabling the feature, if the snap option is turned off in the scene, the snap will be forced on throughout the rest of the transformation (unless interactive mode is canceled). - During a transformation, if no snap target is set for an element in the scene (Vertex, Grid...), the snap targets to geometry Vertex, Edge, Face, Center of Edge and Perpendicular of Edge will be set automatically. - Snap cannot be turned off during the snap source editing. - Constraint or similar modification features will not be available during the snap source editing. - Text input will not be available during the snap source editing. - When adding multiple snap points (A) the new prone snap source point will be indicated with an "X" drawing. {F11817267} Maniphest Tasks: T66484 Differential Revision: https://developer.blender.org/D9415
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_cursor_snap.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_cursor_snap.c26
1 files changed, 1 insertions, 25 deletions
diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c b/source/blender/editors/space_view3d/view3d_cursor_snap.c
index ac80a70011a..961b0bd6862 100644
--- a/source/blender/editors/space_view3d/view3d_cursor_snap.c
+++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c
@@ -414,37 +414,13 @@ void ED_view3d_cursor_snap_draw_util(RegionView3D *rv3d,
}
if (loc_prev) {
- /* Draw an "X" indicating where the previous snap point is.
- * This is useful for indicating perpendicular snap. */
-
- /* v1, v2, v3 and v4 indicate the coordinates of the ends of the "X". */
- float vx[3], vy[3], v1[3], v2[3], v3[3], v4[4];
-
/* Multiply by 0.75f so that the final size of the "X" is close to that of
* the circle.
* (A closer value is 0.7071f, but we don't need to be exact here). */
float x_size = 0.75f * radius * ED_view3d_pixel_size(rv3d, loc_prev);
- mul_v3_v3fl(vx, view_inv[0], x_size);
- mul_v3_v3fl(vy, view_inv[1], x_size);
-
- add_v3_v3v3(v1, vx, vy);
- sub_v3_v3v3(v2, vx, vy);
- negate_v3_v3(v3, v1);
- negate_v3_v3(v4, v2);
-
- add_v3_v3(v1, loc_prev);
- add_v3_v3(v2, loc_prev);
- add_v3_v3(v3, loc_prev);
- add_v3_v3(v4, loc_prev);
-
immUniformColor4ubv(color_line);
- immBegin(GPU_PRIM_LINES, 4);
- immVertex3fv(pos, v3);
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v4);
- immVertex3fv(pos, v2);
- immEnd();
+ imm_drawX(loc_prev, x_size, view_inv, pos);
if (loc_curr && (snap_elem_type & SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
/* Dashed line. */