Page MenuHome

Fix T98055: Library Filters do not work in Source Files
ClosedPublic

Authored by Sonny Campbell (SonnyCampbell_Unity) on Jun 24 2022, 10:41 AM.

Details

Summary

The fix is to ensure the filter for id type is run when displaying assets from an Asset Library.

In the current implementation the id_type filter does not run if a blend file is opened that also happens to be in an Asset Library directory. If we have opened a blend file that is in an Asset Library directory, we use the same is_filtered_id_type() check that is used when filtering assets for "Current File".

How Has This Been Tested?
In Edit > Preferences > FIle Paths, set a directory for "User Library" at the bottom.

Drop the blend file attached in the ticket into the directory set for User Library.
Open a new blend file. Navigate to the Asset Browser and select User Library from the dropdown. Ensure that the filter options correctly hide/show the objects and materials in the library.
Open the blend file that was added to the User Library directly from the User Library directory. Navigate to the Asset Browser and select User Library from the dropdown. Ensure that the filter options correctly hide/show the objects and materials in the library.
Duplicate the blend file in the User Library directory. Repeat the two tests above and ensure that all materials and objects are correctly hidden/shown by the filter options.

Diff Detail

Repository
rB Blender

Event Timeline

Julian Eisel (Severin) requested changes to this revision.Jun 27 2022, 1:18 PM

Thanks a lot for the patch, this is really helpful!

I think we can keep the fix a bit simpler, is_filtered_asset_library() can just check if the "file" comes from within the current file (filelist_intern_entry_is_main_file() -- "main" thereby stands for the main data-base of the current Blender session) and if so, return is_filtered_main_assets() instead.
The asset library filtering was written before the asset browser could display assets from both external and the current file at the same time, so that case was never considered.


I like that this patch moved out the is_filtered_file_type() check from the file ID type checking. I would even go a bit further and make all the filter_fn() callbacks that care about this check explicitly call it, not have it nested in vaguely named functions like is_filtered_lib_type(). This would reduce the spaghetti levels in this code a bit :) Should be a separate cleanup/refactor patch though.

This revision now requires changes to proceed.Jun 27 2022, 1:18 PM

@Julian Eisel (Severin) Thanks for the feedback, that is substantially more straightforward. I'll clean up this PR to implement the fix you mentioned, and then create another to separate out the filtering code.

  • Revert "Fix T98055: Library Filters do not work in Source Files"
  • Updated with more straightforward fix to check if the file is the main file, and if so use the is_filtered_main_assets() filter instead.
This revision is now accepted and ready to land.Jun 27 2022, 4:06 PM