[Bf-blender-cvs] [e37e105fedb] master: Fix Hook to New Object won't appear in Local View

Dalai Felinto noreply at git.blender.org
Tue Mar 12 21:51:26 CET 2019


Commit: e37e105fedb3258df80963573a7c830bb57b3ca4
Author: Dalai Felinto
Date:   Tue Mar 12 17:42:37 2019 -0300
Branches: master
https://developer.blender.org/rBe37e105fedb3258df80963573a7c830bb57b3ca4

Fix Hook to New Object won't appear in Local View

Reported as part of T62436 (although the bug was a different one).

===================================================================

M	source/blender/editors/object/object_hook.c

===================================================================

diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index f65abb2f269..401260df406 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -442,7 +442,7 @@ static bool hook_op_edit_poll(bContext *C)
 	return 0;
 }
 
-static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit)
+static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, Object *obedit)
 {
 	Base *basedit;
 	Object *ob;
@@ -452,6 +452,10 @@ static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_la
 	basedit = BKE_view_layer_base_find(view_layer, obedit);
 	BLI_assert(view_layer->basact->object == ob);
 
+	if (v3d && v3d->localvd) {
+		view_layer->basact->local_view_bits |= v3d->local_view_uuid;
+	}
+
 	/* icky, BKE_object_add sets new base as active.
 	 * so set it back to the original edit object */
 	view_layer->basact = basedit;
@@ -459,7 +463,16 @@ static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_la
 	return ob;
 }
 
-static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit, Object *ob, int mode, ReportList *reports)
+static int add_hook_object(
+        const bContext *C,
+        Main *bmain,
+        Scene *scene,
+        ViewLayer *view_layer,
+        View3D *v3d,
+        Object *obedit,
+        Object *ob,
+        int mode,
+        ReportList *reports)
 {
 	ModifierData *md = NULL;
 	HookModifierData *hmd = NULL;
@@ -477,7 +490,7 @@ static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLay
 
 	if (mode == OBJECT_ADDHOOK_NEWOB && !ob) {
 
-		ob = add_hook_object_new(bmain, scene, view_layer, obedit);
+		ob = add_hook_object_new(bmain, scene, view_layer, v3d, obedit);
 
 		/* transform cent to global coords for loc */
 		mul_v3_m4v3(ob->loc, obedit->obmat, cent);
@@ -576,7 +589,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
 		return OPERATOR_CANCELLED;
 	}
 
-	if (add_hook_object(C, bmain, scene, view_layer, obedit, obsel, mode, op->reports)) {
+	if (add_hook_object(C, bmain, scene, view_layer, NULL, obedit, obsel, mode, op->reports)) {
 		WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit);
 		return OPERATOR_FINISHED;
 	}
@@ -608,9 +621,10 @@ static int object_add_hook_newob_exec(bContext *C, wmOperator *op)
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
 	ViewLayer *view_layer = CTX_data_view_layer(C);
+	View3D *v3d = CTX_wm_view3d(C);
 	Object *obedit = CTX_data_edit_object(C);
 
-	if (add_hook_object(C, bmain, scene, view_layer, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) {
+	if (add_hook_object(C, bmain, scene, view_layer, v3d, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) {
 		DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
 		WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 		WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit);



More information about the Bf-blender-cvs mailing list