[Bf-blender-cvs] [80671518ebc] fracture_modifier: put animated mesh settings to new panel, some fixes
Martin Felke
noreply at git.blender.org
Sun Jan 14 20:14:27 CET 2018
Commit: 80671518ebc0d832ecefb2205fe143d06432e98b
Author: Martin Felke
Date: Sun Jan 14 20:12:53 2018 +0100
Branches: fracture_modifier
https://developer.blender.org/rB80671518ebc0d832ecefb2205fe143d06432e98b
put animated mesh settings to new panel, some fixes
===================================================================
M release/scripts/startup/bl_operators/presets.py
M release/scripts/startup/bl_ui/properties_physics_fracture.py
M source/blender/blenkernel/intern/fracture.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_fracture.c
M source/blender/modifiers/intern/MOD_fracture.c
===================================================================
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index ecfdfe8fbb3..0e1e0371f14 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -708,6 +708,7 @@ class AddPresetFracture(AddPresetBase, Operator):
"fracture.acceleration_fade",
"fracture.use_animated_mesh",
"fracture.animated_mesh_input",
+ "fracture.use_animated_mesh_rotation",
]
preset_subdir = "fracture"
diff --git a/release/scripts/startup/bl_ui/properties_physics_fracture.py b/release/scripts/startup/bl_ui/properties_physics_fracture.py
index d0ffd3e8d73..3f7efb69e66 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -40,21 +40,29 @@ class PhysicButtonsPanel():
rd = context.scene.render
return (ob and (ob.type == 'MESH' or ob.type == 'CURVE' or ob.type == 'SURFACE' or ob.type == 'FONT')) and (not rd.use_game_engine) and (context.fracture)
-class FRACTURE_UL_fracture_settings(UIList):
- def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
- fl = item
- if self.layout_type in {'DEFAULT', 'COMPACT'}:
- layout.prop(fl, "name", text="", emboss=False, icon_value=icon)
- elif self.layout_type in {'GRID'}:
- layout.alignment = 'CENTER'
- layout.label(text="", icon_value=icon)
-
-#class PHYSICS_PT_fracture_settings(PhysicButtonsPanel, Panel):
-# bl_label = "Fracture Settings"
-
-# def draw(self, context):
-# layout = self.layout
-# md = context.fracture
+#class FRACTURE_UL_fracture_settings(UIList):
+# def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
+# fl = item
+# if self.layout_type in {'DEFAULT', 'COMPACT'}:
+# layout.prop(fl, "name", text="", emboss=False, icon_value=icon)
+# elif self.layout_type in {'GRID'}:
+# layout.alignment = 'CENTER'
+# layout.label(text="", icon_value=icon)
+
+class PHYSICS_PT_fracture_anim_mesh(PhysicButtonsPanel, Panel):
+ bl_label = "Fracture Animated Mesh Settings"
+
+ def draw(self, context):
+ layout = self.layout
+ md = context.fracture
+ layout.context_pointer_set("modifier", md)
+ row = layout.row()
+ row.prop(md, "use_animated_mesh")
+ row.prop(md, "use_animated_mesh_rotation")
+ row = layout.row()
+ row.prop(md, "animated_mesh_input")
+ row = layout.row()
+ row.operator("object.fracture_anim_bind", text="Bind", icon="UV_VERTEXSEL")
# layout.template_list("FRACTURE_UL_fracture_settings", "", md, "fracture_settings", md, "active_setting", rows=3)
@@ -131,12 +139,6 @@ class PHYSICS_PT_fracture(PhysicButtonsPanel, Panel):
row.prop(md, "use_smooth")
row = layout.row()
row.prop(md, "auto_execute")
- row.prop(md, "use_animated_mesh")
- row = layout.row()
- row.prop(md, "animated_mesh_input")
- row = layout.row()
- row.context_pointer_set("modifier", md)
- row.operator("object.fracture_anim_bind", text="Bind", icon="UV_VERTEXSEL")
row = layout.row(align=True)
row.prop(md, "splinter_axis")
layout.prop(md, "splinter_length")
@@ -315,10 +317,11 @@ class PHYSICS_PT_fracture_utilities(PhysicButtonsPanel, Panel):
classes = (
FRACTURE_MT_presets,
- FRACTURE_UL_fracture_settings,
+ #FRACTURE_UL_fracture_settings,
PHYSICS_PT_fracture,
PHYSICS_PT_fracture_simulation,
PHYSICS_PT_fracture_utilities,
+ PHYSICS_PT_fracture_anim_mesh,
)
if __name__ == "__main__": # only for live edit.
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index e2c5b9c4d11..8e0c022ecd3 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -3848,7 +3848,7 @@ void BKE_read_animated_loc_rot(FractureModifierData *fmd, Object *ob, bool do_bi
DerivedMesh *dm = NULL;
int totvert, count = 0, i = 0, *orig_index;
KDTree *tree = NULL;
- float obquat[4];
+ float obquat[4], imat[4][4];
bool *used;
if (!fmd->anim_mesh_ob)
@@ -3863,6 +3863,7 @@ void BKE_read_animated_loc_rot(FractureModifierData *fmd, Object *ob, bool do_bi
return;
totvert = dm->getNumVerts(dm);
+ invert_m4_m4(imat, fmd->anim_mesh_ob->obmat);
if (totvert == 0) {
dm->release(dm);
@@ -3940,6 +3941,7 @@ void BKE_read_animated_loc_rot(FractureModifierData *fmd, Object *ob, bool do_bi
n = MEM_mallocN(sizeof(KDTreeNearest) * count, "nearest");
copy_v3_v3(co, mvert[i].co);
+ //mul_m4_v3(fmd->anim_mesh_ob->obmat, co);
mul_m4_v3(ob->obmat, co);
r = BLI_kdtree_find_nearest_n(tree, co, n, count);
bc = 0;
@@ -4034,7 +4036,8 @@ void BKE_read_animated_loc_rot(FractureModifierData *fmd, Object *ob, bool do_bi
copy_v3_v3(co, mvert[v].co);
sub_v3_v3(co, fmd->anim_bind[i].offset);
- mul_m4_v3(ob->obmat, co);
+ mul_m4_v3(fmd->anim_mesh_ob->obmat, co);
+ //mul_m4_v3(ob->obmat, co);
copy_v3_v3(mi->rigidbody->pos, co);
if (quats)
@@ -4044,20 +4047,19 @@ void BKE_read_animated_loc_rot(FractureModifierData *fmd, Object *ob, bool do_bi
quat[2] = quatZ[v];
quat[3] = quatW[v];
- copy_qt_qt(mi->rigidbody->orn, quat);
+ if (fmd->anim_mesh_rot) {
+ mul_qt_qtqt(quat, obquat, quat);
+ copy_qt_qt(mi->rigidbody->orn, quat);
+ }
}
else {
float no[3], vec[3] = {0, 0, 1}, quat[4];
normal_short_to_float_v3(no, mvert[v].no);
- if (dot_v3v3(vec, no) >= 0) {
- //if difference too strong ?
- rotation_between_vecs_to_quat(quat, vec, no);
- }
- else {
- unit_qt(quat);
+ rotation_between_vecs_to_quat(quat, vec, no);
+ if (fmd->anim_mesh_rot) {
+ mul_qt_qtqt(quat, obquat, quat);
+ copy_qt_qt(mi->rigidbody->orn, quat);
}
- mul_qt_qtqt(quat, obquat, quat);
- copy_qt_qt(mi->rigidbody->orn, quat);
}
mi->rigidbody->flag |= RBO_FLAG_NEEDS_VALIDATE;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 86c95f635db..ae63f52abc9 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1745,6 +1745,7 @@ typedef struct FractureModifierData {
int active_setting;
int anim_bind_len;
+ int anim_mesh_rot;
/* values */
int frac_algorithm;
@@ -1866,7 +1867,7 @@ typedef struct FractureModifierData {
short mat_ofs_intersect;
short mat_ofs_difference;
- char pad[4];
+ //char pad[4];
} FractureModifierData;
typedef struct DataTransferModifierData {
diff --git a/source/blender/makesrna/intern/rna_fracture.c b/source/blender/makesrna/intern/rna_fracture.c
index 90aef5fe20f..6e3b075f528 100644
--- a/source/blender/makesrna/intern/rna_fracture.c
+++ b/source/blender/makesrna/intern/rna_fracture.c
@@ -1515,5 +1515,10 @@ void RNA_def_fracture(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "use_animated_mesh_rotation", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "anim_mesh_rot", false);
+ RNA_def_property_ui_text(prop, "Use Rotation", "Allow moving original vertices to rotate the shards as well");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
RNA_api_fracture(brna, srna);
}
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 206a888f207..a8c289a12bf 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -266,6 +266,7 @@ static void initData(ModifierData *md)
fmd->anim_mesh_ob = NULL;
fmd->anim_bind = NULL;
fmd->anim_bind_len = 0;
+ fmd->anim_mesh_rot = false;
}
//XXX TODO, freeing functionality should be in BKE too
@@ -1881,6 +1882,7 @@ static void copyData(ModifierData *md, ModifierData *target)
trmd->anim_bind_len = 0; //rmd->anim_bind_len;
trmd->anim_bind = NULL;
//memcpy(trmd->anim_bind, rmd->anim_bind, sizeof(int) * trmd->anim_bind_len);
+ trmd->anim_mesh_rot = rmd->anim_mesh_rot;
}
//XXXX TODO, is BB really useds still ? aint there exact volume calc now ?
More information about the Bf-blender-cvs
mailing list