Cleanup: USD: various non-functional changes

Tidy up:
- Use blender::Map and blender::Vector for newly created `prim_map`
- Leave bread-crumb comment for moving map creation outside of loop
- Expand UI tooltip for newly added export option

Pull Request: https://projects.blender.org/blender/blender/pulls/131770
This commit is contained in:
Jesse Yurkovich
2024-12-12 00:57:29 +01:00
committed by Jesse Yurkovich
parent fe6609c4eb
commit a6d4e91db8
5 changed files with 18 additions and 15 deletions

View File

@@ -854,9 +854,9 @@ void WM_OT_usd_export(wmOperatorType *ot)
"merge_parent_xform",
false,
"Merge parent Xform",
"Merge USD primitives with their Xform parent if possible: "
"USD does not allow nested UsdGeomGprim. Intermediary Xform will "
"be defined to keep the USD file valid.");
"Merge USD primitives with their Xform parent if possible. USD does not allow "
"nested UsdGeomGprims, intermediary Xform prims will be defined to keep the USD "
"file valid when encountering object hierarchies.");
}
/* ====== USD Import ====== */

View File

@@ -343,7 +343,6 @@ static void import_startjob(void *customdata, wmJobWorkerStatus *worker_status)
/* Setup parenthood and read actual object data. */
i = 0;
for (USDPrimReader *reader : archive->readers()) {
if (!reader) {
continue;
}
@@ -355,11 +354,12 @@ static void import_startjob(void *customdata, wmJobWorkerStatus *worker_status)
reader->read_object_data(data->bmain, 0.0);
data->prim_map[reader->object_prim_path()].push_back(RNA_id_pointer_create(&ob->id));
/* TODO: Move this outside the loop once when we support reading object data in parallel. */
data->prim_map.lookup_or_add_default(reader->object_prim_path())
.append(RNA_id_pointer_create(&ob->id));
if (ob->data) {
data->prim_map[reader->data_prim_path()].push_back(
RNA_id_pointer_create(static_cast<ID *>(ob->data)));
data->prim_map.lookup_or_add_default(reader->data_prim_path())
.append(RNA_id_pointer_create(static_cast<ID *>(ob->data)));
}
USDPrimReader *parent = reader->parent();
@@ -384,7 +384,7 @@ static void import_startjob(void *customdata, wmJobWorkerStatus *worker_status)
[&](const std::string &path, const std::string &name) {
Material *mat = data->settings.mat_name_to_mat.lookup_default(name, nullptr);
if (mat) {
data->prim_map[path].push_back(RNA_id_pointer_create(&mat->id));
data->prim_map.lookup_or_add_default(path).append(RNA_id_pointer_create(&mat->id));
}
});

View File

@@ -145,7 +145,7 @@ struct USDSceneImportContext {
if (!prim_map_dict) {
prim_map_dict = new boost::python::dict;
for (auto &[path, ids] : prim_map) {
prim_map.foreach_item([&](const std::string &path, const Vector<PointerRNA> &ids) {
if (!prim_map_dict->has_key(path)) {
(*prim_map_dict)[path] = boost::python::list();
}
@@ -155,7 +155,7 @@ struct USDSceneImportContext {
for (auto &ptr_rna : ids) {
list.append(ptr_rna);
}
}
});
}
return *prim_map_dict;

View File

@@ -3,17 +3,21 @@
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "BLI_map.hh"
#include "BLI_vector.hh"
#include "RNA_types.hh"
#include <pxr/usd/usd/common.h>
#include <pxr/usd/usdShade/material.h>
struct Depsgraph;
struct Material;
struct PointerRNA;
struct ReportList;
namespace blender::io::usd {
using ImportedPrimMap = std::map<std::string, std::vector<PointerRNA>>;
using ImportedPrimMap = Map<std::string, Vector<PointerRNA>>;
/** Ensure classes and type converters necessary for invoking import and export hooks
* are registered. */

View File

@@ -136,6 +136,7 @@ struct USDExportParams {
bool only_deform_bones = false;
bool convert_world_material = true;
bool merge_parent_xform = false;
bool use_instancing = false;
bool export_custom_properties = true;
@@ -168,8 +169,6 @@ struct USDExportParams {
char collection[MAX_IDPROP_NAME] = "";
char custom_properties_namespace[MAX_IDPROP_NAME] = "";
bool merge_parent_xform = false;
/** Communication structure between the wmJob management code and the worker code. Currently used
* to generate safely reports from the worker thread. */
wmJobWorkerStatus *worker_status = nullptr;