Blender  V3.3
asset_filter.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "BKE_idtype.h"
8 
9 #include "BLI_listbase.h"
10 
11 #include "DNA_asset_types.h"
12 
13 #include "ED_asset_filter.h"
14 #include "ED_asset_handle.h"
15 
17 {
18  ID_Type asset_type = ED_asset_handle_get_id_type(asset);
19  uint64_t asset_id_filter = BKE_idtype_idcode_to_idfilter(asset_type);
20 
21  if ((filter->id_types & asset_id_filter) == 0) {
22  return false;
23  }
24  /* Not very efficient (O(n^2)), could be improved quite a bit. */
25  LISTBASE_FOREACH (const AssetTag *, filter_tag, &filter->tags) {
26  AssetMetaData *asset_data = ED_asset_handle_get_metadata(asset);
27 
28  AssetTag *matched_tag = (AssetTag *)BLI_findstring(
29  &asset_data->tags, filter_tag->name, offsetof(AssetTag, name));
30  if (matched_tag == nullptr) {
31  return false;
32  }
33  }
34 
35  /* Successfully passed through all filters. */
36  return true;
37 }
uint64_t BKE_idtype_idcode_to_idfilter(short idcode)
Definition: idtype.c:206
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
ID_Type
Definition: DNA_ID_enums.h:44
ID_Type ED_asset_handle_get_id_type(const struct AssetHandle *asset)
struct AssetMetaData * ED_asset_handle_get_metadata(const struct AssetHandle *asset)
bool ED_asset_filter_matches_asset(const AssetFilterSettings *filter, const AssetHandle *asset)
Definition: asset_filter.cc:16
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
unsigned __int64 uint64_t
Definition: stdint.h:90
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
User defined tag. Currently only used by assets, could be used more often at some point....