Commit: a715ef9f7fe4a62104178cd985a2c95e305222a8
Author: Martin Felke
Date:   Tue Feb 3 18:02:13 2015 +0100
Branches: fracture_modifier
https://developer.blender.org/rBa715ef9f7fe4a62104178cd985a2c95e305222a8

allow independent setting of cuts and iterations (please PLEASE keep low like 
about 5 max but not at the same time ! or computation time will explode) but 
this allows some control over fractal pattern,
also allow smoothing of inner faces

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

M       release/scripts/startup/bl_ui/properties_physics_fracture.py
M       source/blender/blenkernel/BKE_fracture.h
M       source/blender/blenkernel/BKE_fracture_util.h
M       source/blender/blenkernel/intern/fracture.c
M       source/blender/blenkernel/intern/fracture_util.c
M       source/blender/makesdna/DNA_modifier_types.h
M       source/blender/makesrna/intern/rna_modifier.c
M       source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_fracture.py 
b/release/scripts/startup/bl_ui/properties_physics_fracture.py
index 3dd6a78..1ab195e 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -80,9 +80,12 @@ class PHYSICS_PT_fracture(PhysicButtonsPanel, Panel):
         if md.frac_algorithm == 'BOOLEAN_FRACTAL':
             layout.prop(md, "inner_material")
             col = layout.column(align=True)
-            col.prop(md, "fractal_cuts")
-            col.prop(md, "fractal_amount")
-            col.prop(md, "physics_mesh_scale")
+            row = col.row(align=True)
+            row.prop(md, "fractal_cuts")
+            row.prop(md, "fractal_iterations")
+            row = col.row(align=True)
+            row.prop(md, "fractal_amount")
+            row.prop(md, "physics_mesh_scale")
         row = layout.row()
         row.prop(md, "shards_to_islands")
         row.prop(md, "auto_execute")
diff --git a/source/blender/blenkernel/BKE_fracture.h 
b/source/blender/blenkernel/BKE_fracture.h
index 1d0a95c..e88166b 100644
--- a/source/blender/blenkernel/BKE_fracture.h
+++ b/source/blender/blenkernel/BKE_fracture.h
@@ -83,7 +83,7 @@ struct DerivedMesh *BKE_shard_create_dm(struct Shard *s, bool 
doCustomData);
 
 /* create shards from base mesh and a liste of points */
 void BKE_fracture_shard_by_points(struct FracMesh *fmesh, ShardID id, struct 
FracPointCloud *points, int algorithm,
-                                  struct Object *obj, struct DerivedMesh 
*dm,short inner_material_index, float mat[4][4], int num_cuts, float fractal);
+                                  struct Object *obj, struct DerivedMesh *dm, 
short inner_material_index, float mat[4][4], int num_cuts, float fractal, bool 
smooth, int num_levels);
 
 
 #endif /* BKE_FRACTURE_H */
diff --git a/source/blender/blenkernel/BKE_fracture_util.h 
b/source/blender/blenkernel/BKE_fracture_util.h
index ea016a8..a06e563 100644
--- a/source/blender/blenkernel/BKE_fracture_util.h
+++ b/source/blender/blenkernel/BKE_fracture_util.h
@@ -35,7 +35,7 @@
 
 #include "DNA_fracture_types.h"
 
-Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh *dm_parent, Shard* 
child, short inner_material_index, int num_cuts, float fractal, Shard **other, 
float mat[4][4], float radius, bool use_smooth_inner);
+Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh *dm_parent, Shard* 
child, short inner_material_index, int num_cuts, float fractal, Shard **other, 
float mat[4][4], float radius, bool use_smooth_inner, int num_levels);
 Shard *BKE_fracture_shard_bisect(struct BMesh *bm_orig, Shard* child, float 
obmat[4][4], bool use_fill,
                                  bool clear_inner, bool clear_outer, int 
cutlimit, float centroid[],
                                  short inner_mat_index);
diff --git a/source/blender/blenkernel/intern/fracture.c 
b/source/blender/blenkernel/intern/fracture.c
index 4214021..e7f37f9 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -382,7 +382,7 @@ FracMesh *BKE_create_fracture_container(void)
 
 
 /* parse the voro++ cell data */
-static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, 
FracMesh *fm, int algorithm, Object *obj, DerivedMesh *dm, short 
inner_material_index, float mat[4][4], int num_cuts, float fractal)
+static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, 
FracMesh *fm, int algorithm, Object *obj, DerivedMesh *dm, short 
inner_material_index, float mat[4][4], int num_cuts, float fractal, bool 
smooth, int num_levels)
 {
        /*Parse voronoi raw data*/
        int i = 0;
@@ -454,7 +454,7 @@ static void parse_cells(cell *cells, int expected_shards, 
ShardID parent_id, Fra
 
                        /* XXX TODO, need object for material as well, or 
atleast a material index... */
                        if (algorithm == MOD_FRACTURE_BOOLEAN) {
-                               s = BKE_fracture_shard_boolean(obj, dm_parent, 
t, inner_material_index, 0, 0.0f, NULL, NULL, 0.0f, false);
+                               s = BKE_fracture_shard_boolean(obj, dm_parent, 
t, inner_material_index, 0, 0.0f, NULL, NULL, 0.0f, false, 0);
                        }
                        else if (algorithm == MOD_FRACTURE_BOOLEAN_FRACTAL) {
                                /* physics shard and fractalized shard, so we 
need to booleanize twice */
@@ -493,7 +493,7 @@ static void parse_cells(cell *cells, int expected_shards, 
ShardID parent_id, Fra
                                        loc_eul_size_to_mat4(matrix, loc, eul, 
one);
 
                                        /*visual shards next, fractalized cuts 
*/
-                                       s = BKE_fracture_shard_boolean(obj, 
dm_p, t, inner_material_index, num_cuts,fractal, &s2, matrix, radius, false);
+                                       s = BKE_fracture_shard_boolean(obj, 
dm_p, t, inner_material_index, num_cuts,fractal, &s2, matrix, radius, smooth, 
num_levels);
 
                                        if (index < max_retries)
                                        {
@@ -817,7 +817,7 @@ static void parse_cell_neighbors(cell c, int *neighbors, 
int totpoly)
        }
 }
 
-void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID id, FracPointCloud 
*pointcloud, int algorithm, Object *obj, DerivedMesh *dm, short 
inner_material_index, float mat[4][4], int num_cuts, float fractal) {
+void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID id, FracPointCloud 
*pointcloud, int algorithm, Object *obj, DerivedMesh *dm, short 
inner_material_index, float mat[4][4], int num_cuts, float fractal, bool 
smooth, int num_levels) {
        int n_size = 8;
        
        Shard *shard;
@@ -877,7 +877,7 @@ void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID 
id, FracPointCloud *p
        container_compute_cells(voro_container, voro_cells);
 
        /*Evaluate result*/
-       parse_cells(voro_cells, pointcloud->totpoints, id, fmesh, algorithm, 
obj, dm, inner_material_index, mat, num_cuts, fractal);
+       parse_cells(voro_cells, pointcloud->totpoints, id, fmesh, algorithm, 
obj, dm, inner_material_index, mat, num_cuts, fractal, smooth, num_levels);
 
        /*Free structs in C++ area of memory */
        cells_free(voro_cells, pointcloud->totpoints);
diff --git a/source/blender/blenkernel/intern/fracture_util.c 
b/source/blender/blenkernel/intern/fracture_util.c
index bf48af4..1ea2a60 100644
--- a/source/blender/blenkernel/intern/fracture_util.c
+++ b/source/blender/blenkernel/intern/fracture_util.c
@@ -282,7 +282,7 @@ static bool compare_dm_size(DerivedMesh *dmOld, DerivedMesh 
*dmNew)
        return v2 < v1;
 }
 
-Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh *dm_parent, Shard 
*child, short inner_material_index, int num_cuts, float fractal, Shard** other, 
float mat[4][4], float radius, bool use_smooth_inner)
+Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh *dm_parent, Shard 
*child, short inner_material_index, int num_cuts, float fractal, Shard** other, 
float mat[4][4], float radius, bool use_smooth_inner, int num_levels)
 {
        Shard *output_s;
        DerivedMesh *left_dm, *right_dm, *output_dm, *other_dm;
@@ -302,7 +302,7 @@ Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh 
*dm_parent, Shard *ch
                        1, 1, radius*1.4, mat);
 
                /*subdivide the plane fractally*/
-               for (i = 0; i < num_cuts; i++)
+               for (i = 0; i < num_levels; i++)
                {
                        BMO_op_callf(bm,(BMO_FLAG_DEFAULTS & 
~BMO_FLAG_RESPECT_HIDE),
                                                 "subdivide_edges edges=ae "
@@ -315,7 +315,7 @@ Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh 
*dm_parent, Shard *ch
                                                 "seed=%i",
                                                 0.0f, SUBD_FALLOFF_ROOT, false,
                                                 fractal, 1.0f,
-                                                1,
+                                                num_cuts,
                                                 SUBD_CORNER_INNERVERT,
                                                 false, true,
                                                 true,
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index c818c52..01e9295 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1458,6 +1458,7 @@ typedef struct FractureModifierData {
        int cluster_breaking_percentage;
        int splinter_axis;
        int fractal_cuts;
+       int fractal_iterations;
 
        float breaking_angle;
        float breaking_distance;
@@ -1500,7 +1501,7 @@ typedef struct FractureModifierData {
        /* internal values */
        float max_vol;
 
-       char pad[4];
+       //char pad[4];
 } FractureModifierData;
 
 #endif  /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index dd82fea..5040f20 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4165,6 +4165,12 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
        RNA_def_property_range(prop, 0.1f , 1.0f);
        RNA_def_property_ui_text(prop, "Physics Mesh Scale", "Scale factor of 
physics mesh, reduce this to avoid explosion of the mesh (MESH SHAPE ONLY)");
        RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+       prop = RNA_def_property(srna, "fractal_iterations", PROP_INT, 
PROP_NONE);
+       RNA_def_property_int_sdna(prop, NULL, "fractal_iterations");
+       RNA_def_property_range(prop, 1, 10);
+       RNA_def_property_ui_text(prop, "Fractal Iterations", "Number of times 
the number of cuts will be made to the grid, with the given fractal amount");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
 void RNA_def_modifier(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_fracture.c 
b/source/blender/modifiers/intern/MOD_fracture.c
index ff44b65..10f8c00 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -142,9 +142,10 @@ static void initData(ModifierData *md)
        fmd->use_breaking = true;
        fmd->use_smooth = false;
 
-       fmd->fractal_cuts = 4;
+       fmd->fractal_cuts = 1;
        fmd->fractal_amount = 1.0f;
        fmd->physics_mesh_scale = 0.75f;
+       fmd->fractal_iterations = 5;
 }
 
 static void freeMeshIsland(FractureModifierData *rmd, MeshIsland *mi, bool 
remove_rigidbody)
@@ -1000,7 +1001,8 @@ static void do_fracture(FractureModifierData *fracmd, 
ShardID id, Object *obj, D
                }
 
                mat_index = mat_index > 0 ? mat_index - 1 : mat_index;
-               BKE_fracture_shard_by_points(fracmd->frac_mesh, id, &points, 
fracmd->frac_algorithm, obj, dm, mat_index, mat2, fracmd->fractal_cuts, 
fracmd->fractal_amount);
+               BKE_fracture_shard_by_points(fracmd->frac_mesh, id, &points, 
fracmd->frac_algorithm, obj, dm, mat_index, mat2,
+                                            fracmd->fractal_cuts, fra

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to