[Bf-blender-cvs] [2fff10e2bf8] temp-T96709-painting-target: Use wmMsgBus to notify active tool changes.
Jeroen Bakker
noreply at git.blender.org
Tue Mar 29 09:25:48 CEST 2022
Commit: 2fff10e2bf80c7bddfc6bcacb0dc84145c736494
Author: Jeroen Bakker
Date: Tue Mar 29 09:25:40 2022 +0200
Branches: temp-T96709-painting-target
https://developer.blender.org/rB2fff10e2bf80c7bddfc6bcacb0dc84145c736494
Use wmMsgBus to notify active tool changes.
===================================================================
M source/blender/editors/include/ED_paint.h
M source/blender/editors/sculpt_paint/paint_canvas.cc
M source/blender/editors/space_view3d/space_view3d.c
===================================================================
diff --git a/source/blender/editors/include/ED_paint.h b/source/blender/editors/include/ED_paint.h
index 7442ef5a116..d8733bb71bc 100644
--- a/source/blender/editors/include/ED_paint.h
+++ b/source/blender/editors/include/ED_paint.h
@@ -21,6 +21,8 @@ struct UndoStep;
struct UndoType;
struct bContext;
struct wmKeyConfig;
+struct wmMsgSubscribeKey;
+struct wmMsgSubscribeValue;
struct wmOperator;
/* paint_ops.c */
@@ -131,6 +133,10 @@ eV3DShadingColorType ED_paint_draw_color_override(struct bContext *C,
/** Does the active tool uses a paint canvas for the given object. */
bool ED_paint_tool_use_canvas(struct bContext *C, struct Object *ob);
+void ED_paint_do_msg_notify_active_tool_changed(struct bContext *C,
+ struct wmMsgSubscribeKey *msg_key,
+ struct wmMsgSubscribeValue *msg_val);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/editors/sculpt_paint/paint_canvas.cc b/source/blender/editors/sculpt_paint/paint_canvas.cc
index dad50f77711..9a1a0040a85 100644
--- a/source/blender/editors/sculpt_paint/paint_canvas.cc
+++ b/source/blender/editors/sculpt_paint/paint_canvas.cc
@@ -18,6 +18,8 @@
#include "BKE_material.h"
#include "BKE_paint.h"
+#include "DEG_depsgraph.h"
+
#include "NOD_shader.h"
#include "UI_resources.h"
@@ -528,4 +530,15 @@ bool ED_paint_tool_use_canvas(struct bContext *C, struct Object *ob)
return false;
}
+
+void ED_paint_do_msg_notify_active_tool_changed(struct bContext *C,
+ struct wmMsgSubscribeKey *msg_key,
+ struct wmMsgSubscribeValue *msg_val)
+{
+ Object *ob = CTX_data_active_object(C);
+ if (ob == nullptr) {
+ return;
+ }
+ DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
+}
}
\ No newline at end of file
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index e2a027837a7..3c7d1a545b7 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -43,6 +43,7 @@
#include "ED_object.h"
#include "ED_outliner.h"
+#include "ED_paint.h"
#include "ED_render.h"
#include "ED_screen.h"
#include "ED_space_api.h"
@@ -1275,6 +1276,12 @@ static void view3d_main_region_message_subscribe(const wmRegionMessageSubscribeP
.notify = ED_region_do_msg_notify_tag_redraw,
};
+ wmMsgSubscribeValue msg_sub_value_pbvh_refresh = {
+ .owner = region,
+ .user_data = region,
+ .notify = ED_paint_do_msg_notify_active_tool_changed,
+ };
+
for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
msg_key_params.ptr.type = type_array[i];
WM_msg_subscribe_rna_params(mbus, &msg_key_params, &msg_sub_value_region_tag_redraw, __func__);
@@ -1308,6 +1315,10 @@ static void view3d_main_region_message_subscribe(const wmRegionMessageSubscribeP
case OB_MODE_PARTICLE_EDIT:
WM_msg_subscribe_rna_anon_type(mbus, ParticleEdit, &msg_sub_value_region_tag_redraw);
break;
+
+ case OB_MODE_SCULPT:
+ WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_pbvh_refresh);
+ break;
default:
break;
}
More information about the Bf-blender-cvs
mailing list