Page MenuHome

scaling in viewport doesn't work with snap to nearest vertex.
Closed, ResolvedPublic

Description

System Information
All

Blender Version
Broken: 2.70
Short description of error
Scaling an object relative to 3d cursor and with snap to nearest vertex gives random results.

Exact steps for others to reproduce the error
Open attached file, place mouse cursor on the bottom-left vertex of the active cube, hit S, move cursor to nearest vertex of the bottom cube : it scales properly, now press ctrl to have it exactly touch the vertex, it scales back to a random position.

Event Timeline

matali (mattali) updated the task description. (Show Details)
matali (mattali) raised the priority of this task from to Needs Triage by Developer.
matali (mattali) set Type to Bug.

This behavior is admittedly awkward. Scaling is a very limited operation (1 degree or freedom only), which makes it rather unsuitable for snapping in the way it works with other transform modes. I'm not sure how this could fit better into the snapping system, but it's not a bug or regression.

Afaik the snapping works like roughly this:

  1. Select the element indicated by the mouse (the orange circle)
  2. Select the closest corresponding element of the transformed object (in untransformed state)
  3. Calculate a transform such that the distance (whatever the actual metric is) between snap target and selected element becomes minimal.

The first 2 steps should be independent of the transform mode, but the 3rd can be quite tricky depending on the mode and additional constraints. For scaling there might not be an efficient way to calculate such a transform or it may require an iterative approach. Apart from that you cannot expect the elements to snap together precisely, due to the inherent limitation of (uniform) scaling to 1 degree of freedom.

On the same scene, translating on 1 local axis, here Y, works (G Y Y). So blender finds a way to snap that nearest vertex without it to be presicely snapped (also 1 degree of freedom). If blender succeed in finding the right position for that vertex, it can deduce the scale from the new edge length comparing to the old?

Scripting it in Python works (makes a 1 axis translation, save snap location, compute new edge length, divide by old edge length, undo trtanslation and scale with that factor).

Bastien Montagne (mont29) triaged this task as Normal priority.Mar 21 2014, 9:38 PM

Encountered same bug today, can confirm. When used in "nearest vertex" mode, it is for that nearest vertex a translation constrained on the center-nearest vertex axis. Translating on local axis with snap works (GXX combo with snap active for example). So it is possible to determine a perfect scale factor too, at least in "nearest vertex" (by doing a 1 axis translation with snap of the nearest vertex and using the given new location to determine the appropriate scale). For modes where no factor can be determined, a warning would be better than the current random scale.

since 2.73 is mostly a bugfix release, would it be possible to fix such old, waiting bugs? Many professionals prefer polishing over new features, please use this quiet release to polish Blender. Would be a lovely Christmas present :)

thanks for the fix, it works well with "median" as pivot point but with "individual origins" it breaks.
In attached file:
Scale and choose a vertex with "ctrl" pressed, cube seems to disappear.
To compare, press "G" and choose a vertex for snap, the cube's center is moved as a cube (also individual origins could make all selected verts move to that position making a point instead of a cube?) to that vertex.
Scale with "median" as pivot, it works

So maybe to make it consistent, make "individual origins behave like median.

@mathieu menuet (bliblubli)

While we try to keep track of all reports (even updates to closed ones), they do get overlooked sometimes since theres a lot of activity.

Please open new reports if you find further problems, you can always reference other reports if you think they're related.

Ok, as it's stil not resolved by last commit, I made https://developer.blender.org/T46505.