diff options
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py | 8 | ||||
-rw-r--r-- | release/scripts/modules/bpy/path.py | 3 | ||||
-rw-r--r-- | release/scripts/modules/bpy/utils/__init__.py | 35 | ||||
-rw-r--r-- | release/scripts/modules/bpy_extras/object_utils.py | 41 |
4 files changed, 41 insertions, 46 deletions
diff --git a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py index bedad638dbe..da4a47783ad 100644 --- a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py +++ b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py @@ -25,7 +25,7 @@ __all__ = ( "generate", ) -def generate(context, space_type): +def generate(context, space_type, use_fallback_keys=True, use_reset=True): """ Keymap for popup toolbar, currently generated each time. """ @@ -66,7 +66,7 @@ def generate(context, space_type): # to 'drop' currently active tools (it's basically a 'none' tool). # so this allows us to quickly go back to a state that allows # a shortcut based workflow (before the tool system was added). - use_tap_reset = True + use_tap_reset = use_reset # TODO: support other tools for modes which don't use this tool. tap_reset_tool = "builtin.cursor" # Check the tool is available in the current context. @@ -76,11 +76,11 @@ def generate(context, space_type): from bl_operators.wm import use_toolbar_release_hack # Pie-menu style release to activate. - use_release_confirm = True + use_release_confirm = use_reset # Generate items when no keys are mapped. use_auto_keymap_alpha = False # Map manually in the default key-map. - use_auto_keymap_num = True + use_auto_keymap_num = use_fallback_keys # Temporary, only create so we can pass 'properties' to find_item_from_operator. use_hack_properties = True diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index 845475b9180..3860445233d 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -352,7 +352,8 @@ def module_names(path, recursive=False): elif filename.endswith(".py") and filename != "__init__.py": fullpath = join(path, filename) modules.append((filename[0:-3], fullpath)) - elif "." not in filename: + elif not filename.startswith("."): + # Skip hidden files since they are used by for version control. directory = join(path, filename) fullpath = join(directory, "__init__.py") if isfile(fullpath): diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py index 04aaa7bd69d..abe33b0e8ea 100644 --- a/release/scripts/modules/bpy/utils/__init__.py +++ b/release/scripts/modules/bpy/utils/__init__.py @@ -457,6 +457,41 @@ def preset_paths(subdir): return dirs +def is_path_builtin(path): + """ + Returns True if the path is one of the built-in paths used by Blender. + + :arg path: Path you want to check if it is in the built-in settings directory + :type path: str + :rtype: bool + """ + # Note that this function is is not optimized for speed, + # it's intended to be used to check if it's OK to remove presets. + # + # If this is used in a draw-loop for example, we could cache some of the values. + user_path = resource_path('USER') + + for res in ('SYSTEM', 'LOCAL'): + parent_path = resource_path(res) + if not parent_path or parent_path == user_path: + # Make sure that the current path is not empty string and that it is + # not the same as the user config path. IE "~/.config/blender" on Linux + # This can happen on portable installs. + continue + + try: + if _os.path.samefile( + _os.path.commonpath([parent_path]), + _os.path.commonpath([parent_path, path]) + ): + return True + except FileNotFoundError: + #The path we tried to look up doesn't exist + pass + + return False + + def smpte_from_seconds(time, fps=None, fps_base=None): """ Returns an SMPTE formatted string from the *time*: diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py index 151cfa84f85..9db86782d02 100644 --- a/release/scripts/modules/bpy_extras/object_utils.py +++ b/release/scripts/modules/bpy_extras/object_utils.py @@ -24,7 +24,6 @@ __all__ = ( "AddObjectHelper", "object_add_grid_scale", "object_add_grid_scale_apply_operator", - "object_image_guess", "world_to_camera_view", ) @@ -225,46 +224,6 @@ def object_add_grid_scale_apply_operator(operator, context): getattr(operator, prop_id) * grid_scale) -def object_image_guess(obj, bm=None): - """ - Return a single image used by the object, - first checking the texture-faces, then the material. - """ - # TODO, cycles/nodes materials - me = obj.data - if bm is None: - if obj.mode == 'EDIT': - import bmesh - bm = bmesh.from_edit_mesh(me) - - if bm is not None: - tex_layer = bm.faces.layers.tex.active - if tex_layer is not None: - for f in bm.faces: - image = f[tex_layer].image - if image is not None: - return image - else: - tex_layer = me.uv_textures.active - if tex_layer is not None: - for tf in tex_layer.data: - image = tf.image - if image is not None: - return image - - for m in obj.data.materials: - if m is not None: - # backwards so topmost are highest priority - for mtex in reversed(m.texture_slots): - if mtex and mtex.use_map_color_diffuse: - texture = mtex.texture - if texture and texture.type == 'IMAGE': - image = texture.image - if image is not None: - return image - return None - - def world_to_camera_view(scene, obj, coord): """ Returns the camera space coords for a 3d point. |