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:
authorBastien Montagne <montagne29@wanadoo.fr>2014-07-28 17:15:18 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-07-28 17:21:42 +0400
commitc4b47b89f76d259792b3a8f0f9b6718668996000 (patch)
tree4c636d953858e5b21a8bb82833b2ee63d23122b9 /source/blender/editors
parent1a9252d97e409887fe65cbbc508ec7d53cd98f17 (diff)
Fix T41191: Face snapping doesn't work properly.
Issue was caused by rB47ec0394ca3d, which disabled BBox check in editmode - but bbox check was also setting `len_diff`, which is mandatory when doing ray_start_local correction for ortho view... Now, in this case, we do a quick rough compute of len_diff from vertices coordinates (accuracy is not needed here, we just have to be sure corrected `ray_start_local` remains 'before' (outside) of the geometry).
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/transform/transform_snap.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 2aba8b792d2..26eb836bdc9 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -1493,6 +1493,8 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
const float mval[2], float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth, bool do_bb)
{
bool retval = false;
+ const bool do_ray_start_correction = (snap_mode == SCE_SNAP_MODE_FACE && ar &&
+ !((RegionView3D *)ar->regiondata)->is_persp);
int totvert = dm->getNumVerts(dm);
if (totvert > 0) {
@@ -1519,6 +1521,24 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
return retval;
}
}
+ else if (do_ray_start_correction) {
+ /* We *need* a reasonably valid len_diff in this case.
+ * Default to distance from object's center (i.e. point (0,0,0) since we are in local space)
+ * minus farthest vertex from this center.
+ */
+ int i = totvert;
+ MVert *mv = dm->getVertArray(dm);
+ float max_dist_squared = 0.0f;
+
+ for (; i; i--, mv++) {
+ const float d = len_squared_v3(mv->co);
+ if (d > max_dist_squared) {
+ max_dist_squared = d;
+ }
+ }
+
+ len_diff = len_v3(ray_start_local) - sqrtf(max_dist_squared);
+ }
switch (snap_mode) {
case SCE_SNAP_MODE_FACE:
@@ -1530,7 +1550,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
* been *inside* boundbox, leading to snap failures (see T38409).
* Note also ar might be null (see T38435), in this case we assume ray_start is ok!
*/
- if (ar && !((RegionView3D *)ar->regiondata)->is_persp) {
+ if (do_ray_start_correction) {
float ray_org_local[3];
copy_v3_v3(ray_org_local, ray_origin);