summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/BoundingBox.cpp
diff options
context:
space:
mode:
authorAnthony <Helios747@users.noreply.github.com>2019-12-07 18:40:02 -0800
committerGitHub <noreply@github.com>2019-12-07 18:40:02 -0800
commitfdb78b64e18baaaf1c8851fde3b5ee1d1da4d775 (patch)
treea4530f2719ab3b9a6103bec042f5416a9ff7a648 /Source/Core/VideoCommon/BoundingBox.cpp
parentb39756dbce310f658b766597054c59662ca930e5 (diff)
parent2c9ec6cb8abba5a4dfd7a3792b0d866ed4898118 (diff)
Merge pull request #8513 from lioncash/bounding-box
VideoCommon/BoundingBox: Make interface for querying bounding box data
Diffstat (limited to 'Source/Core/VideoCommon/BoundingBox.cpp')
-rw-r--r--Source/Core/VideoCommon/BoundingBox.cpp66
1 files changed, 60 insertions, 6 deletions
diff --git a/Source/Core/VideoCommon/BoundingBox.cpp b/Source/Core/VideoCommon/BoundingBox.cpp
index 4c9b6c4c3b..805431c7d6 100644
--- a/Source/Core/VideoCommon/BoundingBox.cpp
+++ b/Source/Core/VideoCommon/BoundingBox.cpp
@@ -3,20 +3,74 @@
// Refer to the license.txt file included.
#include "VideoCommon/BoundingBox.h"
+
+#include <algorithm>
+#include <array>
+
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
+#include "VideoCommon/PixelShaderManager.h"
namespace BoundingBox
{
-// External vars
-bool active = false;
-u16 coords[4] = {0x80, 0xA0, 0x80, 0xA0};
+namespace
+{
+// Whether or not bounding box is enabled.
+bool s_is_active = false;
+
+// Current bounding box coordinates.
+std::array<u16, 4> s_coordinates{
+ 0x80,
+ 0xA0,
+ 0x80,
+ 0xA0,
+};
+} // Anonymous namespace
+
+void Enable()
+{
+ s_is_active = true;
+ PixelShaderManager::SetBoundingBoxActive(s_is_active);
+}
+
+void Disable()
+{
+ s_is_active = false;
+ PixelShaderManager::SetBoundingBoxActive(s_is_active);
+}
+
+bool IsEnabled()
+{
+ return s_is_active;
+}
+
+u16 GetCoordinate(Coordinate coordinate)
+{
+ return s_coordinates[static_cast<u32>(coordinate)];
+}
+
+void SetCoordinate(Coordinate coordinate, u16 value)
+{
+ s_coordinates[static_cast<u32>(coordinate)] = value;
+}
+
+void Update(u16 left, u16 right, u16 top, u16 bottom)
+{
+ const u16 new_left = std::min(left, GetCoordinate(Coordinate::Left));
+ const u16 new_right = std::max(right, GetCoordinate(Coordinate::Right));
+ const u16 new_top = std::min(top, GetCoordinate(Coordinate::Top));
+ const u16 new_bottom = std::max(bottom, GetCoordinate(Coordinate::Bottom));
+
+ SetCoordinate(Coordinate::Left, new_left);
+ SetCoordinate(Coordinate::Right, new_right);
+ SetCoordinate(Coordinate::Top, new_top);
+ SetCoordinate(Coordinate::Bottom, new_bottom);
+}
-// Save state
void DoState(PointerWrap& p)
{
- p.Do(active);
- p.Do(coords);
+ p.Do(s_is_active);
+ p.DoArray(s_coordinates);
}
} // namespace BoundingBox