[Bf-blender-cvs] [d3da8f964c7] temp-fracture-modifier-2.8: partial fix for bullet related crashes or lockups
Martin Felke
noreply at git.blender.org
Fri Nov 23 14:21:23 CET 2018
Commit: d3da8f964c7ec20e596b8b0da705f6653cc7f0e1
Author: Martin Felke
Date: Fri Nov 23 14:21:08 2018 +0100
Branches: temp-fracture-modifier-2.8
https://developer.blender.org/rBd3da8f964c7ec20e596b8b0da705f6653cc7f0e1
partial fix for bullet related crashes or lockups
especially when 2 or more dynamic objects fracture each other, there are still crashes / lockups
===================================================================
M source/blender/blenkernel/intern/fracture_constraints.c
M source/blender/blenkernel/intern/fracture_prefractured.c
M source/blender/blenkernel/intern/fracture_rigidbody.c
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/blenloader/intern/readfile.c
M source/blender/depsgraph/intern/builder/deg_builder_relations.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/fracture_constraints.c b/source/blender/blenkernel/intern/fracture_constraints.c
index 4827c0ef251..9d9763d3c22 100644
--- a/source/blender/blenkernel/intern/fracture_constraints.c
+++ b/source/blender/blenkernel/intern/fracture_constraints.c
@@ -737,17 +737,6 @@ void BKE_fracture_constraints_free(FractureModifierData *fmd, Scene *scene)
MeshIsland *mi = NULL;
RigidBodyShardCon *rbsc = NULL;
-#if 0
- //hmm after loading the pointers might be out of sync...
- if (fmd->shared->current_mi_entry) {
- fmd->shared->mesh_islands = fmd->shared->current_mi_entry->meshIslands;
- }
- else {
- fmd->shared->mesh_islands.first = NULL;
- fmd->shared->mesh_islands.last = NULL;
- }
-#endif
-
for (mi = fmd->shared->mesh_islands.first; mi; mi = mi->next) {
if (mi->participating_constraints != NULL && mi->participating_constraint_count > 0) {
int i;
diff --git a/source/blender/blenkernel/intern/fracture_prefractured.c b/source/blender/blenkernel/intern/fracture_prefractured.c
index 51d15bc1027..20ebc093734 100644
--- a/source/blender/blenkernel/intern/fracture_prefractured.c
+++ b/source/blender/blenkernel/intern/fracture_prefractured.c
@@ -167,10 +167,20 @@ static void do_initial_prefracture(FractureModifierData* fmd, Object* ob, Depsgr
mi->id = 0;
BLI_addtail(&fmd->shared->mesh_islands, mi);
+ if (fmd->shared->last_islands) {
+ MEM_freeN(fmd->shared->last_islands);
+ fmd->shared->last_islands = NULL;
+ fmd->shared->last_expected_islands = 0;
+ }
+
+ fmd->shared->last_islands = MEM_callocN(sizeof(MeshIsland*), "island initial");
+ fmd->shared->last_islands[0] = mi;
+ fmd->shared->last_expected_islands = 1;
+
BKE_fracture_do(fmd, mi, ob, depsgraph, bmain, scene, true);
- if ((fmd->point_source & MOD_FRACTURE_CUSTOM) == 0)
- mi->endframe = frame;
+ //if ((fmd->point_source & MOD_FRACTURE_CUSTOM) == 0)
+ // mi->endframe = frame;
}
@@ -191,7 +201,7 @@ Mesh* BKE_fracture_apply(FractureModifierData *fmd, Object *ob, Mesh *me_orig, D
fmd->shared->refresh = true;
}
- if (fmd->shared->refresh || fmd->shared->reset_shards)
+ if (fmd->shared->refresh /*|| fmd->shared->reset_shards*/)
{
/*reset_shards called from readfile.c; refresh from operator */
@@ -215,7 +225,7 @@ Mesh* BKE_fracture_apply(FractureModifierData *fmd, Object *ob, Mesh *me_orig, D
fmd->shared->refresh_constraints = true;
fmd->shared->refresh_autohide = true;
- fmd->shared->reset_shards = false;
+ //fmd->shared->reset_shards = false;
}
else if (fmd->shared->refresh_dynamic) {
//handle_initial_shards(fmd, ob, depsgraph, bmain, scene, frame);
diff --git a/source/blender/blenkernel/intern/fracture_rigidbody.c b/source/blender/blenkernel/intern/fracture_rigidbody.c
index 3318c03e74b..c9d6d4d6f9a 100644
--- a/source/blender/blenkernel/intern/fracture_rigidbody.c
+++ b/source/blender/blenkernel/intern/fracture_rigidbody.c
@@ -1573,6 +1573,16 @@ void BKE_rigidbody_shard_validate(RigidBodyWorld *rbw, MeshIsland *mi, Object *o
}
if (BKE_fracture_meshisland_check_frame(fmd, mi, (int)ctime)) {
+ RigidBodyOb *rbo = mi->rigidbody;
+
+ if (rbw->shared->physics_world && rbo->shared->physics_object)
+ {
+ RB_dworld_remove_body(rbw->shared->physics_world, rbo->shared->physics_object);
+ RB_body_delete(rbo->shared->physics_object);
+ rbo->shared->physics_object = NULL;
+ }
+
+ //rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
return;
}
@@ -2355,14 +2365,14 @@ bool BKE_rigidbody_modifier_sync(ModifierData *md, Object *ob, Scene *scene, flo
#endif
/* use rigid body transform after cache start frame if objects is not being transformed */
- if (BKE_rigidbody_check_sim_running(rbw, ctime)) {
+ if (BKE_rigidbody_check_sim_running(rbw, ctime) && !(ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ)) {
/* keep original transform when the simulation is muted */
if (rbw->flag & RBW_FLAG_MUTED)
break;
}
/* otherwise set rigid body transform to current obmat*/
- else if (!(ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ))
+ else //if (!(ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ))
{
mat4_to_loc_quat(rbo->pos, rbo->orn, ob->obmat);
mat4_to_size(size, ob->obmat);
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 384f92ff72f..888928ab390 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1755,7 +1755,7 @@ void BKE_rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool reb
}
}
-static ThreadMutex post_step_lock = BLI_MUTEX_INITIALIZER;
+//static ThreadMutex post_step_lock = BLI_MUTEX_INITIALIZER;
static void rigidbody_update_simulation_post_step(Depsgraph* depsgraph, RigidBodyWorld *rbw)
{
CollectionObject *go;
@@ -1769,7 +1769,7 @@ static void rigidbody_update_simulation_post_step(Depsgraph* depsgraph, RigidBod
Object *ob = go->ob;
//handle fractured rigidbodies, maybe test for psys as well ?
- BLI_mutex_lock(&post_step_lock);
+ //BLI_mutex_lock(&post_step_lock);
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Fracture) {
rmd = (FractureModifierData *)md;
@@ -1802,7 +1802,7 @@ static void rigidbody_update_simulation_post_step(Depsgraph* depsgraph, RigidBod
}
}
}
- BLI_mutex_unlock(&post_step_lock);
+ //BLI_mutex_unlock(&post_step_lock);
/* handle regular rigidbodies */
if (ob && ob->rigidbody_object && !modFound) {
@@ -1833,7 +1833,7 @@ bool BKE_rigidbody_check_sim_running(RigidBodyWorld *rbw, float ctime)
}
/* Sync rigid body and object transformations */
-static ThreadMutex modifier_lock = BLI_MUTEX_INITIALIZER;
+//static ThreadMutex modifier_lock = BLI_MUTEX_INITIALIZER;
void BKE_rigidbody_sync_transforms(Scene *scene, Object *ob, float ctime)
{
RigidBodyWorld *rbw = scene->rigidbody_world; //take later other rbws into account too !
@@ -1844,13 +1844,13 @@ void BKE_rigidbody_sync_transforms(Scene *scene, Object *ob, float ctime)
if (rbw == NULL)
return;
- BLI_mutex_lock(&modifier_lock);
+ //BLI_mutex_lock(&modifier_lock);
for (md = ob->modifiers.first; md; md = md->next) {
modFound = BKE_rigidbody_modifier_sync(md, ob, scene, ctime);
if (modFound)
break;
}
- BLI_mutex_unlock(&modifier_lock);
+ //BLI_mutex_unlock(&modifier_lock);
if (!modFound)
{
@@ -2062,6 +2062,13 @@ void BKE_rigidbody_rebuild_world(Depsgraph *depsgraph, Scene *scene, float ctime
if (frame == startframe + 1 && rbw->ltime == startframe)
{
if (cache->flag & PTCACHE_OUTDATED) {
+
+ if (!(cache->flag & PTCACHE_BAKED))
+ {
+ //if we destroy the cache, also reset dynamic data (if not baked, when jumping back)
+ BKE_rigidbody_cache_reset(scene);
+ }
+
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
BKE_rigidbody_update_simulation(scene, rbw, true, depsgraph);
BKE_ptcache_validate(cache, (int)ctime);
@@ -2069,12 +2076,6 @@ void BKE_rigidbody_rebuild_world(Depsgraph *depsgraph, Scene *scene, float ctime
cache->flag &= ~PTCACHE_REDO_NEEDED;
}
}
-
- //if we destroy the cache, also reset dynamic data (if not baked, when jumping back)
- if ((frame == startframe && rbw->ltime == frame) && !(cache->flag & PTCACHE_BAKED))
- {
- BKE_rigidbody_cache_reset(scene);
- }
}
/* Run RigidBody simulation for the specified physics world */
@@ -2123,6 +2124,7 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
rbw->flag &= ~RBW_FLAG_OBJECT_CHANGED;
BKE_rigidbody_update_simulation(scene, rbw, true, depsgraph);
}
+
return;
}
/* make sure we don't go out of cache frame range */
@@ -2130,6 +2132,7 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
ctime = endframe;
}
+
/* don't try to run the simulation if we don't have a world yet but allow reading baked cache */
if (rbw->shared->physics_world == NULL && !(cache->flag & PTCACHE_BAKED)) {
//BKE_rigidbody_rebuild_world(depsgraph, scene, ctime);
@@ -2269,6 +2272,7 @@ void BKE_rigidbody_eval_simulation(Depsgraph *depsgraph,
if (!BKE_scene_check_rigidbody_active(scene)) {
return;
}
+
BKE_rigidbody_do_simulation(depsgraph, scene, ctime);
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 560640aedd4..39fa95b0e2c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5444,8 +5444,8 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
/* initialize with halfway sane defaults here atleast*/
fmd->shared->last_cache_start = 0;
fmd->shared->last_cache_end = 250;
- fmd->shared->refresh = false;
- fmd->shared->reset_shards = true;
+ fmd->shared->refresh = true;
+ fmd->shared->reset_shards = false;
}
}
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index bbfcc0c36c5..1f4a12d0f8c 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1655,7 +1655,6 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
/* Needed to get correct base values. */
add_relation(trans_op, sim_key, "Base Ob Transform -> Rigidbody Sim Eval");
-#if 1
if (fmd)
{
OperationKey uber_geom_key(&object->id,
@@ -1663,7 +1662,6 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
DEG_OPCODE_GEOMETRY_UBEREVAL);
add_relation(rbo_key, uber_geom_key, "RBO Sync -> Uber Geom (Fracture)");
}
-#endif
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
More information about the Bf-blender-cvs
mailing list