Fix T42571,T42572 snapping ignores linked objects
authorAntony Riakiotakis <kalast@gmail.com>
Thu, 13 Nov 2014 14:41:29 +0000 (15:41 +0100)
committerAntony Riakiotakis <kalast@gmail.com>
Thu, 13 Nov 2014 14:41:57 +0000 (15:41 +0100)
Make sure to use edit object if objects share the same data.

source/blender/editors/transform/transform_snap.c

index dcc7024705add3e3280f96f4ad94cae891e23902..a3e2ab3907b60ea25d1a68ecd9ad911b7c232565 100644 (file)
@@ -1948,21 +1948,32 @@ static bool snapObjectsRay(Scene *scene, short snap_mode, Base *base_act, View3D
                     (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != base_act)))
                {
                        Object *ob = base->object;
-                       
+                       Object *ob_snap = ob;
+                       bool use_obedit = false;
+
+                       /* for linked objects, use the same object but a different matrix */
+                       if (obedit && ob->data == obedit->data) {
+                               use_obedit = true;
+                               ob_snap = obedit;
+                       }
+
                        if (ob->transflag & OB_DUPLI) {
                                DupliObject *dupli_ob;
                                ListBase *lb = object_duplilist(G.main->eval_ctx, scene, ob);
                                
                                for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
-                                       retval |= snapObject(scene, snap_mode, ar, dupli_ob->ob, dupli_ob->mat, false,
+                                       bool use_obedit_dupli = (obedit && dupli_ob->ob->data == obedit->data);
+                                       Object *dupli_snap = (use_obedit_dupli) ? obedit : dupli_ob->ob;
+
+                                       retval |= snapObject(scene, snap_mode, ar, dupli_snap, dupli_ob->mat, use_obedit_dupli,
                                                             r_ob, r_obmat,
                                                             ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_ray_dist);
                                }
                                
                                free_object_duplilist(lb);
                        }
-                       
-                       retval |= snapObject(scene, snap_mode, ar, ob, ob->obmat, false,
+
+                       retval |= snapObject(scene, snap_mode, ar, ob_snap, ob->obmat, use_obedit,
                                             r_ob, r_obmat,
                                             ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_ray_dist);
                }