[Bf-blender-cvs] [c0c1b4542f3] master: Fix T65996: metaballs converted to meshes appear to render at an incorrect isosurface.

Bastien Montagne noreply at git.blender.org
Mon Jun 24 20:46:23 CEST 2019


Commit: c0c1b4542f391fbec18b7168d2d845212fb44ac3
Author: Bastien Montagne
Date:   Mon Jun 24 20:40:56 2019 +0200
Branches: master
https://developer.blender.org/rBc0c1b4542f391fbec18b7168d2d845212fb44ac3

Fix T65996: metaballs converted to meshes appear to render at an incorrect isosurface.

Not much to be done here really, besides adding yet another hack to that
giant pile of hacks that are mballs...

So to avoid newly created copy of basis of mball to influence to mball
computation, we simply switch it to Empty object for the depsgraph
update run.

Not nice, but working (besides a weird change of basis obflag which
should not happen), and presumably reasonably safe change.

===================================================================

M	source/blender/editors/object/object_add.c

===================================================================

diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 823f6c55a06..0fdb1cec16f 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2029,6 +2029,18 @@ static Base *duplibase_for_convert(
   ED_object_base_select(basen, BA_SELECT);
   ED_object_base_select(base, BA_DESELECT);
 
+  /* XXX An ugly hack needed because if we re-run depsgraph with some new MBall objects
+   * having same 'family name' as orig ones, they will affect end result of MBall computation...
+   * For until we get rid of that name-based thingy in MBalls, that should do the trick
+   * (this is weak, but other solution (to change name of obn) is even worse imho).
+   * See T65996. */
+  const bool is_meta_ball = (obn->type == OB_MBALL);
+  void *obdata = obn->data;
+  if (is_meta_ball) {
+    obn->type = OB_EMPTY;
+    obn->data = NULL;
+  }
+
   /* XXX Doing that here is stupid, it means we update and re-evaluate the whole depsgraph every
    * time we need to duplicate an object to convert it. Even worse, this is not 100% correct, since
    * we do not yet have duplicated obdata.
@@ -2043,6 +2055,11 @@ static Base *duplibase_for_convert(
   BKE_scene_graph_update_tagged(depsgraph, bmain);
   scene->customdata_mask = customdata_mask_prev;
 
+  if (is_meta_ball) {
+    obn->type = OB_MBALL;
+    obn->data = obdata;
+  }
+
   return basen;
 }
 
@@ -2312,8 +2329,6 @@ static int convert_exec(bContext *C, wmOperator *op)
       }
 
       if (!(baseob->flag & OB_DONE)) {
-        baseob->flag |= OB_DONE;
-
         basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, baseob);
         newob = basen->object;
 
@@ -2339,6 +2354,7 @@ static int convert_exec(bContext *C, wmOperator *op)
           basact = basen;
         }
 
+        baseob->flag |= OB_DONE;
         mballConverted = 1;
       }
     }



More information about the Bf-blender-cvs mailing list