From 63cd6a32f25da764567dfcd751da74c3a8218d6d Mon Sep 17 00:00:00 2001 From: Kleadron Date: Mon, 31 Jul 2023 17:24:15 -0700 Subject: [PATCH 1/4] Add volume attenuation to SoundSystem_windows --- platforms/windows/SoundSystem_windows.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/platforms/windows/SoundSystem_windows.cpp b/platforms/windows/SoundSystem_windows.cpp index 226ff82..c34b84e 100644 --- a/platforms/windows/SoundSystem_windows.cpp +++ b/platforms/windows/SoundSystem_windows.cpp @@ -179,6 +179,23 @@ void SoundSystemWindows::playAt(const SoundDesc& sound, float x, float y, float return; } + // references: + // https://gamedev.net/forums/topic/337397-sound-volume-question-directsound/3243306/ + // https://learn.microsoft.com/en-us/previous-versions/windows/desktop/mt708939(v=vs.85) + // Conversion from 0-1 linear volume to directsound logarithmic volume.. + // This seems to work for the most part, but accuracy testing should be done for actual MCPE, water splashing is pretty quiet. + float attenuation = volume;//Lerp(DSBVOLUME_MIN, DSBVOLUME_MAX, volume); + if (attenuation == 0) + { + // no sound would come out, maybe skip playing this sound? + attenuation = DSBVOLUME_MIN; + } + else + { + attenuation = floorf(2000.0f * log10f((float)(attenuation) / (float)1.0f) + 0.5f); + } + (*soundbuffer)->SetVolume(LONG(attenuation)); + (*soundbuffer)->Play(0, 0, 0); m_buffers.push_back(soundbuffer); } From 40e54c2be8f05aa6049920ab17fec08c8c826aa9 Mon Sep 17 00:00:00 2001 From: Kleadron Date: Mon, 31 Jul 2023 17:30:00 -0700 Subject: [PATCH 2/4] Add 0-1 clamp and remove useless operations --- platforms/windows/SoundSystem_windows.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platforms/windows/SoundSystem_windows.cpp b/platforms/windows/SoundSystem_windows.cpp index c34b84e..f545dc5 100644 --- a/platforms/windows/SoundSystem_windows.cpp +++ b/platforms/windows/SoundSystem_windows.cpp @@ -185,6 +185,13 @@ void SoundSystemWindows::playAt(const SoundDesc& sound, float x, float y, float // Conversion from 0-1 linear volume to directsound logarithmic volume.. // This seems to work for the most part, but accuracy testing should be done for actual MCPE, water splashing is pretty quiet. float attenuation = volume;//Lerp(DSBVOLUME_MIN, DSBVOLUME_MAX, volume); + + // clamp the attenuation value + if (attenuation < 0.0f) + attenuation = 0.0f; + else if (attenuation > 1.0f) + attenuation = 1.0f; + if (attenuation == 0) { // no sound would come out, maybe skip playing this sound? @@ -192,7 +199,7 @@ void SoundSystemWindows::playAt(const SoundDesc& sound, float x, float y, float } else { - attenuation = floorf(2000.0f * log10f((float)(attenuation) / (float)1.0f) + 0.5f); + attenuation = floorf(2000.0f * log10f(attenuation) + 0.5f); } (*soundbuffer)->SetVolume(LONG(attenuation)); From 328ef4fff58c25c76c739a571a1008b50503a9e6 Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Tue, 1 Aug 2023 11:57:35 +0300 Subject: [PATCH 3/4] * Allow smooth shading on translucent blocks. --- source/Renderer/GameRenderer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/Renderer/GameRenderer.cpp b/source/Renderer/GameRenderer.cpp index 58a3a95..15cadd5 100644 --- a/source/Renderer/GameRenderer.cpp +++ b/source/Renderer/GameRenderer.cpp @@ -432,6 +432,10 @@ void GameRenderer::renderLevel(float f) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); setupFog(0); +#ifndef ORIGINAL_CODE + glShadeModel(GL_SMOOTH); +#endif + glEnable(GL_BLEND); glDisable(GL_CULL_FACE); // glDepthMask(false); -- added in 0.1.1j. Introduces more issues than fixes @@ -441,7 +445,11 @@ void GameRenderer::renderLevel(float f) pLR->render(pMob, 1, f); glDepthMask(true); - + + +#ifndef ORIGINAL_CODE + glShadeModel(GL_FLAT); +#endif glEnable(GL_CULL_FACE); glDisable(GL_BLEND); From 7fd8c67f139c1f5719bc015fd882dcb9bf642912 Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Tue, 1 Aug 2023 12:05:24 +0300 Subject: [PATCH 4/4] * Fix some more bugs. --- platforms/windows/AppPlatform_windows.cpp | 4 ---- source/GUI/Screen/PauseScreen.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/platforms/windows/AppPlatform_windows.cpp b/platforms/windows/AppPlatform_windows.cpp index 95777a8..c61bc41 100644 --- a/platforms/windows/AppPlatform_windows.cpp +++ b/platforms/windows/AppPlatform_windows.cpp @@ -238,10 +238,6 @@ void AppPlatform_windows::recenterMouse() void AppPlatform_windows::setMouseGrabbed(bool b) { - // only if stuff has changed do we update - if (m_bGrabbedMouse == b) - return; - m_bGrabbedMouse = b; if (m_bActuallyGrabbedMouse == (b && m_bIsFocused)) diff --git a/source/GUI/Screen/PauseScreen.cpp b/source/GUI/Screen/PauseScreen.cpp index 0cb596b..5a90466 100644 --- a/source/GUI/Screen/PauseScreen.cpp +++ b/source/GUI/Screen/PauseScreen.cpp @@ -41,7 +41,7 @@ void PauseScreen::init() #ifdef ENH_ADD_OPTIONS_PAUSE // TODO: when visible or quit© are on, lower this m_btnOptions.m_width = 160; - m_btnOptions.m_yPos = 144; + m_btnOptions.m_yPos = 112; m_btnOptions.m_xPos = m_btnBack.m_xPos; #endif @@ -55,10 +55,13 @@ void PauseScreen::init() //m_buttons.push_back(&m_btnQuitAndCopy); - if (m_pMinecraft->m_pRakNetInstance) + if (m_pMinecraft->m_pRakNetInstance && m_pMinecraft->m_pRakNetInstance->m_bIsHost) { updateServerVisibilityText(); m_buttons.push_back(&m_btnVisible); +#ifdef ENH_ADD_OPTIONS_PAUSE + m_btnOptions.m_yPos += 32; +#endif } for (auto thing : m_buttons)