[Bf-blender-cvs] [934589c7370] usd-importer-T81257: USD import flags.
makowalski
noreply at git.blender.org
Sun Dec 27 22:18:13 CET 2020
Commit: 934589c7370f9d2312742b3b78685ec224406011
Author: makowalski
Date: Wed Dec 9 16:50:18 2020 -0500
Branches: usd-importer-T81257
https://developer.blender.org/rB934589c7370f9d2312742b3b78685ec224406011
USD import flags.
Added Is Sequence and Transform Cache Constraint
import options.
===================================================================
M source/blender/editors/io/io_usd.c
M source/blender/io/usd/import/usd_reader_xformable.cc
M source/blender/io/usd/intern/usd_capi.cc
M source/blender/io/usd/usd.h
===================================================================
diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c
index 09452d46ced..3655abea00b 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -283,6 +283,9 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
const bool import_usdpreview = RNA_boolean_get(op->ptr, "import_usdpreview");
+ const bool is_sequence = RNA_boolean_get(op->ptr, "is_sequence");
+ const bool transform_constraint = RNA_boolean_get(op->ptr, "transform_constraint");
+
/* Switch out of edit mode to avoid being stuck in it (T54326). */
Object *obedit = CTX_data_edit_object(C);
if (obedit) {
@@ -296,7 +299,9 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
debug,
use_instancing,
light_intensity_scale,
- import_usdpreview};
+ import_usdpreview,
+ is_sequence,
+ transform_constraint};
bool ok = USD_import(C, filename, ¶ms, as_background_job);
@@ -322,6 +327,11 @@ static void wm_usd_import_draw(bContext *UNUSED(C), wmOperator *op)
uiItemR(box, ptr, "light_intensity_scale", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "debug", 0, NULL, ICON_NONE);
+ box = uiLayoutBox(layout);
+ uiItemL(box, IFACE_("Animation Cache"), ICON_NONE);
+ uiItemR(box, ptr, "is_sequence", 0, NULL, ICON_NONE);
+ uiItemR(box, ptr, "transform_constraint", 0, NULL, ICON_NONE);
+
box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Experimental"), ICON_NONE);
uiItemR(box, ptr, "use_instancing", 0, NULL, ICON_NONE);
@@ -394,6 +404,19 @@ void WM_OT_usd_import(wmOperatorType *ot)
false,
"Import UsdPreviewSurface",
"When checked, convert UsdPreviewSurface shaders to Principled BSD shader networks.");
+
+ RNA_def_boolean(ot->srna,
+ "is_sequence",
+ false,
+ "Is Sequence",
+ "Set to true if the cache is split into separate files");
+
+ RNA_def_boolean(ot->srna,
+ "transform_constraint",
+ true,
+ "Transform Cache Constraint",
+ "When checked, create transform cache constraints for objects that have "
+ "time-varying transforms.");
}
#endif /* WITH_USD */
diff --git a/source/blender/io/usd/import/usd_reader_xformable.cc b/source/blender/io/usd/import/usd_reader_xformable.cc
index 539b388438a..fdca56cf7ed 100644
--- a/source/blender/io/usd/import/usd_reader_xformable.cc
+++ b/source/blender/io/usd/import/usd_reader_xformable.cc
@@ -97,7 +97,7 @@ void USDXformableReader::set_object_transform(const double time, CacheFile *cach
BKE_object_apply_mat4(object_, transform_from_usd, true, false);
BKE_object_to_mat4(object_, object_->obmat);
- if (cache_file && !is_constant) {
+ if (cache_file && (!is_constant || this->context_.import_params.is_sequence)) {
bConstraint *con = BKE_constraint_add_for_object(
object_, NULL, CONSTRAINT_TYPE_TRANSFORM_CACHE);
bTransformCacheConstraint *data = static_cast<bTransformCacheConstraint *>(con->data);
diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc
index 931b08433ef..73a1a5ede14 100644
--- a/source/blender/io/usd/intern/usd_capi.cc
+++ b/source/blender/io/usd/intern/usd_capi.cc
@@ -298,22 +298,23 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
USDPrimIterator usd_prim_iter(data->stage, import_ctx, data->bmain);
- CacheFile *cache_file = static_cast<CacheFile *>(
- BKE_cachefile_add(data->bmain, BLI_path_basename(data->filename)));
-
- /* Decrement the ID ref-count because it is going to be incremented for each
- * modifier and constraint that it will be attached to, so since currently
- * it is not used by anyone, its use count will off by one. */
- /* TODO(makowalski): rather than decrementing the use count, should
- * we just call BKE_id_free_us() on the cache_file id when cleaning up? */
- id_us_min(&cache_file->id);
-
- // cache_file->is_sequence = data->params.is_sequence;
- cache_file->scale = data->params.scale;
- STRNCPY(cache_file->filepath, data->filename);
-
- // data->archive = archive;
- // data->settings.cache_file = cache_file;
+ CacheFile *cache_file = nullptr;
+
+ if (data->params.transform_constraint) {
+ cache_file = static_cast<CacheFile *>(
+ BKE_cachefile_add(data->bmain, BLI_path_basename(data->filename)));
+
+ /* Decrement the ID ref-count because it is going to be incremented for each
+ * modifier and constraint that it will be attached to, so since currently
+ * it is not used by anyone, its use count will off by one. */
+ /* TODO(makowalski): rather than decrementing the use count, should
+ * we just call BKE_id_free_us() on the cache_file id when cleaning up? */
+ id_us_min(&cache_file->id);
+
+ cache_file->is_sequence = data->params.is_sequence;
+ cache_file->scale = data->params.scale;
+ STRNCPY(cache_file->filepath, data->filename);
+ }
// Optionally print the stage contents for debugging.
if (data->params.debug) {
diff --git a/source/blender/io/usd/usd.h b/source/blender/io/usd/usd.h
index d993d7d62cf..cd3ff47ab68 100644
--- a/source/blender/io/usd/usd.h
+++ b/source/blender/io/usd/usd.h
@@ -65,6 +65,8 @@ struct USDImportParams {
bool use_instancing;
float light_intensity_scale;
bool import_usdpreview;
+ bool is_sequence;
+ bool transform_constraint;
};
/* The USD_import function takes a as_background_job parameter, and returns a boolean.
More information about the Bf-blender-cvs
mailing list