Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Releases the memory a data handle is holding onto when exporting meshes. #2882

Merged
merged 7 commits into from
Mar 2, 2023
4 changes: 2 additions & 2 deletions lib/mayaUsd/fileio/utils/meshWriteUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1408,8 +1408,8 @@ MStatus UsdMayaMeshWriteUtils::exportComponentTags(UsdGeomMesh& primSchema, MObj
MPlug outShp = depNodeFn.findPlug("outMesh", &status);
CHECK_MSTATUS_AND_RETURN_IT(status);

MDataHandle geomDataHandle = outShp.asMDataHandle();
MObject geomObj = geomDataHandle.data();
auto outShpHolder = UsdMayaUtil::GetPlugDataHandle(outShp);
MObject geomObj = outShpHolder->GetDataHandle().data();
if (geomObj.hasFn(MFn::kGeometryData)) {
TfToken componentTagFamilyName("componentTag");
MFnGeometryData fnGeomData(geomObj);
Expand Down
5 changes: 4 additions & 1 deletion lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <pxr/usdImaging/usdImaging/delegate.h>

#ifdef MAYA_HAS_DISPLAY_LAYER_API
#include <mayaUsd/utils/util.h>

#include <maya/MFnDisplayLayer.h>
#include <maya/MFnDisplayLayerManager.h>
#include <maya/MObjectArray.h>
Expand Down Expand Up @@ -697,7 +699,8 @@ void MayaUsdRPrim::_ProcessDisplayLayerModes(
}

if (useRGBColors.asBool()) {
const float3& rgbColor = colorRGB.asMDataHandle().asFloat3();
auto colorRGBHolder = UsdMayaUtil::GetPlugDataHandle(colorRGB);
const float3& rgbColor = colorRGBHolder->GetDataHandle().asFloat3();
displayLayerModes._wireframeColorIndex = -1;
displayLayerModes._wireframeColorRGBA
= MColor(rgbColor[0], rgbColor[1], rgbColor[2], colorA.asFloat());
Expand Down
6 changes: 4 additions & 2 deletions lib/usd/translators/meshWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,11 @@ bool PxrUsdTranslators_MeshWriter::writeMeshAttrs(
MPlug plgBlendShapeInput = plgBlendShapeInputs.elementByLogicalIndex(idxGeo);
MPlug plgBlendShapeInputGeometry
= UsdMayaUtil::FindChildPlugWithName(plgBlendShapeInput, "inputGeometry");
auto plgBlendShapeInputGeometryHolder
= UsdMayaUtil::GetPlugDataHandle(plgBlendShapeInputGeometry);
MDataHandle dhInputGeo
= plgBlendShapeInputGeometry
.asMDataHandle(); // NOTE: (yliangsiew) This should be the pref mesh.
= plgBlendShapeInputGeometryHolder->GetDataHandle(); // NOTE: (yliangsiew) This
// should be the pref mesh.
TF_VERIFY(dhInputGeo.type() == MFnData::kMesh);
MObject inputGeo = dhInputGeo.asMesh();
TF_VERIFY(inputGeo.hasFn(MFn::kMesh));
Expand Down