diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-05-29 15:00:36 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-05-29 16:11:20 +0300 |
commit | bc54823376695844ff04ec977c3ce602529e95c1 (patch) | |
tree | 3f907ad119cdc1deb0c83ff0fa8c6f991400b920 /source/blender/blenkernel/intern | |
parent | 8b24f45e6bd9f310260da4fe2a2510042a50665f (diff) |
Fix T55244: Parenting object(s) to curve crashes blender
There is a chance parts of Blender call BKE_object_workob_calc_parent
with ob->parent objects that are outside the depsgraph.
This we can tackle later since these are corner cases anyways,
and this fix fixes all parenting operators in Blender.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 57324b88912..1b6916a2d55 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2168,28 +2168,37 @@ void BKE_object_where_is_calc(Depsgraph *depsgraph, Scene *scene, Object *ob) BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, BKE_scene_frame_get(scene), NULL, NULL); } -/* for calculation of the inverse parent transform, only used for editor */ +/** + * For calculation of the inverse parent transform, only used for editor. + * + * It assumes the object parent is already in the depsgraph. + * Otherwise, after changing ob->parent you need to call: + * DEG_relations_tag_update(bmain); + * BKE_scene_graph_update_tagged(depsgraph, bmain); + */ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *ob, Object *workob) { + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); BKE_object_workob_clear(workob); unit_m4(workob->obmat); unit_m4(workob->parentinv); unit_m4(workob->constinv); - workob->parent = ob->parent; - workob->trackflag = ob->trackflag; - workob->upflag = ob->upflag; + /* Since this is used while calculating parenting, at this moment ob_eval->parent is still NULL. */ + workob->parent = DEG_get_evaluated_object(depsgraph, ob->parent); + + workob->trackflag = ob_eval->trackflag; + workob->upflag = ob_eval->upflag; - workob->partype = ob->partype; - workob->par1 = ob->par1; - workob->par2 = ob->par2; - workob->par3 = ob->par3; + workob->partype = ob_eval->partype; + workob->par1 = ob_eval->par1; + workob->par2 = ob_eval->par2; + workob->par3 = ob_eval->par3; - workob->constraints.first = ob->constraints.first; - workob->constraints.last = ob->constraints.last; + workob->constraints = ob_eval->constraints; - BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr)); + BLI_strncpy(workob->parsubstr, ob_eval->parsubstr, sizeof(workob->parsubstr)); BKE_object_where_is_calc(depsgraph, scene, workob); } |