diff options
| author | JMC47 <JMC4789@gmail.com> | 2022-06-28 13:35:39 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-28 13:35:39 -0400 |
| commit | 5d04e1e1de8248da8366f6f99ff4cdbe5467c789 (patch) | |
| tree | 47ff1e96f099cef3443635b982d03e2bf1ce3f04 /Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.cpp | |
| parent | e50e45f400856191eafb5f0c6044a8efbf152321 (diff) | |
| parent | 8aef0015fd8903b92cf0aab8a98ee669ec97b5ef (diff) | |
Merge pull request #10518 from iwubcode/draw-mod
Introducing a 'GraphicsMod' system for creators
Diffstat (limited to 'Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.cpp new file mode 100644 index 0000000000..d0cac24acb --- /dev/null +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.cpp @@ -0,0 +1,59 @@ +// Copyright 2022 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.h" + +std::unique_ptr<ScaleAction> ScaleAction::Create(const picojson::value& json_data) +{ + Common::Vec3 scale; + const auto& x = json_data.get("X"); + if (x.is<double>()) + { + scale.x = static_cast<float>(x.get<double>()); + } + + const auto& y = json_data.get("Y"); + if (y.is<double>()) + { + scale.y = static_cast<float>(y.get<double>()); + } + + const auto& z = json_data.get("Z"); + if (z.is<double>()) + { + scale.z = static_cast<float>(z.get<double>()); + } + return std::make_unique<ScaleAction>(scale); +} + +ScaleAction::ScaleAction(Common::Vec3 scale) : m_scale(scale) +{ +} + +void ScaleAction::OnEFB(bool*, u32 texture_width, u32 texture_height, u32* scaled_width, + u32* scaled_height) +{ + if (scaled_width && m_scale.x > 0) + *scaled_width = texture_width * m_scale.x; + + if (scaled_height && m_scale.y > 0) + *scaled_height = texture_height * m_scale.y; +} + +void ScaleAction::OnProjection(Common::Matrix44* matrix) +{ + if (!matrix) + return; + auto& the_matrix = *matrix; + the_matrix.data[0] = the_matrix.data[0] * m_scale.x; + the_matrix.data[5] = the_matrix.data[5] * m_scale.y; +} + +void ScaleAction::OnProjectionAndTexture(Common::Matrix44* matrix) +{ + if (!matrix) + return; + auto& the_matrix = *matrix; + the_matrix.data[0] = the_matrix.data[0] * m_scale.x; + the_matrix.data[5] = the_matrix.data[5] * m_scale.y; +} |
