Skip to content

Commit 2037159

Browse files
authored
Merge pull request #3956 from Autodesk/bailp/EMSUSD-1719/import-units-prefs
EMSUSD-1719 units prefs during import
2 parents 5db48a5 + 44bf4cf commit 2037159

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/mayaUsd/fileio/jobs/readJob.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,13 @@ void UsdMaya_ReadJob::_ConvertUpAxisAndUnits(const UsdStageRefPtr& stage)
495495

496496
// Convert units if required and different between Maya and USD.
497497
const bool convertUnits = mArgs.unit;
498-
conversion.mayaMetersPerUnit
499-
= UsdMayaUtil::ConvertMDistanceUnitToUsdGeomLinearUnit(MDistance::internalUnit());
498+
// Note: when changing preference, we need to compare to the UI units.
499+
// When adding scaling transforms, we need to compare to internal units.
500+
const MDistance::Unit mayaUnits
501+
= (mArgs.axisAndUnitMethod == UsdMayaJobImportArgsTokens->overwritePrefs)
502+
? MDistance::uiUnit()
503+
: MDistance::internalUnit();
504+
conversion.mayaMetersPerUnit = UsdMayaUtil::ConvertMDistanceUnitToUsdGeomLinearUnit(mayaUnits);
500505
conversion.usdMetersPerUnit = UsdGeomGetStageMetersPerUnit(stage);
501506
conversion.needUnitsConversion
502507
= (convertUnits && (conversion.mayaMetersPerUnit != conversion.usdMetersPerUnit));

lib/mayaUsd/utils/utilSerialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void setLayerUpAxisAndUnits(const SdfLayerRefPtr& layer)
375375
= UsdMayaUtil::ConvertMDistanceUnitToUsdGeomLinearUnit(MDistance::internalUnit());
376376

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

0 commit comments

Comments
 (0)