[Bf-blender-cvs] [0b30ef2e384] usd-importer-T81257: Format changes.
Michael A. Kowalski
noreply at git.blender.org
Mon Oct 12 01:33:34 CEST 2020
Commit: 0b30ef2e3846aa807ef7c47c0d388bad1c4b830a
Author: Michael A. Kowalski
Date: Sun Oct 11 19:31:57 2020 -0400
Branches: usd-importer-T81257
https://developer.blender.org/rB0b30ef2e3846aa807ef7c47c0d388bad1c4b830a
Format changes.
===================================================================
M source/blender/editors/io/io_usd.c
M source/blender/io/usd/intern/usd_reader_mesh.cc
M source/blender/io/usd/intern/usd_util.cc
===================================================================
diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c
index f6c8062e96c..9f82e9a2849 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -328,7 +328,8 @@ void WM_OT_usd_import(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "import_uvs", true, "uvs", "When checked, import mesh uvs.");
- RNA_def_boolean(ot->srna, "import_normals", true, "normals", "When checked, import mesh normals.");
+ RNA_def_boolean(
+ ot->srna, "import_normals", true, "normals", "When checked, import mesh normals.");
RNA_def_float(
ot->srna,
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 173293e929d..8e5da92c47f 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -224,25 +224,24 @@ static void process_loop_normals(Mesh *mesh, const MeshSampleData &mesh_data)
}
float(*lnors)[3] = static_cast<float(*)[3]>(
- MEM_malloc_arrayN(loop_count, sizeof(float[3]), "USD::FaceNormals"));
+ MEM_malloc_arrayN(loop_count, sizeof(float[3]), "USD::FaceNormals"));
for (int i = 0; i < loop_count; ++i) {
- if (mesh_data.y_up)
- {
- blender::io::usd::copy_zup_from_yup(lnors[i], mesh_data.normals[i].data());
- }
- else {
- lnors[i][0] = mesh_data.normals[i].data()[0];
- lnors[i][1] = mesh_data.normals[i].data()[1];
- lnors[i][2] = mesh_data.normals[i].data()[2];
- }
-
- if (mesh_data.reverse_vert_order) {
- lnors[i][0] = -lnors[i][0];
- lnors[i][1] = -lnors[i][1];
- lnors[i][2] = -lnors[i][2];
- }
+ if (mesh_data.y_up) {
+ blender::io::usd::copy_zup_from_yup(lnors[i], mesh_data.normals[i].data());
+ }
+ else {
+ lnors[i][0] = mesh_data.normals[i].data()[0];
+ lnors[i][1] = mesh_data.normals[i].data()[1];
+ lnors[i][2] = mesh_data.normals[i].data()[2];
+ }
+
+ if (mesh_data.reverse_vert_order) {
+ lnors[i][0] = -lnors[i][0];
+ lnors[i][1] = -lnors[i][1];
+ lnors[i][2] = -lnors[i][2];
+ }
}
mesh->flag |= ME_AUTOSMOOTH;
@@ -265,12 +264,11 @@ static void process_vertex_normals(Mesh *mesh, const MeshSampleData &mesh_data)
}
float(*vnors)[3] = static_cast<float(*)[3]>(
- MEM_malloc_arrayN(normals_count, sizeof(float[3]), "USD::VertexNormals"));
+ MEM_malloc_arrayN(normals_count, sizeof(float[3]), "USD::VertexNormals"));
for (int i = 0; i < normals_count; ++i) {
- if (mesh_data.y_up)
- {
+ if (mesh_data.y_up) {
blender::io::usd::copy_zup_from_yup(vnors[i], mesh_data.normals[i].data());
}
else {
@@ -293,21 +291,22 @@ static void process_vertex_normals(Mesh *mesh, const MeshSampleData &mesh_data)
static void process_normals(Mesh *mesh, const MeshSampleData &mesh_data)
{
- if (!mesh || mesh_data.normals.empty() ) {
+ if (!mesh || mesh_data.normals.empty()) {
process_no_normals(mesh);
return;
}
if (mesh_data.normals_interpolation == pxr::UsdGeomTokens->faceVarying) {
- process_loop_normals(mesh, mesh_data); /* 'vertex normals' in Houdini. */
- } else if (mesh_data.normals_interpolation == pxr::UsdGeomTokens->vertex) {
+ process_loop_normals(mesh, mesh_data); /* 'vertex normals' in Houdini. */
+ }
+ else if (mesh_data.normals_interpolation == pxr::UsdGeomTokens->vertex) {
process_vertex_normals(mesh, mesh_data); /* 'point normals' in Houdini. */
- } else {
+ }
+ else {
process_no_normals(mesh);
}
}
-
namespace blender::io::usd {
UsdMeshReader::UsdMeshReader(const pxr::UsdPrim &prim, const USDImporterContext &context)
@@ -379,7 +378,8 @@ Mesh *UsdMeshReader::read_mesh(Mesh *existing_mesh,
mesh_data.normals_interpolation = mesh_.GetNormalsInterpolation();
process_normals(new_mesh, mesh_data);
- } else {
+ }
+ else {
process_no_normals(new_mesh);
}
}
diff --git a/source/blender/io/usd/intern/usd_util.cc b/source/blender/io/usd/intern/usd_util.cc
index 361afcce762..c81d882758f 100644
--- a/source/blender/io/usd/intern/usd_util.cc
+++ b/source/blender/io/usd/intern/usd_util.cc
@@ -305,7 +305,9 @@ void create_readers(const pxr::UsdStageRefPtr &usd_stage,
if (merge_reader) {
std::string parent_path = prim.GetPath().GetString();
if (readers_map.insert(std::make_pair(parent_path, reader)).second == false) {
- std::cerr << "Programmer error: couldn't insert merged prim into reader map with parent path key." << std::endl;
+ std::cerr << "Programmer error: couldn't insert merged prim into reader map with parent "
+ "path key."
+ << std::endl;
}
}
@@ -354,7 +356,7 @@ void create_readers(const pxr::UsdPrim &prim,
/* Recursively create readers for the child prims. */
pxr::UsdPrimSiblingRange child_prims = prim.GetFilteredChildren(
- pxr::UsdTraverseInstanceProxies(pxr::UsdPrimAllPrimsPredicate));
+ pxr::UsdTraverseInstanceProxies(pxr::UsdPrimAllPrimsPredicate));
for (const pxr::UsdPrim &child_prim : child_prims) {
create_readers(child_prim, context, r_readers, child_readers);
@@ -368,8 +370,9 @@ void create_readers(const pxr::UsdPrim &prim,
/* We prune away empty transform or scope hierarchies (we can add an import flag to make this
* behavior optional). Therefore, we skip this prim if it's an Xform or Scope and if
* it has no corresponding child readers. */
- if ((prim.GetTypeName() == usdtokens::xform_type || prim.GetTypeName() == usdtokens::scope_type)
- && child_readers.empty()) {
+ if ((prim.GetTypeName() == usdtokens::xform_type ||
+ prim.GetTypeName() == usdtokens::scope_type) &&
+ child_readers.empty()) {
return;
}
@@ -378,8 +381,7 @@ void create_readers(const pxr::UsdPrim &prim,
* The list of child types that can be merged will be expanded as we
* support more reader types (e.g., for lights, curves, etc.). */
- if (prim.GetTypeName() == usdtokens::xform_type &&
- child_readers.size() == 1 &&
+ if (prim.GetTypeName() == usdtokens::xform_type && child_readers.size() == 1 &&
child_readers.front()->prim().GetTypeName() == usdtokens::mesh_type) {
child_readers.front()->set_merged_with_parent(true);
// We don't create a reader for the Xform but, instead, we return the grandchild
@@ -391,18 +393,17 @@ void create_readers(const pxr::UsdPrim &prim,
UsdObjectReader *reader = get_reader(prim, context);
if (reader) {
- for (UsdObjectReader *child_reader : child_readers)
- {
+ for (UsdObjectReader *child_reader : child_readers) {
child_reader->set_parent(reader);
}
r_child_readers.push_back(reader);
r_readers.push_back(reader);
- } else {
+ }
+ else {
/* No reader was allocated for this prim, so we pass our child readers back to the caller,
* for possible handling by a parent reader. */
r_child_readers.insert(r_child_readers.end(), child_readers.begin(), child_readers.end());
}
-
}
} /* namespace blender::io::usd */
More information about the Bf-blender-cvs
mailing list