Bad crash in volume snapping code when duplis where involved.
authorMartin Poirier <theeth@yahoo.com>
Tue, 24 Mar 2009 19:39:43 +0000 (19:39 +0000)
committerMartin Poirier <theeth@yahoo.com>
Tue, 24 Mar 2009 19:39:43 +0000 (19:39 +0000)
Found out using Coverity's scan report.

source/blender/src/transform_snap.c

index bedfaf60b77fdf66fb5ce68755b05a7e189cd13c..b43984af1a68fb30de8f25bfe2cf0f452cd32249 100644 (file)
@@ -1563,11 +1563,21 @@ int peelObjects(ListBase *depth_peels, short mval[2])
                                        Object *ob = dupli_ob->ob;
                                        
                                        if (ob->type == OB_MESH) {
-                                               DerivedMesh *dm;
-                                               int editmesh = 0;
+                                               DerivedMesh *dm = NULL;
                                                int val;
                                                
-                                               val = peelDerivedMesh(ob, dm, dupli_ob->mat, ray_start, ray_normal, mval, depth_peels);
+                                               if (ob != G.obedit)
+                                               {
+                                                       dm = mesh_get_derived_final(ob, CD_MASK_BAREMESH);
+                                                       
+                                                       val = peelDerivedMesh(ob, dm, dupli_ob->mat, ray_start, ray_normal, mval, depth_peels);
+                                               }
+                                               else
+                                               {
+                                                       dm = editmesh_get_derived_cage(CD_MASK_BAREMESH);
+                                                       
+                                                       val = peelDerivedMesh(ob, dm, dupli_ob->mat, ray_start, ray_normal, mval, depth_peels);
+                                               }
        
                                                retval = retval || val;