Files
GhostEngine/src/Editor/Ghost.Editor/ActivationHandler.cs
Misaki 5903ddda2b Refactor mesh import, meshlet, and asset handler systems
- Mesh import now builds full node hierarchy and splits geometry by material, with robust normal/tangent handling
- Meshlet generation supports material indices for correct assignment
- Refactored texture cube map compression and mipmap handling
- Updated asset handler registration to new namespace
- Enabled asset reimport on import events
- Improved code quality, resource management, and formatting
2026-04-26 14:49:58 +09:00

84 lines
2.9 KiB
C#

using Ghost.Editor.Core.Contracts;
using Ghost.Editor.Core.Utilities;
using Ghost.Editor.Models;
using Ghost.Engine;
using Misaki.HighPerformance.LowLevel.Buffer;
using System.Reflection;
namespace Ghost.Editor;
internal static class ActivationHandler
{
public static LaunchArguments ParseArguments(ReadOnlySpan<char> args)
{
var arguments = new LaunchArguments();
var properties = typeof(LaunchArguments).GetProperties();
var split = args.Split(' ');
while (split.MoveNext())
{
var range = split.Current;
var arg = args[range.Start..range.End];
if (arg.Length > 2)
{
if (arg[0] == '-' && arg[1] == '-')
{
var argName = arg[2..];
foreach (var property in properties)
{
var propName = property.Name;
var attr = property.GetCustomAttributes<ArgumentNameAttribute>(false).FirstOrDefault();
if (attr != null)
{
propName = attr.Name;
}
if (argName.Equals(propName, StringComparison.OrdinalIgnoreCase))
{
if (split.MoveNext())
{
var valueRange = split.Current;
var value = args[valueRange.Start..valueRange.End];
var convertedValue = Convert.ChangeType(value.ToString(), property.PropertyType);
property.SetValue(arguments, convertedValue);
break;
}
}
}
}
}
}
return arguments;
}
public static ValueTask HandleAsync(LaunchArguments args)
{
var opts = new AllocationManagerDesc
{
ArenaCapacity = 1024 * 1024 * 1024, // 1 GB. Arena using virtual memory, so this is just a reservation and won't actually consume physical memory until used.
StackCapacity = 1024 * 1024 * 32, // 32 MB. Stack using virtual memory, so this is just a reservation and won't actually consume physical memory until used.
FreeListChunkSize = 64 * 1024 * 1024,
FreeListDefaultAlignment = 8,
FreeListConcurrencyLevel = Environment.ProcessorCount
};
AllocationManager.Initialize(opts);
var assetRegistry = App.GetService<IAssetRegistry>();
var engineCore = App.GetService<EngineCore>();
assetRegistry.OnAssetImported += (sender, e) =>
{
engineCore.AssetManager.ReimportAsset(e);
};
return ValueTask.CompletedTask;
}
public static void Shutdown()
{
AllocationManager.Dispose();
}
}