Skip to content

Commit

Permalink
Merge pull request #202 from rdeioris/gprim_displayColors
Browse files Browse the repository at this point in the history
added GPrim::get_displayColors and GPrim::get_displayColorsInterpolation
  • Loading branch information
syoyo authored Oct 27, 2024
2 parents 3fb00d1 + 1444f64 commit 69b6e5a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/usdGeom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,23 @@ const std::vector<value::normal3f> GeomMesh::get_normals(
return dst;
}

const std::vector<value::color3f> GPrim::get_displayColors(
double time, value::TimeSampleInterpolationType interp) const {
std::vector<value::color3f> 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");
Expand All @@ -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<int32_t> GeomMesh::get_faceVertexCounts(double time) const {
std::vector<int32_t> dst;

Expand Down
7 changes: 7 additions & 0 deletions src/usdGeom.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<value::color3f> get_displayColors(
double time = value::TimeCode::Default(),
value::TimeSampleInterpolationType interp =
value::TimeSampleInterpolationType::Linear) const;

Interpolation get_displayColorsInterpolation() const;

RelationshipProperty proxyPrim;

#if 0
Expand Down

0 comments on commit 69b6e5a

Please sign in to comment.