Don't trigger depsgraph update when switching tools.

This commit is contained in:
2022-04-05 13:50:06 +02:00
parent a327d98d3c
commit 66a3a589fa
3 changed files with 28 additions and 37 deletions

View File

@@ -129,10 +129,6 @@ eV3DShadingColorType ED_paint_shading_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);
/* Store the last used tool in the sculpt session. */
void ED_paint_tool_update_sticky_shading_color(struct bContext *C, struct Object *ob);

View File

@@ -1,10 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "ED_paint.h"
#include "BLI_compiler_compat.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_screen_types.h"
#include "DNA_workspace_types.h"
#include "BKE_context.h"
@@ -104,20 +104,11 @@ bool ED_paint_tool_use_canvas(struct bContext *C, struct Object *ob)
return false;
}
static bool paint_tool_last_used_tool_used_canvas(struct Object *ob)
{
if (ob == nullptr || ob->sculpt == nullptr) {
return false;
}
return ob->sculpt->sticky_shading_color;
}
eV3DShadingColorType ED_paint_shading_color_override(bContext *C,
const PaintModeSettings *settings,
Object *ob,
eV3DShadingColorType orig_color_type)
{
printf("%s %d\n", __func__, orig_color_type);
/* NOTE: This early exit is temporarily, until a paint mode has been added.
* For better integration with the vertex paint in sculpt mode we sticky
* with the last stoke when using tools like masking.
@@ -160,7 +151,6 @@ eV3DShadingColorType ED_paint_shading_color_override(bContext *C,
if (!U.experimental.use_sculpt_texture_paint && color_type == V3D_SHADING_TEXTURE_COLOR) {
return orig_color_type;
}
printf("%s %d->%d\n", __func__, orig_color_type, color_type);
return color_type;
}
@@ -219,20 +209,4 @@ int ED_paint_canvas_uvmap_layer_index_get(const struct PaintModeSettings *settin
}
return -1;
}
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;
}
if (ob->sculpt == nullptr) {
return;
}
PBVH *pbvh = ob->sculpt->pbvh;
BKE_pbvh_mark_update_color(pbvh);
printf("%s\n", __func__);
}
}

View File

@@ -1301,6 +1301,27 @@ static void view3d_main_region_listener(const wmRegionListenerParams *params)
}
}
static void view3d_do_msg_notify_workbench_view_update(struct bContext *C,
struct wmMsgSubscribeKey *UNUSED(msg_key),
struct wmMsgSubscribeValue *msg_val)
{
Scene *scene = CTX_data_scene(C);
ScrArea *area = (ScrArea *)msg_val->user_data;
View3D *v3d = (View3D *)area->spacedata.first;
if (v3d->shading.type == OB_SOLID) {
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
DRWUpdateContext drw_context = {NULL};
drw_context.bmain = CTX_data_main(C);
drw_context.depsgraph = CTX_data_depsgraph_pointer(C);
drw_context.scene = scene;
drw_context.view_layer = CTX_data_view_layer(C);
drw_context.region = (ARegion *)(msg_val->owner);
drw_context.v3d = v3d;
drw_context.engine_type = engine_type;
DRW_notify_view_update(&drw_context);
}
}
static void view3d_main_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
{
struct wmMsgBus *mbus = params->message_bus;
@@ -1342,10 +1363,10 @@ static void view3d_main_region_message_subscribe(const wmRegionMessageSubscribeP
.notify = ED_region_do_msg_notify_tag_redraw,
};
wmMsgSubscribeValue msg_sub_value_pbvh_refresh = {
wmMsgSubscribeValue msg_sub_value_workbench_view_update = {
.owner = region,
.user_data = region,
.notify = ED_paint_do_msg_notify_active_tool_changed,
.user_data = area,
.notify = view3d_do_msg_notify_workbench_view_update,
};
for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
@@ -1383,8 +1404,8 @@ static void view3d_main_region_message_subscribe(const wmRegionMessageSubscribeP
break;
case OB_MODE_SCULPT:
WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_pbvh_refresh);
WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
WM_msg_subscribe_rna_anon_prop(
mbus, WorkSpace, tools, &msg_sub_value_workbench_view_update);
break;
default:
break;