[Bf-blender-cvs] [d324407cb87] usd-importer-T81257-merge: USD Import: support animating display color.

makowalski noreply at git.blender.org
Sun May 9 22:59:18 CEST 2021


Commit: d324407cb8732aaab9a7e7718dfddf1567db610b
Author: makowalski
Date:   Sat May 8 23:11:41 2021 -0400
Branches: usd-importer-T81257-merge
https://developer.blender.org/rBd324407cb8732aaab9a7e7718dfddf1567db610b

USD Import: support animating display color.

Added missing functionality in the mesh color import logic
to support animating display color.

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

M	source/blender/io/usd/intern/usd_reader_mesh.cc

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

diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index da9fa184495..a8ac4de8100 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -441,12 +441,18 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo
   }
 }
 
-void USDMeshReader::read_colors(Mesh *mesh, const double /* motionSampleTime */)
+void USDMeshReader::read_colors(Mesh *mesh, const double motionSampleTime)
 {
   if (!(mesh && mesh_prim_ && mesh->totloop > 0)) {
     return;
   }
 
+  /* Early out if we read the display color before and if this attribute isn't animated. */
+  if (primvar_varying_map_.find(usdtokens::displayColor) != primvar_varying_map_.end() &&
+      !primvar_varying_map_.at(usdtokens::displayColor)) {
+    return;
+  }
+
   pxr::UsdGeomPrimvar color_primvar = mesh_prim_.GetDisplayColorPrimvar();
 
   if (!color_primvar.HasValue()) {
@@ -460,9 +466,17 @@ void USDMeshReader::read_colors(Mesh *mesh, const double /* motionSampleTime */)
     return;
   }
 
+  if (primvar_varying_map_.find(usdtokens::displayColor) == primvar_varying_map_.end()) {
+    bool might_be_time_varying = color_primvar.ValueMightBeTimeVarying();
+    primvar_varying_map_.insert(std::make_pair(usdtokens::displayColor, might_be_time_varying));
+    if (might_be_time_varying) {
+      is_time_varying_ = true;
+    }
+  }
+
   pxr::VtArray<pxr::GfVec3f> display_colors;
 
-  if (!color_primvar.ComputeFlattened(&display_colors)) {
+  if (!color_primvar.ComputeFlattened(&display_colors, motionSampleTime)) {
     std::cerr << "WARNING: Couldn't compute display colors\n" << std::endl;
     return;
   }



More information about the Bf-blender-cvs mailing list