Skip to content

Commit

Permalink
Print connections in Print Fabric stage button
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Jul 12, 2023
1 parent f060e6b commit 824f691
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions src/core/src/FabricUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ std::string printAttributeValue(
}
}

std::string printConnection(const omni::fabric::Path& primPath, const omni::fabric::Token& attributeName) {
auto stageReaderWriter = UsdUtil::getFabricStageReaderWriter();
const auto connection = stageReaderWriter.getConnection(primPath, attributeName);
if (connection == nullptr) {
return NO_DATA_STRING;
}

const auto path = omni::fabric::Path(connection->path).getText();
const auto attrName = omni::fabric::Token(connection->attrName).getText();

return fmt::format("Path: {}, Attribute Name: {}", path, attrName);
}

std::string printAttributeValue(const omni::fabric::Path& primPath, const omni::fabric::AttrNameAndType& attribute) {
auto stageReaderWriter = UsdUtil::getFabricStageReaderWriter();

Expand All @@ -165,6 +178,17 @@ std::string printAttributeValue(const omni::fabric::Path& primPath, const omni::
}
break;
}
case omni::fabric::BaseDataType::eConnection: {
switch (componentCount) {
case 1: {
return printConnection(primPath, name);
}
default: {
break;
}
}
break;
}
case omni::fabric::BaseDataType::eToken: {
switch (componentCount) {
case 1: {
Expand Down Expand Up @@ -545,7 +569,7 @@ FabricStatistics getStatistics() {
statistics.geometriesCapacity += paths.size();

for (size_t i = 0; i < paths.size(); i++) {
if (tilesetIdFabric[i] == NO_TILESET_ID) {
if (tilesetIdFabric[i] == -1) {
continue;
}

Expand All @@ -571,7 +595,7 @@ FabricStatistics getStatistics() {
statistics.materialsCapacity += paths.size();

for (size_t i = 0; i < paths.size(); i++) {
if (tilesetIdFabric[i] == NO_TILESET_ID) {
if (tilesetIdFabric[i] == -1) {
continue;
}

Expand All @@ -590,20 +614,6 @@ void destroyPrim(const omni::fabric::Path& path) {

auto srw = UsdUtil::getFabricStageReaderWriter();
srw.destroyPrim(path);

// Prims removed from Fabric need special handling for their removal to be reflected in the Hydra render index
// This workaround may not be needed in future Kit versions, but is needed as of Kit 105.0
const omni::fabric::Path changeTrackingPath("/TempChangeTracking");

if (srw.getAttribute<uint64_t>(changeTrackingPath, FabricTokens::_deletedPrims) == nullptr) {
return;
}

const auto deletedPrimsSize = srw.getArrayAttributeSize(changeTrackingPath, FabricTokens::_deletedPrims);
srw.setArrayAttributeSize(changeTrackingPath, FabricTokens::_deletedPrims, deletedPrimsSize + 1);
auto deletedPrimsFabric = srw.getArrayAttributeWr<uint64_t>(changeTrackingPath, FabricTokens::_deletedPrims);

deletedPrimsFabric[deletedPrimsSize] = omni::fabric::PathC(path).path;
}

void setTilesetTransform(int64_t tilesetId, const glm::dmat4& ecefToUsdTransform) {
Expand Down

0 comments on commit 824f691

Please sign in to comment.