diff --git a/Assets/Scripts/AudioManager.cs b/Assets/Scripts/AudioManager.cs index 1e7f5ce..c00020e 100644 --- a/Assets/Scripts/AudioManager.cs +++ b/Assets/Scripts/AudioManager.cs @@ -30,6 +30,13 @@ public class AudioManager : MonoBehaviour return instance; } } + + [SerializeField, Range(0, 1)] + private float masterVolume = 1f; + + private float prevMasterVolume; + + private FMOD.ChannelGroup masterChannelGroup; void Awake() { @@ -43,6 +50,20 @@ public class AudioManager : MonoBehaviour InitFmod(); } + void Update() + { + if (!fmodSystem.hasHandle() || !masterChannelGroup.hasHandle()) + return; + + if (!Mathf.Approximately(masterVolume, prevMasterVolume)) + { + masterChannelGroup.setVolume(masterVolume); + prevMasterVolume = masterVolume; + } + + masterChannelGroup.getVolume(out masterVolume); + } + void OnDisable() { // Ensure FMOD gets closed before hot reload @@ -85,6 +106,11 @@ public class AudioManager : MonoBehaviour result = fmodSystem.init(MaxVirtualChannels, FMOD.INITFLAGS.VOL0_BECOMES_VIRTUAL, IntPtr.Zero); CheckFmodResult(result, "FMOD.System.init"); + + result = fmodSystem.getMasterChannelGroup(out masterChannelGroup); + CheckFmodResult(result, "FMOD.System.getMasterChannelGroup"); + masterChannelGroup.setVolume(masterVolume); + prevMasterVolume = masterVolume; } private void CheckFmodResult(FMOD.RESULT result, string cause) diff --git a/Assets/Scripts/QuakeParms.cs b/Assets/Scripts/QuakeParms.cs index f983db9..7d5c845 100644 --- a/Assets/Scripts/QuakeParms.cs +++ b/Assets/Scripts/QuakeParms.cs @@ -29,7 +29,9 @@ public class QuakeParms public IntPtr ToNativePtr() { - nativeBlock = Marshal.AllocHGlobal(Marshal.SizeOf()); + if (nativeBlock == IntPtr.Zero) + nativeBlock = Marshal.AllocHGlobal(Marshal.SizeOf()); + Marshal.StructureToPtr(this, nativeBlock, false); return nativeBlock; } @@ -48,6 +50,10 @@ public class QuakeParms { memSize = memorySize; memBase = Marshal.AllocHGlobal(memorySize); + if (memBase == IntPtr.Zero) + { + throw new OutOfMemoryException($"Could not allocate {memorySize / 1024 / 1024} MB of heap memory!"); + } } public void Destroy() diff --git a/Assets/Scripts/Support/AliasModel.cs b/Assets/Scripts/Support/AliasModel.cs index caa18e2..781ae9c 100644 --- a/Assets/Scripts/Support/AliasModel.cs +++ b/Assets/Scripts/Support/AliasModel.cs @@ -111,6 +111,9 @@ public class AliasModel animName = frameName; continue; } + + // TODO do we maybe need to distinguish between frames and poses here after all? + // In most cases frames and poses are correlated 1-to-1, but perhaps not always. This could cause subtle animation glitches. if (frameName != animName) { @@ -284,7 +287,7 @@ public class AliasModel mesh.SetUVs(0, uvs); mesh.Optimize(); mesh.RecalculateBounds(); - mesh.UploadMeshData(false); + mesh.UploadMeshData(false); // Meshes have to stay in RAM, otherwise they won't show up in standalone builds return mesh; } diff --git a/Assets/Styles/GLQuake/GLQuake.asset b/Assets/Styles/GLQuake/GLQuake.asset index ad7c1fd..eba8ec3 100644 --- a/Assets/Styles/GLQuake/GLQuake.asset +++ b/Assets/Styles/GLQuake/GLQuake.asset @@ -16,9 +16,9 @@ MonoBehaviour: worldMaterial: {fileID: 2100000, guid: fcbaf32c00bea2344bbb1419c61364b6, type: 2} liquidMaterial: {fileID: 2100000, guid: cd59502a1689c0847a1963c60e347987, type: 2} liquidProperties: - waterAlpha: 0.85 - slimeAlpha: 0.9 - lavaAlpha: 0.95 + waterAlpha: 0.8 + slimeAlpha: 0.85 + lavaAlpha: 0.9 teleporterAlpha: 1 particles: explosion: {fileID: 0} diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset index cdc1f3e..084758c 100644 --- a/ProjectSettings/DynamicsManager.asset +++ b/ProjectSettings/DynamicsManager.asset @@ -3,10 +3,11 @@ --- !u!55 &1 PhysicsManager: m_ObjectHideFlags: 0 - serializedVersion: 11 - m_Gravity: {x: 0, y: -9.81, z: 0} + serializedVersion: 13 + m_Gravity: {x: 0, y: -800, z: 0} m_DefaultMaterial: {fileID: 0} m_BounceThreshold: 2 + m_DefaultMaxDepenetrationVelocity: 10 m_SleepThreshold: 0.005 m_DefaultContactOffset: 0.01 m_DefaultSolverIterations: 6 @@ -22,6 +23,7 @@ PhysicsManager: m_AutoSyncTransforms: 0 m_ReuseCollisionCallbacks: 1 m_ClothInterCollisionSettingsToggle: 0 + m_ClothGravity: {x: 0, y: -9.81, z: 0} m_ContactPairsMode: 0 m_BroadphaseType: 0 m_WorldBounds: @@ -31,4 +33,5 @@ PhysicsManager: m_FrictionType: 0 m_EnableEnhancedDeterminism: 0 m_EnableUnifiedHeightmaps: 1 - m_DefaultMaxAngluarSpeed: 7 + m_SolverType: 0 + m_DefaultMaxAngularSpeed: 7