diff options
author | Kalle-Samuli Riihikoski <haikalle@gmail.com> | 2018-11-10 19:13:29 +0300 |
---|---|---|
committer | Kalle-Samuli Riihikoski <haikalle@gmail.com> | 2018-11-10 19:13:29 +0300 |
commit | a4d7aa618baa4c4b6f0b567f988efb0831956f6e (patch) | |
tree | a4018480087109c6a839e202927a6a42b410aac7 | |
parent | 7dbc0b2324368458115640e4659d0f630db6d2d0 (diff) | |
parent | bb2d2a0db41b98f40f9ba38e5c0d711f661b2045 (diff) |
Merge branch 'blender2.8' of git.blender.org:blender-addons into blender2.8
-rw-r--r-- | io_scene_fbx/__init__.py | 19 | ||||
-rw-r--r-- | io_scene_fbx/export_fbx_bin.py | 92 | ||||
-rw-r--r-- | object_collections.py | 14 | ||||
-rw-r--r-- | render_copy_settings/__init__.py | 6 | ||||
-rw-r--r-- | render_copy_settings/operator.py | 2 | ||||
-rw-r--r-- | render_copy_settings/panel.py | 10 | ||||
-rw-r--r-- | render_copy_settings/presets.py | 3 | ||||
-rw-r--r-- | space_view3d_brush_menus/dyntopo_menu.py | 4 |
8 files changed, 87 insertions, 63 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py index 490a2ff6..1f3112b5 100644 --- a/io_scene_fbx/__init__.py +++ b/io_scene_fbx/__init__.py @@ -21,7 +21,7 @@ bl_info = { "name": "FBX format", "author": "Campbell Barton, Bastien Montagne, Jens Restemeier", - "version": (4, 12, 1), + "version": (4, 13, 0), "blender": (2, 80, 0), "location": "File > Import-Export", "description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions", @@ -256,7 +256,12 @@ class ExportFBX(bpy.types.Operator, ExportHelper): use_selection: BoolProperty( name="Selected Objects", - description="Export selected objects on visible layers", + description="Export selected and visible objects only", + default=False, + ) + use_active_collection: BoolProperty( + name="Active Collection", + description="Export only objects from the active collection (and its children)", default=False, ) global_scale: FloatProperty( @@ -442,7 +447,14 @@ class ExportFBX(bpy.types.Operator, ExportHelper): name="Batch Mode", items=(('OFF', "Off", "Active scene to file"), ('SCENE', "Scene", "Each scene as a file"), - ('GROUP', "Group", "Each group as a file"), + ('COLLECTION', "Collection", + "Each collection (data-block ones) as a file, does not include content of children collections"), + ('SCENE_COLLECTION', "Scene Collections", + "Each collection (including master, non-data-block ones) of each scene as a file, " + "including content from children collections"), + ('ACTIVE_SCENE_COLLECTION', "Active Scene Collections", + "Each collection (including master, non-data-block one) of the active scene as a file, " + "including content from children collections"), ), ) use_batch_own_dir: BoolProperty( @@ -462,6 +474,7 @@ class ExportFBX(bpy.types.Operator, ExportHelper): layout.prop(self, "ui_tab", expand=True) if self.ui_tab == 'MAIN': layout.prop(self, "use_selection") + layout.prop(self, "use_active_collection") col = layout.column(align=True) row = col.row(align=True) diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py index f6c53272..3c970dcd 100644 --- a/io_scene_fbx/export_fbx_bin.py +++ b/io_scene_fbx/export_fbx_bin.py @@ -2995,7 +2995,6 @@ def save_single(operator, scene, depsgraph, filepath="", def defaults_unity3d(): return { # These options seem to produce the same result as the old Ascii exporter in Unity3D: - "version": 'BIN7400', "axis_up": 'Y', "axis_forward": '-Z', "global_matrix": Matrix.Rotation(-math.pi / 2.0, 4, 'X'), @@ -3034,16 +3033,17 @@ def defaults_unity3d(): def save(operator, context, filepath="", use_selection=False, + use_active_collection=False, batch_mode='OFF', use_batch_own_dir=False, **kwargs ): """ - This is a wrapper around save_single, which handles multi-scenes (or groups) cases, when batch-exporting a whole - .blend file. + This is a wrapper around save_single, which handles multi-scenes (or collections) cases, when batch-exporting + a whole .blend file. """ - ret = None + ret = {'FINISHED'} active_object = context.view_layer.objects.active @@ -3054,38 +3054,59 @@ def save(operator, context, if batch_mode == 'OFF': kwargs_mod = kwargs.copy() - if use_selection: - kwargs_mod["context_objects"] = context.selected_objects + if use_active_collection: + if use_selection: + ctx_objects = tuple(obj + for obj in context.view_layer.active_layer_collection.collection.all_objects + if obj.select_get()) + else: + ctx_objects = context.view_layer.active_layer_collection.collection.all_objects else: - kwargs_mod["context_objects"] = context.view_layer.objects + if use_selection: + ctx_objects = context.selected_objects + else: + ctx_objects = context.view_layer.objects + kwargs_mod["context_objects"] = ctx_objects ret = save_single(operator, context.scene, context.depsgraph, filepath, **kwargs_mod) else: - return # TODO Update for 2.8 + # XXX We need a way to generate a depsgraph for inactive view_layers first... + # XXX Also, what to do in case of batch-exporting scenes, when there is more than one view layer? + # Scenes have no concept of 'active' view layer, that's on window level... fbxpath = filepath prefix = os.path.basename(fbxpath) if prefix: fbxpath = os.path.dirname(fbxpath) - if batch_mode == 'GROUP': - data_seq = tuple(grp for grp in bpy.data.groups if grp.objects) + if batch_mode == 'COLLECTION': + data_seq = tuple((coll, coll.name, 'objects') for coll in bpy.data.collections if coll.objects) + elif batch_mode in {'SCENE_COLLECTION', 'ACTIVE_SCENE_COLLECTION'}: + scenes = [context.scene] if batch_mode == 'ACTIVE_SCENE_COLLECTION' else bpy.data.scenes + data_seq = [] + for scene in scenes: + if not scene.objects: + continue + # Needed to avoid having tens of 'Master Collection' entries. + todo_collections = [(scene.collection, "_".join((scene.name, scene.collection.name)))] + while todo_collections: + coll, coll_name = todo_collections.pop() + todo_collections.extend(((c, c.name) for c in coll.children if c.all_objects)) + data_seq.append((coll, coll_name, 'all_objects')) else: - data_seq = bpy.data.scenes + data_seq = tuple((scene, scene.name, 'objects') for scene in bpy.data.scenes if scene.objects) # call this function within a loop with BATCH_ENABLE == False - # no scene switching done at the moment. - # orig_sce = context.scene new_fbxpath = fbxpath # own dir option modifies, we need to keep an original - for data in data_seq: # scene or group - newname = "_".join((prefix, bpy.path.clean_name(data.name))) if prefix else bpy.path.clean_name(data.name) + for data, data_name, data_obj_propname in data_seq: # scene or collection + newname = "_".join((prefix, bpy.path.clean_name(data_name))) if prefix else bpy.path.clean_name(data_name) if use_batch_own_dir: new_fbxpath = os.path.join(fbxpath, newname) - # path may already exist - # TODO - might exist but be a file. unlikely but should probably account for it. - + # path may already exist... and be a file. + while os.path.isfile(new_fbxpath): + new_fbxpath = "_".join((new_fbxpath, "dir")) if not os.path.exists(new_fbxpath): os.makedirs(new_fbxpath) @@ -3093,18 +3114,14 @@ def save(operator, context, print('\nBatch exporting %s as...\n\t%r' % (data, filepath)) - if batch_mode == 'GROUP': # group - # group, so objects update properly, add a dummy scene. + if batch_mode in {'COLLECTION', 'SCENE_COLLECTION', 'ACTIVE_SCENE_COLLECTION'}: + # Collection, so that objects update properly, add a dummy scene. scene = bpy.data.scenes.new(name="FBX_Temp") - scene.layers = [True] * 20 - # bpy.data.scenes.active = scene # XXX, cant switch src_scenes = {} # Count how much each 'source' scenes are used. - for ob_base in data.objects: - for src_sce in ob_base.users_scene: - if src_sce not in src_scenes: - src_scenes[src_sce] = 0 - src_scenes[src_sce] += 1 - scene.objects.link(ob_base) + for obj in getattr(data, data_obj_propname): + for src_sce in obj.users_scene: + src_scenes[src_sce] = src_scenes.setdefault(src_sce, 0) + 1 + scene.collection.objects.link(obj) # Find the 'most used' source scene, and use its unit settings. This is somewhat weak, but should work # fine in most cases, and avoids stupid issues like T41931. @@ -3124,20 +3141,17 @@ def save(operator, context, scene = data kwargs_batch = kwargs.copy() - kwargs_batch["context_objects"] = data.objects + kwargs_batch["context_objects"] = getattr(data, data_obj_propname) - save_single(operator, scene, filepath, **kwargs_batch) + save_single(operator, scene, scene.view_layers[0].depsgraph, filepath, **kwargs_batch) - if batch_mode == 'GROUP': - # remove temp group scene + if batch_mode in {'COLLECTION', 'SCENE_COLLECTION', 'ACTIVE_SCENE_COLLECTION'}: + # Remove temp collection scene. bpy.data.scenes.remove(scene) - # no active scene changing! - # bpy.data.scenes.active = orig_sce - - ret = {'FINISHED'} # so the script wont run after we have batch exported. - - if active_object and org_mode and bpy.ops.object.mode_set.poll(): - bpy.ops.object.mode_set(mode=org_mode) + if active_object and org_mode: + context.view_layer.objects.active = active_object + if bpy.ops.object.mode_set.poll(): + bpy.ops.object.mode_set(mode=org_mode) return ret diff --git a/object_collections.py b/object_collections.py index b7ec5c56..8d38d7ff 100644 --- a/object_collections.py +++ b/object_collections.py @@ -126,15 +126,15 @@ class OBJECT_OT_collection_link(Operator): bl_idname = "object.collection_link" bl_label = "Link to Collection" - collection_index = IntProperty( - name = "Collection Index", - default = -1, - options = {'SKIP_SAVE'}, + collection_index: IntProperty( + name="Collection Index", + default=-1, + options={'SKIP_SAVE'}, ) - type = EnumProperty( - name = "", - description = "Dynamic enum for collections", + type: EnumProperty( + name="", + description="Dynamic enum for collections", items=collection_items, ) diff --git a/render_copy_settings/__init__.py b/render_copy_settings/__init__.py index 5f7d8781..8c57f68f 100644 --- a/render_copy_settings/__init__.py +++ b/render_copy_settings/__init__.py @@ -19,10 +19,10 @@ # <pep8 compliant> bl_info = { - "name": "Copy Settings", + "name": "Copy Render Settings", "author": "Bastien Montagne", - "version": (0, 1, 7), - "blender": (2, 79, 1), + "version": (1, 0, 0), + "blender": (2, 80, 0), "location": "Render buttons (Properties window)", "description": "Allows to copy a selection of render settings " "from current scene to others.", diff --git a/render_copy_settings/operator.py b/render_copy_settings/operator.py index a88e7dc1..c65107d8 100644 --- a/render_copy_settings/operator.py +++ b/render_copy_settings/operator.py @@ -47,7 +47,7 @@ def collection_property_sort(collection, sortkey, start_idx=0): class RenderCopySettingsOPPrepare(bpy.types.Operator): - """Prepare internal data for render_copy_settings (gathering all existingrender settings, and scenes)""" + """Prepare internal data for render_copy_settings (gathering all existing render settings, and scenes)""" bl_idname = "scene.render_copy_settings_prepare" bl_label = "Render: Copy Settings Prepare" bl_option = {'REGISTER'} diff --git a/render_copy_settings/panel.py b/render_copy_settings/panel.py index 375e1bd3..88f4e940 100644 --- a/render_copy_settings/panel.py +++ b/render_copy_settings/panel.py @@ -28,14 +28,14 @@ class RENDER_UL_copy_settings(bpy.types.UIList): #assert(isinstance(item, (data_types.RenderCopySettingsScene, data_types.RenderCopySettingsDataSetting))) if self.layout_type in {'DEFAULT', 'COMPACT'}: if isinstance(item, data_types.RenderCopySettingsDataSetting): - layout.label(item.name, icon_value=icon) + layout.label(text=item.name, icon_value=icon) layout.prop(item, "copy", text="") else: #elif isinstance(item, data_types.RenderCopySettingsDataScene): layout.prop(item, "allowed", text=item.name, toggle=True) elif self.layout_type in {'GRID'}: layout.alignment = 'CENTER' if isinstance(item, data_types.RenderCopySettingsDataSetting): - layout.label(item.name, icon_value=icon) + layout.label(text=item.name, icon_value=icon) layout.prop(item, "copy", text="") else: #elif isinstance(item, data_types.RenderCopySettingsDataScene): layout.prop(item, "allowed", text=item.name, toggle=True) @@ -60,9 +60,9 @@ class RENDER_PT_copy_settings(bpy.types.Panel): if bpy.ops.scene.render_copy_settings_prepare.poll(): bpy.ops.scene.render_copy_settings_prepare() - split = layout.split(0.75) + split = layout.split(factor=0.75) split.template_list("RENDER_UL_copy_settings", "settings", cp_sett, "affected_settings", - cp_sett, "affected_settings_idx", rows=6) + cp_sett, "affected_settings_idx", rows=5) col = split.column() all_set = {sett.strid for sett in cp_sett.affected_settings if sett.copy} @@ -76,7 +76,7 @@ class RENDER_PT_copy_settings(bpy.types.Panel): layout.prop(cp_sett, "filter_scene") if len(cp_sett.allowed_scenes): - layout.label("Affected Scenes:") + layout.label(text="Affected Scenes:") layout.template_list("RENDER_UL_copy_settings", "scenes", cp_sett, "allowed_scenes", # cp_sett, "allowed_scenes_idx", rows=6, type='GRID') cp_sett, "allowed_scenes_idx", rows=6) # XXX Grid is not nice currently... diff --git a/render_copy_settings/presets.py b/render_copy_settings/presets.py index 8bc43afb..0fc53e39 100644 --- a/render_copy_settings/presets.py +++ b/render_copy_settings/presets.py @@ -38,9 +38,6 @@ presets = (CopyPreset("Resolution", CopyPreset("Threads", ("threads", "Render Threads", "The thread mode and number settings"), {"threads_mode", "threads"}), - CopyPreset("Fields", - ("fields", "Render Fields", "The Fields settings"), - {"use_fields", "field_order", "use_fields_still"}), CopyPreset("Stamp", ("stamp", "Render Stamp", "The Stamp toggle"), {"use_stamp"}) diff --git a/space_view3d_brush_menus/dyntopo_menu.py b/space_view3d_brush_menus/dyntopo_menu.py index ff746df3..a755b983 100644 --- a/space_view3d_brush_menus/dyntopo_menu.py +++ b/space_view3d_brush_menus/dyntopo_menu.py @@ -59,8 +59,8 @@ class DynDetailMenu(Menu): slider_setting = "detail_size" elif bpy.context.tool_settings.sculpt.detail_type_method == 'CONSTANT': - datapath = "tool_settings.sculpt.constant_detail" - slider_setting = "constant_detail" + datapath = "tool_settings.sculpt.constant_detail_resolution" + slider_setting = "constant_detail_resolution" else: datapath = "tool_settings.sculpt.detail_percent" slider_setting = "detail_percent" |