[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4816] contrib/py/scripts/addons/ presets/keyconfig/blender_2012_experimental.py: Experimental keymap: changed the create edge/face tool to contextually

Nathan Vegdahl cessen at cessen.com
Sun Oct 27 21:58:56 CET 2013


Revision: 4816
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4816
Author:   cessen
Date:     2013-10-27 20:58:55 +0000 (Sun, 27 Oct 2013)
Log Message:
-----------
Experimental keymap: changed the create edge/face tool to contextually
understand when all selected mesh elements are part of the same face, and
trigger the "connect" tool instead in that case.

This prevents accidental creation of weird meshes when creating an edge
between two vertices on the same face.  The user almost certainly expects
the face to be split by the new edge in that case.  This makes that happen.

Modified Paths:
--------------
    contrib/py/scripts/addons/presets/keyconfig/blender_2012_experimental.py

Modified: contrib/py/scripts/addons/presets/keyconfig/blender_2012_experimental.py
===================================================================
--- contrib/py/scripts/addons/presets/keyconfig/blender_2012_experimental.py	2013-10-27 05:35:06 UTC (rev 4815)
+++ contrib/py/scripts/addons/presets/keyconfig/blender_2012_experimental.py	2013-10-27 20:58:55 UTC (rev 4816)
@@ -7,6 +7,7 @@
 #   user-configurable.
 
 import bpy
+import bmesh
 
 ######################
 # Misc configuration
@@ -249,6 +250,53 @@
 bpy.utils.register_class(SetEditMeshSelectMode)
 
 
+class MeshCreateEdgeFaceContextual(bpy.types.Operator):
+    """ Creates edges or faces from selected vertices,
+        but understands that if it's creating an edge across
+        an existing face that it should split it.
+    """
+    bl_idname = "mesh.create_edge_face_contextual"
+    bl_label = "Create Edge/Face Contextual"
+    bl_options = {'UNDO'}
+    
+    @classmethod
+    def poll(cls, context):
+        return (context.active_object is not None) and (context.mode == "EDIT_MESH")
+    
+    def execute(self, context):
+        bm = bmesh.from_edit_mesh(context.active_object.data)
+        
+        # Get a list of selected vertices
+        selected_verts = [v.index for v in bm.verts if v.select]
+        
+        # Accumulate a list of faces that the selected verts belong to,
+        # and a count for each face of how many selected verts belong to
+        # them.
+        face_counts = {}
+        for i in selected_verts:
+            for f in bm.verts[i].link_faces:
+                if f.index in face_counts:
+                    face_counts[f.index] += 1
+                else:
+                    face_counts[f.index] = 1
+        
+        # Check if any face has all selected verts
+        do_connect = False
+        for i in face_counts:
+            if face_counts[i] == len(selected_verts):
+                do_connect = True
+                break
+        
+        # Do the chosen operation
+        if not do_connect:
+            bpy.ops.mesh.edge_face_add()
+        else:
+            bpy.ops.mesh.vert_connect()
+        
+        return {'FINISHED'}
+bpy.utils.register_class(MeshCreateEdgeFaceContextual)
+
+
 class MeshDeleteContextual(bpy.types.Operator):
     """ Deletes mesh elements based on context instead
         of forcing the user to select from a menu what
@@ -1308,7 +1356,7 @@
     kmi.properties.name = 'INFO_MT_mesh_add'
     
     # Add edge and face / vertex connect
-    kmi = km.keymap_items.new('mesh.edge_face_add', 'C', 'CLICK')
+    kmi = km.keymap_items.new('mesh.create_edge_face_contextual', 'C', 'CLICK')
     kmi = kmi = km.keymap_items.new('mesh.vert_connect', 'C', 'PRESS', shift=True)
     
     kmi = km.keymap_items.new('mesh.fill', 'C', 'PRESS', alt=True)
@@ -1476,20 +1524,13 @@
     # Map Sculpt
     km = kc.keymaps.new('Sculpt', space_type='EMPTY', region_type='WINDOW', modal=False)
 
-    # Sculpt strokes
-    # TODO: alt for MASK(?)
+    # Sculpt strokesff
     kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS')
     kmi.properties.mode = 'NORMAL'
     kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS', ctrl=True)
     kmi.properties.mode = 'INVERT'
     kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS', shift=True)
     kmi.properties.mode = 'SMOOTH'
-    #kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS', alt=True)
-    #kmi.properties.mode = 'MASK'
-    #kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS', alt=True, ctrl=True)
-    #kmi.properties.mode = 'MASK_INVERT'
-    #kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS', alt=True, shift=True)
-    #kmi.properties.mode = 'MASK_SMOOTH'
     
     # Change stroke methods
     kmi = km.keymap_items.new('wm.context_menu_enum', 'A', 'PRESS')
@@ -1504,7 +1545,7 @@
     kmi.properties.scalar = 0.9
     kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS')
     kmi.properties.scalar = 1.1111111111
-    kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS')
+    kmi = km.keymap_items.new('wm.radial_control', 'R', 'PRESS')
     kmi.properties.data_path_primary = 'tool_settings.sculpt.brush.size'
     kmi.properties.data_path_secondary = 'tool_settings.unified_paint_settings.size'
     kmi.properties.use_secondary = 'tool_settings.unified_paint_settings.use_unified_size'
@@ -1515,7 +1556,7 @@
     kmi.properties.image_id = 'tool_settings.sculpt.brush'
     
     # Brush strength
-    kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True)
+    kmi = km.keymap_items.new('wm.radial_control', 'R', 'PRESS', shift=True)
     kmi.properties.data_path_primary = 'tool_settings.sculpt.brush.strength'
     kmi.properties.data_path_secondary = 'tool_settings.unified_paint_settings.strength'
     kmi.properties.use_secondary = 'tool_settings.unified_paint_settings.use_unified_strength'
@@ -1526,7 +1567,7 @@
     kmi.properties.image_id = 'tool_settings.sculpt.brush'
     
     # Brush angle
-    kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True)
+    kmi = km.keymap_items.new('wm.radial_control', 'R', 'PRESS', ctrl=True)
     kmi.properties.data_path_primary = 'tool_settings.sculpt.brush.texture_slot.angle'
     kmi.properties.data_path_secondary = ''
     kmi.properties.use_secondary = ''
@@ -1706,6 +1747,175 @@
     kmi.properties.texmode = 'SECONDARY'
 
 
+def MapAdd_WeightPaint(kc):
+    km = kc.keymaps.new('Weight Paint', space_type='EMPTY', region_type='WINDOW', modal=False)
+
+    # Select bones/objects/etc
+    kmi = km.keymap_items.new('view3d.select', 'LEFTMOUSE', 'PRESS', alt=True)
+    kmi.properties.extend = False
+    kmi.properties.deselect = False
+    kmi.properties.toggle = False
+    kmi.properties.center = False
+    kmi.properties.enumerate = False
+    kmi.properties.object = False
+    kmi = km.keymap_items.new('view3d.select', 'LEFTMOUSE', 'PRESS', alt=True, shift=True)
+    kmi.properties.extend = True
+    kmi.properties.deselect = False
+    kmi.properties.toggle = False
+    kmi.properties.center = False
+    kmi.properties.enumerate = False
+    kmi.properties.object = False
+    kmi = km.keymap_items.new('view3d.select', 'LEFTMOUSE', 'PRESS', alt=True, ctrl=True)
+    kmi.properties.extend = False
+    kmi.properties.deselect = True
+    kmi.properties.toggle = False
+    kmi.properties.center = False
+    kmi.properties.enumerate = False
+    kmi.properties.object = False
+
+    # Paint weight
+    kmi = km.keymap_items.new('paint.weight_paint', 'LEFTMOUSE', 'PRESS')
+    
+    # Weight gradient
+    kmi = km.keymap_items.new('paint.weight_gradient', 'LEFTMOUSE', 'PRESS', ctrl=True)
+    kmi.properties.type = 'LINEAR'
+    kmi = km.keymap_items.new('paint.weight_gradient', 'LEFTMOUSE', 'PRESS', ctrl=True, shift=True)
+    kmi.properties.type = 'RADIAL'
+    
+    # Sample weight
+    kmi = km.keymap_items.new('paint.weight_sample', 'RIGHTMOUSE', 'PRESS', alt=True)
+    kmi = km.keymap_items.new('paint.weight_sample_group', 'RIGHTMOUSE', 'PRESS', alt=True, shift=True)
+    
+    # Brush radius
+    # TODO: armature pose mode masks this, instead of this masking
+    # armature pose mode.  Fix.
+    kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS')
+    kmi.properties.scalar = 0.9
+    kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS')
+    kmi.properties.scalar = 1.1111111111111111
+    kmi = km.keymap_items.new('wm.radial_control', 'R', 'PRESS')
+    kmi.properties.data_path_primary = 'tool_settings.weight_paint.brush.size'
+    kmi.properties.data_path_secondary = 'tool_settings.unified_paint_settings.size'
+    kmi.properties.use_secondary = 'tool_settings.unified_paint_settings.use_unified_size'
+    kmi.properties.rotation_path = 'tool_settings.weight_paint.brush.texture_slot.angle'
+    kmi.properties.color_path = 'tool_settings.weight_paint.brush.cursor_color_add'
+    kmi.properties.fill_color_path = ''
+    kmi.properties.zoom_path = ''
+    kmi.properties.image_id = 'tool_settings.weight_paint.brush'
+    kmi.properties.secondary_tex = False
+    
+    # Brush strength
+    kmi = km.keymap_items.new('wm.radial_control', 'R', 'PRESS', shift=True)
+    kmi.properties.data_path_primary = 'tool_settings.weight_paint.brush.strength'
+    kmi.properties.data_path_secondary = 'tool_settings.unified_paint_settings.strength'
+    kmi.properties.use_secondary = 'tool_settings.unified_paint_settings.use_unified_strength'
+    kmi.properties.rotation_path = 'tool_settings.weight_paint.brush.texture_slot.angle'
+    kmi.properties.color_path = 'tool_settings.weight_paint.brush.cursor_color_add'
+    kmi.properties.fill_color_path = ''
+    kmi.properties.zoom_path = ''
+    kmi.properties.image_id = 'tool_settings.weight_paint.brush'
+    kmi.properties.secondary_tex = False
+    
+    # Brush weight
+    kmi = km.keymap_items.new('wm.radial_control', 'W', 'PRESS')
+    kmi.properties.data_path_primary = 'tool_settings.weight_paint.brush.weight'
+    kmi.properties.data_path_secondary = 'tool_settings.unified_paint_settings.weight'
+    kmi.properties.use_secondary = 'tool_settings.unified_paint_settings.use_unified_weight'
+    kmi.properties.rotation_path = 'tool_settings.weight_paint.brush.texture_slot.angle'
+    kmi.properties.color_path = 'tool_settings.weight_paint.brush.cursor_color_add'
+    kmi.properties.fill_color_path = ''
+    kmi.properties.zoom_path = ''
+    kmi.properties.image_id = 'tool_settings.weight_paint.brush'
+    kmi.properties.secondary_tex = False
+    kmi = km.keymap_items.new('paint.weight_set', 'K', 'PRESS', shift=True)
+    
+    # Brush selection by index
+    kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS')
+    kmi.properties.mode = 'weight_paint'
+    kmi.properties.index = 0
+    kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS')
+    kmi.properties.mode = 'weight_paint'
+    kmi.properties.index = 1
+    kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS')
+    kmi.properties.mode = 'weight_paint'
+    kmi.properties.index = 2
+    kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS')
+    kmi.properties.mode = 'weight_paint'
+    kmi.properties.index = 3
+    kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS')
+    kmi.properties.mode = 'weight_paint'

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list