diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2020-09-09 12:46:40 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2020-09-09 12:48:52 +0300 |
commit | d51c8f78ff8a210675dae44048156c23e3793508 (patch) | |
tree | 809aa4e321f5771d46aad901a2a1804dd31b0aca /source/blender | |
parent | 377a1e3d7b7f108c5feff24dc2adb5ef7c402989 (diff) |
Fix T80596: Convert to Curve from Mesh crashes Blender
The point cache code needs a non NULL rbw pointer.
This could have been avoided if there was a sanity check in the convert
function, so added a check there as well.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 14 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 4 |
3 files changed, 11 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 8c5915d3768..6b433e5edaa 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1848,7 +1848,7 @@ void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, Object *ob, RigidBodyWorld *r memset(pid, 0, sizeof(PTCacheID)); - pid->owner_id = &ob->id; + pid->owner_id = ob != NULL ? &ob->id : NULL; pid->calldata = rbw; pid->type = PTCACHE_TYPE_RIGIDBODY; pid->cache = rbw->shared->pointcache; diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 7eab716d805..0a31af032d3 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1554,18 +1554,18 @@ void BKE_rigidbody_remove_object(Main *bmain, Scene *scene, Object *ob, const bo BKE_collection_object_add(bmain, scene->master_collection, ob); } BKE_collection_object_remove(bmain, rbw->group, ob, free_us); + + /* flag cache as outdated */ + BKE_rigidbody_cache_reset(rbw); + /* Reset cache as the object order probably changed after freeing the object. */ + PTCacheID pid; + BKE_ptcache_id_from_rigidbody(&pid, NULL, rbw); + BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); } /* remove object's settings */ BKE_rigidbody_free_object(ob, rbw); - /* flag cache as outdated */ - BKE_rigidbody_cache_reset(rbw); - /* Reset cache as the object order probably changed after freeing the object. */ - PTCacheID pid; - BKE_ptcache_id_from_rigidbody(&pid, NULL, rbw); - BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); - /* Dependency graph update */ DEG_relations_tag_update(bmain); DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index bfb13fb99bf..482ae4019c3 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -2572,7 +2572,9 @@ static int object_convert_exec(bContext *C, wmOperator *op) if (newob->type == OB_CURVE) { BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */ - ED_rigidbody_object_remove(bmain, scene, newob); + if (newob->rigidbody_object != NULL) { + ED_rigidbody_object_remove(bmain, scene, newob); + } } } else if (ob->type == OB_MESH && target == OB_GPENCIL) { |