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:
authorMartin Poirier <theeth@yahoo.com>2006-12-20 22:47:12 +0300
committerMartin Poirier <theeth@yahoo.com>2006-12-20 22:47:12 +0300
commit88ef0928761f815d2fa39f1939d63d82974dec72 (patch)
treea260bd30793df8936b7cb855c655adc4ff59faa1 /source/blender/src/transform_snap.c
parent496410a255376d2e09f8d990501cf8847e794f1b (diff)
=== Transform Snap ===
(Implementing Matt's idea) Grid and Snap are now exclusively controlled by the Control key (pun intented). You can switch to Snap by selecting the snap option in the Transform menu (this option is only available in edit mode on a mesh. this option is per 3D view) (NOTE: There is currently no hotkey for that, anyone should feel free to add one). When Snap is selected, holding down Ctrl during translations (grab) snaps to vertex. All other situations which have no snapping code yet defaults to Grid.
Diffstat (limited to 'source/blender/src/transform_snap.c')
-rw-r--r--source/blender/src/transform_snap.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/source/blender/src/transform_snap.c b/source/blender/src/transform_snap.c
index cdd4fb793ba..bf307eb5825 100644
--- a/source/blender/src/transform_snap.c
+++ b/source/blender/src/transform_snap.c
@@ -79,7 +79,8 @@ void TargetSnapClosest(TransInfo *t);
void drawSnapping(TransInfo *t)
{
- if ((t->tsnap.status & (SNAP_ON|POINT_INIT|TARGET_INIT)) == (SNAP_ON|POINT_INIT|TARGET_INIT)) {
+ if ((t->tsnap.status & (SNAP_ON|POINT_INIT|TARGET_INIT)) == (SNAP_ON|POINT_INIT|TARGET_INIT) &&
+ (G.qual & LR_CTRLKEY)) {
float unitmat[4][4];
char col[4];
@@ -103,21 +104,15 @@ int handleSnapping(TransInfo *t, int event)
{
int status = 0;
- switch(event) {
- case ACCENTGRAVEKEY:
- t->tsnap.status ^= SNAP_ON;
- status = 1;
- break;
- }
+ // Put keyhandling code here
return status;
}
void applySnapping(TransInfo *t, float *vec)
{
- if ( (t->tsnap.status & SNAP_ON) &&
- t->tsnap.applySnap != NULL &&
- (t->flag & T_PROP_EDIT) == 0)
+ if ((t->tsnap.status & SNAP_ON) &&
+ (G.qual & LR_CTRLKEY))
{
double current = PIL_check_seconds_timer();
@@ -148,13 +143,18 @@ void initSnapping(TransInfo *t)
resetSnapping(t);
setSnappingCallback(t);
- if ((t->spacetype==SPACE_VIEW3D) && (G.vd->flag2 & V3D_TRANSFORM_SNAP))
+ if (t->tsnap.applySnap != NULL && // A snapping function actually exist
+ (G.obedit != NULL && G.obedit->type==OB_MESH) && // Temporary limited to edit mode meshes
+ (t->spacetype==SPACE_VIEW3D) && // Only 3D view (not UV)
+ (G.vd->flag2 & V3D_TRANSFORM_SNAP) && // Only if the snap flag is on
+ (t->flag & T_PROP_EDIT) == 0) // No PET, obviously
{
t->tsnap.status |= SNAP_ON;
+ t->tsnap.mode = SNAP_GEO;
}
else
{
- t->tsnap.status &= ~SNAP_ON;
+ t->tsnap.mode = SNAP_GRID;
}
}
@@ -197,12 +197,6 @@ void setSnappingCallback(TransInfo *t)
void ApplySnapTranslation(TransInfo *t, float vec[3])
{
VecSubf(vec, t->tsnap.snapPoint, t->tsnap.snapTarget);
-/*
- if (t->con.mode & CON_APPLY)
- {
- Mat3MulVecfl(t->con.pmtx, vec);
- }
-*/
}
void ApplySnapRotation(TransInfo *t, float vec[3])
@@ -387,6 +381,10 @@ void snapGridAction(TransInfo *t, float *val, GearsType action) {
void snapGrid(TransInfo *t, float *val) {
int invert;
GearsType action;
+
+ // Only do something if using Snap to Grid
+ if ((t->tsnap.mode & SNAP_GRID) == 0)
+ return;
if(t->mode==TFM_ROTATION || t->mode==TFM_WARP || t->mode==TFM_TILT || t->mode==TFM_TRACKBALL || t->mode==TFM_BONE_ROLL)
invert = U.flag & USER_AUTOROTGRID;