Do not output material IDs at all if there's no material assigned
@@ -1944,6 +1944,7 @@ OutputGeometryPart::computeMaterial(
materialDataFn.setObject(materialObj);
}
+ bool are_all_the_same = true;
std::vector<int> materialIdsBuffer(myPartInfo.faceCount);
if(materialIdsBuffer.size())
{
@@ -1952,12 +1953,18 @@ OutputGeometryPart::computeMaterial(
CHECK_HAPI(HAPI_GetMaterialNodeIdsOnFaces(
Util::theHAPISession.get(),
myNodeId, myPartId,
- NULL,
+ &are_all_the_same,
&materialIdsBuffer[0],
0, materialIdsBuffer.size()
));
}
+ if(materialIdsBuffer.size()
+ && materialIdsBuffer[0] == -1 && are_all_the_same)
+ {
+ return;
+ }
+
MIntArray materialIds = materialDataFn.array();
Util::convertArray(materialIds, materialIdsBuffer);
}
