Try to get soft body to curve working

This commit is contained in:
Jens Ole Wund 2009-12-28 00:07:24 +00:00
parent 310d417334
commit ff31d2d65c
4 changed files with 43 additions and 3 deletions

@ -264,6 +264,7 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
layout.label(text="Diagnostics:") layout.label(text="Diagnostics:")
layout.prop(softbody, "diagnose") layout.prop(softbody, "diagnose")
layout.prop(softbody, "estimate_matrix")
class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel): class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel):

@ -3608,7 +3608,7 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts,
if(sb){ if(sb){
BodyPoint *bp= sb->bpoint; BodyPoint *bp= sb->bpoint;
int a; int a;
if(sb->solverflags & SBSO_MONITOR ||sb->solverflags & SBSO_ESTIMATEIPO){SB_estimate_transform(ob,sb->lcom,sb->lrot,sb->lscale);} if(sb->solverflags & SBSO_ESTIMATEIPO){SB_estimate_transform(ob,sb->lcom,sb->lrot,sb->lscale);}
/* inverse matrix is not uptodate... */ /* inverse matrix is not uptodate... */
invert_m4_m4(ob->imat, ob->obmat); invert_m4_m4(ob->imat, ob->obmat);
@ -3836,9 +3836,19 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
free_scratch(sb); /* clear if any */ free_scratch(sb); /* clear if any */
sb_new_scratch(sb); /* make a new */ sb_new_scratch(sb); /* make a new */
sb->scratch->needstobuildcollider=1; sb->scratch->needstobuildcollider=1;
zero_v3(sb->lcom);
unit_m3(sb->lrot);
unit_m3(sb->lscale);
/* copy some info to scratch */ /* copy some info to scratch */
if (1) reference_to_scratch(ob); /* wa only need that if we want to reconstruct IPO */ /* we only need that if we want to reconstruct IPO */
if(1) {
reference_to_scratch(ob);
SB_estimate_transform(ob,NULL,NULL,NULL);
SB_estimate_transform(ob,NULL,NULL,NULL);
}
switch(ob->type) { switch(ob->type) {
case OB_MESH: case OB_MESH:
if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob); if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob);

@ -5909,7 +5909,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
SoftBody *sb = 0; SoftBody *sb = 0;
float tipw = 0.5f, tiph = 0.5f,drawsize = 4.0f; float tipw = 0.5f, tiph = 0.5f,drawsize = 4.0f;
if ((sb= ob->soft)){ if ((sb= ob->soft)){
if(sb->solverflags & SBSO_MONITOR ||sb->solverflags & SBSO_ESTIMATEIPO){ if(sb->solverflags & SBSO_ESTIMATEIPO){
wmLoadMatrix(rv3d->viewmat); wmLoadMatrix(rv3d->viewmat);
copy_m3_m3(msc,sb->lscale); copy_m3_m3(msc,sb->lscale);

@ -1381,6 +1381,8 @@ static void rna_def_softbody(BlenderRNA *brna)
{ {
StructRNA *srna; StructRNA *srna;
PropertyRNA *prop; PropertyRNA *prop;
int matrix_dimsize[]= {3, 3};
static EnumPropertyItem collision_type_items[] = { static EnumPropertyItem collision_type_items[] = {
{SBC_MODE_MANUAL, "MANUAL", 0, "Manual", "Manual adjust"}, {SBC_MODE_MANUAL, "MANUAL", 0, "Manual", "Manual adjust"},
@ -1586,6 +1588,33 @@ static void rna_def_softbody(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_MONITOR); RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_MONITOR);
RNA_def_property_ui_text(prop, "Print Performance to Console", "Turn on SB diagnose console prints"); RNA_def_property_ui_text(prop, "Print Performance to Console", "Turn on SB diagnose console prints");
prop= RNA_def_property(srna, "estimate_matrix", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_ESTIMATEIPO);
RNA_def_property_ui_text(prop, "Estimate matrix", "esimate matrix .. split to COM , ROT ,SCALE ");
/***********************************************************************************/
/* these are not exactly settings, but reading calculated results*/
/* but i did not want to start a new property struct */
/* so rather rename this from SoftBodySettings to SoftBody */
/* translation */
prop= RNA_def_property(srna, "lcom", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "lcom");
RNA_def_property_ui_text(prop, "Center of mass", "Location of Center of mass.");
/* matrix */
prop= RNA_def_property(srna, "lrot", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "lrot");
RNA_def_property_multi_array(prop, 2, matrix_dimsize);
RNA_def_property_ui_text(prop, "Rot Matrix", "Estimated rotation matrix.");
prop= RNA_def_property(srna, "lscale", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "lscale");
RNA_def_property_multi_array(prop, 2, matrix_dimsize);
RNA_def_property_ui_text(prop, "Scale Matrix", "Estimated scale matrix.");
/***********************************************************************************/
/* Flags */ /* Flags */
prop= RNA_def_property(srna, "use_goal", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "use_goal", PROP_BOOLEAN, PROP_NONE);