[Bf-blender-cvs] [649825b91b9] temp-sybren-usd-patch-02: USD: Fixed export of animated meshes
Sybren A. Stüvel
noreply at git.blender.org
Thu Dec 5 18:33:06 CET 2019
Commit: 649825b91b9eac451763247cd3be1ab186ebdcc0
Author: Sybren A. Stüvel
Date: Thu Dec 5 18:32:16 2019 +0100
Branches: temp-sybren-usd-patch-02
https://developer.blender.org/rB649825b91b9eac451763247cd3be1ab186ebdcc0
USD: Fixed export of animated meshes
I missed a bit earlier, when creating the mesh attributes with an explicit
default, causing meshes to be non-animated. Now I use the 'sparse value
writer', as recommended on the USD forum [1], and animated meshes are
properly written once again.
[1] https://groups.google.com/d/msg/usd-interest/cVJv_eDYxZo/oREDDm11AgAJ
===================================================================
M source/blender/usd/intern/usd_writer_abstract.cc
M source/blender/usd/intern/usd_writer_abstract.h
M source/blender/usd/intern/usd_writer_mesh.cc
===================================================================
diff --git a/source/blender/usd/intern/usd_writer_abstract.cc b/source/blender/usd/intern/usd_writer_abstract.cc
index 98c7784d404..ff8f3c83ed0 100644
--- a/source/blender/usd/intern/usd_writer_abstract.cc
+++ b/source/blender/usd/intern/usd_writer_abstract.cc
@@ -40,7 +40,10 @@ static const pxr::TfToken surface("surface", pxr::TfToken::Immortal);
}; // namespace usdtokens
USDAbstractWriter::USDAbstractWriter(const USDExporterContext &usd_export_context)
- : usd_export_context_(usd_export_context), frame_has_been_written_(false), is_animated_(false)
+ : usd_export_context_(usd_export_context),
+ usd_value_writer(),
+ frame_has_been_written_(false),
+ is_animated_(false)
{
}
diff --git a/source/blender/usd/intern/usd_writer_abstract.h b/source/blender/usd/intern/usd_writer_abstract.h
index 548c8cf9659..b48a69e4942 100644
--- a/source/blender/usd/intern/usd_writer_abstract.h
+++ b/source/blender/usd/intern/usd_writer_abstract.h
@@ -25,6 +25,7 @@
#include <pxr/usd/sdf/path.h>
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/usdShade/material.h>
+#include <pxr/usd/usdUtils/sparseValueWriter.h>
#include <vector>
@@ -40,6 +41,7 @@ struct Object;
class USDAbstractWriter : public AbstractHierarchyWriter {
protected:
const USDExporterContext usd_export_context_;
+ pxr::UsdUtilsSparseValueWriter usd_value_writer;
bool frame_has_been_written_;
bool is_animated_;
diff --git a/source/blender/usd/intern/usd_writer_mesh.cc b/source/blender/usd/intern/usd_writer_mesh.cc
index c0297371cb0..8150721eba6 100644
--- a/source/blender/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/usd/intern/usd_writer_mesh.cc
@@ -173,26 +173,27 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh)
return;
}
- /* Set the default value of the attributes to the first-time values. This will make the USD
- * library deduplicate values that we write on every frame but don't actually change. */
- pxr::UsdAttribute attr_points = usd_mesh.CreatePointsAttr(pxr::VtValue(usd_mesh_data.points),
- true);
- pxr::UsdAttribute attr_face_vertex_counts = usd_mesh.CreateFaceVertexCountsAttr(
- pxr::VtValue(usd_mesh_data.face_vertex_counts), true);
- pxr::UsdAttribute attr_face_vertex_indices = usd_mesh.CreateFaceVertexIndicesAttr(
- pxr::VtValue(usd_mesh_data.face_indices), true);
+ pxr::UsdAttribute attr_points = usd_mesh.CreatePointsAttr();
+ pxr::UsdAttribute attr_face_vertex_counts = usd_mesh.CreateFaceVertexCountsAttr();
+ pxr::UsdAttribute attr_face_vertex_indices = usd_mesh.CreateFaceVertexIndicesAttr();
+
+ usd_value_writer.SetAttribute(attr_points, pxr::VtValue(usd_mesh_data.points), timecode);
+ usd_value_writer.SetAttribute(
+ attr_face_vertex_counts, pxr::VtValue(usd_mesh_data.face_vertex_counts), timecode);
+ usd_value_writer.SetAttribute(
+ attr_face_vertex_indices, pxr::VtValue(usd_mesh_data.face_indices), timecode);
if (!usd_mesh_data.crease_lengths.empty()) {
- pxr::UsdAttribute attr_crease_lengths = usd_mesh.CreateCreaseLengthsAttr(
- pxr::VtValue(usd_mesh_data.crease_lengths), true);
- pxr::UsdAttribute attr_crease_indices = usd_mesh.CreateCreaseIndicesAttr(
- pxr::VtValue(usd_mesh_data.crease_vertex_indices), true);
- pxr::UsdAttribute attr_crease_sharpness = usd_mesh.CreateCreaseSharpnessesAttr(
- pxr::VtValue(usd_mesh_data.crease_sharpnesses), true);
-
- attr_crease_lengths.Set(usd_mesh_data.crease_lengths, timecode);
- attr_crease_indices.Set(usd_mesh_data.crease_vertex_indices, timecode);
- attr_crease_sharpness.Set(usd_mesh_data.crease_sharpnesses, timecode);
+ pxr::UsdAttribute attr_crease_lengths = usd_mesh.CreateCreaseLengthsAttr();
+ pxr::UsdAttribute attr_crease_indices = usd_mesh.CreateCreaseIndicesAttr();
+ pxr::UsdAttribute attr_crease_sharpness = usd_mesh.CreateCreaseSharpnessesAttr();
+
+ usd_value_writer.SetAttribute(
+ attr_crease_lengths, pxr::VtValue(usd_mesh_data.crease_lengths), timecode);
+ usd_value_writer.SetAttribute(
+ attr_crease_indices, pxr::VtValue(usd_mesh_data.crease_vertex_indices), timecode);
+ usd_value_writer.SetAttribute(
+ attr_crease_sharpness, pxr::VtValue(usd_mesh_data.crease_sharpnesses), timecode);
}
if (usd_export_context_.export_params.export_uvmaps) {
More information about the Bf-blender-cvs
mailing list