diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-09-14 13:51:04 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-09-14 13:53:52 +0300 |
commit | 34843a855e6b45cffbc0cd0ffae2d688e6ee1168 (patch) | |
tree | 1a90816443ce788ef67ae994d33b0a7d3dfb5096 /source/blender/editors | |
parent | 2db71782e750313fc2c7d0a420e0fab6e06e38d4 (diff) |
Fix T46099: snapping failed on objects with some NULL-dimension in their bbox.
Added a helper that ensures a bbox has some non-NULL dimension along all its axes.
Also, fixed some (rather unlikely) NULL dereference cases (though it should not in this context,
`BKE_object_boundbox_get()` can return NULL).
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 867e862017f..f6040732983 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1527,8 +1527,17 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes if (do_bb) { BoundBox *bb = BKE_object_boundbox_get(ob); - if (!BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, &len_diff)) { - return retval; + + if (bb) { + BoundBox bb_temp; + + /* We cannot aford a bbox with some null dimension, which may happen in some cases... + * Threshold is rather high, but seems to be needed to get good behavior, see T46099. */ + bb = BKE_boundbox_ensure_minimum_dimensions(bb, &bb_temp, 1e-1f); + + if (!BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, &len_diff)) { + return retval; + } } } else if (do_ray_start_correction) { @@ -2151,8 +2160,17 @@ static bool peelDerivedMesh( * test against boundbox first * */ if (looptri_num > 16) { - struct BoundBox *bb = BKE_object_boundbox_get(ob); - test = BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, NULL); + BoundBox *bb = BKE_object_boundbox_get(ob); + + if (bb) { + BoundBox bb_temp; + + /* We cannot aford a bbox with some null dimension, which may happen in some cases... + * Threshold is rather high, but seems to be needed to get good behavior, see T46099. */ + bb = BKE_boundbox_ensure_minimum_dimensions(bb, &bb_temp, 1e-1f); + + test = BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, NULL); + } } if (test == true) { |