Skip to content

Commit

Permalink
Merge pull request #7457 from Tilka/use_clamp
Browse files Browse the repository at this point in the history
VideoSoftware: make use of Clamp()
  • Loading branch information
CrossVR committed Oct 7, 2018
2 parents 0bef9fa + a6a5d86 commit 1ab1d41
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Source/Core/VideoBackends/Software/Tev.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


#include "Common/ChunkFile.h" #include "Common/ChunkFile.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/MathUtil.h"
#include "VideoBackends/Software/DebugUtil.h" #include "VideoBackends/Software/DebugUtil.h"
#include "VideoBackends/Software/EfbInterface.h" #include "VideoBackends/Software/EfbInterface.h"
#include "VideoBackends/Software/Tev.h" #include "VideoBackends/Software/Tev.h"
Expand Down Expand Up @@ -776,9 +777,7 @@ void Tev::Draw()
// Based on that, choose the index such that points which are far away from the z-axis use the // Based on that, choose the index such that points which are far away from the z-axis use the
// 10th "k" value and such that central points use the first value. // 10th "k" value and such that central points use the first value.
float floatindex = 9.f - std::abs(offset) * 9.f; float floatindex = 9.f - std::abs(offset) * 9.f;
floatindex = (floatindex < 0.f) ? floatindex = MathUtil::Clamp(floatindex, 0.f, 9.f); // TODO: This shouldn't be necessary!
0.f :
(floatindex > 9.f) ? 9.f : floatindex; // TODO: This shouldn't be necessary!


// Get the two closest integer indices, look up the corresponding samples // Get the two closest integer indices, look up the corresponding samples
const int indexlower = (int)floor(floatindex); const int indexlower = (int)floor(floatindex);
Expand All @@ -799,7 +798,7 @@ void Tev::Draw()
ze -= bpmem.fog.GetC(); ze -= bpmem.fog.GetC();


// clamp 0 to 1 // clamp 0 to 1
float fog = (ze < 0.0f) ? 0.0f : ((ze > 1.0f) ? 1.0f : ze); float fog = MathUtil::Clamp(ze, 0.f, 1.f);


switch (bpmem.fog.c_proj_fsel.fsel) switch (bpmem.fog.c_proj_fsel.fsel)
{ {
Expand Down

0 comments on commit 1ab1d41

Please sign in to comment.