[Bf-extensions-cvs] [87d8e1d2] master: BlenderKit: improve searching for first ratable asset. Now parents will be searched to get first parent with relevant data, also in appended assets.

Vilém Duha noreply at git.blender.org
Mon Aug 12 16:05:28 CEST 2019


Commit: 87d8e1d28ae0deb271540cf1487970de865d51f7
Author: Vilém Duha
Date:   Fri Aug 9 11:39:01 2019 +0200
Branches: master
https://developer.blender.org/rBA87d8e1d28ae0deb271540cf1487970de865d51f7

BlenderKit: improve searching for first ratable asset.
Now parents will be searched to get first parent with relevant data, also in appended assets.

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

M	blenderkit/ui.py

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

diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index b03875f0..e62b8aa6 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -973,12 +973,20 @@ def is_rating_possible():
                 rated = bpy.context.scene['assets rated'].get(ad['asset_base_id'])
                 return True, rated, b, ad
         if ao is not None:
-            # TODO ADD BRUSHES HERE
-            ad = ao.get('asset_data')
-            if ad is not None:
-                rated = bpy.context.scene['assets rated'].get(ad['asset_base_id'])
-                # originally hidden for already rated assets
-                return True, rated, ao, ad
+            ad = None
+            #crawl parents to reach active asset. there could have been parenting so we need to find the first onw
+            ao_check = ao
+            while ad is None or (ad is None and ao_check.parent is not None):
+                ad = ao_check.get('asset_data')
+                if ad is not None:
+                    rated = bpy.context.scene['assets rated'].get(ad['asset_base_id'])
+                    # originally hidden for already rated assets
+                    return True, rated, ao_check, ad
+                elif ao_check.parent is not None:
+                    ao_check = ao_check.parent
+                else:
+                    break;
+
 
             # check also materials
             m = ao.active_material



More information about the Bf-extensions-cvs mailing list