fix for calculate mass crash, and attempt for edgebased fracture with voronoi (disabled, not working yet)

This commit is contained in:
2014-08-28 18:18:32 +02:00
parent b2d7241473
commit 1d8c635499
5 changed files with 50 additions and 5 deletions

View File

@@ -139,6 +139,7 @@ class PHYSICS_PT_fracture_simulation(PhysicButtonsPanel, Panel):
box.label("Inner Vertex Group:")
box.prop_search(md, "inner_vertex_group", ob, "vertex_groups", text = "")
box.prop(md, "autohide_dist")
# box.prop(md, "use_ortho")
row = box.row(align=True)
row.operator("fracture.toggle_ground", text = "Toggle Ground")
row.operator("fracture.toggle_connect_ground", text = "Toggle Connect Ground")

View File

@@ -53,6 +53,8 @@
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_rigidbody.h"
#include "BKE_DerivedMesh.h"
#include "BKE_cdderivedmesh.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -510,6 +512,7 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
{
if (ob->rigidbody_object) {
PointerRNA ptr;
DerivedMesh* dm_ob;
float volume; /* m^3 */
float mass; /* kg */
@@ -517,7 +520,21 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
/* mass is calculated from the approximate volume of the object,
* and the density of the material we're simulating
*/
BKE_rigidbody_calc_volume(ob, &volume);
if (ob->type == OB_MESH)
{
//if we have a mesh, determine its volume
dm_ob = CDDM_from_mesh(ob->data);
volume = BKE_rigidbody_calc_volume(dm_ob, ob->rigidbody_object);
}
else
{
float dim[3];
//else get object boundbox as last resort
BKE_object_dimensions_get(ob, dim);
volume = dim[0] * dim[1] * dim[2];
}
mass = volume * density;
/* use RNA-system to change the property and perform all necessary changes */

View File

@@ -1457,11 +1457,11 @@ typedef struct FractureModifierData {
int breaking_percentage, use_proportional_distance, use_proportional_limit;
int use_cellbased_sim, use_experimental;
int solver_iterations_override, use_proportional_solver_iterations, refresh_images;
int shards_to_islands, execute_threaded, fix_normals, auto_execute;
int shards_to_islands, execute_threaded, fix_normals, auto_execute, use_ortho;
float breaking_distance, max_vol, cell_size;
float origmat[4][4], breaking_threshold, cluster_breaking_threshold;
float contact_dist, autohide_dist;
//char pad[4];
char pad[4];
} FractureModifierData;
#endif /* __DNA_MODIFIER_TYPES_H__ */

View File

@@ -4309,6 +4309,11 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyModifier_autohide_dist_set", NULL);
RNA_def_property_ui_text(prop, "Autohide Distance", "Distance between faces below which both faces should be hidden");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "use_ortho", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_ortho", false);
RNA_def_property_ui_text(prop, "Exact Line", "Modify point cloud to get determined cracking lines");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
void RNA_def_modifier(BlenderRNA *brna)

View File

@@ -130,6 +130,7 @@ static void initData(ModifierData *md)
fmd->auto_execute = false;
fmd->face_pairs = NULL;
fmd->autohide_dist = 0.0f;
fmd->use_ortho = false;
}
static void freeData(ModifierData *md)
@@ -892,7 +893,7 @@ static void points_from_particles(Object** ob, int totobj, Scene* scene, FracPoi
points->totpoints = pt;
}
static void points_from_greasepencil(Object** ob, int totobj, FracPointCloud* points, float mat[4][4], float thresh)
static void points_from_greasepencil(Object** ob, int totobj, FracPointCloud* points, float mat[4][4], float thresh, FractureModifierData* fmd)
{
bGPDlayer* gpl;
bGPDframe* gpf;
@@ -922,6 +923,27 @@ static void points_from_greasepencil(Object** ob, int totobj, FracPointCloud* po
point[2] = gps->points[p].z;
mul_m4_v3(imat, point);
#if 0
if (pt > 1 && fmd->use_ortho)
{
//last point and this point is the stroke, calc midpoint and orthogonal vector
float v[3], ov[3], mid[3], p1[3], p2[3];
sub_v3_v3v3(v, point, points->points[pt-1].co);
ortho_v3_v3(ov, v);
mid_v3_v3v3(mid, point, points->points[pt-1].co);
//"rotate" points by 90 degrees, creating a pair of orthogonal points
add_v3_v3v3(p1, mid, ov);
sub_v3_v3v3(p2, mid, ov);
mul_v3_fl(p1, 0.5f);
mul_v3_fl(p2, 0.5f);
copy_v3_v3(point, p1);
copy_v3_v3(points->points[pt-1].co, p2);
}
#endif
copy_v3_v3(points->points[pt].co, point);
pt++;
}
@@ -1001,7 +1023,7 @@ static FracPointCloud get_points_global(FractureModifierData *emd, Object *ob, D
if (emd->point_source & MOD_FRACTURE_GREASEPENCIL)
{
points_from_greasepencil(go, totgroup, &points, ob->obmat, thresh);
points_from_greasepencil(go, totgroup, &points, ob->obmat, thresh, emd);
}
//greasecut, imagebased... backend is via projected curvemeshes