Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-11-03 07:44:16 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-03 07:55:45 +0300
commit13c3c9b22fd8453d4418577efbc2ccb93209e92e (patch)
treecb332a7ed0e9022db2d189cd11bd983e33248468 /source/blender/makesrna/intern/rna_sculpt_paint.c
parenta18927463c18eec24c74ce8c0b3c261ff5ace889 (diff)
Cleanup: move brush query into utility function
Diffstat (limited to 'source/blender/makesrna/intern/rna_sculpt_paint.c')
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index dcddf77b963..86c860ef6a5 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -274,36 +274,17 @@ static bool rna_Brush_mode_poll(PointerRNA *ptr, PointerRNA value)
{
Scene *scene = (Scene *)ptr->id.data;
const Paint *paint = ptr->data;
- ToolSettings *ts = scene->toolsettings;
Brush *brush = value.id.data;
- int mode = 0;
+ eObjectMode ob_mode = 0;
uint brush_tool_offset = 0;
/* check the origin of the Paint struct to see which paint
* mode to select from */
- if (paint == &ts->imapaint.paint) {
- mode = OB_MODE_TEXTURE_PAINT;
- brush_tool_offset = offsetof(Brush, imagepaint_tool);
- }
- else if (paint == &ts->sculpt->paint) {
- mode = OB_MODE_SCULPT;
- brush_tool_offset = offsetof(Brush, sculpt_tool);
- }
- else if (paint == &ts->vpaint->paint) {
- mode = OB_MODE_VERTEX_PAINT;
- brush_tool_offset = offsetof(Brush, vertexpaint_tool);
- }
- else if (paint == &ts->wpaint->paint) {
- mode = OB_MODE_WEIGHT_PAINT;
- brush_tool_offset = offsetof(Brush, vertexpaint_tool);
- }
- else if (paint == &ts->gp_paint->paint) {
- mode = OB_MODE_GPENCIL_PAINT;
- brush_tool_offset = offsetof(Brush, gpencil_tool);
- }
+ bool ok = BKE_paint_brush_tool_info(scene, paint, &brush_tool_offset, &ob_mode);
+ BLI_assert(ok);
- if (brush->ob_mode & mode) {
+ if (brush->ob_mode & ob_mode) {
if (paint->brush) {
const char *tool_a = (const char *)POINTER_OFFSET(paint->brush, brush_tool_offset);
const char *tool_b = (const char *)POINTER_OFFSET(brush, brush_tool_offset);