Skip to content

Commit

Permalink
Merge pull request #3956 from Autodesk/bailp/EMSUSD-1719/import-units…
Browse files Browse the repository at this point in the history
…-prefs

EMSUSD-1719 units prefs during import
  • Loading branch information
seando-adsk authored Oct 21, 2024
2 parents 5db48a5 + 44bf4cf commit 2037159
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/mayaUsd/fileio/jobs/readJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,13 @@ void UsdMaya_ReadJob::_ConvertUpAxisAndUnits(const UsdStageRefPtr& stage)

// Convert units if required and different between Maya and USD.
const bool convertUnits = mArgs.unit;
conversion.mayaMetersPerUnit
= UsdMayaUtil::ConvertMDistanceUnitToUsdGeomLinearUnit(MDistance::internalUnit());
// Note: when changing preference, we need to compare to the UI units.
// When adding scaling transforms, we need to compare to internal units.
const MDistance::Unit mayaUnits
= (mArgs.axisAndUnitMethod == UsdMayaJobImportArgsTokens->overwritePrefs)
? MDistance::uiUnit()
: MDistance::internalUnit();
conversion.mayaMetersPerUnit = UsdMayaUtil::ConvertMDistanceUnitToUsdGeomLinearUnit(mayaUnits);
conversion.usdMetersPerUnit = UsdGeomGetStageMetersPerUnit(stage);
conversion.needUnitsConversion
= (convertUnits && (conversion.mayaMetersPerUnit != conversion.usdMetersPerUnit));
Expand Down
2 changes: 1 addition & 1 deletion lib/mayaUsd/utils/utilSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void setLayerUpAxisAndUnits(const SdfLayerRefPtr& layer)
= UsdMayaUtil::ConvertMDistanceUnitToUsdGeomLinearUnit(MDistance::internalUnit());

// Note: code similar to what UsdGeomSetStageUpAxis -> UsdStage::SetMetadata end-up doing,
// but without having to have a stage. We basically set metadat on the virtual root object
// but without having to have a stage. We basically set metadata on the virtual root object
// of the layer.
layer->SetField(
PXR_NS::SdfPath::AbsoluteRootPath(), PXR_NS::UsdGeomTokens->metersPerUnit, metersPerUnit);
Expand Down

0 comments on commit 2037159

Please sign in to comment.