
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
101 lines
4.2 KiB
C++
101 lines
4.2 KiB
C++
/*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
/** \file
|
|
* \ingroup gpu
|
|
*
|
|
* Utility drawing functions (rough equivalent to OpenGL's GLU)
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Draw 2D rectangles (replaces glRect functions) */
|
|
/* caller is responsible for vertex format & shader */
|
|
void immRectf(uint pos, float x1, float y1, float x2, float y2);
|
|
void immRecti(uint pos, int x1, int y1, int x2, int y2);
|
|
|
|
/* Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GPU_PRIM_TRIS. */
|
|
void immRectf_fast(uint pos, float x1, float y1, float x2, float y2);
|
|
void immRectf_fast_with_color(
|
|
uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4]);
|
|
void immRecti_fast_with_color(
|
|
uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4]);
|
|
|
|
void imm_cpack(uint x);
|
|
|
|
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments);
|
|
void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float radius, int nsegments);
|
|
|
|
void imm_draw_circle_wire_aspect_2d(
|
|
uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments);
|
|
void imm_draw_circle_fill_aspect_2d(
|
|
uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments);
|
|
|
|
/* use this version when GPUVertFormat has a vec3 position */
|
|
void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments);
|
|
void imm_draw_circle_dashed_3d(uint pos, float x, float y, float radius, int nsegments);
|
|
void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegments);
|
|
|
|
/* same as 'imm_draw_disk_partial_fill_2d', except it draws a wire arc. */
|
|
void imm_draw_circle_partial_wire_2d(
|
|
uint pos, float x, float y, float radius, int nsegments, float start, float sweep);
|
|
|
|
void imm_draw_disk_partial_fill_2d(uint pos,
|
|
float x,
|
|
float y,
|
|
float rad_inner,
|
|
float rad_outer,
|
|
int nsegments,
|
|
float start,
|
|
float sweep);
|
|
|
|
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2);
|
|
void imm_draw_box_wire_3d(uint pos, float x1, float y1, float x2, float y2);
|
|
|
|
void imm_draw_box_checker_2d_ex(float x1,
|
|
float y1,
|
|
float x2,
|
|
float y2,
|
|
const float color_primary[4],
|
|
const float color_secondary[4],
|
|
int checker_size);
|
|
void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2);
|
|
|
|
void imm_draw_cube_fill_3d(uint pos, const float center[3], const float aspect[3]);
|
|
void imm_draw_cube_wire_3d(uint pos, const float center[3], const float aspect[3]);
|
|
void imm_draw_cube_corners_3d(uint pos,
|
|
const float center[3],
|
|
const float aspect[3],
|
|
const float factor);
|
|
|
|
void imm_draw_cylinder_fill_normal_3d(
|
|
uint pos, uint nor, float base, float top, float height, int slices, int stacks);
|
|
void imm_draw_cylinder_wire_3d(
|
|
uint pos, float base, float top, float height, int slices, int stacks);
|
|
void imm_draw_cylinder_fill_3d(
|
|
uint pos, float base, float top, float height, int slices, int stacks);
|
|
|
|
void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], uint pos);
|
|
void imm_drawX(const float cent[3], float size, const float tmat[4][4], uint pos);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|