BlenderKit: search - default order

-default order by last upload
-enable search by file size
-improve procedural material search UI
This commit is contained in:
Vilém Duha 2020-01-25 09:05:52 +01:00
parent 1285546768
commit 4300021a7a
3 changed files with 106 additions and 52 deletions

View File

@ -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.

View File

@ -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

View File

@ -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, "search_design_year", text='designed in ( min - max )')
@ -345,8 +345,16 @@ def draw_panel_model_search(self, context):
row.prop(props, "search_texture_resolution_min", text='min')
row.prop(props, "search_texture_resolution_max", text='max')
# FILE SIZE
layout.prop(props, "search_file_size", text='File size ( min - max )')
if props.search_file_size:
row = layout.row(align=True)
row.prop(props, "search_file_size_min", text='min')
row.prop(props, "search_file_size_max", text='max')
# layout.prop(props, "search_procedural", expand=True)
# ADULT
#layout.prop(props, "search_adult") # , text ='condition of object new/old e.t.c.')
# layout.prop(props, "search_adult") # , text ='condition of object new/old e.t.c.')
draw_panel_categories(self, context)
@ -447,7 +455,7 @@ class VIEW3D_PT_blenderkit_profile(Panel):
me = bpy.context.window_manager.get('bkit profile')
if me is not None:
me = me['user']
#user name
# user name
layout.label(text='Me: %s %s' % (me['firstName'], me['lastName']))
# layout.label(text='Email: %s' % (me['email']))
@ -461,7 +469,7 @@ class VIEW3D_PT_blenderkit_profile(Panel):
# layout.operator("wm.url_open", text="Change plan",
# icon='URL').url = paths.get_bkit_url() + paths.BLENDERKIT_PLANS
#storage statistics
# storage statistics
# if me.get('sumAssetFilesSize') is not None: # TODO remove this when production server has these too.
# layout.label(text='My public assets: %i MiB' % (me['sumAssetFilesSize']))
# if me.get('sumPrivateAssetFilesSize') is not None:
@ -572,19 +580,32 @@ def draw_panel_material_search(self, context):
# if props.search_engine == 'OTHER':
# layout.prop(props, 'search_engine_other')
# TEXTURE RESOLUTION
layout.prop(props, "search_texture_resolution", text='texture resolution ( min - max )')
if props.search_texture_resolution:
row = layout.row(align=True)
row.prop(props, "search_texture_resolution_min", text='min')
row.prop(props, "search_texture_resolution_max", text='max')
layout.prop(props, "search_advanced")
if props.search_advanced:
layout.separator()
layout.prop(props, "search_procedural", expand=True)
if props.search_procedural == 'TEXTURE_BASED':
# TEXTURE RESOLUTION
layout.prop(props, "search_texture_resolution", text='texture resolution ( min - max )')
if props.search_texture_resolution:
row = layout.row(align=True)
row.prop(props, "search_texture_resolution_min", text='min')
row.prop(props, "search_texture_resolution_max", text='max')
# FILE SIZE
layout.prop(props, "search_file_size", text='File size ( min - max in mb)')
if props.search_file_size:
row = layout.row(align=True)
row.prop(props, "search_file_size_min", text='min')
row.prop(props, "search_file_size_max", text='max')
draw_panel_categories(self, context)
layout.prop(props, 'automap')
def draw_panel_material_ratings(self, context):
op = draw_ratings(self.layout, context) # , props)
op.asset_type = 'MATERIAL'
@ -833,7 +854,7 @@ class OBJECT_MT_blenderkit_asset_menu(bpy.types.Menu):
wm = bpy.context.window_manager
profile = wm.get('bkit profile')
if profile is not None:
# validation
# validation
if utils.profile_is_validator():
layout.label(text='Validation tools:')
if asset_data['verificationStatus'] != 'uploaded':
@ -1039,7 +1060,7 @@ def header_search_draw(self, context):
# the center snap menu is in edit and object mode if tool settings are off.
if context.space_data.show_region_tool_header == True or context.mode[:4] not in ('EDIT', 'OBJE'):
layout.separator_spacer()
layout.separator_spacer()
layout.prop(ui_props, "asset_type", text='', icon='URL')
layout.prop(props, "search_keywords", text="", icon='VIEWZOOM')
draw_assetbar_show_hide(layout, props)