Adjustments for #3338

This commit is contained in:
Wojtek Figat
2025-10-12 23:24:34 +02:00
parent 12decc3320
commit 7dfc37f652
6 changed files with 58 additions and 21 deletions

View File

@@ -4,8 +4,6 @@
#include "Config.h" #include "Config.h"
#include "Types.h" #include "Types.h"
#include "Engine/Core/Math/Vector3.h"
#include "Engine/Core/Types/BaseTypes.h" #include "Engine/Core/Types/BaseTypes.h"
/// <summary> /// <summary>
@@ -85,8 +83,7 @@ public:
FORCE_INLINE static void VelocityChanged(const Vector3& velocity) FORCE_INLINE static void VelocityChanged(const Vector3& velocity)
{ {
if (!velocity.IsNanOrInfinity()) Instance->Listener_VelocityChanged(velocity);
Instance->Listener_VelocityChanged(velocity);
} }
FORCE_INLINE static void TransformChanged(const Vector3& position, const Quaternion& orientation) FORCE_INLINE static void TransformChanged(const Vector3& position, const Quaternion& orientation)

View File

@@ -23,11 +23,11 @@ void AudioListener::Update()
{ {
// Update the velocity // Update the velocity
const Vector3 pos = GetPosition(); const Vector3 pos = GetPosition();
const float dt = Time::Update.UnscaledDeltaTime.GetTotalSeconds(); const float dt = Math::Max(Time::Update.UnscaledDeltaTime.GetTotalSeconds(), 0.00001f);
const auto prevVelocity = _velocity; const auto prevVelocity = _velocity;
_velocity = (pos - _prevPos) / dt; _velocity = (pos - _prevPos) / dt;
_prevPos = pos; _prevPos = pos;
if (_velocity != prevVelocity) if (_velocity != prevVelocity && !_velocity.IsNanOrInfinity())
{ {
AudioBackend::Listener::VelocityChanged(_velocity); AudioBackend::Listener::VelocityChanged(_velocity);
} }

View File

@@ -195,7 +195,7 @@ namespace Flax.Deps.Dependencies
RunCmake(cmakeFolder, platform, architecture, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + cmakeArgs, envVars); RunCmake(cmakeFolder, platform, architecture, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + cmakeArgs, envVars);
// Run build // Run build
BuildCmake(cmakeFolder, envVars: envVars); BuildCmake(cmakeFolder, envVars);
// Deploy binaries // Deploy binaries
var libs = new[] var libs = new[]

View File

@@ -50,8 +50,7 @@ namespace Flax.Deps.Dependencies
{ {
var root = options.IntermediateFolder; var root = options.IntermediateFolder;
var version = "1.24.3"; var version = "1.24.3";
string configuration = "Release"; var configuration = "Release";
int concurrency = Math.Min(Math.Max(1, (int)(Environment.ProcessorCount * Configuration.ConcurrencyProcessorScale)), Configuration.MaxConcurrency);
var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "OpenAL"); var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "OpenAL");
foreach (var platform in options.Platforms) foreach (var platform in options.Platforms)
@@ -123,7 +122,7 @@ namespace Flax.Deps.Dependencies
{ {
{ "CC", "clang-" + Configuration.LinuxClangMinVer }, { "CC", "clang-" + Configuration.LinuxClangMinVer },
{ "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer }, { "CC_FOR_BUILD", "clang-" + Configuration.LinuxClangMinVer },
{ "CMAKE_BUILD_PARALLEL_LEVEL", concurrency.ToString() }, { "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel },
}; };
var config = $"-DALSOFT_REQUIRE_ALSA=ON " + var config = $"-DALSOFT_REQUIRE_ALSA=ON " +
$"-DALSOFT_REQUIRE_OSS=ON " + $"-DALSOFT_REQUIRE_OSS=ON " +
@@ -158,7 +157,11 @@ namespace Flax.Deps.Dependencies
{ {
"libopenal.a", "libopenal.a",
}; };
var config = "-DALSOFT_REQUIRE_OBOE=OFF -DALSOFT_REQUIRE_OPENSL=ON -DALSOFT_EMBED_HRTF_DATA=YES"; var envVars = new Dictionary<string, string>
{
{ "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel },
};
var config = " -DALSOFT_REQUIRE_OBOE=OFF -DALSOFT_REQUIRE_OPENSL=ON -DALSOFT_EMBED_HRTF_DATA=YES";
// Get the source // Get the source
var packagePath = Path.Combine(root, "package.zip"); var packagePath = Path.Combine(root, "package.zip");
@@ -181,8 +184,8 @@ namespace Flax.Deps.Dependencies
SetupDirectory(buildDir, true); SetupDirectory(buildDir, true);
// Build // Build
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config); RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars);
BuildCmake(buildDir); BuildCmake(buildDir, envVars);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
foreach (var file in binariesToCopy) foreach (var file in binariesToCopy)
Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file));
@@ -194,7 +197,11 @@ namespace Flax.Deps.Dependencies
{ {
"libopenal.a", "libopenal.a",
}; };
var config = "-DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES"; var envVars = new Dictionary<string, string>
{
{ "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel },
};
var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES";
// Get the source // Get the source
var packagePath = Path.Combine(root, "package.zip"); var packagePath = Path.Combine(root, "package.zip");
@@ -210,8 +217,8 @@ namespace Flax.Deps.Dependencies
foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 }) foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 })
{ {
SetupDirectory(buildDir, true); SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, architecture, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config); RunCmake(buildDir, platform, architecture, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars);
BuildCmake(buildDir); BuildCmake(buildDir, envVars);
var depsFolder = GetThirdPartyFolder(options, platform, architecture); var depsFolder = GetThirdPartyFolder(options, platform, architecture);
foreach (var file in binariesToCopy) foreach (var file in binariesToCopy)
Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file));
@@ -224,7 +231,11 @@ namespace Flax.Deps.Dependencies
{ {
"libopenal.a", "libopenal.a",
}; };
var config = "-DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES"; var envVars = new Dictionary<string, string>
{
{ "CMAKE_BUILD_PARALLEL_LEVEL", CmakeBuildParallel },
};
var config = " -DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES";
// Get the source // Get the source
var packagePath = Path.Combine(root, "package.zip"); var packagePath = Path.Combine(root, "package.zip");
@@ -240,8 +251,8 @@ namespace Flax.Deps.Dependencies
// Build for iOS // Build for iOS
SetupDirectory(buildDir, true); SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_SYSTEM_NAME=iOS -DALSOFT_OSX_FRAMEWORK=ON -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config); RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_SYSTEM_NAME=iOS -DALSOFT_OSX_FRAMEWORK=ON -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=" + configuration + config, envVars);
BuildCmake(buildDir); BuildCmake(buildDir, envVars);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
foreach (var file in binariesToCopy) foreach (var file in binariesToCopy)
Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file)); Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file));

View File

@@ -248,6 +248,21 @@ namespace Flax.Deps
Utilities.Run("git", "reset --hard", null, path, Utilities.RunOptions.DefaultTool); Utilities.Run("git", "reset --hard", null, path, Utilities.RunOptions.DefaultTool);
} }
/// <summary>
/// Gets the maximum concurrency level for a cmake command. See CMAKE_BUILD_PARALLEL_LEVEL or -j docs.
/// </summary>
public static string CmakeBuildParallel => Math.Min(Math.Max(1, (int)(Environment.ProcessorCount * Configuration.ConcurrencyProcessorScale)), Configuration.MaxConcurrency).ToString();
/// <summary>
/// Builds the cmake project.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="envVars">Custom environment variables to pass to the child process.</param>
public static void BuildCmake(string path, Dictionary<string, string> envVars)
{
BuildCmake(path, "Release", envVars);
}
/// <summary> /// <summary>
/// Builds the cmake project. /// Builds the cmake project.
/// </summary> /// </summary>

View File

@@ -14,6 +14,7 @@ namespace Flax.Deps
/// </summary> /// </summary>
static class Downloader static class Downloader
{ {
private static bool IgnoreSSL = false;
private const string GoogleDriveDomain = "drive.google.com"; private const string GoogleDriveDomain = "drive.google.com";
private const string GoogleDriveDomain2 = "https://drive.google.com"; private const string GoogleDriveDomain2 = "https://drive.google.com";
@@ -54,7 +55,7 @@ namespace Flax.Deps
{ {
if (httpClient == null) if (httpClient == null)
{ {
using (httpClient = new HttpClient()) using (httpClient = GetHttpClient())
{ {
return DownloadFileFromUrlToPathRaw(url, path, httpClient); return DownloadFileFromUrlToPathRaw(url, path, httpClient);
} }
@@ -130,7 +131,7 @@ namespace Flax.Deps
// You can comment the statement below if the provided url is guaranteed to be in the following format: // You can comment the statement below if the provided url is guaranteed to be in the following format:
// https://drive.google.com/uc?id=FILEID&export=download // https://drive.google.com/uc?id=FILEID&export=download
url = GetGoogleDriveDownloadLinkFromUrl(url); url = GetGoogleDriveDownloadLinkFromUrl(url);
using (var httpClient = new HttpClient()) using (var httpClient = GetHttpClient())
{ {
FileInfo downloadedFile; FileInfo downloadedFile;
@@ -209,5 +210,18 @@ namespace Flax.Deps
return string.Format("https://drive.google.com/uc?id={0}&export=download", url.Substring(index, closingIndex - index)); return string.Format("https://drive.google.com/uc?id={0}&export=download", url.Substring(index, closingIndex - index));
} }
private static HttpClient GetHttpClient()
{
if (IgnoreSSL)
{
Log.Warning("Accessing HTTP with SSL certificate validation disabled!");
var handler = new HttpClientHandler();
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true;
return new HttpClient(handler);
}
return new HttpClient();
}
} }
} }