[Bf-blender-cvs] [cf8cf884d14] universal-scene-description: Merge branch 'master' into universal-scene-description

Michael Kowalski noreply at git.blender.org
Tue Oct 18 22:21:46 CEST 2022


Commit: cf8cf884d147cdd6d1786d3a1a341bbeec2b871d
Author: Michael Kowalski
Date:   Tue Oct 18 14:16:53 2022 -0400
Branches: universal-scene-description
https://developer.blender.org/rBcf8cf884d147cdd6d1786d3a1a341bbeec2b871d

Merge branch 'master' into universal-scene-description

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



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

diff --cc source/blender/editors/io/io_usd.c
index 0998fc77b01,c776fbf0dd7..313e2488ace
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@@ -178,43 -85,16 +179,29 @@@ static int wm_usd_export_invoke(bContex
    options->as_background_job = true;
    op->customdata = options;
  
 +  RNA_boolean_set(op->ptr, "init_scene_frame_range", true);
 +
-   if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
-     Main *bmain = CTX_data_main(C);
-     char filepath[FILE_MAX];
-     const char *main_blendfile_path = BKE_main_blendfile_path(bmain);
- 
-     if (main_blendfile_path[0] == '\0') {
-       BLI_strncpy(filepath, "untitled", sizeof(filepath));
-     }
-     else {
-       BLI_strncpy(filepath, main_blendfile_path, sizeof(filepath));
-     }
- 
-     BLI_path_extension_replace(filepath, sizeof(filepath), ".usd");
-     RNA_string_set(op->ptr, "filepath", filepath);
-   }
+   ED_fileselect_ensure_default_filepath(C, op, ".usdc");
  
    WM_event_add_fileselect(C, op);
  
    return OPERATOR_RUNNING_MODAL;
  }
  
 +static char *usd_ensure_prim_path(char *primpath)
 +{
 +  if (primpath != NULL && primpath[0] != '/' && primpath[0] != '\0') {
 +    char *legal_path = BLI_strdupcat("/", primpath);
 +    MEM_freeN(primpath);
 +    primpath = legal_path;
 +    return legal_path;
 +  }
 +  return primpath;
 +}
 +
  static int wm_usd_export_exec(bContext *C, wmOperator *op)
  {
-   if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
+   if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
      BKE_report(op->reports, RPT_ERROR, "No filename given");
      return OPERATOR_CANCELLED;
    }
@@@ -559,11 -187,23 +546,24 @@@ static void wm_usd_export_draw(bContex
    uiItemR(col, ptr, "relative_paths", 0, NULL, ICON_NONE);
  
    box = uiLayoutBox(layout);
 -  uiItemL(box, IFACE_("Experimental"), ICON_NONE);
 +  uiItemL(box, IFACE_("Experimental:"), ICON_NONE);
    uiItemR(box, ptr, "use_instancing", 0, NULL, ICON_NONE);
 +  uiItemR(box, ptr, "fix_skel_root", 0, NULL, ICON_NONE);
  }
  
+ static void free_operator_customdata(wmOperator *op)
+ {
+   if (op->customdata) {
+     MEM_freeN(op->customdata);
+     op->customdata = NULL;
+   }
+ }
+ 
+ static void wm_usd_export_cancel(bContext *UNUSED(C), wmOperator *op)
+ {
+   free_operator_customdata(op);
+ }
+ 
  static bool wm_usd_export_check(bContext *UNUSED(C), wmOperator *op)
  {
    char filepath[FILE_MAX];
@@@ -1137,17 -424,13 +1138,19 @@@ static int wm_usd_import_exec(bContext 
                                     .import_render = import_render,
                                     .import_visible_only = import_visible_only,
                                     .use_instancing = use_instancing,
 -                                   .import_usd_preview = import_usd_preview,
 +                                   .import_shaders_mode = import_shaders_mode,
                                     .set_material_blend = set_material_blend,
                                     .light_intensity_scale = light_intensity_scale,
 -                                   .mtl_name_collision_mode = mtl_name_collision_mode};
 +                                   .apply_unit_conversion_scale = apply_unit_conversion_scale,
 +                                   .convert_light_from_nits = convert_light_from_nits,
 +                                   .scale_light_radius = scale_light_radius,
 +                                   .create_background_shader = create_background_shader,
 +                                   .mtl_name_collision_mode = mtl_name_collision_mode,
 +                                   .attr_import_mode = attr_import_mode,
 +                                   .import_shapes = import_shapes};
  
+   STRNCPY(params.prim_path_mask, prim_path_mask);
+ 
    const bool ok = USD_import(C, filename, &params, as_background_job);
  
    return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
diff --cc source/blender/editors/space_file/filelist.cc
index 00000000000,b6f6ab39438..783e471e630
mode 000000,100644..100644
--- a/source/blender/editors/space_file/filelist.cc
+++ b/source/blender/editors/space_file/filelist.cc
@@@ -1,0 -1,3960 +1,3960 @@@
+ /* SPDX-License-Identifier: GPL-2.0-or-later
+  * Copyright 2007 Blender Foundation. All rights reserved. */
+ 
+ /** \file
+  * \ingroup spfile
+  */
+ 
+ /* global includes */
+ 
+ #include <cmath>
+ #include <cstdlib>
+ #include <cstring>
+ #include <ctime>
+ #include <sys/stat.h>
+ 
+ #ifndef WIN32
+ #  include <unistd.h>
+ #else
+ #  include <direct.h>
+ #  include <io.h>
+ #endif
+ #include "MEM_guardedalloc.h"
+ 
+ #include "BLF_api.h"
+ 
+ #include "BLI_blenlib.h"
+ #include "BLI_fileops.h"
+ #include "BLI_fileops_types.h"
+ #include "BLI_fnmatch.h"
+ #include "BLI_ghash.h"
+ #include "BLI_linklist.h"
+ #include "BLI_math.h"
+ #include "BLI_stack.h"
+ #include "BLI_task.h"
+ #include "BLI_threads.h"
+ #include "BLI_utildefines.h"
+ #include "BLI_uuid.h"
+ 
+ #ifdef WIN32
+ #  include "BLI_winstuff.h"
+ #endif
+ 
+ #include "BKE_asset.h"
+ #include "BKE_asset_library.h"
+ #include "BKE_context.h"
+ #include "BKE_global.h"
+ #include "BKE_icons.h"
+ #include "BKE_idtype.h"
+ #include "BKE_lib_id.h"
+ #include "BKE_main.h"
+ #include "BKE_main_idmap.h"
+ #include "BKE_preferences.h"
+ #include "BLO_readfile.h"
+ 
+ #include "DNA_asset_types.h"
+ #include "DNA_space_types.h"
+ 
+ #include "ED_datafiles.h"
+ #include "ED_fileselect.h"
+ #include "ED_screen.h"
+ 
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+ #include "IMB_thumbs.h"
+ 
+ #include "PIL_time.h"
+ 
+ #include "WM_api.h"
+ #include "WM_types.h"
+ 
+ #include "UI_interface_icons.h"
+ #include "UI_resources.h"
+ 
+ #include "atomic_ops.h"
+ 
+ #include "file_indexer.h"
+ #include "file_intern.h"
+ #include "filelist.h"
+ 
+ #define FILEDIR_NBR_ENTRIES_UNSET -1
+ 
+ /* ------------------FILELIST------------------------ */
+ 
+ struct FileListInternEntry {
+   FileListInternEntry *next, *prev;
+ 
+   FileUID uid;
+ 
+   eFileSel_File_Types typeflag;
+   /** ID type, in case typeflag has FILE_TYPE_BLENDERLIB set. */
+   int blentype;
+ 
+   char *relpath;
+   /** Optional argument for shortcuts, aliases etc. */
+   char *redirection_path;
+   /** not strictly needed, but used during sorting, avoids to have to recompute it there... */
+   char *name;
+   bool free_name;
+ 
+   /**
+    * This is data from the current main, represented by this file. It's crucial that this is
+    * updated correctly on undo, redo and file reading (without UI). The space is responsible to
+    * take care of that.
+    */
+   struct {
+     /** When showing local IDs (FILE_MAIN, FILE_MAIN_ASSET), the ID this file entry represents. */
+     ID *id;
+ 
+     /* For the few file types that have the preview already in memory. For others, there's delayed
+      * preview reading from disk. Non-owning pointer. */
+     PreviewImage *preview_image;
+   } local_data;
+ 
+   /** When the file represents an asset read from another file, it is stored here.
+    * Owning pointer. */
+   AssetMetaData *imported_asset_data;
+ 
+   /** Defined in BLI_fileops.h */
+   eFileAttributes attributes;
+   BLI_stat_t st;
+ };
+ 
+ struct FileListIntern {
+   /** FileListInternEntry items. */
+   ListBase entries;
+   FileListInternEntry **filtered;
+ 
+   FileUID curr_uid; /* Used to generate UID during internal listing. */
+ };
+ 
+ #define FILELIST_ENTRYCACHESIZE_DEFAULT 1024 /* Keep it a power of two! */
+ struct FileListEntryCache {
+   size_t size; /* The size of the cache... */
+ 
+   int flags;
+ 
+   /* This one gathers all entries from both block and misc caches. Used for easy bulk-freeing. */
+   ListBase cached_entries;
+ 
+   /* Block cache: all entries between start and end index.
+    * used for part of the list on display. */
+   FileDirEntry **block_entries;
+   int block_start_index, block_end_index, block_center_index, block_cursor;
+ 
+   /* Misc cache: random indices, FIFO behavior.
+    * NOTE: Not 100% sure we actually need that, time will say. */
+   int misc_cursor;
+   int *misc_entries_indices;
+   GHash *misc_entries;
+ 
+   /* Allows to quickly get a cached entry from its UID. */
+   GHash *uids;
+ 
+   /* Previews handling. */
+   TaskPool *previews_pool;
+   ThreadQueue *previews_done;
+   /** Counter for previews that are not fully loaded and ready to display yet. So includes all
+    * previews either in `previews_pool` or `previews_done`. #filelist_cache_previews_update() makes
+    * previews in `preview_done` ready for display, so the counter is decremented there. */
+   int previews_todo_count;
+ };
+ 
+ /** #FileListCache.flags */
+ enum {
+   FLC_IS_INIT = 1 << 0,
+   FLC_PREVIEWS_ACTIVE = 1 << 1,
+ };
+ 
+ struct FileListEntryPreview {
+   char filepath[FILE_MAX];
+   uint flags;
+   int index;
+   int attributes; /* from FileDirEntry. */
+   int icon_id;
+ };
+ 
+ /* Dummy wrapper around FileListEntryPreview to ensure we do not access freed memory when freeing
+  * tasks' data (see T74609). */
+ struct FileListEntryPreviewTaskData {
+   FileListEntryPreview *preview;
+ };
+ 
+ struct FileListFilter {
+   uint64_t filter;
+   uint64_t filter_id;
+   char filter_glob[FILE_MAXFILE];
+   char filter_search[66]; /* + 2 for heading/trailing implicit '*' wildcards. */
+   short flags;
+ 
+   FileAssetCatalogFilterSettingsHandle *asset_catalog_filter;
+ };
+ 
+ /** #FileListFilter.flags */
+ enum {
+   FLF_DO_FILTER = 1 << 0,
+   FLF_HIDE_DOT = 1 << 1,
+   FLF_HIDE_PARENT = 1 << 2,
+   FLF_HIDE_LIB_DIR = 1 << 3,
+   FLF_ASSETS_ONLY = 1 << 4,
+ };
+ 
+ struct FileListReadJob;
+ struct FileList {
+   FileDirEntryArr filelist;
+ 
+   eFileSelectType type;
+   /* The library this list was created for. Stored here so we know when to re-read. */
+   AssetLibraryReference *asset_library_ref;
+   AssetLibrary *asset_library; /* Non-owning pointer. */
+ 
+   short flags;
+ 
+   short sort;
+ 
+   FileListFilter filter_data;
+ 
+   /**
+    * File indexer to use. Attribute is always set.
+    */
+   const FileIndexerType *indexer;
+ 
+   FileListIntern filelist_intern;
+ 
+   FileListEntryCache filelist_cache;
+ 
+   /* We need to keep those info outside of actual fi

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list