[Bf-blender-cvs] [08d8751] master: Depsgraph: Add utility function to check whether modifier depends on time

Sergey Sharybin noreply at git.blender.org
Tue May 12 13:06:58 CEST 2015


Commit: 08d87514d3bf33f8b4770e9213ad3dcddcda9b26
Author: Sergey Sharybin
Date:   Tue May 12 13:38:55 2015 +0500
Branches: master
https://developer.blender.org/rB08d87514d3bf33f8b4770e9213ad3dcddcda9b26

Depsgraph: Add utility function to check whether modifier depends on time

Currently unused, based on the code from old depsgraph.c. The purpose is to
re-sue the code over old and new depsgraph in an easy way.

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

M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/object.c

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

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index d287eb4..ec90cc7 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -47,6 +47,7 @@ struct MovieClip;
 struct Main;
 struct RigidBodyWorld;
 struct HookModifierData;
+struct ModifierData;
 
 void BKE_object_workob_clear(struct Object *workob);
 void BKE_object_workob_calc_parent(struct Scene *scene, struct Object *ob, struct Object *workob);
@@ -232,6 +233,8 @@ void             BKE_object_groups_clear(struct Scene *scene, struct Base *base,
 
 struct KDTree *BKE_object_as_kdtree(struct Object *ob, int *r_tot);
 
+bool BKE_object_modifier_use_time(struct Object *ob, struct ModifierData *md);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index d5f070b..8dfc7e0 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3891,3 +3891,51 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
 	*r_tot = tot;
 	return tree;
 }
+
+bool BKE_object_modifier_use_time(Object *ob, ModifierData *md)
+{
+	if (modifier_dependsOnTime(md)) {
+		return true;
+	}
+
+	/* Check whether modifier is animated. */
+	/* TODO: this should be handled as part of build_animdata() -- Aligorith */
+	if (ob->adt) {
+		AnimData *adt = ob->adt;
+		FCurve *fcu;
+
+		char pattern[MAX_NAME + 10];
+		/* TODO(sergey): Escape modifier name. */
+		BLI_snprintf(pattern, sizeof(pattern), "modifiers[%s", md->name);
+
+		/* action - check for F-Curves with paths containing 'modifiers[' */
+		if (adt->action) {
+			for (fcu = (FCurve *)adt->action->curves.first;
+			     fcu != NULL;
+			     fcu = (FCurve *)fcu->next)
+			{
+				if (fcu->rna_path && strstr(fcu->rna_path, pattern))
+					return true;
+			}
+		}
+
+		/* This here allows modifier properties to get driven and still update properly
+		 *
+		 * Workaround to get [#26764] (e.g. subsurf levels not updating when animated/driven)
+		 * working, without the updating problems ([#28525] [#28690] [#28774] [#28777]) caused
+		 * by the RNA updates cache introduced in r.38649
+		 */
+		for (fcu = (FCurve *)adt->drivers.first;
+		     fcu != NULL;
+		     fcu = (FCurve *)fcu->next)
+		{
+			if (fcu->rna_path && strstr(fcu->rna_path, pattern))
+				return true;
+		}
+
+		/* XXX: also, should check NLA strips, though for now assume that nobody uses
+		 * that and we can omit that for performance reasons... */
+	}
+
+	return false;
+}




More information about the Bf-blender-cvs mailing list