[Bf-blender-cvs] [646a96b] master: Fix T42952: Curve modifier not taken into account when curve is created from mesh

Sergey Sharybin noreply at git.blender.org
Mon Dec 22 15:06:07 CET 2014


Commit: 646a96bf8edc211a06f3df652101c265ee166e8d
Author: Sergey Sharybin
Date:   Mon Dec 22 19:02:47 2014 +0500
Branches: master
https://developer.blender.org/rB646a96bf8edc211a06f3df652101c265ee166e8d

Fix T42952: Curve modifier not taken into account when curve is created from mesh

Curve and array modifiers requires curve path to be evaluated, dependency graph
will make sure that curve eval would create such a path, but if curve was already
evaluated we might miss path.

So what we do now is: if path was not calculated for target curve we tag it for
update.

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

M	source/blender/makesrna/intern/rna_modifier.c

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

diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 7058e90..cc7c978 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -130,6 +130,7 @@ EnumPropertyItem modifier_triangulate_ngon_method_items[] = {
 #ifdef RNA_RUNTIME
 
 #include "DNA_particle_types.h"
+#include "DNA_curve_types.h"
 #include "DNA_smoke_types.h"
 
 #include "BKE_context.h"
@@ -604,6 +605,40 @@ static int rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr)
 	return ((lmd->flag & MOD_LAPLACIANDEFORM_BIND) && (lmd->cache_system != NULL));
 }
 
+/* NOTE: Curve and array modifiers requires curve path to be evaluated,
+ * dependency graph will make sure that curve eval would create such a path,
+ * but if curve was already evaluated we might miss path.
+ *
+ * So what we do here is: if path was not calculated for target curve we
+ * tag it for update.
+ */
+
+static void rna_CurveModifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+	CurveModifierData *cmd = (CurveModifierData *)ptr->data;
+	rna_Modifier_update(bmain, scene, ptr);
+	DAG_relations_tag_update(bmain);
+	if (cmd->object != NULL) {
+		Curve *curve = cmd->object->data;
+		if ((curve->flag & CU_PATH) == 0) {
+			DAG_id_tag_update(&curve->id, OB_RECALC_DATA);
+		}
+	}
+}
+
+static void rna_ArrayModifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+	ArrayModifierData *amd = (ArrayModifierData *)ptr->data;
+	rna_Modifier_update(bmain, scene, ptr);
+	DAG_relations_tag_update(bmain);
+	if (amd->curve_ob != NULL) {
+		Curve *curve = amd->curve_ob->data;
+		if ((curve->flag & CU_PATH) == 0) {
+			DAG_id_tag_update(&curve->id, OB_RECALC_DATA);
+		}
+	}
+}
+
 #else
 
 static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[])
@@ -876,7 +911,7 @@ static void rna_def_modifier_curve(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Object", "Curve object to deform with");
 	RNA_def_property_pointer_funcs(prop, NULL, "rna_CurveModifier_object_set", NULL, "rna_Curve_object_poll");
 	RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
-	RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
+	RNA_def_property_update(prop, 0, "rna_CurveModifier_dependency_update");
 
 	prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
 	RNA_def_property_string_sdna(prop, NULL, "name");
@@ -1399,7 +1434,7 @@ static void rna_def_modifier_array(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Curve", "Curve object to fit array length to");
 	RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_curve_ob_set", NULL, "rna_Curve_object_poll");
 	RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
-	RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
+	RNA_def_property_update(prop, 0, "rna_ArrayModifier_dependency_update");
 
 	/* Offset parameters */
 	prop = RNA_def_property(srna, "use_constant_offset", PROP_BOOLEAN, PROP_NONE);




More information about the Bf-blender-cvs mailing list