diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index f7b1f7930f9..80f450000bb 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -346,6 +346,24 @@ static void dag_add_driver_relation(Ipo *ipo, DagForest *dag, DagNode *node, int } } +static void dag_add_collision_field_relation(DagForest *dag, Object *ob, DagNode *node) +{ + Base *base; + DagNode *node2; + + // would be nice to have a list of colliders here + // so for now walk all objects in scene check 'same layer rule' + for(base = G.scene->base.first; base; base= base->next) { + if((base->lay & ob->lay) && base->object->pd) { + Object *ob1= base->object; + if((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) { + node2 = dag_get_node(dag, ob1); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Field Collision"); + } + } + } +} + static void build_dag_object(DagForest *dag, DagNode *scenenode, Object *ob, int mask) { bConstraint *con; @@ -523,22 +541,9 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Object *ob, int } /* softbody collision */ - if((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE)) { - Base *base; - if(modifiers_isSoftbodyEnabled(ob)){ - // would be nice to have a list of colliders here - // so for now walk all objects in scene check 'same layer rule' - for(base = G.scene->base.first; base; base= base->next) { - if( (base->lay & ob->lay) && base->object->pd) { - Object *ob1= base->object; - if((ob1->pd->deflect) && (ob1 != ob)) { - node2 = dag_get_node(dag, ob1); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Softbody Collision"); - } - } - } - } - } + if((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE)) + if(modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob)) + dag_add_collision_field_relation(dag, ob, node); if (ob->type==OB_MBALL) { Object *mom= find_basis_mball(ob); diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index c71caa082e7..919187a4abe 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -3208,6 +3208,7 @@ static void object_collision__enabletoggle ( void *ob_v, void *arg2 ) { md = modifier_new ( eModifierType_Collision ); BLI_addtail ( &ob->modifiers, md ); + DAG_scene_sort(G.scene); DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWVIEW3D, 0); @@ -3215,8 +3216,10 @@ static void object_collision__enabletoggle ( void *ob_v, void *arg2 ) } else { + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); BLI_remlink ( &ob->modifiers, md ); modifier_free ( md ); + DAG_scene_sort(G.scene); allqueue(REDRAWBUTSEDIT, 0); } }