diff --git a/examples/api_tutorial/api-tutorial-main.cc b/examples/api_tutorial/api-tutorial-main.cc index f85b1c15..8efe5253 100644 --- a/examples/api_tutorial/api-tutorial-main.cc +++ b/examples/api_tutorial/api-tutorial-main.cc @@ -116,7 +116,7 @@ void CreateScene(tinyusdz::Stage *stage) { tinyusdz::value::matrix4d transform = a0 * b0; - op.set_value(transform); + op.set_value(std::move(transform)); // `xformOpOrder`(token[]) is represented as std::vector xform.xformOps.push_back(op); @@ -130,7 +130,7 @@ void CreateScene(tinyusdz::Stage *stage) { translate[0] = 1.0; translate[1] = 2.0; translate[2] = 3.0; - op.set_value(translate); + op.set_value(std::move(translate)); // `xformOpOrder`(token[]) is represented as std::vector xform.xformOps.push_back(op); @@ -172,7 +172,7 @@ void CreateScene(tinyusdz::Stage *stage) { pts.push_back({1.0f, 1.0f, 0.0f}); pts.push_back({0.0f, 1.0f, 0.0f}); - mesh.points.set_value(pts); + mesh.points.set_value(std::move(pts)); } { @@ -181,7 +181,7 @@ void CreateScene(tinyusdz::Stage *stage) { std::vector counts; counts.push_back(3); counts.push_back(3); - mesh.faceVertexCounts.set_value(counts); + mesh.faceVertexCounts.set_value(std::move(counts)); indices.push_back(0); indices.push_back(1); @@ -191,7 +191,7 @@ void CreateScene(tinyusdz::Stage *stage) { indices.push_back(2); indices.push_back(3); - mesh.faceVertexIndices.set_value(indices); + mesh.faceVertexIndices.set_value(std::move(indices)); } // primvar and custom attribute can be added to generic Property container @@ -212,7 +212,7 @@ void CreateScene(tinyusdz::Stage *stage) { uvs.push_back({0.0f, 1.0f}); // Fast path. Set the value directly to Attribute. - uvAttr.set_value(uvs); + uvAttr.set_value(std::move(uvs)); // or we can first build primvar::PrimVar // tinyusdz::primvar::PrimVar uvVar; @@ -240,7 +240,7 @@ void CreateScene(tinyusdz::Stage *stage) { uvIndices.push_back(2); tinyusdz::primvar::PrimVar uvIndexVar; - uvIndexVar.set_value(uvIndices); + uvIndexVar.set_value(std::move(uvIndices)); uvIndexAttr.set_var(std::move(uvIndexVar)); // Or you can use this approach(if you want to keep a copy of PrimVar // data) @@ -280,7 +280,7 @@ void CreateScene(tinyusdz::Stage *stage) { uvs.push_back({1.0f, 1.0f}); uvs.push_back({0.0f, 1.0f}); - uvPrimvar.set_value(uvs); // value at 'default' time + uvPrimvar.set_value(std::move(uvs)); // value at 'default' time uvPrimvar.set_interpolation(tinyusdz::Interpolation::Vertex); std::vector uvIndices; @@ -407,7 +407,7 @@ void CreateScene(tinyusdz::Stage *stage) { redVariant.metas().comment = "red color"; tinyusdz::value::color3f redColor({1.0f, 0.0f, 0.0f}); tinyusdz::Attribute redColorAttr; - redColorAttr.set_value(redColor); + redColorAttr.set_value(std::move(redColor)); redVariant.properties().emplace("mycolor", redColorAttr); // TODO: Add example to add childPrims under Variant // redVariant.primChildren().emplace(...) @@ -416,7 +416,7 @@ void CreateScene(tinyusdz::Stage *stage) { greenVariant.metas().comment = "green color"; tinyusdz::value::color3f greenColor({0.0f, 1.0f, 0.0f}); tinyusdz::Attribute greenColorAttr; - greenColorAttr.set_value(greenColor); + greenColorAttr.set_value(std::move(greenColor)); greenVariant.properties().emplace("mycolor", greenColorAttr); variantSet.name = "red"; diff --git a/examples/file_format/file-format-example.cc b/examples/file_format/file-format-example.cc index a5b04da5..c19b320f 100644 --- a/examples/file_format/file-format-example.cc +++ b/examples/file_format/file-format-example.cc @@ -158,7 +158,7 @@ static bool MyRead(const tinyusdz::Asset &asset, memcpy(&val, asset.data(), 4); tinyusdz::Attribute attr; - attr.set_value(val); + attr.set_value(std::move(val)); attr.set_name("myval"); attr.variability() = tinyusdz::Variability::Uniform; diff --git a/examples/save_usda/main.cc b/examples/save_usda/main.cc index b48d8dad..4d76bf2b 100644 --- a/examples/save_usda/main.cc +++ b/examples/save_usda/main.cc @@ -24,7 +24,7 @@ void SimpleScene(tinyusdz::Stage *stage) translate[0] = 1.0; translate[1] = 2.0; translate[2] = 3.0; - op.set_value(translate); + op.set_value(std::move(translate)); xform.xformOps.push_back(op); @@ -41,7 +41,7 @@ void SimpleScene(tinyusdz::Stage *stage) pts.push_back({0.0f, 1.0f, 0.0f}); - mesh.points.set_value(pts); + mesh.points.set_value(std::move(pts)); } { @@ -50,7 +50,7 @@ void SimpleScene(tinyusdz::Stage *stage) std::vector counts; counts.push_back(3); counts.push_back(3); - mesh.faceVertexCounts.set_value(counts); + mesh.faceVertexCounts.set_value(std::move(counts)); indices.push_back(0); indices.push_back(1); @@ -60,7 +60,7 @@ void SimpleScene(tinyusdz::Stage *stage) indices.push_back(2); indices.push_back(3); - mesh.faceVertexIndices.set_value(indices); + mesh.faceVertexIndices.set_value(std::move(indices)); } // primvar and custom attribute can be added to generic Property container `props` @@ -80,7 +80,7 @@ void SimpleScene(tinyusdz::Stage *stage) uvs.push_back({0.0f, 1.0f}); // Fast path. Set the value directly to Attribute. - uvAttr.set_value(uvs); + uvAttr.set_value(std::move(uvs)); // or we can first build primvar::PrimVar //tinyusdz::primvar::PrimVar uvVar; @@ -109,7 +109,7 @@ void SimpleScene(tinyusdz::Stage *stage) tinyusdz::primvar::PrimVar uvIndexVar; - uvIndexVar.set_value(uvIndices); + uvIndexVar.set_value(std::move(uvIndices)); uvIndexAttr.set_var(std::move(uvIndexVar)); tinyusdz::Property uvIndexProp(uvIndexAttr, /* custom*/false); diff --git a/tests/unit/unit-primvar.cc b/tests/unit/unit-primvar.cc index ee9c2cb2..ffe3a53d 100644 --- a/tests/unit/unit-primvar.cc +++ b/tests/unit/unit-primvar.cc @@ -20,7 +20,7 @@ void primvar_test(void) { tinyusdz::GeomMesh mesh; std::vector scalar_array = {1.0, 2.0, 3.0, 4.0}; tinyusdz::Attribute attr; - attr.set_value(scalar_array); + attr.set_value(std::move(scalar_array)); tinyusdz::Property prop(attr, /* custom */false); mesh.props.emplace("primvars:myvar", prop);