2014-09-14 10:52:51 -06:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2014-09-14 10:52:51 -06:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "VideoCommon/BoundingBox.h"
|
2019-12-05 08:58:03 -07:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <array>
|
|
|
|
|
2015-09-24 01:19:43 -06:00
|
|
|
#include "Common/ChunkFile.h"
|
|
|
|
#include "Common/CommonTypes.h"
|
2019-12-05 09:55:21 -07:00
|
|
|
#include "VideoCommon/PixelShaderManager.h"
|
2014-09-14 10:52:51 -06:00
|
|
|
|
|
|
|
namespace BoundingBox
|
|
|
|
{
|
2019-12-05 08:58:03 -07:00
|
|
|
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;
|
2019-12-05 09:55:21 -07:00
|
|
|
PixelShaderManager::SetBoundingBoxActive(s_is_active);
|
2019-12-05 08:58:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Disable()
|
|
|
|
{
|
|
|
|
s_is_active = false;
|
2019-12-05 09:55:21 -07:00
|
|
|
PixelShaderManager::SetBoundingBoxActive(s_is_active);
|
2019-12-05 08:58:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2014-09-14 10:52:51 -06:00
|
|
|
|
2016-01-17 14:54:31 -07:00
|
|
|
void DoState(PointerWrap& p)
|
2014-09-14 10:52:51 -06:00
|
|
|
{
|
2019-12-05 08:58:03 -07:00
|
|
|
p.Do(s_is_active);
|
|
|
|
p.DoArray(s_coordinates);
|
2014-09-14 10:52:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace BoundingBox
|