diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-07-19 21:44:44 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-07-19 21:44:44 +0400 |
commit | d410135408fcce7856cc044ba717297c89302a34 (patch) | |
tree | e8f863161288e9b7e02c4b88bc50cae1d18231b5 /source | |
parent | 8ac67fcd21039676011b5393e22a0fede89c34c9 (diff) |
Sculpt+Paint/2.5:
* Moved brush NKEY panel from C to Python. Could use some UI review :)
* Added a NULL check in bpy_internal_import.c, was crashing here on Python errors
* Added RNA for vpaint brush and for weight paint
* Added context for vpaint/wpaint similar to edit_object and sculpt_object
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 18 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_buttons.c | 84 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_vpaint.c | 4 | ||||
-rw-r--r-- | source/blender/python/generic/bpy_internal_import.c | 2 |
5 files changed, 27 insertions, 85 deletions
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 5944ef5f507..19750833b4d 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -37,6 +37,8 @@ #include "RNA_access.h" +#include "ED_object.h" + int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result) { bScreen *sc= CTX_wm_screen(C); @@ -47,8 +49,8 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult static const char *dir[] = { "scene", "selected_objects", "selected_bases", "selected_editable_objects", "selected_editable_bases" - "active_base", - "active_object", "edit_object", "sculpt_object", NULL}; + "active_base", "active_object", "edit_object", + "sculpt_object", "vpaint_object", "wpaint_object", NULL}; CTX_data_dir_set(result, dir); return 1; @@ -114,6 +116,18 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } + else if(CTX_data_equals(member, "vpaint_object")) { + if(G.f & G_VERTEXPAINT && scene->basact) + CTX_data_id_pointer_set(result, &scene->basact->object->id); + + return 1; + } + else if(CTX_data_equals(member, "wpaint_object")) { + if(G.f & G_WEIGHTPAINT && scene->basact) + CTX_data_id_pointer_set(result, &scene->basact->object->id); + + return 1; + } return 0; } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 077f34f3c4d..a50502e8265 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1101,81 +1101,6 @@ static void brush_idpoin_handle(bContext *C, ID *id, int event) } } -static int view3d_panel_brush_poll(const bContext *C, PanelType *pt) -{ - Brush **brp = current_brush_source(CTX_data_scene(C)); - - return ((G.f & (G_SCULPTMODE|G_TEXTUREPAINT|G_VERTEXPAINT|G_WEIGHTPAINT)) && brp); -} - -static void view3d_panel_brush(const bContext *C, Panel *pa) -{ - uiBlock *block; - ToolSettings *ts= CTX_data_tool_settings(C); - Brush **brp = current_brush_source(CTX_data_scene(C)), *br; - short w = 268, h = 400, cx = 10, cy = h; - rctf rect; - - br = *brp; - - block= uiLayoutFreeBlock(pa->layout); - uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL); - - uiBlockBeginAlign(block); - uiDefIDPoinButs(block, CTX_data_main(C), NULL, &br->id, ID_BR, NULL, cx, cy, - brush_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE); - cy-= 25; - uiBlockEndAlign(block); - - if(!br) - return; - - if(G.f & G_SCULPTMODE) { - uiBlockBeginAlign(block); - uiDefButC(block,ROW,B_REDR,"Draw",cx,cy,67,19,&br->sculpt_tool,14.0,SCULPT_TOOL_DRAW,0,0,"Draw lines on the model"); - uiDefButC(block,ROW,B_REDR,"Smooth",cx+67,cy,67,19,&br->sculpt_tool,14.0,SCULPT_TOOL_SMOOTH,0,0,"Interactively smooth areas of the model"); - uiDefButC(block,ROW,B_REDR,"Pinch",cx+134,cy,67,19,&br->sculpt_tool,14.0,SCULPT_TOOL_PINCH,0,0,"Interactively pinch areas of the model"); - uiDefButC(block,ROW,B_REDR,"Inflate",cx+201,cy,67,19,&br->sculpt_tool,14,SCULPT_TOOL_INFLATE,0,0,"Push vertices along the direction of their normals"); - cy-= 20; - uiDefButC(block,ROW,B_REDR,"Grab", cx,cy,67,19,&br->sculpt_tool,14,SCULPT_TOOL_GRAB,0,0,"Grabs a group of vertices and moves them with the mouse"); - uiDefButC(block,ROW,B_REDR,"Layer", cx+67,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_LAYER,0,0,"Adds a layer of depth"); - uiDefButC(block,ROW,B_REDR,"Flatten", cx+134,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_FLATTEN,0,0,"Interactively flatten areas of the model"); - uiDefButC(block,ROW,B_REDR,"Clay", cx+201,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_CLAY,0,0,"Build up depth quickly"); - cy-= 25; - uiBlockEndAlign(block); - } - - uiBlockBeginAlign(block); - uiDefButI(block,NUMSLI,B_NOP,"Size: ",cx,cy,w,19,&br->size,1.0,200.0,0,0,"Set brush radius in pixels"); - cy-= 20; - if(G.f & G_WEIGHTPAINT) { - uiDefButF(block,NUMSLI,B_NOP,"Weight: ",cx,cy,w,19,&ts->vgroup_weight,0,1.0,0,0,"Set vertex weight"); - cy-= 20; - } - uiDefButF(block,NUMSLI,B_NOP,"Strength: ",cx,cy,w,19,&br->alpha,0,1.0,0,0,"Set brush strength"); - cy-= 25; - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - - uiDefButBitS(block, TOG, BRUSH_AIRBRUSH, B_NOP, "Airbrush", cx,cy,w/3,19, &br->flag,0,0,0,0, "Brush makes changes without waiting for the mouse to move"); - uiDefButBitS(block, TOG, BRUSH_RAKE, B_NOP, "Rake", cx+w/3,cy,w/3,19, &br->flag,0,0,0,0, ""); - uiDefButBitS(block, TOG, BRUSH_ANCHORED, B_NOP, "Anchored", cx+w*2.0/3,cy,w/3,19, &br->flag,0,0,0,0, ""); - cy-= 20; - uiDefButBitS(block, TOG, BRUSH_SPACE, B_NOP, "Space", cx,cy,w/3,19, &br->flag,0,0,0,0, ""); - uiDefButF(block,NUMSLI,B_NOP,"Spacing: ",cx+w/3,cy,w*2.0/3,19,&br->spacing,1.0,500,0,0,""); - cy-= 20; - uiBlockEndAlign(block); - - if(br->curve) { - rect.xmin= cx; rect.xmax= cx + w; - rect.ymin= cy - 200; rect.ymax= cy; - uiBlockBeginAlign(block); - curvemap_buttons(block, br->curve, (char)0, B_NOP, 0, &rect); - uiBlockEndAlign(block); - } -} - static void view3d_panel_object(const bContext *C, Panel *pa) { uiBlock *block; @@ -1715,14 +1640,7 @@ void view3d_buttons_register(ARegionType *art) strcpy(pt->label, "Background Image"); pt->draw= view3d_panel_background; BLI_addtail(&art->paneltypes, pt); -*/ - pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel brush"); - strcpy(pt->idname, "VIEW3D_PT_brush"); - strcpy(pt->label, "Brush"); - pt->draw= view3d_panel_brush; - pt->poll= view3d_panel_brush_poll; - BLI_addtail(&art->paneltypes, pt); -/* + pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel transform spaces"); strcpy(pt->idname, "VIEW3D_PT_transform spaces"); strcpy(pt->label, "Transform Orientations"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 8d0fc4f6a8b..d1ef9dbbef3 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -294,6 +294,10 @@ void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_struct_type(prop, "VPaint"); RNA_def_property_ui_text(prop, "Vertex Paint", ""); + prop= RNA_def_property(srna, "wpaint", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "VPaint"); + RNA_def_property_ui_text(prop, "Weight Paint", ""); + /* Transform */ prop= RNA_def_property(srna, "proportional_editing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "proportional", 0); diff --git a/source/blender/makesrna/intern/rna_vpaint.c b/source/blender/makesrna/intern/rna_vpaint.c index a34099dffb7..bf6b70dab23 100644 --- a/source/blender/makesrna/intern/rna_vpaint.c +++ b/source/blender/makesrna/intern/rna_vpaint.c @@ -51,6 +51,10 @@ void RNA_def_vpaint(BlenderRNA *brna) srna= RNA_def_struct(brna, "VPaint", NULL); RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of the Vpaint tool."); + + prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Brush"); + RNA_def_property_ui_text(prop, "Brush", ""); prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_mode_items); diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index c41ea386c0e..b8c17d71ac4 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -65,6 +65,8 @@ PyObject *bpy_text_import( char *name, int *found ) Main *maggie= bpy_import_main; *found= 0; + + if(!maggie) return NULL; if (namelen>21-3) return NULL; /* we know this cant be importable, the name is too long for blender! */ |