[Bf-blender-cvs] [fbaeef73deb] usd-importer-T81257-merge: USD Import: remove unsupported geometry flags.

makowalski noreply at git.blender.org
Fri Mar 12 07:25:52 CET 2021


Commit: fbaeef73debdedffee860ce61c38ca6f60792cd7
Author: makowalski
Date:   Fri Mar 12 01:18:13 2021 -0500
Branches: usd-importer-T81257-merge
https://developer.blender.org/rBfbaeef73debdedffee860ce61c38ca6f60792cd7

USD Import: remove unsupported geometry flags.

For now, removing support for reading velocities and
attributes, because the data allocation for these layers
no longer works in the current version of Blender.  We will
revisit implementing these features in the future.

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

M	source/blender/editors/io/io_usd.c
M	source/blender/io/usd/intern/usd_capi.cc
M	source/blender/io/usd/intern/usd_reader_mesh.cc
M	source/blender/io/usd/intern/usd_reader_mesh.h
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 c2f7013675b..bad7aa25b74 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -78,8 +78,6 @@ const EnumPropertyItem rna_enum_usd_import_read_flags[] = {
     {MOD_MESHSEQ_READ_POLY, "POLY", 0, "Faces", ""},
     {MOD_MESHSEQ_READ_UV, "UV", 0, "UV", ""},
     {MOD_MESHSEQ_READ_COLOR, "COLOR", 0, "Color", ""},
-    {MOD_MESHSEQ_READ_ATTR, "ATTR", 0, "Attributes", ""},
-    {MOD_MESHSEQ_READ_VELS, "VELS", 0, "Velocities", ""},
     {0, NULL, 0, NULL, NULL},
 };
 
@@ -282,7 +280,6 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
   RNA_string_get(op->ptr, "filepath", filename);
 
   const float scale = RNA_float_get(op->ptr, "scale");
-  const float vel_scale = RNA_float_get(op->ptr, "vel_scale");
   const bool is_sequence = RNA_boolean_get(op->ptr, "is_sequence");
   const bool set_frame_range = RNA_boolean_get(op->ptr, "set_frame_range");
   const bool validate_meshes = RNA_boolean_get(op->ptr, "validate_meshes");
@@ -339,7 +336,6 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
   }
 
   struct USDImportParams params = {scale,
-                                   vel_scale,
                                    is_sequence,
                                    set_frame_range,
                                    sequence_len,
@@ -392,8 +388,6 @@ static void wm_usd_import_draw(bContext *UNUSED(C), wmOperator *op)
   uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);
   row = uiLayoutRow(box, false);
   uiItemR(row, ptr, "scale", 0, NULL, ICON_NONE);
-  row = uiLayoutRow(box, false);
-  uiItemR(row, ptr, "vel_scale", 0, NULL, ICON_NONE);
 
   box = uiLayoutBox(layout);
   row = uiLayoutRow(box, false);
@@ -490,15 +484,6 @@ void WM_OT_usd_import(struct wmOperatorType *ot)
       "Value by which to enlarge or shrink the objects with respect to the world's origin",
       0.0001f,
       1000.0f);
-  RNA_def_float(ot->srna,
-                "vel_scale",
-                1.0f,
-                0.0001f,
-                1000.0f,
-                "Velocity Scale",
-                "Amount to scale velocity",
-                0.0001f,
-                1000.0f);
 
   RNA_def_boolean(
       ot->srna,
diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc
index 50335f25f07..fc2779e1a4c 100644
--- a/source/blender/io/usd/intern/usd_capi.cc
+++ b/source/blender/io/usd/intern/usd_capi.cc
@@ -544,7 +544,6 @@ static void import_startjob(void *customdata, short *stop, short *do_update, flo
 
   data->archive = archive;
   data->settings.cache_file = cache_file;
-  data->settings.vel_scale = data->params.vel_scale;
 
   *data->do_update = true;
   *data->progress = 0.05f;
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 7ebfe3fa984..3d902126b74 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -430,114 +430,6 @@ void USDMeshReader::read_uvs(Mesh *mesh,
   }
 }
 
-void USDMeshReader::read_attributes(Mesh *mesh,
-                                    pxr::UsdGeomMesh mesh_prim_,
-                                    double motionSampleTime)
-{
-  CustomData *cd = &mesh->vdata;
-  std::vector<pxr::UsdGeomPrimvar> primvars = mesh_prim_.GetPrimvars();
-
-  for (pxr::UsdGeomPrimvar p : primvars) {
-    int cd_type = 0;
-    size_t num = 0;
-    size_t type_size = 0;
-    void *data;
-
-    if (!p.HasAuthoredValue())
-      continue;
-
-    if (!is_initial_load_ &&
-        primvar_varying_map_.find(p.GetPrimvarName()) == primvar_varying_map_.end())
-      continue;
-
-    const char *name = p.GetPrimvarName().GetString().c_str();
-    if (p.GetTypeName() == pxr::SdfValueTypeNames->TexCoord2hArray ||
-        p.GetTypeName() == pxr::SdfValueTypeNames->TexCoord2fArray ||
-        p.GetTypeName() == pxr::SdfValueTypeNames->TexCoord2dArray) {
-      continue;
-    }
-    else if (p.GetTypeName() == pxr::SdfValueTypeNames->Color3fArray ||
-             p.GetTypeName() == pxr::SdfValueTypeNames->Double3Array ||
-             p.GetTypeName() == pxr::SdfValueTypeNames->Float3Array) {
-      cd_type = CD_VALUE_F3;
-      pxr::VtVec3fArray idata;
-      p.Get<pxr::VtVec3fArray>(&idata, motionSampleTime);
-      num = idata.size();
-      type_size = sizeof(pxr::GfVec3f);
-      data = (void *)idata.cdata();
-    }
-    else if (p.GetTypeName() == pxr::SdfValueTypeNames->FloatArray ||
-             p.GetTypeName() == pxr::SdfValueTypeNames->DoubleArray) {
-      cd_type = CD_VALUE_FLOAT;
-      pxr::VtFloatArray idata;
-      p.Get<pxr::VtFloatArray>(&idata, motionSampleTime);
-      num = idata.size();
-      type_size = sizeof(float);
-      data = (void *)idata.cdata();
-    }
-    else if (p.GetTypeName() == pxr::SdfValueTypeNames->IntArray) {
-      cd_type = CD_VALUE_INT;
-      pxr::VtIntArray idata;
-      p.Get<pxr::VtIntArray>(&idata, motionSampleTime);
-      num = idata.size();
-      type_size = sizeof(int);
-      data = (void *)idata.cdata();
-    }
-    else if (p.GetTypeName() == pxr::SdfValueTypeNames->Int3Array) {
-      cd_type = CD_VALUE_I3;
-      pxr::VtVec3iArray idata;
-      p.Get<pxr::VtVec3iArray>(&idata, motionSampleTime);
-      num = idata.size();
-      type_size = sizeof(pxr::GfVec3i);
-      data = (void *)idata.cdata();
-    }
-    else {
-      continue;
-    }
-
-    void *cdata = CustomData_get_layer_named(cd, cd_type, name);
-
-    if (!cdata) {
-      cdata = CustomData_add_layer_named(cd, cd_type, CD_DEFAULT, NULL, num, name);
-    }
-
-    if (cdata) {
-      memcpy(cdata, data, num * type_size);
-    }
-    else {
-      std::cerr << "WARNING: Couldn't add custom data layer " << name << std::endl;
-    }
-  }
-}
-
-void USDMeshReader::read_vels(Mesh *mesh,
-                              pxr::UsdGeomMesh mesh_prim_,
-                              float vel_scale,
-                              double motionSampleTime)
-{
-  pxr::VtVec3fArray velocities;
-  pxr::UsdAttribute vel_attr = mesh_prim_.GetVelocitiesAttr();
-
-  if (!is_initial_load_ && !vel_attr.ValueMightBeTimeVarying())
-    return;
-
-  vel_attr.Get<pxr::VtVec3fArray>(&velocities, motionSampleTime);
-
-  if (velocities.size() <= 0)
-    return;
-
-  float(*vdata)[3] = (float(*)[3])CustomData_add_layer(
-      &mesh->vdata, CD_VELOCITY, CD_DEFAULT, NULL, mesh->totvert);
-
-  if (vdata) {
-    for (int i = 0; i < mesh->totvert; i++) {
-      vdata[i][0] = velocities[i][0] * vel_scale;
-      vdata[i][1] = velocities[i][1] * vel_scale;
-      vdata[i][2] = velocities[i][2] * vel_scale;
-    }
-  }
-}
-
 void USDMeshReader::read_colors(Mesh *mesh,
                                 const pxr::UsdGeomMesh &mesh_prim_,
                                 double motionSampleTime)
@@ -768,14 +660,6 @@ void USDMeshReader::read_mesh_sample(const std::string &iobject_full_name,
     read_uvs(mesh, mesh_prim_, motionSampleTime, new_mesh);
   }
 
-  if ((settings->read_flag & MOD_MESHSEQ_READ_ATTR) != 0) {
-    read_attributes(mesh, mesh_prim_, motionSampleTime);
-  }
-
-  if ((settings->read_flag & MOD_MESHSEQ_READ_VELS) != 0) {
-    read_vels(mesh, mesh_prim_, settings->vel_scale, motionSampleTime);
-  }
-
   if ((settings->read_flag & MOD_MESHSEQ_READ_COLOR) != 0) {
     read_colors(mesh, mesh_prim_, motionSampleTime);
   }
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.h b/source/blender/io/usd/intern/usd_reader_mesh.h
index ce2f5183437..751032d55af 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.h
+++ b/source/blender/io/usd/intern/usd_reader_mesh.h
@@ -79,8 +79,6 @@ class USDMeshReader : public USDGeomReader {
                 pxr::UsdGeomMesh mesh_prim_,
                 double motionSampleTime,
                 bool load_uvs = false);
-  void read_attributes(Mesh *mesh, pxr::UsdGeomMesh mesh_prim_, double motionSampleTime);
-  void read_vels(Mesh *mesh, pxr::UsdGeomMesh mesh_prim, float vel_scale, double motionSampleTime);
   void read_colors(Mesh *mesh, const pxr::UsdGeomMesh &mesh_prim, double motionSampleTime);
 
   void read_mesh_sample(const std::string &iobject_full_name,
diff --git a/source/blender/io/usd/usd.h b/source/blender/io/usd/usd.h
index 2cf62e7cbff..4dc26409097 100644
--- a/source/blender/io/usd/usd.h
+++ b/source/blender/io/usd/usd.h
@@ -46,7 +46,6 @@ struct USDExportParams {
 
 struct USDImportParams {
   float scale;
-  float vel_scale;
   bool is_sequence;
   bool set_frame_range;
   int sequence_len;



More information about the Bf-blender-cvs mailing list