[Bf-blender-cvs] [50e308c] fracture_modifier: taking now all constraint properties into account when converting back to objects
Martin Felke
noreply at git.blender.org
Fri Jan 22 01:56:52 CET 2016
Commit: 50e308c19cb9d91cccb575ff4f121f3ee4b9e917
Author: Martin Felke
Date: Fri Jan 22 01:56:31 2016 +0100
Branches: fracture_modifier
https://developer.blender.org/rB50e308c19cb9d91cccb575ff4f121f3ee4b9e917
taking now all constraint properties into account when converting back to objects
===================================================================
M source/blender/blenkernel/BKE_rigidbody.h
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/editors/object/object_modifier.c
M source/blender/editors/physics/rigidbody_constraint.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index e4ea460..6eab856 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -63,7 +63,7 @@ void BKE_rigidbody_relink_constraint(struct RigidBodyCon *rbc);
/* create Blender-side settings data - physics objects not initialized yet */
struct RigidBodyWorld *BKE_rigidbody_create_world(struct Scene *scene);
struct RigidBodyOb *BKE_rigidbody_create_object(struct Scene *scene, struct Object *ob, short type);
-struct RigidBodyCon *BKE_rigidbody_create_constraint(struct Scene *scene, struct Object *ob, short type);
+struct RigidBodyCon *BKE_rigidbody_create_constraint(struct Scene *scene, struct Object *ob, short type, struct RigidBodyShardCon *con);
struct RigidBodyOb *BKE_rigidbody_create_shard(struct Scene *scene, struct Object *ob, struct Object *target, struct MeshIsland *mi);
struct RigidBodyShardCon *BKE_rigidbody_create_shard_constraint(struct Scene *scene, short type, bool reset);
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 8664b6b..db99fa4 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -2396,7 +2396,7 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type)
}
/* Add rigid body constraint to the specified object */
-RigidBodyCon *BKE_rigidbody_create_constraint(Scene *scene, Object *ob, short type)
+RigidBodyCon *BKE_rigidbody_create_constraint(Scene *scene, Object *ob, short type, RigidBodyShardCon *con)
{
RigidBodyCon *rbc;
RigidBodyWorld *rbw = scene->rigidbody_world;
@@ -2421,33 +2421,67 @@ RigidBodyCon *BKE_rigidbody_create_constraint(Scene *scene, Object *ob, short ty
rbc->flag |= RBC_FLAG_ENABLED;
rbc->flag |= RBC_FLAG_DISABLE_COLLISIONS;
- rbc->breaking_threshold = 10.0f; /* no good default here, just use 10 for now */
- rbc->num_solver_iterations = 10; /* 10 is Bullet default */
-
- rbc->limit_lin_x_lower = -1.0f;
- rbc->limit_lin_x_upper = 1.0f;
- rbc->limit_lin_y_lower = -1.0f;
- rbc->limit_lin_y_upper = 1.0f;
- rbc->limit_lin_z_lower = -1.0f;
- rbc->limit_lin_z_upper = 1.0f;
- rbc->limit_ang_x_lower = -M_PI_4;
- rbc->limit_ang_x_upper = M_PI_4;
- rbc->limit_ang_y_lower = -M_PI_4;
- rbc->limit_ang_y_upper = M_PI_4;
- rbc->limit_ang_z_lower = -M_PI_4;
- rbc->limit_ang_z_upper = M_PI_4;
-
- rbc->spring_damping_x = 0.5f;
- rbc->spring_damping_y = 0.5f;
- rbc->spring_damping_z = 0.5f;
- rbc->spring_stiffness_x = 10.0f;
- rbc->spring_stiffness_y = 10.0f;
- rbc->spring_stiffness_z = 10.0f;
-
- rbc->motor_lin_max_impulse = 1.0f;
- rbc->motor_lin_target_velocity = 1.0f;
- rbc->motor_ang_max_impulse = 1.0f;
- rbc->motor_ang_target_velocity = 1.0f;
+ if (con)
+ {
+ rbc->flag = con->flag;
+ rbc->breaking_threshold = con->breaking_threshold;
+ rbc->num_solver_iterations = con->num_solver_iterations;
+
+ rbc->limit_lin_x_lower = con->limit_lin_x_lower;
+ rbc->limit_lin_x_upper = con->limit_lin_x_upper;
+ rbc->limit_lin_y_lower = con->limit_lin_y_lower;
+ rbc->limit_lin_y_upper = con->limit_lin_y_upper;
+ rbc->limit_lin_z_lower = con->limit_lin_z_lower;
+ rbc->limit_lin_z_upper = con->limit_lin_z_upper;
+ rbc->limit_ang_x_lower = con->limit_ang_x_lower;
+ rbc->limit_ang_x_upper = con->limit_ang_x_upper;
+ rbc->limit_ang_y_lower = con->limit_ang_y_lower;
+ rbc->limit_ang_y_upper = con->limit_ang_y_upper;
+ rbc->limit_ang_z_lower = con->limit_ang_z_lower;
+ rbc->limit_ang_z_upper = con->limit_ang_z_upper;
+
+ rbc->spring_damping_x = con->spring_damping_x;
+ rbc->spring_damping_y = con->spring_damping_y;
+ rbc->spring_damping_z = con->spring_damping_z;
+ rbc->spring_stiffness_x = con->spring_stiffness_x;
+ rbc->spring_stiffness_y = con->spring_stiffness_y;
+ rbc->spring_stiffness_z = con->spring_stiffness_z;
+
+ rbc->motor_lin_max_impulse = con->motor_lin_max_impulse;
+ rbc->motor_lin_target_velocity = con->motor_lin_target_velocity;
+ rbc->motor_ang_max_impulse = con->motor_ang_max_impulse;
+ rbc->motor_ang_target_velocity = con->motor_ang_target_velocity;
+ }
+ else
+ {
+ rbc->breaking_threshold = 10.0f; /* no good default here, just use 10 for now */
+ rbc->num_solver_iterations = 10; /* 10 is Bullet default */
+
+ rbc->limit_lin_x_lower = -1.0f;
+ rbc->limit_lin_x_upper = 1.0f;
+ rbc->limit_lin_y_lower = -1.0f;
+ rbc->limit_lin_y_upper = 1.0f;
+ rbc->limit_lin_z_lower = -1.0f;
+ rbc->limit_lin_z_upper = 1.0f;
+ rbc->limit_ang_x_lower = -M_PI_4;
+ rbc->limit_ang_x_upper = M_PI_4;
+ rbc->limit_ang_y_lower = -M_PI_4;
+ rbc->limit_ang_y_upper = M_PI_4;
+ rbc->limit_ang_z_lower = -M_PI_4;
+ rbc->limit_ang_z_upper = M_PI_4;
+
+ rbc->spring_damping_x = 0.5f;
+ rbc->spring_damping_y = 0.5f;
+ rbc->spring_damping_z = 0.5f;
+ rbc->spring_stiffness_x = 10.0f;
+ rbc->spring_stiffness_y = 10.0f;
+ rbc->spring_stiffness_z = 10.0f;
+
+ rbc->motor_lin_max_impulse = 1.0f;
+ rbc->motor_lin_target_velocity = 1.0f;
+ rbc->motor_ang_max_impulse = 1.0f;
+ rbc->motor_ang_target_velocity = 1.0f;
+ }
/* flag cache as outdated */
BKE_rigidbody_cache_reset(rbw);
@@ -3500,7 +3534,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
/* Since this object is included in the group but doesn't have
* constraint settings (perhaps it was added manually), add!
*/
- ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, RBC_TYPE_FIXED);
+ ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, RBC_TYPE_FIXED, NULL);
rigidbody_validate_sim_constraint(rbw, ob, true);
rbc = ob->rigidbody_constraint;
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 6a72937..2ac55c5 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2651,7 +2651,7 @@ static void do_add_group_unchecked(Group* group, Object *ob, Base *bas)
bas->flag |= OB_FROMGROUP;
}
-static bool do_unchecked_constraint_add(Scene *scene, Object *ob, int type, ReportList *reports, Base* base)
+static bool do_unchecked_constraint_add(Scene *scene, Object *ob, RigidBodyShardCon *con, ReportList *reports, Base* base)
{
RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene);
@@ -2665,7 +2665,7 @@ static bool do_unchecked_constraint_add(Scene *scene, Object *ob, int type, Repo
rbw->constraints = BKE_group_add(G.main, "RigidBodyConstraints");
}
/* make rigidbody constraint settings */
- ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, type);
+ ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, con->type, con);
ob->rigidbody_constraint->flag |= RBC_FLAG_NEEDS_VALIDATE;
/* add constraint to rigid body constraint group */
@@ -2845,7 +2845,7 @@ static Object* do_convert_constraints(FractureModifierData *fmd, RigidBodyShardC
iterations = fmd->solver_iterations_override;
}
- if (iterations > 0) {
+ if (iterations > 0 && fmd->fracture_mode != MOD_FRACTURE_EXTERNAL) {
con->flag |= RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS;
con->num_solver_iterations = iterations;
}
@@ -2882,12 +2882,12 @@ static Object* do_convert_constraints(FractureModifierData *fmd, RigidBodyShardC
}
/*omit check for existing objects in group, since this seems very slow, and should not be necessary in this internal function*/
- do_unchecked_constraint_add(scene, rbcon, con->type, reports, *base);
+ do_unchecked_constraint_add(scene, rbcon, con, reports, *base);
rbcon->rigidbody_constraint->ob1 = ob1;
rbcon->rigidbody_constraint->ob2 = ob2;
- rbcon->rigidbody_constraint->breaking_threshold = con->breaking_threshold;
- rbcon->rigidbody_constraint->flag |= RBC_FLAG_USE_BREAKING;
+ //rbcon->rigidbody_constraint->breaking_threshold = con->breaking_threshold;
+ //rbcon->rigidbody_constraint->flag |= RBC_FLAG_USE_BREAKING;
if (con->flag & RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS) {
rbcon->rigidbody_constraint->flag |= RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS;
diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c
index cf44a5c..83f1637 100644
--- a/source/blender/editors/physics/rigidbody_constraint.c
+++ b/source/blender/editors/physics/rigidbody_constraint.c
@@ -87,7 +87,7 @@ bool ED_rigidbody_constraint_add(Scene *scene, Object *ob, int type, ReportList
rbw->constraints = BKE_group_add(G.main, "RigidBodyConstraints");
}
/* make rigidbody constraint settings */
- ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, type);
+ ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, type, NULL);
ob->rigidbody_constraint->flag |= RBC_FLAG_NEEDS_VALIDATE;
/* add constraint to rigid body constraint group */
More information about the Bf-blender-cvs
mailing list