[Bf-extensions-cvs] [4300021a] blender-v2.82-release: BlenderKit: search - default order

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


Commit: 4300021a7a8ec4bd092237848daa1ecb96616df7
Author: Vilém Duha
Date:   Sat Jan 25 09:05:52 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rBA4300021a7a8ec4bd092237848daa1ecb96616df7

BlenderKit: search - default order

-default order by last upload
-enable search by file size
-improve procedural material search UI

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

M	blenderkit/__init__.py
M	blenderkit/search.py
M	blenderkit/ui_panels.py

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

diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index 8937392d..05747d0f 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -385,6 +385,10 @@ class BlenderKitUIProps(PropertyGroup):
     dragging_rating_work_hours: BoolProperty(name="Dragging Rating Work Hours", default=False)
     last_rating_time: FloatProperty(name="Last Rating Time", default=0.0)
 
+def search_procedural_update(self,context):
+    if self.search_procedural in ('PROCEDURAL', 'BOTH'):
+        self.search_texture_resolution = False
+    search.search_update(self, context)
 
 class BlenderKitCommonSearchProps(object):
     # STATES
@@ -395,6 +399,9 @@ class BlenderKitCommonSearchProps(object):
                               default=False)
     own_only: BoolProperty(name="My Assets", description="Search only for your assets",
                            default=False)
+    search_advanced: BoolProperty(name="Advanced Search Options", description="use advanced search properties",
+                                  default=False, update=search.search_update)
+
     search_error: BoolProperty(name="Search Error", description="last search had an error", default=False)
     report: StringProperty(
         name="Report",
@@ -422,7 +429,42 @@ class BlenderKitCommonSearchProps(object):
                                                max=32768,
                                                update=search.search_update,
                                                )
-    search_verification_status:  EnumProperty(
+
+    # file_size
+    search_file_size: BoolProperty(name="File Size",
+                                   description="Span of the file sizes",
+                                   default=False,
+                                   update=search.search_update,
+                                   )
+    search_file_size_min: IntProperty(name="Min File Size",
+                                      description="Minimum file size",
+                                      default=0,
+                                      min=0,
+                                      max=2000,
+                                      update=search.search_update,
+                                      )
+
+    search_file_size_max: IntProperty(name="Max File Size",
+                                      description="Maximum file size",
+                                      default=500,
+                                      min=0,
+                                      max=2000,
+                                      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_procedural_update
+    )
+
+    search_verification_status: EnumProperty(
         name="Verification status",
         description="Search by verification status",
         items=
@@ -435,7 +477,7 @@ class BlenderKitCommonSearchProps(object):
             ('REJECTED', 'Rejected', 'Rejected'),
             ('DELETED', 'Deleted', 'Deleted'),
         ),
-        default = 'ALL',
+        default='ALL',
         update=search.search_update,
     )
 
@@ -1197,10 +1239,7 @@ class BlenderKitModelSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
     )
 
     free_only: BoolProperty(name="Free only", description="Show only free models",
-                            default=False,update=search.search_update)
-
-    search_advanced: BoolProperty(name="Advanced Search Options", description="use advanced search properties",
-                                  default=False,update=search.search_update)
+                            default=False, update=search.search_update)
 
     # CONDITION
     search_condition: EnumProperty(
@@ -1217,18 +1256,6 @@ 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",
@@ -1250,21 +1277,18 @@ class BlenderKitModelSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
                                         update=search.search_update,
                                         )
 
-
-
-
     # POLYCOUNT
     search_polycount: BoolProperty(name="Use Polycount",
                                    description="use polycount of object search tag",
                                    default=False,
-                                   update=search.search_update,)
+                                   update=search.search_update, )
 
     search_polycount_min: IntProperty(name="Min Polycount",
                                       description="polycount of the asset minimum",
                                       default=0,
                                       min=0,
                                       max=100000000,
-                                      update=search.search_update,)
+                                      update=search.search_update, )
 
     search_polycount_max: IntProperty(name="Max Polycount",
                                       description="polycount of the asset maximum",
@@ -1359,7 +1383,6 @@ class BlenderKitSceneSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
     )
 
 
-
 class BlenderKitAddonPreferences(AddonPreferences):
     # this must match the addon name, use '__package__'
     # when defining this in a submodule of a python package.
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 4290a875..f68306a6 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -743,10 +743,13 @@ class Searcher(threading.Thread):
                 requeststring += q + ':' + str(query[q]).lower()
 
         # result ordering: _score - relevance, score - BlenderKit score
-        # first condition assumes no keywords and no category, thus an empty search that is triggered on start.
+
         if query.get('query') is None and query.get('category_subtree') == None:
-            requeststring += '+order:-created'
+            # assumes no keywords and no category, thus an empty search that is triggered on start.
+            # orders by last core file upload
+            requeststring += '+order:-last_upload'
         elif query.get('author_id') is not None and utils.profile_is_validator():
+
             requeststring += '+order:-created'
         else:
             if query.get('category_subtree') is not None:
@@ -950,6 +953,25 @@ def build_query_common(query, props):
     if props.search_verification_status != 'ALL':
         query_common['verification_status'] = props.search_verification_status.lower()
 
+    if props.search_advanced:
+        if props.search_texture_resolution:
+            query["textureResolutionMax_gte"] = props.search_texture_resolution_min
+            query["textureResolutionMax_lte"] = props.search_texture_resolution_max
+
+        elif props.search_procedural == 'TEXTURE_BASED':
+            # todo this procedural hack should be replaced with the parameter
+            query["textureResolutionMax_gte"] = 0
+            # query["procedural"] = False
+
+        if props.search_procedural == "PROCEDURAL":
+            #todo this procedural hack should be replaced with the parameter
+            query["files_size_lte"] = 1024 * 1024
+            # query["procedural"] = True
+        elif props.search_file_size:
+            query_common["files_size_gte"] = props.search_file_size_min * 1024 * 1024
+            query_common["files_size_lte"] = props.search_file_size_max * 1024 * 1024
+
+
     query.update(query_common)
 
 
@@ -980,14 +1002,6 @@ def build_query_model():
         if props.search_polycount:
             query["faceCount_gte"] = props.search_polycount_min
             query["faceCount_lte"] = props.search_polycount_max
-        if props.search_texture_resolution:
-            query["textureResolutionMax_gte"] = props.search_texture_resolution_min
-            query["textureResolutionMax_lte"] = 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)
 
@@ -1025,10 +1039,6 @@ def build_query_material():
         else:
             query["style"] = props.search_style_other
 
-    if props.search_texture_resolution:
-        query["textureResolutionMax_gte"] = props.search_texture_resolution_min
-        query["textureResolutionMax_lte"] = props.search_texture_resolution_max
-
     build_query_common(query, props)
 
     return query
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 29a5f7ad..00ff869e 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -303,7 +303,7 @@ def draw_panel_model_search(self, context):
     layout.prop(props, "search_style")
     layout.prop(props, "own_only")
     layout.prop(props, "free_only")
-    # layout.prop(props, "search_procedural", expand = True)
+
     # if props.search_style == 'OTHER':
     #     layout.prop(props, "search_style_other")
     # layout.prop(props, "search_engine")
@@ -322,7 +322,7 @@ def draw_panel_model_search(self, context):
         #     layout.prop(props, "search_engine_keyword")
 
         # AGE
-        layout.prop(props, "search_condition", text = 'Condition')  # , text ='condition of object new/old e.t.c.')
+        layout.prop(props, "search_condition", text='Condition')  # , text ='condition of object new/old e.t.c.')
 
         # DESIGN YEAR
         layout.prop(props, "searc

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list