feat: add option to disable camera parallax

This commit is contained in:
Almamu 2025-05-10 09:32:43 +02:00
parent fe02b73d43
commit a21e0cfa61
5 changed files with 21 additions and 7 deletions

View File

@ -150,6 +150,7 @@ You can use either:
| `--list-properties` | Show customizable properties of a wallpaper |
| `--set-property name=value` | Override a specific property |
| `--disable-mouse` | Disable mouse interaction |
| `--disable-parallax` | Disable parallax effect on backgrounds that support it |
| `--no-fullscreen-pause` | Prevent pausing while fullscreen apps are running |
---

View File

@ -209,6 +209,12 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) :
.action ([this](const std::string& value) -> void {
this->settings.mouse.enabled = false;
});
configurationGroup.add_argument ("--disable-parallax")
.help ("Disables parallax effect for the backgrounds")
.flag ()
.action ([this](const std::string& value) -> void {
this->settings.mouse.disableparallax = true;
});
configurationGroup.add_argument ("-l", "--list-properties")
.help ("List all the available properties and their configuration")

View File

@ -91,6 +91,8 @@ class CApplicationContext {
struct {
/** If the mouse movement is enabled */
bool enabled;
/** If the mouse parallax should be disabled */
bool disableparallax;
} mouse;
/**
@ -119,12 +121,11 @@ class CApplicationContext {
.mode = NORMAL_WINDOW,
.maximumFPS = 30,
.pauseOnFullscreen = true,
.window =
{
.geometry = {},
.clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVs,
.scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs,
},
.window = {
.geometry = {},
.clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVs,
.scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs,
},
},
.audio = {
.enabled = true,
@ -134,6 +135,7 @@ class CApplicationContext {
},
.mouse = {
.enabled = true,
.disableparallax = false,
},
.screenshot = {
.take = false,

View File

@ -420,6 +420,11 @@ void CImage::render () {
}
void CImage::updateScreenSpacePosition () {
// do not perform any changes to the image based on the parallax if it was explicitly disabled
if (this->getScene ()->getContext ().getApp ().getContext ().settings.mouse.disableparallax) {
return;
}
const double parallaxAmount = this->getScene ()->getScene ()->getCameraParallaxAmount ();
const glm::vec2 depth = this->getImage ()->getParallaxDepth ();
const glm::vec2* displacement = this->getScene ()->getParallaxDisplacement ();

View File

@ -207,7 +207,7 @@ void CScene::renderFrame (glm::ivec4 viewport) {
this->updateMouse (viewport);
// update the parallax position if required
if (this->getScene ()->isCameraParallax ()) {
if (this->getScene ()->isCameraParallax () && !this->getContext ().getApp ().getContext ().settings.mouse.disableparallax) {
const float influence = this->getScene ()->getCameraParallaxMouseInfluence ();
const float amount = this->getScene ()->getCameraParallaxAmount ();
const float delay =