From 1444f64b38a8a422bebaca948aefcba8ee02ec33 Mon Sep 17 00:00:00 2001 From: rdeioris Date: Sun, 27 Oct 2024 12:55:42 +0100 Subject: [PATCH] added GPrim::get_displayColors and GPrim::get_displayColorsInterpolation --- src/usdGeom.cc | 30 ++++++++++++++++++++++++++++++ src/usdGeom.hh | 7 +++++++ 2 files changed, 37 insertions(+) diff --git a/src/usdGeom.cc b/src/usdGeom.cc index 7a220771..59846d87 100644 --- a/src/usdGeom.cc +++ b/src/usdGeom.cc @@ -796,6 +796,23 @@ const std::vector GeomMesh::get_normals( return dst; } +const std::vector GPrim::get_displayColors( + double time, value::TimeSampleInterpolationType interp) const { + std::vector dst; + + std::string err; + if (has_primvar("displayColor")) { + GeomPrimvar primvar; + if (!get_primvar("displayColor", &primvar, &err)) { + return dst; + } + + primvar.flatten_with_indices(time, &dst, interp); + } + + return dst; +} + Interpolation GeomMesh::get_normalsInterpolation() const { if (props.count("primvars:normals")) { const auto &prop = props.at("primvars:normals"); @@ -811,6 +828,19 @@ Interpolation GeomMesh::get_normalsInterpolation() const { return Interpolation::Vertex; // default 'vertex' } +Interpolation GPrim::get_displayColorsInterpolation() const { + if (props.count("primvars:displayColor")) { + const auto &prop = props.at("primvars:displayColor"); + if (prop.get_attribute().type_name() == "color3f[]") { + if (prop.get_attribute().metas().interpolation) { + return prop.get_attribute().metas().interpolation.value(); + } + } + } + + return Interpolation::Vertex; // default 'vertex' +} + const std::vector GeomMesh::get_faceVertexCounts(double time) const { std::vector dst; diff --git a/src/usdGeom.hh b/src/usdGeom.hh index 52c5cb11..2d510cfb 100644 --- a/src/usdGeom.hh +++ b/src/usdGeom.hh @@ -363,6 +363,13 @@ struct GPrim : Xformable, MaterialBinding, Collection { bool get_displayOpacity(float *opacity, const double t = value::TimeCode::Default(), const value::TimeSampleInterpolationType tinterp = value::TimeSampleInterpolationType::Linear) const; + const std::vector get_displayColors( + double time = value::TimeCode::Default(), + value::TimeSampleInterpolationType interp = + value::TimeSampleInterpolationType::Linear) const; + + Interpolation get_displayColorsInterpolation() const; + RelationshipProperty proxyPrim; #if 0