Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilem Duha <vilem.duha@gmail.com>2021-07-10 12:43:40 +0300
committerVilem Duha <vilem.duha@gmail.com>2021-07-12 21:46:00 +0300
commit7a63ecf80573cd59ab64b51a7c680421efcc656a (patch)
tree7f6b5828516a3d645ae9ef722e07c5ed2e11a4e5 /blenderkit
parent69f875e1171ae83b6737fc988411afd14c8c4282 (diff)
BlenderKit: Fix autothumb for materials - scale wasn't applied on the preview object
This caused displacement to render incorrectly sized on scaled preview objects support more objects for drag-drop materials don't show ratings for private objects
Diffstat (limited to 'blenderkit')
-rw-r--r--blenderkit/autothumb_material_bg.py17
-rw-r--r--blenderkit/ui.py23
-rw-r--r--blenderkit/ui_panels.py3
-rw-r--r--blenderkit/utils.py4
4 files changed, 32 insertions, 15 deletions
diff --git a/blenderkit/autothumb_material_bg.py b/blenderkit/autothumb_material_bg.py
index b5d2651b..50e8aa4b 100644
--- a/blenderkit/autothumb_material_bg.py
+++ b/blenderkit/autothumb_material_bg.py
@@ -82,16 +82,23 @@ if __name__ == "__main__":
bpy.data.materials["bg checker colorable"].node_tree.nodes['input_level'].outputs['Value'].default_value \
= data['thumbnail_background_lightness']
tscale = data["thumbnail_scale"]
- bpy.context.view_layer.objects['scaler'].scale = (tscale, tscale, tscale)
+ scaler = bpy.context.view_layer.objects['scaler']
+ scaler.scale = (tscale, tscale, tscale)
+ utils.activate(scaler)
+ bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
+
bpy.context.view_layer.update()
for ob in bpy.context.visible_objects:
if ob.name[:15] == 'MaterialPreview':
+ utils.activate(ob)
+ bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
+
ob.material_slots[0].material = mat
ob.data.use_auto_texspace = False
- ob.data.texspace_size.x = 1 / tscale
- ob.data.texspace_size.y = 1 / tscale
- ob.data.texspace_size.z = 1 / tscale
+ ob.data.texspace_size.x = 1 #/ tscale
+ ob.data.texspace_size.y = 1 #/ tscale
+ ob.data.texspace_size.z = 1 #/ tscale
if data["adaptive_subdivision"] == True:
ob.cycles.use_adaptive_subdivision = True
@@ -130,6 +137,8 @@ if __name__ == "__main__":
bpy.context.scene.render.filepath = data['thumbnail_path']
bg_blender.progress('rendering thumbnail')
+ # bpy.ops.wm.save_as_mainfile(filepath='C:/tmp/test.blend')
+ # fal
render_thumbnails()
if data.get('upload_after_render') and data.get('asset_data'):
bg_blender.progress('uploading thumbnail')
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index d5692eab..da1e6f29 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -771,7 +771,6 @@ def deep_ray_cast(depsgraph, ray_origin, vec):
if not object:
return empty_set
try_object = object
- print(object.type)
while try_object and (try_object.display_type == 'BOUNDS' or object_in_particle_collection(try_object)):
ray_origin = snapped_location + vec.normalized() * 0.0003
try_has_hit, try_snapped_location, try_snapped_normal, try_face_index, try_object, try_matrix = bpy.context.scene.ray_cast(
@@ -1542,9 +1541,13 @@ class AssetBarOperator(bpy.types.Operator):
# create final mesh to extract correct material slot
depsgraph = bpy.context.evaluated_depsgraph_get()
object_eval = object.evaluated_get(depsgraph)
- temp_mesh = object_eval.to_mesh()
- target_slot = temp_mesh.polygons[face_index].material_index
- object_eval.to_mesh_clear()
+ if object.type =='MESH':
+ temp_mesh = object_eval.to_mesh()
+ target_slot = temp_mesh.polygons[face_index].material_index
+ object_eval.to_mesh_clear()
+ else:
+ ui_props.snapped_location = object.location
+ target_slot = 0
else:
if object.is_library_indirect:
ui_panels.ui_message(title='This object is linked from outer file',
@@ -1553,9 +1556,12 @@ class AssetBarOperator(bpy.types.Operator):
"in BlenderKit and hit 'Bring to Scene' first.")
print(object.type)
if object.type not in utils.supported_material_drag:
- ui_panels.ui_message(title='Unsupported object type',
- message="Only meshes are supported for material drag-drop.\n "
- "Use click interaction for other object types.")
+ if object.type in utils.supported_material_click:
+ ui_panels.ui_message(title='Unsupported object type',
+ message=f"Use click interaction for {object.type.lower()} object.")
+ else:
+ ui_panels.ui_message(title='Unsupported object type',
+ message=f"Can't assign materials to {object.type.lower()} object.")
self.report({'WARNING'}, "Invalid or library object as input:")
target_object = ''
target_slot = ''
@@ -1576,8 +1582,7 @@ class AssetBarOperator(bpy.types.Operator):
else:
if ao != None and ui_props.asset_type == 'MATERIAL' and ao.type not in supported_material_click:
ui_panels.ui_message(title='Unsupported object type',
- message="Can't assign material to this object type."
- "Please select another object.")
+ message=f"Can't assign materials to {ao.type.lower()} object.")
target_object = ''
target_slot = ''
# FIRST START SEARCH
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index ef963d91..ad642288 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -1733,7 +1733,10 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
# row = box_thumbnail.row()
# row.scale_y = 3
# op = row.operator('view3d.asset_drag_drop', text='Drag & Drop from here', depress=True)
+ # From here on, only ratings are drawn, which won't be displayed for private assets from now on.
+ if self.asset_data['isPrivate']:
+ return;
row = box_thumbnail.row()
row.alignment = 'EXPAND'
diff --git a/blenderkit/utils.py b/blenderkit/utils.py
index fd01e74b..d5bdd84b 100644
--- a/blenderkit/utils.py
+++ b/blenderkit/utils.py
@@ -39,8 +39,8 @@ NORMAL_PRIORITY_CLASS = 0x00000020
REALTIME_PRIORITY_CLASS = 0x00000100
supported_material_click = ('MESH', 'CURVE', 'META', 'FONT', 'SURFACE', 'VOLUME', 'GPENCIL')
-# supported_material_drag = ('MESH', 'CURVE', 'META', 'FONT', 'SURFACE', 'VOLUME', 'GPENCIL')
-supported_material_drag = ('MESH')
+supported_material_drag = ('MESH', 'CURVE', 'META', 'FONT','SURFACE', 'VOLUME', 'GPENCIL')
+# supported_material_drag = ('MESH')
def experimental_enabled():