[Bf-blender-cvs] [81a67d8] fracture_modifier: fixed some more transform issues with dynamic fracture, added openmp for loop for boolean fracturing
Martin Felke
noreply at git.blender.org
Thu Oct 6 22:21:24 CEST 2016
Commit: 81a67d8e988575b3870bd763a98d8d9fe6f9f716
Author: Martin Felke
Date: Thu Oct 6 22:20:58 2016 +0200
Branches: fracture_modifier
https://developer.blender.org/rB81a67d8e988575b3870bd763a98d8d9fe6f9f716
fixed some more transform issues with dynamic fracture, added openmp for loop for boolean fracturing
===================================================================
M source/blender/blenkernel/intern/fracture.c
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/modifiers/intern/MOD_fracture.c
===================================================================
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 3200a0a..6f92463 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -937,7 +937,7 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
}
BLI_kdtree_balance(preselect_tree);
-
+#pragma omp parallel for if (algorithm == MOD_FRACTURE_BOOLEAN && !threaded)
for (i = 0; i < expected_shards; i++) {
bool stop = handle_boolean_bisect(fm, obj, expected_shards, algorithm, parent_id, tempshards, dm_parent,
bm_parent, obmat, inner_material_index, num_cuts, num_levels, fractal,
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 0dd92b7..528f497 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -2027,15 +2027,19 @@ static int filterCallback(void* world, void* island1, void* island2, void *blend
return check_colgroup_ghost(ob1, ob2);
}
-static bool can_break(Object* collider, Object* ob, bool limit, Shard *s)
+static bool can_break(Object* collider, Object* ob, bool limit)
{
//allow limit impact only on initial shard and 1st level shards ?
- if (collider && collider->rigidbody_object && (collider->rigidbody_object->flag & RBO_FLAG_IS_TRIGGER &&
- s && (s->parent_id == 0 || s->shard_id == 0)))
+ if (collider && collider->rigidbody_object && (collider->rigidbody_object->flag & RBO_FLAG_IS_TRIGGER))
{
- /*if (limit && (collider == ob)) {
+ if (limit && (collider == ob)) {
return false;
- }*/
+ }
+
+ //dont allow limit impact with ground
+ if (collider->rigidbody_object->type == RBO_TYPE_PASSIVE) {
+ return false;
+ }
return true;
}
@@ -2065,7 +2069,7 @@ static Shard* findShard(FractureModifierData *fmd, int id)
static bool check_shard_size(FractureModifierData *fmd, int id)
{
FractureID *fid;
- float size = 0.05f;
+ float size = 1.0f;
Shard *s = NULL;
s = findShard(fmd, id);
@@ -2084,10 +2088,6 @@ static bool check_shard_size(FractureModifierData *fmd, int id)
return false;
}
- /*if (s->raw_volume < size) {
- return false;
- }*/
-
for (fid = fmd->fracture_ids.first; fid; fid = fid->next)
{
if (fid->shardID == id)
@@ -2101,18 +2101,6 @@ static bool check_shard_size(FractureModifierData *fmd, int id)
return true;
}
-static void impact_to_shard(Shard* s/*, Object* ob,*/, RigidBodyOb *rbo)
-{
- float mat[4][4];
-
- if ((s->shard_id == 0) /*|| (s->parent_id == 0)*/)
- {
- /*invert_m4_m4(mat, ob->obmat);
- mul_m4_v3(mat, s->impact_loc);*/
- sub_v3_v3(s->impact_loc, rbo->pos);
- }
-}
-
static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw)
{
int linear_index1, linear_index2;
@@ -2155,17 +2143,16 @@ static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw)
Shard *s = findShard(fmd1, id);
//printf("FORCE1:%f\n",force);
+ bool canbreak = (force > fmd1->dynamic_force) || (fmd1->limit_impact && can_break(ob2, ob1, fmd1->limit_impact));
- if (((force > fmd1->dynamic_force) && (!fmd1->limit_impact || (fmd1->limit_impact && s && (s->parent_id > 0 || s->shard_id >= 0)))) ||
- (s && ob2 && (fmd1->limit_impact && can_break(ob2, ob1, fmd1->limit_impact, s))))
+ if (canbreak)
{
if (s) {
float size[3];
- if (s->parent_id > 0 || ob1 == ob2 || (ob2 && ob2->rigidbody_object && ob2->rigidbody_object->type == RBO_TYPE_PASSIVE)) {
- size[0] = -1.0f; //mark as invalid, so the regular object size is used
- size[1] = -1.0f;
- size[2] = -1.0f;
+ if (ob1 == ob2) {
+ //todo calculate shard...
+ size[0] = size[1] = size[2] = force;
}
else {
BKE_object_dimensions_get(ob2, size);
@@ -2173,11 +2160,6 @@ static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw)
copy_v3_v3(s->impact_loc, cp->contact_pos_world_onA);
copy_v3_v3(s->impact_size, size);
-
- if (fmd1->limit_impact && s)
- {
- impact_to_shard(s, rbo);
- }
}
/*only fracture on new entries, this is necessary because after loading a file
*the pointcache thinks it is empty and a fracture is attempted ! */
@@ -2208,28 +2190,21 @@ static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw)
Shard *s = findShard(fmd2, id);
//printf("FORCE2:%f\n",force);
+ bool canbreak = (force > fmd2->dynamic_force) || (fmd2->limit_impact && can_break(ob1, ob2, fmd2->limit_impact));
- if (((force > fmd2->dynamic_force) && (!fmd2->limit_impact || (fmd2->limit_impact && s && (s->parent_id > 0 || s->shard_id >= 0)))) ||
- (ob1 && s && (fmd2->limit_impact && can_break(ob1, ob2, fmd2->limit_impact, s))))
+ if (canbreak)
{
if (s) {
float size[3];
- if (s->parent_id > 0 ||ob1 == ob2 || (ob1 && ob1->rigidbody_object && ob1->rigidbody_object->type == RBO_TYPE_PASSIVE)) {
- size[0] = -1.0f; //mark as invalid, so the regular object size is used
- size[1] = -1.0f;
- size[2] = -1.0f;
+ if (ob1 == ob2) {
+ size[0] = size[1] = size[2] = force;
}
else {
BKE_object_dimensions_get(ob1, size);
}
copy_v3_v3(s->impact_loc, cp->contact_pos_world_onB);
copy_v3_v3(s->impact_size, size);
-
- if (fmd2->limit_impact && s)
- {
- impact_to_shard(s, rbo);
- }
}
if (check_shard_size(fmd2, id))
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 191098d..6ae3459 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -1183,10 +1183,37 @@ static FracPointCloud get_points_global(FractureModifierData *emd, Object *ob, D
s = BKE_shard_by_id(emd->frac_mesh, id, fracmesh);
if (s != NULL && s->impact_size[0] > 0.0f) {
float size[3], nmin[3], nmax[3], loc[3], tmin[3], tmax[3];
+ MeshIslandSequence *msq = emd->current_mi_entry, *prev = NULL;
+ MeshIsland *mi = NULL;
+ RigidBodyOb *rbo = NULL;
+
+ if (msq) {
+ if (msq->prev) {
+ prev = msq->prev;
+ }
+ else {
+ prev = msq;
+ }
+
+ mi = find_meshisland(&prev->meshIslands, s->parent_id);
+ if (!mi) {
+ mi = find_meshisland(&prev->meshIslands, id);
+ }
+
+ rbo = mi->rigidbody;
+ }
+
print_v3("Impact Loc\n", s->impact_loc);
print_v3("Impact Size\n", s->impact_size);
copy_v3_v3(loc, s->impact_loc);
+
+ if (rbo) {
+ sub_v3_v3(loc, rbo->pos);
+ add_v3_v3(loc, cent);
+ add_v3_v3(loc, s->centroid);
+ }
+
copy_v3_v3(tmax, s->max);
copy_v3_v3(tmin, s->min);
@@ -3357,21 +3384,21 @@ static void do_island_from_shard(FractureModifierData *fmd, Object *ob, Shard* s
//keep 1st level shards kinematic if parent is triggered
if (par->id == 0 && (par->rigidbody->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION) && fmd->limit_impact) {
-#if 0
- ShardSequence *prev_shards = fmd->current_shard_entry ? fmd->current_shard_entry->prev : NULL;
+
+ /*ShardSequence *prev_shards = fmd->current_shard_entry ? fmd->current_shard_entry->prev : NULL;
Shard *par_shard = prev_shards ? BKE_shard_by_id(prev_shards->frac_mesh, s->parent_id, NULL) : NULL;
if (par_shard) {
float size[3];
- mul_v3_v3fl(size, par_shard->impact_size, 0.5f);
+ //mul_v3_v3fl(size, par_shard->impact_size, 0.5f);
if (!contains(par_shard->impact_loc, size, s->centroid)) {
mi->rigidbody->flag |= RBO_FLAG_KINEMATIC;
mi->rigidbody->flag |= RBO_FLAG_NEEDS_VALIDATE;
}
- }
-#endif
+ }*/
+
mi->rigidbody->flag |= RBO_FLAG_KINEMATIC;
mi->rigidbody->flag |= RBO_FLAG_NEEDS_VALIDATE;
}
More information about the Bf-blender-cvs
mailing list