=== Transform Snapping ===

Snap/Grid icon button in 3D view header (edit mesh). FIXME NOTICE: make nice looking icons (yes, that's for you Matt)
When snap is on, a drop down appears for the target method (closest, median, center)

Hotkey to toggle snap is Shift-Tab (this was previously used for a not totally equivalent to Tab. Ton said OK to scrap it). That hotkey is currently restricted to edit mesh (where snap is currently restricted).

Changed a couple of ugliness on how snap settings are stored.
This commit is contained in:
Martin Poirier 2007-01-07 19:33:00 +00:00
parent fea030a9ca
commit eb3d720bd9
8 changed files with 2050 additions and 2020 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

@ -294,8 +294,8 @@ typedef enum {
ICON_CONSTRAINT,
ICON_CAMERA_DEHLT,
ICON_ARMATURE_DEHLT,
ICON_BLANK39,
ICON_BLANK40,
ICON_SNAP_GEAR,
ICON_SNAP_GEO,
ICON_BLANK41,
ICON_BLANK42,

@ -137,7 +137,9 @@ typedef struct View3D {
short gridsubdiv; /* Number of subdivisions in the grid between each highlighted grid line */
short pad2[2];
short snap_target;
short pad2;
void *properties_storage; /* Nkey panel stores stuff here, not in file */
@ -166,10 +168,11 @@ typedef struct View3D {
#define V3D_OPP_DIRECTION_NAME 1
#define V3D_FLYMODE 2
#define V3D_TRANSFORM_SNAP 4
#define V3D_SNAP_TARGET (8|16)
/* View3d->snap_target */
#define V3D_SNAP_TARGET_CLOSEST 0
#define V3D_SNAP_TARGET_CENTER 8
#define V3D_SNAP_TARGET_MEDIAN 16
#define V3D_SNAP_TARGET_CENTER 1
#define V3D_SNAP_TARGET_MEDIAN 2
/* View3D->around */

File diff suppressed because it is too large Load Diff

@ -1703,16 +1703,13 @@ static void do_view3d_transformmenu(void *arg, int event)
G.vd->flag2 |= V3D_TRANSFORM_SNAP;
break;
case 17:
G.vd->flag2 &= ~V3D_SNAP_TARGET;
G.vd->flag2 |= V3D_SNAP_TARGET_CLOSEST;
G.vd->snap_target = V3D_SNAP_TARGET_CLOSEST;
break;
case 18:
G.vd->flag2 &= ~V3D_SNAP_TARGET;
G.vd->flag2 |= V3D_SNAP_TARGET_CENTER;
G.vd->snap_target = V3D_SNAP_TARGET_CENTER;
break;
case 19:
G.vd->flag2 &= ~V3D_SNAP_TARGET;
G.vd->flag2 |= V3D_SNAP_TARGET_MEDIAN;
G.vd->snap_target = V3D_SNAP_TARGET_MEDIAN;
break;
}
allqueue(REDRAWVIEW3D, 0);
@ -1782,7 +1779,7 @@ static uiBlock *view3d_transformmenu(void *arg_unused)
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
switch(G.vd->flag2 & V3D_SNAP_TARGET)
switch(G.vd->snap_target)
{
case V3D_SNAP_TARGET_CLOSEST:
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Snap Closest", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 17, "");
@ -5102,6 +5099,27 @@ void view3d_buttons(void)
xco+= 10;
}
/* Snap */
if(G.obedit && (G.obedit->type == OB_MESH)) { // Only Mesh for now
uiBlockBeginAlign(block);
if (G.vd->flag2 & V3D_TRANSFORM_SNAP)
{
uiDefIconButBitS(block, TOG, V3D_TRANSFORM_SNAP, B_REDR, ICON_SNAP_GEO,xco,0,XIC,YIC, &G.vd->flag2, 0, 0, 0, 0, "Use Snapping or Gears (Shift Tab)");
xco+= XIC;
uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2",xco,0,70,YIC, &G.vd->snap_target, 0, 0, 0, 0, "Snap Target Mode");
xco+= 70;
}
else
{
uiDefIconButBitS(block, TOG, V3D_TRANSFORM_SNAP, B_REDR, ICON_SNAP_GEAR,xco,0,XIC,YIC, &G.vd->flag2, 0, 0, 0, 0, "Use Snapping or Gears (Shift Tab)");
xco+= XIC;
}
uiBlockEndAlign(block);
xco+= 10;
}
/* selection modus */
if(G.obedit && (G.obedit->type == OB_MESH)) {
uiBlockBeginAlign(block);

@ -1358,6 +1358,19 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
BIF_view3d_previewrender(sa);
break;
case TABKEY:
// Shift-Tabe handling (other cases are in toets)
if (G.qual == LR_SHIFTKEY)
{
// Snap toggle (only edit mesh right now)
if (G.obedit && G.obedit->type==OB_MESH)
{
G.vd->flag2 ^= V3D_TRANSFORM_SNAP;
allqueue(REDRAWHEADERS, 0);
}
}
break;
/* LEFTMOUSE and RIGHTMOUSE event codes can be swapped above,
* based on user preference USER_LMOUSESELECT
*/

@ -681,20 +681,6 @@ int blenderqread(unsigned short event, short val)
}
}
}
else if(G.qual==LR_SHIFTKEY) { // ??
if(G.obedit)
exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); // freedata, and undo
if(G.f & G_FACESELECT)
set_faceselect();
if(G.f & G_VERTEXPAINT)
set_vpaint();
if(G.f & G_TEXTUREPAINT)
set_texturepaint();
if(G.f & G_WEIGHTPAINT)
set_wpaint();
if(G.f & G_SCULPTMODE)
set_sculptmode();
}
break;
case BACKSPACEKEY:

@ -173,7 +173,7 @@ void setSnappingCallback(TransInfo *t)
t->tsnap.calcSnap = CalcSnapGeometry;
switch(G.vd->flag2 & V3D_SNAP_TARGET)
switch(G.vd->snap_target)
{
case V3D_SNAP_TARGET_CLOSEST:
t->tsnap.modeTarget = SNAP_CLOSEST;
@ -200,7 +200,7 @@ void setSnappingCallback(TransInfo *t)
t->tsnap.distance = RotationBetween;
// Can't do TARGET_CENTER with rotation, use TARGET_MEDIAN instead
if ((G.vd->flag2 & V3D_SNAP_TARGET) == V3D_SNAP_TARGET_CENTER) {
if (G.vd->snap_target == V3D_SNAP_TARGET_CENTER) {
t->tsnap.modeTarget = SNAP_MEDIAN;
t->tsnap.targetSnap = TargetSnapMedian;
}