Fix T45929: OpenSubdiv was doing extra object recalc tags

This commit is contained in:
Sergey Sharybin 2015-08-28 14:54:27 +02:00
parent c53b1e2a93
commit b024ccd619
Notes: blender-bot 2023-02-14 19:53:12 +01:00
Referenced by issue blender/blender-addons#45929, Existence of boolean modifier slows unrelated operations
3 changed files with 17 additions and 10 deletions

View File

@ -1143,9 +1143,12 @@ void dag_add_relation(DagForest *forest, DagNode *fob1, DagNode *fob2, short rel
if ((rel & DAG_RL_DATA_DATA) != 0) {
if (fob1->type == ID_OB) {
if ((fob1->eval_flags & DAG_EVAL_NEED_CPU) == 0) {
Object *object = fob1->ob;
/* Make sure object has all the data on CPU. */
object->recalc |= OB_RECALC_DATA;
Object *ob2 = fob2->ob;
if (ob2->recalc & OB_RECALC_ALL) {
/* Make sure object has all the data on CPU. */
Object *ob1 = fob1->ob;
ob1->recalc |= OB_RECALC_DATA;
}
fob1->eval_flags |= DAG_EVAL_NEED_CPU;
}
}

View File

@ -1587,7 +1587,9 @@ static void scene_free_unused_opensubdiv_cache(Scene *scene)
if (md != NULL && md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *) md;
bool object_in_editmode = object->mode == OB_MODE_EDIT;
if (!smd->use_opensubdiv) {
if (!smd->use_opensubdiv ||
DAG_get_eval_flags_for_object(scene, object) & DAG_EVAL_NEED_CPU)
{
if (smd->mCache != NULL) {
ccgSubSurf_free_osd_mesh(smd->mCache);
}

View File

@ -356,13 +356,15 @@ DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from,
DepsRelation *rel = OBJECT_GUARDED_NEW(DepsRelation, from, to, type, description);
/* TODO(sergey): Find a better place for this. */
#ifdef WITH_OPENSUBDIV
if (type == DEPSREL_TYPE_GEOMETRY_EVAL) {
ComponentDepsNode *comp_node = from->owner;
if (comp_node->type == DEPSNODE_TYPE_GEOMETRY) {
IDDepsNode *id_to = to->owner->owner;
IDDepsNode *id_from = to->owner->owner;
if (id_to != id_from) {
if ((id_to->eval_flags & DAG_EVAL_NEED_CPU) == 0) {
id_to->tag_update(this);
id_to->eval_flags |= DAG_EVAL_NEED_CPU;
IDDepsNode *id_from = from->owner->owner;
Object *object_to = (Object *)id_to->id;
if (id_to != id_from && (object_to->recalc & OB_RECALC_ALL)) {
if ((id_from->eval_flags & DAG_EVAL_NEED_CPU) == 0) {
id_from->tag_update(this);
id_from->eval_flags |= DAG_EVAL_NEED_CPU;
}
}
}