diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-04-24 18:23:44 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-04-24 18:23:44 +0300 |
commit | a8441fc90086bf21dc50dc9dcd6085e0a0674921 (patch) | |
tree | f02a5d015e1b315175c1887f7de6a3c575cb1ea8 /source/blender | |
parent | 4542b50afcfc9b797d5f3048393ba1f1836561a0 (diff) |
Fix T69753 Instanced Metaballs not rendering but showing up in Viewport
This hides the original metaballs when they are used in
duplifaces/-verts instancing, and still shows the instanced metaballs.
The visibility of the original metaballs is now determined by the
visibility of the instancer. I'm not too thrilled about this, but at
least it gives users the ability to show/hide the metaballs for
viewport/render.
Differential Revision: https://developer.blender.org/D7478
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/mball_tessellate.c | 11 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_query_iter.cc | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 12 |
3 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c index cd629c888a4..ad178e76ef6 100644 --- a/source/blender/blenkernel/intern/mball_tessellate.c +++ b/source/blender/blenkernel/intern/mball_tessellate.c @@ -44,6 +44,7 @@ #include "BKE_displist.h" #include "BKE_mball_tessellate.h" /* own include */ +#include "BKE_object.h" #include "BKE_scene.h" #include "DEG_depsgraph.h" @@ -1191,6 +1192,8 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje int obnr, zero_size = 0; char obname[MAX_ID_NAME]; SceneBaseIter iter; + const eEvaluationMode deg_eval_mode = DEG_get_mode(depsgraph); + const short parenting_dupli_transflag = (OB_DUPLIFACES | OB_DUPLIVERTS); copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from BKE_scene_base_iter_next */ invert_m4_m4(obinv, ob->obmat); @@ -1204,6 +1207,14 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje zero_size = 0; ml = NULL; + /* If this metaball is the original that's used for duplication, only have it it visible when + * the instancer is visible too. */ + if ((base->flag_legacy & OB_FROMDUPLI) == 0 && ob->parent != NULL && + (ob->parent->transflag & parenting_dupli_transflag) != 0 && + (BKE_object_visibility(ob->parent, deg_eval_mode) & OB_VISIBLE_SELF) == 0) { + continue; + } + if (bob == ob && (base->flag_legacy & OB_FROMDUPLI) == 0) { mb = ob->data; diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index fadd0beb636..c4b53bd8176 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -103,7 +103,10 @@ static bool deg_object_hide_original(eEvaluationMode eval_mode, Object *ob, Dupl * by its parent. Ideally this should not be needed, but due to the wrong * dependency direction in the data design there is no way to keep the object * visible otherwise. The better solution eventually would be for objects - * to specify which object they instance, instead of through parenting. */ + * to specify which object they instance, instead of through parenting. + * + * This function should not be used for metaballs. They have custom visibility rules, as hiding + * the base metaball will also hide all the other balls in the group. */ if (eval_mode == DAG_EVAL_RENDER || dob) { const int hide_original_types = OB_DUPLIVERTS | OB_DUPLIFACES; @@ -215,7 +218,7 @@ void deg_iterator_objects_step(BLI_Iterator *iter, DEG::IDNode *id_node) if (data->flag & DEG_ITER_OBJECT_FLAG_VISIBLE) { ob_visibility = BKE_object_visibility(object, data->eval_mode); - if (deg_object_hide_original(data->eval_mode, object, nullptr)) { + if (object->type != OB_MBALL && deg_object_hide_original(data->eval_mode, object, nullptr)) { return; } } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index b108093a9dd..33048d4b057 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -349,6 +349,14 @@ static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id); } +static void rna_Object_duplicator_visibility_flag_update(Main *UNUSED(bmain), + Scene *UNUSED(scene), + PointerRNA *ptr) +{ + Object *ob = (Object *)ptr->owner_id; + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); +} + static void rna_MaterialIndex_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = (Object *)ptr->owner_id; @@ -3097,10 +3105,14 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "show_instancer_for_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_RENDER); RNA_def_property_ui_text(prop, "Render Instancer", "Make instancer visible when rendering"); + RNA_def_property_update( + prop, NC_OBJECT | ND_DRAW, "rna_Object_duplicator_visibility_flag_update"); prop = RNA_def_property(srna, "show_instancer_for_viewport", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_VIEWPORT); RNA_def_property_ui_text(prop, "Display Instancer", "Make instancer visible in the viewport"); + RNA_def_property_update( + prop, NC_OBJECT | ND_DRAW, "rna_Object_duplicator_visibility_flag_update"); /* anim */ rna_def_animdata_common(srna); |