Skip to content
Permalink
Browse files
Merge pull request #8767 from iwubcode/freelook-camera-type
Expand freelook camera with control options
  • Loading branch information
delroth committed May 17, 2020
2 parents 30b166e + aed7319 commit cea779c
Show file tree
Hide file tree
Showing 14 changed files with 410 additions and 49 deletions.
@@ -41,6 +41,8 @@ const Info<bool> GFX_DUMP_EFB_TARGET{{System::GFX, "Settings", "DumpEFBTarget"},
const Info<bool> GFX_DUMP_XFB_TARGET{{System::GFX, "Settings", "DumpXFBTarget"}, false};
const Info<bool> GFX_DUMP_FRAMES_AS_IMAGES{{System::GFX, "Settings", "DumpFramesAsImages"}, false};
const Info<bool> GFX_FREE_LOOK{{System::GFX, "Settings", "FreeLook"}, false};
const Info<FreelookControlType> GFX_FREE_LOOK_CONTROL_TYPE{
{System::GFX, "Settings", "FreeLookControlType"}, FreelookControlType::SixAxis};
const Info<bool> GFX_USE_FFV1{{System::GFX, "Settings", "UseFFV1"}, false};
const Info<std::string> GFX_DUMP_FORMAT{{System::GFX, "Settings", "DumpFormat"}, "avi"};
const Info<std::string> GFX_DUMP_CODEC{{System::GFX, "Settings", "DumpCodec"}, ""};
@@ -11,6 +11,7 @@
enum class AspectMode : int;
enum class ShaderCompilationMode : int;
enum class StereoMode : int;
enum class FreelookControlType : int;

namespace Config
{
@@ -41,6 +42,7 @@ extern const Info<bool> GFX_DUMP_EFB_TARGET;
extern const Info<bool> GFX_DUMP_XFB_TARGET;
extern const Info<bool> GFX_DUMP_FRAMES_AS_IMAGES;
extern const Info<bool> GFX_FREE_LOOK;
extern const Info<FreelookControlType> GFX_FREE_LOOK_CONTROL_TYPE;
extern const Info<bool> GFX_USE_FFV1;
extern const Info<std::string> GFX_DUMP_FORMAT;
extern const Info<std::string> GFX_DUMP_CODEC;
@@ -28,7 +28,7 @@ bool IsSettingSaveable(const Config::Location& config_location)
return true;
}

static constexpr std::array<const Config::Location*, 96> s_setting_saveable = {
static constexpr std::array<const Config::Location*, 97> s_setting_saveable = {
// Main.Core

&Config::MAIN_DEFAULT_ISO.location,
@@ -73,6 +73,7 @@ bool IsSettingSaveable(const Config::Location& config_location)
&Config::GFX_DUMP_EFB_TARGET.location,
&Config::GFX_DUMP_FRAMES_AS_IMAGES.location,
&Config::GFX_FREE_LOOK.location,
&Config::GFX_FREE_LOOK_CONTROL_TYPE.location,
&Config::GFX_USE_FFV1.location,
&Config::GFX_DUMP_FORMAT.location,
&Config::GFX_DUMP_CODEC.location,
@@ -72,16 +72,27 @@ void AdvancedWidget::CreateWidgets()
m_dump_efb_target = new GraphicsBool(tr("Dump EFB Target"), Config::GFX_DUMP_EFB_TARGET);
m_disable_vram_copies =
new GraphicsBool(tr("Disable EFB VRAM Copies"), Config::GFX_HACK_DISABLE_COPY_TO_VRAM);
m_enable_freelook = new GraphicsBool(tr("Free Look"), Config::GFX_FREE_LOOK);

utility_layout->addWidget(m_load_custom_textures, 0, 0);
utility_layout->addWidget(m_prefetch_custom_textures, 0, 1);

utility_layout->addWidget(m_enable_freelook, 1, 0);
utility_layout->addWidget(m_disable_vram_copies, 1, 1);
utility_layout->addWidget(m_disable_vram_copies, 1, 0);
utility_layout->addWidget(m_dump_textures, 1, 1);

utility_layout->addWidget(m_dump_textures, 2, 0);
utility_layout->addWidget(m_dump_efb_target, 2, 1);
utility_layout->addWidget(m_dump_efb_target, 2, 0);

// Freelook
auto* freelook_box = new QGroupBox(tr("Free Look"));
auto* freelook_layout = new QGridLayout();
freelook_box->setLayout(freelook_layout);

m_enable_freelook = new GraphicsBool(tr("Enable"), Config::GFX_FREE_LOOK);
m_freelook_control_type = new GraphicsChoice({tr("Six Axis"), tr("First Person"), tr("Orbital")},
Config::GFX_FREE_LOOK_CONTROL_TYPE);

freelook_layout->addWidget(m_enable_freelook, 0, 0);
freelook_layout->addWidget(new QLabel(tr("Control Type:")), 1, 0);
freelook_layout->addWidget(m_freelook_control_type, 1, 1);

// Frame dumping
auto* dump_box = new QGroupBox(tr("Frame Dumping"));
@@ -132,6 +143,7 @@ void AdvancedWidget::CreateWidgets()

main_layout->addWidget(debugging_box);
main_layout->addWidget(utility_box);
main_layout->addWidget(freelook_box);
main_layout->addWidget(dump_box);
main_layout->addWidget(misc_box);
main_layout->addWidget(experimental_box);
@@ -145,6 +157,7 @@ void AdvancedWidget::ConnectWidgets()
connect(m_load_custom_textures, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings);
connect(m_dump_use_ffv1, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings);
connect(m_enable_prog_scan, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings);
connect(m_enable_freelook, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings);
}

void AdvancedWidget::LoadSettings()
@@ -153,6 +166,8 @@ void AdvancedWidget::LoadSettings()
m_dump_bitrate->setEnabled(!Config::Get(Config::GFX_USE_FFV1));

m_enable_prog_scan->setChecked(Config::Get(Config::SYSCONF_PROGRESSIVE_SCAN));

m_freelook_control_type->setEnabled(Config::Get(Config::GFX_FREE_LOOK));
}

void AdvancedWidget::SaveSettings()
@@ -161,6 +176,8 @@ void AdvancedWidget::SaveSettings()
m_dump_bitrate->setEnabled(!Config::Get(Config::GFX_USE_FFV1));

Config::SetBase(Config::SYSCONF_PROGRESSIVE_SCAN, m_enable_prog_scan->isChecked());

m_freelook_control_type->setEnabled(Config::Get(Config::GFX_FREE_LOOK));
}

void AdvancedWidget::OnBackendChanged()
@@ -213,6 +230,14 @@ void AdvancedWidget::AddDescriptions()
"to pan or middle button to roll.\n\nUse the WASD keys while holding SHIFT to move the "
"camera. Press SHIFT+2 to increase speed or SHIFT+1 to decrease speed. Press SHIFT+R "
"to reset the camera or SHIFT+F to reset the speed.\n\nIf unsure, leave this unchecked. ");
static const char TR_FREE_LOOK_CONTROL_TYPE_DESCRIPTION[] = QT_TR_NOOP(
"Changes the in-game camera type during freelook.\n\n Six Axis: Offers full camera control "
"on all axis, akin to moving a spacecraft in zero gravity. This is the most powerful "
"freelook option but is the most challenging to use.\n"
"First Person: cControls the free camera similarly to a first person video game. The camera "
"can rotate and travel, but roll is impossible. Easy to use, but limiting.\nOrbital: Rotates "
"the free camera around the original camera. Has no lateral movement, only rotation and you "
"may zoom up to the camera's origin point.");
static const char TR_CROPPING_DESCRIPTION[] =
QT_TR_NOOP("Crops the picture from its native aspect ratio to 4:3 or "
"16:9.\n\nIf unsure, leave this unchecked.");
@@ -254,6 +279,7 @@ void AdvancedWidget::AddDescriptions()
AddDescription(m_enable_cropping, TR_CROPPING_DESCRIPTION);
AddDescription(m_enable_prog_scan, TR_PROGRESSIVE_SCAN_DESCRIPTION);
AddDescription(m_enable_freelook, TR_FREE_LOOK_DESCRIPTION);
AddDescription(m_freelook_control_type, TR_FREE_LOOK_CONTROL_TYPE_DESCRIPTION);
AddDescription(m_backend_multithreading, TR_BACKEND_MULTITHREADING_DESCRIPTION);
#ifdef _WIN32
AddDescription(m_borderless_fullscreen, TR_BORDERLESS_FULLSCREEN_DESCRIPTION);
@@ -8,6 +8,7 @@

class GraphicsWindow;
class QCheckBox;
class QComboBox;
class QSpinBox;

class AdvancedWidget final : public GraphicsWidget
@@ -39,6 +40,7 @@ class AdvancedWidget final : public GraphicsWidget
QCheckBox* m_disable_vram_copies;
QCheckBox* m_load_custom_textures;
QCheckBox* m_enable_freelook;
QComboBox* m_freelook_control_type;

// Frame dumping
QCheckBox* m_dump_use_ffv1;
@@ -30,6 +30,7 @@
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"

#include "VideoCommon/FreeLookCamera.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VertexShaderManager.h"
@@ -545,25 +546,25 @@ void HotkeyScheduler::Run()
fl_speed = 1.0;

if (IsHotkey(HK_FREELOOK_UP, true))
VertexShaderManager::TranslateView(0.0, 0.0, -fl_speed);
g_freelook_camera.MoveVertical(-fl_speed);

if (IsHotkey(HK_FREELOOK_DOWN, true))
VertexShaderManager::TranslateView(0.0, 0.0, fl_speed);
g_freelook_camera.MoveVertical(fl_speed);

if (IsHotkey(HK_FREELOOK_LEFT, true))
VertexShaderManager::TranslateView(fl_speed, 0.0);
g_freelook_camera.MoveHorizontal(fl_speed);

if (IsHotkey(HK_FREELOOK_RIGHT, true))
VertexShaderManager::TranslateView(-fl_speed, 0.0);
g_freelook_camera.MoveHorizontal(-fl_speed);

if (IsHotkey(HK_FREELOOK_ZOOM_IN, true))
VertexShaderManager::TranslateView(0.0, fl_speed);
g_freelook_camera.Zoom(fl_speed);

if (IsHotkey(HK_FREELOOK_ZOOM_OUT, true))
VertexShaderManager::TranslateView(0.0, -fl_speed);
g_freelook_camera.Zoom(-fl_speed);

if (IsHotkey(HK_FREELOOK_RESET, true))
VertexShaderManager::ResetView();
g_freelook_camera.Reset();

// Savestates
for (u32 i = 0; i < State::NUM_STATES; i++)
@@ -32,6 +32,7 @@
#include "DolphinQt/Resources.h"
#include "DolphinQt/Settings.h"

#include "VideoCommon/FreeLookCamera.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoConfig.h"
@@ -238,12 +239,12 @@ void RenderWidget::OnFreeLookMouseMove(QMouseEvent* event)
if (event->buttons() & Qt::RightButton)
{
// Camera Pitch and Yaw:
VertexShaderManager::RotateView(mouse_move.y() / 200.f, mouse_move.x() / 200.f, 0.f);
g_freelook_camera.Rotate(Common::Vec3{mouse_move.y() / 200.f, mouse_move.x() / 200.f, 0.f});
}
else if (event->buttons() & Qt::MidButton)
{
// Camera Roll:
VertexShaderManager::RotateView(0.f, 0.f, mouse_move.x() / 200.f);
g_freelook_camera.Rotate({0.f, 0.f, mouse_move.x() / 200.f});
}
}

@@ -33,6 +33,8 @@ add_library(videocommon
FramebufferManager.h
FramebufferShaderGen.cpp
FramebufferShaderGen.h
FreeLookCamera.cpp
FreeLookCamera.h
GeometryShaderGen.cpp
GeometryShaderGen.h
GeometryShaderManager.cpp

0 comments on commit cea779c

Please sign in to comment.