[Bf-extensions-cvs] [8e375717] blender-v2.82-release: BlenderKit: -improve multiline tooltips -change addon category to 3d view, fits a bit more than add mesh -support searching only own assets -support searching for procedural only assets(hiddn by now) -switch off defautl GPU on for thumbnails- this was a bug that went unnoticed for a long time. -add gpu render option directly to thumbnail render dialogs -non-treaded downloading for resolutions -move in utils and rename correctly params_to_dict and dict_to_params -display icon for rejected assets(needs a new icon) -split login panel -rename some panels for more consistency -improve some tooltips

Vilém Duha noreply at git.blender.org
Tue Jan 28 13:49:36 CET 2020


Commit: 8e3757177ce98f760583b858435e940700ce8ed2
Author: Vilém Duha
Date:   Sat Jan 18 15:29:38 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rBA8e3757177ce98f760583b858435e940700ce8ed2

BlenderKit:
-improve multiline tooltips
-change addon category to 3d view, fits a bit more than add mesh
-support searching only own assets
-support searching for procedural only assets(hiddn by now)
-switch off defautl GPU on for thumbnails- this was a bug that went unnoticed for a long time.
-add gpu render option directly to thumbnail render dialogs
-non-treaded downloading for resolutions
-move in utils and rename correctly params_to_dict and dict_to_params
-display icon for rejected assets(needs a new icon)
-split login panel
-rename some panels for more consistency
-improve some tooltips

===================================================================

M	blenderkit/__init__.py
M	blenderkit/autothumb.py
M	blenderkit/download.py
M	blenderkit/rerequests.py
M	blenderkit/search.py
M	blenderkit/ui.py
M	blenderkit/ui_panels.py
M	blenderkit/upload.py
M	blenderkit/upload_bg.py
M	blenderkit/utils.py

===================================================================

diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index 5cecc7b9..adb8e797 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -26,7 +26,7 @@ bl_info = {
     "warning": "",
     "wiki_url": "https://youtu.be/1hVgcQhIAo8"
                 "Scripts/Add_Mesh/BlenderKit",
-    "category": "Add Mesh",
+    "category": "3D View",
 }
 
 if "bpy" in locals():
@@ -249,11 +249,11 @@ def asset_type_callback(self, context):
     #ui_props = s.blenderkitUI
     if self.down_up == 'SEARCH':
         items = (
-            ('MODEL', 'Search Models', 'Browse models', 'OBJECT_DATAMODE', 0),
+            ('MODEL', 'Find Models', 'Find models in the BlenderKit online database', 'OBJECT_DATAMODE', 0),
             # ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
-            ('MATERIAL', 'Search Materials', 'Browse materials', 'MATERIAL', 2),
+            ('MATERIAL', 'Find Materials', 'Find models in the BlenderKit online database', 'MATERIAL', 2),
             # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
-            ('BRUSH', 'Search Brushes', 'Browse brushes', 'BRUSH_DATA', 3)
+            ('BRUSH', 'Find Brushes', 'Find models in the BlenderKit online database', 'BRUSH_DATA', 3)
         )
     else:
         items = (
@@ -386,6 +386,8 @@ class BlenderKitCommonSearchProps(object):
                                  default=False)
     search_done: BoolProperty(name="Search Completed", description="at least one search did run (internal)",
                               default=False)
+    own_only: BoolProperty(name="My Assets", description="Search only for your assets",
+                              default=False)
     search_error: BoolProperty(name="Search Error", description="last search had an error", default=False)
     report: StringProperty(
         name="Report",
@@ -508,8 +510,8 @@ class BlenderKitCommonUploadProps(object):
                           default=True
                           )
     node_count: IntProperty(name="Node count", description="Total nodes in the asset", default=0)
-    texture_count: IntProperty(name="Node count", description="Total nodes in the asset", default=0)
-    total_megapixels: IntProperty(name="Node count", description="Total nodes in the asset", default=0)
+    texture_count: IntProperty(name="Texture count", description="Total texture count in asset", default=0)
+    total_megapixels: IntProperty(name="Megapixels", description="Total megapixels of texture", default=0)
 
     # is_private: BoolProperty(name="Asset is Private",
     #                       description="If not marked private, your asset will go into the validation process automatically\n"
@@ -1165,6 +1167,18 @@ class BlenderKitModelSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
         update=search.search_update
     )
 
+    search_procedural: EnumProperty(
+        items=(
+            ('BOTH', 'Both',''),
+            ('PROCEDURAL', 'Procedural',''),
+            ('TEXTURE_BASED', 'Texture based',''),
+
+        ),
+        default='BOTH',
+        description='Search only procedural/texture based assets',
+        update=search.search_update
+    )
+
     # DESIGN YEAR
     search_design_year: BoolProperty(name="Sesigned in Year",
                                      description="when the object was approximately designed",
@@ -1389,7 +1403,7 @@ class BlenderKitAddonPreferences(AddonPreferences):
     thumbnail_use_gpu: BoolProperty(
         name="Use GPU for Thumbnails Rendering",
         description="By default this is off so you can continue your work without any lag",
-        default=True
+        default=False
     )
 
     panel_behaviour: EnumProperty(
diff --git a/blenderkit/autothumb.py b/blenderkit/autothumb.py
index 06efd8a0..f26f99dd 100644
--- a/blenderkit/autothumb.py
+++ b/blenderkit/autothumb.py
@@ -262,6 +262,8 @@ class GenerateThumbnailOperator(bpy.types.Operator):
         layout.prop(props, 'thumbnail_samples')
         layout.prop(props, 'thumbnail_resolution')
         layout.prop(props, 'thumbnail_denoising')
+        preferences = bpy.context.preferences.addons['blenderkit'].preferences
+        layout.prop(preferences, "thumbnail_use_gpu")
 
     def execute(self, context):
         start_thumbnailer(self, context)
@@ -307,6 +309,8 @@ class GenerateMaterialThumbnailOperator(bpy.types.Operator):
         layout.prop(props, 'thumbnail_samples')
         layout.prop(props, 'thumbnail_denoising')
         layout.prop(props, 'adaptive_subdivision')
+        preferences = bpy.context.preferences.addons['blenderkit'].preferences
+        layout.prop(preferences, "thumbnail_use_gpu")
 
     def execute(self, context):
         start_material_thumbnailer(self, context)
diff --git a/blenderkit/download.py b/blenderkit/download.py
index c4a14ecd..c9df6c0b 100644
--- a/blenderkit/download.py
+++ b/blenderkit/download.py
@@ -523,6 +523,34 @@ def timer_update():  # TODO might get moved to handle all blenderkit stuff, not
     return .5
 
 
+def download_file(asset_data):
+    #this is a simple non-threaded way to download files for background resolution genenration tool
+    file_name = paths.get_download_filenames(asset_data)[0]  # prefer global dir if possible.
+
+    if check_existing(asset_data):
+        # this sends the thread for processing, where another check should occur, since the file might be corrupted.
+        utils.p('not downloading, already in db')
+        return file_name
+    preferences = bpy.context.preferences.addons['blenderkit'].preferences
+    api_key = preferences.api_key
+
+    with open(file_name, "wb") as f:
+        print("Downloading %s" % file_name)
+        headers = utils.get_headers(api_key)
+
+        response = requests.get(asset_data['url'], stream=True)
+        total_length = response.headers.get('Content-Length')
+
+        if total_length is None:  # no content length header
+            f.write(response.content)
+        else:
+            dl = 0
+            for data in response.iter_content(chunk_size=4096):
+                dl += len(data)
+                print(dl)
+                f.write(data)
+    return file_name
+
 class Downloader(threading.Thread):
     def __init__(self, asset_data, tcom, scene_id, api_key):
         super(Downloader, self).__init__()
diff --git a/blenderkit/rerequests.py b/blenderkit/rerequests.py
index 0524c156..eab78fba 100644
--- a/blenderkit/rerequests.py
+++ b/blenderkit/rerequests.py
@@ -55,9 +55,11 @@ def rerequest(method, url, **kwargs):
             user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
             if user_preferences.api_key != '':
                 if user_preferences.enable_oauth:
-                    tasks_queue.add_task((ui.add_report, ('refreshing token.',)))
+                    tasks_queue.add_task((ui.add_report, (
+                    'refreshing token. If this fails, please login in BlenderKit Login panel.', 10)))
                     refresh_url = paths.get_bkit_url()
-                    auth_token, refresh_token, oauth_response = bkit_oauth.refresh_token(user_preferences.api_key_refresh, refresh_url)
+                    auth_token, refresh_token, oauth_response = bkit_oauth.refresh_token(
+                        user_preferences.api_key_refresh, refresh_url)
 
                     # utils.p(auth_token, refresh_token)
                     if auth_token is not None:
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 87bf45da..2c2b2dea 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -220,7 +220,7 @@ def timer_update():  # TODO might get moved to handle all blenderkit stuff.
                                 asset_data['downloaded'] = 0
 
                                 # parse extra params needed for blender here
-                                params = params_to_dict(r['parameters'])
+                                params = utils.params_to_dict(r['parameters'])
 
                                 if asset_type == 'model':
                                     if params.get('boundBoxMinX') != None:
@@ -403,17 +403,13 @@ def has(mdata, prop):
         return False
 
 
-def params_to_dict(params):
-    params_dict = {}
-    for p in params:
-        params_dict[p['parameterType']] = p['value']
-    return params_dict
+
 
 
 def generate_tooltip(mdata):
     col_w = 40
     if type(mdata['parameters']) == list:
-        mparams = params_to_dict(mdata['parameters'])
+        mparams = utils.params_to_dict(mdata['parameters'])
     else:
         mparams = mdata['parameters']
     t = ''
@@ -953,6 +949,11 @@ def build_query_model():
             query["textureResolutionMin"] = props.search_texture_resolution_min
             query["textureResolutionMax"] = props.search_texture_resolution_max
 
+    if props.search_procedural == "PROCEDURAL":
+        query["procedural"] = True
+    elif props.search_procedural == 'TEXTURE_BASED':
+        query["procedural"] = False
+
     build_query_common(query, props)
 
     return query
@@ -1106,6 +1107,12 @@ def search(category='', get_next=False, author_id=''):
     if author_id != '':
         query['author_id'] = author_id
 
+    elif props.own_only:
+        # if user searches for [another] author, 'only my assets' is invalid. that's why in elif.
+        profile = bpy.context.window_manager.get('bkit profile')
+        if profile is not None:
+            query['author_id'] = str(profile['user']['id'])
+
     # utils.p('searching')
     props.is_searching = True
 
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index fc9563a9..5def630f 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -67,7 +67,7 @@ verification_icons = {
     'uploading': 'vs_uploading.png',
     'on_hold': 'vs_on_hold.png',
     'validated': None,
-    'rejected': None
+    'rejected': 'vs_on_hold.png'
 
 }
 
@@ -698,6 +698,7 @@ def draw_callback_2d_upload_preview(self, context):
 
     props = utils.get_upload_props()
     if props != None and ui_props.draw_tooltip:
+
         if ui_props.asset_type != 'BRUSH':
             ui_props.thumbnail_image = props.thumbnail
         else:
@@ -1417,6 +1418,9 @@ class AssetBarOperator(bpy.types.Operator):
                     ui_props.draw_tooltip = True

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list