[Bf-blender-cvs] [8af66d6088e] fracture_modifier: versioning fixes for angular spring stiffness / damping and exposed those to FM python api

Martin Felke noreply at git.blender.org
Sun Aug 13 01:39:20 CEST 2017


Commit: 8af66d6088e78ec7fcb21628860a7eeb6f963c11
Author: Martin Felke
Date:   Sun Aug 13 01:39:10 2017 +0200
Branches: fracture_modifier
https://developer.blender.org/rB8af66d6088e78ec7fcb21628860a7eeb6f963c11

versioning fixes for angular spring stiffness / damping and exposed those to FM python api

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

M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/makesrna/intern/rna_fracture_api.c

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

diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index b139b84d5be..2a6b2b0f70a 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -3467,6 +3467,20 @@ static void rigidbody_set_springs_active(RigidBodyShardCon *rbc, bool active)
 			RB_constraint_set_spring_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, rbc->flag & RBC_FLAG_USE_SPRING_Z);
 			RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, rbc->spring_stiffness_z);
 			RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, rbc->spring_damping_z);
+
+#if 0
+			RB_constraint_set_spring_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_X, rbc->flag & RBC_FLAG_USE_SPRING_ANG_X);
+			RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_X, rbc->spring_stiffness_ang_x);
+			RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_X, rbc->spring_damping_ang_x);
+
+			RB_constraint_set_spring_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Y, rbc->flag & RBC_FLAG_USE_SPRING_ANG_Y);
+			RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Y, rbc->spring_stiffness_ang_y);
+			RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Y, rbc->spring_damping_ang_y);
+
+			RB_constraint_set_spring_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Z, rbc->flag & RBC_FLAG_USE_SPRING_ANG_Z);
+			RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Z, rbc->spring_stiffness_ang_z);
+			RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Z, rbc->spring_damping_ang_z);
+#endif
 		}
 		else
 		{
@@ -3481,6 +3495,20 @@ static void rigidbody_set_springs_active(RigidBodyShardCon *rbc, bool active)
 			RB_constraint_set_spring_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, rbc->flag & RBC_FLAG_USE_SPRING_Z);
 			RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, 0);
 			RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, rbc->spring_damping_z);
+
+#if 0
+			RB_constraint_set_spring_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_X, rbc->flag & RBC_FLAG_USE_SPRING_ANG_X);
+			RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_X, 0);
+			RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_X, rbc->spring_damping_ang_x);
+
+			RB_constraint_set_spring_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Y, rbc->flag & RBC_FLAG_USE_SPRING_ANG_Y);
+			RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Y, 0);
+			RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Y, rbc->spring_damping_ang_y);
+
+			RB_constraint_set_spring_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Z, rbc->flag & RBC_FLAG_USE_SPRING_ANG_Z);
+			RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Z, 0);
+			RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Z, rbc->spring_damping_ang_z);
+#endif
 		}
 	}
 }
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 3e7108eef79..38c84fb94f5 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1685,6 +1685,42 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 		for (Mesh *me = main->mesh.first; me; me = me->id.next) {
 			CustomData_set_layer_name(&me->vdata, CD_MDEFORMVERT, 0, "");
 		}
+
+		for (Object *ob = main->object.first; ob != NULL; ob = ob->id.next) {
+			/*initialize older blends to useful values */
+			FractureModifierData *fmd = (FractureModifierData* )modifiers_findByType(ob, eModifierType_Fracture);
+			if (fmd != NULL)
+			{
+				for (RigidBodyShardCon *rbsc = fmd->meshConstraints.first; rbsc != NULL; rbsc =  rbsc->next)
+				{
+					/* before 2.79, the FM constraint flag values were different, so adapt this here */
+					if (rbsc->flag & RBC_FLAG_USE_SPRING_ANG_X)
+					{
+						rbsc->flag &= ~RBC_FLAG_USE_SPRING_ANG_X;
+						rbsc->flag |= RBC_FLAG_USE_KINEMATIC_DEACTIVATION;
+					}
+
+					if (rbsc->flag & RBC_FLAG_USE_SPRING_ANG_Y)
+					{
+						rbsc->flag &= ~RBC_FLAG_USE_SPRING_ANG_Y;
+						rbsc->flag |= RBC_FLAG_USE_PLASTIC;
+					}
+
+					if (rbsc->flag & RBC_FLAG_USE_SPRING_ANG_Z)
+					{
+						rbsc->flag &= ~RBC_FLAG_USE_SPRING_ANG_Z;
+						rbsc->flag |= RBC_FLAG_PLASTIC_ACTIVE;
+					}
+
+					rbsc->spring_stiffness_ang_x = 10.0;
+					rbsc->spring_stiffness_ang_y = 10.0;
+					rbsc->spring_stiffness_ang_z = 10.0;
+					rbsc->spring_damping_ang_x = 0.5;
+					rbsc->spring_damping_ang_y = 0.5;
+					rbsc->spring_damping_ang_z = 0.5;
+				}
+			}
+		}
 	}
 }
 
diff --git a/source/blender/makesrna/intern/rna_fracture_api.c b/source/blender/makesrna/intern/rna_fracture_api.c
index 34216ac360e..0d748798b37 100644
--- a/source/blender/makesrna/intern/rna_fracture_api.c
+++ b/source/blender/makesrna/intern/rna_fracture_api.c
@@ -261,6 +261,45 @@ static void rna_MeshCon_spring_stiffness_z_set(PointerRNA *ptr, float value)
 #endif
 }
 
+static void rna_MeshCon_spring_stiffness_ang_x_set(PointerRNA *ptr, float value)
+{
+	RigidBodyShardCon *rbc = (RigidBodyShardCon *)ptr->data;
+
+	rbc->spring_stiffness_ang_x = value;
+
+#ifdef WITH_BULLET
+	if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_ANG_X)) {
+		RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_X, value);
+	}
+#endif
+}
+
+static void rna_MeshCon_spring_stiffness_ang_y_set(PointerRNA *ptr, float value)
+{
+	RigidBodyShardCon *rbc = (RigidBodyShardCon *)ptr->data;
+
+	rbc->spring_stiffness_ang_y = value;
+
+#ifdef WITH_BULLET
+	if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_ANG_Y)) {
+		RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Y, value);
+	}
+#endif
+}
+
+static void rna_MeshCon_spring_stiffness_ang_z_set(PointerRNA *ptr, float value)
+{
+	RigidBodyShardCon *rbc = (RigidBodyShardCon *)ptr->data;
+
+	rbc->spring_stiffness_ang_z = value;
+
+#ifdef WITH_BULLET
+	if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_ANG_Z)) {
+		RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Z, value);
+	}
+#endif
+}
+
 static void rna_MeshCon_spring_damping_x_set(PointerRNA *ptr, float value)
 {
 	RigidBodyShardCon *rbc = (RigidBodyShardCon *)ptr->data;
@@ -298,6 +337,43 @@ static void rna_MeshCon_spring_damping_z_set(PointerRNA *ptr, float value)
 #endif
 }
 
+static void rna_MeshCon_spring_damping_ang_x_set(PointerRNA *ptr, float value)
+{
+	RigidBodyShardCon *rbc = (RigidBodyShardCon *)ptr->data;
+
+	rbc->spring_damping_ang_x = value;
+
+#ifdef WITH_BULLET
+	if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_ANG_X)) {
+		RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_X, value);
+	}
+#endif
+}
+
+static void rna_MeshCon_spring_damping_ang_y_set(PointerRNA *ptr, float value)
+{
+	RigidBodyShardCon *rbc = (RigidBodyShardCon *)ptr->data;
+
+	rbc->spring_damping_ang_y = value;
+#ifdef WITH_BULLET
+	if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_ANG_Y)) {
+		RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Y, value);
+	}
+#endif
+}
+
+static void rna_MeshCon_spring_damping_ang_z_set(PointerRNA *ptr, float value)
+{
+	RigidBodyShardCon *rbc = (RigidBodyShardCon *)ptr->data;
+
+	rbc->spring_damping_ang_z = value;
+#ifdef WITH_BULLET
+	if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_ANG_Z)) {
+		RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Z, value);
+	}
+#endif
+}
+
 static void rna_MeshCon_motor_lin_max_impulse_set(PointerRNA *ptr, float value)
 {
 	RigidBodyShardCon *rbc = (RigidBodyShardCon *)ptr->data;
@@ -690,6 +766,21 @@ static void rna_def_mesh_constraint(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Z Spring", "Enable spring on Z axis");
 	//RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+	prop = RNA_def_property(srna, "use_spring_ang_x", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_SPRING_ANG_X);
+	RNA_def_property_ui_text(prop, "X Angle Spring", "Enable spring on X rotational axis");
+	//RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
+
+	prop = RNA_def_property(srna, "use_spring_ang_y", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_SPRING_ANG_Y);
+	RNA_def_property_ui_text(prop, "Y Angle Spring", "Enable spring on Y rotational axis");
+	//RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
+
+	prop = RNA_def_property(srna, "use_spring_ang_z", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_SPRING_ANG_Z);
+	RNA_def_property_ui_text(prop, "Z Angle Spring", "Enable spring on Z rotational axis");
+	//RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
+
 	prop = RNA_def_property(srna, "use_motor_lin", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_MOTOR_LIN);
 	RNA_def_property_boolean_funcs(prop, NULL, "rna_MeshCon_use_motor_lin_set");
@@ -807,6 +898,33 @@ static void rna_def_mesh_constraint(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Z Axis Stiffness", "Stiffness on the Z axis");
 	//RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+	prop = RNA_def_property(srna, "spring_stiffness_ang_x", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "spring_stiffness_ang_x");
+	RNA_def_property_range(prop, 0.0f, FLT_MAX);
+	RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
+	RNA_def_property_float_default(prop, 10.0f);
+	RNA_def_property_float_funcs(prop, NULL, "rna_MeshCon_spring_stiffness_ang_x_set", NULL);
+	RNA_d

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list