Sculpt Branch:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 7 Dec 2009 19:56:59 +0000 (19:56 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 7 Dec 2009 19:56:59 +0000 (19:56 +0000)
Subdivision set with Ctrl+1-5 now works for multires as well.

release/scripts/op/object.py
source/blender/editors/object/object_ops.c
source/blender/editors/sculpt_paint/paint_ops.c

index 86678176fc98efe355b94e876df407fe991a136d..e29259cacfb9832ffab30d0ca481d45d1328bbfb 100644 (file)
@@ -75,16 +75,16 @@ class SelectPattern(bpy.types.Operator):
         row.prop(props, "extend")
 
 
-class SubsurfSet(bpy.types.Operator):
+class SubdivisionSet(bpy.types.Operator):
     '''Sets a Subdivision Surface Level (1-5)'''
 
-    bl_idname = "object.subsurf_set"
-    bl_label = "Subsurf Set"
+    bl_idname = "object.subdivision_set"
+    bl_label = "Subdivision Set"
     bl_register = True
     bl_undo = True
 
     level = IntProperty(name="Level",
-            default=1, min=0, max=6)
+            default=1, min=0, max=100, soft_min=0, soft_max=6)
 
     def poll(self, context):
         ob = context.active_object
@@ -94,7 +94,11 @@ class SubsurfSet(bpy.types.Operator):
         level = self.properties.level
         ob = context.active_object
         for mod in ob.modifiers:
-            if mod.type == 'SUBSURF':
+            if mod.type == 'MULTIRES' and ob.mode == 'SCULPT':
+                if mod.sculpt_levels != level:
+                    mod.sculpt_levels = level
+                return ('FINISHED',)
+            elif mod.type == 'SUBSURF' or mod.type == 'MULTIRES':
                 if mod.levels != level:
                     mod.levels = level
                 return ('FINISHED',)
@@ -120,5 +124,6 @@ class Retopo(bpy.types.Operator):
 
 
 bpy.ops.add(SelectPattern)
-bpy.ops.add(SubsurfSet)
+bpy.ops.add(SubdivisionSet)
 bpy.ops.add(Retopo)
+
index 49c947f52c8d87275f17eb7891f5f42d77c292ab..13b1155d61636a56bc86a368f405ec25169c908a 100644 (file)
@@ -227,6 +227,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
 {
        wmKeyMap *keymap;
        wmKeyMapItem *kmi;
+       int i;
        
        /* Objects, Regardless of Mode -------------------------------------------------- */
        keymap= WM_keymap_find(keyconf, "Object Non-modal", 0, 0);
@@ -314,16 +315,10 @@ void ED_keymap_object(wmKeyConfig *keyconf)
        WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
        WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
 
-       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subsurf_set", ONEKEY, KM_PRESS, KM_CTRL, 0);
-       RNA_int_set(kmi->ptr, "level", 1);
-       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subsurf_set", TWOKEY, KM_PRESS, KM_CTRL, 0);
-       RNA_int_set(kmi->ptr, "level", 2);
-       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subsurf_set", THREEKEY, KM_PRESS, KM_CTRL, 0);
-       RNA_int_set(kmi->ptr, "level", 3);
-       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subsurf_set", FOURKEY, KM_PRESS, KM_CTRL, 0);
-       RNA_int_set(kmi->ptr, "level", 4);
-       kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subsurf_set", FIVEKEY, KM_PRESS, KM_CTRL, 0);
-       RNA_int_set(kmi->ptr, "level", 5);
+       for(i=1; i<=5; i++) {
+               kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0);
+               RNA_int_set(kmi->ptr, "level", i);
+       }
 
        /* Lattice -------------------------------------------------------------------- */
        keymap= WM_keymap_find(keyconf, "Lattice", 0, 0);
index 92812c2ab0859b34386642ef67ffae4e03560d17..ae694ed863ba576cc149419df6c736ed3d87513f 100644 (file)
@@ -179,6 +179,7 @@ static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *path)
 void ED_keymap_paint(wmKeyConfig *keyconf)
 {
        wmKeyMap *keymap;
+       int i;
        
        /* Sculpt mode */
        keymap= WM_keymap_find(keyconf, "Sculpt", 0, 0);
@@ -193,6 +194,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
 
        ed_keymap_paint_brush_switch(keymap, "tool_settings.sculpt.active_brush_index");
 
+       for(i=1; i<=5; i++)
+               RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i);
+
        /* Vertex Paint mode */
        keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0);
        keymap->poll= vertex_paint_poll;