|
Blender
V2.59
|
00001 /* 00002 * 00003 * ***** BEGIN GPL LICENSE BLOCK ***** 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software Foundation, 00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * ***** END GPL LICENSE BLOCK ***** 00020 */ 00021 00026 #include "MEM_guardedalloc.h" 00027 00028 #include <stdlib.h> 00029 #include "BLI_string.h" 00030 #include "BLI_utildefines.h" 00031 00032 #include "DNA_object_types.h" 00033 #include "DNA_scene_types.h" 00034 #include "DNA_brush_types.h" 00035 00036 #include "BKE_brush.h" 00037 #include "BKE_context.h" 00038 #include "BKE_paint.h" 00039 #include "BKE_main.h" 00040 00041 #include "ED_sculpt.h" 00042 #include "ED_screen.h" 00043 #include "UI_resources.h" 00044 00045 #include "WM_api.h" 00046 #include "WM_types.h" 00047 00048 #include "RNA_access.h" 00049 #include "RNA_define.h" 00050 #include "RNA_enum_types.h" 00051 00052 #include "paint_intern.h" 00053 #include "sculpt_intern.h" 00054 00055 #include <string.h> 00056 //#include <stdio.h> 00057 #include <stddef.h> 00058 00059 /* Brush operators */ 00060 static int brush_add_exec(bContext *C, wmOperator *UNUSED(op)) 00061 { 00062 /*int type = RNA_enum_get(op->ptr, "type");*/ 00063 Paint *paint = paint_get_active(CTX_data_scene(C)); 00064 struct Brush *br = paint_brush(paint); 00065 00066 if (br) 00067 br = copy_brush(br); 00068 else 00069 br = add_brush("Brush"); 00070 00071 paint_brush_set(paint_get_active(CTX_data_scene(C)), br); 00072 00073 return OPERATOR_FINISHED; 00074 } 00075 00076 static void BRUSH_OT_add(wmOperatorType *ot) 00077 { 00078 /* identifiers */ 00079 ot->name= "Add Brush"; 00080 ot->description= "Add brush by mode type"; 00081 ot->idname= "BRUSH_OT_add"; 00082 00083 /* api callbacks */ 00084 ot->exec= brush_add_exec; 00085 00086 /* flags */ 00087 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; 00088 } 00089 00090 00091 static int brush_scale_size_exec(bContext *C, wmOperator *op) 00092 { 00093 Paint *paint= paint_get_active(CTX_data_scene(C)); 00094 struct Brush *brush= paint_brush(paint); 00095 // Object *ob= CTX_data_active_object(C); 00096 float scalar= RNA_float_get(op->ptr, "scalar"); 00097 00098 if (brush) { 00099 // pixel radius 00100 { 00101 const int old_size= brush_size(brush); 00102 int size= (int)(scalar*old_size); 00103 00104 if (old_size == size) { 00105 if (scalar > 1) { 00106 size++; 00107 } 00108 else if (scalar < 1) { 00109 size--; 00110 } 00111 } 00112 CLAMP(size, 1, 2000); // XXX magic number 00113 00114 brush_set_size(brush, size); 00115 } 00116 00117 // unprojected radius 00118 { 00119 float unprojected_radius= scalar*brush_unprojected_radius(brush); 00120 00121 if (unprojected_radius < 0.001f) // XXX magic number 00122 unprojected_radius= 0.001f; 00123 00124 brush_set_unprojected_radius(brush, unprojected_radius); 00125 } 00126 } 00127 00128 return OPERATOR_FINISHED; 00129 } 00130 00131 static void BRUSH_OT_scale_size(wmOperatorType *ot) 00132 { 00133 /* identifiers */ 00134 ot->name= "Scale Sculpt/Paint Brush Size"; 00135 ot->description= "Change brush size by a scalar"; 00136 ot->idname= "BRUSH_OT_scale_size"; 00137 00138 /* api callbacks */ 00139 ot->exec= brush_scale_size_exec; 00140 00141 /* flags */ 00142 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; 00143 00144 RNA_def_float(ot->srna, "scalar", 1, 0, 2, "Scalar", "Factor to scale brush size by", 0, 2); 00145 } 00146 00147 static int vertex_color_set_exec(bContext *C, wmOperator *UNUSED(op)) 00148 { 00149 Scene *scene = CTX_data_scene(C); 00150 Object *obact = CTX_data_active_object(C); 00151 unsigned int paintcol = vpaint_get_current_col(scene->toolsettings->vpaint); 00152 vpaint_fill(obact, paintcol); 00153 00154 ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views 00155 return OPERATOR_FINISHED; 00156 } 00157 00158 static void PAINT_OT_vertex_color_set(wmOperatorType *ot) 00159 { 00160 /* identifiers */ 00161 ot->name= "Set Vertex Colors"; 00162 ot->idname= "PAINT_OT_vertex_color_set"; 00163 00164 /* api callbacks */ 00165 ot->exec= vertex_color_set_exec; 00166 ot->poll= vertex_paint_mode_poll; 00167 00168 /* flags */ 00169 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; 00170 } 00171 00172 static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) 00173 { 00174 Paint *paint = paint_get_active(CTX_data_scene(C)); 00175 struct Brush *brush = paint_brush(paint); 00176 Object *ob = CTX_data_active_object(C); 00177 00178 if(!ob) return OPERATOR_CANCELLED; 00179 00180 if(ob->mode & OB_MODE_SCULPT) 00181 brush_reset_sculpt(brush); 00182 /* TODO: other modes */ 00183 00184 return OPERATOR_FINISHED; 00185 } 00186 00187 static void BRUSH_OT_reset(wmOperatorType *ot) 00188 { 00189 /* identifiers */ 00190 ot->name= "Reset Brush"; 00191 ot->description= "Return brush to defaults based on current tool"; 00192 ot->idname= "BRUSH_OT_reset"; 00193 00194 /* api callbacks */ 00195 ot->exec= brush_reset_exec; 00196 00197 /* flags */ 00198 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; 00199 } 00200 00201 /* generic functions for setting the active brush based on the tool */ 00202 static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode) 00203 { 00204 struct Brush *brush; 00205 00206 if(!brush_orig && !(brush_orig= bmain->brush.first)) { 00207 return NULL; 00208 } 00209 00210 /* get the next brush with the active tool */ 00211 for( brush= brush_orig->id.next ? brush_orig->id.next : bmain->brush.first; 00212 brush != brush_orig; 00213 brush= brush->id.next ? brush->id.next : bmain->brush.first) 00214 { 00215 if( (brush->ob_mode & ob_mode) && 00216 (*(((char *)brush) + tool_offset) == tool) 00217 ) { 00218 return brush; 00219 } 00220 } 00221 00222 return NULL; 00223 00224 } 00225 00226 static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, const size_t tool_offset, const int ob_mode) 00227 { 00228 struct Brush *brush, *brush_orig= paint_brush(paint); 00229 00230 brush= brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); 00231 00232 if(brush) { 00233 paint_brush_set(paint, brush); 00234 WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); 00235 return OPERATOR_FINISHED; 00236 } 00237 else { 00238 return OPERATOR_CANCELLED; 00239 } 00240 } 00241 00242 static int brush_sculpt_tool_set_exec(bContext *C, wmOperator *op) 00243 { 00244 Main *bmain= CTX_data_main(C); 00245 Scene *scene= CTX_data_scene(C); 00246 00247 return brush_generic_tool_set(bmain, &scene->toolsettings->sculpt->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, sculpt_tool), OB_MODE_SCULPT); 00248 } 00249 00250 static void BRUSH_OT_sculpt_tool_set(wmOperatorType *ot) 00251 { 00252 /* identifiers */ 00253 ot->name= "Sculpt Tool Set"; 00254 ot->description= "Set the sculpt tool"; 00255 ot->idname= "BRUSH_OT_sculpt_tool_set"; 00256 00257 /* api callbacks */ 00258 ot->exec= brush_sculpt_tool_set_exec; 00259 00260 /* flags */ 00261 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; 00262 00263 /* props */ 00264 ot->prop= RNA_def_enum(ot->srna, "tool", brush_sculpt_tool_items, 0, "Tool", ""); 00265 } 00266 00267 static int brush_vertex_tool_set_exec(bContext *C, wmOperator *op) 00268 { 00269 Main *bmain= CTX_data_main(C); 00270 Scene *scene= CTX_data_scene(C); 00271 00272 return brush_generic_tool_set(bmain, &scene->toolsettings->vpaint->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, vertexpaint_tool), OB_MODE_VERTEX_PAINT); 00273 } 00274 00275 static void BRUSH_OT_vertex_tool_set(wmOperatorType *ot) 00276 { 00277 /* identifiers */ 00278 ot->name= "Vertex Paint Tool Set"; 00279 ot->description= "Set the vertex paint tool"; 00280 ot->idname= "BRUSH_OT_vertex_tool_set"; 00281 00282 /* api callbacks */ 00283 ot->exec= brush_vertex_tool_set_exec; 00284 00285 /* flags */ 00286 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; 00287 00288 /* props */ 00289 ot->prop= RNA_def_enum(ot->srna, "tool", brush_vertex_tool_items, 0, "Tool", ""); 00290 } 00291 00292 static int brush_weight_tool_set_exec(bContext *C, wmOperator *op) 00293 { 00294 Main *bmain= CTX_data_main(C); 00295 Scene *scene= CTX_data_scene(C); 00296 /* vertexpaint_tool is used for weight paint mode */ 00297 return brush_generic_tool_set(bmain, &scene->toolsettings->wpaint->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, vertexpaint_tool), OB_MODE_WEIGHT_PAINT); 00298 } 00299 00300 static void BRUSH_OT_weight_tool_set(wmOperatorType *ot) 00301 { 00302 /* identifiers */ 00303 ot->name= "Weight Paint Tool Set"; 00304 ot->description= "Set the weight paint tool"; 00305 ot->idname= "BRUSH_OT_weight_tool_set"; 00306 00307 /* api callbacks */ 00308 ot->exec= brush_weight_tool_set_exec; 00309 00310 /* flags */ 00311 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; 00312 00313 /* props */ 00314 ot->prop= RNA_def_enum(ot->srna, "tool", brush_vertex_tool_items, 0, "Tool", ""); 00315 } 00316 00317 static int brush_image_tool_set_exec(bContext *C, wmOperator *op) 00318 { 00319 Main *bmain= CTX_data_main(C); 00320 Scene *scene= CTX_data_scene(C); 00321 00322 return brush_generic_tool_set(bmain, &scene->toolsettings->imapaint.paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, imagepaint_tool), OB_MODE_TEXTURE_PAINT); 00323 } 00324 00325 static void BRUSH_OT_image_tool_set(wmOperatorType *ot) 00326 { 00327 /* identifiers */ 00328 ot->name= "Image Paint Tool Set"; 00329 ot->description= "Set the image tool"; 00330 ot->idname= "BRUSH_OT_image_tool_set"; 00331 00332 /* api callbacks */ 00333 ot->exec= brush_image_tool_set_exec; 00334 00335 /* flags */ 00336 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; 00337 00338 /* props */ 00339 ot->prop= RNA_def_enum(ot->srna, "tool", brush_image_tool_items, 0, "Tool", ""); 00340 } 00341 00342 00343 /**************************** registration **********************************/ 00344 00345 void ED_operatortypes_paint(void) 00346 { 00347 /* brush */ 00348 WM_operatortype_append(BRUSH_OT_add); 00349 WM_operatortype_append(BRUSH_OT_scale_size); 00350 WM_operatortype_append(BRUSH_OT_curve_preset); 00351 WM_operatortype_append(BRUSH_OT_reset); 00352 00353 /* note, particle uses a different system, can be added with existing operators in wm.py */ 00354 WM_operatortype_append(BRUSH_OT_sculpt_tool_set); 00355 WM_operatortype_append(BRUSH_OT_vertex_tool_set); 00356 WM_operatortype_append(BRUSH_OT_weight_tool_set); 00357 WM_operatortype_append(BRUSH_OT_image_tool_set); 00358 00359 /* image */ 00360 WM_operatortype_append(PAINT_OT_texture_paint_toggle); 00361 WM_operatortype_append(PAINT_OT_image_paint); 00362 WM_operatortype_append(PAINT_OT_sample_color); 00363 WM_operatortype_append(PAINT_OT_grab_clone); 00364 WM_operatortype_append(PAINT_OT_clone_cursor_set); 00365 WM_operatortype_append(PAINT_OT_project_image); 00366 WM_operatortype_append(PAINT_OT_image_from_view); 00367 00368 /* weight */ 00369 WM_operatortype_append(PAINT_OT_weight_paint_toggle); 00370 WM_operatortype_append(PAINT_OT_weight_paint); 00371 WM_operatortype_append(PAINT_OT_weight_set); 00372 WM_operatortype_append(PAINT_OT_weight_from_bones); 00373 WM_operatortype_append(PAINT_OT_weight_sample); 00374 WM_operatortype_append(PAINT_OT_weight_sample_group); 00375 00376 /* vertex */ 00377 WM_operatortype_append(PAINT_OT_vertex_paint_toggle); 00378 WM_operatortype_append(PAINT_OT_vertex_paint); 00379 WM_operatortype_append(PAINT_OT_vertex_color_set); 00380 00381 /* face-select */ 00382 WM_operatortype_append(PAINT_OT_face_select_linked); 00383 WM_operatortype_append(PAINT_OT_face_select_linked_pick); 00384 WM_operatortype_append(PAINT_OT_face_select_all); 00385 WM_operatortype_append(PAINT_OT_face_select_inverse); 00386 WM_operatortype_append(PAINT_OT_face_select_hide); 00387 WM_operatortype_append(PAINT_OT_face_select_reveal); 00388 } 00389 00390 00391 static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *mode) 00392 { 00393 wmKeyMapItem *kmi; 00394 00395 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ONEKEY, KM_PRESS, 0, 0); 00396 RNA_string_set(kmi->ptr, "mode", mode); 00397 RNA_int_set(kmi->ptr, "index", 0); 00398 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", TWOKEY, KM_PRESS, 0, 0); 00399 RNA_string_set(kmi->ptr, "mode", mode); 00400 RNA_int_set(kmi->ptr, "index", 1); 00401 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", THREEKEY, KM_PRESS, 0, 0); 00402 RNA_string_set(kmi->ptr, "mode", mode); 00403 RNA_int_set(kmi->ptr, "index", 2); 00404 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FOURKEY, KM_PRESS, 0, 0); 00405 RNA_string_set(kmi->ptr, "mode", mode); 00406 RNA_int_set(kmi->ptr, "index", 3); 00407 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FIVEKEY, KM_PRESS, 0, 0); 00408 RNA_string_set(kmi->ptr, "mode", mode); 00409 RNA_int_set(kmi->ptr, "index", 4); 00410 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SIXKEY, KM_PRESS, 0, 0); 00411 RNA_string_set(kmi->ptr, "mode", mode); 00412 RNA_int_set(kmi->ptr, "index", 5); 00413 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SEVENKEY, KM_PRESS, 0, 0); 00414 RNA_string_set(kmi->ptr, "mode", mode); 00415 RNA_int_set(kmi->ptr, "index", 6); 00416 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", EIGHTKEY, KM_PRESS, 0, 0); 00417 RNA_string_set(kmi->ptr, "mode", mode); 00418 RNA_int_set(kmi->ptr, "index", 7); 00419 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", NINEKEY, KM_PRESS, 0, 0); 00420 RNA_string_set(kmi->ptr, "mode", mode); 00421 RNA_int_set(kmi->ptr, "index", 8); 00422 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ZEROKEY, KM_PRESS, 0, 0); 00423 RNA_string_set(kmi->ptr, "mode", mode); 00424 RNA_int_set(kmi->ptr, "index", 9); 00425 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ONEKEY, KM_PRESS, KM_SHIFT, 0); 00426 RNA_string_set(kmi->ptr, "mode", mode); 00427 RNA_int_set(kmi->ptr, "index", 10); 00428 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", TWOKEY, KM_PRESS, KM_SHIFT, 0); 00429 RNA_string_set(kmi->ptr, "mode", mode); 00430 RNA_int_set(kmi->ptr, "index", 11); 00431 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", THREEKEY, KM_PRESS, KM_SHIFT, 0); 00432 RNA_string_set(kmi->ptr, "mode", mode); 00433 RNA_int_set(kmi->ptr, "index", 12); 00434 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FOURKEY, KM_PRESS, KM_SHIFT, 0); 00435 RNA_string_set(kmi->ptr, "mode", mode); 00436 RNA_int_set(kmi->ptr, "index", 13); 00437 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FIVEKEY, KM_PRESS, KM_SHIFT, 0); 00438 RNA_string_set(kmi->ptr, "mode", mode); 00439 RNA_int_set(kmi->ptr, "index", 14); 00440 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SIXKEY, KM_PRESS, KM_SHIFT, 0); 00441 RNA_string_set(kmi->ptr, "mode", mode); 00442 RNA_int_set(kmi->ptr, "index", 15); 00443 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SEVENKEY, KM_PRESS, KM_SHIFT, 0); 00444 RNA_string_set(kmi->ptr, "mode", mode); 00445 RNA_int_set(kmi->ptr, "index", 16); 00446 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", EIGHTKEY, KM_PRESS, KM_SHIFT, 0); 00447 RNA_string_set(kmi->ptr, "mode", mode); 00448 RNA_int_set(kmi->ptr, "index", 17); 00449 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", NINEKEY, KM_PRESS, KM_SHIFT, 0); 00450 RNA_string_set(kmi->ptr, "mode", mode); 00451 RNA_int_set(kmi->ptr, "index", 18); 00452 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ZEROKEY, KM_PRESS, KM_SHIFT, 0); 00453 RNA_string_set(kmi->ptr, "mode", mode); 00454 RNA_int_set(kmi->ptr, "index", 19); 00455 } 00456 00457 static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path)) 00458 { 00459 wmKeyMapItem *kmi; 00460 00461 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_scale_size", LEFTBRACKETKEY, KM_PRESS, 0, 0); 00462 RNA_float_set(kmi->ptr, "scalar", 0.9); 00463 00464 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_scale_size", RIGHTBRACKETKEY, KM_PRESS, 0, 0); 00465 RNA_float_set(kmi->ptr, "scalar", 10.0/9.0); // 1.1111.... 00466 } 00467 00468 typedef enum { 00469 RC_COLOR = 1, 00470 RC_ROTATION = 2, 00471 RC_ZOOM = 4, 00472 } RCFlags; 00473 00474 static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path, 00475 const char *output_name, const char *input_name) 00476 { 00477 char *path; 00478 00479 path = BLI_sprintfN("%s.%s", brush_path, input_name); 00480 RNA_string_set(ptr, output_name, path); 00481 MEM_freeN(path); 00482 } 00483 00484 static void set_brush_rc_props(PointerRNA *ptr, const char *paint, 00485 const char *prop, RCFlags flags) 00486 { 00487 char *brush_path; 00488 00489 brush_path = BLI_sprintfN("tool_settings.%s.brush", paint); 00490 00491 set_brush_rc_path(ptr, brush_path, "data_path", prop); 00492 set_brush_rc_path(ptr, brush_path, "color_path", "cursor_color_add"); 00493 set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle"); 00494 RNA_string_set(ptr, "image_id", brush_path); 00495 00496 if(flags & RC_COLOR) 00497 set_brush_rc_path(ptr, brush_path, "fill_color_path", "color"); 00498 if(flags & RC_ZOOM) 00499 RNA_string_set(ptr, "zoom_path", "space_data.zoom"); 00500 00501 MEM_freeN(brush_path); 00502 } 00503 00504 static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *paint, 00505 RCFlags flags) 00506 { 00507 wmKeyMapItem *kmi; 00508 00509 kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0); 00510 set_brush_rc_props(kmi->ptr, paint, "size", flags); 00511 00512 kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); 00513 set_brush_rc_props(kmi->ptr, paint, "strength", flags); 00514 00515 if(flags & RC_ROTATION) { 00516 kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0); 00517 set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", flags); 00518 } 00519 } 00520 00521 void ED_keymap_paint(wmKeyConfig *keyconf) 00522 { 00523 wmKeyMap *keymap; 00524 wmKeyMapItem *kmi; 00525 int i; 00526 00527 /* Sculpt mode */ 00528 keymap= WM_keymap_find(keyconf, "Sculpt", 0, 0); 00529 keymap->poll= sculpt_poll; 00530 00531 RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); 00532 RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT); 00533 RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH); 00534 00535 for(i=0; i<=5; i++) 00536 RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i); 00537 00538 /* multires switch */ 00539 kmi= WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEUPKEY, KM_PRESS, 0, 0); 00540 RNA_int_set(kmi->ptr, "level", 1); 00541 RNA_boolean_set(kmi->ptr, "relative", 1); 00542 00543 kmi= WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEDOWNKEY, KM_PRESS, 0, 0); 00544 RNA_int_set(kmi->ptr, "level", -1); 00545 RNA_boolean_set(kmi->ptr, "relative", 1); 00546 00547 ed_keymap_paint_brush_switch(keymap, "sculpt"); 00548 ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size"); 00549 ed_keymap_paint_brush_radial_control(keymap, "sculpt", RC_ROTATION); 00550 00551 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", DKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_DRAW); 00552 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", SKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_SMOOTH); 00553 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", PKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_PINCH); 00554 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", IKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_INFLATE); 00555 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", GKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_GRAB); 00556 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", LKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_LAYER); 00557 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", TKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "tool", SCULPT_TOOL_FLATTEN); /* was just TKEY in 2.4x */ 00558 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", CKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_CLAY); 00559 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", CKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "tool", SCULPT_TOOL_CREASE); 00560 00561 /* */ 00562 kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", AKEY, KM_PRESS, 0, 0); 00563 RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.stroke_method"); 00564 00565 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SKEY, KM_PRESS, KM_SHIFT, 0); 00566 RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.use_smooth_stroke"); 00567 00568 kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", RKEY, KM_PRESS, 0, 0); 00569 RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.texture_angle_source_random"); 00570 00571 /* Vertex Paint mode */ 00572 keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0); 00573 keymap->poll= vertex_paint_mode_poll; 00574 00575 WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0); 00576 WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0); 00577 00578 WM_keymap_add_item(keymap, 00579 "PAINT_OT_vertex_color_set",KKEY, KM_PRESS, KM_SHIFT, 0); 00580 00581 ed_keymap_paint_brush_switch(keymap, "vertex_paint"); 00582 ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size"); 00583 ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR); 00584 00585 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ 00586 RNA_string_set(kmi->ptr, "data_path", "vertex_paint_object.data.use_paint_mask"); 00587 00588 /* Weight Paint mode */ 00589 keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0); 00590 keymap->poll= weight_paint_mode_poll; 00591 00592 WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0); 00593 00594 /* these keys are from 2.4x but could be changed */ 00595 WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); 00596 WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample_group", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); 00597 00598 WM_keymap_add_item(keymap, 00599 "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0); 00600 00601 ed_keymap_paint_brush_switch(keymap, "weight_paint"); 00602 ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size"); 00603 ed_keymap_paint_brush_radial_control(keymap, "weight_paint", 0); 00604 00605 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ 00606 RNA_string_set(kmi->ptr, "data_path", "weight_paint_object.data.use_paint_mask"); 00607 00608 WM_keymap_verify_item(keymap, "PAINT_OT_weight_from_bones", WKEY, KM_PRESS, 0, 0); 00609 00610 /* Image/Texture Paint mode */ 00611 keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0); 00612 keymap->poll= image_texture_paint_poll; 00613 00614 WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0); 00615 WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0); 00616 WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0); 00617 WM_keymap_add_item(keymap, "PAINT_OT_clone_cursor_set", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); 00618 00619 ed_keymap_paint_brush_switch(keymap, "image_paint"); 00620 ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size"); 00621 ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR|RC_ZOOM); 00622 00623 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ 00624 RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask"); 00625 00626 /* face-mask mode */ 00627 keymap= WM_keymap_find(keyconf, "Face Mask", 0, 0); 00628 keymap->poll= facemask_paint_poll; 00629 00630 WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, 0, 0); 00631 WM_keymap_add_item(keymap, "PAINT_OT_face_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0); 00632 WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, 0, 0); 00633 RNA_boolean_set(WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); 00634 WM_keymap_add_item(keymap, "PAINT_OT_face_select_reveal", HKEY, KM_PRESS, KM_ALT, 0); 00635 00636 WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); 00637 WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked_pick", LKEY, KM_PRESS, 0, 0); 00638 }