diff --git a/lib/mayaUsd/fileio/jobs/readJob.cpp b/lib/mayaUsd/fileio/jobs/readJob.cpp index 5e30a97b21..170512ed45 100644 --- a/lib/mayaUsd/fileio/jobs/readJob.cpp +++ b/lib/mayaUsd/fileio/jobs/readJob.cpp @@ -512,7 +512,7 @@ double UsdMaya_ReadJob::timeSampleMultiplier() const { return mTimeSampleMultipl double UsdMaya_ReadJob::_setTimeSampleMultiplierFrom(const double layerFPS) { - float sceneFPS = UsdMayaUtil::GetSceneMTimeUnitAsFloat(); + double sceneFPS = UsdMayaUtil::GetSceneMTimeUnitAsDouble(); mTimeSampleMultiplier = sceneFPS / layerFPS; return mTimeSampleMultiplier; } diff --git a/lib/mayaUsd/fileio/jobs/writeJob.cpp b/lib/mayaUsd/fileio/jobs/writeJob.cpp index 01bc0f8d93..fccd5eb3f2 100644 --- a/lib/mayaUsd/fileio/jobs/writeJob.cpp +++ b/lib/mayaUsd/fileio/jobs/writeJob.cpp @@ -244,8 +244,8 @@ bool UsdMaya_WriteJob::_BeginWriting(const std::string& fileName, bool append) if (!mJobCtx.mArgs.timeSamples.empty()) { mJobCtx.mStage->SetStartTimeCode(mJobCtx.mArgs.timeSamples.front()); mJobCtx.mStage->SetEndTimeCode(mJobCtx.mArgs.timeSamples.back()); - mJobCtx.mStage->SetTimeCodesPerSecond(UsdMayaUtil::GetSceneMTimeUnitAsFloat()); - mJobCtx.mStage->SetFramesPerSecond(UsdMayaUtil::GetSceneMTimeUnitAsFloat()); + mJobCtx.mStage->SetTimeCodesPerSecond(UsdMayaUtil::GetSceneMTimeUnitAsDouble()); + mJobCtx.mStage->SetFramesPerSecond(UsdMayaUtil::GetSceneMTimeUnitAsDouble()); } // Setup the requested render layer mode: diff --git a/lib/mayaUsd/fileio/translators/translatorCurves.cpp b/lib/mayaUsd/fileio/translators/translatorCurves.cpp index abcee48ea5..88d0e710ff 100644 --- a/lib/mayaUsd/fileio/translators/translatorCurves.cpp +++ b/lib/mayaUsd/fileio/translators/translatorCurves.cpp @@ -243,8 +243,9 @@ bool UsdMayaTranslatorCurves::Create( // Construct the time array to be used for all the keys MTime::Unit timeUnit = MTime::uiUnit(); - double timeSampleMultiplier = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; - MTimeArray timeArray(numTimeSamples, MTime()); + double timeSampleMultiplier + = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; + MTimeArray timeArray(numTimeSamples, MTime()); for (unsigned int ti = 0; ti < numTimeSamples; ++ti) { timeArray.set(MTime(pointsTimeSamples[ti] * timeSampleMultiplier, timeUnit), ti); } diff --git a/lib/mayaUsd/fileio/translators/translatorMesh.cpp b/lib/mayaUsd/fileio/translators/translatorMesh.cpp index 602d3d47cf..1ded2dae4c 100644 --- a/lib/mayaUsd/fileio/translators/translatorMesh.cpp +++ b/lib/mayaUsd/fileio/translators/translatorMesh.cpp @@ -301,7 +301,7 @@ TranslatorMeshRead::TranslatorMeshRead( // Get the values needed to convert time to the current maya scenes framerate MTime::Unit timeUnit = MTime::uiUnit(); - double timeSampleMultiplier = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; + double timeSampleMultiplier = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; // Construct the time array to be used for all the keys MTimeArray timeArray; diff --git a/lib/mayaUsd/fileio/translators/translatorNurbsPatch.cpp b/lib/mayaUsd/fileio/translators/translatorNurbsPatch.cpp index d402aa7e6c..b5dffd3ab8 100644 --- a/lib/mayaUsd/fileio/translators/translatorNurbsPatch.cpp +++ b/lib/mayaUsd/fileio/translators/translatorNurbsPatch.cpp @@ -265,8 +265,9 @@ bool UsdMayaTranslatorNurbsPatch::Read( // Construct the time array to be used for all the keys MTime::Unit timeUnit = MTime::uiUnit(); - double timeSampleMultiplier = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; - MTimeArray timeArray; + double timeSampleMultiplier + = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; + MTimeArray timeArray; timeArray.setLength(numTimeSamples); for (unsigned int ti = 0; ti < numTimeSamples; ++ti) { timeArray.set(MTime(pointsTimeSamples[ti] * timeSampleMultiplier, timeUnit), ti); diff --git a/lib/mayaUsd/fileio/translators/translatorPrim.cpp b/lib/mayaUsd/fileio/translators/translatorPrim.cpp index 12f5fa1bd8..1a3dcf99b2 100644 --- a/lib/mayaUsd/fileio/translators/translatorPrim.cpp +++ b/lib/mayaUsd/fileio/translators/translatorPrim.cpp @@ -34,7 +34,7 @@ void UsdMayaTranslatorPrim::Read( { UsdGeomImageable primSchema(prim); MTime::Unit timeUnit = MTime::uiUnit(); - double timeSampleMultiplier = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; + double timeSampleMultiplier = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; if (!primSchema) { TF_CODING_ERROR("Prim %s is not UsdGeomImageable.", prim.GetPath().GetText()); return; diff --git a/lib/mayaUsd/fileio/translators/translatorSkel.cpp b/lib/mayaUsd/fileio/translators/translatorSkel.cpp index 3643c38343..9390b5b813 100644 --- a/lib/mayaUsd/fileio/translators/translatorSkel.cpp +++ b/lib/mayaUsd/fileio/translators/translatorSkel.cpp @@ -477,7 +477,7 @@ bool _CopyAnimFromSkel( MTimeArray mayaTimes; mayaTimes.setLength(usdTimes.size()); MTime::Unit timeUnit = MTime::uiUnit(); - double timeSampleMultiplier = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; + double timeSampleMultiplier = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; for (size_t i = 0; i < usdTimes.size(); ++i) { mayaTimes[i] = MTime(usdTimes[i] * timeSampleMultiplier, timeUnit); } diff --git a/lib/mayaUsd/fileio/translators/translatorXformable.cpp b/lib/mayaUsd/fileio/translators/translatorXformable.cpp index 8441dd8270..5485b89848 100644 --- a/lib/mayaUsd/fileio/translators/translatorXformable.cpp +++ b/lib/mayaUsd/fileio/translators/translatorXformable.cpp @@ -211,7 +211,7 @@ static bool _pushUSDXformOpToMayaXform( const UsdMayaPrimReaderContext* context) { MTime::Unit timeUnit = MTime::uiUnit(); - double timeSampleMultiplier = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; + double timeSampleMultiplier = (context != nullptr) ? context->GetTimeSampleMultiplier() : 1.0; std::vector xValue; std::vector yValue; diff --git a/lib/mayaUsd/utils/util.cpp b/lib/mayaUsd/utils/util.cpp index 7f03b8a9d0..92e488d76f 100644 --- a/lib/mayaUsd/utils/util.cpp +++ b/lib/mayaUsd/utils/util.cpp @@ -2079,171 +2079,171 @@ void UsdMayaUtil::GetFilteredSelectionToExport( } } -float UsdMayaUtil::ConvertMTimeUnitToFloat(const MTime::Unit& unit) +double UsdMayaUtil::ConvertMTimeUnitToDouble(const MTime::Unit& unit) { - float ret = 0.f; + double ret = 0.0; switch (unit) { case MTime::k2FPS: { - ret = 2.f; + ret = 2.0; } break; case MTime::k3FPS: { - ret = 3.f; + ret = 3.0; } break; case MTime::k4FPS: { - ret = 4.f; + ret = 4.0; } break; case MTime::k5FPS: { - ret = 5.f; + ret = 5.0; } break; case MTime::k6FPS: { - ret = 6.f; + ret = 6.0; } break; case MTime::k8FPS: { - ret = 8.f; + ret = 8.0; } break; case MTime::k10FPS: { - ret = 10.f; + ret = 10.0; } break; case MTime::k12FPS: { - ret = 12.f; + ret = 12.0; } break; case MTime::k15FPS: { - ret = 15.f; + ret = 15.0; } break; case MTime::k16FPS: { - ret = 16.f; + ret = 16.0; } break; case MTime::k20FPS: { - ret = 20.f; + ret = 20.0; } break; case MTime::k23_976FPS: { - ret = 23.976f; + ret = (24.0 * 1000.0) / 1001.0; } break; case MTime::k24FPS: { - ret = 24.f; + ret = 24.0; } break; case MTime::k25FPS: { - ret = 25.f; + ret = 25.0; } break; case MTime::k29_97FPS: { - ret = 29.97f; + ret = (30.0 * 1000.0) / 1001.0; } break; case MTime::k29_97DF: { - ret = 29.97f; + ret = (30.0 * 1000.0) / 1001.0; } break; case MTime::k30FPS: { - ret = 30.f; + ret = 30.0; } break; case MTime::k40FPS: { - ret = 40.f; + ret = 40.0; } break; case MTime::k47_952FPS: { - ret = 47.952f; + ret = (48.0 * 1000.0) / 1001.0; } break; case MTime::k48FPS: { - ret = 48.f; + ret = 48.0; } break; case MTime::k50FPS: { - ret = 50.f; + ret = 50.0; } break; case MTime::k59_94FPS: { - ret = 59.94f; + ret = (60.0 * 1000.0) / 100; } break; case MTime::k60FPS: { - ret = 60.f; + ret = 60.0; } break; case MTime::k75FPS: { - ret = 75.f; + ret = 75.0; } break; case MTime::k80FPS: { - ret = 80.f; + ret = 80.0; } break; #if MAYA_API_VERSION >= 20200000 case MTime::k90FPS: { - ret = 90.f; + ret = 90.0; } break; #endif case MTime::k100FPS: { - ret = 100.f; + ret = 100.0; } break; case MTime::k120FPS: { - ret = 120.f; + ret = 120.0; } break; case MTime::k125FPS: { - ret = 125.f; + ret = 125.0; } break; case MTime::k150FPS: { - ret = 150.f; + ret = 150.0; } break; case MTime::k200FPS: { - ret = 200.f; + ret = 200.0; } break; case MTime::k240FPS: { - ret = 240.f; + ret = 240.0; } break; case MTime::k250FPS: { - ret = 250.f; + ret = 250.0; } break; case MTime::k300FPS: { - ret = 300.f; + ret = 300.0; } break; case MTime::k375FPS: { - ret = 375.f; + ret = 375.0; } break; case MTime::k400FPS: { - ret = 400.f; + ret = 400.0; } break; case MTime::k500FPS: { - ret = 500.f; + ret = 500.0; } break; case MTime::k600FPS: { - ret = 600.f; + ret = 600.0; } break; case MTime::k750FPS: { - ret = 750.f; + ret = 750.0; } break; case MTime::k1200FPS: { - ret = 1200.f; + ret = 1200.0; } break; case MTime::k1500FPS: { - ret = 1500.f; + ret = 1500.0; } break; case MTime::k2000FPS: { - ret = 2000.f; + ret = 2000.0; } break; case MTime::k3000FPS: { - ret = 3000.f; + ret = 3000.0; } break; case MTime::k6000FPS: { - ret = 6000.f; + ret = 6000.0; } break; case MTime::k44100FPS: { - ret = 44100.f; + ret = 44100.0; } break; case MTime::k48000FPS: { - ret = 48000.f; + ret = 48000.0; } break; case MTime::kHours: { - ret = (1.f / 3600.f); + ret = (1.0 / 3600.0); } break; case MTime::kMinutes: { - ret = (1.f / 60.f); + ret = (1.0 / 60.0); } break; case MTime::kSeconds: { - ret = 1.0f; + ret = 1.0; } break; case MTime::kMilliseconds: { - ret = 1000.f; + ret = 1000.0; } break; default: { - ret = 0.0f; + ret = 0.0; } break; } return ret; } -float UsdMayaUtil::GetSceneMTimeUnitAsFloat() +double UsdMayaUtil::GetSceneMTimeUnitAsDouble() { const MTime::Unit sceneUnit = MTime::uiUnit(); - return UsdMayaUtil::ConvertMTimeUnitToFloat(sceneUnit); + return UsdMayaUtil::ConvertMTimeUnitToDouble(sceneUnit); } diff --git a/lib/mayaUsd/utils/util.h b/lib/mayaUsd/utils/util.h index 444e9c5d9e..bbcdaa1cca 100644 --- a/lib/mayaUsd/utils/util.h +++ b/lib/mayaUsd/utils/util.h @@ -570,15 +570,15 @@ void GetFilteredSelectionToExport( MSelectionList& objectList, UsdMayaUtil::MDagPathSet& dagPaths); -/// Coverts a given \pMTime::\pUnit enum to a \pfloat value of samples per second -/// Returns 0.0f if the result is invalid. +/// Coverts a given \pMTime::\pUnit enum to a \pdouble value of samples per second +/// Returns 0.0 if the result is invalid. MAYAUSD_CORE_PUBLIC -float ConvertMTimeUnitToFloat(const MTime::Unit& unit); +double ConvertMTimeUnitToDouble(const MTime::Unit& unit); -/// Get's the scene's \pMTime::\pUnit as a \pfloat value of samples per second -/// Returns 0.0f if the result is invalid. +/// Get's the scene's \pMTime::\pUnit as a \pdouble value of samples per second +/// Returns 0.0 if the result is invalid. MAYAUSD_CORE_PUBLIC -float GetSceneMTimeUnitAsFloat(); +double GetSceneMTimeUnitAsDouble(); } // namespace UsdMayaUtil diff --git a/test/lib/usd/translators/testUsdExportLayerAttributes.py b/test/lib/usd/translators/testUsdExportLayerAttributes.py index 7b72473d1c..c8e45e6dae 100644 --- a/test/lib/usd/translators/testUsdExportLayerAttributes.py +++ b/test/lib/usd/translators/testUsdExportLayerAttributes.py @@ -36,7 +36,7 @@ def setUpClass(cls): def tearDownClass(cls): standalone.uninitialize() - def test_fps_30(self): + def test_fps(self): fps_map = { "ntsc": 30, "game": 15,