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

EMSUSD-1719 units prefs during import #3956

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -371,7 +371,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