diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-10-19 23:01:41 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-10-19 23:04:14 +0300 |
commit | fc10484f7c55d425f8374f2ea64f6b525cff2b7d (patch) | |
tree | 0e9a08aaa918f95bb8814ce316ac1e24fd65ea9d /source/blender/blenkernel/intern | |
parent | 4d2416b99c472c9735e074d864dcf82a85da8c58 (diff) |
Fix/properly implement: "make group proxy"
This was never correctly implemented. It now works as expected (ala 2.79 behaviour).
The proxy object is added to all the collections of the original empty.
Before not only this wasn't the case, but it would crash Blender.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 57 |
1 files changed, 45 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index a47e88a8e48..af27203d0cb 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -724,33 +724,66 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name) return ob; } -/* general add: to scene, with layer from area and default name */ + +static Object *object_add_common(Main *bmain, SceneLayer *scene_layer, int type, const char *name) +{ + Object *ob; + + ob = BKE_object_add_only_object(bmain, type, name); + ob->data = BKE_object_obdata_add_from_type(bmain, type, name); + BKE_scene_layer_base_deselect_all(scene_layer); + + DEG_id_tag_update_ex(bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + return ob; +} + +/** + * General add: to scene, with layer from area and default name + * + * Object is added to the active SceneCollection. + * If there is no linked collection to the active SceneLayer we create a new one. + */ /* creates minimum required data, but without vertices etc. */ Object *BKE_object_add( - Main *bmain, Scene *scene, SceneLayer *sl, + Main *bmain, Scene *scene, SceneLayer *scene_layer, int type, const char *name) { Object *ob; Base *base; - LayerCollection *lc; + LayerCollection *layer_collection; - ob = BKE_object_add_only_object(bmain, type, name); + ob = object_add_common(bmain, scene_layer, type, name); - ob->data = BKE_object_obdata_add_from_type(bmain, type, name); + layer_collection = BKE_layer_collection_get_active_ensure(scene, scene_layer); + BKE_collection_object_add(scene, layer_collection->scene_collection, ob); - lc = BKE_layer_collection_get_active_ensure(scene, sl); + base = BKE_scene_layer_base_find(scene_layer, ob); + BKE_scene_layer_base_select(scene_layer, base); + + return ob; +} + +/** + * Add a new object, using another one as a reference + * + * /param ob_src object to use to determine the collections of the new object. + */ +Object *BKE_object_add_from( + Main *bmain, Scene *scene, SceneLayer *scene_layer, + int type, const char *name, Object *ob_src) +{ + Object *ob; + Base *base; - BKE_collection_object_add(scene, lc->scene_collection, ob); + ob = object_add_common(bmain, scene_layer, type, name); + BKE_collection_object_add_from(scene, ob_src, ob); - base = BKE_scene_layer_base_find(sl, ob); - BKE_scene_layer_base_deselect_all(sl); - BKE_scene_layer_base_select(sl, base); + base = BKE_scene_layer_base_find(scene_layer, ob); + BKE_scene_layer_base_select(scene_layer, base); - DEG_id_tag_update_ex(bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); return ob; } - #ifdef WITH_GAMEENGINE void BKE_object_lod_add(Object *ob) |