From 3522f622f38d7fe8f5bdb3e274583e31e3528a57 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Thu, 12 Aug 2021 18:37:59 -0700 Subject: [PATCH] more castings Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- Code/Editor/Objects/DisplayContextShared.inl | 7 +++++-- Code/Editor/editor_lib_files.cmake | 1 + .../Tests/EditorTransformComponentSelectionTests.cpp | 2 +- .../Prefab/Benchmark/PrefabCreateBenchmarks.cpp | 8 ++++---- .../Prefab/Benchmark/PrefabInstantiateBenchmarks.cpp | 2 +- .../Benchmark/PrefabUpdateInstancesBenchmarks.cpp | 10 +++++----- .../Prefab/Benchmark/SpawnableCreateBenchmarks.cpp | 2 +- .../Code/Source/Converters/FIR-Weights.cpp | 10 +++++----- .../Source/ActionHistory/ActionHistoryPlugin.cpp | 2 +- .../Source/AnimGraph/GameControllerWindow.cpp | 8 ++++---- .../Code/Tests/PythonDictionaryTests.cpp | 4 ++-- .../Code/Tests/SceneBuilder/SceneBuilderTests.cpp | 12 ++++++------ .../Editor/View/Windows/ScriptCanvasContextMenus.cpp | 2 +- 13 files changed, 37 insertions(+), 33 deletions(-) diff --git a/Code/Editor/Objects/DisplayContextShared.inl b/Code/Editor/Objects/DisplayContextShared.inl index a602d8eca9..5af04d821e 100644 --- a/Code/Editor/Objects/DisplayContextShared.inl +++ b/Code/Editor/Objects/DisplayContextShared.inl @@ -63,7 +63,7 @@ void DisplayContext::InternalDrawLine(const Vec3& v0, const ColorB& colV0, const ////////////////////////////////////////////////////////////////////////// void DisplayContext::DrawPoint(const Vec3& p, int nSize) { - pRenderAuxGeom->DrawPoint(ToWorldSpacePosition(p), m_color4b, nSize); + pRenderAuxGeom->DrawPoint(ToWorldSpacePosition(p), m_color4b, static_cast(nSize)); } ////////////////////////////////////////////////////////////////////////// @@ -856,7 +856,10 @@ void DisplayContext::DrawLine(const Vec3& p1, const Vec3& p2, const ColorF& col1 ////////////////////////////////////////////////////////////////////////// void DisplayContext::DrawLine(const Vec3& p1, const Vec3& p2, const QColor& rgb1, const QColor& rgb2) { - InternalDrawLine(ToWorldSpacePosition(p1), ColorB(rgb1.red(), rgb1.green(), rgb1.blue(), 255), ToWorldSpacePosition(p2), ColorB(rgb2.red(), rgb2.green(), rgb2.blue(), 255)); + InternalDrawLine(ToWorldSpacePosition(p1), + ColorB(static_cast(rgb1.red()), static_cast(rgb1.green()), static_cast(rgb1.blue()), 255), + ToWorldSpacePosition(p2), + ColorB(static_cast(rgb2.red()), static_cast(rgb2.green()), static_cast(rgb2.blue()), 255)); } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Editor/editor_lib_files.cmake b/Code/Editor/editor_lib_files.cmake index c10db3bac5..6c5096a8f5 100644 --- a/Code/Editor/editor_lib_files.cmake +++ b/Code/Editor/editor_lib_files.cmake @@ -503,6 +503,7 @@ set(FILES LogFileImpl.h Objects/ClassDesc.cpp Objects/ClassDesc.h + Objects/DisplayContextShared.inl Objects/IEntityObjectListener.h Objects/SelectionGroup.cpp Objects/SelectionGroup.h diff --git a/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp b/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp index 895c91b0a4..e95f7aa271 100644 --- a/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp @@ -583,7 +583,7 @@ namespace UnitTest AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus::EventResult( m_mouseInteractionResult, AzToolsFramework::GetEntityContextId(), &AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus::Events::InternalHandleAllMouseInteractions, - vi::MouseInteractionEvent(mouseInteraction, ev->angleDelta().y())); + vi::MouseInteractionEvent(mouseInteraction, static_cast(ev->angleDelta().y()))); } MouseInteractionResult m_mouseInteractionResult; diff --git a/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabCreateBenchmarks.cpp b/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabCreateBenchmarks.cpp index 12efea1cc8..64c4058a47 100644 --- a/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabCreateBenchmarks.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabCreateBenchmarks.cpp @@ -16,7 +16,7 @@ namespace Benchmark BENCHMARK_DEFINE_F(BM_PrefabCreate, CreatePrefabs_SingleEntityEach)(::benchmark::State& state) { - const unsigned int numEntities = state.range(); + const unsigned int numEntities = static_cast(state.range()); const unsigned int numInstances = numEntities; CreateFakePaths(numInstances); @@ -58,7 +58,7 @@ namespace Benchmark BENCHMARK_DEFINE_F(BM_PrefabCreate, CreatePrefab_FromEntities)(::benchmark::State& state) { - const unsigned int numEntities = state.range(); + const unsigned int numEntities = static_cast(state.range()); for (auto _ : state) { @@ -93,7 +93,7 @@ namespace Benchmark BENCHMARK_DEFINE_F(BM_PrefabCreate, CreatePrefab_FromSingleDepthInstances)(::benchmark::State& state) { - const unsigned int numInstancesToAdd = state.range(); + const unsigned int numInstancesToAdd = static_cast(state.range()); const unsigned int numEntities = numInstancesToAdd; // Create fake paths for all the nested instances @@ -144,7 +144,7 @@ namespace Benchmark BENCHMARK_DEFINE_F(BM_PrefabCreate, CreatePrefab_FromLinearNestingOfInstances)(::benchmark::State& state) { - const unsigned int numInstances = state.range(); + const unsigned int numInstances = static_cast(state.range()); // Create fake paths for all the nested instances // plus the root instance diff --git a/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabInstantiateBenchmarks.cpp b/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabInstantiateBenchmarks.cpp index 90ff30a30e..f2f3cf82b0 100644 --- a/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabInstantiateBenchmarks.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabInstantiateBenchmarks.cpp @@ -16,7 +16,7 @@ namespace Benchmark BENCHMARK_DEFINE_F(BM_PrefabInstantiate, InstantiatePrefab_SingleEntityInstance)(::benchmark::State& state) { - const unsigned int numInstances = state.range(); + const unsigned int numInstances = static_cast(state.range()); AZStd::unique_ptr firstInstance = m_prefabSystemComponent->CreatePrefab( { CreateEntity("Entity1") }, diff --git a/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabUpdateInstancesBenchmarks.cpp b/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabUpdateInstancesBenchmarks.cpp index f1e319b28a..0d95049e76 100644 --- a/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabUpdateInstancesBenchmarks.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabUpdateInstancesBenchmarks.cpp @@ -18,7 +18,7 @@ namespace Benchmark BENCHMARK_DEFINE_F(BM_PrefabUpdateInstances, UpdateInstances_SingeEntityInstances)(::benchmark::State& state) { - const unsigned int numInstances = state.range(); + const unsigned int numInstances = static_cast(state.range()); CreateFakePaths(2); const auto& nestedTemplatePath = m_paths.front(); @@ -80,7 +80,7 @@ namespace Benchmark BENCHMARK_DEFINE_F(BM_PrefabUpdateInstances, UpdateInstances_SingleLinearNestingOfInstances)(::benchmark::State& state) { - const unsigned int maxDepth = state.range(); + const unsigned int maxDepth = static_cast(state.range()); CreateFakePaths(maxDepth); const unsigned int numInstances = maxDepth; @@ -131,8 +131,8 @@ namespace Benchmark BENCHMARK_DEFINE_F(BM_PrefabUpdateInstances, UpdateInstances_MultipleLinearNestingOfInstances)(::benchmark::State& state) { - const unsigned int numRootInstances = state.range(); - const unsigned int maxDepth = state.range(); + const unsigned int numRootInstances = static_cast(state.range()); + const unsigned int maxDepth = static_cast(state.range()); CreateFakePaths(maxDepth); const unsigned int numInstances = numRootInstances * maxDepth; @@ -192,7 +192,7 @@ namespace Benchmark BENCHMARK_DEFINE_F(BM_PrefabUpdateInstances, UpdateInstances_BinaryTreeNestedInstanceHierarchy)(::benchmark::State& state) { - const unsigned int maxDepth = state.range(); + const unsigned int maxDepth = static_cast(state.range()); CreateFakePaths(maxDepth); const unsigned int numInstances = (1 << maxDepth) - 1; diff --git a/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/SpawnableCreateBenchmarks.cpp b/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/SpawnableCreateBenchmarks.cpp index 54e53a6ebc..d9024114a5 100644 --- a/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/SpawnableCreateBenchmarks.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/SpawnableCreateBenchmarks.cpp @@ -18,7 +18,7 @@ namespace Benchmark BENCHMARK_DEFINE_F(BM_SpawnableCreate, CreateSpawnable_SingleEntityInstance)(::benchmark::State& state) { - const unsigned int numSpawnables = state.range(); + const unsigned int numSpawnables = static_cast(state.range()); AZStd::unique_ptr instance(m_prefabSystemComponent->CreatePrefab( { CreateEntity("Entity1") }, diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Weights.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Weights.cpp index a7689a86ba..170805aa57 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Weights.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Weights.cpp @@ -17,7 +17,7 @@ namespace ImageProcessingAtom { float round(float x) { - return ((x) >= 0) ? floor((x) + 0.5) : ceil((x)-0.5); + return ((x) >= 0.f) ? floor((x) + 0.5f) : ceil((x) - 0.5f); } void calculateFilterRange(unsigned int srcFactor, int& srcFirst, int& srcLast, @@ -220,7 +220,7 @@ namespace ImageProcessingAtom /* normalize against the peak sumWeights, because the sums are not allowed to leave -32768/32767 */ fWeight = fWeight * nrmWeights; - iWeight = int(round(fWeight)); + iWeight = int(round(static_cast(fWeight))); /* find first nonzero */ if (stillzero && (iWeight == 0)) @@ -246,7 +246,7 @@ namespace ImageProcessingAtom /* add weight to table, interleaved sign */ for (n = 0; n < -numRepetitions; n++) { - *weightsPtr++ = sgnextend(n, -iWeight); + *weightsPtr++ = static_cast(sgnextend(n, -iWeight)); } } else @@ -254,7 +254,7 @@ namespace ImageProcessingAtom /* add weight to table */ for (n = 0; n < numRepetitions; n++) { - *weightsPtr++ = -iWeight; + *weightsPtr++ = static_cast(-iWeight); } } @@ -311,7 +311,7 @@ namespace ImageProcessingAtom for (n = 0, weightsPtr = weightsMem + (i - i0) * numRepetitions; n < numRepetitions; n++) { - *weightsPtr++ -= iWeight; + *weightsPtr++ -= static_cast(iWeight); } } } diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/ActionHistory/ActionHistoryPlugin.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/ActionHistory/ActionHistoryPlugin.cpp index d84bbebbc6..728ceb059b 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/ActionHistory/ActionHistoryPlugin.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/ActionHistory/ActionHistoryPlugin.cpp @@ -114,7 +114,7 @@ namespace EMStudio } // Set the current history index in case the user called undo. - m_list->setCurrentRow(commandManager->GetHistoryIndex()); + m_list->setCurrentRow(static_cast(commandManager->GetHistoryIndex())); } diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameControllerWindow.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameControllerWindow.cpp index c17ff12947..6434799773 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameControllerWindow.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameControllerWindow.cpp @@ -1176,7 +1176,7 @@ namespace EMStudio } else { - settingsInfo->m_axis = elementID; + settingsInfo->m_axis = static_cast(elementID); } } else @@ -1188,7 +1188,7 @@ namespace EMStudio } else { - settingsInfo->m_axis = value - 1; + settingsInfo->m_axis = static_cast(value - 1); } } #else @@ -1619,7 +1619,7 @@ namespace EMStudio const uint32 numButtons = m_gameController->GetNumButtons(); for (uint32 i = 0; i < numButtons; ++i) { - const bool isPressed = m_gameController->GetIsButtonPressed(i); + const bool isPressed = m_gameController->GetIsButtonPressed(static_cast(i)); // get the game controller settings info for the given button EMotionFX::AnimGraphGameControllerSettings::ButtonInfo* settingsInfo = activePreset->FindButtonInfo(i); @@ -1792,7 +1792,7 @@ namespace EMStudio m_string.clear(); for (uint32 i = 0; i < numButtons; ++i) { - if (m_gameController->GetIsButtonPressed(i)) + if (m_gameController->GetIsButtonPressed(static_cast(i))) { m_string += AZStd::string::format("%s%d ", (i < 10) ? "0" : "", i); } diff --git a/Gems/EditorPythonBindings/Code/Tests/PythonDictionaryTests.cpp b/Gems/EditorPythonBindings/Code/Tests/PythonDictionaryTests.cpp index 8f6abd5a17..24689bbfe3 100644 --- a/Gems/EditorPythonBindings/Code/Tests/PythonDictionaryTests.cpp +++ b/Gems/EditorPythonBindings/Code/Tests/PythonDictionaryTests.cpp @@ -52,8 +52,8 @@ namespace UnitTest } }; - MapOf m_indexOfu8tou32 { {1, 4}, {2, 5}, {3, 6}, {4, 7} }; - MapOf m_indexOfu16toFloat { {1, 0.4f}, {2, 0.5f}, {3, 0.6f}, {4, 0.7f} }; + MapOf m_indexOfu8tou32 { {AZ::u8(1), 4u}, {AZ::u8(2), 5u}, {AZ::u8(3), 6u}, {AZ::u8(4), 7u} }; + MapOf m_indexOfu16toFloat { {AZ::u16(1u), 0.4f}, {AZ::u16(2u), 0.5f}, {AZ::u16(3u), 0.6f}, {AZ::u16(4u), 0.7f} }; MapOf m_indexOfStringTos32 { {"1", -4}, {"2", 5}, {"3", -6}, {"4", 7} }; MapOf m_indexOfStringToString { {"hello", "foo"}, {"world", "bar"}, {"bye", "baz"}, {"sky", "qux"} }; MapOf m_indexOfStringToVec3{ {"up", AZ::Vector3{ 0, 1.0, 0 }}, {"down", AZ::Vector3{0, -1.0, 0}}, diff --git a/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderTests.cpp b/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderTests.cpp index 4d34725e36..46e14e6985 100644 --- a/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderTests.cpp +++ b/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderTests.cpp @@ -109,7 +109,7 @@ protected: TEST_F(SceneBuilderTests, SceneBuilderWorker_ExportProductDependencies_NoDependencies) { - SceneAPI::Events::ExportProduct exportProduct("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), 0, AZStd::nullopt); + SceneAPI::Events::ExportProduct exportProduct("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), u8(0), AZStd::nullopt); TestSuccessCaseNoDependencies(exportProduct); } @@ -122,7 +122,7 @@ TEST_F(SceneBuilderTests, SceneBuilderWorker_ExportProductDependencies_PathDepen #endif // AZ_TRAIT_OS_USE_WINDOWS_FILE_PATHS AssetBuilderSDK::ProductPathDependency expectedPathDependency(absolutePathToFile, AssetBuilderSDK::ProductPathDependencyType::SourceFile); - SceneAPI::Events::ExportProduct product("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), 0, AZStd::nullopt); + SceneAPI::Events::ExportProduct product("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), u8(0), AZStd::nullopt); product.m_legacyPathDependencies.push_back(absolutePathToFile); TestSuccessCase(product, &expectedPathDependency); @@ -134,7 +134,7 @@ TEST_F(SceneBuilderTests, SceneBuilderWorker_ExportProductDependencies_PathDepen AssetBuilderSDK::ProductPathDependency expectedPathDependency(relativeDependencyPathToFile, AssetBuilderSDK::ProductPathDependencyType::ProductFile); - SceneAPI::Events::ExportProduct product("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), 0, AZStd::nullopt); + SceneAPI::Events::ExportProduct product("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), u8(0), AZStd::nullopt); product.m_legacyPathDependencies.push_back(relativeDependencyPathToFile); TestSuccessCase(product, &expectedPathDependency); @@ -150,7 +150,7 @@ TEST_F(SceneBuilderTests, SceneBuilderWorker_ExportProductDependencies_PathDepen const char* absolutePathToFile = "/some/test/file.mtl"; #endif // AZ_TRAIT_OS_USE_WINDOWS_FILE_PATHS - SceneAPI::Events::ExportProduct exportProduct("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), 0, AZStd::nullopt); + SceneAPI::Events::ExportProduct exportProduct("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), u8(0), AZStd::nullopt); exportProduct.m_legacyPathDependencies.push_back(absolutePathToFile); exportProduct.m_legacyPathDependencies.push_back(relativeDependencyPathToFile); @@ -164,7 +164,7 @@ TEST_F(SceneBuilderTests, SceneBuilderWorker_ExportProductDependencies_PathDepen TEST_F(SceneBuilderTests, SceneBuilderWorker_ExportProductDependencies_ProductDependency) { AZ::Uuid dependencyId = AZ::Uuid::CreateRandom(); - SceneAPI::Events::ExportProduct exportProduct("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), 0, AZStd::nullopt); + SceneAPI::Events::ExportProduct exportProduct("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), u8(0), AZStd::nullopt); exportProduct.m_productDependencies.push_back(SceneAPI::Events::ExportProduct("testDependencyFile", dependencyId, AZ::Data::AssetType::CreateNull(), 0, AZStd::nullopt)); TestSuccessCase(exportProduct, nullptr, &dependencyId); @@ -173,7 +173,7 @@ TEST_F(SceneBuilderTests, SceneBuilderWorker_ExportProductDependencies_ProductDe TEST_F(SceneBuilderTests, SceneBuilderWorker_ExportProductDependencies_ProductAndPathDependencies) { AZ::Uuid dependencyId = AZ::Uuid::CreateRandom(); - SceneAPI::Events::ExportProduct exportProduct("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), 0, AZStd::nullopt); + SceneAPI::Events::ExportProduct exportProduct("testExportFile", AZ::Uuid::CreateRandom(), AZ::Data::AssetType::CreateNull(), u8(0), AZStd::nullopt); exportProduct.m_productDependencies.push_back(SceneAPI::Events::ExportProduct("testDependencyFile", dependencyId, AZ::Data::AssetType::CreateNull(), 0, AZStd::nullopt)); const char* relativeDependencyPathToFile = "some/test/file.mtl"; diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/ScriptCanvasContextMenus.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/ScriptCanvasContextMenus.cpp index b789c2e675..e4a95d7d19 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/ScriptCanvasContextMenus.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/ScriptCanvasContextMenus.cpp @@ -568,7 +568,7 @@ namespace ScriptCanvasEditor // Show the selection dialog bool createSlot = false; VariablePaletteRequests::SlotSetup selectedSlotSetup; - QPoint scenePoint(scenePos.GetX(), scenePos.GetY()); + QPoint scenePoint(static_cast(scenePos.GetX()), static_cast(scenePos.GetY())); VariablePaletteRequestBus::BroadcastResult(createSlot, &VariablePaletteRequests::ShowSlotTypeSelector, slot, scenePoint, selectedSlotSetup); bool changed = false;