Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Felke <martin.felke@googlemail.com>2018-08-12 15:54:57 +0300
committerMartin Felke <martin.felke@googlemail.com>2018-08-12 15:54:57 +0300
commitd846f810b2b76987ebd2044c3482e7de8a534ee2 (patch)
tree7efdff05b1a79ed0444f178c9723d0c4f5969e77
parentc5cf0667cb7c0b28feade2b7fa8c59f2fde2fa25 (diff)
added autohide filtering based on filter object vertex positions
mesh objects now use their verts and a distance, while empties (or other non-mesh objects) still use the maximum of the object size as radius
-rw-r--r--release/scripts/startup/bl_operators/presets.py1
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_fracture.py5
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_fracture.c8
-rw-r--r--source/blender/modifiers/intern/MOD_fracture.c68
5 files changed, 75 insertions, 10 deletions
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index 24f956b773c..baa33e85f5f 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -715,6 +715,7 @@ class AddPresetFracture(AddPresetBase, Operator):
"fracture.grid_offset",
"fracture.grid_spacing",
"fracture.use_constraint_group",
+ "fracture.autohide_filter_dist",
]
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 20efd1f0557..933ae296e4b 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -303,7 +303,10 @@ class PHYSICS_PT_fracture_utilities(PhysicButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
md = context.fracture
- layout.prop(md, "autohide_filter_group", text = "Filter Group")
+ col = layout.column()
+ col.prop(md, "autohide_filter_group", text = "Filter Group")
+ if md.autohide_filter_group:
+ col.prop(md, "autohide_filter_dist")
col = layout.column(align=True)
col.prop(md, "autohide_dist")
col.prop(md, "automerge_dist")
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index cd70132c254..4fd719af672 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1824,6 +1824,7 @@ typedef struct FractureModifierData {
float anim_bind_limit;
float grid_offset[3];
float grid_spacing[3];
+ float autohide_filter_dist;
/* flags */
int refresh;
@@ -1885,7 +1886,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 9a16ecd7755..a4f1ff67e5a 100644
--- a/source/blender/makesrna/intern/rna_fracture.c
+++ b/source/blender/makesrna/intern/rna_fracture.c
@@ -1584,5 +1584,13 @@ 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, "autohide_filter_dist", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "autohide_filter_dist");
+ RNA_def_property_range(prop, 0, FLT_MAX);
+ RNA_def_property_ui_text(prop, "Filter Distance", "Distance between verts of filter objects and face centers of object");
+ RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 0.1f, 3);
+ //RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ 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 6dbf8e80ff0..2734622c557 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -273,6 +273,7 @@ static void initData(ModifierData *md)
zero_v3(fmd->grid_spacing);
fmd->use_constraint_group = false;
fmd->activate_broken = false;
+ fmd->autohide_filter_dist = 0.1f;
}
//XXX TODO, freeing functionality should be in BKE too
@@ -1929,6 +1930,8 @@ static void copyData(ModifierData *md, ModifierData *target)
trmd->use_constraint_group = rmd->use_constraint_group;
trmd->activate_broken = rmd->activate_broken;
+
+ trmd->autohide_filter_dist = rmd->autohide_filter_dist;
}
//XXXX TODO, is BB really useds still ? aint there exact volume calc now ?
@@ -3389,22 +3392,71 @@ static void find_other_face(FractureModifierData *fmd, int i, BMesh* bm, Object*
/*if not in any filter range, delete... else keep */
Object* obj = go->ob;
float f1_loc[3], f2_loc[3];
- float radius = MAX3(obj->size[0], obj->size[1], obj->size[2]);
+
+ float radius = fmd->autohide_filter_dist;
/* TODO XXX watch out if go->ob is parented to ob (Transformation error ?) */
mul_v3_m4v3(f1_loc, ob->obmat, f_centr);
mul_v3_m4v3(f2_loc, ob->obmat, f_centr_other);
radius = radius * radius;
- if ((len_squared_v3v3(f1_loc, obj->loc) < radius) &&
- (len_squared_v3v3(f2_loc, obj->loc) < radius))
+ if (obj->type == OB_MESH)
{
- in_filter = true;
- break;
+ //use geometry of meshes
+ MVert* mvert = NULL, *mv = NULL;
+ DerivedMesh *dm = obj->derivedFinal;
+ bool final = true;
+ int totvert, v;
+
+ if (!dm) {
+ dm = CDDM_from_mesh(obj->data);
+ final = false;
+ }
+
+ mvert = dm->getVertArray(dm);
+ totvert = dm->getNumVerts(dm);
+
+ for (v = 0, mv = mvert; v < totvert; v++, mv++)
+ {
+ float loc[3];
+ mul_v3_m4v3(loc, obj->obmat, mv->co);
+
+ if ((len_squared_v3v3(f1_loc, loc) < radius) &&
+ (len_squared_v3v3(f2_loc, loc) < radius))
+ {
+ in_filter = true;
+ break;
+ }
+ else
+ {
+ in_filter = false;
+ }
+ }
+
+ if (!final && dm)
+ {
+ dm->needsFree = 1;
+ dm->release(dm);
+ dm = NULL;
+ }
+
+ if (in_filter)
+ break;
}
- else
- {
- in_filter = false;
+ else {
+ //override with object size here, makes more sense
+ radius = MAX3(obj->size[0], obj->size[1], obj->size[2]);
+
+ if ((len_squared_v3v3(f1_loc, obj->loc) < radius) &&
+ (len_squared_v3v3(f2_loc, obj->loc) < radius))
+ {
+ in_filter = true;
+ break;
+ }
+ else
+ {
+ in_filter = false;
+ }
}
}
}