Depsgraph: Fix relations for metaballs

Initially spotted and investigated by Dalai and Germano.
This commit is contained in:
Sergey Sharybin 2017-11-13 14:43:08 +01:00
parent 075950ad66
commit 7103c6ef3b
2 changed files with 20 additions and 9 deletions

View File

@ -820,11 +820,11 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
case OB_MBALL:
{
Object *mom = BKE_mball_basis_find(scene, ob);
/* Motherball - mom depends on children! */
/* NOTE: Only the motherball gets evaluated, it's children are
* having empty placeholders for the correct relations being built.
*/
if (mom == ob) {
/* metaball evaluation operations */
/* NOTE: only the motherball gets evaluated! */
op_node = add_operation_node(obdata,
DEG_NODE_TYPE_GEOMETRY,
function_bind(BKE_mball_eval_geometry,
@ -832,6 +832,12 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
(MetaBall *)obdata),
DEG_OPCODE_PLACEHOLDER,
"Geometry Eval");
} else {
op_node = add_operation_node(obdata,
DEG_NODE_TYPE_GEOMETRY,
NULL,
DEG_OPCODE_PLACEHOLDER,
"Geometry Eval");
op_node->set_as_entry();
}
break;

View File

@ -1501,14 +1501,19 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje
case OB_MBALL:
{
Object *mom = BKE_mball_basis_find(scene, ob);
ComponentKey mom_geom_key(&mom->id, DEG_NODE_TYPE_GEOMETRY);
/* motherball - mom depends on children! */
if (mom != ob) {
/* non-motherball -> cannot be directly evaluated! */
ComponentKey mom_key(&mom->id, DEG_NODE_TYPE_GEOMETRY);
if (mom == ob) {
ComponentKey mom_transform_key(&mom->id,
DEG_NODE_TYPE_TRANSFORM);
add_relation(mom_transform_key,
mom_geom_key,
"Metaball Motherball Transform -> Geometry");
}
else if (mom != ob) {
ComponentKey transform_key(&ob->id, DEG_NODE_TYPE_TRANSFORM);
add_relation(geom_key, mom_key, "Metaball Motherball");
add_relation(transform_key, mom_key, "Metaball Motherball");
add_relation(geom_key, mom_geom_key, "Metaball Motherball");
add_relation(transform_key, mom_geom_key, "Metaball Motherball");
}
break;
}