Browse Source

Enable clang-tidy in Visual Studio projects (#3101)

pull/3070/head
Andrew James 4 years ago committed by GitHub
parent
commit
949206424e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CMakeLists.txt
  2. 18
      CMakeSettings.json
  3. 16
      Source/engine/animationinfo.cpp

2
CMakeLists.txt

@ -1064,7 +1064,7 @@ if(VITA)
${VITA_TRANSLATIONS_LIST}
)
endif()
endif()
if(NINTENDO_3DS)

18
CMakeSettings.json

@ -7,7 +7,8 @@
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"inheritEnvironments": [ "msvc_x64" ],
"intelliSenseMode": "windows-msvc-x64"
"intelliSenseMode": "windows-msvc-x64",
"enableClangTidyCodeAnalysis": true
},
{
"name": "x64-Debug-UnitTests",
@ -17,7 +18,8 @@
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"inheritEnvironments": [ "msvc_x64" ],
"intelliSenseMode": "windows-msvc-x64",
"cmakeCommandArgs": "-DRUN_TESTS=ON"
"cmakeCommandArgs": "-DRUN_TESTS=ON",
"enableClangTidyCodeAnalysis": true
},
{
"name": "x64-Release",
@ -27,7 +29,8 @@
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "-DBINARY_RELEASE=ON",
"inheritEnvironments": [ "msvc_x64" ],
"intelliSenseMode": "windows-msvc-x64"
"intelliSenseMode": "windows-msvc-x64",
"enableClangTidyCodeAnalysis": true
},
{
"name": "x86-Debug",
@ -36,7 +39,8 @@
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"inheritEnvironments": [ "msvc_x86" ],
"intelliSenseMode": "windows-msvc-x86"
"intelliSenseMode": "windows-msvc-x86",
"enableClangTidyCodeAnalysis": true
},
{
"name": "x86-Debug-UnitTests",
@ -46,7 +50,8 @@
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"inheritEnvironments": [ "msvc_x86" ],
"intelliSenseMode": "windows-msvc-x86",
"cmakeCommandArgs": "-DRUN_TESTS=ON"
"cmakeCommandArgs": "-DRUN_TESTS=ON",
"enableClangTidyCodeAnalysis": true
},
{
"name": "x86-Release",
@ -56,7 +61,8 @@
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "-DBINARY_RELEASE=ON",
"inheritEnvironments": [ "msvc_x86" ],
"intelliSenseMode": "windows-msvc-x86"
"intelliSenseMode": "windows-msvc-x86",
"enableClangTidyCodeAnalysis": true
}
]
}

16
Source/engine/animationinfo.cpp

@ -24,7 +24,7 @@ int AnimationInfo::GetFrameToUseForRendering() const
if (CurrentFrame > RelevantFramesForDistributing)
return CurrentFrame;
auto ticksSinceSequenceStarted = (float)TicksSinceSequenceStarted;
float ticksSinceSequenceStarted = static_cast<float>(TicksSinceSequenceStarted);
if (TicksSinceSequenceStarted < 0) {
ticksSinceSequenceStarted = 0.0F;
Log("GetFrameToUseForRendering: Invalid TicksSinceSequenceStarted {}", TicksSinceSequenceStarted);
@ -34,7 +34,7 @@ int AnimationInfo::GetFrameToUseForRendering() const
float totalTicksForCurrentAnimationSequence = GetProgressToNextGameTick() + ticksSinceSequenceStarted;
// 1 added for rounding reasons. float to int cast always truncate.
int absoluteAnimationFrame = 1 + (int)(totalTicksForCurrentAnimationSequence * TickModifier);
int absoluteAnimationFrame = 1 + static_cast<int>(totalTicksForCurrentAnimationSequence * TickModifier);
if (SkippedFramesFromPreviousAnimation > 0) {
// absoluteAnimationFrames contains also the Frames from the previous Animation, so if we want to get the current Frame we have to remove them
absoluteAnimationFrame -= SkippedFramesFromPreviousAnimation;
@ -66,12 +66,12 @@ float AnimationInfo::GetAnimationProgress() const
// This logic is used if animation distribution is not active (see GetFrameToUseForRendering).
// In this case the variables calculated with animation distribution are not initialized and we have to calculate them on the fly with the given information.
ticksSinceSequenceStarted = ((CurrentFrame - 1) * TicksPerFrame) + TickCounterOfCurrentFrame;
tickModifier = 1.f / TicksPerFrame;
tickModifier = 1.0F / static_cast<float>(TicksPerFrame);
}
float totalTicksForCurrentAnimationSequence = GetProgressToNextGameTick() + ticksSinceSequenceStarted;
float totalTicksForCurrentAnimationSequence = GetProgressToNextGameTick() + static_cast<float>(ticksSinceSequenceStarted);
float progressInAnimationFrames = totalTicksForCurrentAnimationSequence * tickModifier;
float animationFraction = progressInAnimationFrames / NumberOfFrames;
float animationFraction = progressInAnimationFrames / static_cast<float>(NumberOfFrames);
return animationFraction;
}
@ -153,10 +153,10 @@ void AnimationInfo::SetNewAnimation(const CelSprite *celSprite, int numberOfFram
relevantAnimationTicksForDistribution += (SkippedFramesFromPreviousAnimation * ticksPerFrame);
// if we skipped Frames we need to expand the game ticks to make one game tick for this Animation "faster"
float tickModifier = (float)relevantAnimationTicksForDistribution / (float)relevantAnimationTicksWithSkipping;
float tickModifier = static_cast<float>(relevantAnimationTicksForDistribution) / static_cast<float>(relevantAnimationTicksWithSkipping);
// tickModifier specifies the Animation fraction per game tick, so we have to remove the delay from the variable
tickModifier /= ticksPerFrame;
tickModifier /= static_cast<float>(ticksPerFrame);
RelevantFramesForDistributing = relevantAnimationFramesForDistributing;
TickModifier = tickModifier;
@ -208,7 +208,7 @@ void AnimationInfo::ProcessAnimation(bool reverseAnimation /*= false*/, bool don
float AnimationInfo::GetProgressToNextGameTick() const
{
if (IsPetrified)
return 0.0;
return 0.0F;
return gfProgressToNextGameTick;
}

Loading…
Cancel
Save