Merge branch 'master' into xr-controller-support

This commit is contained in:
Peter Kim 2021-08-06 16:05:58 +09:00
commit f01afb5bae
11 changed files with 91 additions and 45 deletions

View File

@ -382,7 +382,7 @@ class BlenderKitUIProps(PropertyGroup):
drag_init: BoolProperty(name="Drag Initialisation", default=False)
drag_init_button: BoolProperty(name="Drag Initialisation from button",
default=False,
description="Click or drag into scene for download.",
description="Click or drag into scene for download",
update = run_drag_drop_update)
drag_length: IntProperty(name="Drag length", default=0)
draw_drag_image: BoolProperty(name="Draw Drag Image", default=False)
@ -697,9 +697,9 @@ class BlenderKitCommonUploadProps(object):
name="Thumbnail Style",
items=(
('FULL', 'Full', "Your asset will be only available for subscribers"),
('FREE', 'Free', "You consent you want to release this asset as free for everyone.")
('FREE', 'Free', "You consent you want to release this asset as free for everyone")
),
description="Assets can be in Free or in Full plan. Also free assets generate credits.",
description="Assets can be in Free or in Full plan. Also free assets generate credits",
default="FULL",
)
@ -871,7 +871,7 @@ class BlenderKitMaterialUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
('FREE', 'Free', "You consent you want to release this asset as free for everyone.")
),
description="Assets can be in Free or in Full plan. Also free assets generate credits. \n"
"All BlenderKit materials are free.",
"All BlenderKit materials are free",
default="FREE",
update=update_free
)
@ -886,7 +886,7 @@ class BlenderKitMaterialUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
texture_resolution_max: IntProperty(name="Texture Resolution Max", description="texture resolution maximum",
default=0)
texture_size_meters: FloatProperty(name="Texture Size in Meters", description="Size of texture in real world units.",
texture_size_meters: FloatProperty(name="Texture Size in Meters", description="Size of texture in real world units",
default=1.0, min=0)
thumbnail_scale: FloatProperty(name="Thumbnail Object Size",
@ -932,9 +932,9 @@ class BlenderKitMaterialUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
thumbnail: StringProperty(
name="Thumbnail",
description="Thumbnail path - 512x512 .jpg image, rendered with cycles. \n"
description="Thumbnail path - 512x512 .jpg image, rendered with cycles.\n"
"Only standard BlenderKit previews will be accepted.\n"
"Only exception are special effects like fire or similar.",
"Only exception are special effects like fire or similar",
subtype='FILE_PATH',
default="",
update=autothumb.update_upload_material_preview)
@ -1739,14 +1739,14 @@ class BlenderKitAddonPreferences(AddonPreferences):
experimental_features: BoolProperty(
name="Enable experimental features",
description="Enable all experimental features of BlenderKit. Use at your own risk.",
description="Enable all experimental features of BlenderKit. Use at your own risk",
default=False,
update=utils.save_prefs
)
categories_fix: BoolProperty(
name="Enable category fixing mode",
description="Enable category fixing mode.",
description="Enable category fixing mode",
default=False,
update=utils.save_prefs
)

View File

@ -302,17 +302,26 @@ def append_objects(file_name, obnames=[], location=(0, 0, 0), link=False, **kwar
bpy.ops.object.select_all(action='DESELECT')
path = file_name + "\\Collection\\"
object_name = kwargs.get('name')
collection_name = kwargs.get('name')
fc = utils.get_fake_context(bpy.context, area_type='VIEW_3D')
bpy.ops.wm.append(fc, filename=object_name, directory=path)
bpy.ops.wm.append(fc, filename=collection_name, directory=path)
return_obs = []
to_hidden_collection = []
collection = None
for ob in bpy.context.scene.objects:
if ob.select_get():
return_obs.append(ob)
if not ob.parent:
main_object = ob
ob.location = location
# check for object that should be hidden
if ob.users_collection[0].name == collection_name:
collection = ob.users_collection[0]
else:
to_hidden_collection.append(ob)
if kwargs.get('rotation'):
main_object.rotation_euler = kwargs['rotation']
@ -321,6 +330,16 @@ def append_objects(file_name, obnames=[], location=(0, 0, 0), link=False, **kwar
main_object.parent = bpy.data.objects[kwargs['parent']]
main_object.matrix_world.translation = location
#move objects that should be hidden to a sub collection
if len(to_hidden_collection)>0 and collection is not None:
hidden_collection_name = collection_name+'_hidden'
h_col = bpy.data.collections.new(name = hidden_collection_name)
collection.children.link(h_col)
for ob in to_hidden_collection:
ob.users_collection[0].objects.unlink(ob)
h_col.objects.link(ob)
utils.exclude_collection(hidden_collection_name)
bpy.ops.object.select_all(action='DESELECT')
utils.selection_set(sel)

View File

@ -330,7 +330,7 @@ class GenerateThumbnailOperator(bpy.types.Operator):
class ReGenerateThumbnailOperator(bpy.types.Operator):
"""
Generate default thumbnail with Cycles renderer and upload it.
Works also for assets from search results, without being downloaded before.
Works also for assets from search results, without being downloaded before
"""
bl_idname = "object.blenderkit_regenerate_thumbnail"
bl_label = "BlenderKit Thumbnail Re-generate"
@ -440,7 +440,7 @@ class ReGenerateThumbnailOperator(bpy.types.Operator):
class GenerateMaterialThumbnailOperator(bpy.types.Operator):
"""Generate default thumbnail with Cycles renderer."""
"""Generate default thumbnail with Cycles renderer"""
bl_idname = "object.blenderkit_generate_material_thumbnail"
bl_label = "BlenderKit Material Thumbnail Generator"
bl_options = {'REGISTER', 'INTERNAL'}

View File

@ -298,7 +298,7 @@ def parse_result(r):
asset_data['downloaded'] = 0
# parse extra params needed for blender here
params = r['dictParameters']#utils.params_to_dict(r['parameters'])
params = r['dictParameters'] # utils.params_to_dict(r['parameters'])
if asset_type == 'model':
if params.get('boundBoxMinX') != None:
@ -398,8 +398,6 @@ def search_timer():
return 0.5
for thread in search_threads:
# TODO this doesn't check all processes when one gets removed,
# but most of the time only one is running anyway
@ -499,10 +497,9 @@ def load_preview(asset, index):
loaded = True
tpath = os.path.join(directory, asset['thumbnail_small'])
if not asset['thumbnail_small'] or not os.path.exists(tpath):
if not asset['thumbnail_small'] or asset['thumbnail_small'] == '' or not os.path.exists(tpath):
# tpath = paths.get_addon_thumbnail_path('thumbnail_notready.jpg')
asset['thumb_small_loaded'] = False
loaded = False
iname = utils.previmg_name(index)
@ -512,25 +509,33 @@ def load_preview(asset, index):
if img is None:
if not os.path.exists(tpath):
return False
img = bpy.data.images.load(tpath)
img.name = iname
# wrap into try statement since sometimes
try:
img = bpy.data.images.load(tpath)
img.name = iname
except:
return False
elif img.filepath != tpath:
if not os.path.exists(tpath):
#unload loaded previews from previous results
# unload loaded previews from previous results
bpy.data.images.remove(img)
return False
# had to add this check for autopacking files...
if bpy.data.use_autopack and img.packed_file is not None:
img.unpack(method='USE_ORIGINAL')
img.filepath = tpath
img.reload()
try:
img.reload()
except:
return False
if asset['assetType'] == 'hdr':
# to display hdr thumbnails correctly, we use non-color, otherwise looks shifted
image_utils.set_colorspace(img, 'Non-Color')
else:
image_utils.set_colorspace(img, 'sRGB')
asset['thumb_small_loaded'] = True
return loaded
return True
def load_previews():
@ -658,6 +663,7 @@ def generate_author_textblock(adata):
t = writeblockm(t, adata, key='aboutMe', pretext='', width=col_w)
return t
def download_image(session, url, filepath):
r = None
try:
@ -669,25 +675,26 @@ def download_image(session, url, filepath):
with open(filepath, 'wb') as f:
f.write(r.content)
def thumb_download_worker(queue_sml, queue_full):
# print('thumb downloader', self.url)
# utils.p('start thumbdownloader thread')
while 1:
session = None
#start a session only for single search usually, if users starts scrolling, the session might last longer if
# start a session only for single search usually, if users starts scrolling, the session might last longer if
# queue gets filled.
if not queue_sml.empty() or not queue_full.empty():
if session is None:
session = requests.Session()
while not queue_sml.empty():
#first empty the small thumbs queue
# first empty the small thumbs queue
url, filepath = queue_sml.get()
download_image(session,url, filepath)
download_image(session, url, filepath)
exit_full = False
# download full resolution image, but only if no small thumbs are waiting. If there are small
while not queue_full.empty() and queue_sml.empty():
url, filepath = queue_full.get()
download_image(session,url, filepath)
download_image(session, url, filepath)
if queue_sml.empty() and queue_full.empty():
if session is not None:
@ -1235,7 +1242,8 @@ def add_search_process(query, params):
if thumb_workers_sml == []:
for a in range(0, 8):
thread = threading.Thread(target=thumb_download_worker, args=(thumb_sml_download_threads, thumb_full_download_threads),
thread = threading.Thread(target=thumb_download_worker,
args=(thumb_sml_download_threads, thumb_full_download_threads),
daemon=True)
thread.start()
thumb_workers_sml.append(thread)

View File

@ -1622,7 +1622,7 @@ def find_and_activate_instancers(object):
class AssetDragOperator(bpy.types.Operator):
"""Drag & drop assets into scene."""
"""Drag & drop assets into scene"""
bl_idname = "view3d.asset_drag_drop"
bl_label = "BlenderKit asset drag drop"

View File

@ -645,7 +645,7 @@ class FastMetadata(bpy.types.Operator):
('PUBLIC', 'Public', '"Your asset will go into the validation process automatically')
),
description="If not marked private, your asset will go into the validation process automatically\n"
"Private assets are limited by quota.",
"Private assets are limited by quota",
default="PUBLIC",
)
@ -1245,10 +1245,10 @@ class UploadOperator(Operator):
ui_panels.draw_not_logged_in(self, message='To upload assets you need to login/signup.')
return {'CANCELLED'}
if props.is_private == 'PUBLIC':
return context.window_manager.invoke_props_dialog(self)
else:
return self.execute(context)
# if props.is_private == 'PUBLIC':
return context.window_manager.invoke_props_dialog(self)
# else:
# return self.execute(context)
class AssetDebugPrint(Operator):

View File

@ -152,6 +152,28 @@ def get_selected_replace_adepts():
return parents
def exclude_collection(name, state=True):
'''
Set the exclude state of collection
Parameters
----------
name - name of collection
state - default True.
Returns
-------
None
'''
vl = bpy.context.view_layer.layer_collection
cc = [vl]
found = False
while len(cc) > 0 and not found:
c = cc.pop()
if c.name == name:
c.exclude = state
found = True
cc.extend(c.children)
def get_search_props():
scene = bpy.context.scene
wm = bpy.context.window_manager

View File

@ -83,10 +83,7 @@ def SVGParseCoord(coord, size):
if unit == '%':
return float(size) / 100.0 * val
else:
return val * units[unit]
return val
return val * units[unit]
def SVGRectFromNode(node, context):

View File

@ -115,7 +115,8 @@ def pose_library_list_item_context_menu(self: UIList, context: Context) -> None:
props.select = False
layout.separator()
layout.operator("asset.open_containing_blend_file")
if is_pose_asset_view():
layout.operator("asset.open_containing_blend_file")
class ASSETBROWSER_PT_pose_library_usage(asset_utils.AssetBrowserSpecificCategoryPanel, Panel):
@ -208,7 +209,7 @@ def register() -> None:
WindowManager.pose_assets = bpy.props.CollectionProperty(type=AssetHandle)
bpy.types.UI_MT_list_item_context_menu.prepend(pose_library_list_item_context_menu)
bpy.types.FILEBROWSER_MT_context_menu.prepend(pose_library_list_item_context_menu)
bpy.types.ASSETBROWSER_MT_context_menu.prepend(pose_library_list_item_context_menu)
def unregister() -> None:
@ -218,4 +219,4 @@ def unregister() -> None:
del WindowManager.pose_assets
bpy.types.UI_MT_list_item_context_menu.remove(pose_library_list_item_context_menu)
bpy.types.FILEBROWSER_MT_context_menu.remove(pose_library_list_item_context_menu)
bpy.types.ASSETBROWSER_MT_context_menu.remove(pose_library_list_item_context_menu)

View File

@ -21,9 +21,8 @@ from .utils.functions import convert_duration_to_frames
class POWER_SEQUENCER_OT_value_offset(bpy.types.Operator):
"""Instantly offset selected strips, either using frames or seconds. Allows to
nudge the selection quickly, using keyboard shortcuts.
"""
"""Instantly offset selected strips, either using frames or seconds. """ \
"""Allows to nudge the selection quickly, using keyboard shortcuts"""
doc = {
"name": doc_name(__qualname__),

View File

@ -222,7 +222,7 @@ else:
class POV_OT_update_addon(bpy.types.Operator):
"""Update this addon to the latest version."""
"""Update this add-on to the latest version"""
bl_idname = "pov.update_addon"
bl_label = "Update POV addon"