diff --git a/src/Editor/Ghost.Editor.Core/AssetHandler/TextureAsset.cs b/src/Editor/Ghost.Editor.Core/AssetHandler/TextureAsset.cs index 762328e..0d7276f 100644 --- a/src/Editor/Ghost.Editor.Core/AssetHandler/TextureAsset.cs +++ b/src/Editor/Ghost.Editor.Core/AssetHandler/TextureAsset.cs @@ -284,7 +284,6 @@ internal class TextureAssetHandler : IImportableAssetHandler public async ValueTask ImportAsync(Stream sourceStream, Stream targetStream, Guid id, CancellationToken token = default) { - // ---- 1. Probe image info ----------------------------------------------- var info = ImageInfo.FromStream(sourceStream); if (info.BitsPerChannel <= 0) { @@ -296,93 +295,94 @@ internal class TextureAssetHandler : IImportableAssetHandler var height = info.Height; var colorComponents = info.ColorComponents; - // ---- 2. Decode pixels into a managed byte[] ---------------------------- byte[] pixelBytes; if (isFloat) { using var image = ImageResultFloat.FromStream(sourceStream, colorComponents); var span = MemoryMarshal.AsBytes(image.AsSpan()); - pixelBytes = new byte[span.Length]; + pixelBytes = ArrayPool.Shared.Rent(span.Length); span.CopyTo(pixelBytes); } else { using var image = ImageResult.FromStream(sourceStream, colorComponents); - var span = MemoryMarshal.AsBytes(image.AsSpan()); - pixelBytes = new byte[span.Length]; + var span = image.AsSpan(); + pixelBytes = ArrayPool.Shared.Rent(span.Length); span.CopyTo(pixelBytes); } - // ---- 3. Run NVTT compression on a thread-pool thread (side-effect only) - - // The cache path is derivable at any time from (id, settingsHash), so we - // do NOT store it in the asset file. LoadAsync/SaveAsync will recompute it. - var settings = new TextureAssetSettings(); - await Task.Run(() => - TextureProcessor.CompressToCache( - EditorApplication.CachesFolderPath, - id, - pixelBytes, - width, - height, - isFloat, - colorComponents, - settings), - token).ConfigureAwait(false); - - // ---- 4. Write asset file: header + settings + raw image data ----------- - - var header = new AssetMetadata(id, TextureAsset.s_typeGuid) - { - HandlerVersion = _CURRENT_VERSION, - SettingsOffset = AssetMetadata.SIZE, - }; - - targetStream.Seek(header.SettingsOffset, SeekOrigin.Begin); - var sizeResult = await WriteSettingsToStreamAsync(settings, targetStream, token).ConfigureAwait(false); - if (sizeResult.IsFailure) - { - return Result.Failure($"Failed to write texture asset settings: {sizeResult.Message}"); - } - - // Content layout (all little-endian): - // int32 width - // int32 height - // byte isFloat (0 = byte, 1 = float) - // int32 colorComponents (cast of ColorComponents enum) - // byte[] pixelBytes - const int _CONTENT_HEADER_SIZE = 4 + 4 + 1 + 4; // 13 bytes - - header.SettingsSize = sizeResult.Value; - header.ContentOffset = header.SettingsOffset + sizeResult.Value; - header.ContentSize = _CONTENT_HEADER_SIZE + pixelBytes.Length; - - // Write raw image content - targetStream.Seek(header.ContentOffset, SeekOrigin.Begin); - - var contentHeader = ArrayPool.Shared.Rent(_CONTENT_HEADER_SIZE); try { - BitConverter.TryWriteBytes(contentHeader.AsSpan(0, 4), width); - BitConverter.TryWriteBytes(contentHeader.AsSpan(4, 4), height); - contentHeader[8] = isFloat ? (byte)1 : (byte)0; - BitConverter.TryWriteBytes(contentHeader.AsSpan(9, 4), (int)colorComponents); + var settings = new TextureAssetSettings(); + await Task.Run(() => + TextureProcessor.CompressToCache( + EditorApplication.CachesFolderPath, + id, + pixelBytes, + width, + height, + isFloat, + colorComponents, + settings), + token).ConfigureAwait(false); - await targetStream.WriteAsync(contentHeader.AsMemory(0, _CONTENT_HEADER_SIZE), token).ConfigureAwait(false); + var header = new AssetMetadata(id, TextureAsset.s_typeGuid) + { + HandlerVersion = _CURRENT_VERSION, + SettingsOffset = AssetMetadata.SIZE, + }; + + targetStream.Seek(header.SettingsOffset, SeekOrigin.Begin); + var sizeResult = await WriteSettingsToStreamAsync(settings, targetStream, token).ConfigureAwait(false); + if (sizeResult.IsFailure) + { + return Result.Failure($"Failed to write texture asset settings: {sizeResult.Message}"); + } + + // Content layout (all little-endian): + // int32 width + // int32 height + // byte isFloat (0 = byte, 1 = float) + // int32 colorComponents (cast of ColorComponents enum) + // byte[] pixelBytes + const int _CONTENT_HEADER_SIZE = 4 + 4 + 1 + 4; // 13 bytes + + header.SettingsSize = sizeResult.Value; + header.ContentOffset = header.SettingsOffset + sizeResult.Value; + header.ContentSize = _CONTENT_HEADER_SIZE + pixelBytes.Length; + + // Write raw image content + targetStream.Seek(header.ContentOffset, SeekOrigin.Begin); + + var contentHeader = ArrayPool.Shared.Rent(_CONTENT_HEADER_SIZE); + try + { + BitConverter.TryWriteBytes(contentHeader.AsSpan(0, 4), width); + BitConverter.TryWriteBytes(contentHeader.AsSpan(4, 4), height); + contentHeader[8] = isFloat ? (byte)1 : (byte)0; + BitConverter.TryWriteBytes(contentHeader.AsSpan(9, 4), (int)colorComponents); + + await targetStream.WriteAsync(contentHeader.AsMemory(0, _CONTENT_HEADER_SIZE), token).ConfigureAwait(false); + } + finally + { + ArrayPool.Shared.Return(contentHeader); + } + + await targetStream.WriteAsync(pixelBytes, token).ConfigureAwait(false); + await targetStream.FlushAsync(token).ConfigureAwait(false); + + // Patch header now that all sizes are known + targetStream.Seek(0, SeekOrigin.Begin); + AssetMetadata.WriteToStream(targetStream, ref header); + + return Result.Success(); } finally { - ArrayPool.Shared.Return(contentHeader); + ArrayPool.Shared.Return(pixelBytes); } - - await targetStream.WriteAsync(pixelBytes, token).ConfigureAwait(false); - await targetStream.FlushAsync(token).ConfigureAwait(false); - - // Patch header now that all sizes are known - targetStream.Seek(0, SeekOrigin.Begin); - AssetMetadata.WriteToStream(targetStream, ref header); - - return Result.Success(); } public ValueTask> LoadAsync(Stream sourceStream, IAssetRegistry assetRegistry, CancellationToken token = default) diff --git a/src/Editor/Ghost.Editor.Core/AssetHandler/TextureProcessor.cs b/src/Editor/Ghost.Editor.Core/AssetHandler/TextureProcessor.cs index cdb9f8f..968bf51 100644 --- a/src/Editor/Ghost.Editor.Core/AssetHandler/TextureProcessor.cs +++ b/src/Editor/Ghost.Editor.Core/AssetHandler/TextureProcessor.cs @@ -1,9 +1,10 @@ using Ghost.Nvtt; -using Ghost.Nvtt.Wrapper; using Misaki.HighPerformance.Image; +using Misaki.HighPerformance.LowLevel; using System.IO.Hashing; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Text; namespace Ghost.Editor.Core.AssetHandler; @@ -39,7 +40,6 @@ internal static unsafe class TextureProcessor ColorComponents colorComponents, TextureAssetSettings settings) { - // --- derive cache path -------------------------------------------------- var cacheDir = Path.Combine(cachesFolderPath, _TEXTURE_CACHE_SUBFOLDER); Directory.CreateDirectory(cacheDir); @@ -47,19 +47,16 @@ internal static unsafe class TextureProcessor var cacheFileName = $"{assetId:N}_{settingsHash:X16}.dds"; var cachePath = Path.Combine(cacheDir, cacheFileName); - // --- check validity: same file name = same settings hash = already done - if (File.Exists(cachePath)) { return cachePath; } - // --- delete any stale cache entries for this asset ---------------------- foreach (var stale in Directory.EnumerateFiles(cacheDir, $"{assetId:N}_*.dds")) { File.Delete(stale); } - // --- run NVTT pipeline -------------------------------------------------- RunNvttPipeline(cachePath, pixelData, width, height, isFloat, colorComponents, settings); return cachePath; @@ -74,84 +71,75 @@ internal static unsafe class TextureProcessor ColorComponents colorComponents, TextureAssetSettings settings) { - using var surface = new NvttSurfaceHandle(); - using var compOpts = new NvttCompressionOptionsHandle(); - using var outOpts = new NvttOutputOptionsHandle(); - using var ctx = new NvttContextHandle(); + using var pSurface = new DisposablePtr(NvttSurface.Create()); + using var pCompOpts = new DisposablePtr(NvttCompressionOptions.Create()); + using var pOutOpts = new DisposablePtr(NvttOutputOptions.Create()); + using var pCtx = new DisposablePtr(NvttContext.Create()); - // ---- 1. load pixels into NVTT ----------------------------------------- - // Misaki.HighPerformance.Image always decodes to RGBA channel order. - // Float images → RGBA_32F, byte images → BGRA_8UB. - // NOTE: NVTT BGRA_8UB expects Blue in byte[0]; stb decodes RGBA so we need - // to pass RGBA. There is no RGBA_8UB enum — we swizzle after load instead. var inputFormat = isFloat ? NvttInputFormat.NVTT_InputFormat_RGBA_32F : NvttInputFormat.NVTT_InputFormat_BGRA_8UB; // we'll swizzle RB below - surface.SetImageData(inputFormat, width, height, 1, pixelData); + fixed (void* pData = pixelData) + { + pSurface.Get()->SetImageData(inputFormat, width, height, 1, pData, NvttBoolean.NVTT_True, null); + } // stb gives us RGBA byte order; NVTT BGRA_8UB reads it as BGRA, // so channels R and B are swapped — fix with swizzle(2,1,0,3). if (!isFloat) { - surface.Swizzle(2, 1, 0, 3); + pSurface.Get()->Swizzle(2, 1, 0, 3, null); } - // ---- 2. resize --------------------------------------------------------- var maxExtent = (int)settings.Sampler.MaxSize; if (settings.Advanced.StretchToPowerOfTwo) { - surface.ResizeMakeSquare(maxExtent, + pSurface.Get()->ResizeMakeSquare(maxExtent, NvttRoundMode.NVTT_RoundMode_ToNearestPowerOfTwo, - NvttResizeFilter.NVTT_ResizeFilter_Box); + NvttResizeFilter.NVTT_ResizeFilter_Box, null); } - else if (surface.Width > maxExtent || surface.Height > maxExtent) + else if (pSurface.Get()->Width() > maxExtent || pSurface.Get()->Height() > maxExtent) { - surface.ResizeMax(maxExtent, + pSurface.Get()->ResizeMax(maxExtent, NvttRoundMode.NVTT_RoundMode_None, - NvttResizeFilter.NVTT_ResizeFilter_Box); + NvttResizeFilter.NVTT_ResizeFilter_Box, null); } - // ---- 2b. border color -------------------------------------------------- if (settings.Advanced.UseBorderColor) { var c = settings.Advanced.BorderColor; - surface.SetBorder(c.r, c.g, c.b, c.a); + pSurface.Get()->SetBorder(c.r, c.g, c.b, c.a, null); } else if (settings.Advanced.ZeroAlphaBorder) { - surface.SetBorder(0f, 0f, 0f, 0f); + pSurface.Get()->SetBorder(0f, 0f, 0f, 0f, null); } - - // ---- 3. colour-space: convert to linear before mip filtering ----------- + if (settings.Basic.IsSRGB && settings.Advanced.GammaCorrection) { - surface.ToLinearFromSrgb(); + pSurface.Get()->ToLinearFromSrgb(null); } - // ---- 4. premultiply alpha (before mip chain) --------------------------- if (settings.Advanced.PremultiplyAlpha) { - surface.PremultiplyAlpha(); + pSurface.Get()->PremultiplyAlpha(null); } - // ---- 5. configure compression options ---------------------------------- - compOpts.Format = SelectFormat(settings); - compOpts.Quality = SelectQuality(settings.Advanced.CompressionLevel); + pCompOpts.Get()->SetFormat(SelectFormat(settings)); + pCompOpts.Get()->SetQuality(SelectQuality(settings.Advanced.CompressionLevel)); if (settings.Advanced.CutoutAlpha) { - compOpts.SetQuantization(false, false, true, + pCompOpts.Get()->SetQuantization(false, false, true, settings.Advanced.CutoutAlphaThreshold); } - // ---- 6. configure output options --------------------------------------- - outOpts.OutputHeader = true; - outOpts.Srgb = settings.Basic.IsSRGB; - outOpts.Container = NvttContainer.NVTT_Container_DDS10; - outOpts.FileName = outputPath; + pOutOpts.Get()->SetOutputHeader(true); + pOutOpts.Get()->SetSrgbFlag(settings.Basic.IsSRGB); + pOutOpts.Get()->SetContainer(NvttContainer.NVTT_Container_DDS10); + pOutOpts.Get()->SetFileName(Encoding.UTF8.GetBytes(outputPath)); - // ---- 7. mipmap count --------------------------------------------------- var nvttFilter = SelectMipmapFilter(settings.Advanced.MipmapFilter); int mipmapCount; @@ -161,38 +149,35 @@ internal static unsafe class TextureProcessor } else if (settings.Advanced.MipmapLevelCount == 0) { - mipmapCount = surface.CountMipmaps(); + mipmapCount = pSurface.Get()->CountMipmaps(1); } else { mipmapCount = (int)settings.Advanced.MipmapLevelCount; } - // ---- 8. enable CUDA if available --------------------------------------- - ctx.SetCudaAcceleration(NvttGlobal.IsCudaSupported); + pCtx.Get()->SetCudaAcceleration(Api.nvttIsCudaSupported()); - // ---- 9. write DDS header ----------------------------------------------- - ctx.OutputHeader(surface, mipmapCount, compOpts, outOpts); + pCtx.Get()->OutputHeader(pSurface.Get(), mipmapCount, pCompOpts.Get(), pOutOpts.Get()); - // ---- 10. compress mip chain using a working clone ---------------------- - using var mip = surface.Clone(); + using var pMip = new DisposablePtr(pSurface.Get()->Clone()); for (var level = 0; level < mipmapCount; level++) { - // Scale alpha for coverage on each mip (if requested) + // Scale alpha for coverage on each pMip (if requested) if (settings.Advanced.ScaleAlphaForMipCoverage && level > 0) { - var refCoverage = mip.AlphaTestCoverage( - settings.Advanced.ScaleAlphaForMipCoverageThreshold / 255f); - mip.ScaleAlphaToCoverage(refCoverage, - settings.Advanced.ScaleAlphaForMipCoverageThreshold / 255f); + var refCoverage = pMip.Get()->AlphaTestCoverage( + settings.Advanced.ScaleAlphaForMipCoverageThreshold / 255f, 3); + pMip.Get()->ScaleAlphaToCoverage(refCoverage, + settings.Advanced.ScaleAlphaForMipCoverageThreshold / 255f, 3, null); } - ctx.Compress(mip, 0, level, compOpts, outOpts); + pCtx.Get()->Compress(pMip.Get(), 0, level, pCompOpts.Get(), pOutOpts.Get()); if (level + 1 < mipmapCount) { - mip.BuildNextMipmap(nvttFilter); + pMip.Get()->BuildNextMipmapDefaults(nvttFilter, 1, null); } } } @@ -203,7 +188,7 @@ internal static unsafe class TextureProcessor TextureType.Normal => NvttFormat.NVTT_Format_BC5, // RG normal map TextureType.SingleChannel => NvttFormat.NVTT_Format_BC4, // single channel TextureType.Lightmap => NvttFormat.NVTT_Format_BC6U, // HDR lightmap (unsigned) - _ => NvttFormat.NVTT_Format_BC7, // default colour + _ => NvttFormat.NVTT_Format_BC7, // default color }; private static NvttQuality SelectQuality(TextureCompressionLevel level) diff --git a/src/Runtime/Ghost.Core/Ghost.Core.csproj b/src/Runtime/Ghost.Core/Ghost.Core.csproj index a347d44..5111c8c 100644 --- a/src/Runtime/Ghost.Core/Ghost.Core.csproj +++ b/src/Runtime/Ghost.Core/Ghost.Core.csproj @@ -22,12 +22,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/Runtime/Ghost.Graphics/Ghost.Graphics.csproj b/src/Runtime/Ghost.Graphics/Ghost.Graphics.csproj index 9cad2fe..fe61d22 100644 --- a/src/Runtime/Ghost.Graphics/Ghost.Graphics.csproj +++ b/src/Runtime/Ghost.Graphics/Ghost.Graphics.csproj @@ -22,7 +22,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/Test/Ghost.MicroTest/NvttBindingTest.cs b/src/Test/Ghost.MicroTest/NvttBindingTest.cs index f7c28d5..06ce9ae 100644 --- a/src/Test/Ghost.MicroTest/NvttBindingTest.cs +++ b/src/Test/Ghost.MicroTest/NvttBindingTest.cs @@ -1,6 +1,8 @@ using Ghost.Nvtt; -using Ghost.Nvtt.Wrapper; using Ghost.Test.Core; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; namespace Ghost.MicroTest; @@ -14,7 +16,7 @@ namespace Ghost.MicroTest; /// 4. sRGB conversion — converts to linear colour space. /// 5. Mipmap count — verifies CountMipmaps() returns a sensible value. /// 6. Compression — compresses to BC7 with in-memory output. -/// 7. Mip chain — generates and compresses the full mip chain. +/// 7. Mip chain — generates and compresses the full pMip chain. /// 8. Error callback — installs a global message callback and verifies /// it doesn't crash. /// 9. Output to file — re-runs the full pipeline writing a real .dds file @@ -23,6 +25,7 @@ namespace Ghost.MicroTest; internal sealed unsafe class NvttBindingTest : ITest { private const string _IMAGE_PATH = @"C:/Users/Misaki/Downloads/Screenshot 2024-07-20 035047.png"; + private static ReadOnlySpan ImagePathByte => @"C:/Users/Misaki/Downloads/Screenshot 2024-07-20 035047.png"u8; private string _outputDdsPath = string.Empty; @@ -38,26 +41,20 @@ internal sealed unsafe class NvttBindingTest : ITest { // ---- Test 1: Version --------------------------------------------------- Console.Write("[Test 1] nvttVersion ... "); - var version = NvttGlobal.Version; + var version = Api.nvttVersion(); Assert(version > 0, $"Expected version > 0, got {version}"); Console.WriteLine($"OK (version = {version >> 16}.{(version >> 8) & 0xFF}.{version & 0xFF})"); // ---- Test 2: CUDA support query (must not crash) ---------------------- Console.Write("[Test 2] IsCudaSupported ... "); - var cuda = NvttGlobal.IsCudaSupported; + var cuda = Api.nvttIsCudaSupported(); Console.WriteLine($"OK (cuda = {cuda})"); // ---- Test 3: Global message callback ---------------------------------- Console.Write("[Test 3] SetMessageCallback ... "); var callbackFired = 0; - using (var token = NvttGlobal.SetMessageCallback((severity, error, msg) => - { - callbackFired++; - Console.WriteLine($"/n [NVTT] [{severity}] {error}: {msg}"); - })) - { - // Just install + dispose — no assertion needed; must not throw. - } + var token = Api.nvttSetMessageCallback(&CallBack, &callbackFired); + Console.WriteLine($"OK (no crash, callback fired {callbackFired} times during install)"); // ---- Test 4: Surface creation + load ---------------------------------- @@ -65,81 +62,92 @@ internal sealed unsafe class NvttBindingTest : ITest Assert(File.Exists(_IMAGE_PATH), $"Image not found: '{_IMAGE_PATH}'. Edit _IMAGE_PATH before running."); - using var surface = new NvttSurfaceHandle(); - var loaded = surface.Load(_IMAGE_PATH, out var hasAlpha); + var pSurface = NvttSurface.Create(); + + NvttBoolean hasAlpha; + var loaded = pSurface->Load(ImagePathByte, &hasAlpha, false, null); + Assert(loaded, "nvttSurfaceLoad returned false"); - Assert(!surface.IsNull, "Surface is null after load"); - Assert(surface.Width > 0 && surface.Height > 0, - $"Bad dimensions after load: {surface.Width}x{surface.Height}"); - Console.WriteLine($"OK ({surface.Width}x{surface.Height}, hasAlpha={hasAlpha})"); + Assert(pSurface != null, "Surface is null after load"); + Assert(pSurface->Width() > 0 && pSurface->Height() > 0, + $"Bad dimensions after load: {pSurface->Width()}x{pSurface->Height()}"); + + Console.WriteLine($"OK ({pSurface->Width()}x{pSurface->Height()}, hasAlpha={hasAlpha})"); // ---- Test 5: Resize to power-of-two ≤ 512 ---------------------------- Console.Write("[Test 5] ResizeMakeSquare ... "); - surface.ResizeMakeSquare(512, + pSurface->ResizeMakeSquare(512, NvttRoundMode.NVTT_RoundMode_ToPreviousPowerOfTwo, - NvttResizeFilter.NVTT_ResizeFilter_Box); - Assert(surface.Width <= 512 && surface.Height <= 512, - $"Expected ≤512 after resize, got {surface.Width}x{surface.Height}"); - Assert(IsPowerOfTwo(surface.Width) && IsPowerOfTwo(surface.Height), - $"Expected power-of-two after resize, got {surface.Width}x{surface.Height}"); - Console.WriteLine($"OK ({surface.Width}x{surface.Height})"); + NvttResizeFilter.NVTT_ResizeFilter_Box, null); + + Assert(pSurface->Width() <= 512 && pSurface->Height() <= 512, + $"Expected ≤512 after resize, got {pSurface->Width()}x{pSurface->Height()}"); + Assert(IsPowerOfTwo(pSurface->Width()) && IsPowerOfTwo(pSurface->Height()), + $"Expected power-of-two after resize, got {pSurface->Width()}x{pSurface->Height()}"); + + Console.WriteLine($"OK ({pSurface->Width()}x{pSurface->Height()})"); // ---- Test 6: sRGB → linear conversion --------------------------------- Console.Write("[Test 6] ToLinearFromSrgb ... "); - surface.ToLinearFromSrgb(); // must not crash + pSurface->ToLinearFromSrgb(null); // must not crash Console.WriteLine("OK"); // ---- Test 7: CountMipmaps --------------------------------------------- Console.Write("[Test 7] CountMipmaps ... "); - var mipCount = surface.CountMipmaps(); - var expectedMax = (int)Math.Log2(Math.Max(surface.Width, surface.Height)) + 1; + + var mipCount = pSurface->CountMipmaps(1); + var expectedMax = (int)Math.Log2(Math.Max(pSurface->Width(), pSurface->Height())) + 1; + Assert(mipCount > 0 && mipCount <= expectedMax, $"Unexpected mip count: {mipCount} (expected 1..{expectedMax})"); + Console.WriteLine($"OK ({mipCount} levels)"); - // ---- Test 8: In-memory BC7 compression + mip chain ------------------- + // ---- Test 8: In-memory BC7 compression + pMip chain ------------------- Console.Write("[Test 8] Compress BC7 in-memory ... "); - long totalBytesReceived = 0; + var totalBytesReceived = 0L; var imagesBegun = 0; - using var compOpts = new NvttCompressionOptionsHandle(); - compOpts.Format = NvttFormat.NVTT_Format_BC7; - compOpts.Quality = NvttQuality.NVTT_Quality_Fastest; + var pCompOpts = NvttCompressionOptions.Create(); + pCompOpts->SetFormat(NvttFormat.NVTT_Format_BC7); + pCompOpts->SetQuality(NvttQuality.NVTT_Quality_Fastest); - using var outOpts = new NvttOutputOptionsHandle(); - outOpts.OutputHeader = true; - outOpts.Srgb = true; - outOpts.Container = NvttContainer.NVTT_Container_DDS10; + var pOutOpts = NvttOutputOptions.Create(); + pOutOpts->SetOutputHeader(true); + pOutOpts->SetSrgbFlag(true); + pOutOpts->SetContainer(NvttContainer.NVTT_Container_DDS10); - outOpts.SetOutputHandler( - beginImage: (size, w, h, d, face, mip) => + pOutOpts->SetOutputHandler( + (size, w, h, d, face, mip) => { imagesBegun++; }, - outputData: (ptr, len) => + (ptr, len) => { totalBytesReceived += len; return true; }, - endImage: null + null ); - outOpts.SetErrorHandler(err => + pOutOpts->SetErrorHandler(err => Console.WriteLine($"/n [NVTT Error] {err}")); - using var ctx = new NvttContextHandle(); - ctx.SetCudaAcceleration(false); // CPU only for the test + var pCtx = NvttContext.Create(); + pCtx->SetCudaAcceleration(false); // CPU only for the test - using var mip = surface.Clone(); - var headerOk = ctx.OutputHeader(mip, mipCount, compOpts, outOpts); + var pMip = pSurface->Clone(); + var headerOk = pCtx->OutputHeader(pMip, mipCount, pCompOpts, pOutOpts); Assert(headerOk, "OutputHeader returned false"); for (var level = 0; level < mipCount; level++) { - var compressOk = ctx.Compress(mip, face: 0, mipmap: level, compOpts, outOpts); + var compressOk = pCtx->Compress(pMip, face: 0, mipmap: level, pCompOpts, pOutOpts); Assert(compressOk, $"Compress returned false at mip level {level}"); if (level + 1 < mipCount) - mip.BuildNextMipmap(NvttMipmapFilter.NVTT_MipmapFilter_Kaiser); + { + pMip->BuildNextMipmapDefaults(NvttMipmapFilter.NVTT_MipmapFilter_Kaiser, 1, null); + } } Assert(imagesBegun == mipCount, @@ -149,48 +157,75 @@ internal sealed unsafe class NvttBindingTest : ITest Console.WriteLine($"OK ({imagesBegun} mips, {totalBytesReceived:N0} bytes total)"); // ---- Test 9: EstimateSize consistency --------------------------------- + Console.Write("[Test 9] EstimateSize ... "); - var estimated = ctx.EstimateSize(surface, mipCount, compOpts); + var estimated = pCtx->EstimateSize(pSurface, mipCount, pCompOpts); + // Estimate can differ from actual due to header overhead; just sanity-check it's > 0. Assert(estimated > 0, $"EstimateSize returned {estimated}"); Console.WriteLine($"OK (estimated = {estimated:N0} bytes, actual = {totalBytesReceived:N0} bytes)"); // ---- Test 10: Output to real DDS file --------------------------------- Console.Write("[Test 10] Compress to file ... "); - using var outOptsFile = new NvttOutputOptionsHandle(); - outOptsFile.OutputHeader = true; - outOptsFile.Srgb = true; - outOptsFile.Container = NvttContainer.NVTT_Container_DDS10; - outOptsFile.FileName = _outputDdsPath; + var pOutOptsFile = NvttOutputOptions.Create(); + pOutOptsFile->SetOutputHeader(true); + pOutOptsFile->SetSrgbFlag(true); + pOutOptsFile->SetContainer(NvttContainer.NVTT_Container_DDS10); + pOutOptsFile->SetFileName(Encoding.UTF8.GetBytes(_outputDdsPath)); - using var ctxFile = new NvttContextHandle(); - using var mipFile = surface.Clone(); + var pCtxFile = NvttContext.Create(); + var pMipFile = pSurface->Clone(); - var fileHeaderOk = ctxFile.OutputHeader(mipFile, mipCount, compOpts, outOptsFile); + var fileHeaderOk = pCtxFile->OutputHeader(pMipFile, mipCount, pCompOpts, pOutOptsFile); Assert(fileHeaderOk, "File OutputHeader returned false"); for (var level = 0; level < mipCount; level++) { - var ok = ctxFile.Compress(mipFile, face: 0, mipmap: level, compOpts, outOptsFile); + var ok = pCtxFile->Compress(pMipFile, face: 0, mipmap: level, pCompOpts, pOutOptsFile); Assert(ok, $"File Compress returned false at level {level}"); if (level + 1 < mipCount) - mipFile.BuildNextMipmap(NvttMipmapFilter.NVTT_MipmapFilter_Kaiser); + { + pMipFile->BuildNextMipmapDefaults(NvttMipmapFilter.NVTT_MipmapFilter_Kaiser, 1, null); + } } - Assert(File.Exists(_outputDdsPath), - $"DDS output file was not created: {_outputDdsPath}"); + Assert(File.Exists(_outputDdsPath), $"DDS output file was not created: {_outputDdsPath}"); + var fileSize = new FileInfo(_outputDdsPath).Length; Assert(fileSize > 128, $"DDS file suspiciously small: {fileSize} bytes"); + Console.WriteLine($"OK ({fileSize:N0} bytes → {_outputDdsPath})"); - Console.WriteLine("/n[NvttBindingTest] All tests PASSED."); + Console.WriteLine("[NvttBindingTest] All tests PASSED."); + + pMipFile->Dispose(); + pCtxFile->Dispose(); + pOutOptsFile->Dispose(); + pMip->Dispose(); + pCtx->Dispose(); + pOutOpts->Dispose(); + pCompOpts->Dispose(); + pSurface->Dispose(); + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static void CallBack(NvttSeverity severity, NvttError error, sbyte* msg, void* userData) + { + (*(int*)userData)++; + + int i = 0; + while (msg[i] != 0) + { + i++; + } + + Console.WriteLine($"/n [NVTT] [{severity}] {error}: {Encoding.UTF8.GetString((byte*)msg, i)}"); } public void Cleanup() { - // Leave the DDS file in place so you can inspect it. - Console.WriteLine($"/n[NvttBindingTest] Output DDS left at: {_outputDdsPath}"); + Console.WriteLine($"[NvttBindingTest] Output DDS left at: {_outputDdsPath}"); } // ------------------------------------------------------------------------- @@ -198,7 +233,9 @@ internal sealed unsafe class NvttBindingTest : ITest private static void Assert(bool condition, string message) { if (!condition) + { throw new InvalidOperationException($"[ASSERTION FAILED] {message}"); + } } private static bool IsPowerOfTwo(int n) diff --git a/src/Test/Ghost.MicroTest/UfbxBindingTest.cs b/src/Test/Ghost.MicroTest/UfbxBindingTest.cs index 3d63e58..a435075 100644 --- a/src/Test/Ghost.MicroTest/UfbxBindingTest.cs +++ b/src/Test/Ghost.MicroTest/UfbxBindingTest.cs @@ -3,69 +3,50 @@ using Ghost.Ufbx; namespace Ghost.MicroTest; -internal class UfbxBindingTest : ITest +internal unsafe class UfbxBindingTest : ITest { - private static ReadOnlySpan TestFilePath => "F:/c/Third Parties/ufbx/data/blender_340_z_up_7400_binary.fbx"u8; - public void Setup() { } public void Run() { - // Smoke-test LoadOpts heap-pointer shape (construct, set, read back, dispose) - using var opts = new LoadOpts(); - opts.IgnoreAnimation = true; - opts.IgnoreEmbedded = true; + var load_Opts = new ufbx_load_opts(); + var error = new ufbx_error(); - // Load scene using the safe high-level wrapper (no unsafe, no fixed blocks) - using var scene = Scene.LoadFile(TestFilePath, opts); + var pScene = ufbx_scene.load_file_len("F:/c/Third Parties/ufbx/data/blender_340_z_up_7400_binary.fbx"u8, &load_Opts, &error); - // Enumerate nodes using the wrapper's NodeList (ref struct, no allocation) - for (var i = 0; i < scene.Nodes.Count; i++) + if (pScene == null) { - var node = scene.Nodes[i]; - if (node.IsRoot) + Console.WriteLine(error.description.ToString()); + } + + for (var i = 0u; i < pScene->nodes.count; i++) + { + var node = pScene->nodes.data[i]; + if (node->is_root) { continue; } - // node.Name is a string property — no manual ToString() needed - Console.WriteLine($"Object: {node.Name}"); + Console.WriteLine($"Object: {node->name}"); - if (node.HasMesh) + if (node->mesh != null) { - Console.WriteLine($"-> mesh with {node.Mesh.NumFaces} faces"); + Console.WriteLine($"-> mesh with {node->mesh->num_faces} faces"); + Console.WriteLine($"-> mesh with positions: {node->local_transform.translation}"); + } + + for (var j = 0u; j < node->materials.count; j++) + { + var mat = node->materials.data[j]; + Console.WriteLine("-> material: " + mat->name); + Console.WriteLine(" -> shader type: " + mat->shader_type); + Console.WriteLine(" -> texture count: " + mat->textures.count); } } - // Find a node by name using the new instance method (no unsafe, no fixed) - var rootNode = scene.FindNode("RootNode"u8); - if (!rootNode.IsNull) - { - Console.WriteLine($"Found root node: {rootNode.Name}"); - } - - // Find a material by name - var material = scene.FindMaterial("Material"u8); - if (!material.IsNull) - { - Console.WriteLine($"Found material: {material.Name}"); - // Find a prop on the material's props using the instance method - var prop = material.Props.FindProp("DiffuseColor"u8); - if (!prop.IsNull) - { - Console.WriteLine($" DiffuseColor prop type: {prop.Type}"); - } - } - - // Find an anim stack - var animStack = scene.FindAnimStack("Take 001"u8); - if (!animStack.IsNull) - { - Console.WriteLine($"Found anim stack: {animStack.Name}"); - } - + pScene->free(); Console.WriteLine("Done."); } diff --git a/src/ThridParty/Ghost.MeshOptimizer/Api.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/Api.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/Api.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/Api.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/NativeAnnotationAttribute.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/NativeAnnotationAttribute.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/NativeAnnotationAttribute.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/NativeAnnotationAttribute.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/NativeTypeNameAttribute.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/NativeTypeNameAttribute.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/NativeTypeNameAttribute.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/NativeTypeNameAttribute.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_Allocator.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_Allocator.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_Allocator.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_Allocator.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_Bounds.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_Bounds.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_Bounds.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_Bounds.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_CoverageStatistics.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_CoverageStatistics.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_CoverageStatistics.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_CoverageStatistics.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_EncodeExpMode.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_EncodeExpMode.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_EncodeExpMode.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_EncodeExpMode.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_Meshlet.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_Meshlet.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_Meshlet.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_Meshlet.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_OverdrawStatistics.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_OverdrawStatistics.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_OverdrawStatistics.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_OverdrawStatistics.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_SimplifyOptions.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_SimplifyOptions.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_SimplifyOptions.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_SimplifyOptions.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_SimplifyVertexFlags.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_SimplifyVertexFlags.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_SimplifyVertexFlags.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_SimplifyVertexFlags.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_Stream.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_Stream.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_Stream.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_Stream.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_VertexCacheStatistics.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_VertexCacheStatistics.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_VertexCacheStatistics.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_VertexCacheStatistics.cs diff --git a/src/ThridParty/Ghost.MeshOptimizer/meshopt_VertexFetchStatistics.cs b/src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_VertexFetchStatistics.cs similarity index 100% rename from src/ThridParty/Ghost.MeshOptimizer/meshopt_VertexFetchStatistics.cs rename to src/ThridParty/Ghost.MeshOptimizer/Generated/meshopt_VertexFetchStatistics.cs diff --git a/src/ThridParty/Ghost.Nvtt/Generated/NvttBoolean.cs b/src/ThridParty/Ghost.Nvtt/Generated/NvttBoolean.cs index cb19b8a..5d1c2fb 100644 --- a/src/ThridParty/Ghost.Nvtt/Generated/NvttBoolean.cs +++ b/src/ThridParty/Ghost.Nvtt/Generated/NvttBoolean.cs @@ -1,8 +1,63 @@ namespace Ghost.Nvtt { - public enum NvttBoolean + //public enum NvttBoolean + //{ + // NVTT_False, + // NVTT_True, + //} + + // The native NVTT API uses an enum for boolean values, but we want to expose it as a struct that can be implicitly converted to/from C# bool for better ergonomics. + // Since the binary layout of a struct with a single int field is the same as an enum, this should be safe for interop. + public readonly struct NvttBoolean : IEquatable { - NVTT_False, - NVTT_True, + public static NvttBoolean NVTT_False => new(0); + public static NvttBoolean NVTT_True => new(1); + + private readonly int _value; + + public NvttBoolean(int value) + { + _value = value; + } + + public bool Equals(NvttBoolean other) + { + return _value == other._value; + } + + public override bool Equals(object? obj) + { + return obj is NvttBoolean && Equals((NvttBoolean)obj); + } + + public override int GetHashCode() + { + return _value; + } + + public override string ToString() + { + return _value.ToString(); + } + + public static bool operator ==(NvttBoolean left, NvttBoolean right) + { + return left.Equals(right); + } + + public static bool operator !=(NvttBoolean left, NvttBoolean right) + { + return !(left == right); + } + + public static implicit operator NvttBoolean(bool value) + { + return value ? NVTT_True : NVTT_False; + } + + public static implicit operator bool(NvttBoolean value) + { + return value._value != 0; + } } } diff --git a/src/ThridParty/Ghost.Nvtt/NvttOutputOptions.cs b/src/ThridParty/Ghost.Nvtt/NvttOutputOptions.cs new file mode 100644 index 0000000..cce7926 --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/NvttOutputOptions.cs @@ -0,0 +1,34 @@ +using System.Runtime.InteropServices; + +namespace Ghost.Nvtt; + +public delegate void BeginImageDelegate(int w, int h, int d, int f, int m, int t); +public delegate NvttBoolean OutputDelegate(IntPtr data, int size); +public delegate void EndImageDelegate(); + +public delegate void ErrorDelegate(NvttError error); + +public unsafe partial struct NvttOutputOptions +{ + public void SetOutputHandler(BeginImageDelegate? beginImageHandler, OutputDelegate? outputHandler, EndImageDelegate? endImageHandler) + { + var beginPtr = beginImageHandler == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(beginImageHandler); + var outputPtr = outputHandler == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(outputHandler); + var endPtr = endImageHandler == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(endImageHandler); + + Api.nvttSetOutputOptionsOutputHandler( + (NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (delegate* unmanaged[Cdecl])beginPtr, + (delegate* unmanaged[Cdecl])outputPtr, + endPtr); + } + + public void SetErrorHandler(ErrorDelegate? errorHandler) + { + var errorPtr = errorHandler == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(errorHandler); + + Api.nvttSetOutputOptionsErrorHandler( + (NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (delegate* unmanaged[Cdecl])errorPtr); + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Utility.cs b/src/ThridParty/Ghost.Nvtt/Utility.cs new file mode 100644 index 0000000..da07665 --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Utility.cs @@ -0,0 +1,11 @@ +namespace Ghost.Nvtt; + +public static class Utility +{ + //extension(NvttBoolean boolean) + //{ + // public static bool operator true(NvttBoolean b) => b == NvttBoolean.NVTT_True; + // public static bool operator false(NvttBoolean b) => b == NvttBoolean.NVTT_False; + // public static bool operator !(NvttBoolean b) => b == NvttBoolean.NVTT_False; + //} +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttBatchList.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttBatchList.cs deleted file mode 100644 index fc11351..0000000 --- a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttBatchList.cs +++ /dev/null @@ -1,91 +0,0 @@ -namespace Ghost.Nvtt.Wrapper; - -/// -/// Wrapper around an nvtt batch list — a list of (surface, face, mipmap, -/// outputOptions) tuples passed to . -/// -public sealed unsafe class NvttBatchListHandle : IDisposable -{ - private NvttBatchList* _ptr; - - /// Raw pointer - use only when calling the native API directly. - public NvttBatchList* Ptr => _ptr; - - // ------------------------------------------------------------------------- - // Construction / destruction - // ------------------------------------------------------------------------- - - public NvttBatchListHandle() => _ptr = Api.nvttCreateBatchList(); - - public void Dispose() - { - if (_ptr != null) - { - Api.nvttDestroyBatchList(_ptr); - _ptr = null; - } - } - - // ------------------------------------------------------------------------- - // Mutation - // ------------------------------------------------------------------------- - - /// Removes all items from the list. - public void Clear() - { - ThrowIfDisposed(); - Api.nvttBatchListClear(_ptr); - } - - /// - /// Appends an entry. The and - /// must remain alive for the duration of - /// any subsequent call. - /// - public void Append(NvttSurfaceHandle surface, int face, int mipmap, - NvttOutputOptionsHandle outputOptions) - { - ThrowIfDisposed(); - Api.nvttBatchListAppend(_ptr, surface.Ptr, face, mipmap, - outputOptions.Ptr); - } - - // ------------------------------------------------------------------------- - // Query - // ------------------------------------------------------------------------- - - /// Number of items currently in the list. - public uint Count - { - get { ThrowIfDisposed(); return Api.nvttBatchListGetSize(_ptr); } - } - - /// - /// Returns the raw pointers for item . - /// The pointers are borrowed - do NOT dispose them. - /// - public void GetItem(uint index, - out NvttSurface* surface, out int face, out int mipmap, - out NvttOutputOptions* outputOptions) - { - ThrowIfDisposed(); - NvttSurface* s; - NvttOutputOptions* o; - int f, m; - Api.nvttBatchListGetItem(_ptr, index, &s, &f, &m, &o); - surface = s; - face = f; - mipmap = m; - outputOptions = o; - } - - // ------------------------------------------------------------------------- - - private void ThrowIfDisposed() - { - if (_ptr == null) - { - throw new ObjectDisposedException(nameof(NvttBatchListHandle)); - } - } -} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttBatchList.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttBatchList.nativegen.cs new file mode 100644 index 0000000..1955383 --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttBatchList.nativegen.cs @@ -0,0 +1,55 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttBatchList : System.IDisposable +{ + // From: nvttCreateBatchList() + public static NvttBatchList* Create() + { + return Api.nvttCreateBatchList(); + } + + // From: nvttDestroyBatchList(NvttBatchList*) + public void Dispose() + { + Api.nvttDestroyBatchList((NvttBatchList*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttBatchListClear(NvttBatchList*) + public void Clear() + { + Api.nvttBatchListClear((NvttBatchList*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttBatchListAppend(NvttBatchList*, NvttSurface*, int, int, NvttOutputOptions*) + public void Append(NvttSurface* pImg, int face, int mipmap, NvttOutputOptions* outputOptions) + { + Api.nvttBatchListAppend( + (NvttBatchList*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + pImg, + face, + mipmap, + outputOptions); + } + + // From: nvttBatchListGetSize(NvttBatchList*) + public uint GetSize() + { + return Api.nvttBatchListGetSize((NvttBatchList*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttBatchListGetItem(NvttBatchList*, uint, NvttSurface**, int*, int*, NvttOutputOptions**) + public void GetItem(uint i, NvttSurface** pImg, int* face, int* mipmap, NvttOutputOptions** outputOptions) + { + Api.nvttBatchListGetItem( + (NvttBatchList*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + i, + pImg, + face, + mipmap, + outputOptions); + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCPUInputBuffer.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCPUInputBuffer.nativegen.cs new file mode 100644 index 0000000..9533871 --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCPUInputBuffer.nativegen.cs @@ -0,0 +1,212 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttCPUInputBuffer : System.IDisposable +{ + // From: nvttDestroyCPUInputBuffer(NvttCPUInputBuffer*) + public void Dispose() + { + Api.nvttDestroyCPUInputBuffer((NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttCPUInputBufferNumTiles(NvttCPUInputBuffer*) + public int NumTiles() + { + return Api.nvttCPUInputBufferNumTiles((NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttCPUInputBufferTileSize(NvttCPUInputBuffer*, int*, int*) + public void TileSize(int* tile_w, int* tile_h) + { + Api.nvttCPUInputBufferTileSize( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tile_w, + tile_h); + } + + // From: nvttCPUInputBufferType(NvttCPUInputBuffer*) + public NvttValueType Type() + { + return Api.nvttCPUInputBufferType((NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttEncodeCPU(NvttCPUInputBuffer*, void*, NvttEncodeSettings*) + public NvttBoolean EncodeCPU(void* output, NvttEncodeSettings* settings) + { + return Api.nvttEncodeCPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + settings); + } + + // From: nvttEncodeBC1CPU(NvttCPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC1CPU(NvttBoolean fast_mode, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC1CPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + fast_mode, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeBC1ACPU(NvttCPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC1ACPU(NvttBoolean fast_mode, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC1ACPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + fast_mode, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeBC2CPU(NvttCPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC2CPU(NvttBoolean fast_mode, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC2CPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + fast_mode, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeBC3CPU(NvttCPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC3CPU(NvttBoolean fast_mode, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC3CPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + fast_mode, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeBC3NCPU(NvttCPUInputBuffer*, int, void*, NvttTimingContext*) + public void EncodeBC3NCPU(int qualityLevel, void* output, NvttTimingContext* tc) + { + Api.nvttEncodeBC3NCPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + qualityLevel, + output, + tc); + } + + // From: nvttEncodeBC3RGBMCPU(NvttCPUInputBuffer*, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC3RGBMCPU(void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC3RGBMCPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeBC4CPU(NvttCPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC4CPU(NvttBoolean slow_mode, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC4CPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + slow_mode, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeBC4SCPU(NvttCPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC4SCPU(NvttBoolean slow_mode, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC4SCPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + slow_mode, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeATI2CPU(NvttCPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeATI2CPU(NvttBoolean slow_mode, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeATI2CPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + slow_mode, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeBC5CPU(NvttCPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC5CPU(NvttBoolean slow_mode, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC5CPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + slow_mode, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeBC5SCPU(NvttCPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC5SCPU(NvttBoolean slow_mode, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC5SCPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + slow_mode, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeBC6HCPU(NvttCPUInputBuffer*, NvttBoolean, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC6HCPU(NvttBoolean slow_mode, NvttBoolean is_signed, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC6HCPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + slow_mode, + is_signed, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeBC7CPU(NvttCPUInputBuffer*, NvttBoolean, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeBC7CPU(NvttBoolean slow_mode, NvttBoolean imageHasAlpha, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC7CPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + slow_mode, + imageHasAlpha, + output, + useGpu, + to_device_mem, + tc); + } + + // From: nvttEncodeASTCCPU(NvttCPUInputBuffer*, int, NvttBoolean, void*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void EncodeASTCCPU(int qualityLevel, NvttBoolean imageHasAlpha, void* output, NvttBoolean useGpu, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeASTCCPU( + (NvttCPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + qualityLevel, + imageHasAlpha, + output, + useGpu, + to_device_mem, + tc); + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCompressionOptions.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCompressionOptions.cs deleted file mode 100644 index 263a189..0000000 --- a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCompressionOptions.cs +++ /dev/null @@ -1,123 +0,0 @@ -namespace Ghost.Nvtt.Wrapper; - -/// -/// Controls how a surface is compressed - format, quality, pixel layout and -/// optional quantization settings. -/// -public sealed unsafe class NvttCompressionOptionsHandle : IDisposable -{ - private NvttCompressionOptions* _ptr; - - /// Raw pointer - use only when calling the native API directly. - public NvttCompressionOptions* Ptr => _ptr; - - // ------------------------------------------------------------------------- - // Construction / destruction - // ------------------------------------------------------------------------- - - public NvttCompressionOptionsHandle() => _ptr = Api.nvttCreateCompressionOptions(); - - public void Dispose() - { - if (_ptr != null) - { - Api.nvttDestroyCompressionOptions(_ptr); - _ptr = null; - } - } - - // ------------------------------------------------------------------------- - // Properties - // ------------------------------------------------------------------------- - - /// Target compressed format (e.g. BC1, BC7, ASTC …). - public NvttFormat Format - { - set { ThrowIfDisposed(); Api.nvttSetCompressionOptionsFormat(_ptr, value); } - } - - /// Compression quality preset. - public NvttQuality Quality - { - set { ThrowIfDisposed(); Api.nvttSetCompressionOptionsQuality(_ptr, value); } - } - - /// Pixel type for uncompressed RGB(A) output. - public NvttPixelType PixelType - { - set { ThrowIfDisposed(); Api.nvttSetCompressionOptionsPixelType(_ptr, value); } - } - - /// Row-pitch alignment in bytes for uncompressed output. - public int PitchAlignment - { - set { ThrowIfDisposed(); Api.nvttSetCompressionOptionsPitchAlignment(_ptr, value); } - } - - // ------------------------------------------------------------------------- - // Methods - // ------------------------------------------------------------------------- - - /// Resets all options to their default values. - public void Reset() - { - ThrowIfDisposed(); - Api.nvttResetCompressionOptions(_ptr); - } - - /// - /// Sets per-channel importance weights used during block-compression error - /// minimisation. - /// - public void SetColorWeights(float red, float green, float blue, float alpha = 1f) - { - ThrowIfDisposed(); - Api.nvttSetCompressionOptionsColorWeights(_ptr, red, green, blue, alpha); - } - - /// - /// Configures a custom uncompressed pixel format by specifying the bit-depth - /// and per-channel bit masks. - /// - public void SetPixelFormat(uint bitCount, uint rMask, uint gMask, uint bMask, uint aMask) - { - ThrowIfDisposed(); - Api.nvttSetCompressionOptionsPixelFormat(_ptr, bitCount, rMask, gMask, bMask, aMask); - } - - /// - /// Enables or disables dithering and binary-alpha quantisation. - /// - /// Dither RGB channels. - /// Dither the alpha channel. - /// Snap alpha to 0 or 255. - /// Threshold used when is true. - public void SetQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, - int alphaThreshold = 127) - { - ThrowIfDisposed(); - Api.nvttSetCompressionOptionsQuantization( - _ptr, - NvttInterop.ToNvtt(colorDithering), - NvttInterop.ToNvtt(alphaDithering), - NvttInterop.ToNvtt(binaryAlpha), - alphaThreshold); - } - - /// Returns the D3D9 FourCC / D3DFORMAT value for the current settings. - public uint GetD3D9Format() - { - ThrowIfDisposed(); - return Api.nvttGetCompressionOptionsD3D9Format(_ptr); - } - - // ------------------------------------------------------------------------- - - private void ThrowIfDisposed() - { - if (_ptr == null) - { - throw new ObjectDisposedException(nameof(NvttCompressionOptionsHandle)); - } - } -} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCompressionOptions.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCompressionOptions.nativegen.cs new file mode 100644 index 0000000..9ed0e27 --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCompressionOptions.nativegen.cs @@ -0,0 +1,98 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttCompressionOptions : System.IDisposable +{ + // From: nvttCreateCompressionOptions() + public static NvttCompressionOptions* Create() + { + return Api.nvttCreateCompressionOptions(); + } + + // From: nvttDestroyCompressionOptions(NvttCompressionOptions*) + public void Dispose() + { + Api.nvttDestroyCompressionOptions((NvttCompressionOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttResetCompressionOptions(NvttCompressionOptions*) + public void Reset() + { + Api.nvttResetCompressionOptions((NvttCompressionOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSetCompressionOptionsFormat(NvttCompressionOptions*, NvttFormat) + public void SetFormat(NvttFormat format) + { + Api.nvttSetCompressionOptionsFormat( + (NvttCompressionOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + format); + } + + // From: nvttSetCompressionOptionsQuality(NvttCompressionOptions*, NvttQuality) + public void SetQuality(NvttQuality quality) + { + Api.nvttSetCompressionOptionsQuality( + (NvttCompressionOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + quality); + } + + // From: nvttSetCompressionOptionsColorWeights(NvttCompressionOptions*, float, float, float, float) + public void SetColorWeights(float red, float green, float blue, float alpha) + { + Api.nvttSetCompressionOptionsColorWeights( + (NvttCompressionOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + red, + green, + blue, + alpha); + } + + // From: nvttSetCompressionOptionsPixelFormat(NvttCompressionOptions*, uint, uint, uint, uint, uint) + public void SetPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) + { + Api.nvttSetCompressionOptionsPixelFormat( + (NvttCompressionOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + bitcount, + rmask, + gmask, + bmask, + amask); + } + + // From: nvttSetCompressionOptionsPixelType(NvttCompressionOptions*, NvttPixelType) + public void SetPixelType(NvttPixelType pixelType) + { + Api.nvttSetCompressionOptionsPixelType( + (NvttCompressionOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + pixelType); + } + + // From: nvttSetCompressionOptionsPitchAlignment(NvttCompressionOptions*, int) + public void SetPitchAlignment(int pitchAlignment) + { + Api.nvttSetCompressionOptionsPitchAlignment( + (NvttCompressionOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + pitchAlignment); + } + + // From: nvttSetCompressionOptionsQuantization(NvttCompressionOptions*, NvttBoolean, NvttBoolean, NvttBoolean, int) + public void SetQuantization(NvttBoolean colorDithering, NvttBoolean alphaDithering, NvttBoolean binaryAlpha, int alphaThreshold) + { + Api.nvttSetCompressionOptionsQuantization( + (NvttCompressionOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + colorDithering, + alphaDithering, + binaryAlpha, + alphaThreshold); + } + + // From: nvttGetCompressionOptionsD3D9Format(NvttCompressionOptions*) + public uint GetD3D9Format() + { + return Api.nvttGetCompressionOptionsD3D9Format((NvttCompressionOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttContext.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttContext.cs deleted file mode 100644 index 3e16672..0000000 --- a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttContext.cs +++ /dev/null @@ -1,229 +0,0 @@ -namespace Ghost.Nvtt.Wrapper; - -/// -/// Wrapper around the nvtt compression context — the central object that drives -/// the compression pipeline. -/// -public sealed unsafe class NvttContextHandle : IDisposable -{ - private NvttContext* _ptr; - - /// Raw pointer - use only when calling the native API directly. - public NvttContext* Ptr => _ptr; - - // ------------------------------------------------------------------------- - // Construction / destruction - // ------------------------------------------------------------------------- - - public NvttContextHandle() => _ptr = Api.nvttCreateContext(); - - public void Dispose() - { - if (_ptr != null) - { - Api.nvttDestroyContext(_ptr); - _ptr = null; - } - } - - // ------------------------------------------------------------------------- - // CUDA acceleration - // ------------------------------------------------------------------------- - - /// Enables or disables CUDA-accelerated compression. - public void SetCudaAcceleration(bool enable) - { - ThrowIfDisposed(); - Api.nvttSetContextCudaAcceleration(_ptr, NvttInterop.ToNvtt(enable)); - } - - /// Returns true if CUDA acceleration is currently enabled. - public bool IsCudaAccelerationEnabled - { - get - { - ThrowIfDisposed(); - return NvttInterop.ToBool(Api.nvttContextIsCudaAccelerationEnabled(_ptr)); - } - } - - // ------------------------------------------------------------------------- - // Timing - // ------------------------------------------------------------------------- - - /// - /// Enables or disables internal timing collection. - /// controls the granularity (0 = off, higher = more detail). - /// - public void EnableTiming(bool enable, int detailLevel = 1) - { - ThrowIfDisposed(); - Api.nvttContextEnableTiming(_ptr, NvttInterop.ToNvtt(enable), detailLevel); - } - - /// - /// Returns the timing context owned by this nvtt context. - /// The pointer is borrowed - do NOT dispose it separately. - /// Returns null if timing was never enabled. - /// - public NvttTimingContext* GetTimingContextPtr() - { - ThrowIfDisposed(); - return Api.nvttContextGetTimingContext(_ptr); - } - - // ------------------------------------------------------------------------- - // Estimate size - // ------------------------------------------------------------------------- - - /// - /// Estimates the compressed size in bytes for - /// mip levels of using . - /// - public int EstimateSize(NvttSurfaceHandle img, int mipmapCount, - NvttCompressionOptionsHandle compressionOptions) - { - ThrowIfDisposed(); - return Api.nvttContextEstimateSize(_ptr, img.Ptr, mipmapCount, - compressionOptions.Ptr); - } - - /// Estimates the compressed size for a cube map. - public int EstimateSizeCube(NvttCubeSurfaceHandle img, int mipmapCount, - NvttCompressionOptionsHandle compressionOptions) - { - ThrowIfDisposed(); - return Api.nvttContextEstimateSizeCube(_ptr, img.Ptr, mipmapCount, - compressionOptions.Ptr); - } - - /// Estimates the compressed size for raw-data dimensions. - public int EstimateSizeData(int w, int h, int d, int mipmapCount, - NvttCompressionOptionsHandle compressionOptions) - { - ThrowIfDisposed(); - return Api.nvttContextEstimateSizeData(_ptr, w, h, d, mipmapCount, - compressionOptions.Ptr); - } - - // ------------------------------------------------------------------------- - // Output header - // ------------------------------------------------------------------------- - - /// - /// Writes the DDS / KTX header to . - /// Must be called once before compressing mip levels. - /// Returns false on failure. - /// - public bool OutputHeader(NvttSurfaceHandle img, int mipmapCount, - NvttCompressionOptionsHandle compressionOptions, NvttOutputOptionsHandle outputOptions) - { - ThrowIfDisposed(); - return NvttInterop.ToBool( - Api.nvttContextOutputHeader(_ptr, img.Ptr, mipmapCount, - compressionOptions.Ptr, outputOptions.Ptr)); - } - - /// Writes the header for a cube-map texture. - public bool OutputHeaderCube(NvttCubeSurfaceHandle img, int mipmapCount, - NvttCompressionOptionsHandle compressionOptions, NvttOutputOptionsHandle outputOptions) - { - ThrowIfDisposed(); - return NvttInterop.ToBool( - Api.nvttContextOutputHeaderCube(_ptr, img.Ptr, mipmapCount, - compressionOptions.Ptr, outputOptions.Ptr)); - } - - /// Writes the header using explicit dimensions instead of a surface. - public bool OutputHeaderData(NvttTextureType type, int w, int h, int d, - int mipmapCount, bool isNormalMap, - NvttCompressionOptionsHandle compressionOptions, NvttOutputOptionsHandle outputOptions) - { - ThrowIfDisposed(); - return NvttInterop.ToBool( - Api.nvttContextOutputHeaderData(_ptr, type, w, h, d, mipmapCount, - NvttInterop.ToNvtt(isNormalMap), - compressionOptions.Ptr, outputOptions.Ptr)); - } - - // ------------------------------------------------------------------------- - // Compress - // ------------------------------------------------------------------------- - - /// - /// Compresses a single face/mip of and sends the - /// result to . - /// Returns false on failure. - /// - public bool Compress(NvttSurfaceHandle img, int face, int mipmap, - NvttCompressionOptionsHandle compressionOptions, NvttOutputOptionsHandle outputOptions) - { - ThrowIfDisposed(); - return NvttInterop.ToBool( - Api.nvttContextCompress(_ptr, img.Ptr, face, mipmap, - compressionOptions.Ptr, outputOptions.Ptr)); - } - - /// Compresses a single mip of a cube-map face. - public bool CompressCube(NvttCubeSurfaceHandle img, int mipmap, - NvttCompressionOptionsHandle compressionOptions, NvttOutputOptionsHandle outputOptions) - { - ThrowIfDisposed(); - return NvttInterop.ToBool( - Api.nvttContextCompressCube(_ptr, img.Ptr, mipmap, - compressionOptions.Ptr, outputOptions.Ptr)); - } - - /// Compresses a single mip from a raw float RGBA buffer. - public bool CompressData(int w, int h, int d, int face, int mipmap, - ReadOnlySpan rgba, - NvttCompressionOptionsHandle compressionOptions, NvttOutputOptionsHandle outputOptions) - { - ThrowIfDisposed(); - fixed (float* p = rgba) - { - return NvttInterop.ToBool( - Api.nvttContextCompressData(_ptr, w, h, d, face, mipmap, p, - compressionOptions.Ptr, outputOptions.Ptr)); - } - } - - /// - /// Compresses a batch of (surface, face, mipmap, outputOptions) entries - /// using the shared . - /// Returns false on failure. - /// - public bool CompressBatch(NvttBatchListHandle batchList, - NvttCompressionOptionsHandle compressionOptions) - { - ThrowIfDisposed(); - return NvttInterop.ToBool( - Api.nvttContextCompressBatch(_ptr, batchList.Ptr, - compressionOptions.Ptr)); - } - - // ------------------------------------------------------------------------- - // Quantize - // ------------------------------------------------------------------------- - - /// - /// Quantizes in place according to - /// (useful before compressing - /// to formats that only support limited bit depths). - /// - public void Quantize(NvttSurfaceHandle surface, NvttCompressionOptionsHandle compressionOptions) - { - ThrowIfDisposed(); - Api.nvttContextQuantize(_ptr, surface.Ptr, compressionOptions.Ptr); - } - - // ------------------------------------------------------------------------- - - private void ThrowIfDisposed() - { - if (_ptr == null) - { - throw new ObjectDisposedException(nameof(NvttContextHandle)); - } - } -} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttContext.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttContext.nativegen.cs new file mode 100644 index 0000000..528631d --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttContext.nativegen.cs @@ -0,0 +1,174 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttContext : System.IDisposable +{ + // From: nvttCreateContext() + public static NvttContext* Create() + { + return Api.nvttCreateContext(); + } + + // From: nvttDestroyContext(NvttContext*) + public void Dispose() + { + Api.nvttDestroyContext((NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSetContextCudaAcceleration(NvttContext*, NvttBoolean) + public void SetCudaAcceleration(NvttBoolean enable) + { + Api.nvttSetContextCudaAcceleration( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + enable); + } + + // From: nvttContextIsCudaAccelerationEnabled(NvttContext*) + public NvttBoolean IsCudaAccelerationEnabled() + { + return Api.nvttContextIsCudaAccelerationEnabled((NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttContextOutputHeader(NvttContext*, NvttSurface*, int, NvttCompressionOptions*, NvttOutputOptions*) + public NvttBoolean OutputHeader(NvttSurface* img, int mipmapCount, NvttCompressionOptions* compressionOptions, NvttOutputOptions* outputOptions) + { + return Api.nvttContextOutputHeader( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + mipmapCount, + compressionOptions, + outputOptions); + } + + // From: nvttContextCompress(NvttContext*, NvttSurface*, int, int, NvttCompressionOptions*, NvttOutputOptions*) + public NvttBoolean Compress(NvttSurface* img, int face, int mipmap, NvttCompressionOptions* compressionOptions, NvttOutputOptions* outputOptions) + { + return Api.nvttContextCompress( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + face, + mipmap, + compressionOptions, + outputOptions); + } + + // From: nvttContextEstimateSize(NvttContext*, NvttSurface*, int, NvttCompressionOptions*) + public int EstimateSize(NvttSurface* img, int mipmapCount, NvttCompressionOptions* compressionOptions) + { + return Api.nvttContextEstimateSize( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + mipmapCount, + compressionOptions); + } + + // From: nvttContextQuantize(NvttContext*, NvttSurface*, NvttCompressionOptions*) + public void Quantize(NvttSurface* tex, NvttCompressionOptions* compressionOptions) + { + Api.nvttContextQuantize( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tex, + compressionOptions); + } + + // From: nvttContextOutputHeaderCube(NvttContext*, NvttCubeSurface*, int, NvttCompressionOptions*, NvttOutputOptions*) + public NvttBoolean OutputHeaderCube(NvttCubeSurface* img, int mipmapCount, NvttCompressionOptions* compressionOptions, NvttOutputOptions* outputOptions) + { + return Api.nvttContextOutputHeaderCube( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + mipmapCount, + compressionOptions, + outputOptions); + } + + // From: nvttContextCompressCube(NvttContext*, NvttCubeSurface*, int, NvttCompressionOptions*, NvttOutputOptions*) + public NvttBoolean CompressCube(NvttCubeSurface* img, int mipmap, NvttCompressionOptions* compressionOptions, NvttOutputOptions* outputOptions) + { + return Api.nvttContextCompressCube( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + mipmap, + compressionOptions, + outputOptions); + } + + // From: nvttContextEstimateSizeCube(NvttContext*, NvttCubeSurface*, int, NvttCompressionOptions*) + public int EstimateSizeCube(NvttCubeSurface* img, int mipmapCount, NvttCompressionOptions* compressionOptions) + { + return Api.nvttContextEstimateSizeCube( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + mipmapCount, + compressionOptions); + } + + // From: nvttContextOutputHeaderData(NvttContext*, NvttTextureType, int, int, int, int, NvttBoolean, NvttCompressionOptions*, NvttOutputOptions*) + public NvttBoolean OutputHeaderData(NvttTextureType type, int w, int h, int d, int mipmapCount, NvttBoolean isNormalMap, NvttCompressionOptions* compressionOptions, NvttOutputOptions* outputOptions) + { + return Api.nvttContextOutputHeaderData( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + type, + w, + h, + d, + mipmapCount, + isNormalMap, + compressionOptions, + outputOptions); + } + + // From: nvttContextCompressData(NvttContext*, int, int, int, int, int, float*, NvttCompressionOptions*, NvttOutputOptions*) + public NvttBoolean CompressData(int w, int h, int d, int face, int mipmap, float* rgba, NvttCompressionOptions* compressionOptions, NvttOutputOptions* outputOptions) + { + return Api.nvttContextCompressData( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + w, + h, + d, + face, + mipmap, + rgba, + compressionOptions, + outputOptions); + } + + // From: nvttContextEstimateSizeData(NvttContext*, int, int, int, int, NvttCompressionOptions*) + public int EstimateSizeData(int w, int h, int d, int mipmapCount, NvttCompressionOptions* compressionOptions) + { + return Api.nvttContextEstimateSizeData( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + w, + h, + d, + mipmapCount, + compressionOptions); + } + + // From: nvttContextCompressBatch(NvttContext*, NvttBatchList*, NvttCompressionOptions*) + public NvttBoolean CompressBatch(NvttBatchList* lst, NvttCompressionOptions* compressionOptions) + { + return Api.nvttContextCompressBatch( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + lst, + compressionOptions); + } + + // From: nvttContextEnableTiming(NvttContext*, NvttBoolean, int) + public void EnableTiming(NvttBoolean enable, int detailLevel) + { + Api.nvttContextEnableTiming( + (NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + enable, + detailLevel); + } + + // From: nvttContextGetTimingContext(NvttContext*) + public NvttTimingContext* GetTiming() + { + return Api.nvttContextGetTimingContext((NvttContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCubeSurface.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCubeSurface.cs deleted file mode 100644 index 4f4f795..0000000 --- a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCubeSurface.cs +++ /dev/null @@ -1,227 +0,0 @@ -namespace Ghost.Nvtt.Wrapper; - -/// -/// Wrapper around an nvtt cube-map surface (six faces, optional mip chain). -/// -/// Methods that return a new transfer ownership -/// to the caller; dispose the result when done. -/// -public sealed unsafe class NvttCubeSurfaceHandle : IDisposable -{ - private NvttCubeSurface* _ptr; - - /// Raw pointer - use only when calling the native API directly. - public NvttCubeSurface* Ptr => _ptr; - - // ------------------------------------------------------------------------- - // Construction / destruction - // ------------------------------------------------------------------------- - - public NvttCubeSurfaceHandle() => _ptr = Api.nvttCreateCubeSurface(); - - /// Wraps an existing raw pointer (takes ownership; will destroy on dispose). - internal NvttCubeSurfaceHandle(NvttCubeSurface* existing) => _ptr = existing; - - public void Dispose() - { - if (_ptr != null) - { - Api.nvttDestroyCubeSurface(_ptr); - _ptr = null; - } - } - - // ------------------------------------------------------------------------- - // Read-only properties - // ------------------------------------------------------------------------- - - /// Returns true when the cube surface holds no data. - public bool IsNull - { - get { ThrowIfDisposed(); return NvttInterop.ToBool(Api.nvttCubeSurfaceIsNull(_ptr)); } - } - - /// Side length in pixels of each face. - public int EdgeLength - { - get { ThrowIfDisposed(); return Api.nvttCubeSurfaceEdgeLength(_ptr); } - } - - /// Number of mip levels stored in this cube surface. - public int MipmapCount - { - get { ThrowIfDisposed(); return Api.nvttCubeSurfaceCountMipmaps(_ptr); } - } - - // ------------------------------------------------------------------------- - // Load / Save - // ------------------------------------------------------------------------- - - /// - /// Loads a cube map from disk. - /// selects which mip level to load (-1 = all). - /// Returns false on failure. - /// - public bool Load(string fileName, int mipmap = 0) - { - ThrowIfDisposed(); - Span buf = stackalloc byte[NvttInterop._MAX_STACK_PATH]; - var utf8 = NvttInterop.ToUtf8(fileName, buf); - fixed (byte* p = utf8) - { - return NvttInterop.ToBool(Api.nvttCubeSurfaceLoad(_ptr, (sbyte*)p, mipmap)); - } - } - - /// Loads a cube map from a managed byte array. Returns false on failure. - public bool LoadFromMemory(ReadOnlySpan data, int mipmap = 0) - { - ThrowIfDisposed(); - fixed (byte* p = data) - { - return NvttInterop.ToBool( - Api.nvttCubeSurfaceLoadFromMemory(_ptr, p, (ulong)data.Length, mipmap)); - } - } - - /// Saves the cube map to disk. Returns false on failure. - public bool Save(string fileName) - { - ThrowIfDisposed(); - Span buf = stackalloc byte[NvttInterop._MAX_STACK_PATH]; - var utf8 = NvttInterop.ToUtf8(fileName, buf); - fixed (byte* p = utf8) - { - return NvttInterop.ToBool(Api.nvttCubeSurfaceSave(_ptr, (sbyte*)p)); - } - } - - // ------------------------------------------------------------------------- - // Face access - // ------------------------------------------------------------------------- - - /// - /// Returns the raw pointer for the given face - /// (0–5). The pointer is owned by this cube surface - do NOT dispose it. - /// - public NvttSurface* FacePtr(int face) - { - ThrowIfDisposed(); - return Api.nvttCubeSurfaceFace(_ptr, face); - } - - // ------------------------------------------------------------------------- - // Fold / Unfold - // ------------------------------------------------------------------------- - - /// - /// Folds a cross-layout into this cube surface. - /// - public void Fold(NvttSurfaceHandle img, NvttCubeLayout layout) - { - ThrowIfDisposed(); - Api.nvttCubeSurfaceFold(_ptr, img.Ptr, layout); - } - - /// - /// Unfolds the cube surface into a flat cross-layout image. - /// Caller owns the returned surface. - /// - public NvttSurfaceHandle Unfold(NvttCubeLayout layout) - { - ThrowIfDisposed(); - return new NvttSurfaceHandle(Api.nvttCubeSurfaceUnfold(_ptr, layout)); - } - - // ------------------------------------------------------------------------- - // Query methods - // ------------------------------------------------------------------------- - - /// Returns the per-channel average for the given channel index. - public float Average(int channel) - { - ThrowIfDisposed(); - return Api.nvttCubeSurfaceAverage(_ptr, channel); - } - - /// Returns the min and max values of a channel across all faces. - public void Range(int channel, out float min, out float max) - { - ThrowIfDisposed(); - float lo, hi; - Api.nvttCubeSurfaceRange(_ptr, channel, &lo, &hi); - min = lo; - max = hi; - } - - // ------------------------------------------------------------------------- - // Pixel operations - // ------------------------------------------------------------------------- - - /// Clamps a channel to [, ]. - public void Clamp(int channel, float low, float high) - { - ThrowIfDisposed(); - Api.nvttCubeSurfaceClamp(_ptr, channel, low, high); - } - - /// Applies gamma expansion (toLinear) to all faces. - public void ToLinear(float gamma) - { - ThrowIfDisposed(); - Api.nvttCubeSurfaceToLinear(_ptr, gamma); - } - - /// Applies gamma compression to all faces. - public void ToGamma(float gamma) - { - ThrowIfDisposed(); - Api.nvttCubeSurfaceToGamma(_ptr, gamma); - } - - // ------------------------------------------------------------------------- - // Filtering (return new owned NvttCubeSurface) - // ------------------------------------------------------------------------- - - /// - /// Computes an irradiance-filtered cube map of the given . - /// Caller owns the result. - /// - public NvttCubeSurfaceHandle IrradianceFilter(int size, EdgeFixup fixup = EdgeFixup.NVTT_EdgeFixup_None) - { - ThrowIfDisposed(); - return new NvttCubeSurfaceHandle(Api.nvttCubeSurfaceIrradianceFilter(_ptr, size, fixup)); - } - - /// - /// Computes a cosine-power (specular) filtered cube map. - /// Caller owns the result. - /// - public NvttCubeSurfaceHandle CosinePowerFilter(int size, float cosinePower, - EdgeFixup fixup = EdgeFixup.NVTT_EdgeFixup_None) - { - ThrowIfDisposed(); - return new NvttCubeSurfaceHandle( - Api.nvttCubeSurfaceCosinePowerFilter(_ptr, size, cosinePower, fixup)); - } - - /// - /// Resamples the cube map to the given using fast bilinear resampling. - /// Caller owns the result. - /// - public NvttCubeSurfaceHandle FastResample(int size, EdgeFixup fixup = EdgeFixup.NVTT_EdgeFixup_None) - { - ThrowIfDisposed(); - return new NvttCubeSurfaceHandle(Api.nvttCubeSurfaceFastResample(_ptr, size, fixup)); - } - - // ------------------------------------------------------------------------- - - private void ThrowIfDisposed() - { - if (_ptr == null) - { - throw new ObjectDisposedException(nameof(NvttCubeSurfaceHandle)); - } - } -} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCubeSurface.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCubeSurface.nativegen.cs new file mode 100644 index 0000000..233b9e0 --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttCubeSurface.nativegen.cs @@ -0,0 +1,168 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttCubeSurface : System.IDisposable +{ + // From: nvttCreateCubeSurface() + public static NvttCubeSurface* Create() + { + return Api.nvttCreateCubeSurface(); + } + + // From: nvttDestroyCubeSurface(NvttCubeSurface*) + public void Dispose() + { + Api.nvttDestroyCubeSurface((NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttCubeSurfaceIsNull(NvttCubeSurface*) + public NvttBoolean IsNull() + { + return Api.nvttCubeSurfaceIsNull((NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttCubeSurfaceEdgeLength(NvttCubeSurface*) + public int EdgeLength() + { + return Api.nvttCubeSurfaceEdgeLength((NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttCubeSurfaceCountMipmaps(NvttCubeSurface*) + public int CountMipmaps() + { + return Api.nvttCubeSurfaceCountMipmaps((NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttCubeSurfaceLoad(NvttCubeSurface*, sbyte*, int) + public NvttBoolean Load(ReadOnlySpan fileName, int mipmap) + { + fixed (byte* pfileName = fileName) + { + return Api.nvttCubeSurfaceLoad( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pfileName, + mipmap); + } + } + + // From: nvttCubeSurfaceLoadFromMemory(NvttCubeSurface*, void*, ulong, int) + public NvttBoolean LoadFromMemory(void* data, ulong sizeInBytes, int mipmap) + { + return Api.nvttCubeSurfaceLoadFromMemory( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + data, + sizeInBytes, + mipmap); + } + + // From: nvttCubeSurfaceSave(NvttCubeSurface*, sbyte*) + public NvttBoolean Save(ReadOnlySpan fileName) + { + fixed (byte* pfileName = fileName) + { + return Api.nvttCubeSurfaceSave( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pfileName); + } + } + + // From: nvttCubeSurfaceFace(NvttCubeSurface*, int) + public NvttSurface* Face(int face) + { + return Api.nvttCubeSurfaceFace( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + face); + } + + // From: nvttCubeSurfaceFold(NvttCubeSurface*, NvttSurface*, NvttCubeLayout) + public void Fold(NvttSurface* img, NvttCubeLayout layout) + { + Api.nvttCubeSurfaceFold( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + layout); + } + + // From: nvttCubeSurfaceUnfold(NvttCubeSurface*, NvttCubeLayout) + public NvttSurface* Unfold(NvttCubeLayout layout) + { + return Api.nvttCubeSurfaceUnfold( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + layout); + } + + // From: nvttCubeSurfaceAverage(NvttCubeSurface*, int) + public float Average(int channel) + { + return Api.nvttCubeSurfaceAverage( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel); + } + + // From: nvttCubeSurfaceRange(NvttCubeSurface*, int, float*, float*) + public void Range(int channel, float* minimum_ptr, float* maximum_ptr) + { + Api.nvttCubeSurfaceRange( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + minimum_ptr, + maximum_ptr); + } + + // From: nvttCubeSurfaceClamp(NvttCubeSurface*, int, float, float) + public void Clamp(int channel, float low, float high) + { + Api.nvttCubeSurfaceClamp( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + low, + high); + } + + // From: nvttCubeSurfaceIrradianceFilter(NvttCubeSurface*, int, EdgeFixup) + public NvttCubeSurface* IrradianceFilter(int size, EdgeFixup fixupMethod) + { + return Api.nvttCubeSurfaceIrradianceFilter( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + size, + fixupMethod); + } + + // From: nvttCubeSurfaceCosinePowerFilter(NvttCubeSurface*, int, float, EdgeFixup) + public NvttCubeSurface* CosinePowerFilter(int size, float cosinePower, EdgeFixup fixupMethod) + { + return Api.nvttCubeSurfaceCosinePowerFilter( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + size, + cosinePower, + fixupMethod); + } + + // From: nvttCubeSurfaceFastResample(NvttCubeSurface*, int, EdgeFixup) + public NvttCubeSurface* FastResample(int size, EdgeFixup fixupMethod) + { + return Api.nvttCubeSurfaceFastResample( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + size, + fixupMethod); + } + + // From: nvttCubeSurfaceToLinear(NvttCubeSurface*, float) + public void ToLinear(float gamma) + { + Api.nvttCubeSurfaceToLinear( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + gamma); + } + + // From: nvttCubeSurfaceToGamma(NvttCubeSurface*, float) + public void ToGamma(float gamma) + { + Api.nvttCubeSurfaceToGamma( + (NvttCubeSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + gamma); + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttGPUInputBuffer.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttGPUInputBuffer.nativegen.cs new file mode 100644 index 0000000..7b93e51 --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttGPUInputBuffer.nativegen.cs @@ -0,0 +1,169 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttGPUInputBuffer : System.IDisposable +{ + // From: nvttDestroyGPUInputBuffer(NvttGPUInputBuffer*) + public void Dispose() + { + Api.nvttDestroyGPUInputBuffer((NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttGPUInputBufferNumTiles(NvttGPUInputBuffer*) + public int NumTiles() + { + return Api.nvttGPUInputBufferNumTiles((NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttGPUInputBufferTileSize(NvttGPUInputBuffer*, int*, int*) + public void TileSize(int* tile_w, int* tile_h) + { + Api.nvttGPUInputBufferTileSize( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tile_w, + tile_h); + } + + // From: nvttGPUInputBufferType(NvttGPUInputBuffer*) + public NvttValueType Type() + { + return Api.nvttGPUInputBufferType((NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttEncodeGPU(NvttGPUInputBuffer*, void*, NvttEncodeSettings*) + public NvttBoolean EncodeGPU(void* output, NvttEncodeSettings* settings) + { + return Api.nvttEncodeGPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + settings); + } + + // From: nvttEncodeBC1GPU(NvttGPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttTimingContext*) + public void EncodeBC1GPU(NvttBoolean fast_mode, void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC1GPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + fast_mode, + output, + to_device_mem, + tc); + } + + // From: nvttEncodeBC1AGPU(NvttGPUInputBuffer*, void*, NvttBoolean, NvttTimingContext*) + public void EncodeBC1AGPU(void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC1AGPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + to_device_mem, + tc); + } + + // From: nvttEncodeBC2GPU(NvttGPUInputBuffer*, void*, NvttBoolean, NvttTimingContext*) + public void EncodeBC2GPU(void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC2GPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + to_device_mem, + tc); + } + + // From: nvttEncodeBC3GPU(NvttGPUInputBuffer*, void*, NvttBoolean, NvttTimingContext*) + public void EncodeBC3GPU(void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC3GPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + to_device_mem, + tc); + } + + // From: nvttEncodeBC4GPU(NvttGPUInputBuffer*, void*, NvttBoolean, NvttTimingContext*) + public void EncodeBC4GPU(void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC4GPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + to_device_mem, + tc); + } + + // From: nvttEncodeBC4SGPU(NvttGPUInputBuffer*, void*, NvttBoolean, NvttTimingContext*) + public void EncodeBC4SGPU(void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC4SGPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + to_device_mem, + tc); + } + + // From: nvttEncodeATI2GPU(NvttGPUInputBuffer*, void*, NvttBoolean, NvttTimingContext*) + public void EncodeATI2GPU(void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeATI2GPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + to_device_mem, + tc); + } + + // From: nvttEncodeBC5GPU(NvttGPUInputBuffer*, void*, NvttBoolean, NvttTimingContext*) + public void EncodeBC5GPU(void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC5GPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + to_device_mem, + tc); + } + + // From: nvttEncodeBC5SGPU(NvttGPUInputBuffer*, void*, NvttBoolean, NvttTimingContext*) + public void EncodeBC5SGPU(void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC5SGPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + output, + to_device_mem, + tc); + } + + // From: nvttEncodeBC6HGPU(NvttGPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttTimingContext*) + public void EncodeBC6HGPU(NvttBoolean is_signed, void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC6HGPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + is_signed, + output, + to_device_mem, + tc); + } + + // From: nvttEncodeBC7GPU(NvttGPUInputBuffer*, NvttBoolean, void*, NvttBoolean, NvttTimingContext*) + public void EncodeBC7GPU(NvttBoolean imageHasAlpha, void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeBC7GPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + imageHasAlpha, + output, + to_device_mem, + tc); + } + + // From: nvttEncodeASTCGPU(NvttGPUInputBuffer*, int, NvttBoolean, void*, NvttBoolean, NvttTimingContext*) + public void EncodeASTCGPU(int qualityLevel, NvttBoolean imageHasAlpha, void* output, NvttBoolean to_device_mem, NvttTimingContext* tc) + { + Api.nvttEncodeASTCGPU( + (NvttGPUInputBuffer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + qualityLevel, + imageHasAlpha, + output, + to_device_mem, + tc); + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttGlobal.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttGlobal.cs deleted file mode 100644 index 0af9649..0000000 --- a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttGlobal.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System.Runtime.InteropServices; - -namespace Ghost.Nvtt.Wrapper; - -/// -/// Static helpers wrapping global nvtt functions (version, CUDA detection, -/// error utilities, image comparison, mipmap helpers). -/// -public static unsafe class NvttGlobal -{ - // ------------------------------------------------------------------------- - // Library info - // ------------------------------------------------------------------------- - - /// Returns the nvtt library version as a packed uint (major*10000 + minor*100 + patch). - public static uint Version => Api.nvttVersion(); - - /// Returns true when a CUDA-capable GPU is available. - public static bool IsCudaSupported - => NvttInterop.ToBool(Api.nvttIsCudaSupported()); - - // ------------------------------------------------------------------------- - // Error strings - // ------------------------------------------------------------------------- - - /// Returns a human-readable string for . - public static string? ErrorString(NvttError error) - => NvttInterop.FromUtf8(Api.nvttErrorString(error)); - - // ------------------------------------------------------------------------- - // Global message callback - // - // The delegate type must be kept alive as long as the callback is registered. - // Store the returned token and dispose it to clear the callback. - // ------------------------------------------------------------------------- - - /// - /// Delegate type for the global nvtt message callback. - /// - public delegate void MessageCallback( - NvttSeverity severity, NvttError error, string? description); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - internal delegate void NativeMessageCallback( - NvttSeverity severity, NvttError error, sbyte* description, void* userData); - - /// - /// A registration token returned by . - /// Dispose to clear the callback and release the pinned delegate. - /// - public sealed class MessageCallbackToken : IDisposable - { - private NativeMessageCallback? _pinned; - - internal MessageCallbackToken(NativeMessageCallback pinned) - => _pinned = pinned; - - public void Dispose() - { - if (_pinned != null) - { - // Clear the callback by registering null. - Api.nvttSetMessageCallback(null, null); - _pinned = null; - } - } - } - - /// - /// Registers a managed message callback that nvtt calls for warnings and errors. - /// Returns a token; dispose the token to unregister. - /// - public static MessageCallbackToken SetMessageCallback(MessageCallback callback) - { - void native(NvttSeverity sev, NvttError err, sbyte* descPtr, void* _) - { - var desc = NvttInterop.FromUtf8(descPtr); - callback(sev, err, desc); - } - - var fp = Marshal.GetFunctionPointerForDelegate(native); - Api.nvttSetMessageCallback( - (delegate* unmanaged[Cdecl])fp, - null); - - return new MessageCallbackToken(native); - } - - // ------------------------------------------------------------------------- - // Image comparison (error metrics) - // ------------------------------------------------------------------------- - - /// RMS per-channel colour error between two surfaces. - public static float RmsError(NvttSurfaceHandle reference, NvttSurfaceHandle img, - NvttTimingContext* tc = null) - => Api.nvttRmsError(reference.Ptr, img.Ptr, tc); - - /// RMS alpha-channel error between two surfaces. - public static float RmsAlphaError(NvttSurfaceHandle reference, NvttSurfaceHandle img, - NvttTimingContext* tc = null) - => Api.nvttRmsAlphaError(reference.Ptr, img.Ptr, tc); - - /// RMS CIE-Lab perceptual error between two surfaces. - public static float RmsCIELabError(NvttSurfaceHandle reference, NvttSurfaceHandle img, - NvttTimingContext* tc = null) - => Api.nvttRmsCIELabError(reference.Ptr, img.Ptr, tc); - - /// Angular error between two normal-map surfaces. - public static float AngularError(NvttSurfaceHandle reference, NvttSurfaceHandle img, - NvttTimingContext* tc = null) - => Api.nvttAngularError(reference.Ptr, img.Ptr, tc); - - /// - /// Tone-mapped RMS error. Useful for HDR comparisons. - /// - public static float RmsToneMappedError(NvttSurfaceHandle reference, NvttSurfaceHandle img, - float exposure, NvttTimingContext* tc = null) - => Api.nvttRmsToneMappedError(reference.Ptr, img.Ptr, exposure, tc); - - // ------------------------------------------------------------------------- - // Difference image - // ------------------------------------------------------------------------- - - /// - /// Returns a new surface containing the scaled per-pixel difference. - /// Caller owns the returned surface. - /// - public static NvttSurfaceHandle Diff(NvttSurfaceHandle reference, NvttSurfaceHandle img, - float scale, NvttTimingContext* tc = null) - => new NvttSurfaceHandle(Api.nvttDiff(reference.Ptr, img.Ptr, scale, tc)); - - // ------------------------------------------------------------------------- - // Histogram - // ------------------------------------------------------------------------- - - /// - /// Returns a new surface containing a histogram visualisation of - /// at the given dimensions. - /// Caller owns the returned surface. - /// - public static NvttSurfaceHandle Histogram(NvttSurfaceHandle img, int width, int height, - NvttTimingContext* tc = null) - => new NvttSurfaceHandle(Api.nvttHistogram(img.Ptr, width, height, tc)); - - /// - /// Returns a new surface containing a histogram visualisation with an - /// explicit value range. - /// Caller owns the returned surface. - /// - public static NvttSurfaceHandle HistogramRange(NvttSurfaceHandle img, - float minRange, float maxRange, int width, int height, - NvttTimingContext* tc = null) - => new NvttSurfaceHandle( - Api.nvttHistogramRange(img.Ptr, minRange, maxRange, width, height, tc)); - - // ------------------------------------------------------------------------- - // Extent / mipmap helpers - // ------------------------------------------------------------------------- - - /// - /// Computes the target extent (power-of-two rounding, texture type clamping, - /// etc.) for a texture of the given dimensions. - /// Modifies , and - /// in place. - /// - public static void GetTargetExtent(ref int width, ref int height, ref int depth, - int maxExtent, NvttRoundMode roundMode, NvttTextureType textureType, - NvttTimingContext* tc = null) - { - fixed (int* pw = &width, ph = &height, pd = &depth) - { - Api.nvttGetTargetExtent(pw, ph, pd, maxExtent, roundMode, textureType, tc); - } - } - - /// - /// Returns the number of mip levels that can be generated for the given - /// base dimensions. - /// - public static int CountMipmaps(int w, int h, int d, - NvttTimingContext* tc = null) - => Api.nvttCountMipmaps(w, h, d, tc); -} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttInterop.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttInterop.cs deleted file mode 100644 index 614af0b..0000000 --- a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttInterop.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Text; - -namespace Ghost.Nvtt.Wrapper; - -/// -/// Internal helpers for converting between managed and unmanaged types. -/// -internal static unsafe class NvttInterop -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static NvttBoolean ToNvtt(bool value) - => value ? NvttBoolean.NVTT_True : NvttBoolean.NVTT_False; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static bool ToBool(NvttBoolean value) - => value != NvttBoolean.NVTT_False; - - // ------------------------------------------------------------------------- - // String to UTF-8 sbyte* - // - // Usage pattern: - // fixed (byte* ptr = NvttInterop.ToUtf8(str, stackalloc byte[MaxStack])) - // Api.nvttSomething((sbyte*)ptr); - // - // For paths longer than MaxStack bytes the helper falls back to a heap - // allocation via Encoding.UTF8.GetBytes. The Span overload lets the - // caller decide the stackalloc size. - // ------------------------------------------------------------------------- - - internal const int _MAX_STACK_PATH = 512; - - /// - /// Encode as null-terminated UTF-8 into - /// . Returns the used portion (including the - /// null terminator). If the buffer is too small a new heap array is - /// returned instead. - /// - internal static Span ToUtf8(string value, Span buffer) - { - var needed = Encoding.UTF8.GetByteCount(value) + 1; // +1 for null term - if (needed > buffer.Length) - { - buffer = new byte[needed]; - } - - var written = Encoding.UTF8.GetBytes(value, buffer); - buffer[written] = 0; // null terminator - return buffer[..(written + 1)]; - } - - internal static string? FromUtf8(sbyte* ptr) - { - if (ptr == null) - { - return null; - } - - var len = 0; - while (ptr[len] != 0) - { - len++; - } - - return Encoding.UTF8.GetString((byte*)ptr, len); - } -} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttOutputOptions.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttOutputOptions.cs deleted file mode 100644 index 69547d6..0000000 --- a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttOutputOptions.cs +++ /dev/null @@ -1,210 +0,0 @@ -using System.Runtime.InteropServices; - -namespace Ghost.Nvtt.Wrapper; - -/// -/// Configures where compressed data is written and how it is formatted. -/// -/// Managed callback delegates are stored in this object and passed to the -/// native library via . -/// The delegates are kept alive by pinned instances -/// for the lifetime of this object. -/// -public sealed unsafe class NvttOutputOptionsHandle : IDisposable -{ - private NvttOutputOptions* _ptr; - - /// Raw pointer - use only when calling the native API directly. - public NvttOutputOptions* Ptr => _ptr; - - // ------------------------------------------------------------------------- - // Managed callback storage - // ------------------------------------------------------------------------- - - // Delegate types that match the native C signatures exactly. - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void BeginImageDelegate(int size, int width, int height, int depth, int face, int mipLevel); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate NvttBoolean OutputDataDelegate(void* data, int size, NvttBoolean lastChunk); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void ErrorDelegate(NvttError error); - - // Pinned delegate instances - must stay alive as long as native code may call them. - private BeginImageDelegate? _beginImageDelegate; - private OutputDataDelegate? _outputDataDelegate; - private ErrorDelegate? _errorDelegate; - - // Managed user-facing callbacks. - private Action? _beginImage; - private Func? _outputData; - private Action? _endImage; - private Action? _errorHandler; - - // ------------------------------------------------------------------------- - // Construction / destruction - // ------------------------------------------------------------------------- - - public NvttOutputOptionsHandle() => _ptr = Api.nvttCreateOutputOptions(); - - public void Dispose() - { - if (_ptr != null) - { - Api.nvttDestroyOutputOptions(_ptr); - _ptr = null; - } - // Release delegate references so GC can collect them. - _beginImageDelegate = null; - _outputDataDelegate = null; - _errorDelegate = null; - } - - // ------------------------------------------------------------------------- - // Properties - // ------------------------------------------------------------------------- - - /// - /// Path of the output file. The file is created/overwritten when - /// compression runs. - /// - public string FileName - { - set - { - ThrowIfDisposed(); - Span buf = stackalloc byte[NvttInterop._MAX_STACK_PATH]; - var utf8 = NvttInterop.ToUtf8(value, buf); - fixed (byte* p = utf8) - { - Api.nvttSetOutputOptionsFileName(_ptr, (sbyte*)p); - } - } - } - - /// - /// Whether to write a DDS / KTX file header. Default is true. - /// - public bool OutputHeader - { - set { ThrowIfDisposed(); Api.nvttSetOutputOptionsOutputHeader(_ptr, NvttInterop.ToNvtt(value)); } - } - - /// Container format (DDS or DDS10). - public NvttContainer Container - { - set { ThrowIfDisposed(); Api.nvttSetOutputOptionsContainer(_ptr, value); } - } - - /// Application-defined version number stored in the header. - public int UserVersion - { - set { ThrowIfDisposed(); Api.nvttSetOutputOptionsUserVersion(_ptr, value); } - } - - /// Sets the sRGB flag in the output header. - public bool Srgb - { - set { ThrowIfDisposed(); Api.nvttSetOutputOptionsSrgbFlag(_ptr, NvttInterop.ToNvtt(value)); } - } - - // ------------------------------------------------------------------------- - // Methods - // ------------------------------------------------------------------------- - - /// Resets all options to their default values. - public void Reset() - { - ThrowIfDisposed(); - Api.nvttResetOutputOptions(_ptr); - } - - /// - /// Installs managed callbacks that receive the compressed data stream. - /// - /// is called once per mip level before any - /// data arrives: (size, width, height, depth, face, mipLevel). - /// receives each chunk of compressed bytes. - /// The first argument is an pointing to the data, the - /// second is the byte count. Return true to continue, false - /// to abort. - /// is called once after the last chunk. - /// - /// Only one set of output callbacks can be active at a time; calling this - /// method again replaces the previous ones. - /// - public void SetOutputHandler( - Action? beginImage, - Func? outputData, - Action? endImage) - { - ThrowIfDisposed(); - _beginImage = beginImage; - _outputData = outputData; - _endImage = endImage; - RebindOutputHandler(); - } - - /// - /// Installs a managed error handler. The handler is invoked with the - /// code whenever the native library encounters an - /// error. - /// - public void SetErrorHandler(Action? handler) - { - ThrowIfDisposed(); - _errorHandler = handler; - RebindErrorHandler(); - } - - // ------------------------------------------------------------------------- - // Internal delegate trampolines (instance-bound via closures) - // ------------------------------------------------------------------------- - - private void RebindOutputHandler() - { - // Capture current callbacks into local vars for the closure. - var beginImage = _beginImage; - var outputData = _outputData; - - _beginImageDelegate = (size, width, height, depth, face, mipLevel) => - beginImage?.Invoke(size, width, height, depth, face, mipLevel); - - _outputDataDelegate = (data, size, lastChunk) => - { - var ok = outputData?.Invoke((nint)data, size) ?? true; - return ok ? Ghost.Nvtt.NvttBoolean.NVTT_True : Ghost.Nvtt.NvttBoolean.NVTT_False; - }; - - var beginPtr = Marshal.GetFunctionPointerForDelegate(_beginImageDelegate); - var outputPtr = Marshal.GetFunctionPointerForDelegate(_outputDataDelegate); - - Api.nvttSetOutputOptionsOutputHandler( - _ptr, - (delegate* unmanaged[Cdecl])beginPtr, - (delegate* unmanaged[Cdecl])outputPtr, - IntPtr.Zero); - } - - private void RebindErrorHandler() - { - var handler = _errorHandler; - _errorDelegate = error => handler?.Invoke(error); - - var errorPtr = Marshal.GetFunctionPointerForDelegate(_errorDelegate); - Api.nvttSetOutputOptionsErrorHandler( - _ptr, - (delegate* unmanaged[Cdecl])errorPtr); - } - - // ------------------------------------------------------------------------- - - private void ThrowIfDisposed() - { - if (_ptr == null) - { - throw new ObjectDisposedException(nameof(NvttOutputOptionsHandle)); - } - } -} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttOutputOptions.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttOutputOptions.nativegen.cs new file mode 100644 index 0000000..e71bc9e --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttOutputOptions.nativegen.cs @@ -0,0 +1,95 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttOutputOptions : System.IDisposable +{ + // From: nvttCreateOutputOptions() + public static NvttOutputOptions* Create() + { + return Api.nvttCreateOutputOptions(); + } + + // From: nvttDestroyOutputOptions(NvttOutputOptions*) + public void Dispose() + { + Api.nvttDestroyOutputOptions((NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttResetOutputOptions(NvttOutputOptions*) + public void Reset() + { + Api.nvttResetOutputOptions((NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSetOutputOptionsFileName(NvttOutputOptions*, sbyte*) + public void SetFileName(ReadOnlySpan fileName) + { + fixed (byte* pfileName = fileName) + { + Api.nvttSetOutputOptionsFileName( + (NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pfileName); + } + } + + // From: nvttSetOutputOptionsFileHandle(NvttOutputOptions*, void*) + public void SetFileHandle(void* fp) + { + Api.nvttSetOutputOptionsFileHandle( + (NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + fp); + } + + // From: nvttSetOutputOptionsOutputHandler(NvttOutputOptions*, delegate* unmanaged[Cdecl], delegate* unmanaged[Cdecl], IntPtr) + public void SetOutputHandler(delegate* unmanaged[Cdecl] beginImageHandler, delegate* unmanaged[Cdecl] outputHandler, IntPtr endImageHandler) + { + Api.nvttSetOutputOptionsOutputHandler( + (NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + beginImageHandler, + outputHandler, + endImageHandler); + } + + // From: nvttSetOutputOptionsErrorHandler(NvttOutputOptions*, delegate* unmanaged[Cdecl]) + public void SetErrorHandler(delegate* unmanaged[Cdecl] errorHandler) + { + Api.nvttSetOutputOptionsErrorHandler( + (NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + errorHandler); + } + + // From: nvttSetOutputOptionsOutputHeader(NvttOutputOptions*, NvttBoolean) + public void SetOutputHeader(NvttBoolean b) + { + Api.nvttSetOutputOptionsOutputHeader( + (NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + b); + } + + // From: nvttSetOutputOptionsContainer(NvttOutputOptions*, NvttContainer) + public void SetContainer(NvttContainer container) + { + Api.nvttSetOutputOptionsContainer( + (NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + container); + } + + // From: nvttSetOutputOptionsUserVersion(NvttOutputOptions*, int) + public void SetUserVersion(int version) + { + Api.nvttSetOutputOptionsUserVersion( + (NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + version); + } + + // From: nvttSetOutputOptionsSrgbFlag(NvttOutputOptions*, NvttBoolean) + public void SetSrgbFlag(NvttBoolean b) + { + Api.nvttSetOutputOptionsSrgbFlag( + (NvttOutputOptions*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + b); + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttRefImage.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttRefImage.nativegen.cs new file mode 100644 index 0000000..ef5956c --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttRefImage.nativegen.cs @@ -0,0 +1,42 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttRefImage +{ + // From: nvttCreateCPUInputBuffer(NvttRefImage*, NvttValueType, int, int, int, float, float, float, float, NvttTimingContext*, uint*) + public NvttCPUInputBuffer* CreateCPUInputBuffer(NvttValueType value_type, int numImages, int tile_w, int tile_h, float WeightR, float WeightG, float WeightB, float WeightA, NvttTimingContext* tc, uint* num_tiles) + { + return Api.nvttCreateCPUInputBuffer( + (NvttRefImage*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + value_type, + numImages, + tile_w, + tile_h, + WeightR, + WeightG, + WeightB, + WeightA, + tc, + num_tiles); + } + + // From: nvttCreateGPUInputBuffer(NvttRefImage*, NvttValueType, int, int, int, float, float, float, float, NvttTimingContext*, uint*) + public NvttGPUInputBuffer* CreateGPUInputBuffer(NvttValueType value_type, int numImages, int tile_w, int tile_h, float WeightR, float WeightG, float WeightB, float WeightA, NvttTimingContext* tc, uint* num_tiles) + { + return Api.nvttCreateGPUInputBuffer( + (NvttRefImage*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + value_type, + numImages, + tile_w, + tile_h, + WeightR, + WeightG, + WeightB, + WeightA, + tc, + num_tiles); + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurface.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurface.cs deleted file mode 100644 index bc248c6..0000000 --- a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurface.cs +++ /dev/null @@ -1,712 +0,0 @@ -namespace Ghost.Nvtt.Wrapper; - -/// -/// Wrapper around a single 2-D / 3-D / cube-face image surface used as input -/// to the compression pipeline. -/// -/// Most mutating methods accept an optional timing -/// context. Pass null (the default) to skip timing. -/// -public sealed unsafe class NvttSurfaceHandle : IDisposable -{ - private NvttSurface* _ptr; - - /// Raw pointer - use only when calling the native API directly. - public NvttSurface* Ptr => _ptr; - - // ------------------------------------------------------------------------- - // Construction / destruction - // ------------------------------------------------------------------------- - - public NvttSurfaceHandle() => _ptr = Api.nvttCreateSurface(); - - /// Wraps an existing raw pointer (takes ownership; will destroy on dispose). - internal NvttSurfaceHandle(NvttSurface* existing) => _ptr = existing; - - public void Dispose() - { - if (_ptr != null) - { - Api.nvttDestroySurface(_ptr); - _ptr = null; - } - } - - // ------------------------------------------------------------------------- - // Clone / sub-image - // ------------------------------------------------------------------------- - - /// Returns a deep copy of this surface. - public NvttSurfaceHandle Clone() - { - ThrowIfDisposed(); - return new NvttSurfaceHandle(Api.nvttSurfaceClone(_ptr)); - } - - /// - /// Extracts a rectangular sub-region into a new . - /// - public NvttSurfaceHandle CreateSubImage( - int x0, int x1, int y0, int y1, int z0, int z1, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - return new NvttSurfaceHandle(Api.nvttSurfaceCreateSubImage(_ptr, x0, x1, y0, y1, z0, z1, tc)); - } - - // ------------------------------------------------------------------------- - // Read-only properties - // ------------------------------------------------------------------------- - - /// Returns true when the surface holds no data. - public bool IsNull - { - get { ThrowIfDisposed(); return NvttInterop.ToBool(Api.nvttSurfaceIsNull(_ptr)); } - } - - /// Image width in pixels. - public int Width - { - get { ThrowIfDisposed(); return Api.nvttSurfaceWidth(_ptr); } - } - - /// Image height in pixels. - public int Height - { - get { ThrowIfDisposed(); return Api.nvttSurfaceHeight(_ptr); } - } - - /// Image depth (1 for 2-D textures). - public int Depth - { - get { ThrowIfDisposed(); return Api.nvttSurfaceDepth(_ptr); } - } - - /// Texture dimensionality. - public NvttTextureType TextureType - { - get { ThrowIfDisposed(); return Api.nvttSurfaceType(_ptr); } - } - - /// Whether the surface contains a normal map. - public bool IsNormalMap - { - get { ThrowIfDisposed(); return NvttInterop.ToBool(Api.nvttSurfaceIsNormalMap(_ptr)); } - } - - // ------------------------------------------------------------------------- - // Settable properties - // ------------------------------------------------------------------------- - - /// UV wrap mode used when filtering near edges. - public NvttWrapMode WrapMode - { - get { ThrowIfDisposed(); return Api.nvttSurfaceWrapMode(_ptr); } - } - - /// Alpha mode interpretation. - public NvttAlphaMode AlphaMode - { - get { ThrowIfDisposed(); return Api.nvttSurfaceAlphaMode(_ptr); } - } - - // ------------------------------------------------------------------------- - // Query methods - // ------------------------------------------------------------------------- - - /// - /// Returns the number of mip levels that can be generated down to - /// pixels on the smallest side. - /// - public int CountMipmaps(int minSize = 1) - { - ThrowIfDisposed(); - return Api.nvttSurfaceCountMipmaps(_ptr, minSize); - } - - /// Alpha-test coverage for the given reference value and channel. - public float AlphaTestCoverage(float alphaRef, int alphaChannel = 3) - { - ThrowIfDisposed(); - return Api.nvttSurfaceAlphaTestCoverage(_ptr, alphaRef, alphaChannel); - } - - /// Per-channel average luminance. - public float Average(int channel, int alphaChannel = 3, float gamma = 2.2f) - { - ThrowIfDisposed(); - return Api.nvttSurfaceAverage(_ptr, channel, alphaChannel, gamma); - } - - /// - /// Returns a pointer to the raw float data for all four channels interleaved. - /// The span is valid only while this surface is alive. - /// - public Span Data - { - get - { - ThrowIfDisposed(); - var p = Api.nvttSurfaceData(_ptr); - var count = Width * Height * Depth * 4; - return p == null ? Span.Empty : new Span(p, count); - } - } - - /// - /// Returns a pointer to the raw float data for a single channel (0=R,1=G,2=B,3=A). - /// The span is valid only while this surface is alive. - /// - public Span Channel(int index) - { - ThrowIfDisposed(); - var p = Api.nvttSurfaceChannel(_ptr, index); - var count = Width * Height * Depth; - return p == null ? Span.Empty : new Span(p, count); - } - - /// Populates a histogram array for the given channel. - public void Histogram(int channel, float rangeMin, float rangeMax, Span bins, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - fixed (int* b = bins) - { - Api.nvttSurfaceHistogram(_ptr, channel, rangeMin, rangeMax, bins.Length, b, tc); - } - } - - /// Returns the minimum and maximum values of a channel. - public void Range(int channel, out float min, out float max, - int alphaChannel = 3, float alphaRef = 0f, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - float lo, hi; - Api.nvttSurfaceRange(_ptr, channel, &lo, &hi, alphaChannel, alphaRef, tc); - min = lo; - max = hi; - } - - // ------------------------------------------------------------------------- - // Load / Save - // ------------------------------------------------------------------------- - - /// Loads an image from disk. Returns false on failure. - public bool Load(string fileName, out bool hasAlpha, bool expectSigned = false, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Span buf = stackalloc byte[NvttInterop._MAX_STACK_PATH]; - var utf8 = NvttInterop.ToUtf8(fileName, buf); - fixed (byte* p = utf8) - { - NvttBoolean nvAlpha; - var ok = NvttInterop.ToBool( - Api.nvttSurfaceLoad(_ptr, (sbyte*)p, &nvAlpha, - NvttInterop.ToNvtt(expectSigned), tc)); - hasAlpha = NvttInterop.ToBool(nvAlpha); - return ok; - } - } - - /// Loads an image from a managed byte array. Returns false on failure. - public bool LoadFromMemory(ReadOnlySpan data, out bool hasAlpha, - bool expectSigned = false, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - fixed (byte* p = data) - { - NvttBoolean nvAlpha; - var ok = NvttInterop.ToBool( - Api.nvttSurfaceLoadFromMemory(_ptr, p, (ulong)data.Length, - &nvAlpha, NvttInterop.ToNvtt(expectSigned), tc)); - hasAlpha = NvttInterop.ToBool(nvAlpha); - return ok; - } - } - - /// Saves the surface to disk. Returns false on failure. - public bool Save(string fileName, bool hasAlpha = false, bool hdr = false, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Span buf = stackalloc byte[NvttInterop._MAX_STACK_PATH]; - var utf8 = NvttInterop.ToUtf8(fileName, buf); - fixed (byte* p = utf8) - { - return NvttInterop.ToBool( - Api.nvttSurfaceSave(_ptr, (sbyte*)p, - NvttInterop.ToNvtt(hasAlpha), NvttInterop.ToNvtt(hdr), tc)); - } - } - - // ------------------------------------------------------------------------- - // Set image data - // ------------------------------------------------------------------------- - - /// Allocates an empty surface of the given dimensions. - public bool SetImage(int w, int h, int d = 1, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - return NvttInterop.ToBool(Api.nvttSurfaceSetImage(_ptr, w, h, d, tc)); - } - - /// Sets the surface from interleaved RGBA data. - public bool SetImageData(NvttInputFormat format, int w, int h, int d, - ReadOnlySpan data, bool unsignedToSigned = false, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - fixed (byte* p = data) - { - return NvttInterop.ToBool( - Api.nvttSurfaceSetImageData(_ptr, format, w, h, d, p, - NvttInterop.ToNvtt(unsignedToSigned), tc)); - } - } - - /// Sets the surface from separate RGBA channel planes. - public bool SetImageRGBA(NvttInputFormat format, int w, int h, int d, - ReadOnlySpan r, ReadOnlySpan g, - ReadOnlySpan b, ReadOnlySpan a, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - fixed (byte* pr = r, pg = g, pb = b, pa = a) - { - return NvttInterop.ToBool( - Api.nvttSurfaceSetImageRGBA(_ptr, format, w, h, d, pr, pg, pb, pa, tc)); - } - } - - /// Sets the surface from a compressed 2-D image. - public bool SetImage2D(NvttFormat format, int w, int h, - ReadOnlySpan data, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - fixed (byte* p = data) - { - return NvttInterop.ToBool( - Api.nvttSurfaceSetImage2D(_ptr, format, w, h, p, tc)); - } - } - - /// Sets the surface from a compressed 3-D image. - public bool SetImage3D(NvttFormat format, int w, int h, int d, - ReadOnlySpan data, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - fixed (byte* p = data) - { - return NvttInterop.ToBool( - Api.nvttSurfaceSetImage3D(_ptr, format, w, h, d, p, tc)); - } - } - - // ------------------------------------------------------------------------- - // Resize / mipmap - // ------------------------------------------------------------------------- - - /// Resizes the surface to the exact dimensions given. - public void Resize(int w, int h, int d, NvttResizeFilter filter, - float filterWidth = 1f, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Api.nvttSurfaceResize(_ptr, w, h, d, filter, filterWidth, null, tc); - } - - /// Resizes so that the longest extent is at most . - public void ResizeMax(int maxExtent, NvttRoundMode mode, NvttResizeFilter filter, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Api.nvttSurfaceResizeMax(_ptr, maxExtent, mode, filter, tc); - } - - /// Resizes to a square texture with side at most . - public void ResizeMakeSquare(int maxExtent, NvttRoundMode mode, NvttResizeFilter filter, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Api.nvttSurfaceResizeMakeSquare(_ptr, maxExtent, mode, filter, tc); - } - - /// Pads or crops the canvas to the given dimensions without resampling. - public void CanvasSize(int w, int h, int d, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Api.nvttSurfaceCanvasSize(_ptr, w, h, d, tc); - } - - /// Returns true if a next mip level can still be generated. - public bool CanMakeNextMipmap(int minSize = 1) - { - ThrowIfDisposed(); - return NvttInterop.ToBool(Api.nvttSurfaceCanMakeNextMipmap(_ptr, minSize)); - } - - /// Generates the next mip level in place (downsamples by 2). - public bool BuildNextMipmap(NvttMipmapFilter filter, int minSize = 1, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - return NvttInterop.ToBool( - Api.nvttSurfaceBuildNextMipmapDefaults(_ptr, filter, minSize, tc)); - } - - /// Generates the next mip level using a solid colour. - public bool BuildNextMipmapSolidColor(float r, float g, float b, float a, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - var color = stackalloc float[4] { r, g, b, a }; - return NvttInterop.ToBool( - Api.nvttSurfaceBuildNextMipmapSolidColor(_ptr, color, tc)); - } - - // ------------------------------------------------------------------------- - // Colour-space conversions - // ------------------------------------------------------------------------- - - /// Converts from sRGB to linear (per-channel). - public void ToLinearFromSrgb(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToLinearFromSrgb(_ptr, tc); - } - - /// Converts from linear to sRGB (clamped). - public void ToSrgb(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToSrgb(_ptr, tc); - } - - /// Converts from sRGB to linear (unclamped). - public void ToLinearFromSrgbUnclamped(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToLinearFromSrgbUnclamped(_ptr, tc); - } - - /// Converts from linear to sRGB (unclamped). - public void ToSrgbUnclamped(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToSrgbUnclamped(_ptr, tc); - } - - /// Applies gamma expansion (toLinear) to all channels. - public void ToLinear(float gamma, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToLinear(_ptr, gamma, tc); - } - - /// Applies gamma compression to all channels. - public void ToGamma(float gamma, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToGamma(_ptr, gamma, tc); - } - - /// Applies gamma expansion to a single channel. - public void ToLinearChannel(int channel, float gamma, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToLinearChannel(_ptr, channel, gamma, tc); - } - - /// Applies gamma compression to a single channel. - public void ToGammaChannel(int channel, float gamma, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToGammaChannel(_ptr, channel, gamma, tc); - } - - // ------------------------------------------------------------------------- - // Pixel operations - // ------------------------------------------------------------------------- - - /// Applies a 4×4 colour transform matrix plus per-channel offset. - public void Transform( - float[] w0, float[] w1, float[] w2, float[] w3, float[] offset, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - fixed (float* pw0 = w0, pw1 = w1, pw2 = w2, pw3 = w3, po = offset) - { - Api.nvttSurfaceTransform(_ptr, pw0, pw1, pw2, pw3, po, tc); - } - } - - /// Rearranges channels: result[0]=src[r], result[1]=src[g], etc. - public void Swizzle(int r, int g, int b, int a, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceSwizzle(_ptr, r, g, b, a, tc); - } - - /// Applies x = x * scale + bias to a single channel. - public void ScaleBias(int channel, float scale, float bias, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceScaleBias(_ptr, channel, scale, bias, tc); - } - - /// Clamps a channel to [, ]. - public void Clamp(int channel, float low, float high, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceClamp(_ptr, channel, low, high, tc); - } - - /// Blends toward a constant RGBA colour by factor . - public void Blend(float r, float g, float b, float a, float t, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceBlend(_ptr, r, g, b, a, t, tc); - } - - /// Multiplies RGB by alpha. - public void PremultiplyAlpha(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfacePremultiplyAlpha(_ptr, tc); - } - - /// Divides RGB by alpha (with epsilon guard against divide-by-zero). - public void DemultiplyAlpha(float epsilon = 1e-6f, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceDemultiplyAlpha(_ptr, epsilon, tc); - } - - /// Converts to greyscale by weighted sum of channels. - public void ToGreyScale(float redScale, float greenScale, float blueScale, - float alphaScale, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Api.nvttSurfaceToGreyScale(_ptr, redScale, greenScale, blueScale, alphaScale, tc); - } - - /// Fills the edge border of the surface with the given colour. - public void SetBorder(float r, float g, float b, float a, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceSetBorder(_ptr, r, g, b, a, tc); - } - - /// Fills the entire surface with a constant colour. - public void Fill(float r, float g, float b, float a, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceFill(_ptr, r, g, b, a, tc); - } - - /// Scales alpha so that alpha-test coverage matches the given target. - public void ScaleAlphaToCoverage(float coverage, float alphaRef = 0.5f, - int alphaChannel = 3, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Api.nvttSurfaceScaleAlphaToCoverage(_ptr, coverage, alphaRef, alphaChannel, tc); - } - - // ------------------------------------------------------------------------- - // HDR encodings - // ------------------------------------------------------------------------- - - /// Encodes to RGBM (RGB * M, M in alpha). - public void ToRGBM(float range = 6f, float threshold = 0.25f, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToRGBM(_ptr, range, threshold, tc); - } - - /// Decodes from RGBM back to linear HDR. - public void FromRGBM(float range = 6f, float threshold = 0.25f, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceFromRGBM(_ptr, range, threshold, tc); - } - - /// Encodes to RGBE (Radiance HDR format). - public void ToRGBE(int mantissaBits = 9, int exponentBits = 5, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToRGBE(_ptr, mantissaBits, exponentBits, tc); - } - - /// Decodes from RGBE back to linear HDR. - public void FromRGBE(int mantissaBits = 9, int exponentBits = 5, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceFromRGBE(_ptr, mantissaBits, exponentBits, tc); - } - - /// Converts to YCoCg colour space. - public void ToYCoCg(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToYCoCg(_ptr, tc); - } - - /// Converts from YCoCg back to RGB. - public void FromYCoCg(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceFromYCoCg(_ptr, tc); - } - - // ------------------------------------------------------------------------- - // Normal-map operations - // ------------------------------------------------------------------------- - - /// - /// Generates a normal map from the surface (treated as a height map) - /// using four blur kernel sizes. - /// - public void ToNormalMap(float sm, float medium, float big, float large, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Api.nvttSurfaceToNormalMap(_ptr, sm, medium, big, large, tc); - } - - /// Re-normalises all normal vectors in the surface. - public void NormalizeNormalMap(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceNormalizeNormalMap(_ptr, tc); - } - - /// Applies a normal-space transform. - public void TransformNormals(NvttNormalTransform xform, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceTransformNormals(_ptr, xform, tc); - } - - /// Reconstructs normals from a packed representation. - public void ReconstructNormals(NvttNormalTransform xform, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceReconstructNormals(_ptr, xform, tc); - } - - /// Packs normals into [0,1] range using n*scale+bias. - public void PackNormals(float scale = 0.5f, float bias = 0.5f, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfacePackNormals(_ptr, scale, bias, tc); - } - - /// Expands packed normals back to [-1,1] range. - public void ExpandNormals(float scale = 2f, float bias = -1f, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceExpandNormals(_ptr, scale, bias, tc); - } - - /// - /// Creates a Toksvig specular power map from a normal map. - /// Caller owns the returned surface. - /// - public NvttSurfaceHandle CreateToksvigMap(float power, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - return new NvttSurfaceHandle(Api.nvttSurfaceCreateToksvigMap(_ptr, power, tc)); - } - - // ------------------------------------------------------------------------- - // Flip - // ------------------------------------------------------------------------- - - /// Flips the surface along the X axis. - public void FlipX(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceFlipX(_ptr, tc); - } - - /// Flips the surface along the Y axis. - public void FlipY(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceFlipY(_ptr, tc); - } - - /// Flips the surface along the Z axis. - public void FlipZ(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceFlipZ(_ptr, tc); - } - - // ------------------------------------------------------------------------- - // Channel copy / add - // ------------------------------------------------------------------------- - - /// Copies a single channel from another surface. - public bool CopyChannel(NvttSurfaceHandle src, int srcChannel, int dstChannel, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - return NvttInterop.ToBool( - Api.nvttSurfaceCopyChannel(_ptr, src.Ptr, srcChannel, dstChannel, tc)); - } - - /// Adds a scaled channel from another surface into this one. - public bool AddChannel(NvttSurfaceHandle src, int srcChannel, int dstChannel, - float scale = 1f, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - return NvttInterop.ToBool( - Api.nvttSurfaceAddChannel(_ptr, src.Ptr, srcChannel, dstChannel, scale, tc)); - } - - /// Copies a rectangular region from another surface into this one. - public bool Copy(NvttSurfaceHandle src, - int xsrc, int ysrc, int zsrc, - int xsize, int ysize, int zsize, - int xdst, int ydst, int zdst, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - return NvttInterop.ToBool( - Api.nvttSurfaceCopy(_ptr, src.Ptr, - xsrc, ysrc, zsrc, xsize, ysize, zsize, xdst, ydst, zdst, tc)); - } - - // ------------------------------------------------------------------------- - // GPU transfer - // ------------------------------------------------------------------------- - - /// Uploads the surface to the GPU (CUDA). clones instead of moving. - public void ToGPU(bool performCopy = false, NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Api.nvttSurfaceToGPU(_ptr, NvttInterop.ToNvtt(performCopy), tc); - } - - /// Downloads the surface back to CPU memory. - public void ToCPU(NvttTimingContext* tc = null) - { - ThrowIfDisposed(); Api.nvttSurfaceToCPU(_ptr, tc); - } - - // ------------------------------------------------------------------------- - // Quantize / binarize - // ------------------------------------------------------------------------- - - /// Quantizes a channel to the given bit depth. - public void Quantize(int channel, int bits, - bool exactEndPoints = false, bool dither = false, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Api.nvttSurfaceQuantize(_ptr, channel, bits, - NvttInterop.ToNvtt(exactEndPoints), NvttInterop.ToNvtt(dither), tc); - } - - /// Binarizes a channel using a threshold. - public void Binarize(int channel, float threshold, bool dither = false, - NvttTimingContext* tc = null) - { - ThrowIfDisposed(); - Api.nvttSurfaceBinarize(_ptr, channel, threshold, - NvttInterop.ToNvtt(dither), tc); - } - - // ------------------------------------------------------------------------- - - private void ThrowIfDisposed() - { - if (_ptr == null) - { - throw new ObjectDisposedException(nameof(NvttSurfaceHandle)); - } - } -} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurface.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurface.nativegen.cs new file mode 100644 index 0000000..391f541 --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurface.nativegen.cs @@ -0,0 +1,1030 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttSurface : System.IDisposable +{ + // From: nvttCreateSurface() + public static NvttSurface* Create() + { + return Api.nvttCreateSurface(); + } + + // From: nvttDestroySurface(NvttSurface*) + public void Dispose() + { + Api.nvttDestroySurface((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceClone(NvttSurface*) + public NvttSurface* Clone() + { + return Api.nvttSurfaceClone((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSetSurfaceWrapMode(NvttSurface*, NvttWrapMode) + public void SetWrapMode(NvttWrapMode mode) + { + Api.nvttSetSurfaceWrapMode( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + mode); + } + + // From: nvttSetSurfaceAlphaMode(NvttSurface*, NvttAlphaMode) + public void SetAlphaMode(NvttAlphaMode alphaMode) + { + Api.nvttSetSurfaceAlphaMode( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + alphaMode); + } + + // From: nvttSetSurfaceNormalMap(NvttSurface*, NvttBoolean) + public void SetNormalMap(NvttBoolean isNormalMap) + { + Api.nvttSetSurfaceNormalMap( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + isNormalMap); + } + + // From: nvttSurfaceIsNull(NvttSurface*) + public NvttBoolean IsNull() + { + return Api.nvttSurfaceIsNull((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceWidth(NvttSurface*) + public int Width() + { + return Api.nvttSurfaceWidth((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceHeight(NvttSurface*) + public int Height() + { + return Api.nvttSurfaceHeight((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceDepth(NvttSurface*) + public int Depth() + { + return Api.nvttSurfaceDepth((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceType(NvttSurface*) + public NvttTextureType Type() + { + return Api.nvttSurfaceType((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceWrapMode(NvttSurface*) + public NvttWrapMode WrapMode() + { + return Api.nvttSurfaceWrapMode((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceAlphaMode(NvttSurface*) + public NvttAlphaMode AlphaMode() + { + return Api.nvttSurfaceAlphaMode((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceIsNormalMap(NvttSurface*) + public NvttBoolean IsNormalMap() + { + return Api.nvttSurfaceIsNormalMap((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceCountMipmaps(NvttSurface*, int) + public int CountMipmaps(int min_size) + { + return Api.nvttSurfaceCountMipmaps( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + min_size); + } + + // From: nvttSurfaceAlphaTestCoverage(NvttSurface*, float, int) + public float AlphaTestCoverage(float alphaRef, int alpha_channel) + { + return Api.nvttSurfaceAlphaTestCoverage( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + alphaRef, + alpha_channel); + } + + // From: nvttSurfaceAverage(NvttSurface*, int, int, float) + public float Average(int channel, int alpha_channel, float gamma) + { + return Api.nvttSurfaceAverage( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + alpha_channel, + gamma); + } + + // From: nvttSurfaceData(NvttSurface*) + public float* Data() + { + return Api.nvttSurfaceData((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceChannel(NvttSurface*, int) + public float* Channel(int i) + { + return Api.nvttSurfaceChannel( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + i); + } + + // From: nvttSurfaceHistogram(NvttSurface*, int, float, float, int, int*, NvttTimingContext*) + public void Histogram(int channel, float rangeMin, float rangeMax, int binCount, int* binPtr, NvttTimingContext* tc) + { + Api.nvttSurfaceHistogram( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + rangeMin, + rangeMax, + binCount, + binPtr, + tc); + } + + // From: nvttSurfaceRange(NvttSurface*, int, float*, float*, int, float, NvttTimingContext*) + public void Range(int channel, float* rangeMin, float* rangeMax, int alpha_channel, float alpha_ref, NvttTimingContext* tc) + { + Api.nvttSurfaceRange( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + rangeMin, + rangeMax, + alpha_channel, + alpha_ref, + tc); + } + + // From: nvttSurfaceLoad(NvttSurface*, sbyte*, NvttBoolean*, NvttBoolean, NvttTimingContext*) + public NvttBoolean Load(ReadOnlySpan filename, NvttBoolean* hasAlpha, NvttBoolean expectSigned, NvttTimingContext* tc) + { + fixed (byte* pfilename = filename) + { + return Api.nvttSurfaceLoad( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pfilename, + hasAlpha, + expectSigned, + tc); + } + } + + // From: nvttSurfaceLoadFromMemory(NvttSurface*, void*, ulong, NvttBoolean*, NvttBoolean, NvttTimingContext*) + public NvttBoolean LoadFromMemory(void* data, ulong sizeInBytes, NvttBoolean* hasAlpha, NvttBoolean expectSigned, NvttTimingContext* tc) + { + return Api.nvttSurfaceLoadFromMemory( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + data, + sizeInBytes, + hasAlpha, + expectSigned, + tc); + } + + // From: nvttSurfaceSave(NvttSurface*, sbyte*, NvttBoolean, NvttBoolean, NvttTimingContext*) + public NvttBoolean Save(ReadOnlySpan fileName, NvttBoolean hasAlpha, NvttBoolean hdr, NvttTimingContext* tc) + { + fixed (byte* pfileName = fileName) + { + return Api.nvttSurfaceSave( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pfileName, + hasAlpha, + hdr, + tc); + } + } + + // From: nvttSurfaceSetImage(NvttSurface*, int, int, int, NvttTimingContext*) + public NvttBoolean SetImage(int w, int h, int d, NvttTimingContext* tc) + { + return Api.nvttSurfaceSetImage( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + w, + h, + d, + tc); + } + + // From: nvttSurfaceSetImageData(NvttSurface*, NvttInputFormat, int, int, int, void*, NvttBoolean, NvttTimingContext*) + public NvttBoolean SetImageData(NvttInputFormat format, int w, int h, int d, void* data, NvttBoolean unsignedToSigned, NvttTimingContext* tc) + { + return Api.nvttSurfaceSetImageData( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + format, + w, + h, + d, + data, + unsignedToSigned, + tc); + } + + // From: nvttSurfaceSetImageRGBA(NvttSurface*, NvttInputFormat, int, int, int, void*, void*, void*, void*, NvttTimingContext*) + public NvttBoolean SetImageRGBA(NvttInputFormat format, int w, int h, int d, void* r, void* g, void* b, void* a, NvttTimingContext* tc) + { + return Api.nvttSurfaceSetImageRGBA( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + format, + w, + h, + d, + r, + g, + b, + a, + tc); + } + + // From: nvttSurfaceSetImage2D(NvttSurface*, NvttFormat, int, int, void*, NvttTimingContext*) + public NvttBoolean SetImage2D(NvttFormat format, int w, int h, void* data, NvttTimingContext* tc) + { + return Api.nvttSurfaceSetImage2D( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + format, + w, + h, + data, + tc); + } + + // From: nvttSurfaceSetImage3D(NvttSurface*, NvttFormat, int, int, int, void*, NvttTimingContext*) + public NvttBoolean SetImage3D(NvttFormat format, int w, int h, int d, void* data, NvttTimingContext* tc) + { + return Api.nvttSurfaceSetImage3D( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + format, + w, + h, + d, + data, + tc); + } + + // From: nvttSurfaceResize(NvttSurface*, int, int, int, NvttResizeFilter, float, float*, NvttTimingContext*) + public void Resize(int w, int h, int d, NvttResizeFilter filter, float filterWidth, float* @params, NvttTimingContext* tc) + { + Api.nvttSurfaceResize( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + w, + h, + d, + filter, + filterWidth, + @params, + tc); + } + + // From: nvttSurfaceResizeMax(NvttSurface*, int, NvttRoundMode, NvttResizeFilter, NvttTimingContext*) + public void ResizeMax(int maxExtent, NvttRoundMode mode, NvttResizeFilter filter, NvttTimingContext* tc) + { + Api.nvttSurfaceResizeMax( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + maxExtent, + mode, + filter, + tc); + } + + // From: nvttSurfaceResizeMaxParams(NvttSurface*, int, NvttRoundMode, NvttResizeFilter, float, float*, NvttTimingContext*) + public void ResizeMaxParams(int maxExtent, NvttRoundMode mode, NvttResizeFilter filter, float filterWidth, float* @params, NvttTimingContext* tc) + { + Api.nvttSurfaceResizeMaxParams( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + maxExtent, + mode, + filter, + filterWidth, + @params, + tc); + } + + // From: nvttSurfaceResizeMakeSquare(NvttSurface*, int, NvttRoundMode, NvttResizeFilter, NvttTimingContext*) + public void ResizeMakeSquare(int maxExtent, NvttRoundMode mode, NvttResizeFilter filter, NvttTimingContext* tc) + { + Api.nvttSurfaceResizeMakeSquare( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + maxExtent, + mode, + filter, + tc); + } + + // From: nvttSurfaceBuildNextMipmap(NvttSurface*, NvttMipmapFilter, float, float*, int, NvttTimingContext*) + public NvttBoolean BuildNextMipmap(NvttMipmapFilter filter, float filterWidth, float* @params, int min_size, NvttTimingContext* tc) + { + return Api.nvttSurfaceBuildNextMipmap( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + filter, + filterWidth, + @params, + min_size, + tc); + } + + // From: nvttSurfaceBuildNextMipmapDefaults(NvttSurface*, NvttMipmapFilter, int, NvttTimingContext*) + public NvttBoolean BuildNextMipmapDefaults(NvttMipmapFilter filter, int min_size, NvttTimingContext* tc) + { + return Api.nvttSurfaceBuildNextMipmapDefaults( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + filter, + min_size, + tc); + } + + // From: nvttSurfaceBuildNextMipmapSolidColor(NvttSurface*, float*, NvttTimingContext*) + public NvttBoolean BuildNextMipmapSolidColor(float* color_components, NvttTimingContext* tc) + { + return Api.nvttSurfaceBuildNextMipmapSolidColor( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + color_components, + tc); + } + + // From: nvttSurfaceCanvasSize(NvttSurface*, int, int, int, NvttTimingContext*) + public void CanvasSize(int w, int h, int d, NvttTimingContext* tc) + { + Api.nvttSurfaceCanvasSize( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + w, + h, + d, + tc); + } + + // From: nvttSurfaceCanMakeNextMipmap(NvttSurface*, int) + public NvttBoolean CanMakeNextMipmap(int min_size) + { + return Api.nvttSurfaceCanMakeNextMipmap( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + min_size); + } + + // From: nvttSurfaceToLinear(NvttSurface*, float, NvttTimingContext*) + public void ToLinear(float gamma, NvttTimingContext* tc) + { + Api.nvttSurfaceToLinear( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + gamma, + tc); + } + + // From: nvttSurfaceToGamma(NvttSurface*, float, NvttTimingContext*) + public void ToGamma(float gamma, NvttTimingContext* tc) + { + Api.nvttSurfaceToGamma( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + gamma, + tc); + } + + // From: nvttSurfaceToLinearChannel(NvttSurface*, int, float, NvttTimingContext*) + public void ToLinearChannel(int channel, float gamma, NvttTimingContext* tc) + { + Api.nvttSurfaceToLinearChannel( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + gamma, + tc); + } + + // From: nvttSurfaceToGammaChannel(NvttSurface*, int, float, NvttTimingContext*) + public void ToGammaChannel(int channel, float gamma, NvttTimingContext* tc) + { + Api.nvttSurfaceToGammaChannel( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + gamma, + tc); + } + + // From: nvttSurfaceToSrgb(NvttSurface*, NvttTimingContext*) + public void ToSrgb(NvttTimingContext* tc) + { + Api.nvttSurfaceToSrgb( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceToSrgbUnclamped(NvttSurface*, NvttTimingContext*) + public void ToSrgbUnclamped(NvttTimingContext* tc) + { + Api.nvttSurfaceToSrgbUnclamped( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceToLinearFromSrgb(NvttSurface*, NvttTimingContext*) + public void ToLinearFromSrgb(NvttTimingContext* tc) + { + Api.nvttSurfaceToLinearFromSrgb( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceToLinearFromSrgbUnclamped(NvttSurface*, NvttTimingContext*) + public void ToLinearFromSrgbUnclamped(NvttTimingContext* tc) + { + Api.nvttSurfaceToLinearFromSrgbUnclamped( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceToXenonSrgb(NvttSurface*, NvttTimingContext*) + public void ToXenonSrgb(NvttTimingContext* tc) + { + Api.nvttSurfaceToXenonSrgb( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceToLinearFromXenonSrgb(NvttSurface*, NvttTimingContext*) + public void ToLinearFromXenonSrgb(NvttTimingContext* tc) + { + Api.nvttSurfaceToLinearFromXenonSrgb( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceTransform(NvttSurface*, float*, float*, float*, float*, float*, NvttTimingContext*) + public void Transform(float* w0, float* w1, float* w2, float* w3, float* offset, NvttTimingContext* tc) + { + Api.nvttSurfaceTransform( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + w0, + w1, + w2, + w3, + offset, + tc); + } + + // From: nvttSurfaceSwizzle(NvttSurface*, int, int, int, int, NvttTimingContext*) + public void Swizzle(int r, int g, int b, int a, NvttTimingContext* tc) + { + Api.nvttSurfaceSwizzle( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + r, + g, + b, + a, + tc); + } + + // From: nvttSurfaceScaleBias(NvttSurface*, int, float, float, NvttTimingContext*) + public void ScaleBias(int channel, float scale, float bias, NvttTimingContext* tc) + { + Api.nvttSurfaceScaleBias( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + scale, + bias, + tc); + } + + // From: nvttSurfaceClamp(NvttSurface*, int, float, float, NvttTimingContext*) + public void Clamp(int channel, float low, float high, NvttTimingContext* tc) + { + Api.nvttSurfaceClamp( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + low, + high, + tc); + } + + // From: nvttSurfaceBlend(NvttSurface*, float, float, float, float, float, NvttTimingContext*) + public void Blend(float r, float g, float b, float a, float t, NvttTimingContext* tc) + { + Api.nvttSurfaceBlend( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + r, + g, + b, + a, + t, + tc); + } + + // From: nvttSurfacePremultiplyAlpha(NvttSurface*, NvttTimingContext*) + public void PremultiplyAlpha(NvttTimingContext* tc) + { + Api.nvttSurfacePremultiplyAlpha( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceDemultiplyAlpha(NvttSurface*, float, NvttTimingContext*) + public void DemultiplyAlpha(float epsilon, NvttTimingContext* tc) + { + Api.nvttSurfaceDemultiplyAlpha( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + epsilon, + tc); + } + + // From: nvttSurfaceToGreyScale(NvttSurface*, float, float, float, float, NvttTimingContext*) + public void ToGreyScale(float redScale, float greenScale, float blueScale, float alphaScale, NvttTimingContext* tc) + { + Api.nvttSurfaceToGreyScale( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + redScale, + greenScale, + blueScale, + alphaScale, + tc); + } + + // From: nvttSurfaceSetBorder(NvttSurface*, float, float, float, float, NvttTimingContext*) + public void SetBorder(float r, float g, float b, float a, NvttTimingContext* tc) + { + Api.nvttSurfaceSetBorder( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + r, + g, + b, + a, + tc); + } + + // From: nvttSurfaceFill(NvttSurface*, float, float, float, float, NvttTimingContext*) + public void Fill(float r, float g, float b, float a, NvttTimingContext* tc) + { + Api.nvttSurfaceFill( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + r, + g, + b, + a, + tc); + } + + // From: nvttSurfaceScaleAlphaToCoverage(NvttSurface*, float, float, int, NvttTimingContext*) + public void ScaleAlphaToCoverage(float coverage, float alphaRef, int alpha_channel, NvttTimingContext* tc) + { + Api.nvttSurfaceScaleAlphaToCoverage( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + coverage, + alphaRef, + alpha_channel, + tc); + } + + // From: nvttSurfaceToRGBM(NvttSurface*, float, float, NvttTimingContext*) + public void ToRGBM(float range, float threshold, NvttTimingContext* tc) + { + Api.nvttSurfaceToRGBM( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + range, + threshold, + tc); + } + + // From: nvttSurfaceFromRGBM(NvttSurface*, float, float, NvttTimingContext*) + public void FromRGBM(float range, float threshold, NvttTimingContext* tc) + { + Api.nvttSurfaceFromRGBM( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + range, + threshold, + tc); + } + + // From: nvttSurfaceToLM(NvttSurface*, float, float, NvttTimingContext*) + public void ToLM(float range, float threshold, NvttTimingContext* tc) + { + Api.nvttSurfaceToLM( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + range, + threshold, + tc); + } + + // From: nvttSurfaceToRGBE(NvttSurface*, int, int, NvttTimingContext*) + public void ToRGBE(int mantissaBits, int exponentBits, NvttTimingContext* tc) + { + Api.nvttSurfaceToRGBE( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + mantissaBits, + exponentBits, + tc); + } + + // From: nvttSurfaceFromRGBE(NvttSurface*, int, int, NvttTimingContext*) + public void FromRGBE(int mantissaBits, int exponentBits, NvttTimingContext* tc) + { + Api.nvttSurfaceFromRGBE( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + mantissaBits, + exponentBits, + tc); + } + + // From: nvttSurfaceToYCoCg(NvttSurface*, NvttTimingContext*) + public void ToYCoCg(NvttTimingContext* tc) + { + Api.nvttSurfaceToYCoCg( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceBlockScaleCoCg(NvttSurface*, int, float, NvttTimingContext*) + public void BlockScaleCoCg(int bits, float threshold, NvttTimingContext* tc) + { + Api.nvttSurfaceBlockScaleCoCg( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + bits, + threshold, + tc); + } + + // From: nvttSurfaceFromYCoCg(NvttSurface*, NvttTimingContext*) + public void FromYCoCg(NvttTimingContext* tc) + { + Api.nvttSurfaceFromYCoCg( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceToLUVW(NvttSurface*, float, NvttTimingContext*) + public void ToLUVW(float range, NvttTimingContext* tc) + { + Api.nvttSurfaceToLUVW( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + range, + tc); + } + + // From: nvttSurfaceFromLUVW(NvttSurface*, float, NvttTimingContext*) + public void FromLUVW(float range, NvttTimingContext* tc) + { + Api.nvttSurfaceFromLUVW( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + range, + tc); + } + + // From: nvttSurfaceAbs(NvttSurface*, int, NvttTimingContext*) + public void Abs(int channel, NvttTimingContext* tc) + { + Api.nvttSurfaceAbs( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + tc); + } + + // From: nvttSurfaceConvolve(NvttSurface*, int, int, float*, NvttTimingContext*) + public void Convolve(int channel, int kernelSize, float* kernelData, NvttTimingContext* tc) + { + Api.nvttSurfaceConvolve( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + kernelSize, + kernelData, + tc); + } + + // From: nvttSurfaceToLogScale(NvttSurface*, int, float, NvttTimingContext*) + public void ToLogScale(int channel, float @base, NvttTimingContext* tc) + { + Api.nvttSurfaceToLogScale( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + @base, + tc); + } + + // From: nvttSurfaceFromLogScale(NvttSurface*, int, float, NvttTimingContext*) + public void FromLogScale(int channel, float @base, NvttTimingContext* tc) + { + Api.nvttSurfaceFromLogScale( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + @base, + tc); + } + + // From: nvttSurfaceSetAtlasBorder(NvttSurface*, int, int, float, float, float, float, NvttTimingContext*) + public void SetAtlasBorder(int w, int h, float r, float g, float b, float a, NvttTimingContext* tc) + { + Api.nvttSurfaceSetAtlasBorder( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + w, + h, + r, + g, + b, + a, + tc); + } + + // From: nvttSurfaceToneMap(NvttSurface*, NvttToneMapper, float*, NvttTimingContext*) + public void ToneMap(NvttToneMapper tm, float* parameters, NvttTimingContext* tc) + { + Api.nvttSurfaceToneMap( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tm, + parameters, + tc); + } + + // From: nvttSurfaceBinarize(NvttSurface*, int, float, NvttBoolean, NvttTimingContext*) + public void Binarize(int channel, float threshold, NvttBoolean dither, NvttTimingContext* tc) + { + Api.nvttSurfaceBinarize( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + threshold, + dither, + tc); + } + + // From: nvttSurfaceQuantize(NvttSurface*, int, int, NvttBoolean, NvttBoolean, NvttTimingContext*) + public void Quantize(int channel, int bits, NvttBoolean exactEndPoints, NvttBoolean dither, NvttTimingContext* tc) + { + Api.nvttSurfaceQuantize( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + bits, + exactEndPoints, + dither, + tc); + } + + // From: nvttSurfaceToNormalMap(NvttSurface*, float, float, float, float, NvttTimingContext*) + public void ToNormalMap(float sm, float medium, float big, float large, NvttTimingContext* tc) + { + Api.nvttSurfaceToNormalMap( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + sm, + medium, + big, + large, + tc); + } + + // From: nvttSurfaceNormalizeNormalMap(NvttSurface*, NvttTimingContext*) + public void NormalizeNormalMap(NvttTimingContext* tc) + { + Api.nvttSurfaceNormalizeNormalMap( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceTransformNormals(NvttSurface*, NvttNormalTransform, NvttTimingContext*) + public void TransformNormals(NvttNormalTransform xform, NvttTimingContext* tc) + { + Api.nvttSurfaceTransformNormals( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + xform, + tc); + } + + // From: nvttSurfaceReconstructNormals(NvttSurface*, NvttNormalTransform, NvttTimingContext*) + public void ReconstructNormals(NvttNormalTransform xform, NvttTimingContext* tc) + { + Api.nvttSurfaceReconstructNormals( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + xform, + tc); + } + + // From: nvttSurfaceToCleanNormalMap(NvttSurface*, NvttTimingContext*) + public void ToCleanNormalMap(NvttTimingContext* tc) + { + Api.nvttSurfaceToCleanNormalMap( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfacePackNormals(NvttSurface*, float, float, NvttTimingContext*) + public void PackNormals(float scale, float bias, NvttTimingContext* tc) + { + Api.nvttSurfacePackNormals( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + scale, + bias, + tc); + } + + // From: nvttSurfaceExpandNormals(NvttSurface*, float, float, NvttTimingContext*) + public void ExpandNormals(float scale, float bias, NvttTimingContext* tc) + { + Api.nvttSurfaceExpandNormals( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + scale, + bias, + tc); + } + + // From: nvttSurfaceCreateToksvigMap(NvttSurface*, float, NvttTimingContext*) + public NvttSurface* CreateToksvigMap(float power, NvttTimingContext* tc) + { + return Api.nvttSurfaceCreateToksvigMap( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + power, + tc); + } + + // From: nvttSurfaceCreateCleanMap(NvttSurface*, NvttTimingContext*) + public NvttSurface* CreateCleanMap(NvttTimingContext* tc) + { + return Api.nvttSurfaceCreateCleanMap( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceFlipX(NvttSurface*, NvttTimingContext*) + public void FlipX(NvttTimingContext* tc) + { + Api.nvttSurfaceFlipX( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceFlipY(NvttSurface*, NvttTimingContext*) + public void FlipY(NvttTimingContext* tc) + { + Api.nvttSurfaceFlipY( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceFlipZ(NvttSurface*, NvttTimingContext*) + public void FlipZ(NvttTimingContext* tc) + { + Api.nvttSurfaceFlipZ( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceCreateSubImage(NvttSurface*, int, int, int, int, int, int, NvttTimingContext*) + public NvttSurface* CreateSubImage(int x0, int x1, int y0, int y1, int z0, int z1, NvttTimingContext* tc) + { + return Api.nvttSurfaceCreateSubImage( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + x0, + x1, + y0, + y1, + z0, + z1, + tc); + } + + // From: nvttSurfaceCopyChannel(NvttSurface*, NvttSurface*, int, int, NvttTimingContext*) + public NvttBoolean CopyChannel(NvttSurface* srcImage, int srcChannel, int dstChannel, NvttTimingContext* tc) + { + return Api.nvttSurfaceCopyChannel( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + srcImage, + srcChannel, + dstChannel, + tc); + } + + // From: nvttSurfaceAddChannel(NvttSurface*, NvttSurface*, int, int, float, NvttTimingContext*) + public NvttBoolean AddChannel(NvttSurface* srcImage, int srcChannel, int dstChannel, float scale, NvttTimingContext* tc) + { + return Api.nvttSurfaceAddChannel( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + srcImage, + srcChannel, + dstChannel, + scale, + tc); + } + + // From: nvttSurfaceCopy(NvttSurface*, NvttSurface*, int, int, int, int, int, int, int, int, int, NvttTimingContext*) + public NvttBoolean Copy(NvttSurface* srcImage, int xsrc, int ysrc, int zsrc, int xsize, int ysize, int zsize, int xdst, int ydst, int zdst, NvttTimingContext* tc) + { + return Api.nvttSurfaceCopy( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + srcImage, + xsrc, + ysrc, + zsrc, + xsize, + ysize, + zsize, + xdst, + ydst, + zdst, + tc); + } + + // From: nvttSurfaceToGPU(NvttSurface*, NvttBoolean, NvttTimingContext*) + public void ToGPU(NvttBoolean performCopy, NvttTimingContext* tc) + { + Api.nvttSurfaceToGPU( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + performCopy, + tc); + } + + // From: nvttSurfaceToCPU(NvttSurface*, NvttTimingContext*) + public void ToCPU(NvttTimingContext* tc) + { + Api.nvttSurfaceToCPU( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + tc); + } + + // From: nvttSurfaceGPUData(NvttSurface*) + public float* GPUData() + { + return Api.nvttSurfaceGPUData((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceGPUDataMutable(NvttSurface*) + public float* GPUDataMutable() + { + return Api.nvttSurfaceGPUDataMutable((NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttRmsError(NvttSurface*, NvttSurface*, NvttTimingContext*) + public float RmsError(NvttSurface* img, NvttTimingContext* tc) + { + return Api.nvttRmsError( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + tc); + } + + // From: nvttRmsAlphaError(NvttSurface*, NvttSurface*, NvttTimingContext*) + public float RmsAlphaError(NvttSurface* img, NvttTimingContext* tc) + { + return Api.nvttRmsAlphaError( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + tc); + } + + // From: nvttRmsCIELabError(NvttSurface*, NvttSurface*, NvttTimingContext*) + public float RmsCIELabError(NvttSurface* img, NvttTimingContext* tc) + { + return Api.nvttRmsCIELabError( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + tc); + } + + // From: nvttAngularError(NvttSurface*, NvttSurface*, NvttTimingContext*) + public float AngularError(NvttSurface* img, NvttTimingContext* tc) + { + return Api.nvttAngularError( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + tc); + } + + // From: nvttDiff(NvttSurface*, NvttSurface*, float, NvttTimingContext*) + public NvttSurface* Diff(NvttSurface* img, float scale, NvttTimingContext* tc) + { + return Api.nvttDiff( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + scale, + tc); + } + + // From: nvttRmsToneMappedError(NvttSurface*, NvttSurface*, float, NvttTimingContext*) + public float RmsToneMappedError(NvttSurface* img, float exposure, NvttTimingContext* tc) + { + return Api.nvttRmsToneMappedError( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + img, + exposure, + tc); + } + + // From: nvttHistogram(NvttSurface*, int, int, NvttTimingContext*) + public NvttSurface* Histogram(int width, int height, NvttTimingContext* tc) + { + return Api.nvttHistogram( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + width, + height, + tc); + } + + // From: nvttHistogramRange(NvttSurface*, float, float, int, int, NvttTimingContext*) + public NvttSurface* HistogramRange(float minRange, float maxRange, int width, int height, NvttTimingContext* tc) + { + return Api.nvttHistogramRange( + (NvttSurface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + minRange, + maxRange, + width, + height, + tc); + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurfaceSet.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurfaceSet.cs deleted file mode 100644 index 3dc3510..0000000 --- a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurfaceSet.cs +++ /dev/null @@ -1,144 +0,0 @@ -namespace Ghost.Nvtt.Wrapper; - -/// -/// Wrapper around an nvtt surface set — a collection of faces and mip levels -/// loaded from a DDS file or built programmatically. -/// -public sealed unsafe class NvttSurfaceSetHandle : IDisposable -{ - private NvttSurfaceSet* _ptr; - - /// Raw pointer - use only when calling the native API directly. - public NvttSurfaceSet* Ptr => _ptr; - - // ------------------------------------------------------------------------- - // Construction / destruction - // ------------------------------------------------------------------------- - - public NvttSurfaceSetHandle() => _ptr = Api.nvttCreateSurfaceSet(); - - public void Dispose() - { - if (_ptr != null) - { - Api.nvttDestroySurfaceSet(_ptr); - _ptr = null; - } - } - - // ------------------------------------------------------------------------- - // Read-only properties - // ------------------------------------------------------------------------- - - /// Texture dimensionality stored in this set. - public NvttTextureType TextureType - { - get { ThrowIfDisposed(); return Api.nvttSurfaceSetGetTextureType(_ptr); } - } - - /// Number of faces (1 for 2-D / 3-D, 6 for cube maps). - public int FaceCount - { - get { ThrowIfDisposed(); return Api.nvttSurfaceSetGetFaceCount(_ptr); } - } - - /// Number of mip levels. - public int MipmapCount - { - get { ThrowIfDisposed(); return Api.nvttSurfaceSetGetMipmapCount(_ptr); } - } - - /// Width of the base (mip 0) image in pixels. - public int Width - { - get { ThrowIfDisposed(); return Api.nvttSurfaceSetGetWidth(_ptr); } - } - - /// Height of the base (mip 0) image in pixels. - public int Height - { - get { ThrowIfDisposed(); return Api.nvttSurfaceSetGetHeight(_ptr); } - } - - /// Depth of the base (mip 0) image (1 for 2-D textures). - public int Depth - { - get { ThrowIfDisposed(); return Api.nvttSurfaceSetGetDepth(_ptr); } - } - - // ------------------------------------------------------------------------- - // Surface access - // ------------------------------------------------------------------------- - - /// - /// Returns the raw pointer for the given face - /// and mip level. The pointer is owned by this surface set - do NOT dispose - /// it. - /// - public NvttSurface* GetSurfacePtr(int faceId, int mipId, bool expectSigned = false) - { - ThrowIfDisposed(); - return Api.nvttSurfaceSetGetSurface(_ptr, faceId, mipId, - NvttInterop.ToNvtt(expectSigned)); - } - - // ------------------------------------------------------------------------- - // Load / Save - // ------------------------------------------------------------------------- - - /// Resets the surface set to an empty state. - public void Reset() - { - ThrowIfDisposed(); - Api.nvttResetSurfaceSet(_ptr); - } - - /// Loads from a DDS file. Returns false on failure. - public bool LoadDDS(string fileName, bool forceNormal = false) - { - ThrowIfDisposed(); - Span buf = stackalloc byte[NvttInterop._MAX_STACK_PATH]; - var utf8 = NvttInterop.ToUtf8(fileName, buf); - fixed (byte* p = utf8) - { - return NvttInterop.ToBool( - Api.nvttSurfaceSetLoadDDS(_ptr, (sbyte*)p, - NvttInterop.ToNvtt(forceNormal))); - } - } - - /// Loads from a managed byte array containing DDS data. Returns false on failure. - public bool LoadDDSFromMemory(ReadOnlySpan data, bool forceNormal = false) - { - ThrowIfDisposed(); - fixed (byte* p = data) - { - return NvttInterop.ToBool( - Api.nvttSurfaceSetLoadDDSFromMemory(_ptr, p, (ulong)data.Length, - NvttInterop.ToNvtt(forceNormal))); - } - } - - /// Saves a single face/mip as an image file. Returns false on failure. - public bool SaveImage(string fileName, int faceId, int mipId) - { - ThrowIfDisposed(); - Span buf = stackalloc byte[NvttInterop._MAX_STACK_PATH]; - var utf8 = NvttInterop.ToUtf8(fileName, buf); - fixed (byte* p = utf8) - { - return NvttInterop.ToBool( - Api.nvttSurfaceSetSaveImage(_ptr, (sbyte*)p, faceId, mipId)); - } - } - - // ------------------------------------------------------------------------- - - private void ThrowIfDisposed() - { - if (_ptr == null) - { - throw new ObjectDisposedException(nameof(NvttSurfaceSetHandle)); - } - } -} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurfaceSet.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurfaceSet.nativegen.cs new file mode 100644 index 0000000..61a06fe --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttSurfaceSet.nativegen.cs @@ -0,0 +1,107 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttSurfaceSet : System.IDisposable +{ + // From: nvttCreateSurfaceSet() + public static NvttSurfaceSet* Create() + { + return Api.nvttCreateSurfaceSet(); + } + + // From: nvttDestroySurfaceSet(NvttSurfaceSet*) + public void Dispose() + { + Api.nvttDestroySurfaceSet((NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttResetSurfaceSet(NvttSurfaceSet*) + public void Reset() + { + Api.nvttResetSurfaceSet((NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceSetGetTextureType(NvttSurfaceSet*) + public NvttTextureType GetTextureType() + { + return Api.nvttSurfaceSetGetTextureType((NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceSetGetFaceCount(NvttSurfaceSet*) + public int GetFaceCount() + { + return Api.nvttSurfaceSetGetFaceCount((NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceSetGetMipmapCount(NvttSurfaceSet*) + public int GetMipmapCount() + { + return Api.nvttSurfaceSetGetMipmapCount((NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceSetGetWidth(NvttSurfaceSet*) + public int GetWidth() + { + return Api.nvttSurfaceSetGetWidth((NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceSetGetHeight(NvttSurfaceSet*) + public int GetHeight() + { + return Api.nvttSurfaceSetGetHeight((NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceSetGetDepth(NvttSurfaceSet*) + public int GetDepth() + { + return Api.nvttSurfaceSetGetDepth((NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttSurfaceSetGetSurface(NvttSurfaceSet*, int, int, NvttBoolean) + public NvttSurface* GetSurface(int faceId, int mipId, NvttBoolean expectSigned) + { + return Api.nvttSurfaceSetGetSurface( + (NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + faceId, + mipId, + expectSigned); + } + + // From: nvttSurfaceSetLoadDDS(NvttSurfaceSet*, sbyte*, NvttBoolean) + public NvttBoolean LoadDDS(ReadOnlySpan fileName, NvttBoolean forcenormal) + { + fixed (byte* pfileName = fileName) + { + return Api.nvttSurfaceSetLoadDDS( + (NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pfileName, + forcenormal); + } + } + + // From: nvttSurfaceSetLoadDDSFromMemory(NvttSurfaceSet*, void*, ulong, NvttBoolean) + public NvttBoolean LoadDDSFromMemory(void* data, ulong sizeInBytes, NvttBoolean forcenormal) + { + return Api.nvttSurfaceSetLoadDDSFromMemory( + (NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + data, + sizeInBytes, + forcenormal); + } + + // From: nvttSurfaceSetSaveImage(NvttSurfaceSet*, sbyte*, int, int) + public NvttBoolean SaveImage(ReadOnlySpan fileName, int faceId, int mipId) + { + fixed (byte* pfileName = fileName) + { + return Api.nvttSurfaceSetSaveImage( + (NvttSurfaceSet*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pfileName, + faceId, + mipId); + } + } +} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttTimingContext.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttTimingContext.cs deleted file mode 100644 index cd2d213..0000000 --- a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttTimingContext.cs +++ /dev/null @@ -1,99 +0,0 @@ -namespace Ghost.Nvtt.Wrapper; - -/// -/// Wraps an nvtt timing context that records per-operation wall-clock times. -/// Obtain one from or create a -/// standalone instance and pass it as the optional tc parameter on -/// surface methods. -/// -public sealed unsafe class NvttTimingContextHandle : IDisposable -{ - private NvttTimingContext* _ptr; - - /// Raw pointer - use only when calling the native API directly. - public NvttTimingContext* Ptr => _ptr; - - // ------------------------------------------------------------------------- - // Construction / destruction - // ------------------------------------------------------------------------- - - /// Creates a timing context at the specified detail level (0 = off, higher = more detail). - public NvttTimingContextHandle(int detailLevel = 1) - => _ptr = Api.nvttCreateTimingContext(detailLevel); - - /// Wraps an already-owned native pointer (ownership transferred to this object). - internal NvttTimingContextHandle(NvttTimingContext* owned) => _ptr = owned; - - public void Dispose() - { - if (_ptr != null) - { - Api.nvttDestroyTimingContext(_ptr); - _ptr = null; - } - } - - // ------------------------------------------------------------------------- - // Properties - // ------------------------------------------------------------------------- - - /// - /// Sets the detail level (0 = disabled; higher values record more sub-operations). - /// - public int DetailLevel - { - set - { - ThrowIfDisposed(); - Api.nvttTimingContextSetDetailLevel(_ptr, value); - } - } - - /// Number of timing records captured so far. - public int RecordCount - { - get - { - ThrowIfDisposed(); - return Api.nvttTimingContextGetRecordCount(_ptr); - } - } - - // ------------------------------------------------------------------------- - // Methods - // ------------------------------------------------------------------------- - - /// - /// Returns the description and elapsed seconds for the record at - /// . - /// - public (string description, double seconds) GetRecord(int index) - { - ThrowIfDisposed(); - Span buf = stackalloc byte[256]; - double seconds; - fixed (byte* p = buf) - { - Api.nvttTimingContextGetRecordSafe(_ptr, index, (sbyte*)p, (nuint)buf.Length, &seconds); - var desc = NvttInterop.FromUtf8((sbyte*)p) ?? string.Empty; - return (desc, seconds); - } - } - - /// Prints all timing records to stdout via the native library. - public void PrintRecords() - { - ThrowIfDisposed(); - Api.nvttTimingContextPrintRecords(_ptr); - } - - // ------------------------------------------------------------------------- - - private void ThrowIfDisposed() - { - if (_ptr == null) - { - throw new ObjectDisposedException(nameof(NvttTimingContextHandle)); - } - } -} diff --git a/src/ThridParty/Ghost.Nvtt/Wrapper/NvttTimingContext.nativegen.cs b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttTimingContext.nativegen.cs new file mode 100644 index 0000000..3d240b6 --- /dev/null +++ b/src/ThridParty/Ghost.Nvtt/Wrapper/NvttTimingContext.nativegen.cs @@ -0,0 +1,61 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +namespace Ghost.Nvtt; + +public unsafe partial struct NvttTimingContext : System.IDisposable +{ + // From: nvttCreateTimingContext(int) + public static NvttTimingContext* Create(int detailLevel) + { + return Api.nvttCreateTimingContext(detailLevel); + } + + // From: nvttDestroyTimingContext(NvttTimingContext*) + public void Dispose() + { + Api.nvttDestroyTimingContext((NvttTimingContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttTimingContextSetDetailLevel(NvttTimingContext*, int) + public void SetDetailLevel(int detailLevel) + { + Api.nvttTimingContextSetDetailLevel( + (NvttTimingContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + detailLevel); + } + + // From: nvttTimingContextGetRecordCount(NvttTimingContext*) + public int GetRecordCount() + { + return Api.nvttTimingContextGetRecordCount((NvttTimingContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: nvttTimingContextGetRecord(NvttTimingContext*, int, sbyte*, double*) + public void GetRecord(int i, sbyte* description, double* seconds) + { + Api.nvttTimingContextGetRecord( + (NvttTimingContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + i, + description, + seconds); + } + + // From: nvttTimingContextGetRecordSafe(NvttTimingContext*, int, sbyte*, nuint, double*) + public nuint GetRecordSafe(int i, sbyte* outDescription, nuint outDescriptionSize, double* seconds) + { + return Api.nvttTimingContextGetRecordSafe( + (NvttTimingContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + i, + outDescription, + outDescriptionSize, + seconds); + } + + // From: nvttTimingContextPrintRecords(NvttTimingContext*) + public void PrintRecords() + { + Api.nvttTimingContextPrintRecords((NvttTimingContext*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/LoadOpts.cs b/src/ThridParty/Ghost.Ufbx/LoadOpts.cs deleted file mode 100644 index 3086c39..0000000 --- a/src/ThridParty/Ghost.Ufbx/LoadOpts.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Runtime.InteropServices; - -namespace Ghost.Ufbx; - -public unsafe partial class LoadOpts -{ - public partial cstring ObjMtlPath - { - get => _objMtlPath; - set - { - _objMtlPath.Dispose(); - _objMtlPath = new cstring(value); - _ptr->obj_mtl_path = new ufbx_string - { - data = (sbyte*)_objMtlPath.ptr, - length = (nuint)_objMtlPath.length, - }; - } - } - - public partial cstring Filename - { - get => _filename; - set - { - _filename.Dispose(); - _filename = new cstring(value); - _ptr->filename = new ufbx_string - { - data = (sbyte*)_filename.ptr, - length = (nuint)_filename.length, - }; - } - } - - public partial void Dispose() - { - _objMtlPath.Dispose(); - _filename.Dispose(); - if (_csAlloc && _ptr != null) - { - NativeMemory.Free(_ptr); - _ptr = null; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/UfbxErrorExtensions.cs b/src/ThridParty/Ghost.Ufbx/UfbxErrorExtensions.cs deleted file mode 100644 index 4728c8c..0000000 --- a/src/ThridParty/Ghost.Ufbx/UfbxErrorExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Text; - -namespace Ghost.Ufbx; - -public static unsafe class UfbxErrorExtensions -{ - /// - /// Formats a ufbx_error into a human-readable string using ufbx_format_error. - /// Allocates a 2KB stack buffer; the result is truncated if the message exceeds that. - /// - public static string FormatError(ref this ufbx_error error) - { - const int BufferSize = 2048; - Span buffer = stackalloc byte[BufferSize]; - fixed (ufbx_error* pError = &error) - fixed (byte* pBuffer = buffer) - { - var len = Api.ufbx_format_error((sbyte*)pBuffer, (nuint)BufferSize, pError); - if (len == 0) - return string.Empty; - // ufbx_format_error returns the number of characters written (excluding null terminator) - return Encoding.UTF8.GetString(buffer[..(int)len]); - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Allocator.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Allocator.nativegen.cs deleted file mode 100644 index 7c0f448..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Allocator.nativegen.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Allocator -{ - private ufbx_allocator* _ptr; - - internal Allocator(ufbx_allocator* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public void* User => _ptr->user; - - internal ufbx_allocator* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AllocatorOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AllocatorOpts.nativegen.cs deleted file mode 100644 index 1ad8950..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AllocatorOpts.nativegen.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct AllocatorOpts -{ - private ufbx_allocator_opts* _ptr; - - internal AllocatorOpts(ufbx_allocator_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Allocator Allocator => new((ufbx_allocator*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->allocator)); - - public nuint MemoryLimit => _ptr->memory_limit; - - public nuint AllocationLimit => _ptr->allocation_limit; - - public nuint HugeThreshold => _ptr->huge_threshold; - - public nuint MaxChunkSize => _ptr->max_chunk_size; - - internal ufbx_allocator_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Anim.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Anim.nativegen.cs deleted file mode 100644 index 4db119f..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Anim.nativegen.cs +++ /dev/null @@ -1,91 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe ref struct Anim -{ - private ufbx_anim* _ptr; - - internal Anim(ufbx_anim* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_prop EvaluatePropLen(Element element, sbyte* name, nuint nameLen, double time) - { - return Api.ufbx_evaluate_prop_len(_ptr, element.GetUnsafePtr(), name, nameLen, time); - } - - public ufbx_prop EvaluateProp(Element element, sbyte* name, double time) - { - return Api.ufbx_evaluate_prop(_ptr, element.GetUnsafePtr(), name, time); - } - - public ufbx_prop EvaluatePropFlagsLen(Element element, sbyte* name, nuint nameLen, double time, uint flags) - { - return Api.ufbx_evaluate_prop_flags_len(_ptr, element.GetUnsafePtr(), name, nameLen, time, flags); - } - - public ufbx_prop EvaluatePropFlags(Element element, sbyte* name, double time, uint flags) - { - return Api.ufbx_evaluate_prop_flags(_ptr, element.GetUnsafePtr(), name, time, flags); - } - - public ufbx_props EvaluateProps(Element element, double time, Prop buffer, nuint bufferSize) - { - return Api.ufbx_evaluate_props(_ptr, element.GetUnsafePtr(), time, buffer.GetUnsafePtr(), bufferSize); - } - - public ufbx_props EvaluatePropsFlags(Element element, double time, Prop buffer, nuint bufferSize, uint flags) - { - return Api.ufbx_evaluate_props_flags(_ptr, element.GetUnsafePtr(), time, buffer.GetUnsafePtr(), bufferSize, flags); - } - - public ufbx_transform EvaluateTransform(Node node, double time) - { - return Api.ufbx_evaluate_transform(_ptr, node.GetUnsafePtr(), time); - } - - public ufbx_transform EvaluateTransformFlags(Node node, double time, uint flags) - { - return Api.ufbx_evaluate_transform_flags(_ptr, node.GetUnsafePtr(), time, flags); - } - - public float EvaluateBlendWeight(BlendChannel channel, double time) - { - return Api.ufbx_evaluate_blend_weight(_ptr, channel.GetUnsafePtr(), time); - } - - public float EvaluateBlendWeightFlags(BlendChannel channel, double time, uint flags) - { - return Api.ufbx_evaluate_blend_weight_flags(_ptr, channel.GetUnsafePtr(), time, flags); - } - - public void FreeAnim() - { - Api.ufbx_free_anim(_ptr); - } - - public void RetainAnim() - { - Api.ufbx_retain_anim(_ptr); - } - - public double TimeBegin => _ptr->time_begin; - - public double TimeEnd => _ptr->time_end; - - public AnimLayerList Layers => new(_ptr->layers.data, _ptr->layers.count); - - public ReadOnlySpan OverrideLayerWeights => _ptr->override_layer_weights.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->override_layer_weights.data, checked((int)_ptr->override_layer_weights.count)); - - public ReadOnlySpan PropOverrides => _ptr->prop_overrides.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->prop_overrides.data, checked((int)_ptr->prop_overrides.count)); - - public ReadOnlySpan TransformOverrides => _ptr->transform_overrides.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->transform_overrides.data, checked((int)_ptr->transform_overrides.count)); - - public bool IgnoreConnections => _ptr->ignore_connections; - - public bool Custom => _ptr->custom; - - internal ufbx_anim* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimCurve.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AnimCurve.nativegen.cs deleted file mode 100644 index 505d51e..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimCurve.nativegen.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct AnimCurve -{ - private ufbx_anim_curve* _ptr; - - internal AnimCurve(ufbx_anim_curve* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public float EvaluateCurve(double time, float defaultValue) - { - return Api.ufbx_evaluate_curve(_ptr, time, defaultValue); - } - - public float EvaluateCurveFlags(double time, float defaultValue, uint flags) - { - return Api.ufbx_evaluate_curve_flags(_ptr, time, defaultValue, flags); - } - - public ReadOnlySpan Keyframes => _ptr->keyframes.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->keyframes.data, checked((int)_ptr->keyframes.count)); - - public Extrapolation PreExtrapolation => new((ufbx_extrapolation*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->pre_extrapolation)); - - public Extrapolation PostExtrapolation => new((ufbx_extrapolation*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->post_extrapolation)); - - public float MinValue => _ptr->min_value; - - public float MaxValue => _ptr->max_value; - - public double MinTime => _ptr->min_time; - - public double MaxTime => _ptr->max_time; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_anim_curve* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimCurveList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AnimCurveList.nativegen.cs deleted file mode 100644 index 9136c65..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimCurveList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct AnimCurveList -{ - private readonly ufbx_anim_curve** _data; - public int Count { get; } - - internal AnimCurveList(ufbx_anim_curve** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public AnimCurve this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_anim_curve** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_anim_curve** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public AnimCurve Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimLayer.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AnimLayer.nativegen.cs deleted file mode 100644 index b6cbcac..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimLayer.nativegen.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct AnimLayer -{ - private ufbx_anim_layer* _ptr; - - internal AnimLayer(ufbx_anim_layer* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public AnimProp FindAnimPropLen(Element element, sbyte* prop, nuint propLen) - { - return new(Api.ufbx_find_anim_prop_len(_ptr, element.GetUnsafePtr(), prop, propLen)); - } - - public AnimProp FindAnimProp(Element element, sbyte* prop) - { - return new(Api.ufbx_find_anim_prop(_ptr, element.GetUnsafePtr(), prop)); - } - - public ufbx_anim_prop_list FindAnimProps(Element element) - { - return Api.ufbx_find_anim_props(_ptr, element.GetUnsafePtr()); - } - - public float Weight => _ptr->weight; - - public bool WeightIsAnimated => _ptr->weight_is_animated; - - public bool Blended => _ptr->blended; - - public bool Additive => _ptr->additive; - - public bool ComposeRotation => _ptr->compose_rotation; - - public bool ComposeScale => _ptr->compose_scale; - - public AnimValueList AnimValues => new(_ptr->anim_values.data, _ptr->anim_values.count); - - public ReadOnlySpan AnimProps => _ptr->anim_props.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->anim_props.data, checked((int)_ptr->anim_props.count)); - - public bool HasAnim => _ptr->anim != null; - public Anim Anim => _ptr->anim != null ? new(_ptr->anim) : throw new InvalidOperationException("Anim is null."); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_anim_layer* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimLayerList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AnimLayerList.nativegen.cs deleted file mode 100644 index 4ceecd4..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimLayerList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct AnimLayerList -{ - private readonly ufbx_anim_layer** _data; - public int Count { get; } - - internal AnimLayerList(ufbx_anim_layer** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public AnimLayer this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_anim_layer** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_anim_layer** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public AnimLayer Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AnimOpts.nativegen.cs deleted file mode 100644 index 30066ae..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimOpts.nativegen.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct AnimOpts -{ - private ufbx_anim_opts* _ptr; - - internal AnimOpts(ufbx_anim_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan LayerIds => _ptr->layer_ids.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->layer_ids.data, checked((int)_ptr->layer_ids.count)); - - public ReadOnlySpan OverrideLayerWeights => _ptr->override_layer_weights.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->override_layer_weights.data, checked((int)_ptr->override_layer_weights.count)); - - public ReadOnlySpan PropOverrides => _ptr->prop_overrides.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->prop_overrides.data, checked((int)_ptr->prop_overrides.count)); - - public ReadOnlySpan TransformOverrides => _ptr->transform_overrides.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->transform_overrides.data, checked((int)_ptr->transform_overrides.count)); - - public bool IgnoreConnections => _ptr->ignore_connections; - - public AllocatorOpts ResultAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->result_allocator)); - - internal ufbx_anim_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimProp.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AnimProp.nativegen.cs deleted file mode 100644 index 1c8c50a..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimProp.nativegen.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct AnimProp -{ - private ufbx_anim_prop* _ptr; - - internal AnimProp(ufbx_anim_prop* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool HasElement => _ptr->element != null; - public Element Element => _ptr->element != null ? new(_ptr->element) : throw new InvalidOperationException("Element is null."); - - public ReadOnlySpan PropNameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->prop_name); - public string PropName => NativeWrapperHelpers.GetString(_ptr->prop_name); - - public bool HasAnimValue => _ptr->anim_value != null; - public AnimValue AnimValue => _ptr->anim_value != null ? new(_ptr->anim_value) : throw new InvalidOperationException("AnimValue is null."); - - internal ufbx_anim_prop* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimStack.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AnimStack.nativegen.cs deleted file mode 100644 index 2e1abba..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimStack.nativegen.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct AnimStack -{ - private ufbx_anim_stack* _ptr; - - internal AnimStack(ufbx_anim_stack* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public double TimeBegin => _ptr->time_begin; - - public double TimeEnd => _ptr->time_end; - - public AnimLayerList Layers => new(_ptr->layers.data, _ptr->layers.count); - - public bool HasAnim => _ptr->anim != null; - public Anim Anim => _ptr->anim != null ? new(_ptr->anim) : throw new InvalidOperationException("Anim is null."); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_anim_stack* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimStackList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AnimStackList.nativegen.cs deleted file mode 100644 index 218082b..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimStackList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct AnimStackList -{ - private readonly ufbx_anim_stack** _data; - public int Count { get; } - - internal AnimStackList(ufbx_anim_stack** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public AnimStack this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_anim_stack** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_anim_stack** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public AnimStack Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimValue.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AnimValue.nativegen.cs deleted file mode 100644 index 71ded9e..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimValue.nativegen.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct AnimValue -{ - private ufbx_anim_value* _ptr; - - internal AnimValue(ufbx_anim_value* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public float EvaluateAnimValueReal(double time) - { - return Api.ufbx_evaluate_anim_value_real(_ptr, time); - } - - public Misaki.HighPerformance.Mathematics.float3 EvaluateAnimValueVec3(double time) - { - return Api.ufbx_evaluate_anim_value_vec3(_ptr, time); - } - - public float EvaluateAnimValueRealFlags(double time, uint flags) - { - return Api.ufbx_evaluate_anim_value_real_flags(_ptr, time, flags); - } - - public Misaki.HighPerformance.Mathematics.float3 EvaluateAnimValueVec3Flags(double time, uint flags) - { - return Api.ufbx_evaluate_anim_value_vec3_flags(_ptr, time, flags); - } - - public Misaki.HighPerformance.Mathematics.float3 DefaultValue => _ptr->default_value; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_anim_value* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimValueList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AnimValueList.nativegen.cs deleted file mode 100644 index 2fcc7e4..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AnimValueList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct AnimValueList -{ - private readonly ufbx_anim_value** _data; - public int Count { get; } - - internal AnimValueList(ufbx_anim_value** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public AnimValue this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_anim_value** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_anim_value** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public AnimValue Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Application.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Application.nativegen.cs deleted file mode 100644 index 9010f62..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Application.nativegen.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Application -{ - private ufbx_application* _ptr; - - internal Application(ufbx_application* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan VendorBytes => NativeWrapperHelpers.AsByteSpan(_ptr->vendor); - public string Vendor => NativeWrapperHelpers.GetString(_ptr->vendor); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public ReadOnlySpan VersionBytes => NativeWrapperHelpers.AsByteSpan(_ptr->version); - public string Version => NativeWrapperHelpers.GetString(_ptr->version); - - internal ufbx_application* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AudioClip.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AudioClip.nativegen.cs deleted file mode 100644 index 52b483b..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AudioClip.nativegen.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct AudioClip -{ - private ufbx_audio_clip* _ptr; - - internal AudioClip(ufbx_audio_clip* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan FilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->filename); - public string Filename => NativeWrapperHelpers.GetString(_ptr->filename); - - public ReadOnlySpan AbsoluteFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->absolute_filename); - public string AbsoluteFilename => NativeWrapperHelpers.GetString(_ptr->absolute_filename); - - public ReadOnlySpan RelativeFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->relative_filename); - public string RelativeFilename => NativeWrapperHelpers.GetString(_ptr->relative_filename); - - public ReadOnlySpan RawFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_filename); - - public ReadOnlySpan RawAbsoluteFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_absolute_filename); - - public ReadOnlySpan RawRelativeFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_relative_filename); - - public ReadOnlySpan Content => NativeWrapperHelpers.AsSpan(_ptr->content); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_audio_clip* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AudioClipList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AudioClipList.nativegen.cs deleted file mode 100644 index 5504bf6..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AudioClipList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct AudioClipList -{ - private readonly ufbx_audio_clip** _data; - public int Count { get; } - - internal AudioClipList(ufbx_audio_clip** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public AudioClip this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_audio_clip** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_audio_clip** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public AudioClip Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AudioLayer.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AudioLayer.nativegen.cs deleted file mode 100644 index bb140f8..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AudioLayer.nativegen.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct AudioLayer -{ - private ufbx_audio_layer* _ptr; - - internal AudioLayer(ufbx_audio_layer* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public AudioClipList Clips => new(_ptr->clips.data, _ptr->clips.count); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_audio_layer* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/AudioLayerList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/AudioLayerList.nativegen.cs deleted file mode 100644 index b93a3fc..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/AudioLayerList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct AudioLayerList -{ - private readonly ufbx_audio_layer** _data; - public int Count { get; } - - internal AudioLayerList(ufbx_audio_layer** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public AudioLayer this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_audio_layer** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_audio_layer** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public AudioLayer Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BakeOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BakeOpts.nativegen.cs deleted file mode 100644 index 6c2ef47..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BakeOpts.nativegen.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BakeOpts -{ - private ufbx_bake_opts* _ptr; - - internal BakeOpts(ufbx_bake_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public AllocatorOpts TempAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->temp_allocator)); - - public AllocatorOpts ResultAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->result_allocator)); - - public bool TrimStartTime => _ptr->trim_start_time; - - public double ResampleRate => _ptr->resample_rate; - - public double MinimumSampleRate => _ptr->minimum_sample_rate; - - public double MaximumSampleRate => _ptr->maximum_sample_rate; - - public bool BakeTransformProps => _ptr->bake_transform_props; - - public bool SkipNodeTransforms => _ptr->skip_node_transforms; - - public bool NoResampleRotation => _ptr->no_resample_rotation; - - public bool IgnoreLayerWeightAnimation => _ptr->ignore_layer_weight_animation; - - public nuint MaxKeyframeSegments => _ptr->max_keyframe_segments; - - public ufbx_bake_step_handling StepHandling => _ptr->step_handling; - - public double StepCustomDuration => _ptr->step_custom_duration; - - public double StepCustomEpsilon => _ptr->step_custom_epsilon; - - public uint EvaluateFlags => _ptr->evaluate_flags; - - public bool KeyReductionEnabled => _ptr->key_reduction_enabled; - - public bool KeyReductionRotation => _ptr->key_reduction_rotation; - - public double KeyReductionThreshold => _ptr->key_reduction_threshold; - - public nuint KeyReductionPasses => _ptr->key_reduction_passes; - - internal ufbx_bake_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedAnim.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BakedAnim.nativegen.cs deleted file mode 100644 index e98a624..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedAnim.nativegen.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BakedAnim -{ - private ufbx_baked_anim* _ptr; - - internal BakedAnim(ufbx_baked_anim* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public void RetainBakedAnim() - { - Api.ufbx_retain_baked_anim(_ptr); - } - - public void FreeBakedAnim() - { - Api.ufbx_free_baked_anim(_ptr); - } - - public BakedNode FindBakedNodeByTypedId(uint typedId) - { - return new(Api.ufbx_find_baked_node_by_typed_id(_ptr, typedId)); - } - - public BakedNode FindBakedNode(Node node) - { - return new(Api.ufbx_find_baked_node(_ptr, node.GetUnsafePtr())); - } - - public BakedElement FindBakedElementByElementId(uint elementId) - { - return new(Api.ufbx_find_baked_element_by_element_id(_ptr, elementId)); - } - - public BakedElement FindBakedElement(Element element) - { - return new(Api.ufbx_find_baked_element(_ptr, element.GetUnsafePtr())); - } - - public ReadOnlySpan Nodes => _ptr->nodes.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->nodes.data, checked((int)_ptr->nodes.count)); - - public ReadOnlySpan Elements => _ptr->elements.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->elements.data, checked((int)_ptr->elements.count)); - - public double PlaybackTimeBegin => _ptr->playback_time_begin; - - public double PlaybackTimeEnd => _ptr->playback_time_end; - - public double PlaybackDuration => _ptr->playback_duration; - - public double KeyTimeMin => _ptr->key_time_min; - - public double KeyTimeMax => _ptr->key_time_max; - - public BakedAnimMetadata Metadata => new((ufbx_baked_anim_metadata*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->metadata)); - - internal ufbx_baked_anim* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedAnimMetadata.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BakedAnimMetadata.nativegen.cs deleted file mode 100644 index 55da747..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedAnimMetadata.nativegen.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BakedAnimMetadata -{ - private ufbx_baked_anim_metadata* _ptr; - - internal BakedAnimMetadata(ufbx_baked_anim_metadata* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public nuint ResultMemoryUsed => _ptr->result_memory_used; - - public nuint TempMemoryUsed => _ptr->temp_memory_used; - - public nuint ResultAllocs => _ptr->result_allocs; - - public nuint TempAllocs => _ptr->temp_allocs; - - internal ufbx_baked_anim_metadata* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedElement.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BakedElement.nativegen.cs deleted file mode 100644 index cba5509..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedElement.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BakedElement -{ - private ufbx_baked_element* _ptr; - - internal BakedElement(ufbx_baked_element* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint ElementId => _ptr->element_id; - - public ReadOnlySpan Props => _ptr->props.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->props.data, checked((int)_ptr->props.count)); - - internal ufbx_baked_element* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedNode.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BakedNode.nativegen.cs deleted file mode 100644 index 2c2678a..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedNode.nativegen.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BakedNode -{ - private ufbx_baked_node* _ptr; - - internal BakedNode(ufbx_baked_node* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint TypedId => _ptr->typed_id; - - public uint ElementId => _ptr->element_id; - - public bool ConstantTranslation => _ptr->constant_translation; - - public bool ConstantRotation => _ptr->constant_rotation; - - public bool ConstantScale => _ptr->constant_scale; - - public ReadOnlySpan TranslationKeys => _ptr->translation_keys.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->translation_keys.data, checked((int)_ptr->translation_keys.count)); - - public ReadOnlySpan RotationKeys => _ptr->rotation_keys.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->rotation_keys.data, checked((int)_ptr->rotation_keys.count)); - - public ReadOnlySpan ScaleKeys => _ptr->scale_keys.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->scale_keys.data, checked((int)_ptr->scale_keys.count)); - - internal ufbx_baked_node* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedProp.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BakedProp.nativegen.cs deleted file mode 100644 index 2592b7f..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedProp.nativegen.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BakedProp -{ - private ufbx_baked_prop* _ptr; - - internal BakedProp(ufbx_baked_prop* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public bool ConstantValue => _ptr->constant_value; - - public ReadOnlySpan Keys => _ptr->keys.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->keys.data, checked((int)_ptr->keys.count)); - - internal ufbx_baked_prop* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedQuat.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BakedQuat.nativegen.cs deleted file mode 100644 index 4031661..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedQuat.nativegen.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BakedQuat -{ - private ufbx_baked_quat* _ptr; - - internal BakedQuat(ufbx_baked_quat* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public double Time => _ptr->time; - - public Misaki.HighPerformance.Mathematics.quaternion Value => _ptr->value; - - public ufbx_baked_key_flags Flags => _ptr->flags; - - internal ufbx_baked_quat* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedVec3.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BakedVec3.nativegen.cs deleted file mode 100644 index 8bdffc4..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BakedVec3.nativegen.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BakedVec3 -{ - private ufbx_baked_vec3* _ptr; - - internal BakedVec3(ufbx_baked_vec3* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public double Time => _ptr->time; - - public Misaki.HighPerformance.Mathematics.float3 Value => _ptr->value; - - public ufbx_baked_key_flags Flags => _ptr->flags; - - internal ufbx_baked_vec3* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendChannel.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BlendChannel.nativegen.cs deleted file mode 100644 index 2a1f2f2..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendChannel.nativegen.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BlendChannel -{ - private ufbx_blend_channel* _ptr; - - internal BlendChannel(ufbx_blend_channel* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public float Weight => _ptr->weight; - - public ReadOnlySpan Keyframes => _ptr->keyframes.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->keyframes.data, checked((int)_ptr->keyframes.count)); - - public bool HasTargetShape => _ptr->target_shape != null; - public BlendShape TargetShape => _ptr->target_shape != null ? new(_ptr->target_shape) : throw new InvalidOperationException("TargetShape is null."); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_blend_channel* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendChannelList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BlendChannelList.nativegen.cs deleted file mode 100644 index e8e4fc1..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendChannelList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct BlendChannelList -{ - private readonly ufbx_blend_channel** _data; - public int Count { get; } - - internal BlendChannelList(ufbx_blend_channel** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public BlendChannel this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_blend_channel** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_blend_channel** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public BlendChannel Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendDeformer.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BlendDeformer.nativegen.cs deleted file mode 100644 index 2078161..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendDeformer.nativegen.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BlendDeformer -{ - private ufbx_blend_deformer* _ptr; - - internal BlendDeformer(ufbx_blend_deformer* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Misaki.HighPerformance.Mathematics.float3 GetBlendVertexOffset(nuint vertex) - { - return Api.ufbx_get_blend_vertex_offset(_ptr, vertex); - } - - public void AddBlendVertexOffsets(Misaki.HighPerformance.Mathematics.float3* vertices, nuint numVertices, float weight) - { - Api.ufbx_add_blend_vertex_offsets(_ptr, vertices, numVertices, weight); - } - - public BlendChannelList Channels => new(_ptr->channels.data, _ptr->channels.count); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_blend_deformer* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendDeformerList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BlendDeformerList.nativegen.cs deleted file mode 100644 index 213f5af..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendDeformerList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct BlendDeformerList -{ - private readonly ufbx_blend_deformer** _data; - public int Count { get; } - - internal BlendDeformerList(ufbx_blend_deformer** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public BlendDeformer this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_blend_deformer** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_blend_deformer** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public BlendDeformer Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendKeyframe.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BlendKeyframe.nativegen.cs deleted file mode 100644 index e1b16ae..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendKeyframe.nativegen.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BlendKeyframe -{ - private ufbx_blend_keyframe* _ptr; - - internal BlendKeyframe(ufbx_blend_keyframe* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool HasShape => _ptr->shape != null; - public BlendShape Shape => _ptr->shape != null ? new(_ptr->shape) : throw new InvalidOperationException("Shape is null."); - - public float TargetWeight => _ptr->target_weight; - - public float EffectiveWeight => _ptr->effective_weight; - - internal ufbx_blend_keyframe* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendShape.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BlendShape.nativegen.cs deleted file mode 100644 index 136e49f..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendShape.nativegen.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BlendShape -{ - private ufbx_blend_shape* _ptr; - - internal BlendShape(ufbx_blend_shape* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint GetBlendShapeOffsetIndex(nuint vertex) - { - return Api.ufbx_get_blend_shape_offset_index(_ptr, vertex); - } - - public Misaki.HighPerformance.Mathematics.float3 GetBlendShapeVertexOffset(nuint vertex) - { - return Api.ufbx_get_blend_shape_vertex_offset(_ptr, vertex); - } - - public void AddBlendShapeVertexOffsets(Misaki.HighPerformance.Mathematics.float3* vertices, nuint numVertices, float weight) - { - Api.ufbx_add_blend_shape_vertex_offsets(_ptr, vertices, numVertices, weight); - } - - public nuint NumOffsets => _ptr->num_offsets; - - public ReadOnlySpan OffsetVertices => _ptr->offset_vertices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->offset_vertices.data, checked((int)_ptr->offset_vertices.count)); - - public ReadOnlySpan PositionOffsets => _ptr->position_offsets.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->position_offsets.data, checked((int)_ptr->position_offsets.count)); - - public ReadOnlySpan NormalOffsets => _ptr->normal_offsets.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->normal_offsets.data, checked((int)_ptr->normal_offsets.count)); - - public ReadOnlySpan OffsetWeights => _ptr->offset_weights.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->offset_weights.data, checked((int)_ptr->offset_weights.count)); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_blend_shape* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendShapeList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BlendShapeList.nativegen.cs deleted file mode 100644 index b11f483..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BlendShapeList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct BlendShapeList -{ - private readonly ufbx_blend_shape** _data; - public int Count { get; } - - internal BlendShapeList(ufbx_blend_shape** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public BlendShape this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_blend_shape** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_blend_shape** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public BlendShape Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Bone.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Bone.nativegen.cs deleted file mode 100644 index 1c61ff5..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Bone.nativegen.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Bone -{ - private ufbx_bone* _ptr; - - internal Bone(ufbx_bone* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public float Radius => _ptr->radius; - - public float RelativeLength => _ptr->relative_length; - - public bool IsRoot => _ptr->is_root; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_bone* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BoneList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BoneList.nativegen.cs deleted file mode 100644 index b996942..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BoneList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct BoneList -{ - private readonly ufbx_bone** _data; - public int Count { get; } - - internal BoneList(ufbx_bone** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Bone this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_bone** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_bone** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Bone Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/BonePose.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/BonePose.nativegen.cs deleted file mode 100644 index 579927b..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/BonePose.nativegen.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct BonePose -{ - private ufbx_bone_pose* _ptr; - - internal BonePose(ufbx_bone_pose* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool HasBoneNode => _ptr->bone_node != null; - public Node BoneNode => _ptr->bone_node != null ? new(_ptr->bone_node) : throw new InvalidOperationException("BoneNode is null."); - - public Misaki.HighPerformance.Mathematics.float3x4 BoneToWorld => _ptr->bone_to_world; - - public Misaki.HighPerformance.Mathematics.float3x4 BoneToParent => _ptr->bone_to_parent; - - internal ufbx_bone_pose* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheChannel.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CacheChannel.nativegen.cs deleted file mode 100644 index d623fa0..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheChannel.nativegen.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct CacheChannel -{ - private ufbx_cache_channel* _ptr; - - internal CacheChannel(ufbx_cache_channel* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public nuint SampleGeometryCacheReal(double time, float* data, nuint numData, GeometryCacheDataOpts opts) - { - return Api.ufbx_sample_geometry_cache_real(_ptr, time, data, numData, opts.GetUnsafePtr()); - } - - public nuint SampleGeometryCacheVec3(double time, Misaki.HighPerformance.Mathematics.float3* data, nuint numData, GeometryCacheDataOpts opts) - { - return Api.ufbx_sample_geometry_cache_vec3(_ptr, time, data, numData, opts.GetUnsafePtr()); - } - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public ufbx_cache_interpretation Interpretation => _ptr->interpretation; - - public ReadOnlySpan InterpretationNameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->interpretation_name); - public string InterpretationName => NativeWrapperHelpers.GetString(_ptr->interpretation_name); - - public ReadOnlySpan Frames => _ptr->frames.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->frames.data, checked((int)_ptr->frames.count)); - - public ufbx_mirror_axis MirrorAxis => _ptr->mirror_axis; - - public float ScaleFactor => _ptr->scale_factor; - - internal ufbx_cache_channel* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheDeformer.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CacheDeformer.nativegen.cs deleted file mode 100644 index 24fd309..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheDeformer.nativegen.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct CacheDeformer -{ - private ufbx_cache_deformer* _ptr; - - internal CacheDeformer(ufbx_cache_deformer* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan ChannelBytes => NativeWrapperHelpers.AsByteSpan(_ptr->channel); - public string Channel => NativeWrapperHelpers.GetString(_ptr->channel); - - public bool HasFile => _ptr->file != null; - public CacheFile File => _ptr->file != null ? new(_ptr->file) : throw new InvalidOperationException("File is null."); - - public bool HasExternalCache => _ptr->external_cache != null; - public GeometryCache ExternalCache => _ptr->external_cache != null ? new(_ptr->external_cache) : throw new InvalidOperationException("ExternalCache is null."); - - public bool HasExternalChannel => _ptr->external_channel != null; - public CacheChannel ExternalChannel => _ptr->external_channel != null ? new(_ptr->external_channel) : throw new InvalidOperationException("ExternalChannel is null."); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_cache_deformer* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheDeformerList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CacheDeformerList.nativegen.cs deleted file mode 100644 index 872e09e..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheDeformerList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct CacheDeformerList -{ - private readonly ufbx_cache_deformer** _data; - public int Count { get; } - - internal CacheDeformerList(ufbx_cache_deformer** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public CacheDeformer this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_cache_deformer** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_cache_deformer** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public CacheDeformer Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheFile.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CacheFile.nativegen.cs deleted file mode 100644 index b78d683..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheFile.nativegen.cs +++ /dev/null @@ -1,46 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct CacheFile -{ - private ufbx_cache_file* _ptr; - - internal CacheFile(ufbx_cache_file* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan FilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->filename); - public string Filename => NativeWrapperHelpers.GetString(_ptr->filename); - - public ReadOnlySpan AbsoluteFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->absolute_filename); - public string AbsoluteFilename => NativeWrapperHelpers.GetString(_ptr->absolute_filename); - - public ReadOnlySpan RelativeFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->relative_filename); - public string RelativeFilename => NativeWrapperHelpers.GetString(_ptr->relative_filename); - - public ReadOnlySpan RawFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_filename); - - public ReadOnlySpan RawAbsoluteFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_absolute_filename); - - public ReadOnlySpan RawRelativeFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_relative_filename); - - public ufbx_cache_file_format Format => _ptr->format; - - public bool HasExternalCache => _ptr->external_cache != null; - public GeometryCache ExternalCache => _ptr->external_cache != null ? new(_ptr->external_cache) : throw new InvalidOperationException("ExternalCache is null."); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_cache_file* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheFileList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CacheFileList.nativegen.cs deleted file mode 100644 index c9e1427..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheFileList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct CacheFileList -{ - private readonly ufbx_cache_file** _data; - public int Count { get; } - - internal CacheFileList(ufbx_cache_file** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public CacheFile this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_cache_file** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_cache_file** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public CacheFile Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheFrame.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CacheFrame.nativegen.cs deleted file mode 100644 index 7ae8604..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CacheFrame.nativegen.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct CacheFrame -{ - private ufbx_cache_frame* _ptr; - - internal CacheFrame(ufbx_cache_frame* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public nuint ReadGeometryCacheReal(float* data, nuint numData, GeometryCacheDataOpts opts) - { - return Api.ufbx_read_geometry_cache_real(_ptr, data, numData, opts.GetUnsafePtr()); - } - - public nuint ReadGeometryCacheVec3(Misaki.HighPerformance.Mathematics.float3* data, nuint numData, GeometryCacheDataOpts opts) - { - return Api.ufbx_read_geometry_cache_vec3(_ptr, data, numData, opts.GetUnsafePtr()); - } - - public ReadOnlySpan ChannelBytes => NativeWrapperHelpers.AsByteSpan(_ptr->channel); - public string Channel => NativeWrapperHelpers.GetString(_ptr->channel); - - public double Time => _ptr->time; - - public ReadOnlySpan FilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->filename); - public string Filename => NativeWrapperHelpers.GetString(_ptr->filename); - - public ufbx_cache_file_format FileFormat => _ptr->file_format; - - public ufbx_mirror_axis MirrorAxis => _ptr->mirror_axis; - - public float ScaleFactor => _ptr->scale_factor; - - public ufbx_cache_data_format DataFormat => _ptr->data_format; - - public ufbx_cache_data_encoding DataEncoding => _ptr->data_encoding; - - public ulong DataOffset => _ptr->data_offset; - - public uint DataCount => _ptr->data_count; - - public uint DataElementBytes => _ptr->data_element_bytes; - - public ulong DataTotalBytes => _ptr->data_total_bytes; - - internal ufbx_cache_frame* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Camera.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Camera.nativegen.cs deleted file mode 100644 index 78ecb80..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Camera.nativegen.cs +++ /dev/null @@ -1,68 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Camera -{ - private ufbx_camera* _ptr; - - internal Camera(ufbx_camera* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_projection_mode ProjectionMode => _ptr->projection_mode; - - public bool ResolutionIsPixels => _ptr->resolution_is_pixels; - - public Misaki.HighPerformance.Mathematics.float2 Resolution => _ptr->resolution; - - public Misaki.HighPerformance.Mathematics.float2 FieldOfViewDeg => _ptr->field_of_view_deg; - - public Misaki.HighPerformance.Mathematics.float2 FieldOfViewTan => _ptr->field_of_view_tan; - - public float OrthographicExtent => _ptr->orthographic_extent; - - public Misaki.HighPerformance.Mathematics.float2 OrthographicSize => _ptr->orthographic_size; - - public Misaki.HighPerformance.Mathematics.float2 ProjectionPlane => _ptr->projection_plane; - - public float AspectRatio => _ptr->aspect_ratio; - - public float NearPlane => _ptr->near_plane; - - public float FarPlane => _ptr->far_plane; - - public CoordinateAxes ProjectionAxes => new((ufbx_coordinate_axes*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->projection_axes)); - - public ufbx_aspect_mode AspectMode => _ptr->aspect_mode; - - public ufbx_aperture_mode ApertureMode => _ptr->aperture_mode; - - public ufbx_gate_fit GateFit => _ptr->gate_fit; - - public ufbx_aperture_format ApertureFormat => _ptr->aperture_format; - - public float FocalLengthMm => _ptr->focal_length_mm; - - public Misaki.HighPerformance.Mathematics.float2 FilmSizeInch => _ptr->film_size_inch; - - public Misaki.HighPerformance.Mathematics.float2 ApertureSizeInch => _ptr->aperture_size_inch; - - public float SqueezeRatio => _ptr->squeeze_ratio; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_camera* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CameraList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CameraList.nativegen.cs deleted file mode 100644 index 86c33d4..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CameraList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct CameraList -{ - private readonly ufbx_camera** _data; - public int Count { get; } - - internal CameraList(ufbx_camera** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Camera this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_camera** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_camera** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Camera Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CameraSwitcher.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CameraSwitcher.nativegen.cs deleted file mode 100644 index 9b93d49..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CameraSwitcher.nativegen.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct CameraSwitcher -{ - private ufbx_camera_switcher* _ptr; - - internal CameraSwitcher(ufbx_camera_switcher* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_camera_switcher* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CameraSwitcherList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CameraSwitcherList.nativegen.cs deleted file mode 100644 index 197aa97..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CameraSwitcherList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct CameraSwitcherList -{ - private readonly ufbx_camera_switcher** _data; - public int Count { get; } - - internal CameraSwitcherList(ufbx_camera_switcher** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public CameraSwitcher this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_camera_switcher** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_camera_switcher** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public CameraSwitcher Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Character.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Character.nativegen.cs deleted file mode 100644 index 9fe97f1..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Character.nativegen.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Character -{ - private ufbx_character* _ptr; - - internal Character(ufbx_character* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_character* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CharacterList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CharacterList.nativegen.cs deleted file mode 100644 index 154a8ce..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CharacterList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct CharacterList -{ - private readonly ufbx_character** _data; - public int Count { get; } - - internal CharacterList(ufbx_character** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Character this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_character** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_character** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Character Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CloseMemoryCb.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CloseMemoryCb.nativegen.cs deleted file mode 100644 index c80b3fe..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CloseMemoryCb.nativegen.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct CloseMemoryCb -{ - private ufbx_close_memory_cb* _ptr; - - internal CloseMemoryCb(ufbx_close_memory_cb* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public void* User => _ptr->user; - - internal ufbx_close_memory_cb* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ColorSet.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ColorSet.nativegen.cs deleted file mode 100644 index 8f26208..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ColorSet.nativegen.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ColorSet -{ - private ufbx_color_set* _ptr; - - internal ColorSet(ufbx_color_set* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public uint Index => _ptr->index; - - public VertexVec4 VertexColor => new((ufbx_vertex_vec4*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_color)); - - internal ufbx_color_set* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Connection.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Connection.nativegen.cs deleted file mode 100644 index 2b3214d..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Connection.nativegen.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Connection -{ - private ufbx_connection* _ptr; - - internal Connection(ufbx_connection* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool HasSrc => _ptr->src != null; - public Element Src => _ptr->src != null ? new(_ptr->src) : throw new InvalidOperationException("Src is null."); - - public bool HasDst => _ptr->dst != null; - public Element Dst => _ptr->dst != null ? new(_ptr->dst) : throw new InvalidOperationException("Dst is null."); - - public ReadOnlySpan SrcPropBytes => NativeWrapperHelpers.AsByteSpan(_ptr->src_prop); - public string SrcProp => NativeWrapperHelpers.GetString(_ptr->src_prop); - - public ReadOnlySpan DstPropBytes => NativeWrapperHelpers.AsByteSpan(_ptr->dst_prop); - public string DstProp => NativeWrapperHelpers.GetString(_ptr->dst_prop); - - internal ufbx_connection* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Constraint.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Constraint.nativegen.cs deleted file mode 100644 index acedc62..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Constraint.nativegen.cs +++ /dev/null @@ -1,59 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Constraint -{ - private ufbx_constraint* _ptr; - - internal Constraint(ufbx_constraint* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_constraint_type Type => _ptr->type; - - public ReadOnlySpan TypeNameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->type_name); - public string TypeName => NativeWrapperHelpers.GetString(_ptr->type_name); - - public bool HasNode => _ptr->node != null; - public Node Node => _ptr->node != null ? new(_ptr->node) : throw new InvalidOperationException("Node is null."); - - public ReadOnlySpan Targets => _ptr->targets.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->targets.data, checked((int)_ptr->targets.count)); - - public float Weight => _ptr->weight; - - public bool Active => _ptr->active; - - public Transform TransformOffset => new((ufbx_transform*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transform_offset)); - - public Misaki.HighPerformance.Mathematics.float3 AimVector => _ptr->aim_vector; - - public ufbx_constraint_aim_up_type AimUpType => _ptr->aim_up_type; - - public bool HasAimUpNode => _ptr->aim_up_node != null; - public Node AimUpNode => _ptr->aim_up_node != null ? new(_ptr->aim_up_node) : throw new InvalidOperationException("AimUpNode is null."); - - public Misaki.HighPerformance.Mathematics.float3 AimUpVector => _ptr->aim_up_vector; - - public bool HasIkEffector => _ptr->ik_effector != null; - public Node IkEffector => _ptr->ik_effector != null ? new(_ptr->ik_effector) : throw new InvalidOperationException("IkEffector is null."); - - public bool HasIkEndNode => _ptr->ik_end_node != null; - public Node IkEndNode => _ptr->ik_end_node != null ? new(_ptr->ik_end_node) : throw new InvalidOperationException("IkEndNode is null."); - - public Misaki.HighPerformance.Mathematics.float3 IkPoleVector => _ptr->ik_pole_vector; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_constraint* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ConstraintList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ConstraintList.nativegen.cs deleted file mode 100644 index a31a21e..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ConstraintList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct ConstraintList -{ - private readonly ufbx_constraint** _data; - public int Count { get; } - - internal ConstraintList(ufbx_constraint** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Constraint this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_constraint** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_constraint** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Constraint Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ConstraintTarget.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ConstraintTarget.nativegen.cs deleted file mode 100644 index 58c3e84..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ConstraintTarget.nativegen.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ConstraintTarget -{ - private ufbx_constraint_target* _ptr; - - internal ConstraintTarget(ufbx_constraint_target* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool HasNode => _ptr->node != null; - public Node Node => _ptr->node != null ? new(_ptr->node) : throw new InvalidOperationException("Node is null."); - - public float Weight => _ptr->weight; - - public Transform Transform => new((ufbx_transform*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transform)); - - internal ufbx_constraint_target* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CoordinateAxes.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CoordinateAxes.nativegen.cs deleted file mode 100644 index 7c3945a..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CoordinateAxes.nativegen.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct CoordinateAxes -{ - private ufbx_coordinate_axes* _ptr; - - internal CoordinateAxes(ufbx_coordinate_axes* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_coordinate_axis Right => _ptr->right; - - public ufbx_coordinate_axis Up => _ptr->up; - - public ufbx_coordinate_axis Front => _ptr->front; - - internal ufbx_coordinate_axes* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/CurvePoint.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/CurvePoint.nativegen.cs deleted file mode 100644 index edde6d2..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/CurvePoint.nativegen.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct CurvePoint -{ - private ufbx_curve_point* _ptr; - - internal CurvePoint(ufbx_curve_point* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool Valid => _ptr->valid; - - public Misaki.HighPerformance.Mathematics.float3 Position => _ptr->position; - - public Misaki.HighPerformance.Mathematics.float3 Derivative => _ptr->derivative; - - internal ufbx_curve_point* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/DisplayLayer.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/DisplayLayer.nativegen.cs deleted file mode 100644 index 1e5182a..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/DisplayLayer.nativegen.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct DisplayLayer -{ - private ufbx_display_layer* _ptr; - - internal DisplayLayer(ufbx_display_layer* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public NodeList Nodes => new(_ptr->nodes.data, _ptr->nodes.count); - - public bool Visible => _ptr->visible; - - public bool Frozen => _ptr->frozen; - - public Misaki.HighPerformance.Mathematics.float3 UiColor => _ptr->ui_color; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_display_layer* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/DisplayLayerList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/DisplayLayerList.nativegen.cs deleted file mode 100644 index 1d718e5..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/DisplayLayerList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct DisplayLayerList -{ - private readonly ufbx_display_layer** _data; - public int Count { get; } - - internal DisplayLayerList(ufbx_display_layer** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public DisplayLayer this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_display_layer** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_display_layer** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public DisplayLayer Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/DomNode.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/DomNode.nativegen.cs deleted file mode 100644 index 36b04fc..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/DomNode.nativegen.cs +++ /dev/null @@ -1,72 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct DomNode -{ - private ufbx_dom_node* _ptr; - - internal DomNode(ufbx_dom_node* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public DomNode DomFindLen(sbyte* name, nuint nameLen) - { - return new(Api.ufbx_dom_find_len(_ptr, name, nameLen)); - } - - public DomNode DomFind(sbyte* name) - { - return new(Api.ufbx_dom_find(_ptr, name)); - } - - public bool DomIsArray() - { - return Api.ufbx_dom_is_array(_ptr); - } - - public nuint DomArraySize() - { - return Api.ufbx_dom_array_size(_ptr); - } - - public ufbx_int32_list DomAsInt32List() - { - return Api.ufbx_dom_as_int32_list(_ptr); - } - - public ufbx_int64_list DomAsInt64List() - { - return Api.ufbx_dom_as_int64_list(_ptr); - } - - public ufbx_float_list DomAsFloatList() - { - return Api.ufbx_dom_as_float_list(_ptr); - } - - public ufbx_double_list DomAsDoubleList() - { - return Api.ufbx_dom_as_double_list(_ptr); - } - - public ufbx_real_list DomAsRealList() - { - return Api.ufbx_dom_as_real_list(_ptr); - } - - public ufbx_blob_list DomAsBlobList() - { - return Api.ufbx_dom_as_blob_list(_ptr); - } - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public DomNodeList Children => new(_ptr->children.data, _ptr->children.count); - - public ReadOnlySpan Values => _ptr->values.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->values.data, checked((int)_ptr->values.count)); - - internal ufbx_dom_node* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/DomNodeList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/DomNodeList.nativegen.cs deleted file mode 100644 index 8d0a0fb..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/DomNodeList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct DomNodeList -{ - private readonly ufbx_dom_node** _data; - public int Count { get; } - - internal DomNodeList(ufbx_dom_node** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public DomNode this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_dom_node** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_dom_node** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public DomNode Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/DomValue.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/DomValue.nativegen.cs deleted file mode 100644 index 9f1c00f..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/DomValue.nativegen.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct DomValue -{ - private ufbx_dom_value* _ptr; - - internal DomValue(ufbx_dom_value* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_dom_value_type Type => _ptr->type; - - public ReadOnlySpan ValueStrBytes => NativeWrapperHelpers.AsByteSpan(_ptr->value_str); - public string ValueStr => NativeWrapperHelpers.GetString(_ptr->value_str); - - public ReadOnlySpan ValueBlob => NativeWrapperHelpers.AsSpan(_ptr->value_blob); - - public long ValueInt => _ptr->value_int; - - public double ValueFloat => _ptr->value_float; - - internal ufbx_dom_value* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Edge.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Edge.nativegen.cs deleted file mode 100644 index 23ead45..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Edge.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Edge -{ - private ufbx_edge* _ptr; - - internal Edge(ufbx_edge* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint A => _ptr->a; - - public uint B => _ptr->b; - - internal ufbx_edge* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Element.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Element.nativegen.cs deleted file mode 100644 index 71049ef..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Element.nativegen.cs +++ /dev/null @@ -1,263 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe ref struct Element -{ - private ufbx_element* _ptr; - - internal Element(ufbx_element* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Element GetPropElement(Prop prop, ufbx_element_type type) - { - return new(Api.ufbx_get_prop_element(_ptr, prop.GetUnsafePtr(), type)); - } - - public Element FindPropElementLen(sbyte* name, nuint nameLen, ufbx_element_type type) - { - return new(Api.ufbx_find_prop_element_len(_ptr, name, nameLen, type)); - } - - public Element FindPropElement(sbyte* name, ufbx_element_type type) - { - return new(Api.ufbx_find_prop_element(_ptr, name, type)); - } - - public Unknown AsUnknown() - { - return new(Api.ufbx_as_unknown(_ptr)); - } - - public Node AsNode() - { - return new(Api.ufbx_as_node(_ptr)); - } - - public Mesh AsMesh() - { - return new(Api.ufbx_as_mesh(_ptr)); - } - - public Light AsLight() - { - return new(Api.ufbx_as_light(_ptr)); - } - - public Camera AsCamera() - { - return new(Api.ufbx_as_camera(_ptr)); - } - - public Bone AsBone() - { - return new(Api.ufbx_as_bone(_ptr)); - } - - public Empty AsEmpty() - { - return new(Api.ufbx_as_empty(_ptr)); - } - - public LineCurve AsLineCurve() - { - return new(Api.ufbx_as_line_curve(_ptr)); - } - - public NurbsCurve AsNurbsCurve() - { - return new(Api.ufbx_as_nurbs_curve(_ptr)); - } - - public NurbsSurface AsNurbsSurface() - { - return new(Api.ufbx_as_nurbs_surface(_ptr)); - } - - public NurbsTrimSurface AsNurbsTrimSurface() - { - return new(Api.ufbx_as_nurbs_trim_surface(_ptr)); - } - - public NurbsTrimBoundary AsNurbsTrimBoundary() - { - return new(Api.ufbx_as_nurbs_trim_boundary(_ptr)); - } - - public ProceduralGeometry AsProceduralGeometry() - { - return new(Api.ufbx_as_procedural_geometry(_ptr)); - } - - public StereoCamera AsStereoCamera() - { - return new(Api.ufbx_as_stereo_camera(_ptr)); - } - - public CameraSwitcher AsCameraSwitcher() - { - return new(Api.ufbx_as_camera_switcher(_ptr)); - } - - public Marker AsMarker() - { - return new(Api.ufbx_as_marker(_ptr)); - } - - public LodGroup AsLodGroup() - { - return new(Api.ufbx_as_lod_group(_ptr)); - } - - public SkinDeformer AsSkinDeformer() - { - return new(Api.ufbx_as_skin_deformer(_ptr)); - } - - public SkinCluster AsSkinCluster() - { - return new(Api.ufbx_as_skin_cluster(_ptr)); - } - - public BlendDeformer AsBlendDeformer() - { - return new(Api.ufbx_as_blend_deformer(_ptr)); - } - - public BlendChannel AsBlendChannel() - { - return new(Api.ufbx_as_blend_channel(_ptr)); - } - - public BlendShape AsBlendShape() - { - return new(Api.ufbx_as_blend_shape(_ptr)); - } - - public CacheDeformer AsCacheDeformer() - { - return new(Api.ufbx_as_cache_deformer(_ptr)); - } - - public CacheFile AsCacheFile() - { - return new(Api.ufbx_as_cache_file(_ptr)); - } - - public Material AsMaterial() - { - return new(Api.ufbx_as_material(_ptr)); - } - - public Texture AsTexture() - { - return new(Api.ufbx_as_texture(_ptr)); - } - - public Video AsVideo() - { - return new(Api.ufbx_as_video(_ptr)); - } - - public Shader AsShader() - { - return new(Api.ufbx_as_shader(_ptr)); - } - - public ShaderBinding AsShaderBinding() - { - return new(Api.ufbx_as_shader_binding(_ptr)); - } - - public AnimStack AsAnimStack() - { - return new(Api.ufbx_as_anim_stack(_ptr)); - } - - public AnimLayer AsAnimLayer() - { - return new(Api.ufbx_as_anim_layer(_ptr)); - } - - public AnimValue AsAnimValue() - { - return new(Api.ufbx_as_anim_value(_ptr)); - } - - public AnimCurve AsAnimCurve() - { - return new(Api.ufbx_as_anim_curve(_ptr)); - } - - public DisplayLayer AsDisplayLayer() - { - return new(Api.ufbx_as_display_layer(_ptr)); - } - - public SelectionSet AsSelectionSet() - { - return new(Api.ufbx_as_selection_set(_ptr)); - } - - public SelectionNode AsSelectionNode() - { - return new(Api.ufbx_as_selection_node(_ptr)); - } - - public Character AsCharacter() - { - return new(Api.ufbx_as_character(_ptr)); - } - - public Constraint AsConstraint() - { - return new(Api.ufbx_as_constraint(_ptr)); - } - - public AudioLayer AsAudioLayer() - { - return new(Api.ufbx_as_audio_layer(_ptr)); - } - - public AudioClip AsAudioClip() - { - return new(Api.ufbx_as_audio_clip(_ptr)); - } - - public Pose AsPose() - { - return new(Api.ufbx_as_pose(_ptr)); - } - - public MetadataObject AsMetadataObject() - { - return new(Api.ufbx_as_metadata_object(_ptr)); - } - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - public ufbx_element_type Type => _ptr->type; - - public ReadOnlySpan ConnectionsSrc => _ptr->connections_src.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->connections_src.data, checked((int)_ptr->connections_src.count)); - - public ReadOnlySpan ConnectionsDst => _ptr->connections_dst.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->connections_dst.data, checked((int)_ptr->connections_dst.count)); - - public bool HasDomNode => _ptr->dom_node != null; - public DomNode DomNode => _ptr->dom_node != null ? new(_ptr->dom_node) : throw new InvalidOperationException("DomNode is null."); - - public bool HasScene => _ptr->scene != null; - public Scene Scene => _ptr->scene != null ? new(_ptr->scene) : throw new InvalidOperationException("Scene is null."); - - internal ufbx_element* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ElementList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ElementList.nativegen.cs deleted file mode 100644 index 21a89e7..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ElementList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct ElementList -{ - private readonly ufbx_element** _data; - public int Count { get; } - - internal ElementList(ufbx_element** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Element this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_element** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_element** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Element Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Empty.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Empty.nativegen.cs deleted file mode 100644 index b0df3db..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Empty.nativegen.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Empty -{ - private ufbx_empty* _ptr; - - internal Empty(ufbx_empty* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_empty* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/EmptyList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/EmptyList.nativegen.cs deleted file mode 100644 index e31adfc..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/EmptyList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct EmptyList -{ - private readonly ufbx_empty** _data; - public int Count { get; } - - internal EmptyList(ufbx_empty** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Empty this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_empty** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_empty** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Empty Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Error.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Error.nativegen.cs deleted file mode 100644 index 26265d5..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Error.nativegen.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Error -{ - private ufbx_error* _ptr; - - internal Error(ufbx_error* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_error_type Type => _ptr->type; - - public ReadOnlySpan DescriptionBytes => NativeWrapperHelpers.AsByteSpan(_ptr->description); - public string Description => NativeWrapperHelpers.GetString(_ptr->description); - - public uint StackSize => _ptr->stack_size; - - public nuint InfoLength => _ptr->info_length; - - internal ufbx_error* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ErrorFrame.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ErrorFrame.nativegen.cs deleted file mode 100644 index 088c72c..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ErrorFrame.nativegen.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ErrorFrame -{ - private ufbx_error_frame* _ptr; - - internal ErrorFrame(ufbx_error_frame* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint SourceLine => _ptr->source_line; - - public ReadOnlySpan FunctionBytes => NativeWrapperHelpers.AsByteSpan(_ptr->function); - public string Function => NativeWrapperHelpers.GetString(_ptr->function); - - public ReadOnlySpan DescriptionBytes => NativeWrapperHelpers.AsByteSpan(_ptr->description); - public string Description => NativeWrapperHelpers.GetString(_ptr->description); - - internal ufbx_error_frame* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/EvaluateOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/EvaluateOpts.nativegen.cs deleted file mode 100644 index 7f7bb5c..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/EvaluateOpts.nativegen.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct EvaluateOpts -{ - private ufbx_evaluate_opts* _ptr; - - internal EvaluateOpts(ufbx_evaluate_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public AllocatorOpts TempAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->temp_allocator)); - - public AllocatorOpts ResultAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->result_allocator)); - - public bool EvaluateSkinning => _ptr->evaluate_skinning; - - public bool EvaluateCaches => _ptr->evaluate_caches; - - public uint EvaluateFlags => _ptr->evaluate_flags; - - public bool LoadExternalFiles => _ptr->load_external_files; - - public OpenFileCb OpenFileCb => new((ufbx_open_file_cb*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->open_file_cb)); - - internal ufbx_evaluate_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Extrapolation.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Extrapolation.nativegen.cs deleted file mode 100644 index a9935fd..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Extrapolation.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Extrapolation -{ - private ufbx_extrapolation* _ptr; - - internal Extrapolation(ufbx_extrapolation* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_extrapolation_mode Mode => _ptr->mode; - - public int RepeatCount => _ptr->repeat_count; - - internal ufbx_extrapolation* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Face.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Face.nativegen.cs deleted file mode 100644 index 6758658..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Face.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Face -{ - private ufbx_face* _ptr; - - internal Face(ufbx_face* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint IndexBegin => _ptr->index_begin; - - public uint NumIndices => _ptr->num_indices; - - internal ufbx_face* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/FaceGroup.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/FaceGroup.nativegen.cs deleted file mode 100644 index e8e1ff0..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/FaceGroup.nativegen.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct FaceGroup -{ - private ufbx_face_group* _ptr; - - internal FaceGroup(ufbx_face_group* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public int Id => _ptr->id; - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - internal ufbx_face_group* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/GeometryCache.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/GeometryCache.nativegen.cs deleted file mode 100644 index d69e4ea..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/GeometryCache.nativegen.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct GeometryCache -{ - private ufbx_geometry_cache* _ptr; - - internal GeometryCache(ufbx_geometry_cache* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public static GeometryCache LoadGeometryCache(sbyte* filename, GeometryCacheOpts opts, Error error) - { - return new(Api.ufbx_load_geometry_cache(filename, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public static GeometryCache LoadGeometryCacheLen(sbyte* filename, nuint filenameLen, GeometryCacheOpts opts, Error error) - { - return new(Api.ufbx_load_geometry_cache_len(filename, filenameLen, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public void FreeGeometryCache() - { - Api.ufbx_free_geometry_cache(_ptr); - } - - public void RetainGeometryCache() - { - Api.ufbx_retain_geometry_cache(_ptr); - } - - public ReadOnlySpan RootFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->root_filename); - public string RootFilename => NativeWrapperHelpers.GetString(_ptr->root_filename); - - public ReadOnlySpan Channels => _ptr->channels.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->channels.data, checked((int)_ptr->channels.count)); - - public ReadOnlySpan Frames => _ptr->frames.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->frames.data, checked((int)_ptr->frames.count)); - - public ReadOnlySpan ExtraInfo => _ptr->extra_info.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->extra_info.data, checked((int)_ptr->extra_info.count)); - - internal ufbx_geometry_cache* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/GeometryCacheDataOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/GeometryCacheDataOpts.nativegen.cs deleted file mode 100644 index 6bbea69..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/GeometryCacheDataOpts.nativegen.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct GeometryCacheDataOpts -{ - private ufbx_geometry_cache_data_opts* _ptr; - - internal GeometryCacheDataOpts(ufbx_geometry_cache_data_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public OpenFileCb OpenFileCb => new((ufbx_open_file_cb*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->open_file_cb)); - - public bool Additive => _ptr->additive; - - public bool UseWeight => _ptr->use_weight; - - public float Weight => _ptr->weight; - - public bool IgnoreTransform => _ptr->ignore_transform; - - internal ufbx_geometry_cache_data_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/GeometryCacheOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/GeometryCacheOpts.nativegen.cs deleted file mode 100644 index ead2c9d..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/GeometryCacheOpts.nativegen.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct GeometryCacheOpts -{ - private ufbx_geometry_cache_opts* _ptr; - - internal GeometryCacheOpts(ufbx_geometry_cache_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public AllocatorOpts TempAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->temp_allocator)); - - public AllocatorOpts ResultAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->result_allocator)); - - public OpenFileCb OpenFileCb => new((ufbx_open_file_cb*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->open_file_cb)); - - public double FramesPerSecond => _ptr->frames_per_second; - - public ufbx_mirror_axis MirrorAxis => _ptr->mirror_axis; - - public bool UseScaleFactor => _ptr->use_scale_factor; - - public float ScaleFactor => _ptr->scale_factor; - - internal ufbx_geometry_cache_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/InflateInput.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/InflateInput.nativegen.cs deleted file mode 100644 index 2ad8d5e..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/InflateInput.nativegen.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct InflateInput -{ - private ufbx_inflate_input* _ptr; - - internal InflateInput(ufbx_inflate_input* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public nuint TotalSize => _ptr->total_size; - - public void* Data => _ptr->data; - - public nuint DataSize => _ptr->data_size; - - public void* Buffer => _ptr->buffer; - - public nuint BufferSize => _ptr->buffer_size; - - public void* ReadUser => _ptr->read_user; - - public ProgressCb ProgressCb => new((ufbx_progress_cb*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->progress_cb)); - - public ulong ProgressIntervalHint => _ptr->progress_interval_hint; - - public ulong ProgressSizeBefore => _ptr->progress_size_before; - - public ulong ProgressSizeAfter => _ptr->progress_size_after; - - public bool NoHeader => _ptr->no_header; - - public bool NoChecksum => _ptr->no_checksum; - - public nuint InternalFastBits => _ptr->internal_fast_bits; - - internal ufbx_inflate_input* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/InflateRetain.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/InflateRetain.nativegen.cs deleted file mode 100644 index 25b867b..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/InflateRetain.nativegen.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct InflateRetain -{ - private ufbx_inflate_retain* _ptr; - - internal InflateRetain(ufbx_inflate_retain* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool Initialized => _ptr->initialized; - - internal ufbx_inflate_retain* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Keyframe.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Keyframe.nativegen.cs deleted file mode 100644 index 383dd77..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Keyframe.nativegen.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Keyframe -{ - private ufbx_keyframe* _ptr; - - internal Keyframe(ufbx_keyframe* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public double Time => _ptr->time; - - public float Value => _ptr->value; - - public ufbx_interpolation Interpolation => _ptr->interpolation; - - public Tangent Left => new((ufbx_tangent*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->left)); - - public Tangent Right => new((ufbx_tangent*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->right)); - - internal ufbx_keyframe* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Light.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Light.nativegen.cs deleted file mode 100644 index 842a084..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Light.nativegen.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Light -{ - private ufbx_light* _ptr; - - internal Light(ufbx_light* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Misaki.HighPerformance.Mathematics.float3 Color => _ptr->color; - - public float Intensity => _ptr->intensity; - - public Misaki.HighPerformance.Mathematics.float3 LocalDirection => _ptr->local_direction; - - public ufbx_light_type Type => _ptr->type; - - public ufbx_light_decay Decay => _ptr->decay; - - public ufbx_light_area_shape AreaShape => _ptr->area_shape; - - public float InnerAngle => _ptr->inner_angle; - - public float OuterAngle => _ptr->outer_angle; - - public bool CastLight => _ptr->cast_light; - - public bool CastShadows => _ptr->cast_shadows; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_light* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/LightList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/LightList.nativegen.cs deleted file mode 100644 index 86f73c3..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/LightList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct LightList -{ - private readonly ufbx_light** _data; - public int Count { get; } - - internal LightList(ufbx_light** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Light this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_light** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_light** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Light Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/LineCurve.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/LineCurve.nativegen.cs deleted file mode 100644 index 27f6cda..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/LineCurve.nativegen.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct LineCurve -{ - private ufbx_line_curve* _ptr; - - internal LineCurve(ufbx_line_curve* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public void FreeLineCurve() - { - Api.ufbx_free_line_curve(_ptr); - } - - public void RetainLineCurve() - { - Api.ufbx_retain_line_curve(_ptr); - } - - public Misaki.HighPerformance.Mathematics.float3 Color => _ptr->color; - - public ReadOnlySpan ControlPoints => _ptr->control_points.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->control_points.data, checked((int)_ptr->control_points.count)); - - public ReadOnlySpan PointIndices => _ptr->point_indices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->point_indices.data, checked((int)_ptr->point_indices.count)); - - public ReadOnlySpan Segments => _ptr->segments.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->segments.data, checked((int)_ptr->segments.count)); - - public bool FromTessellatedNurbs => _ptr->from_tessellated_nurbs; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_line_curve* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/LineCurveList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/LineCurveList.nativegen.cs deleted file mode 100644 index f5ec600..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/LineCurveList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct LineCurveList -{ - private readonly ufbx_line_curve** _data; - public int Count { get; } - - internal LineCurveList(ufbx_line_curve** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public LineCurve this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_line_curve** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_line_curve** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public LineCurve Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/LineSegment.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/LineSegment.nativegen.cs deleted file mode 100644 index f7c3ef2..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/LineSegment.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct LineSegment -{ - private ufbx_line_segment* _ptr; - - internal LineSegment(ufbx_line_segment* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint IndexBegin => _ptr->index_begin; - - public uint NumIndices => _ptr->num_indices; - - internal ufbx_line_segment* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/LoadOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/LoadOpts.nativegen.cs deleted file mode 100644 index a48c30a..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/LoadOpts.nativegen.cs +++ /dev/null @@ -1,167 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe partial class LoadOpts : System.IDisposable -{ - private ufbx_load_opts* _ptr; - private bool _csAlloc; - - public LoadOpts() - { - _ptr = (ufbx_load_opts*)System.Runtime.InteropServices.NativeMemory.AllocZeroed((nuint)sizeof(ufbx_load_opts)); - _csAlloc = true; - } - - internal LoadOpts(ufbx_load_opts* ptr) - { - _ptr = ptr; - _csAlloc = false; - } - - public bool IsNull => _ptr == null; - - public partial void Dispose(); - - public ufbx_allocator_opts TempAllocator { get => _ptr->temp_allocator; set => _ptr->temp_allocator = value; } - - public ufbx_allocator_opts ResultAllocator { get => _ptr->result_allocator; set => _ptr->result_allocator = value; } - - public ufbx_thread_opts ThreadOpts { get => _ptr->thread_opts; set => _ptr->thread_opts = value; } - - public bool IgnoreGeometry { get => _ptr->ignore_geometry; set => _ptr->ignore_geometry = value; } - - public bool IgnoreAnimation { get => _ptr->ignore_animation; set => _ptr->ignore_animation = value; } - - public bool IgnoreEmbedded { get => _ptr->ignore_embedded; set => _ptr->ignore_embedded = value; } - - public bool IgnoreAllContent { get => _ptr->ignore_all_content; set => _ptr->ignore_all_content = value; } - - public bool EvaluateSkinning { get => _ptr->evaluate_skinning; set => _ptr->evaluate_skinning = value; } - - public bool EvaluateCaches { get => _ptr->evaluate_caches; set => _ptr->evaluate_caches = value; } - - public bool LoadExternalFiles { get => _ptr->load_external_files; set => _ptr->load_external_files = value; } - - public bool IgnoreMissingExternalFiles { get => _ptr->ignore_missing_external_files; set => _ptr->ignore_missing_external_files = value; } - - public bool SkipSkinVertices { get => _ptr->skip_skin_vertices; set => _ptr->skip_skin_vertices = value; } - - public bool SkipMeshParts { get => _ptr->skip_mesh_parts; set => _ptr->skip_mesh_parts = value; } - - public bool CleanSkinWeights { get => _ptr->clean_skin_weights; set => _ptr->clean_skin_weights = value; } - - public bool UseBlenderPbrMaterial { get => _ptr->use_blender_pbr_material; set => _ptr->use_blender_pbr_material = value; } - - public bool DisableQuirks { get => _ptr->disable_quirks; set => _ptr->disable_quirks = value; } - - public bool Strict { get => _ptr->strict; set => _ptr->strict = value; } - - public bool ForceSingleThreadAsciiParsing { get => _ptr->force_single_thread_ascii_parsing; set => _ptr->force_single_thread_ascii_parsing = value; } - - public bool AllowUnsafe { get => _ptr->allow_unsafe; set => _ptr->allow_unsafe = value; } - - public ufbx_index_error_handling IndexErrorHandling { get => _ptr->index_error_handling; set => _ptr->index_error_handling = value; } - - public bool ConnectBrokenElements { get => _ptr->connect_broken_elements; set => _ptr->connect_broken_elements = value; } - - public bool AllowNodesOutOfRoot { get => _ptr->allow_nodes_out_of_root; set => _ptr->allow_nodes_out_of_root = value; } - - public bool AllowMissingVertexPosition { get => _ptr->allow_missing_vertex_position; set => _ptr->allow_missing_vertex_position = value; } - - public bool AllowEmptyFaces { get => _ptr->allow_empty_faces; set => _ptr->allow_empty_faces = value; } - - public bool GenerateMissingNormals { get => _ptr->generate_missing_normals; set => _ptr->generate_missing_normals = value; } - - public bool OpenMainFileWithDefault { get => _ptr->open_main_file_with_default; set => _ptr->open_main_file_with_default = value; } - - public sbyte PathSeparator { get => _ptr->path_separator; set => _ptr->path_separator = value; } - - public uint NodeDepthLimit { get => _ptr->node_depth_limit; set => _ptr->node_depth_limit = value; } - - public ulong FileSizeEstimate { get => _ptr->file_size_estimate; set => _ptr->file_size_estimate = value; } - - public nuint ReadBufferSize { get => _ptr->read_buffer_size; set => _ptr->read_buffer_size = value; } - - private cstring _filename; - public partial cstring Filename { get; set; } - - public ReadOnlySpan RawFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_filename); - - public ufbx_progress_cb ProgressCb { get => _ptr->progress_cb; set => _ptr->progress_cb = value; } - - public ulong ProgressIntervalHint { get => _ptr->progress_interval_hint; set => _ptr->progress_interval_hint = value; } - - public ufbx_open_file_cb OpenFileCb { get => _ptr->open_file_cb; set => _ptr->open_file_cb = value; } - - public ufbx_geometry_transform_handling GeometryTransformHandling { get => _ptr->geometry_transform_handling; set => _ptr->geometry_transform_handling = value; } - - public ufbx_inherit_mode_handling InheritModeHandling { get => _ptr->inherit_mode_handling; set => _ptr->inherit_mode_handling = value; } - - public ufbx_space_conversion SpaceConversion { get => _ptr->space_conversion; set => _ptr->space_conversion = value; } - - public ufbx_pivot_handling PivotHandling { get => _ptr->pivot_handling; set => _ptr->pivot_handling = value; } - - public bool PivotHandlingRetainEmpties { get => _ptr->pivot_handling_retain_empties; set => _ptr->pivot_handling_retain_empties = value; } - - public ufbx_mirror_axis HandednessConversionAxis { get => _ptr->handedness_conversion_axis; set => _ptr->handedness_conversion_axis = value; } - - public bool HandednessConversionRetainWinding { get => _ptr->handedness_conversion_retain_winding; set => _ptr->handedness_conversion_retain_winding = value; } - - public bool ReverseWinding { get => _ptr->reverse_winding; set => _ptr->reverse_winding = value; } - - public ufbx_coordinate_axes TargetAxes { get => _ptr->target_axes; set => _ptr->target_axes = value; } - - public float TargetUnitMeters { get => _ptr->target_unit_meters; set => _ptr->target_unit_meters = value; } - - public ufbx_coordinate_axes TargetCameraAxes { get => _ptr->target_camera_axes; set => _ptr->target_camera_axes = value; } - - public ufbx_coordinate_axes TargetLightAxes { get => _ptr->target_light_axes; set => _ptr->target_light_axes = value; } - - public ReadOnlySpan GeometryTransformHelperNameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->geometry_transform_helper_name); - public string GeometryTransformHelperName => NativeWrapperHelpers.GetString(_ptr->geometry_transform_helper_name); - - public ReadOnlySpan ScaleHelperNameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->scale_helper_name); - public string ScaleHelperName => NativeWrapperHelpers.GetString(_ptr->scale_helper_name); - - public bool NormalizeNormals { get => _ptr->normalize_normals; set => _ptr->normalize_normals = value; } - - public bool NormalizeTangents { get => _ptr->normalize_tangents; set => _ptr->normalize_tangents = value; } - - public bool UseRootTransform { get => _ptr->use_root_transform; set => _ptr->use_root_transform = value; } - - public ufbx_transform RootTransform { get => _ptr->root_transform; set => _ptr->root_transform = value; } - - public double KeyClampThreshold { get => _ptr->key_clamp_threshold; set => _ptr->key_clamp_threshold = value; } - - public ufbx_unicode_error_handling UnicodeErrorHandling { get => _ptr->unicode_error_handling; set => _ptr->unicode_error_handling = value; } - - public bool RetainVertexAttribW { get => _ptr->retain_vertex_attrib_w; set => _ptr->retain_vertex_attrib_w = value; } - - public bool RetainDom { get => _ptr->retain_dom; set => _ptr->retain_dom = value; } - - public ufbx_file_format FileFormat { get => _ptr->file_format; set => _ptr->file_format = value; } - - public nuint FileFormatLookahead { get => _ptr->file_format_lookahead; set => _ptr->file_format_lookahead = value; } - - public bool NoFormatFromContent { get => _ptr->no_format_from_content; set => _ptr->no_format_from_content = value; } - - public bool NoFormatFromExtension { get => _ptr->no_format_from_extension; set => _ptr->no_format_from_extension = value; } - - public bool ObjSearchMtlByFilename { get => _ptr->obj_search_mtl_by_filename; set => _ptr->obj_search_mtl_by_filename = value; } - - public bool ObjMergeObjects { get => _ptr->obj_merge_objects; set => _ptr->obj_merge_objects = value; } - - public bool ObjMergeGroups { get => _ptr->obj_merge_groups; set => _ptr->obj_merge_groups = value; } - - public bool ObjSplitGroups { get => _ptr->obj_split_groups; set => _ptr->obj_split_groups = value; } - - private cstring _objMtlPath; - public partial cstring ObjMtlPath { get; set; } - - public ReadOnlySpan ObjMtlData => NativeWrapperHelpers.AsSpan(_ptr->obj_mtl_data); - - public float ObjUnitMeters { get => _ptr->obj_unit_meters; set => _ptr->obj_unit_meters = value; } - - public ufbx_coordinate_axes ObjAxes { get => _ptr->obj_axes; set => _ptr->obj_axes = value; } - - internal ufbx_load_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/LodGroup.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/LodGroup.nativegen.cs deleted file mode 100644 index 4a6ced9..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/LodGroup.nativegen.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct LodGroup -{ - private ufbx_lod_group* _ptr; - - internal LodGroup(ufbx_lod_group* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool RelativeDistances => _ptr->relative_distances; - - public ReadOnlySpan LodLevels => _ptr->lod_levels.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->lod_levels.data, checked((int)_ptr->lod_levels.count)); - - public bool IgnoreParentTransform => _ptr->ignore_parent_transform; - - public bool UseDistanceLimit => _ptr->use_distance_limit; - - public float DistanceLimitMin => _ptr->distance_limit_min; - - public float DistanceLimitMax => _ptr->distance_limit_max; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_lod_group* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/LodGroupList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/LodGroupList.nativegen.cs deleted file mode 100644 index 0ccb9db..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/LodGroupList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct LodGroupList -{ - private readonly ufbx_lod_group** _data; - public int Count { get; } - - internal LodGroupList(ufbx_lod_group** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public LodGroup this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_lod_group** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_lod_group** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public LodGroup Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/LodLevel.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/LodLevel.nativegen.cs deleted file mode 100644 index d2f1bdb..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/LodLevel.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct LodLevel -{ - private ufbx_lod_level* _ptr; - - internal LodLevel(ufbx_lod_level* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public float Distance => _ptr->distance; - - public ufbx_lod_display Display => _ptr->display; - - internal ufbx_lod_level* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Marker.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Marker.nativegen.cs deleted file mode 100644 index 9ce4c30..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Marker.nativegen.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Marker -{ - private ufbx_marker* _ptr; - - internal Marker(ufbx_marker* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_marker_type Type => _ptr->type; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_marker* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MarkerList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MarkerList.nativegen.cs deleted file mode 100644 index b34eb76..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MarkerList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct MarkerList -{ - private readonly ufbx_marker** _data; - public int Count { get; } - - internal MarkerList(ufbx_marker** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Marker this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_marker** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_marker** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Marker Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Material.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Material.nativegen.cs deleted file mode 100644 index abaa1ac..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Material.nativegen.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe ref struct Material -{ - private ufbx_material* _ptr; - - internal Material(ufbx_material* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Texture FindPropTextureLen(sbyte* name, nuint nameLen) - { - return new(Api.ufbx_find_prop_texture_len(_ptr, name, nameLen)); - } - - public Texture FindPropTexture(sbyte* name) - { - return new(Api.ufbx_find_prop_texture(_ptr, name)); - } - - public MaterialFbxMaps Fbx => new((ufbx_material_fbx_maps*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->fbx)); - - public MaterialPbrMaps Pbr => new((ufbx_material_pbr_maps*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->pbr)); - - public MaterialFeatures Features => new((ufbx_material_features*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->features)); - - public ufbx_shader_type ShaderType => _ptr->shader_type; - - public bool HasShader => _ptr->shader != null; - public Shader Shader => _ptr->shader != null ? new(_ptr->shader) : throw new InvalidOperationException("Shader is null."); - - public ReadOnlySpan ShadingModelNameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->shading_model_name); - public string ShadingModelName => NativeWrapperHelpers.GetString(_ptr->shading_model_name); - - public ReadOnlySpan ShaderPropPrefixBytes => NativeWrapperHelpers.AsByteSpan(_ptr->shader_prop_prefix); - public string ShaderPropPrefix => NativeWrapperHelpers.GetString(_ptr->shader_prop_prefix); - - public ReadOnlySpan Textures => _ptr->textures.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->textures.data, checked((int)_ptr->textures.count)); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_material* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialFbxMaps.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialFbxMaps.nativegen.cs deleted file mode 100644 index 995ce8c..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialFbxMaps.nativegen.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct MaterialFbxMaps -{ - private ufbx_material_fbx_maps* _ptr; - - internal MaterialFbxMaps(ufbx_material_fbx_maps* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public MaterialMap DiffuseFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->diffuse_factor)); - - public MaterialMap DiffuseColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->diffuse_color)); - - public MaterialMap SpecularFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->specular_factor)); - - public MaterialMap SpecularColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->specular_color)); - - public MaterialMap SpecularExponent => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->specular_exponent)); - - public MaterialMap ReflectionFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->reflection_factor)); - - public MaterialMap ReflectionColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->reflection_color)); - - public MaterialMap TransparencyFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transparency_factor)); - - public MaterialMap TransparencyColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transparency_color)); - - public MaterialMap EmissionFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->emission_factor)); - - public MaterialMap EmissionColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->emission_color)); - - public MaterialMap AmbientFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->ambient_factor)); - - public MaterialMap AmbientColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->ambient_color)); - - public MaterialMap NormalMap => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->normal_map)); - - public MaterialMap Bump => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->bump)); - - public MaterialMap BumpFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->bump_factor)); - - public MaterialMap DisplacementFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->displacement_factor)); - - public MaterialMap Displacement => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->displacement)); - - public MaterialMap VectorDisplacementFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vector_displacement_factor)); - - public MaterialMap VectorDisplacement => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vector_displacement)); - - internal ufbx_material_fbx_maps* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialFeatureInfo.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialFeatureInfo.nativegen.cs deleted file mode 100644 index 0cce45b..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialFeatureInfo.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct MaterialFeatureInfo -{ - private ufbx_material_feature_info* _ptr; - - internal MaterialFeatureInfo(ufbx_material_feature_info* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool Enabled => _ptr->enabled; - - public bool IsExplicit => _ptr->is_explicit; - - internal ufbx_material_feature_info* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialFeatures.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialFeatures.nativegen.cs deleted file mode 100644 index f08cb6c..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialFeatures.nativegen.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct MaterialFeatures -{ - private ufbx_material_features* _ptr; - - internal MaterialFeatures(ufbx_material_features* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public MaterialFeatureInfo Pbr => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->pbr)); - - public MaterialFeatureInfo Metalness => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->metalness)); - - public MaterialFeatureInfo Diffuse => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->diffuse)); - - public MaterialFeatureInfo Specular => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->specular)); - - public MaterialFeatureInfo Emission => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->emission)); - - public MaterialFeatureInfo Transmission => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission)); - - public MaterialFeatureInfo Coat => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat)); - - public MaterialFeatureInfo Sheen => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->sheen)); - - public MaterialFeatureInfo Opacity => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->opacity)); - - public MaterialFeatureInfo AmbientOcclusion => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->ambient_occlusion)); - - public MaterialFeatureInfo Matte => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->matte)); - - public MaterialFeatureInfo Unlit => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->unlit)); - - public MaterialFeatureInfo Ior => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->ior)); - - public MaterialFeatureInfo DiffuseRoughness => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->diffuse_roughness)); - - public MaterialFeatureInfo TransmissionRoughness => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_roughness)); - - public MaterialFeatureInfo ThinWalled => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->thin_walled)); - - public MaterialFeatureInfo Caustics => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->caustics)); - - public MaterialFeatureInfo ExitToBackground => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->exit_to_background)); - - public MaterialFeatureInfo InternalReflections => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->internal_reflections)); - - public MaterialFeatureInfo DoubleSided => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->double_sided)); - - public MaterialFeatureInfo RoughnessAsGlossiness => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->roughness_as_glossiness)); - - public MaterialFeatureInfo CoatRoughnessAsGlossiness => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_roughness_as_glossiness)); - - public MaterialFeatureInfo TransmissionRoughnessAsGlossiness => new((ufbx_material_feature_info*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_roughness_as_glossiness)); - - internal ufbx_material_features* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialList.nativegen.cs deleted file mode 100644 index ef01070..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct MaterialList -{ - private readonly ufbx_material** _data; - public int Count { get; } - - internal MaterialList(ufbx_material** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Material this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_material** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_material** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Material Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialMap.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialMap.nativegen.cs deleted file mode 100644 index 5871e7b..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialMap.nativegen.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct MaterialMap -{ - private ufbx_material_map* _ptr; - - internal MaterialMap(ufbx_material_map* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public long ValueInt => _ptr->value_int; - - public bool HasTexture => _ptr->texture != null; - public Texture Texture => _ptr->texture != null ? new(_ptr->texture) : throw new InvalidOperationException("Texture is null."); - - public bool HasValue => _ptr->has_value; - - public bool TextureEnabled => _ptr->texture_enabled; - - public bool FeatureDisabled => _ptr->feature_disabled; - - public byte ValueComponents => _ptr->value_components; - - public float ValueReal => _ptr->value_real; - - public Misaki.HighPerformance.Mathematics.float2 ValueVec2 => _ptr->value_vec2; - - public Misaki.HighPerformance.Mathematics.float3 ValueVec3 => _ptr->value_vec3; - - public Misaki.HighPerformance.Mathematics.float4 ValueVec4 => _ptr->value_vec4; - - internal ufbx_material_map* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialPbrMaps.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialPbrMaps.nativegen.cs deleted file mode 100644 index c179f41..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialPbrMaps.nativegen.cs +++ /dev/null @@ -1,127 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct MaterialPbrMaps -{ - private ufbx_material_pbr_maps* _ptr; - - internal MaterialPbrMaps(ufbx_material_pbr_maps* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public MaterialMap BaseFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->base_factor)); - - public MaterialMap BaseColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->base_color)); - - public MaterialMap Roughness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->roughness)); - - public MaterialMap Metalness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->metalness)); - - public MaterialMap DiffuseRoughness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->diffuse_roughness)); - - public MaterialMap SpecularFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->specular_factor)); - - public MaterialMap SpecularColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->specular_color)); - - public MaterialMap SpecularIor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->specular_ior)); - - public MaterialMap SpecularAnisotropy => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->specular_anisotropy)); - - public MaterialMap SpecularRotation => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->specular_rotation)); - - public MaterialMap TransmissionFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_factor)); - - public MaterialMap TransmissionColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_color)); - - public MaterialMap TransmissionDepth => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_depth)); - - public MaterialMap TransmissionScatter => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_scatter)); - - public MaterialMap TransmissionScatterAnisotropy => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_scatter_anisotropy)); - - public MaterialMap TransmissionDispersion => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_dispersion)); - - public MaterialMap TransmissionRoughness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_roughness)); - - public MaterialMap TransmissionExtraRoughness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_extra_roughness)); - - public MaterialMap TransmissionPriority => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_priority)); - - public MaterialMap TransmissionEnableInAov => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_enable_in_aov)); - - public MaterialMap SubsurfaceFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->subsurface_factor)); - - public MaterialMap SubsurfaceColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->subsurface_color)); - - public MaterialMap SubsurfaceRadius => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->subsurface_radius)); - - public MaterialMap SubsurfaceScale => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->subsurface_scale)); - - public MaterialMap SubsurfaceAnisotropy => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->subsurface_anisotropy)); - - public MaterialMap SubsurfaceTintColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->subsurface_tint_color)); - - public MaterialMap SubsurfaceType => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->subsurface_type)); - - public MaterialMap SheenFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->sheen_factor)); - - public MaterialMap SheenColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->sheen_color)); - - public MaterialMap SheenRoughness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->sheen_roughness)); - - public MaterialMap CoatFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_factor)); - - public MaterialMap CoatColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_color)); - - public MaterialMap CoatRoughness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_roughness)); - - public MaterialMap CoatIor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_ior)); - - public MaterialMap CoatAnisotropy => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_anisotropy)); - - public MaterialMap CoatRotation => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_rotation)); - - public MaterialMap CoatNormal => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_normal)); - - public MaterialMap CoatAffectBaseColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_affect_base_color)); - - public MaterialMap CoatAffectBaseRoughness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_affect_base_roughness)); - - public MaterialMap ThinFilmFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->thin_film_factor)); - - public MaterialMap ThinFilmThickness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->thin_film_thickness)); - - public MaterialMap ThinFilmIor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->thin_film_ior)); - - public MaterialMap EmissionFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->emission_factor)); - - public MaterialMap EmissionColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->emission_color)); - - public MaterialMap Opacity => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->opacity)); - - public MaterialMap IndirectDiffuse => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->indirect_diffuse)); - - public MaterialMap IndirectSpecular => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->indirect_specular)); - - public MaterialMap NormalMap => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->normal_map)); - - public MaterialMap TangentMap => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->tangent_map)); - - public MaterialMap DisplacementMap => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->displacement_map)); - - public MaterialMap MatteFactor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->matte_factor)); - - public MaterialMap MatteColor => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->matte_color)); - - public MaterialMap AmbientOcclusion => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->ambient_occlusion)); - - public MaterialMap Glossiness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->glossiness)); - - public MaterialMap CoatGlossiness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->coat_glossiness)); - - public MaterialMap TransmissionGlossiness => new((ufbx_material_map*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transmission_glossiness)); - - internal ufbx_material_pbr_maps* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialTexture.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialTexture.nativegen.cs deleted file mode 100644 index 16c6371..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MaterialTexture.nativegen.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct MaterialTexture -{ - private ufbx_material_texture* _ptr; - - internal MaterialTexture(ufbx_material_texture* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan MaterialPropBytes => NativeWrapperHelpers.AsByteSpan(_ptr->material_prop); - public string MaterialProp => NativeWrapperHelpers.GetString(_ptr->material_prop); - - public ReadOnlySpan ShaderPropBytes => NativeWrapperHelpers.AsByteSpan(_ptr->shader_prop); - public string ShaderProp => NativeWrapperHelpers.GetString(_ptr->shader_prop); - - public bool HasTexture => _ptr->texture != null; - public Texture Texture => _ptr->texture != null ? new(_ptr->texture) : throw new InvalidOperationException("Texture is null."); - - internal ufbx_material_texture* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Matrix.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Matrix.nativegen.cs deleted file mode 100644 index 4cc5e8f..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Matrix.nativegen.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Matrix -{ - private ufbx_matrix* _ptr; - - internal Matrix(ufbx_matrix* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public float M00 => _ptr->m00; - - public float M10 => _ptr->m10; - - public float M20 => _ptr->m20; - - public float M01 => _ptr->m01; - - public float M11 => _ptr->m11; - - public float M21 => _ptr->m21; - - public float M02 => _ptr->m02; - - public float M12 => _ptr->m12; - - public float M22 => _ptr->m22; - - public float M03 => _ptr->m03; - - public float M13 => _ptr->m13; - - public float M23 => _ptr->m23; - - internal ufbx_matrix* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Mesh.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Mesh.nativegen.cs deleted file mode 100644 index e1f13ce..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Mesh.nativegen.cs +++ /dev/null @@ -1,168 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe ref struct Mesh -{ - private ufbx_mesh* _ptr; - - internal Mesh(ufbx_mesh* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint FindFaceIndex(nuint index) - { - return Api.ufbx_find_face_index(_ptr, index); - } - - public void ComputeTopology(TopoEdge topo, nuint numTopo) - { - Api.ufbx_compute_topology(_ptr, topo.GetUnsafePtr(), numTopo); - } - - public nuint GenerateNormalMapping(TopoEdge topo, nuint numTopo, uint* normalIndices, nuint numNormalIndices, bool assumeSmooth) - { - return Api.ufbx_generate_normal_mapping(_ptr, topo.GetUnsafePtr(), numTopo, normalIndices, numNormalIndices, assumeSmooth); - } - - public void ComputeNormals(VertexVec3 positions, uint* normalIndices, nuint numNormalIndices, Misaki.HighPerformance.Mathematics.float3* normals, nuint numNormals) - { - Api.ufbx_compute_normals(_ptr, positions.GetUnsafePtr(), normalIndices, numNormalIndices, normals, numNormals); - } - - public Mesh SubdivideMesh(nuint level, SubdivideOpts opts, Error error) - { - return new(Api.ufbx_subdivide_mesh(_ptr, level, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public void FreeMesh() - { - Api.ufbx_free_mesh(_ptr); - } - - public void RetainMesh() - { - Api.ufbx_retain_mesh(_ptr); - } - - public nuint NumVertices => _ptr->num_vertices; - - public nuint NumIndices => _ptr->num_indices; - - public nuint NumFaces => _ptr->num_faces; - - public nuint NumTriangles => _ptr->num_triangles; - - public nuint NumEdges => _ptr->num_edges; - - public nuint MaxFaceTriangles => _ptr->max_face_triangles; - - public nuint NumEmptyFaces => _ptr->num_empty_faces; - - public nuint NumPointFaces => _ptr->num_point_faces; - - public nuint NumLineFaces => _ptr->num_line_faces; - - public ReadOnlySpan Faces => _ptr->faces.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->faces.data, checked((int)_ptr->faces.count)); - - public ReadOnlySpan FaceSmoothing => _ptr->face_smoothing.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->face_smoothing.data, checked((int)_ptr->face_smoothing.count)); - - public ReadOnlySpan FaceMaterial => _ptr->face_material.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->face_material.data, checked((int)_ptr->face_material.count)); - - public ReadOnlySpan FaceGroup => _ptr->face_group.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->face_group.data, checked((int)_ptr->face_group.count)); - - public ReadOnlySpan FaceHole => _ptr->face_hole.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->face_hole.data, checked((int)_ptr->face_hole.count)); - - public ReadOnlySpan Edges => _ptr->edges.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->edges.data, checked((int)_ptr->edges.count)); - - public ReadOnlySpan EdgeSmoothing => _ptr->edge_smoothing.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->edge_smoothing.data, checked((int)_ptr->edge_smoothing.count)); - - public ReadOnlySpan EdgeCrease => _ptr->edge_crease.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->edge_crease.data, checked((int)_ptr->edge_crease.count)); - - public ReadOnlySpan EdgeVisibility => _ptr->edge_visibility.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->edge_visibility.data, checked((int)_ptr->edge_visibility.count)); - - public ReadOnlySpan VertexIndices => _ptr->vertex_indices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->vertex_indices.data, checked((int)_ptr->vertex_indices.count)); - - public ReadOnlySpan Vertices => _ptr->vertices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->vertices.data, checked((int)_ptr->vertices.count)); - - public ReadOnlySpan VertexFirstIndex => _ptr->vertex_first_index.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->vertex_first_index.data, checked((int)_ptr->vertex_first_index.count)); - - public VertexVec3 VertexPosition => new((ufbx_vertex_vec3*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_position)); - - public VertexVec3 VertexNormal => new((ufbx_vertex_vec3*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_normal)); - - public VertexVec2 VertexUv => new((ufbx_vertex_vec2*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_uv)); - - public VertexVec3 VertexTangent => new((ufbx_vertex_vec3*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_tangent)); - - public VertexVec3 VertexBitangent => new((ufbx_vertex_vec3*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_bitangent)); - - public VertexVec4 VertexColor => new((ufbx_vertex_vec4*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_color)); - - public VertexReal VertexCrease => new((ufbx_vertex_real*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_crease)); - - public ReadOnlySpan UvSets => _ptr->uv_sets.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->uv_sets.data, checked((int)_ptr->uv_sets.count)); - - public ReadOnlySpan ColorSets => _ptr->color_sets.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->color_sets.data, checked((int)_ptr->color_sets.count)); - - public MaterialList Materials => new(_ptr->materials.data, _ptr->materials.count); - - public ReadOnlySpan FaceGroups => _ptr->face_groups.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->face_groups.data, checked((int)_ptr->face_groups.count)); - - public ReadOnlySpan MaterialParts => _ptr->material_parts.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->material_parts.data, checked((int)_ptr->material_parts.count)); - - public ReadOnlySpan FaceGroupParts => _ptr->face_group_parts.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->face_group_parts.data, checked((int)_ptr->face_group_parts.count)); - - public ReadOnlySpan MaterialPartUsageOrder => _ptr->material_part_usage_order.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->material_part_usage_order.data, checked((int)_ptr->material_part_usage_order.count)); - - public bool SkinnedIsLocal => _ptr->skinned_is_local; - - public VertexVec3 SkinnedPosition => new((ufbx_vertex_vec3*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->skinned_position)); - - public VertexVec3 SkinnedNormal => new((ufbx_vertex_vec3*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->skinned_normal)); - - public SkinDeformerList SkinDeformers => new(_ptr->skin_deformers.data, _ptr->skin_deformers.count); - - public BlendDeformerList BlendDeformers => new(_ptr->blend_deformers.data, _ptr->blend_deformers.count); - - public CacheDeformerList CacheDeformers => new(_ptr->cache_deformers.data, _ptr->cache_deformers.count); - - public ElementList AllDeformers => new(_ptr->all_deformers.data, _ptr->all_deformers.count); - - public uint SubdivisionPreviewLevels => _ptr->subdivision_preview_levels; - - public uint SubdivisionRenderLevels => _ptr->subdivision_render_levels; - - public ufbx_subdivision_display_mode SubdivisionDisplayMode => _ptr->subdivision_display_mode; - - public ufbx_subdivision_boundary SubdivisionBoundary => _ptr->subdivision_boundary; - - public ufbx_subdivision_boundary SubdivisionUvBoundary => _ptr->subdivision_uv_boundary; - - public bool ReversedWinding => _ptr->reversed_winding; - - public bool GeneratedNormals => _ptr->generated_normals; - - public bool SubdivisionEvaluated => _ptr->subdivision_evaluated; - - public bool HasSubdivisionResult => _ptr->subdivision_result != null; - public SubdivisionResult SubdivisionResult => _ptr->subdivision_result != null ? new(_ptr->subdivision_result) : throw new InvalidOperationException("SubdivisionResult is null."); - - public bool FromTessellatedNurbs => _ptr->from_tessellated_nurbs; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_mesh* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MeshList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MeshList.nativegen.cs deleted file mode 100644 index 4dfbe33..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MeshList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct MeshList -{ - private readonly ufbx_mesh** _data; - public int Count { get; } - - internal MeshList(ufbx_mesh** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Mesh this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_mesh** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_mesh** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Mesh Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MeshPart.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MeshPart.nativegen.cs deleted file mode 100644 index ccc4d32..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MeshPart.nativegen.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct MeshPart -{ - private ufbx_mesh_part* _ptr; - - internal MeshPart(ufbx_mesh_part* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint Index => _ptr->index; - - public nuint NumFaces => _ptr->num_faces; - - public nuint NumTriangles => _ptr->num_triangles; - - public nuint NumEmptyFaces => _ptr->num_empty_faces; - - public nuint NumPointFaces => _ptr->num_point_faces; - - public nuint NumLineFaces => _ptr->num_line_faces; - - public ReadOnlySpan FaceIndices => _ptr->face_indices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->face_indices.data, checked((int)_ptr->face_indices.count)); - - internal ufbx_mesh_part* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Metadata.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Metadata.nativegen.cs deleted file mode 100644 index 453895b..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Metadata.nativegen.cs +++ /dev/null @@ -1,109 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Metadata -{ - private ufbx_metadata* _ptr; - - internal Metadata(ufbx_metadata* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan Warnings => _ptr->warnings.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->warnings.data, checked((int)_ptr->warnings.count)); - - public bool Ascii => _ptr->ascii; - - public uint Version => _ptr->version; - - public ufbx_file_format FileFormat => _ptr->file_format; - - public bool MayContainNoIndex => _ptr->may_contain_no_index; - - public bool MayContainMissingVertexPosition => _ptr->may_contain_missing_vertex_position; - - public bool MayContainBrokenElements => _ptr->may_contain_broken_elements; - - public bool IsUnsafe => _ptr->is_unsafe; - - public ReadOnlySpan CreatorBytes => NativeWrapperHelpers.AsByteSpan(_ptr->creator); - public string Creator => NativeWrapperHelpers.GetString(_ptr->creator); - - public bool BigEndian => _ptr->big_endian; - - public ReadOnlySpan FilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->filename); - public string Filename => NativeWrapperHelpers.GetString(_ptr->filename); - - public ReadOnlySpan RelativeRootBytes => NativeWrapperHelpers.AsByteSpan(_ptr->relative_root); - public string RelativeRoot => NativeWrapperHelpers.GetString(_ptr->relative_root); - - public ReadOnlySpan RawFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_filename); - - public ReadOnlySpan RawRelativeRoot => NativeWrapperHelpers.AsSpan(_ptr->raw_relative_root); - - public ufbx_exporter Exporter => _ptr->exporter; - - public uint ExporterVersion => _ptr->exporter_version; - - public Props SceneProps => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->scene_props)); - - public Application OriginalApplication => new((ufbx_application*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->original_application)); - - public Application LatestApplication => new((ufbx_application*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->latest_application)); - - public Thumbnail Thumbnail => new((ufbx_thumbnail*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->thumbnail)); - - public bool GeometryIgnored => _ptr->geometry_ignored; - - public bool AnimationIgnored => _ptr->animation_ignored; - - public bool EmbeddedIgnored => _ptr->embedded_ignored; - - public nuint MaxFaceTriangles => _ptr->max_face_triangles; - - public nuint ResultMemoryUsed => _ptr->result_memory_used; - - public nuint TempMemoryUsed => _ptr->temp_memory_used; - - public nuint ResultAllocs => _ptr->result_allocs; - - public nuint TempAllocs => _ptr->temp_allocs; - - public nuint ElementBufferSize => _ptr->element_buffer_size; - - public nuint NumShaderTextures => _ptr->num_shader_textures; - - public float BonePropSizeUnit => _ptr->bone_prop_size_unit; - - public bool BonePropLimbLengthRelative => _ptr->bone_prop_limb_length_relative; - - public float OrthoSizeUnit => _ptr->ortho_size_unit; - - public long KtimeSecond => _ptr->ktime_second; - - public ReadOnlySpan OriginalFilePathBytes => NativeWrapperHelpers.AsByteSpan(_ptr->original_file_path); - public string OriginalFilePath => NativeWrapperHelpers.GetString(_ptr->original_file_path); - - public ReadOnlySpan RawOriginalFilePath => NativeWrapperHelpers.AsSpan(_ptr->raw_original_file_path); - - public ufbx_space_conversion SpaceConversion => _ptr->space_conversion; - - public ufbx_geometry_transform_handling GeometryTransformHandling => _ptr->geometry_transform_handling; - - public ufbx_inherit_mode_handling InheritModeHandling => _ptr->inherit_mode_handling; - - public ufbx_pivot_handling PivotHandling => _ptr->pivot_handling; - - public ufbx_mirror_axis HandednessConversionAxis => _ptr->handedness_conversion_axis; - - public Misaki.HighPerformance.Mathematics.quaternion RootRotation => _ptr->root_rotation; - - public float RootScale => _ptr->root_scale; - - public ufbx_mirror_axis MirrorAxis => _ptr->mirror_axis; - - public float GeometryScale => _ptr->geometry_scale; - - internal ufbx_metadata* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MetadataObject.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MetadataObject.nativegen.cs deleted file mode 100644 index 461d2cb..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MetadataObject.nativegen.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct MetadataObject -{ - private ufbx_metadata_object* _ptr; - - internal MetadataObject(ufbx_metadata_object* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_metadata_object* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/MetadataObjectList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/MetadataObjectList.nativegen.cs deleted file mode 100644 index 3a41bac..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/MetadataObjectList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct MetadataObjectList -{ - private readonly ufbx_metadata_object** _data; - public int Count { get; } - - internal MetadataObjectList(ufbx_metadata_object** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public MetadataObject this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_metadata_object** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_metadata_object** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public MetadataObject Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NameElement.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NameElement.nativegen.cs deleted file mode 100644 index 1088355..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NameElement.nativegen.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct NameElement -{ - private ufbx_name_element* _ptr; - - internal NameElement(ufbx_name_element* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public ufbx_element_type Type => _ptr->type; - - public bool HasElement => _ptr->element != null; - public Element Element => _ptr->element != null ? new(_ptr->element) : throw new InvalidOperationException("Element is null."); - - internal ufbx_name_element* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NativeWrapperHelpers.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NativeWrapperHelpers.nativegen.cs deleted file mode 100644 index 969d959..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NativeWrapperHelpers.nativegen.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Text; - -namespace Ghost.Ufbx; - -internal static unsafe class NativeWrapperHelpers -{ - public static ReadOnlySpan AsByteSpan(ufbx_string value) - { - if (value.data == null || value.length == 0) - { - return ReadOnlySpan.Empty; - } - - return new ReadOnlySpan((byte*)value.data, checked((int)value.length) * 1); - } - - public static string GetString(ufbx_string value) - { - var bytes = AsByteSpan(value); - if (bytes.IsEmpty) - { - return string.Empty; - } - - return Encoding.UTF8.GetString(bytes); - } - - public static ReadOnlySpan AsSpan(ufbx_blob value) - { - if (value.data == null || value.size == 0) - { - return ReadOnlySpan.Empty; - } - - return new ReadOnlySpan(value.data, checked((int)value.size)); - } - - public static void ThrowIfOutOfRange(int index, int count) - { - if ((uint)index >= (uint)count) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Node.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Node.nativegen.cs deleted file mode 100644 index e687e1d..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Node.nativegen.cs +++ /dev/null @@ -1,125 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe ref struct Node -{ - private ufbx_node* _ptr; - - internal Node(ufbx_node* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Misaki.HighPerformance.Mathematics.float3x4 GetCompatibleMatrixForNormals() - { - return Api.ufbx_get_compatible_matrix_for_normals(_ptr); - } - - public bool HasParent => _ptr->parent != null; - public Node Parent => _ptr->parent != null ? new(_ptr->parent) : throw new InvalidOperationException("Parent is null."); - - public NodeList Children => new(_ptr->children.data, _ptr->children.count); - - public bool HasMesh => _ptr->mesh != null; - public Mesh Mesh => _ptr->mesh != null ? new(_ptr->mesh) : throw new InvalidOperationException("Mesh is null."); - - public bool HasLight => _ptr->light != null; - public Light Light => _ptr->light != null ? new(_ptr->light) : throw new InvalidOperationException("Light is null."); - - public bool HasCamera => _ptr->camera != null; - public Camera Camera => _ptr->camera != null ? new(_ptr->camera) : throw new InvalidOperationException("Camera is null."); - - public bool HasBone => _ptr->bone != null; - public Bone Bone => _ptr->bone != null ? new(_ptr->bone) : throw new InvalidOperationException("Bone is null."); - - public bool HasAttrib => _ptr->attrib != null; - public Element Attrib => _ptr->attrib != null ? new(_ptr->attrib) : throw new InvalidOperationException("Attrib is null."); - - public bool HasGeometryTransformHelper => _ptr->geometry_transform_helper != null; - public Node GeometryTransformHelper => _ptr->geometry_transform_helper != null ? new(_ptr->geometry_transform_helper) : throw new InvalidOperationException("GeometryTransformHelper is null."); - - public bool HasScaleHelper => _ptr->scale_helper != null; - public Node ScaleHelper => _ptr->scale_helper != null ? new(_ptr->scale_helper) : throw new InvalidOperationException("ScaleHelper is null."); - - public ufbx_element_type AttribType => _ptr->attrib_type; - - public ElementList AllAttribs => new(_ptr->all_attribs.data, _ptr->all_attribs.count); - - public ufbx_inherit_mode InheritMode => _ptr->inherit_mode; - - public ufbx_inherit_mode OriginalInheritMode => _ptr->original_inherit_mode; - - public Transform LocalTransform => new((ufbx_transform*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->local_transform)); - - public Transform GeometryTransform => new((ufbx_transform*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->geometry_transform)); - - public Misaki.HighPerformance.Mathematics.float3 InheritScale => _ptr->inherit_scale; - - public bool HasInheritScaleNode => _ptr->inherit_scale_node != null; - public Node InheritScaleNode => _ptr->inherit_scale_node != null ? new(_ptr->inherit_scale_node) : throw new InvalidOperationException("InheritScaleNode is null."); - - public ufbx_rotation_order RotationOrder => _ptr->rotation_order; - - public Misaki.HighPerformance.Mathematics.float3 EulerRotation => _ptr->euler_rotation; - - public Misaki.HighPerformance.Mathematics.float3x4 NodeToParent => _ptr->node_to_parent; - - public Misaki.HighPerformance.Mathematics.float3x4 NodeToWorld => _ptr->node_to_world; - - public Misaki.HighPerformance.Mathematics.float3x4 GeometryToNode => _ptr->geometry_to_node; - - public Misaki.HighPerformance.Mathematics.float3x4 GeometryToWorld => _ptr->geometry_to_world; - - public Misaki.HighPerformance.Mathematics.float3x4 UnscaledNodeToWorld => _ptr->unscaled_node_to_world; - - public Misaki.HighPerformance.Mathematics.float3 AdjustPreTranslation => _ptr->adjust_pre_translation; - - public Misaki.HighPerformance.Mathematics.quaternion AdjustPreRotation => _ptr->adjust_pre_rotation; - - public float AdjustPreScale => _ptr->adjust_pre_scale; - - public Misaki.HighPerformance.Mathematics.quaternion AdjustPostRotation => _ptr->adjust_post_rotation; - - public float AdjustPostScale => _ptr->adjust_post_scale; - - public float AdjustTranslationScale => _ptr->adjust_translation_scale; - - public ufbx_mirror_axis AdjustMirrorAxis => _ptr->adjust_mirror_axis; - - public MaterialList Materials => new(_ptr->materials.data, _ptr->materials.count); - - public bool HasBindPose => _ptr->bind_pose != null; - public Pose BindPose => _ptr->bind_pose != null ? new(_ptr->bind_pose) : throw new InvalidOperationException("BindPose is null."); - - public bool Visible => _ptr->visible; - - public bool IsRoot => _ptr->is_root; - - public bool HasGeometryTransform => _ptr->has_geometry_transform; - - public bool HasAdjustTransform => _ptr->has_adjust_transform; - - public bool HasRootAdjustTransform => _ptr->has_root_adjust_transform; - - public bool IsGeometryTransformHelper => _ptr->is_geometry_transform_helper; - - public bool IsScaleHelper => _ptr->is_scale_helper; - - public bool IsScaleCompensateParent => _ptr->is_scale_compensate_parent; - - public uint NodeDepth => _ptr->node_depth; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_node* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NodeList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NodeList.nativegen.cs deleted file mode 100644 index 289babf..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NodeList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct NodeList -{ - private readonly ufbx_node** _data; - public int Count { get; } - - internal NodeList(ufbx_node** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Node this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_node** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_node** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Node Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsBasis.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsBasis.nativegen.cs deleted file mode 100644 index 61a8247..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsBasis.nativegen.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct NurbsBasis -{ - private ufbx_nurbs_basis* _ptr; - - internal NurbsBasis(ufbx_nurbs_basis* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public nuint EvaluateNurbsBasis(float u, float* weights, nuint numWeights, float* derivatives, nuint numDerivatives) - { - return Api.ufbx_evaluate_nurbs_basis(_ptr, u, weights, numWeights, derivatives, numDerivatives); - } - - public uint Order => _ptr->order; - - public ufbx_nurbs_topology Topology => _ptr->topology; - - public ReadOnlySpan KnotVector => _ptr->knot_vector.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->knot_vector.data, checked((int)_ptr->knot_vector.count)); - - public float TMin => _ptr->t_min; - - public float TMax => _ptr->t_max; - - public ReadOnlySpan Spans => _ptr->spans.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->spans.data, checked((int)_ptr->spans.count)); - - public bool Is2d => _ptr->is_2d; - - public nuint NumWrapControlPoints => _ptr->num_wrap_control_points; - - public bool Valid => _ptr->valid; - - internal ufbx_nurbs_basis* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsCurve.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsCurve.nativegen.cs deleted file mode 100644 index 007ce84..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsCurve.nativegen.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct NurbsCurve -{ - private ufbx_nurbs_curve* _ptr; - - internal NurbsCurve(ufbx_nurbs_curve* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_curve_point EvaluateNurbsCurve(float u) - { - return Api.ufbx_evaluate_nurbs_curve(_ptr, u); - } - - public LineCurve TessellateNurbsCurve(TessellateCurveOpts opts, Error error) - { - return new(Api.ufbx_tessellate_nurbs_curve(_ptr, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public NurbsBasis Basis => new((ufbx_nurbs_basis*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->basis)); - - public ReadOnlySpan ControlPoints => _ptr->control_points.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->control_points.data, checked((int)_ptr->control_points.count)); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_nurbs_curve* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsCurveList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsCurveList.nativegen.cs deleted file mode 100644 index 35d2e61..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsCurveList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct NurbsCurveList -{ - private readonly ufbx_nurbs_curve** _data; - public int Count { get; } - - internal NurbsCurveList(ufbx_nurbs_curve** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public NurbsCurve this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_nurbs_curve** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_nurbs_curve** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public NurbsCurve Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsSurface.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsSurface.nativegen.cs deleted file mode 100644 index 672ffa5..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsSurface.nativegen.cs +++ /dev/null @@ -1,57 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct NurbsSurface -{ - private ufbx_nurbs_surface* _ptr; - - internal NurbsSurface(ufbx_nurbs_surface* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_surface_point EvaluateNurbsSurface(float u, float v) - { - return Api.ufbx_evaluate_nurbs_surface(_ptr, u, v); - } - - public Mesh TessellateNurbsSurface(TessellateSurfaceOpts opts, Error error) - { - return new(Api.ufbx_tessellate_nurbs_surface(_ptr, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public NurbsBasis BasisU => new((ufbx_nurbs_basis*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->basis_u)); - - public NurbsBasis BasisV => new((ufbx_nurbs_basis*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->basis_v)); - - public nuint NumControlPointsU => _ptr->num_control_points_u; - - public nuint NumControlPointsV => _ptr->num_control_points_v; - - public ReadOnlySpan ControlPoints => _ptr->control_points.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->control_points.data, checked((int)_ptr->control_points.count)); - - public uint SpanSubdivisionU => _ptr->span_subdivision_u; - - public uint SpanSubdivisionV => _ptr->span_subdivision_v; - - public bool FlipNormals => _ptr->flip_normals; - - public bool HasMaterial => _ptr->material != null; - public Material Material => _ptr->material != null ? new(_ptr->material) : throw new InvalidOperationException("Material is null."); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_nurbs_surface* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsSurfaceList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsSurfaceList.nativegen.cs deleted file mode 100644 index ad8d5db..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsSurfaceList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct NurbsSurfaceList -{ - private readonly ufbx_nurbs_surface** _data; - public int Count { get; } - - internal NurbsSurfaceList(ufbx_nurbs_surface** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public NurbsSurface this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_nurbs_surface** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_nurbs_surface** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public NurbsSurface Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimBoundary.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimBoundary.nativegen.cs deleted file mode 100644 index bee5200..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimBoundary.nativegen.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct NurbsTrimBoundary -{ - private ufbx_nurbs_trim_boundary* _ptr; - - internal NurbsTrimBoundary(ufbx_nurbs_trim_boundary* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_nurbs_trim_boundary* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimBoundaryList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimBoundaryList.nativegen.cs deleted file mode 100644 index 0025b26..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimBoundaryList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct NurbsTrimBoundaryList -{ - private readonly ufbx_nurbs_trim_boundary** _data; - public int Count { get; } - - internal NurbsTrimBoundaryList(ufbx_nurbs_trim_boundary** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public NurbsTrimBoundary this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_nurbs_trim_boundary** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_nurbs_trim_boundary** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public NurbsTrimBoundary Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimSurface.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimSurface.nativegen.cs deleted file mode 100644 index 053928f..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimSurface.nativegen.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct NurbsTrimSurface -{ - private ufbx_nurbs_trim_surface* _ptr; - - internal NurbsTrimSurface(ufbx_nurbs_trim_surface* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_nurbs_trim_surface* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimSurfaceList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimSurfaceList.nativegen.cs deleted file mode 100644 index c898880..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/NurbsTrimSurfaceList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct NurbsTrimSurfaceList -{ - private readonly ufbx_nurbs_trim_surface** _data; - public int Count { get; } - - internal NurbsTrimSurfaceList(ufbx_nurbs_trim_surface** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public NurbsTrimSurface this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_nurbs_trim_surface** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_nurbs_trim_surface** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public NurbsTrimSurface Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/OpenFileCb.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/OpenFileCb.nativegen.cs deleted file mode 100644 index 43dd45b..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/OpenFileCb.nativegen.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct OpenFileCb -{ - private ufbx_open_file_cb* _ptr; - - internal OpenFileCb(ufbx_open_file_cb* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public void* User => _ptr->user; - - internal ufbx_open_file_cb* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/OpenFileInfo.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/OpenFileInfo.nativegen.cs deleted file mode 100644 index a754ced..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/OpenFileInfo.nativegen.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct OpenFileInfo -{ - private ufbx_open_file_info* _ptr; - - internal OpenFileInfo(ufbx_open_file_info* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public nuint Context => _ptr->context; - - public ufbx_open_file_type Type => _ptr->type; - - public ReadOnlySpan OriginalFilename => NativeWrapperHelpers.AsSpan(_ptr->original_filename); - - internal ufbx_open_file_info* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/OpenFileOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/OpenFileOpts.nativegen.cs deleted file mode 100644 index 684e7db..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/OpenFileOpts.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct OpenFileOpts -{ - private ufbx_open_file_opts* _ptr; - - internal OpenFileOpts(ufbx_open_file_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public AllocatorOpts Allocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->allocator)); - - public bool FilenameNullTerminated => _ptr->filename_null_terminated; - - internal ufbx_open_file_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/OpenMemoryOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/OpenMemoryOpts.nativegen.cs deleted file mode 100644 index 05a3516..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/OpenMemoryOpts.nativegen.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct OpenMemoryOpts -{ - private ufbx_open_memory_opts* _ptr; - - internal OpenMemoryOpts(ufbx_open_memory_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public AllocatorOpts Allocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->allocator)); - - public bool NoCopy => _ptr->no_copy; - - public CloseMemoryCb CloseCb => new((ufbx_close_memory_cb*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->close_cb)); - - internal ufbx_open_memory_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Panic.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Panic.nativegen.cs deleted file mode 100644 index b350a31..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Panic.nativegen.cs +++ /dev/null @@ -1,84 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Panic -{ - private ufbx_panic* _ptr; - - internal Panic(ufbx_panic* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Misaki.HighPerformance.Mathematics.float3x4 CatchGetSkinVertexMatrix(SkinDeformer skin, nuint vertex, Misaki.HighPerformance.Mathematics.float3x4* fallback) - { - return Api.ufbx_catch_get_skin_vertex_matrix(_ptr, skin.GetUnsafePtr(), vertex, fallback); - } - - public uint CatchTriangulateFace(uint* indices, nuint numIndices, Mesh mesh, ufbx_face face) - { - return Api.ufbx_catch_triangulate_face(_ptr, indices, numIndices, mesh.GetUnsafePtr(), face); - } - - public void CatchComputeTopology(Mesh mesh, TopoEdge topo, nuint numTopo) - { - Api.ufbx_catch_compute_topology(_ptr, mesh.GetUnsafePtr(), topo.GetUnsafePtr(), numTopo); - } - - public uint CatchTopoNextVertexEdge(TopoEdge topo, nuint numTopo, uint index) - { - return Api.ufbx_catch_topo_next_vertex_edge(_ptr, topo.GetUnsafePtr(), numTopo, index); - } - - public uint CatchTopoPrevVertexEdge(TopoEdge topo, nuint numTopo, uint index) - { - return Api.ufbx_catch_topo_prev_vertex_edge(_ptr, topo.GetUnsafePtr(), numTopo, index); - } - - public Misaki.HighPerformance.Mathematics.float3 CatchGetWeightedFaceNormal(VertexVec3 positions, ufbx_face face) - { - return Api.ufbx_catch_get_weighted_face_normal(_ptr, positions.GetUnsafePtr(), face); - } - - public nuint CatchGenerateNormalMapping(Mesh mesh, TopoEdge topo, nuint numTopo, uint* normalIndices, nuint numNormalIndices, bool assumeSmooth) - { - return Api.ufbx_catch_generate_normal_mapping(_ptr, mesh.GetUnsafePtr(), topo.GetUnsafePtr(), numTopo, normalIndices, numNormalIndices, assumeSmooth); - } - - public void CatchComputeNormals(Mesh mesh, VertexVec3 positions, uint* normalIndices, nuint numNormalIndices, Misaki.HighPerformance.Mathematics.float3* normals, nuint numNormals) - { - Api.ufbx_catch_compute_normals(_ptr, mesh.GetUnsafePtr(), positions.GetUnsafePtr(), normalIndices, numNormalIndices, normals, numNormals); - } - - public float CatchGetVertexReal(VertexReal v, nuint index) - { - return Api.ufbx_catch_get_vertex_real(_ptr, v.GetUnsafePtr(), index); - } - - public Misaki.HighPerformance.Mathematics.float2 CatchGetVertexVec2(VertexVec2 v, nuint index) - { - return Api.ufbx_catch_get_vertex_vec2(_ptr, v.GetUnsafePtr(), index); - } - - public Misaki.HighPerformance.Mathematics.float3 CatchGetVertexVec3(VertexVec3 v, nuint index) - { - return Api.ufbx_catch_get_vertex_vec3(_ptr, v.GetUnsafePtr(), index); - } - - public Misaki.HighPerformance.Mathematics.float4 CatchGetVertexVec4(VertexVec4 v, nuint index) - { - return Api.ufbx_catch_get_vertex_vec4(_ptr, v.GetUnsafePtr(), index); - } - - public float CatchGetVertexWVec3(VertexVec3 v, nuint index) - { - return Api.ufbx_catch_get_vertex_w_vec3(_ptr, v.GetUnsafePtr(), index); - } - - public bool DidPanic => _ptr->did_panic; - - public nuint MessageLength => _ptr->message_length; - - internal ufbx_panic* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Pose.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Pose.nativegen.cs deleted file mode 100644 index 9233eff..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Pose.nativegen.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Pose -{ - private ufbx_pose* _ptr; - - internal Pose(ufbx_pose* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public BonePose GetBonePose(Node node) - { - return new(Api.ufbx_get_bone_pose(_ptr, node.GetUnsafePtr())); - } - - public bool IsBindPose => _ptr->is_bind_pose; - - public ReadOnlySpan BonePoses => _ptr->bone_poses.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->bone_poses.data, checked((int)_ptr->bone_poses.count)); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_pose* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/PoseList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/PoseList.nativegen.cs deleted file mode 100644 index ff265dc..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/PoseList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct PoseList -{ - private readonly ufbx_pose** _data; - public int Count { get; } - - internal PoseList(ufbx_pose** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Pose this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_pose** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_pose** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Pose Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ProceduralGeometry.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ProceduralGeometry.nativegen.cs deleted file mode 100644 index 167a601..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ProceduralGeometry.nativegen.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ProceduralGeometry -{ - private ufbx_procedural_geometry* _ptr; - - internal ProceduralGeometry(ufbx_procedural_geometry* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_procedural_geometry* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ProceduralGeometryList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ProceduralGeometryList.nativegen.cs deleted file mode 100644 index 5cc7281..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ProceduralGeometryList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct ProceduralGeometryList -{ - private readonly ufbx_procedural_geometry** _data; - public int Count { get; } - - internal ProceduralGeometryList(ufbx_procedural_geometry** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public ProceduralGeometry this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_procedural_geometry** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_procedural_geometry** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public ProceduralGeometry Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Progress.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Progress.nativegen.cs deleted file mode 100644 index b4234aa..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Progress.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Progress -{ - private ufbx_progress* _ptr; - - internal Progress(ufbx_progress* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ulong BytesRead => _ptr->bytes_read; - - public ulong BytesTotal => _ptr->bytes_total; - - internal ufbx_progress* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ProgressCb.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ProgressCb.nativegen.cs deleted file mode 100644 index dfa6156..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ProgressCb.nativegen.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ProgressCb -{ - private ufbx_progress_cb* _ptr; - - internal ProgressCb(ufbx_progress_cb* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public void* User => _ptr->user; - - internal ufbx_progress_cb* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Prop.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Prop.nativegen.cs deleted file mode 100644 index 1fc47de..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Prop.nativegen.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe ref struct Prop -{ - private ufbx_prop* _ptr; - - internal Prop(ufbx_prop* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public ufbx_prop_type Type => _ptr->type; - - public ufbx_prop_flags Flags => _ptr->flags; - - public ReadOnlySpan ValueStrBytes => NativeWrapperHelpers.AsByteSpan(_ptr->value_str); - public string ValueStr => NativeWrapperHelpers.GetString(_ptr->value_str); - - public ReadOnlySpan ValueBlob => NativeWrapperHelpers.AsSpan(_ptr->value_blob); - - public long ValueInt => _ptr->value_int; - - public float ValueReal => _ptr->value_real; - - public Misaki.HighPerformance.Mathematics.float2 ValueVec2 => _ptr->value_vec2; - - public Misaki.HighPerformance.Mathematics.float3 ValueVec3 => _ptr->value_vec3; - - public Misaki.HighPerformance.Mathematics.float4 ValueVec4 => _ptr->value_vec4; - - internal ufbx_prop* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/PropOverride.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/PropOverride.nativegen.cs deleted file mode 100644 index deaa9b8..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/PropOverride.nativegen.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct PropOverride -{ - private ufbx_prop_override* _ptr; - - internal PropOverride(ufbx_prop_override* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint ElementId => _ptr->element_id; - - public ReadOnlySpan PropNameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->prop_name); - public string PropName => NativeWrapperHelpers.GetString(_ptr->prop_name); - - public Misaki.HighPerformance.Mathematics.float4 Value => _ptr->value; - - public ReadOnlySpan ValueStrBytes => NativeWrapperHelpers.AsByteSpan(_ptr->value_str); - public string ValueStr => NativeWrapperHelpers.GetString(_ptr->value_str); - - public long ValueInt => _ptr->value_int; - - internal ufbx_prop_override* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/PropOverrideDesc.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/PropOverrideDesc.nativegen.cs deleted file mode 100644 index 9fa9442..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/PropOverrideDesc.nativegen.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct PropOverrideDesc -{ - private ufbx_prop_override_desc* _ptr; - - internal PropOverrideDesc(ufbx_prop_override_desc* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint ElementId => _ptr->element_id; - - public ReadOnlySpan PropNameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->prop_name); - public string PropName => NativeWrapperHelpers.GetString(_ptr->prop_name); - - public Misaki.HighPerformance.Mathematics.float4 Value => _ptr->value; - - public ReadOnlySpan ValueStrBytes => NativeWrapperHelpers.AsByteSpan(_ptr->value_str); - public string ValueStr => NativeWrapperHelpers.GetString(_ptr->value_str); - - public long ValueInt => _ptr->value_int; - - internal ufbx_prop_override_desc* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Props.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Props.nativegen.cs deleted file mode 100644 index ae66327..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Props.nativegen.cs +++ /dev/null @@ -1,101 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe ref struct Props -{ - private ufbx_props* _ptr; - - internal Props(ufbx_props* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Prop FindProp(ReadOnlySpan name) - { - fixed (byte* namePtr = name) - { - var value = Api.ufbx_find_prop_len(_ptr, (sbyte*)namePtr, (nuint)name.Length); - return new(value); - } - } - - public Prop FindProp(sbyte* name) - { - return new(Api.ufbx_find_prop(_ptr, name)); - } - - public float FindRealLen(sbyte* name, nuint nameLen, float def) - { - return Api.ufbx_find_real_len(_ptr, name, nameLen, def); - } - - public float FindReal(sbyte* name, float def) - { - return Api.ufbx_find_real(_ptr, name, def); - } - - public Misaki.HighPerformance.Mathematics.float3 FindVec3Len(sbyte* name, nuint nameLen, Misaki.HighPerformance.Mathematics.float3 def) - { - return Api.ufbx_find_vec3_len(_ptr, name, nameLen, def); - } - - public Misaki.HighPerformance.Mathematics.float3 FindVec3(sbyte* name, Misaki.HighPerformance.Mathematics.float3 def) - { - return Api.ufbx_find_vec3(_ptr, name, def); - } - - public long FindIntLen(sbyte* name, nuint nameLen, long def) - { - return Api.ufbx_find_int_len(_ptr, name, nameLen, def); - } - - public long FindInt(sbyte* name, long def) - { - return Api.ufbx_find_int(_ptr, name, def); - } - - public bool FindBoolLen(sbyte* name, nuint nameLen, bool def) - { - return Api.ufbx_find_bool_len(_ptr, name, nameLen, def); - } - - public bool FindBool(sbyte* name, bool def) - { - return Api.ufbx_find_bool(_ptr, name, def); - } - - public string FindStringLen(sbyte* name, nuint nameLen, ufbx_string def) - { - return NativeWrapperHelpers.GetString(Api.ufbx_find_string_len(_ptr, name, nameLen, def)); - } - - public string FindString(sbyte* name, ufbx_string def) - { - return NativeWrapperHelpers.GetString(Api.ufbx_find_string(_ptr, name, def)); - } - - public ReadOnlySpan FindBlobLen(sbyte* name, nuint nameLen, ufbx_blob def) - { - return NativeWrapperHelpers.AsSpan(Api.ufbx_find_blob_len(_ptr, name, nameLen, def)); - } - - public ReadOnlySpan FindBlob(sbyte* name, ufbx_blob def) - { - return NativeWrapperHelpers.AsSpan(Api.ufbx_find_blob(_ptr, name, def)); - } - - public Prop FindPropConcat(UfbxString parts, nuint numParts) - { - return new(Api.ufbx_find_prop_concat(_ptr, parts.GetUnsafePtr(), numParts)); - } - - public ReadOnlySpan PropsValue => _ptr->props.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->props.data, checked((int)_ptr->props.count)); - - public nuint NumAnimated => _ptr->num_animated; - - public bool HasDefaults => _ptr->defaults != null; - public Props Defaults => _ptr->defaults != null ? new(_ptr->defaults) : throw new InvalidOperationException("Defaults is null."); - - internal ufbx_props* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Quat.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Quat.nativegen.cs deleted file mode 100644 index 650e2e8..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Quat.nativegen.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Quat -{ - private ufbx_quat* _ptr; - - internal Quat(ufbx_quat* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public float X => _ptr->x; - - public float Y => _ptr->y; - - public float Z => _ptr->z; - - public float W => _ptr->w; - - internal ufbx_quat* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Scene.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Scene.nativegen.cs deleted file mode 100644 index ade9d72..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Scene.nativegen.cs +++ /dev/null @@ -1,256 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe class Scene : IDisposable -{ - private ufbx_scene* _ptr; - - internal Scene(ufbx_scene* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public void Dispose() - { - if (_ptr != null) - { - Api.ufbx_free_scene(_ptr); - _ptr = null; - } - } - - public static Scene LoadMemory(ReadOnlySpan data, in ufbx_load_opts options = default) - { - var optionsLocal = options; - ufbx_error error = default; - fixed (byte* dataPtr = data) - { - var value = Api.ufbx_load_memory(dataPtr, (nuint)data.Length, &optionsLocal, &error); - if (value == null) - { - throw new InvalidOperationException(NativeWrapperHelpers.GetString(error.description)); - } - return new(value); - } - } - - public static Scene LoadFile(sbyte* filename, LoadOpts opts, Error error) - { - return new(Api.ufbx_load_file(filename, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public static Scene LoadFile(ReadOnlySpan pathUtf8, LoadOpts options) - { - ufbx_error error = default; - fixed (byte* pathUtf8Ptr = pathUtf8) - { - var value = Api.ufbx_load_file_len((sbyte*)pathUtf8Ptr, (nuint)pathUtf8.Length, options.GetUnsafePtr(), &error); - if (value == null) - { - throw new InvalidOperationException(NativeWrapperHelpers.GetString(error.description)); - } - return new(value); - } - } - - public static Scene LoadStdio(void* file, LoadOpts opts, Error error) - { - return new(Api.ufbx_load_stdio(file, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public static Scene LoadStdioPrefix(void* file, void* prefix, nuint prefixSize, LoadOpts opts, Error error) - { - return new(Api.ufbx_load_stdio_prefix(file, prefix, prefixSize, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public void FreeScene() - { - Api.ufbx_free_scene(_ptr); - } - - public void RetainScene() - { - Api.ufbx_retain_scene(_ptr); - } - - public Element FindElement(ufbx_element_type type, ReadOnlySpan name) - { - fixed (byte* namePtr = name) - { - var value = Api.ufbx_find_element_len(_ptr, type, (sbyte*)namePtr, (nuint)name.Length); - return new(value); - } - } - - public Element FindElement(ufbx_element_type type, sbyte* name) - { - return new(Api.ufbx_find_element(_ptr, type, name)); - } - - public Node FindNode(ReadOnlySpan name) - { - fixed (byte* namePtr = name) - { - var value = Api.ufbx_find_node_len(_ptr, (sbyte*)namePtr, (nuint)name.Length); - return new(value); - } - } - - public Node FindNode(sbyte* name) - { - return new(Api.ufbx_find_node(_ptr, name)); - } - - public AnimStack FindAnimStack(ReadOnlySpan name) - { - fixed (byte* namePtr = name) - { - var value = Api.ufbx_find_anim_stack_len(_ptr, (sbyte*)namePtr, (nuint)name.Length); - return new(value); - } - } - - public AnimStack FindAnimStack(sbyte* name) - { - return new(Api.ufbx_find_anim_stack(_ptr, name)); - } - - public Material FindMaterial(ReadOnlySpan name) - { - fixed (byte* namePtr = name) - { - var value = Api.ufbx_find_material_len(_ptr, (sbyte*)namePtr, (nuint)name.Length); - return new(value); - } - } - - public Material FindMaterial(sbyte* name) - { - return new(Api.ufbx_find_material(_ptr, name)); - } - - public Scene EvaluateScene(Anim anim, double time, EvaluateOpts opts, Error error) - { - return new(Api.ufbx_evaluate_scene(_ptr, anim.GetUnsafePtr(), time, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public Anim CreateAnim(AnimOpts opts, Error error) - { - return new(Api.ufbx_create_anim(_ptr, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public BakedAnim BakeAnim(Anim anim, BakeOpts opts, Error error) - { - return new(Api.ufbx_bake_anim(_ptr, anim.GetUnsafePtr(), opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public Metadata Metadata => new((ufbx_metadata*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->metadata)); - - public SceneSettings Settings => new((ufbx_scene_settings*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->settings)); - - public bool HasRootNode => _ptr->root_node != null; - public Node RootNode => _ptr->root_node != null ? new(_ptr->root_node) : throw new InvalidOperationException("RootNode is null."); - - public bool HasAnim => _ptr->anim != null; - public Anim Anim => _ptr->anim != null ? new(_ptr->anim) : throw new InvalidOperationException("Anim is null."); - - public ReadOnlySpan TextureFiles => _ptr->texture_files.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->texture_files.data, checked((int)_ptr->texture_files.count)); - - public ElementList Elements => new(_ptr->elements.data, _ptr->elements.count); - - public ReadOnlySpan ConnectionsSrc => _ptr->connections_src.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->connections_src.data, checked((int)_ptr->connections_src.count)); - - public ReadOnlySpan ConnectionsDst => _ptr->connections_dst.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->connections_dst.data, checked((int)_ptr->connections_dst.count)); - - public ReadOnlySpan ElementsByName => _ptr->elements_by_name.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->elements_by_name.data, checked((int)_ptr->elements_by_name.count)); - - public bool HasDomRoot => _ptr->dom_root != null; - public DomNode DomRoot => _ptr->dom_root != null ? new(_ptr->dom_root) : throw new InvalidOperationException("DomRoot is null."); - - public UnknownList Unknowns => new(_ptr->unknowns.data, _ptr->unknowns.count); - - public NodeList Nodes => new(_ptr->nodes.data, _ptr->nodes.count); - - public MeshList Meshes => new(_ptr->meshes.data, _ptr->meshes.count); - - public LightList Lights => new(_ptr->lights.data, _ptr->lights.count); - - public CameraList Cameras => new(_ptr->cameras.data, _ptr->cameras.count); - - public BoneList Bones => new(_ptr->bones.data, _ptr->bones.count); - - public EmptyList Empties => new(_ptr->empties.data, _ptr->empties.count); - - public LineCurveList LineCurves => new(_ptr->line_curves.data, _ptr->line_curves.count); - - public NurbsCurveList NurbsCurves => new(_ptr->nurbs_curves.data, _ptr->nurbs_curves.count); - - public NurbsSurfaceList NurbsSurfaces => new(_ptr->nurbs_surfaces.data, _ptr->nurbs_surfaces.count); - - public NurbsTrimSurfaceList NurbsTrimSurfaces => new(_ptr->nurbs_trim_surfaces.data, _ptr->nurbs_trim_surfaces.count); - - public NurbsTrimBoundaryList NurbsTrimBoundaries => new(_ptr->nurbs_trim_boundaries.data, _ptr->nurbs_trim_boundaries.count); - - public ProceduralGeometryList ProceduralGeometries => new(_ptr->procedural_geometries.data, _ptr->procedural_geometries.count); - - public StereoCameraList StereoCameras => new(_ptr->stereo_cameras.data, _ptr->stereo_cameras.count); - - public CameraSwitcherList CameraSwitchers => new(_ptr->camera_switchers.data, _ptr->camera_switchers.count); - - public MarkerList Markers => new(_ptr->markers.data, _ptr->markers.count); - - public LodGroupList LodGroups => new(_ptr->lod_groups.data, _ptr->lod_groups.count); - - public SkinDeformerList SkinDeformers => new(_ptr->skin_deformers.data, _ptr->skin_deformers.count); - - public SkinClusterList SkinClusters => new(_ptr->skin_clusters.data, _ptr->skin_clusters.count); - - public BlendDeformerList BlendDeformers => new(_ptr->blend_deformers.data, _ptr->blend_deformers.count); - - public BlendChannelList BlendChannels => new(_ptr->blend_channels.data, _ptr->blend_channels.count); - - public BlendShapeList BlendShapes => new(_ptr->blend_shapes.data, _ptr->blend_shapes.count); - - public CacheDeformerList CacheDeformers => new(_ptr->cache_deformers.data, _ptr->cache_deformers.count); - - public CacheFileList CacheFiles => new(_ptr->cache_files.data, _ptr->cache_files.count); - - public MaterialList Materials => new(_ptr->materials.data, _ptr->materials.count); - - public TextureList Textures => new(_ptr->textures.data, _ptr->textures.count); - - public VideoList Videos => new(_ptr->videos.data, _ptr->videos.count); - - public ShaderList Shaders => new(_ptr->shaders.data, _ptr->shaders.count); - - public ShaderBindingList ShaderBindings => new(_ptr->shader_bindings.data, _ptr->shader_bindings.count); - - public AnimStackList AnimStacks => new(_ptr->anim_stacks.data, _ptr->anim_stacks.count); - - public AnimLayerList AnimLayers => new(_ptr->anim_layers.data, _ptr->anim_layers.count); - - public AnimValueList AnimValues => new(_ptr->anim_values.data, _ptr->anim_values.count); - - public AnimCurveList AnimCurves => new(_ptr->anim_curves.data, _ptr->anim_curves.count); - - public DisplayLayerList DisplayLayers => new(_ptr->display_layers.data, _ptr->display_layers.count); - - public SelectionSetList SelectionSets => new(_ptr->selection_sets.data, _ptr->selection_sets.count); - - public SelectionNodeList SelectionNodes => new(_ptr->selection_nodes.data, _ptr->selection_nodes.count); - - public CharacterList Characters => new(_ptr->characters.data, _ptr->characters.count); - - public ConstraintList Constraints => new(_ptr->constraints.data, _ptr->constraints.count); - - public AudioLayerList AudioLayers => new(_ptr->audio_layers.data, _ptr->audio_layers.count); - - public AudioClipList AudioClips => new(_ptr->audio_clips.data, _ptr->audio_clips.count); - - public PoseList Poses => new(_ptr->poses.data, _ptr->poses.count); - - public MetadataObjectList MetadataObjects => new(_ptr->metadata_objects.data, _ptr->metadata_objects.count); - - internal ufbx_scene* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SceneSettings.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SceneSettings.nativegen.cs deleted file mode 100644 index b943840..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SceneSettings.nativegen.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SceneSettings -{ - private ufbx_scene_settings* _ptr; - - internal SceneSettings(ufbx_scene_settings* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public CoordinateAxes Axes => new((ufbx_coordinate_axes*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->axes)); - - public float UnitMeters => _ptr->unit_meters; - - public double FramesPerSecond => _ptr->frames_per_second; - - public Misaki.HighPerformance.Mathematics.float3 AmbientColor => _ptr->ambient_color; - - public ReadOnlySpan DefaultCameraBytes => NativeWrapperHelpers.AsByteSpan(_ptr->default_camera); - public string DefaultCamera => NativeWrapperHelpers.GetString(_ptr->default_camera); - - public ufbx_time_mode TimeMode => _ptr->time_mode; - - public ufbx_time_protocol TimeProtocol => _ptr->time_protocol; - - public ufbx_snap_mode SnapMode => _ptr->snap_mode; - - public ufbx_coordinate_axis OriginalAxisUp => _ptr->original_axis_up; - - public float OriginalUnitMeters => _ptr->original_unit_meters; - - internal ufbx_scene_settings* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionNode.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionNode.nativegen.cs deleted file mode 100644 index 0ee46ff..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionNode.nativegen.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SelectionNode -{ - private ufbx_selection_node* _ptr; - - internal SelectionNode(ufbx_selection_node* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool HasTargetNode => _ptr->target_node != null; - public Node TargetNode => _ptr->target_node != null ? new(_ptr->target_node) : throw new InvalidOperationException("TargetNode is null."); - - public bool HasTargetMesh => _ptr->target_mesh != null; - public Mesh TargetMesh => _ptr->target_mesh != null ? new(_ptr->target_mesh) : throw new InvalidOperationException("TargetMesh is null."); - - public bool IncludeNode => _ptr->include_node; - - public ReadOnlySpan Vertices => _ptr->vertices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->vertices.data, checked((int)_ptr->vertices.count)); - - public ReadOnlySpan Edges => _ptr->edges.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->edges.data, checked((int)_ptr->edges.count)); - - public ReadOnlySpan Faces => _ptr->faces.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->faces.data, checked((int)_ptr->faces.count)); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_selection_node* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionNodeList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionNodeList.nativegen.cs deleted file mode 100644 index 250ae9e..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionNodeList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct SelectionNodeList -{ - private readonly ufbx_selection_node** _data; - public int Count { get; } - - internal SelectionNodeList(ufbx_selection_node** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public SelectionNode this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_selection_node** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_selection_node** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public SelectionNode Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionSet.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionSet.nativegen.cs deleted file mode 100644 index dcb492c..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionSet.nativegen.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SelectionSet -{ - private ufbx_selection_set* _ptr; - - internal SelectionSet(ufbx_selection_set* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public SelectionNodeList Nodes => new(_ptr->nodes.data, _ptr->nodes.count); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_selection_set* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionSetList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionSetList.nativegen.cs deleted file mode 100644 index 213e8e3..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SelectionSetList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct SelectionSetList -{ - private readonly ufbx_selection_set** _data; - public int Count { get; } - - internal SelectionSetList(ufbx_selection_set** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public SelectionSet this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_selection_set** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_selection_set** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public SelectionSet Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Shader.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Shader.nativegen.cs deleted file mode 100644 index db0fee9..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Shader.nativegen.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Shader -{ - private ufbx_shader* _ptr; - - internal Shader(ufbx_shader* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public string FindShaderPropLen(sbyte* name, nuint nameLen) - { - return NativeWrapperHelpers.GetString(Api.ufbx_find_shader_prop_len(_ptr, name, nameLen)); - } - - public string FindShaderProp(sbyte* name) - { - return NativeWrapperHelpers.GetString(Api.ufbx_find_shader_prop(_ptr, name)); - } - - public ufbx_shader_prop_binding_list FindShaderPropBindingsLen(sbyte* name, nuint nameLen) - { - return Api.ufbx_find_shader_prop_bindings_len(_ptr, name, nameLen); - } - - public ufbx_shader_prop_binding_list FindShaderPropBindings(sbyte* name) - { - return Api.ufbx_find_shader_prop_bindings(_ptr, name); - } - - public ufbx_shader_type Type => _ptr->type; - - public ShaderBindingList Bindings => new(_ptr->bindings.data, _ptr->bindings.count); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_shader* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderBinding.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderBinding.nativegen.cs deleted file mode 100644 index 8a86f93..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderBinding.nativegen.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ShaderBinding -{ - private ufbx_shader_binding* _ptr; - - internal ShaderBinding(ufbx_shader_binding* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan PropBindings => _ptr->prop_bindings.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->prop_bindings.data, checked((int)_ptr->prop_bindings.count)); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_shader_binding* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderBindingList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderBindingList.nativegen.cs deleted file mode 100644 index cbbeebf..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderBindingList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct ShaderBindingList -{ - private readonly ufbx_shader_binding** _data; - public int Count { get; } - - internal ShaderBindingList(ufbx_shader_binding** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public ShaderBinding this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_shader_binding** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_shader_binding** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public ShaderBinding Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderList.nativegen.cs deleted file mode 100644 index 42717b9..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct ShaderList -{ - private readonly ufbx_shader** _data; - public int Count { get; } - - internal ShaderList(ufbx_shader** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Shader this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_shader** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_shader** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Shader Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderPropBinding.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderPropBinding.nativegen.cs deleted file mode 100644 index abce8a9..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderPropBinding.nativegen.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ShaderPropBinding -{ - private ufbx_shader_prop_binding* _ptr; - - internal ShaderPropBinding(ufbx_shader_prop_binding* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan ShaderPropBytes => NativeWrapperHelpers.AsByteSpan(_ptr->shader_prop); - public string ShaderProp => NativeWrapperHelpers.GetString(_ptr->shader_prop); - - public ReadOnlySpan MaterialPropBytes => NativeWrapperHelpers.AsByteSpan(_ptr->material_prop); - public string MaterialProp => NativeWrapperHelpers.GetString(_ptr->material_prop); - - internal ufbx_shader_prop_binding* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderTexture.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderTexture.nativegen.cs deleted file mode 100644 index c11a0ad..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderTexture.nativegen.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ShaderTexture -{ - private ufbx_shader_texture* _ptr; - - internal ShaderTexture(ufbx_shader_texture* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ShaderTextureInput FindShaderTextureInputLen(sbyte* name, nuint nameLen) - { - return new(Api.ufbx_find_shader_texture_input_len(_ptr, name, nameLen)); - } - - public ShaderTextureInput FindShaderTextureInput(sbyte* name) - { - return new(Api.ufbx_find_shader_texture_input(_ptr, name)); - } - - public ufbx_shader_texture_type Type => _ptr->type; - - public ReadOnlySpan ShaderNameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->shader_name); - public string ShaderName => NativeWrapperHelpers.GetString(_ptr->shader_name); - - public ulong ShaderTypeId => _ptr->shader_type_id; - - public ReadOnlySpan Inputs => _ptr->inputs.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->inputs.data, checked((int)_ptr->inputs.count)); - - public ReadOnlySpan ShaderSourceBytes => NativeWrapperHelpers.AsByteSpan(_ptr->shader_source); - public string ShaderSource => NativeWrapperHelpers.GetString(_ptr->shader_source); - - public ReadOnlySpan RawShaderSource => NativeWrapperHelpers.AsSpan(_ptr->raw_shader_source); - - public bool HasMainTexture => _ptr->main_texture != null; - public Texture MainTexture => _ptr->main_texture != null ? new(_ptr->main_texture) : throw new InvalidOperationException("MainTexture is null."); - - public long MainTextureOutputIndex => _ptr->main_texture_output_index; - - public ReadOnlySpan PropPrefixBytes => NativeWrapperHelpers.AsByteSpan(_ptr->prop_prefix); - public string PropPrefix => NativeWrapperHelpers.GetString(_ptr->prop_prefix); - - internal ufbx_shader_texture* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderTextureInput.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderTextureInput.nativegen.cs deleted file mode 100644 index 6a50e77..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ShaderTextureInput.nativegen.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ShaderTextureInput -{ - private ufbx_shader_texture_input* _ptr; - - internal ShaderTextureInput(ufbx_shader_texture_input* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public long ValueInt => _ptr->value_int; - - public ReadOnlySpan ValueStrBytes => NativeWrapperHelpers.AsByteSpan(_ptr->value_str); - public string ValueStr => NativeWrapperHelpers.GetString(_ptr->value_str); - - public ReadOnlySpan ValueBlob => NativeWrapperHelpers.AsSpan(_ptr->value_blob); - - public bool HasTexture => _ptr->texture != null; - public Texture Texture => _ptr->texture != null ? new(_ptr->texture) : throw new InvalidOperationException("Texture is null."); - - public long TextureOutputIndex => _ptr->texture_output_index; - - public bool TextureEnabled => _ptr->texture_enabled; - - public bool HasProp => _ptr->prop != null; - public Prop Prop => _ptr->prop != null ? new(_ptr->prop) : throw new InvalidOperationException("Prop is null."); - - public bool HasTextureProp => _ptr->texture_prop != null; - public Prop TextureProp => _ptr->texture_prop != null ? new(_ptr->texture_prop) : throw new InvalidOperationException("TextureProp is null."); - - public bool HasTextureEnabledProp => _ptr->texture_enabled_prop != null; - public Prop TextureEnabledProp => _ptr->texture_enabled_prop != null ? new(_ptr->texture_enabled_prop) : throw new InvalidOperationException("TextureEnabledProp is null."); - - public float ValueReal => _ptr->value_real; - - public Misaki.HighPerformance.Mathematics.float2 ValueVec2 => _ptr->value_vec2; - - public Misaki.HighPerformance.Mathematics.float3 ValueVec3 => _ptr->value_vec3; - - public Misaki.HighPerformance.Mathematics.float4 ValueVec4 => _ptr->value_vec4; - - internal ufbx_shader_texture_input* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinCluster.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SkinCluster.nativegen.cs deleted file mode 100644 index aae5a90..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinCluster.nativegen.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SkinCluster -{ - private ufbx_skin_cluster* _ptr; - - internal SkinCluster(ufbx_skin_cluster* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool HasBoneNode => _ptr->bone_node != null; - public Node BoneNode => _ptr->bone_node != null ? new(_ptr->bone_node) : throw new InvalidOperationException("BoneNode is null."); - - public Misaki.HighPerformance.Mathematics.float3x4 GeometryToBone => _ptr->geometry_to_bone; - - public Misaki.HighPerformance.Mathematics.float3x4 MeshNodeToBone => _ptr->mesh_node_to_bone; - - public Misaki.HighPerformance.Mathematics.float3x4 BindToWorld => _ptr->bind_to_world; - - public Misaki.HighPerformance.Mathematics.float3x4 GeometryToWorld => _ptr->geometry_to_world; - - public Transform GeometryToWorldTransform => new((ufbx_transform*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->geometry_to_world_transform)); - - public nuint NumWeights => _ptr->num_weights; - - public ReadOnlySpan Vertices => _ptr->vertices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->vertices.data, checked((int)_ptr->vertices.count)); - - public ReadOnlySpan Weights => _ptr->weights.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->weights.data, checked((int)_ptr->weights.count)); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_skin_cluster* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinClusterList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SkinClusterList.nativegen.cs deleted file mode 100644 index 8ed4af4..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinClusterList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct SkinClusterList -{ - private readonly ufbx_skin_cluster** _data; - public int Count { get; } - - internal SkinClusterList(ufbx_skin_cluster** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public SkinCluster this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_skin_cluster** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_skin_cluster** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public SkinCluster Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinDeformer.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SkinDeformer.nativegen.cs deleted file mode 100644 index e38a275..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinDeformer.nativegen.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SkinDeformer -{ - private ufbx_skin_deformer* _ptr; - - internal SkinDeformer(ufbx_skin_deformer* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_skinning_method SkinningMethod => _ptr->skinning_method; - - public SkinClusterList Clusters => new(_ptr->clusters.data, _ptr->clusters.count); - - public ReadOnlySpan Vertices => _ptr->vertices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->vertices.data, checked((int)_ptr->vertices.count)); - - public ReadOnlySpan Weights => _ptr->weights.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->weights.data, checked((int)_ptr->weights.count)); - - public nuint MaxWeightsPerVertex => _ptr->max_weights_per_vertex; - - public nuint NumDqWeights => _ptr->num_dq_weights; - - public ReadOnlySpan DqVertices => _ptr->dq_vertices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->dq_vertices.data, checked((int)_ptr->dq_vertices.count)); - - public ReadOnlySpan DqWeights => _ptr->dq_weights.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->dq_weights.data, checked((int)_ptr->dq_weights.count)); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_skin_deformer* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinDeformerList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SkinDeformerList.nativegen.cs deleted file mode 100644 index 09816c2..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinDeformerList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct SkinDeformerList -{ - private readonly ufbx_skin_deformer** _data; - public int Count { get; } - - internal SkinDeformerList(ufbx_skin_deformer** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public SkinDeformer this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_skin_deformer** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_skin_deformer** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public SkinDeformer Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinVertex.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SkinVertex.nativegen.cs deleted file mode 100644 index 24441a2..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinVertex.nativegen.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SkinVertex -{ - private ufbx_skin_vertex* _ptr; - - internal SkinVertex(ufbx_skin_vertex* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint WeightBegin => _ptr->weight_begin; - - public uint NumWeights => _ptr->num_weights; - - public float DqWeight => _ptr->dq_weight; - - internal ufbx_skin_vertex* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinWeight.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SkinWeight.nativegen.cs deleted file mode 100644 index ea1ddac..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SkinWeight.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SkinWeight -{ - private ufbx_skin_weight* _ptr; - - internal SkinWeight(ufbx_skin_weight* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint ClusterIndex => _ptr->cluster_index; - - public float Weight => _ptr->weight; - - internal ufbx_skin_weight* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/StereoCamera.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/StereoCamera.nativegen.cs deleted file mode 100644 index c4bfd5e..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/StereoCamera.nativegen.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct StereoCamera -{ - private ufbx_stereo_camera* _ptr; - - internal StereoCamera(ufbx_stereo_camera* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool HasLeft => _ptr->left != null; - public Camera Left => _ptr->left != null ? new(_ptr->left) : throw new InvalidOperationException("Left is null."); - - public bool HasRight => _ptr->right != null; - public Camera Right => _ptr->right != null ? new(_ptr->right) : throw new InvalidOperationException("Right is null."); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - public NodeList Instances => new(_ptr->instances.data, _ptr->instances.count); - - internal ufbx_stereo_camera* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/StereoCameraList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/StereoCameraList.nativegen.cs deleted file mode 100644 index faafbe7..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/StereoCameraList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct StereoCameraList -{ - private readonly ufbx_stereo_camera** _data; - public int Count { get; } - - internal StereoCameraList(ufbx_stereo_camera** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public StereoCamera this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_stereo_camera** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_stereo_camera** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public StereoCamera Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Stream.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Stream.nativegen.cs deleted file mode 100644 index 5219e2e..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Stream.nativegen.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Stream -{ - private ufbx_stream* _ptr; - - internal Stream(ufbx_stream* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Scene LoadStream(LoadOpts opts, Error error) - { - return new(Api.ufbx_load_stream(_ptr, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public Scene LoadStreamPrefix(void* prefix, nuint prefixSize, LoadOpts opts, Error error) - { - return new(Api.ufbx_load_stream_prefix(_ptr, prefix, prefixSize, opts.GetUnsafePtr(), error.GetUnsafePtr())); - } - - public bool OpenFile(sbyte* path, nuint pathLen, OpenFileOpts opts, Error error) - { - return Api.ufbx_open_file(_ptr, path, pathLen, opts.GetUnsafePtr(), error.GetUnsafePtr()); - } - - public bool OpenFileCtx(nuint ctx, sbyte* path, nuint pathLen, OpenFileOpts opts, Error error) - { - return Api.ufbx_open_file_ctx(_ptr, ctx, path, pathLen, opts.GetUnsafePtr(), error.GetUnsafePtr()); - } - - public bool OpenMemory(void* data, nuint dataSize, OpenMemoryOpts opts, Error error) - { - return Api.ufbx_open_memory(_ptr, data, dataSize, opts.GetUnsafePtr(), error.GetUnsafePtr()); - } - - public bool OpenMemoryCtx(nuint ctx, void* data, nuint dataSize, OpenMemoryOpts opts, Error error) - { - return Api.ufbx_open_memory_ctx(_ptr, ctx, data, dataSize, opts.GetUnsafePtr(), error.GetUnsafePtr()); - } - - public void* User => _ptr->user; - - internal ufbx_stream* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivideOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivideOpts.nativegen.cs deleted file mode 100644 index bfd9d2f..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivideOpts.nativegen.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SubdivideOpts -{ - private ufbx_subdivide_opts* _ptr; - - internal SubdivideOpts(ufbx_subdivide_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public AllocatorOpts TempAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->temp_allocator)); - - public AllocatorOpts ResultAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->result_allocator)); - - public ufbx_subdivision_boundary Boundary => _ptr->boundary; - - public ufbx_subdivision_boundary UvBoundary => _ptr->uv_boundary; - - public bool IgnoreNormals => _ptr->ignore_normals; - - public bool InterpolateNormals => _ptr->interpolate_normals; - - public bool InterpolateTangents => _ptr->interpolate_tangents; - - public bool EvaluateSourceVertices => _ptr->evaluate_source_vertices; - - public nuint MaxSourceVertices => _ptr->max_source_vertices; - - public bool EvaluateSkinWeights => _ptr->evaluate_skin_weights; - - public nuint MaxSkinWeights => _ptr->max_skin_weights; - - public nuint SkinDeformerIndex => _ptr->skin_deformer_index; - - internal ufbx_subdivide_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivisionResult.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivisionResult.nativegen.cs deleted file mode 100644 index 3aef4c1..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivisionResult.nativegen.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SubdivisionResult -{ - private ufbx_subdivision_result* _ptr; - - internal SubdivisionResult(ufbx_subdivision_result* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public nuint ResultMemoryUsed => _ptr->result_memory_used; - - public nuint TempMemoryUsed => _ptr->temp_memory_used; - - public nuint ResultAllocs => _ptr->result_allocs; - - public nuint TempAllocs => _ptr->temp_allocs; - - public ReadOnlySpan SourceVertexRanges => _ptr->source_vertex_ranges.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->source_vertex_ranges.data, checked((int)_ptr->source_vertex_ranges.count)); - - public ReadOnlySpan SourceVertexWeights => _ptr->source_vertex_weights.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->source_vertex_weights.data, checked((int)_ptr->source_vertex_weights.count)); - - public ReadOnlySpan SkinClusterRanges => _ptr->skin_cluster_ranges.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->skin_cluster_ranges.data, checked((int)_ptr->skin_cluster_ranges.count)); - - public ReadOnlySpan SkinClusterWeights => _ptr->skin_cluster_weights.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->skin_cluster_weights.data, checked((int)_ptr->skin_cluster_weights.count)); - - internal ufbx_subdivision_result* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivisionWeight.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivisionWeight.nativegen.cs deleted file mode 100644 index b1fd3bc..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivisionWeight.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SubdivisionWeight -{ - private ufbx_subdivision_weight* _ptr; - - internal SubdivisionWeight(ufbx_subdivision_weight* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public float Weight => _ptr->weight; - - public uint Index => _ptr->index; - - internal ufbx_subdivision_weight* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivisionWeightRange.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivisionWeightRange.nativegen.cs deleted file mode 100644 index c2a9206..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SubdivisionWeightRange.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SubdivisionWeightRange -{ - private ufbx_subdivision_weight_range* _ptr; - - internal SubdivisionWeightRange(ufbx_subdivision_weight_range* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint WeightBegin => _ptr->weight_begin; - - public uint NumWeights => _ptr->num_weights; - - internal ufbx_subdivision_weight_range* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/SurfacePoint.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/SurfacePoint.nativegen.cs deleted file mode 100644 index abed725..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/SurfacePoint.nativegen.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct SurfacePoint -{ - private ufbx_surface_point* _ptr; - - internal SurfacePoint(ufbx_surface_point* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool Valid => _ptr->valid; - - public Misaki.HighPerformance.Mathematics.float3 Position => _ptr->position; - - public Misaki.HighPerformance.Mathematics.float3 DerivativeU => _ptr->derivative_u; - - public Misaki.HighPerformance.Mathematics.float3 DerivativeV => _ptr->derivative_v; - - internal ufbx_surface_point* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Tangent.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Tangent.nativegen.cs deleted file mode 100644 index 5d5cdcf..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Tangent.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Tangent -{ - private ufbx_tangent* _ptr; - - internal Tangent(ufbx_tangent* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public float Dx => _ptr->dx; - - public float Dy => _ptr->dy; - - internal ufbx_tangent* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/TessellateCurveOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/TessellateCurveOpts.nativegen.cs deleted file mode 100644 index 31bff2c..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/TessellateCurveOpts.nativegen.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct TessellateCurveOpts -{ - private ufbx_tessellate_curve_opts* _ptr; - - internal TessellateCurveOpts(ufbx_tessellate_curve_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public AllocatorOpts TempAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->temp_allocator)); - - public AllocatorOpts ResultAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->result_allocator)); - - public nuint SpanSubdivision => _ptr->span_subdivision; - - internal ufbx_tessellate_curve_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/TessellateSurfaceOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/TessellateSurfaceOpts.nativegen.cs deleted file mode 100644 index aba0d96..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/TessellateSurfaceOpts.nativegen.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct TessellateSurfaceOpts -{ - private ufbx_tessellate_surface_opts* _ptr; - - internal TessellateSurfaceOpts(ufbx_tessellate_surface_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public AllocatorOpts TempAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->temp_allocator)); - - public AllocatorOpts ResultAllocator => new((ufbx_allocator_opts*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->result_allocator)); - - public nuint SpanSubdivisionU => _ptr->span_subdivision_u; - - public nuint SpanSubdivisionV => _ptr->span_subdivision_v; - - public bool SkipMeshParts => _ptr->skip_mesh_parts; - - internal ufbx_tessellate_surface_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Texture.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Texture.nativegen.cs deleted file mode 100644 index 590fed7..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Texture.nativegen.cs +++ /dev/null @@ -1,74 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe ref struct Texture -{ - private ufbx_texture* _ptr; - - internal Texture(ufbx_texture* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_texture_type Type => _ptr->type; - - public ReadOnlySpan FilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->filename); - public string Filename => NativeWrapperHelpers.GetString(_ptr->filename); - - public ReadOnlySpan AbsoluteFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->absolute_filename); - public string AbsoluteFilename => NativeWrapperHelpers.GetString(_ptr->absolute_filename); - - public ReadOnlySpan RelativeFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->relative_filename); - public string RelativeFilename => NativeWrapperHelpers.GetString(_ptr->relative_filename); - - public ReadOnlySpan RawFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_filename); - - public ReadOnlySpan RawAbsoluteFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_absolute_filename); - - public ReadOnlySpan RawRelativeFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_relative_filename); - - public ReadOnlySpan Content => NativeWrapperHelpers.AsSpan(_ptr->content); - - public bool HasVideo => _ptr->video != null; - public Video Video => _ptr->video != null ? new(_ptr->video) : throw new InvalidOperationException("Video is null."); - - public uint FileIndex => _ptr->file_index; - - public bool HasFile => _ptr->has_file; - - public ReadOnlySpan Layers => _ptr->layers.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->layers.data, checked((int)_ptr->layers.count)); - - public bool HasShader => _ptr->shader != null; - public ShaderTexture Shader => _ptr->shader != null ? new(_ptr->shader) : throw new InvalidOperationException("Shader is null."); - - public TextureList FileTextures => new(_ptr->file_textures.data, _ptr->file_textures.count); - - public ReadOnlySpan UvSetBytes => NativeWrapperHelpers.AsByteSpan(_ptr->uv_set); - public string UvSet => NativeWrapperHelpers.GetString(_ptr->uv_set); - - public ufbx_wrap_mode WrapU => _ptr->wrap_u; - - public ufbx_wrap_mode WrapV => _ptr->wrap_v; - - public bool HasUvTransform => _ptr->has_uv_transform; - - public Transform UvTransform => new((ufbx_transform*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->uv_transform)); - - public Misaki.HighPerformance.Mathematics.float3x4 TextureToUv => _ptr->texture_to_uv; - - public Misaki.HighPerformance.Mathematics.float3x4 UvToTexture => _ptr->uv_to_texture; - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_texture* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/TextureFile.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/TextureFile.nativegen.cs deleted file mode 100644 index f5520c0..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/TextureFile.nativegen.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct TextureFile -{ - private ufbx_texture_file* _ptr; - - internal TextureFile(ufbx_texture_file* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint Index => _ptr->index; - - public ReadOnlySpan FilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->filename); - public string Filename => NativeWrapperHelpers.GetString(_ptr->filename); - - public ReadOnlySpan AbsoluteFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->absolute_filename); - public string AbsoluteFilename => NativeWrapperHelpers.GetString(_ptr->absolute_filename); - - public ReadOnlySpan RelativeFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->relative_filename); - public string RelativeFilename => NativeWrapperHelpers.GetString(_ptr->relative_filename); - - public ReadOnlySpan RawFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_filename); - - public ReadOnlySpan RawAbsoluteFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_absolute_filename); - - public ReadOnlySpan RawRelativeFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_relative_filename); - - public ReadOnlySpan Content => NativeWrapperHelpers.AsSpan(_ptr->content); - - internal ufbx_texture_file* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/TextureLayer.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/TextureLayer.nativegen.cs deleted file mode 100644 index c038196..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/TextureLayer.nativegen.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct TextureLayer -{ - private ufbx_texture_layer* _ptr; - - internal TextureLayer(ufbx_texture_layer* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool HasTexture => _ptr->texture != null; - public Texture Texture => _ptr->texture != null ? new(_ptr->texture) : throw new InvalidOperationException("Texture is null."); - - public ufbx_blend_mode BlendMode => _ptr->blend_mode; - - public float Alpha => _ptr->alpha; - - internal ufbx_texture_layer* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/TextureList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/TextureList.nativegen.cs deleted file mode 100644 index dbd5350..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/TextureList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct TextureList -{ - private readonly ufbx_texture** _data; - public int Count { get; } - - internal TextureList(ufbx_texture** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Texture this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_texture** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_texture** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Texture Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ThreadOpts.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ThreadOpts.nativegen.cs deleted file mode 100644 index 0a63268..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ThreadOpts.nativegen.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ThreadOpts -{ - private ufbx_thread_opts* _ptr; - - internal ThreadOpts(ufbx_thread_opts* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ThreadPool Pool => new((ufbx_thread_pool*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->pool)); - - public nuint NumTasks => _ptr->num_tasks; - - public nuint MemoryLimit => _ptr->memory_limit; - - internal ufbx_thread_opts* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ThreadPool.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ThreadPool.nativegen.cs deleted file mode 100644 index 1bff93c..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ThreadPool.nativegen.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ThreadPool -{ - private ufbx_thread_pool* _ptr; - - internal ThreadPool(ufbx_thread_pool* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public void* User => _ptr->user; - - internal ufbx_thread_pool* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ThreadPoolInfo.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ThreadPoolInfo.nativegen.cs deleted file mode 100644 index 26cd8b7..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/ThreadPoolInfo.nativegen.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct ThreadPoolInfo -{ - private ufbx_thread_pool_info* _ptr; - - internal ThreadPoolInfo(ufbx_thread_pool_info* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint MaxConcurrentTasks => _ptr->max_concurrent_tasks; - - internal ufbx_thread_pool_info* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Thumbnail.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Thumbnail.nativegen.cs deleted file mode 100644 index 9e22077..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Thumbnail.nativegen.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Thumbnail -{ - private ufbx_thumbnail* _ptr; - - internal Thumbnail(ufbx_thumbnail* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint Width => _ptr->width; - - public uint Height => _ptr->height; - - public ufbx_thumbnail_format Format => _ptr->format; - - public ReadOnlySpan Data => NativeWrapperHelpers.AsSpan(_ptr->data); - - internal ufbx_thumbnail* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/TopoEdge.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/TopoEdge.nativegen.cs deleted file mode 100644 index 4413639..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/TopoEdge.nativegen.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct TopoEdge -{ - private ufbx_topo_edge* _ptr; - - internal TopoEdge(ufbx_topo_edge* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint TopoNextVertexEdge(nuint numTopo, uint index) - { - return Api.ufbx_topo_next_vertex_edge(_ptr, numTopo, index); - } - - public uint TopoPrevVertexEdge(nuint numTopo, uint index) - { - return Api.ufbx_topo_prev_vertex_edge(_ptr, numTopo, index); - } - - public uint Index => _ptr->index; - - public uint Next => _ptr->next; - - public uint Prev => _ptr->prev; - - public uint Twin => _ptr->twin; - - public uint Face => _ptr->face; - - public uint Edge => _ptr->edge; - - public ufbx_topo_flags Flags => _ptr->flags; - - internal ufbx_topo_edge* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Transform.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Transform.nativegen.cs deleted file mode 100644 index 27dc3bd..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Transform.nativegen.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Transform -{ - private ufbx_transform* _ptr; - - internal Transform(ufbx_transform* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Misaki.HighPerformance.Mathematics.float3x4 TransformToMatrix() - { - return Api.ufbx_transform_to_matrix(_ptr); - } - - public Misaki.HighPerformance.Mathematics.float3 Translation => _ptr->translation; - - public Misaki.HighPerformance.Mathematics.quaternion Rotation => _ptr->rotation; - - public Misaki.HighPerformance.Mathematics.float3 Scale => _ptr->scale; - - internal ufbx_transform* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/TransformOverride.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/TransformOverride.nativegen.cs deleted file mode 100644 index 1694950..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/TransformOverride.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct TransformOverride -{ - private ufbx_transform_override* _ptr; - - internal TransformOverride(ufbx_transform_override* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public uint NodeId => _ptr->node_id; - - public Transform Transform => new((ufbx_transform*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->transform)); - - internal ufbx_transform_override* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Ufbx.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Ufbx.nativegen.cs deleted file mode 100644 index 043ff1a..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Ufbx.nativegen.cs +++ /dev/null @@ -1,140 +0,0 @@ -namespace Ghost.Ufbx; - -public static unsafe class Ufbx -{ - public static bool CoordinateAxesValid(ufbx_coordinate_axes axes) - { - return Api.ufbx_coordinate_axes_valid(axes); - } - - public static bool DefaultOpenFile(void* user, Stream stream, sbyte* path, nuint pathLen, OpenFileInfo info) - { - return Api.ufbx_default_open_file(user, stream.GetUnsafePtr(), path, pathLen, info.GetUnsafePtr()); - } - - public static Misaki.HighPerformance.Mathematics.quaternion EulerToQuat(Misaki.HighPerformance.Mathematics.float3 v, ufbx_rotation_order order) - { - return Api.ufbx_euler_to_quat(v, order); - } - - public static Misaki.HighPerformance.Mathematics.quaternion EvaluateBakedQuat(ufbx_baked_quat_list keyframes, double time) - { - return Api.ufbx_evaluate_baked_quat(keyframes, time); - } - - public static Misaki.HighPerformance.Mathematics.float3 EvaluateBakedVec3(ufbx_baked_vec3_list keyframes, double time) - { - return Api.ufbx_evaluate_baked_vec3(keyframes, time); - } - - public static nuint FormatError(sbyte* dst, nuint dstSize, Error error) - { - return Api.ufbx_format_error(dst, dstSize, error.GetUnsafePtr()); - } - - public static nint Inflate(void* dst, nuint dstSize, InflateInput input, InflateRetain retain) - { - return Api.ufbx_inflate(dst, dstSize, input.GetUnsafePtr(), retain.GetUnsafePtr()); - } - - public static bool IsThreadSafe() - { - return Api.ufbx_is_thread_safe(); - } - - public static float MatrixDeterminant(Misaki.HighPerformance.Mathematics.float3x4* m) - { - return Api.ufbx_matrix_determinant(m); - } - - public static Misaki.HighPerformance.Mathematics.float3x4 MatrixForNormals(Misaki.HighPerformance.Mathematics.float3x4* m) - { - return Api.ufbx_matrix_for_normals(m); - } - - public static Misaki.HighPerformance.Mathematics.float3x4 MatrixInvert(Misaki.HighPerformance.Mathematics.float3x4* m) - { - return Api.ufbx_matrix_invert(m); - } - - public static Misaki.HighPerformance.Mathematics.float3x4 MatrixMul(Misaki.HighPerformance.Mathematics.float3x4* a, Misaki.HighPerformance.Mathematics.float3x4* b) - { - return Api.ufbx_matrix_mul(a, b); - } - - public static ufbx_transform MatrixToTransform(Misaki.HighPerformance.Mathematics.float3x4* m) - { - return Api.ufbx_matrix_to_transform(m); - } - - public static float QuatDot(Misaki.HighPerformance.Mathematics.quaternion a, Misaki.HighPerformance.Mathematics.quaternion b) - { - return Api.ufbx_quat_dot(a, b); - } - - public static Misaki.HighPerformance.Mathematics.quaternion QuatFixAntipodal(Misaki.HighPerformance.Mathematics.quaternion q, Misaki.HighPerformance.Mathematics.quaternion reference) - { - return Api.ufbx_quat_fix_antipodal(q, reference); - } - - public static Misaki.HighPerformance.Mathematics.quaternion QuatMul(Misaki.HighPerformance.Mathematics.quaternion a, Misaki.HighPerformance.Mathematics.quaternion b) - { - return Api.ufbx_quat_mul(a, b); - } - - public static Misaki.HighPerformance.Mathematics.quaternion QuatNormalize(Misaki.HighPerformance.Mathematics.quaternion q) - { - return Api.ufbx_quat_normalize(q); - } - - public static Misaki.HighPerformance.Mathematics.float3 QuatRotateVec3(Misaki.HighPerformance.Mathematics.quaternion q, Misaki.HighPerformance.Mathematics.float3 v) - { - return Api.ufbx_quat_rotate_vec3(q, v); - } - - public static Misaki.HighPerformance.Mathematics.quaternion QuatSlerp(Misaki.HighPerformance.Mathematics.quaternion a, Misaki.HighPerformance.Mathematics.quaternion b, float t) - { - return Api.ufbx_quat_slerp(a, b, t); - } - - public static Misaki.HighPerformance.Mathematics.float3 QuatToEuler(Misaki.HighPerformance.Mathematics.quaternion q, ufbx_rotation_order order) - { - return Api.ufbx_quat_to_euler(q, order); - } - - public static void* ThreadPoolGetUserPtr(nuint ctx) - { - return Api.ufbx_thread_pool_get_user_ptr(ctx); - } - - public static void ThreadPoolRunTask(nuint ctx, uint index) - { - Api.ufbx_thread_pool_run_task(ctx, index); - } - - public static void ThreadPoolSetUserPtr(nuint ctx, void* userPtr) - { - Api.ufbx_thread_pool_set_user_ptr(ctx, userPtr); - } - - public static Misaki.HighPerformance.Mathematics.float3 TransformDirection(Misaki.HighPerformance.Mathematics.float3x4* m, Misaki.HighPerformance.Mathematics.float3 v) - { - return Api.ufbx_transform_direction(m, v); - } - - public static Misaki.HighPerformance.Mathematics.float3 TransformPosition(Misaki.HighPerformance.Mathematics.float3x4* m, Misaki.HighPerformance.Mathematics.float3 v) - { - return Api.ufbx_transform_position(m, v); - } - - public static uint TriangulateFace(uint* indices, nuint numIndices, Mesh mesh, ufbx_face face) - { - return Api.ufbx_triangulate_face(indices, numIndices, mesh.GetUnsafePtr(), face); - } - - public static Misaki.HighPerformance.Mathematics.float3 Vec3Normalize(Misaki.HighPerformance.Mathematics.float3 v) - { - return Api.ufbx_vec3_normalize(v); - } - -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/UfbxBlob.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/UfbxBlob.nativegen.cs deleted file mode 100644 index eb002ed..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/UfbxBlob.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct UfbxBlob -{ - private ufbx_blob* _ptr; - - internal UfbxBlob(ufbx_blob* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public void* Data => _ptr->data; - - public nuint Size => _ptr->size; - - internal ufbx_blob* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/UfbxString.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/UfbxString.nativegen.cs deleted file mode 100644 index c3d0189..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/UfbxString.nativegen.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct UfbxString -{ - private ufbx_string* _ptr; - - internal UfbxString(ufbx_string* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public sbyte* Data => _ptr->data; - - public nuint Length => _ptr->length; - - internal ufbx_string* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Unknown.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Unknown.nativegen.cs deleted file mode 100644 index c9eaa24..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Unknown.nativegen.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Unknown -{ - private ufbx_unknown* _ptr; - - internal Unknown(ufbx_unknown* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan TypeBytes => NativeWrapperHelpers.AsByteSpan(_ptr->type); - public string Type => NativeWrapperHelpers.GetString(_ptr->type); - - public ReadOnlySpan SuperTypeBytes => NativeWrapperHelpers.AsByteSpan(_ptr->super_type); - public string SuperType => NativeWrapperHelpers.GetString(_ptr->super_type); - - public ReadOnlySpan SubTypeBytes => NativeWrapperHelpers.AsByteSpan(_ptr->sub_type); - public string SubType => NativeWrapperHelpers.GetString(_ptr->sub_type); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_unknown* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/UnknownList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/UnknownList.nativegen.cs deleted file mode 100644 index eaca4cc..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/UnknownList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct UnknownList -{ - private readonly ufbx_unknown** _data; - public int Count { get; } - - internal UnknownList(ufbx_unknown** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Unknown this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_unknown** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_unknown** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Unknown Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/UvSet.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/UvSet.nativegen.cs deleted file mode 100644 index aeab21d..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/UvSet.nativegen.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct UvSet -{ - private ufbx_uv_set* _ptr; - - internal UvSet(ufbx_uv_set* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public uint Index => _ptr->index; - - public VertexVec2 VertexUv => new((ufbx_vertex_vec2*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_uv)); - - public VertexVec3 VertexTangent => new((ufbx_vertex_vec3*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_tangent)); - - public VertexVec3 VertexBitangent => new((ufbx_vertex_vec3*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->vertex_bitangent)); - - internal ufbx_uv_set* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexAttrib.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/VertexAttrib.nativegen.cs deleted file mode 100644 index b7f3671..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexAttrib.nativegen.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct VertexAttrib -{ - private ufbx_vertex_attrib* _ptr; - - internal VertexAttrib(ufbx_vertex_attrib* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool Exists => _ptr->exists; - - public VoidList Values => new(_ptr->values.data, _ptr->values.count); - - public ReadOnlySpan Indices => _ptr->indices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->indices.data, checked((int)_ptr->indices.count)); - - public nuint ValueReals => _ptr->value_reals; - - public bool UniquePerVertex => _ptr->unique_per_vertex; - - public ReadOnlySpan ValuesW => _ptr->values_w.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->values_w.data, checked((int)_ptr->values_w.count)); - - internal ufbx_vertex_attrib* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexReal.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/VertexReal.nativegen.cs deleted file mode 100644 index 7194ea4..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexReal.nativegen.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct VertexReal -{ - private ufbx_vertex_real* _ptr; - - internal VertexReal(ufbx_vertex_real* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool Exists => _ptr->exists; - - public ReadOnlySpan Values => _ptr->values.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->values.data, checked((int)_ptr->values.count)); - - public ReadOnlySpan Indices => _ptr->indices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->indices.data, checked((int)_ptr->indices.count)); - - public nuint ValueReals => _ptr->value_reals; - - public bool UniquePerVertex => _ptr->unique_per_vertex; - - public ReadOnlySpan ValuesW => _ptr->values_w.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->values_w.data, checked((int)_ptr->values_w.count)); - - internal ufbx_vertex_real* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexStream.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/VertexStream.nativegen.cs deleted file mode 100644 index 26d295c..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexStream.nativegen.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct VertexStream -{ - private ufbx_vertex_stream* _ptr; - - internal VertexStream(ufbx_vertex_stream* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public nuint GenerateIndices(nuint numStreams, uint* indices, nuint numIndices, AllocatorOpts allocator, Error error) - { - return Api.ufbx_generate_indices(_ptr, numStreams, indices, numIndices, allocator.GetUnsafePtr(), error.GetUnsafePtr()); - } - - public void* Data => _ptr->data; - - public nuint VertexCount => _ptr->vertex_count; - - public nuint VertexSize => _ptr->vertex_size; - - internal ufbx_vertex_stream* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexVec2.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/VertexVec2.nativegen.cs deleted file mode 100644 index 0496d20..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexVec2.nativegen.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct VertexVec2 -{ - private ufbx_vertex_vec2* _ptr; - - internal VertexVec2(ufbx_vertex_vec2* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool Exists => _ptr->exists; - - public ReadOnlySpan Values => _ptr->values.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->values.data, checked((int)_ptr->values.count)); - - public ReadOnlySpan Indices => _ptr->indices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->indices.data, checked((int)_ptr->indices.count)); - - public nuint ValueReals => _ptr->value_reals; - - public bool UniquePerVertex => _ptr->unique_per_vertex; - - public ReadOnlySpan ValuesW => _ptr->values_w.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->values_w.data, checked((int)_ptr->values_w.count)); - - internal ufbx_vertex_vec2* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexVec3.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/VertexVec3.nativegen.cs deleted file mode 100644 index a11c94d..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexVec3.nativegen.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct VertexVec3 -{ - private ufbx_vertex_vec3* _ptr; - - internal VertexVec3(ufbx_vertex_vec3* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public Misaki.HighPerformance.Mathematics.float3 GetWeightedFaceNormal(ufbx_face face) - { - return Api.ufbx_get_weighted_face_normal(_ptr, face); - } - - public bool Exists => _ptr->exists; - - public ReadOnlySpan Values => _ptr->values.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->values.data, checked((int)_ptr->values.count)); - - public ReadOnlySpan Indices => _ptr->indices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->indices.data, checked((int)_ptr->indices.count)); - - public nuint ValueReals => _ptr->value_reals; - - public bool UniquePerVertex => _ptr->unique_per_vertex; - - public ReadOnlySpan ValuesW => _ptr->values_w.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->values_w.data, checked((int)_ptr->values_w.count)); - - internal ufbx_vertex_vec3* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexVec4.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/VertexVec4.nativegen.cs deleted file mode 100644 index 9ab591e..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/VertexVec4.nativegen.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct VertexVec4 -{ - private ufbx_vertex_vec4* _ptr; - - internal VertexVec4(ufbx_vertex_vec4* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public bool Exists => _ptr->exists; - - public ReadOnlySpan Values => _ptr->values.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->values.data, checked((int)_ptr->values.count)); - - public ReadOnlySpan Indices => _ptr->indices.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->indices.data, checked((int)_ptr->indices.count)); - - public nuint ValueReals => _ptr->value_reals; - - public bool UniquePerVertex => _ptr->unique_per_vertex; - - public ReadOnlySpan ValuesW => _ptr->values_w.data == null ? ReadOnlySpan.Empty : new ReadOnlySpan(_ptr->values_w.data, checked((int)_ptr->values_w.count)); - - internal ufbx_vertex_vec4* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Video.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Video.nativegen.cs deleted file mode 100644 index 691c172..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Video.nativegen.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Video -{ - private ufbx_video* _ptr; - - internal Video(ufbx_video* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ReadOnlySpan FilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->filename); - public string Filename => NativeWrapperHelpers.GetString(_ptr->filename); - - public ReadOnlySpan AbsoluteFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->absolute_filename); - public string AbsoluteFilename => NativeWrapperHelpers.GetString(_ptr->absolute_filename); - - public ReadOnlySpan RelativeFilenameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->relative_filename); - public string RelativeFilename => NativeWrapperHelpers.GetString(_ptr->relative_filename); - - public ReadOnlySpan RawFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_filename); - - public ReadOnlySpan RawAbsoluteFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_absolute_filename); - - public ReadOnlySpan RawRelativeFilename => NativeWrapperHelpers.AsSpan(_ptr->raw_relative_filename); - - public ReadOnlySpan Content => NativeWrapperHelpers.AsSpan(_ptr->content); - - public Element Element => new((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->element)); - - public ReadOnlySpan NameBytes => NativeWrapperHelpers.AsByteSpan(_ptr->name); - public string Name => NativeWrapperHelpers.GetString(_ptr->name); - - public Props Props => new((ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->props)); - - public uint ElementId => _ptr->element_id; - - public uint TypedId => _ptr->typed_id; - - internal ufbx_video* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/VideoList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/VideoList.nativegen.cs deleted file mode 100644 index 4617658..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/VideoList.nativegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct VideoList -{ - private readonly ufbx_video** _data; - public int Count { get; } - - internal VideoList(ufbx_video** data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public Video this[int index] - { - get - { - NativeWrapperHelpers.ThrowIfOutOfRange(index, Count); - return new(_data[index]); - } - } - - public Enumerator GetEnumerator() => new(_data, Count); - - public unsafe ref struct Enumerator - { - private readonly ufbx_video** _data; - private readonly int _count; - private int _index; - - internal Enumerator(ufbx_video** data, int count) - { - _data = data; - _count = count; - _index = -1; - } - - public Video Current => new(_data[_index]); - - public bool MoveNext() - { - var next = _index + 1; - if (next >= _count) - { - return false; - } - - _index = next; - return true; - } - } -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/VoidList.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/VoidList.nativegen.cs deleted file mode 100644 index 230fe38..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/VoidList.nativegen.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe readonly ref struct VoidList -{ - private readonly void* _data; - public int Count { get; } - - internal VoidList(void* data, nuint count) - { - _data = data; - Count = checked((int)count); - } - - public void* Data => _data; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/Warning.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/Warning.nativegen.cs deleted file mode 100644 index 826c950..0000000 --- a/src/ThridParty/Ghost.Ufbx/Wrapper/Warning.nativegen.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Ghost.Ufbx; - -public unsafe struct Warning -{ - private ufbx_warning* _ptr; - - internal Warning(ufbx_warning* ptr) - { - _ptr = ptr; - } - - public bool IsNull => _ptr == null; - - public ufbx_warning_type Type => _ptr->type; - - public ReadOnlySpan DescriptionBytes => NativeWrapperHelpers.AsByteSpan(_ptr->description); - public string Description => NativeWrapperHelpers.GetString(_ptr->description); - - public uint ElementId => _ptr->element_id; - - public nuint Count => _ptr->count; - - internal ufbx_warning* GetUnsafePtr() => _ptr; -} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim.nativegen.cs new file mode 100644 index 0000000..904cda1 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim.nativegen.cs @@ -0,0 +1,133 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_anim +{ + // From: ufbx_evaluate_prop_len(ufbx_anim*, ufbx_element*, sbyte*, nuint, double) + public ufbx_prop evaluate_prop_len(ufbx_element* element, ReadOnlySpan name, double time) + { + fixed (byte* pname = name) + { + return Api.ufbx_evaluate_prop_len( + (ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element, + (sbyte*)pname, + (nuint)name.Length, + time); + } + } + + // From: ufbx_evaluate_prop(ufbx_anim*, ufbx_element*, sbyte*, double) + public ufbx_prop evaluate_prop(ufbx_element* element, sbyte* name, double time) + { + return Api.ufbx_evaluate_prop( + (ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element, + name, + time); + } + + // From: ufbx_evaluate_prop_flags_len(ufbx_anim*, ufbx_element*, sbyte*, nuint, double, uint) + public ufbx_prop evaluate_prop_flags_len(ufbx_element* element, ReadOnlySpan name, double time, uint flags) + { + fixed (byte* pname = name) + { + return Api.ufbx_evaluate_prop_flags_len( + (ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element, + (sbyte*)pname, + (nuint)name.Length, + time, + flags); + } + } + + // From: ufbx_evaluate_prop_flags(ufbx_anim*, ufbx_element*, sbyte*, double, uint) + public ufbx_prop evaluate_prop_flags(ufbx_element* element, sbyte* name, double time, uint flags) + { + return Api.ufbx_evaluate_prop_flags( + (ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element, + name, + time, + flags); + } + + // From: ufbx_evaluate_props(ufbx_anim*, ufbx_element*, double, ufbx_prop*, nuint) + public ufbx_props evaluate_props(ufbx_element* element, double time, ufbx_prop* buffer, nuint buffer_size) + { + return Api.ufbx_evaluate_props( + (ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element, + time, + buffer, + buffer_size); + } + + // From: ufbx_evaluate_props_flags(ufbx_anim*, ufbx_element*, double, ufbx_prop*, nuint, uint) + public ufbx_props evaluate_props_flags(ufbx_element* element, double time, ufbx_prop* buffer, nuint buffer_size, uint flags) + { + return Api.ufbx_evaluate_props_flags( + (ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element, + time, + buffer, + buffer_size, + flags); + } + + // From: ufbx_evaluate_transform(ufbx_anim*, ufbx_node*, double) + public ufbx_transform evaluate_transform(ufbx_node* node, double time) + { + return Api.ufbx_evaluate_transform( + (ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + node, + time); + } + + // From: ufbx_evaluate_transform_flags(ufbx_anim*, ufbx_node*, double, uint) + public ufbx_transform evaluate_transform_flags(ufbx_node* node, double time, uint flags) + { + return Api.ufbx_evaluate_transform_flags( + (ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + node, + time, + flags); + } + + // From: ufbx_evaluate_blend_weight(ufbx_anim*, ufbx_blend_channel*, double) + public float evaluate_blend_weight(ufbx_blend_channel* channel, double time) + { + return Api.ufbx_evaluate_blend_weight( + (ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + time); + } + + // From: ufbx_evaluate_blend_weight_flags(ufbx_anim*, ufbx_blend_channel*, double, uint) + public float evaluate_blend_weight_flags(ufbx_blend_channel* channel, double time, uint flags) + { + return Api.ufbx_evaluate_blend_weight_flags( + (ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + channel, + time, + flags); + } + + // From: ufbx_free_anim(ufbx_anim*) + public void free() + { + Api.ufbx_free_anim((ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_retain_anim(ufbx_anim*) + public void retain() + { + Api.ufbx_retain_anim((ufbx_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim_curve.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim_curve.nativegen.cs new file mode 100644 index 0000000..be730af --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim_curve.nativegen.cs @@ -0,0 +1,29 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_anim_curve +{ + // From: ufbx_evaluate_curve(ufbx_anim_curve*, double, float) + public float evaluate_curve(double time, float default_value) + { + return Api.ufbx_evaluate_curve( + (ufbx_anim_curve*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + time, + default_value); + } + + // From: ufbx_evaluate_curve_flags(ufbx_anim_curve*, double, float, uint) + public float evaluate_curve_flags(double time, float default_value, uint flags) + { + return Api.ufbx_evaluate_curve_flags( + (ufbx_anim_curve*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + time, + default_value, + flags); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim_layer.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim_layer.nativegen.cs new file mode 100644 index 0000000..0a27ed6 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim_layer.nativegen.cs @@ -0,0 +1,40 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_anim_layer +{ + // From: ufbx_find_anim_prop_len(ufbx_anim_layer*, ufbx_element*, sbyte*, nuint) + public ufbx_anim_prop* find_anim_prop_len(ufbx_element* element, ReadOnlySpan prop) + { + fixed (byte* pprop = prop) + { + return Api.ufbx_find_anim_prop_len( + (ufbx_anim_layer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element, + (sbyte*)pprop, + (nuint)prop.Length); + } + } + + // From: ufbx_find_anim_prop(ufbx_anim_layer*, ufbx_element*, sbyte*) + public ufbx_anim_prop* find_anim_prop(ufbx_element* element, sbyte* prop) + { + return Api.ufbx_find_anim_prop( + (ufbx_anim_layer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element, + prop); + } + + // From: ufbx_find_anim_props(ufbx_anim_layer*, ufbx_element*) + public ufbx_anim_prop_list find_anim_props(ufbx_element* element) + { + return Api.ufbx_find_anim_props( + (ufbx_anim_layer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim_value.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim_value.nativegen.cs new file mode 100644 index 0000000..5575eed --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_anim_value.nativegen.cs @@ -0,0 +1,44 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_anim_value +{ + // From: ufbx_evaluate_anim_value_real(ufbx_anim_value*, double) + public float evaluate_anim_value_real(double time) + { + return Api.ufbx_evaluate_anim_value_real( + (ufbx_anim_value*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + time); + } + + // From: ufbx_evaluate_anim_value_vec3(ufbx_anim_value*, double) + public Misaki.HighPerformance.Mathematics.float3 evaluate_anim_value_vec3(double time) + { + return Api.ufbx_evaluate_anim_value_vec3( + (ufbx_anim_value*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + time); + } + + // From: ufbx_evaluate_anim_value_real_flags(ufbx_anim_value*, double, uint) + public float evaluate_anim_value_real_flags(double time, uint flags) + { + return Api.ufbx_evaluate_anim_value_real_flags( + (ufbx_anim_value*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + time, + flags); + } + + // From: ufbx_evaluate_anim_value_vec3_flags(ufbx_anim_value*, double, uint) + public Misaki.HighPerformance.Mathematics.float3 evaluate_anim_value_vec3_flags(double time, uint flags) + { + return Api.ufbx_evaluate_anim_value_vec3_flags( + (ufbx_anim_value*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + time, + flags); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_baked_anim.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_baked_anim.nativegen.cs new file mode 100644 index 0000000..ccd197e --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_baked_anim.nativegen.cs @@ -0,0 +1,54 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_baked_anim +{ + // From: ufbx_retain_baked_anim(ufbx_baked_anim*) + public void retain() + { + Api.ufbx_retain_baked_anim((ufbx_baked_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_free_baked_anim(ufbx_baked_anim*) + public void free() + { + Api.ufbx_free_baked_anim((ufbx_baked_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_find_baked_node_by_typed_id(ufbx_baked_anim*, uint) + public ufbx_baked_node* find_baked_node_by_typed_id(uint typed_id) + { + return Api.ufbx_find_baked_node_by_typed_id( + (ufbx_baked_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + typed_id); + } + + // From: ufbx_find_baked_node(ufbx_baked_anim*, ufbx_node*) + public ufbx_baked_node* find_baked_node(ufbx_node* node) + { + return Api.ufbx_find_baked_node( + (ufbx_baked_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + node); + } + + // From: ufbx_find_baked_element_by_element_id(ufbx_baked_anim*, uint) + public ufbx_baked_element* find_baked_element_by_element_id(uint element_id) + { + return Api.ufbx_find_baked_element_by_element_id( + (ufbx_baked_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element_id); + } + + // From: ufbx_find_baked_element(ufbx_baked_anim*, ufbx_element*) + public ufbx_baked_element* find_baked_element(ufbx_element* element) + { + return Api.ufbx_find_baked_element( + (ufbx_baked_anim*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + element); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_blend_deformer.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_blend_deformer.nativegen.cs new file mode 100644 index 0000000..cc4f68f --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_blend_deformer.nativegen.cs @@ -0,0 +1,28 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_blend_deformer +{ + // From: ufbx_get_blend_vertex_offset(ufbx_blend_deformer*, nuint) + public Misaki.HighPerformance.Mathematics.float3 get_blend_vertex_offset(nuint vertex) + { + return Api.ufbx_get_blend_vertex_offset( + (ufbx_blend_deformer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + vertex); + } + + // From: ufbx_add_blend_vertex_offsets(ufbx_blend_deformer*, Misaki.HighPerformance.Mathematics.float3*, nuint, float) + public void add_blend_vertex_offsets(Misaki.HighPerformance.Mathematics.float3* vertices, nuint num_vertices, float weight) + { + Api.ufbx_add_blend_vertex_offsets( + (ufbx_blend_deformer*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + vertices, + num_vertices, + weight); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_blend_shape.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_blend_shape.nativegen.cs new file mode 100644 index 0000000..3a84e75 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_blend_shape.nativegen.cs @@ -0,0 +1,36 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_blend_shape +{ + // From: ufbx_get_blend_shape_offset_index(ufbx_blend_shape*, nuint) + public uint get_blend_shape_offset_index(nuint vertex) + { + return Api.ufbx_get_blend_shape_offset_index( + (ufbx_blend_shape*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + vertex); + } + + // From: ufbx_get_blend_shape_vertex_offset(ufbx_blend_shape*, nuint) + public Misaki.HighPerformance.Mathematics.float3 get_blend_shape_vertex_offset(nuint vertex) + { + return Api.ufbx_get_blend_shape_vertex_offset( + (ufbx_blend_shape*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + vertex); + } + + // From: ufbx_add_blend_shape_vertex_offsets(ufbx_blend_shape*, Misaki.HighPerformance.Mathematics.float3*, nuint, float) + public void add_blend_shape_vertex_offsets(Misaki.HighPerformance.Mathematics.float3* vertices, nuint num_vertices, float weight) + { + Api.ufbx_add_blend_shape_vertex_offsets( + (ufbx_blend_shape*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + vertices, + num_vertices, + weight); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_cache_channel.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_cache_channel.nativegen.cs new file mode 100644 index 0000000..e86fb51 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_cache_channel.nativegen.cs @@ -0,0 +1,32 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_cache_channel +{ + // From: ufbx_sample_geometry_cache_real(ufbx_cache_channel*, double, float*, nuint, ufbx_geometry_cache_data_opts*) + public nuint sample_geometry_cache_real(double time, float* data, nuint num_data, ufbx_geometry_cache_data_opts* opts) + { + return Api.ufbx_sample_geometry_cache_real( + (ufbx_cache_channel*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + time, + data, + num_data, + opts); + } + + // From: ufbx_sample_geometry_cache_vec3(ufbx_cache_channel*, double, Misaki.HighPerformance.Mathematics.float3*, nuint, ufbx_geometry_cache_data_opts*) + public nuint sample_geometry_cache_vec3(double time, Misaki.HighPerformance.Mathematics.float3* data, nuint num_data, ufbx_geometry_cache_data_opts* opts) + { + return Api.ufbx_sample_geometry_cache_vec3( + (ufbx_cache_channel*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + time, + data, + num_data, + opts); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_cache_frame.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_cache_frame.nativegen.cs new file mode 100644 index 0000000..6480a73 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_cache_frame.nativegen.cs @@ -0,0 +1,30 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_cache_frame +{ + // From: ufbx_read_geometry_cache_real(ufbx_cache_frame*, float*, nuint, ufbx_geometry_cache_data_opts*) + public nuint read_geometry_cache_real(float* data, nuint num_data, ufbx_geometry_cache_data_opts* opts) + { + return Api.ufbx_read_geometry_cache_real( + (ufbx_cache_frame*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + data, + num_data, + opts); + } + + // From: ufbx_read_geometry_cache_vec3(ufbx_cache_frame*, Misaki.HighPerformance.Mathematics.float3*, nuint, ufbx_geometry_cache_data_opts*) + public nuint read_geometry_cache_vec3(Misaki.HighPerformance.Mathematics.float3* data, nuint num_data, ufbx_geometry_cache_data_opts* opts) + { + return Api.ufbx_read_geometry_cache_vec3( + (ufbx_cache_frame*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + data, + num_data, + opts); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_dom_node.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_dom_node.nativegen.cs new file mode 100644 index 0000000..cbd0dc9 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_dom_node.nativegen.cs @@ -0,0 +1,78 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_dom_node +{ + // From: ufbx_dom_find_len(ufbx_dom_node*, sbyte*, nuint) + public ufbx_dom_node* dom_find_len(ReadOnlySpan name) + { + fixed (byte* pname = name) + { + return Api.ufbx_dom_find_len( + (ufbx_dom_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length); + } + } + + // From: ufbx_dom_find(ufbx_dom_node*, sbyte*) + public ufbx_dom_node* dom_find(sbyte* name) + { + return Api.ufbx_dom_find( + (ufbx_dom_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name); + } + + // From: ufbx_dom_is_array(ufbx_dom_node*) + public bool dom_is_array() + { + return Api.ufbx_dom_is_array((ufbx_dom_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_dom_array_size(ufbx_dom_node*) + public nuint dom_array_size() + { + return Api.ufbx_dom_array_size((ufbx_dom_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_dom_as_int32_list(ufbx_dom_node*) + public ufbx_int32_list dom_as_int32_list() + { + return Api.ufbx_dom_as_int32_list((ufbx_dom_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_dom_as_int64_list(ufbx_dom_node*) + public ufbx_int64_list dom_as_int64_list() + { + return Api.ufbx_dom_as_int64_list((ufbx_dom_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_dom_as_float_list(ufbx_dom_node*) + public ufbx_float_list dom_as_float_list() + { + return Api.ufbx_dom_as_float_list((ufbx_dom_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_dom_as_double_list(ufbx_dom_node*) + public ufbx_double_list dom_as_double_list() + { + return Api.ufbx_dom_as_double_list((ufbx_dom_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_dom_as_real_list(ufbx_dom_node*) + public ufbx_real_list dom_as_real_list() + { + return Api.ufbx_dom_as_real_list((ufbx_dom_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_dom_as_blob_list(ufbx_dom_node*) + public ufbx_blob_list dom_as_blob_list() + { + return Api.ufbx_dom_as_blob_list((ufbx_dom_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_element.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_element.nativegen.cs new file mode 100644 index 0000000..e9071bf --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_element.nativegen.cs @@ -0,0 +1,293 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_element +{ + // From: ufbx_get_prop_element(ufbx_element*, ufbx_prop*, ufbx_element_type) + public ufbx_element* get_prop(ufbx_prop* prop, ufbx_element_type type) + { + return Api.ufbx_get_prop_element( + (ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + prop, + type); + } + + // From: ufbx_find_prop_element_len(ufbx_element*, sbyte*, nuint, ufbx_element_type) + public ufbx_element* find_prop_element_len(ReadOnlySpan name, ufbx_element_type type) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_prop_element_len( + (ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length, + type); + } + } + + // From: ufbx_find_prop_element(ufbx_element*, sbyte*, ufbx_element_type) + public ufbx_element* find_prop(sbyte* name, ufbx_element_type type) + { + return Api.ufbx_find_prop_element( + (ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name, + type); + } + + // From: ufbx_as_unknown(ufbx_element*) + public ufbx_unknown* as_unknown() + { + return Api.ufbx_as_unknown((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_node(ufbx_element*) + public ufbx_node* as_node() + { + return Api.ufbx_as_node((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_mesh(ufbx_element*) + public ufbx_mesh* as_mesh() + { + return Api.ufbx_as_mesh((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_light(ufbx_element*) + public ufbx_light* as_light() + { + return Api.ufbx_as_light((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_camera(ufbx_element*) + public ufbx_camera* as_camera() + { + return Api.ufbx_as_camera((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_bone(ufbx_element*) + public ufbx_bone* as_bone() + { + return Api.ufbx_as_bone((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_empty(ufbx_element*) + public ufbx_empty* as_empty() + { + return Api.ufbx_as_empty((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_line_curve(ufbx_element*) + public ufbx_line_curve* as_line_curve() + { + return Api.ufbx_as_line_curve((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_nurbs_curve(ufbx_element*) + public ufbx_nurbs_curve* as_nurbs_curve() + { + return Api.ufbx_as_nurbs_curve((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_nurbs_surface(ufbx_element*) + public ufbx_nurbs_surface* as_nurbs_surface() + { + return Api.ufbx_as_nurbs_surface((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_nurbs_trim_surface(ufbx_element*) + public ufbx_nurbs_trim_surface* as_nurbs_trim_surface() + { + return Api.ufbx_as_nurbs_trim_surface((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_nurbs_trim_boundary(ufbx_element*) + public ufbx_nurbs_trim_boundary* as_nurbs_trim_boundary() + { + return Api.ufbx_as_nurbs_trim_boundary((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_procedural_geometry(ufbx_element*) + public ufbx_procedural_geometry* as_procedural_geometry() + { + return Api.ufbx_as_procedural_geometry((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_stereo_camera(ufbx_element*) + public ufbx_stereo_camera* as_stereo_camera() + { + return Api.ufbx_as_stereo_camera((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_camera_switcher(ufbx_element*) + public ufbx_camera_switcher* as_camera_switcher() + { + return Api.ufbx_as_camera_switcher((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_marker(ufbx_element*) + public ufbx_marker* as_marker() + { + return Api.ufbx_as_marker((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_lod_group(ufbx_element*) + public ufbx_lod_group* as_lod_group() + { + return Api.ufbx_as_lod_group((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_skin_deformer(ufbx_element*) + public ufbx_skin_deformer* as_skin_deformer() + { + return Api.ufbx_as_skin_deformer((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_skin_cluster(ufbx_element*) + public ufbx_skin_cluster* as_skin_cluster() + { + return Api.ufbx_as_skin_cluster((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_blend_deformer(ufbx_element*) + public ufbx_blend_deformer* as_blend_deformer() + { + return Api.ufbx_as_blend_deformer((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_blend_channel(ufbx_element*) + public ufbx_blend_channel* as_blend_channel() + { + return Api.ufbx_as_blend_channel((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_blend_shape(ufbx_element*) + public ufbx_blend_shape* as_blend_shape() + { + return Api.ufbx_as_blend_shape((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_cache_deformer(ufbx_element*) + public ufbx_cache_deformer* as_cache_deformer() + { + return Api.ufbx_as_cache_deformer((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_cache_file(ufbx_element*) + public ufbx_cache_file* as_cache_file() + { + return Api.ufbx_as_cache_file((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_material(ufbx_element*) + public ufbx_material* as_material() + { + return Api.ufbx_as_material((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_texture(ufbx_element*) + public ufbx_texture* as_texture() + { + return Api.ufbx_as_texture((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_video(ufbx_element*) + public ufbx_video* as_video() + { + return Api.ufbx_as_video((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_shader(ufbx_element*) + public ufbx_shader* as_shader() + { + return Api.ufbx_as_shader((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_shader_binding(ufbx_element*) + public ufbx_shader_binding* as_shader_binding() + { + return Api.ufbx_as_shader_binding((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_anim_stack(ufbx_element*) + public ufbx_anim_stack* as_anim_stack() + { + return Api.ufbx_as_anim_stack((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_anim_layer(ufbx_element*) + public ufbx_anim_layer* as_anim_layer() + { + return Api.ufbx_as_anim_layer((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_anim_value(ufbx_element*) + public ufbx_anim_value* as_anim_value() + { + return Api.ufbx_as_anim_value((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_anim_curve(ufbx_element*) + public ufbx_anim_curve* as_anim_curve() + { + return Api.ufbx_as_anim_curve((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_display_layer(ufbx_element*) + public ufbx_display_layer* as_display_layer() + { + return Api.ufbx_as_display_layer((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_selection_set(ufbx_element*) + public ufbx_selection_set* as_selection_set() + { + return Api.ufbx_as_selection_set((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_selection_node(ufbx_element*) + public ufbx_selection_node* as_selection_node() + { + return Api.ufbx_as_selection_node((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_character(ufbx_element*) + public ufbx_character* as_character() + { + return Api.ufbx_as_character((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_constraint(ufbx_element*) + public ufbx_constraint* as_constraint() + { + return Api.ufbx_as_constraint((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_audio_layer(ufbx_element*) + public ufbx_audio_layer* as_audio_layer() + { + return Api.ufbx_as_audio_layer((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_audio_clip(ufbx_element*) + public ufbx_audio_clip* as_audio_clip() + { + return Api.ufbx_as_audio_clip((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_pose(ufbx_element*) + public ufbx_pose* as_pose() + { + return Api.ufbx_as_pose((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_as_metadata_object(ufbx_element*) + public ufbx_metadata_object* as_metadata_object() + { + return Api.ufbx_as_metadata_object((ufbx_element*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_geometry_cache.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_geometry_cache.nativegen.cs new file mode 100644 index 0000000..6daedbb --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_geometry_cache.nativegen.cs @@ -0,0 +1,44 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_geometry_cache +{ + // From: ufbx_load_geometry_cache(sbyte*, ufbx_geometry_cache_opts*, ufbx_error*) + public static ufbx_geometry_cache* load(sbyte* filename, ufbx_geometry_cache_opts* opts, ufbx_error* error) + { + return Api.ufbx_load_geometry_cache( + filename, + opts, + error); + } + + // From: ufbx_load_geometry_cache_len(sbyte*, nuint, ufbx_geometry_cache_opts*, ufbx_error*) + public static ufbx_geometry_cache* load_geometry_cache_len(ReadOnlySpan filename, ufbx_geometry_cache_opts* opts, ufbx_error* error) + { + fixed (byte* pfilename = filename) + { + return Api.ufbx_load_geometry_cache_len( + (sbyte*)pfilename, + (nuint)filename.Length, + opts, + error); + } + } + + // From: ufbx_free_geometry_cache(ufbx_geometry_cache*) + public void free() + { + Api.ufbx_free_geometry_cache((ufbx_geometry_cache*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_retain_geometry_cache(ufbx_geometry_cache*) + public void retain() + { + Api.ufbx_retain_geometry_cache((ufbx_geometry_cache*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_line_curve.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_line_curve.nativegen.cs new file mode 100644 index 0000000..a9cb5c3 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_line_curve.nativegen.cs @@ -0,0 +1,22 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_line_curve +{ + // From: ufbx_free_line_curve(ufbx_line_curve*) + public void free() + { + Api.ufbx_free_line_curve((ufbx_line_curve*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_retain_line_curve(ufbx_line_curve*) + public void retain() + { + Api.ufbx_retain_line_curve((ufbx_line_curve*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_material.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_material.nativegen.cs new file mode 100644 index 0000000..f459371 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_material.nativegen.cs @@ -0,0 +1,30 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_material +{ + // From: ufbx_find_prop_texture_len(ufbx_material*, sbyte*, nuint) + public ufbx_texture* find_prop_texture_len(ReadOnlySpan name) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_prop_texture_len( + (ufbx_material*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length); + } + } + + // From: ufbx_find_prop_texture(ufbx_material*, sbyte*) + public ufbx_texture* find_prop_texture(sbyte* name) + { + return Api.ufbx_find_prop_texture( + (ufbx_material*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_mesh.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_mesh.nativegen.cs new file mode 100644 index 0000000..b27cc35 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_mesh.nativegen.cs @@ -0,0 +1,73 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_mesh +{ + // From: ufbx_find_face_index(ufbx_mesh*, nuint) + public uint find_face_index(nuint index) + { + return Api.ufbx_find_face_index( + (ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + index); + } + + // From: ufbx_compute_topology(ufbx_mesh*, ufbx_topo_edge*, nuint) + public void compute_topology(ufbx_topo_edge* topo, nuint num_topo) + { + Api.ufbx_compute_topology( + (ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + topo, + num_topo); + } + + // From: ufbx_generate_normal_mapping(ufbx_mesh*, ufbx_topo_edge*, nuint, uint*, nuint, bool) + public nuint generate_normal_mapping(ufbx_topo_edge* topo, nuint num_topo, uint* normal_indices, nuint num_normal_indices, bool assume_smooth) + { + return Api.ufbx_generate_normal_mapping( + (ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + topo, + num_topo, + normal_indices, + num_normal_indices, + assume_smooth); + } + + // From: ufbx_compute_normals(ufbx_mesh*, ufbx_vertex_vec3*, uint*, nuint, Misaki.HighPerformance.Mathematics.float3*, nuint) + public void compute_normals(ufbx_vertex_vec3* positions, uint* normal_indices, nuint num_normal_indices, Misaki.HighPerformance.Mathematics.float3* normals, nuint num_normals) + { + Api.ufbx_compute_normals( + (ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + positions, + normal_indices, + num_normal_indices, + normals, + num_normals); + } + + // From: ufbx_subdivide_mesh(ufbx_mesh*, nuint, ufbx_subdivide_opts*, ufbx_error*) + public ufbx_mesh* subdivide(nuint level, ufbx_subdivide_opts* opts, ufbx_error* error) + { + return Api.ufbx_subdivide_mesh( + (ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + level, + opts, + error); + } + + // From: ufbx_free_mesh(ufbx_mesh*) + public void free() + { + Api.ufbx_free_mesh((ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_retain_mesh(ufbx_mesh*) + public void retain() + { + Api.ufbx_retain_mesh((ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_node.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_node.nativegen.cs new file mode 100644 index 0000000..170e759 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_node.nativegen.cs @@ -0,0 +1,16 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_node +{ + // From: ufbx_get_compatible_matrix_for_normals(ufbx_node*) + public Misaki.HighPerformance.Mathematics.float3x4 get_compatible_matrix_for_normals() + { + return Api.ufbx_get_compatible_matrix_for_normals((ufbx_node*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_nurbs_basis.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_nurbs_basis.nativegen.cs new file mode 100644 index 0000000..7175618 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_nurbs_basis.nativegen.cs @@ -0,0 +1,22 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_nurbs_basis +{ + // From: ufbx_evaluate_nurbs_basis(ufbx_nurbs_basis*, float, float*, nuint, float*, nuint) + public nuint evaluate(float u, float* weights, nuint num_weights, float* derivatives, nuint num_derivatives) + { + return Api.ufbx_evaluate_nurbs_basis( + (ufbx_nurbs_basis*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + u, + weights, + num_weights, + derivatives, + num_derivatives); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_nurbs_curve.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_nurbs_curve.nativegen.cs new file mode 100644 index 0000000..0efd600 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_nurbs_curve.nativegen.cs @@ -0,0 +1,27 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_nurbs_curve +{ + // From: ufbx_evaluate_nurbs_curve(ufbx_nurbs_curve*, float) + public ufbx_curve_point evaluate(float u) + { + return Api.ufbx_evaluate_nurbs_curve( + (ufbx_nurbs_curve*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + u); + } + + // From: ufbx_tessellate_nurbs_curve(ufbx_nurbs_curve*, ufbx_tessellate_curve_opts*, ufbx_error*) + public ufbx_line_curve* tessellate(ufbx_tessellate_curve_opts* opts, ufbx_error* error) + { + return Api.ufbx_tessellate_nurbs_curve( + (ufbx_nurbs_curve*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + opts, + error); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_nurbs_surface.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_nurbs_surface.nativegen.cs new file mode 100644 index 0000000..daa8621 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_nurbs_surface.nativegen.cs @@ -0,0 +1,28 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_nurbs_surface +{ + // From: ufbx_evaluate_nurbs_surface(ufbx_nurbs_surface*, float, float) + public ufbx_surface_point evaluate(float u, float v) + { + return Api.ufbx_evaluate_nurbs_surface( + (ufbx_nurbs_surface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + u, + v); + } + + // From: ufbx_tessellate_nurbs_surface(ufbx_nurbs_surface*, ufbx_tessellate_surface_opts*, ufbx_error*) + public ufbx_mesh* tessellate(ufbx_tessellate_surface_opts* opts, ufbx_error* error) + { + return Api.ufbx_tessellate_nurbs_surface( + (ufbx_nurbs_surface*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + opts, + error); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_panic.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_panic.nativegen.cs new file mode 100644 index 0000000..32ff4a8 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_panic.nativegen.cs @@ -0,0 +1,141 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_panic +{ + // From: ufbx_catch_get_skin_vertex_matrix(ufbx_panic*, ufbx_skin_deformer*, nuint, Misaki.HighPerformance.Mathematics.float3x4*) + public Misaki.HighPerformance.Mathematics.float3x4 catch_get_skin_vertex_matrix(ufbx_skin_deformer* skin, nuint vertex, Misaki.HighPerformance.Mathematics.float3x4* fallback) + { + return Api.ufbx_catch_get_skin_vertex_matrix( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + skin, + vertex, + fallback); + } + + // From: ufbx_catch_triangulate_face(ufbx_panic*, uint*, nuint, ufbx_mesh*, ufbx_face) + public uint catch_triangulate_face(uint* indices, nuint num_indices, ufbx_mesh* mesh, ufbx_face face) + { + return Api.ufbx_catch_triangulate_face( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + indices, + num_indices, + mesh, + face); + } + + // From: ufbx_catch_compute_topology(ufbx_panic*, ufbx_mesh*, ufbx_topo_edge*, nuint) + public void catch_compute_topology(ufbx_mesh* mesh, ufbx_topo_edge* topo, nuint num_topo) + { + Api.ufbx_catch_compute_topology( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + mesh, + topo, + num_topo); + } + + // From: ufbx_catch_topo_next_vertex_edge(ufbx_panic*, ufbx_topo_edge*, nuint, uint) + public uint catch_topo_next_vertex_edge(ufbx_topo_edge* topo, nuint num_topo, uint index) + { + return Api.ufbx_catch_topo_next_vertex_edge( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + topo, + num_topo, + index); + } + + // From: ufbx_catch_topo_prev_vertex_edge(ufbx_panic*, ufbx_topo_edge*, nuint, uint) + public uint catch_topo_prev_vertex_edge(ufbx_topo_edge* topo, nuint num_topo, uint index) + { + return Api.ufbx_catch_topo_prev_vertex_edge( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + topo, + num_topo, + index); + } + + // From: ufbx_catch_get_weighted_face_normal(ufbx_panic*, ufbx_vertex_vec3*, ufbx_face) + public Misaki.HighPerformance.Mathematics.float3 catch_get_weighted_face_normal(ufbx_vertex_vec3* positions, ufbx_face face) + { + return Api.ufbx_catch_get_weighted_face_normal( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + positions, + face); + } + + // From: ufbx_catch_generate_normal_mapping(ufbx_panic*, ufbx_mesh*, ufbx_topo_edge*, nuint, uint*, nuint, bool) + public nuint catch_generate_normal_mapping(ufbx_mesh* mesh, ufbx_topo_edge* topo, nuint num_topo, uint* normal_indices, nuint num_normal_indices, bool assume_smooth) + { + return Api.ufbx_catch_generate_normal_mapping( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + mesh, + topo, + num_topo, + normal_indices, + num_normal_indices, + assume_smooth); + } + + // From: ufbx_catch_compute_normals(ufbx_panic*, ufbx_mesh*, ufbx_vertex_vec3*, uint*, nuint, Misaki.HighPerformance.Mathematics.float3*, nuint) + public void catch_compute_normals(ufbx_mesh* mesh, ufbx_vertex_vec3* positions, uint* normal_indices, nuint num_normal_indices, Misaki.HighPerformance.Mathematics.float3* normals, nuint num_normals) + { + Api.ufbx_catch_compute_normals( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + mesh, + positions, + normal_indices, + num_normal_indices, + normals, + num_normals); + } + + // From: ufbx_catch_get_vertex_real(ufbx_panic*, ufbx_vertex_real*, nuint) + public float catch_get_vertex_real(ufbx_vertex_real* v, nuint index) + { + return Api.ufbx_catch_get_vertex_real( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + v, + index); + } + + // From: ufbx_catch_get_vertex_vec2(ufbx_panic*, ufbx_vertex_vec2*, nuint) + public Misaki.HighPerformance.Mathematics.float2 catch_get_vertex_vec2(ufbx_vertex_vec2* v, nuint index) + { + return Api.ufbx_catch_get_vertex_vec2( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + v, + index); + } + + // From: ufbx_catch_get_vertex_vec3(ufbx_panic*, ufbx_vertex_vec3*, nuint) + public Misaki.HighPerformance.Mathematics.float3 catch_get_vertex_vec3(ufbx_vertex_vec3* v, nuint index) + { + return Api.ufbx_catch_get_vertex_vec3( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + v, + index); + } + + // From: ufbx_catch_get_vertex_vec4(ufbx_panic*, ufbx_vertex_vec4*, nuint) + public Misaki.HighPerformance.Mathematics.float4 catch_get_vertex_vec4(ufbx_vertex_vec4* v, nuint index) + { + return Api.ufbx_catch_get_vertex_vec4( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + v, + index); + } + + // From: ufbx_catch_get_vertex_w_vec3(ufbx_panic*, ufbx_vertex_vec3*, nuint) + public float catch_get_vertex_w_vec3(ufbx_vertex_vec3* v, nuint index) + { + return Api.ufbx_catch_get_vertex_w_vec3( + (ufbx_panic*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + v, + index); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_pose.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_pose.nativegen.cs new file mode 100644 index 0000000..bf1cb67 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_pose.nativegen.cs @@ -0,0 +1,18 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_pose +{ + // From: ufbx_get_bone_pose(ufbx_pose*, ufbx_node*) + public ufbx_bone_pose* get_bone(ufbx_node* node) + { + return Api.ufbx_get_bone_pose( + (ufbx_pose*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + node); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_props.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_props.nativegen.cs new file mode 100644 index 0000000..e315edf --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_props.nativegen.cs @@ -0,0 +1,171 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_props +{ + // From: ufbx_find_prop_len(ufbx_props*, sbyte*, nuint) + public ufbx_prop* find_prop_len(ReadOnlySpan name) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_prop_len( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length); + } + } + + // From: ufbx_find_prop(ufbx_props*, sbyte*) + public ufbx_prop* find_prop(sbyte* name) + { + return Api.ufbx_find_prop( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name); + } + + // From: ufbx_find_real_len(ufbx_props*, sbyte*, nuint, float) + public float find_real_len(ReadOnlySpan name, float def) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_real_len( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length, + def); + } + } + + // From: ufbx_find_real(ufbx_props*, sbyte*, float) + public float find_real(sbyte* name, float def) + { + return Api.ufbx_find_real( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name, + def); + } + + // From: ufbx_find_vec3_len(ufbx_props*, sbyte*, nuint, Misaki.HighPerformance.Mathematics.float3) + public Misaki.HighPerformance.Mathematics.float3 find_vec3_len(ReadOnlySpan name, Misaki.HighPerformance.Mathematics.float3 def) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_vec3_len( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length, + def); + } + } + + // From: ufbx_find_vec3(ufbx_props*, sbyte*, Misaki.HighPerformance.Mathematics.float3) + public Misaki.HighPerformance.Mathematics.float3 find_vec3(sbyte* name, Misaki.HighPerformance.Mathematics.float3 def) + { + return Api.ufbx_find_vec3( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name, + def); + } + + // From: ufbx_find_int_len(ufbx_props*, sbyte*, nuint, long) + public long find_int_len(ReadOnlySpan name, long def) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_int_len( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length, + def); + } + } + + // From: ufbx_find_int(ufbx_props*, sbyte*, long) + public long find_int(sbyte* name, long def) + { + return Api.ufbx_find_int( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name, + def); + } + + // From: ufbx_find_bool_len(ufbx_props*, sbyte*, nuint, bool) + public bool find_bool_len(ReadOnlySpan name, bool def) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_bool_len( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length, + def); + } + } + + // From: ufbx_find_bool(ufbx_props*, sbyte*, bool) + public bool find_bool(sbyte* name, bool def) + { + return Api.ufbx_find_bool( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name, + def); + } + + // From: ufbx_find_string_len(ufbx_props*, sbyte*, nuint, ufbx_string) + public ufbx_string find_string_len(ReadOnlySpan name, ufbx_string def) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_string_len( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length, + def); + } + } + + // From: ufbx_find_string(ufbx_props*, sbyte*, ufbx_string) + public ufbx_string find_string(sbyte* name, ufbx_string def) + { + return Api.ufbx_find_string( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name, + def); + } + + // From: ufbx_find_blob_len(ufbx_props*, sbyte*, nuint, ufbx_blob) + public ufbx_blob find_blob_len(ReadOnlySpan name, ufbx_blob def) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_blob_len( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length, + def); + } + } + + // From: ufbx_find_blob(ufbx_props*, sbyte*, ufbx_blob) + public ufbx_blob find_blob(sbyte* name, ufbx_blob def) + { + return Api.ufbx_find_blob( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name, + def); + } + + // From: ufbx_find_prop_concat(ufbx_props*, ufbx_string*, nuint) + public ufbx_prop* find_prop_concat(ufbx_string* parts, nuint num_parts) + { + return Api.ufbx_find_prop_concat( + (ufbx_props*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + parts, + num_parts); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_scene.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_scene.nativegen.cs new file mode 100644 index 0000000..dea5b2d --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_scene.nativegen.cs @@ -0,0 +1,186 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_scene +{ + // From: ufbx_load_memory(void*, nuint, ufbx_load_opts*, ufbx_error*) + public static ufbx_scene* load_memory(void* data, nuint data_size, ufbx_load_opts* opts, ufbx_error* error) + { + return Api.ufbx_load_memory( + data, + data_size, + opts, + error); + } + + // From: ufbx_load_file(sbyte*, ufbx_load_opts*, ufbx_error*) + public static ufbx_scene* load_file(sbyte* filename, ufbx_load_opts* opts, ufbx_error* error) + { + return Api.ufbx_load_file( + filename, + opts, + error); + } + + // From: ufbx_load_file_len(sbyte*, nuint, ufbx_load_opts*, ufbx_error*) + public static ufbx_scene* load_file_len(ReadOnlySpan filename, ufbx_load_opts* opts, ufbx_error* error) + { + fixed (byte* pfilename = filename) + { + return Api.ufbx_load_file_len( + (sbyte*)pfilename, + (nuint)filename.Length, + opts, + error); + } + } + + // From: ufbx_load_stdio(void*, ufbx_load_opts*, ufbx_error*) + public static ufbx_scene* load_stdio(void* file, ufbx_load_opts* opts, ufbx_error* error) + { + return Api.ufbx_load_stdio( + file, + opts, + error); + } + + // From: ufbx_load_stdio_prefix(void*, void*, nuint, ufbx_load_opts*, ufbx_error*) + public static ufbx_scene* load_stdio_prefix(void* file, void* prefix, nuint prefix_size, ufbx_load_opts* opts, ufbx_error* error) + { + return Api.ufbx_load_stdio_prefix( + file, + prefix, + prefix_size, + opts, + error); + } + + // From: ufbx_free_scene(ufbx_scene*) + public void free() + { + Api.ufbx_free_scene((ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_retain_scene(ufbx_scene*) + public void retain() + { + Api.ufbx_retain_scene((ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } + + // From: ufbx_find_element_len(ufbx_scene*, ufbx_element_type, sbyte*, nuint) + public ufbx_element* find_element_len(ufbx_element_type type, ReadOnlySpan name) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_element_len( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + type, + (sbyte*)pname, + (nuint)name.Length); + } + } + + // From: ufbx_find_element(ufbx_scene*, ufbx_element_type, sbyte*) + public ufbx_element* find_element(ufbx_element_type type, sbyte* name) + { + return Api.ufbx_find_element( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + type, + name); + } + + // From: ufbx_find_node_len(ufbx_scene*, sbyte*, nuint) + public ufbx_node* find_node_len(ReadOnlySpan name) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_node_len( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length); + } + } + + // From: ufbx_find_node(ufbx_scene*, sbyte*) + public ufbx_node* find_node(sbyte* name) + { + return Api.ufbx_find_node( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name); + } + + // From: ufbx_find_anim_stack_len(ufbx_scene*, sbyte*, nuint) + public ufbx_anim_stack* find_anim_stack_len(ReadOnlySpan name) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_anim_stack_len( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length); + } + } + + // From: ufbx_find_anim_stack(ufbx_scene*, sbyte*) + public ufbx_anim_stack* find_anim_stack(sbyte* name) + { + return Api.ufbx_find_anim_stack( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name); + } + + // From: ufbx_find_material_len(ufbx_scene*, sbyte*, nuint) + public ufbx_material* find_material_len(ReadOnlySpan name) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_material_len( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length); + } + } + + // From: ufbx_find_material(ufbx_scene*, sbyte*) + public ufbx_material* find_material(sbyte* name) + { + return Api.ufbx_find_material( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name); + } + + // From: ufbx_evaluate_scene(ufbx_scene*, ufbx_anim*, double, ufbx_evaluate_opts*, ufbx_error*) + public ufbx_scene* evaluate(ufbx_anim* anim, double time, ufbx_evaluate_opts* opts, ufbx_error* error) + { + return Api.ufbx_evaluate_scene( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + anim, + time, + opts, + error); + } + + // From: ufbx_create_anim(ufbx_scene*, ufbx_anim_opts*, ufbx_error*) + public ufbx_anim* create_anim(ufbx_anim_opts* opts, ufbx_error* error) + { + return Api.ufbx_create_anim( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + opts, + error); + } + + // From: ufbx_bake_anim(ufbx_scene*, ufbx_anim*, ufbx_bake_opts*, ufbx_error*) + public ufbx_baked_anim* bake_anim(ufbx_anim* anim, ufbx_bake_opts* opts, ufbx_error* error) + { + return Api.ufbx_bake_anim( + (ufbx_scene*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + anim, + opts, + error); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_shader.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_shader.nativegen.cs new file mode 100644 index 0000000..63e1e4d --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_shader.nativegen.cs @@ -0,0 +1,50 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_shader +{ + // From: ufbx_find_shader_prop_len(ufbx_shader*, sbyte*, nuint) + public ufbx_string find_shader_prop_len(ReadOnlySpan name) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_shader_prop_len( + (ufbx_shader*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length); + } + } + + // From: ufbx_find_shader_prop(ufbx_shader*, sbyte*) + public ufbx_string find_shader_prop(sbyte* name) + { + return Api.ufbx_find_shader_prop( + (ufbx_shader*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name); + } + + // From: ufbx_find_shader_prop_bindings_len(ufbx_shader*, sbyte*, nuint) + public ufbx_shader_prop_binding_list find_shader_prop_bindings_len(ReadOnlySpan name) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_shader_prop_bindings_len( + (ufbx_shader*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length); + } + } + + // From: ufbx_find_shader_prop_bindings(ufbx_shader*, sbyte*) + public ufbx_shader_prop_binding_list find_shader_prop_bindings(sbyte* name) + { + return Api.ufbx_find_shader_prop_bindings( + (ufbx_shader*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_shader_texture.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_shader_texture.nativegen.cs new file mode 100644 index 0000000..c85ce2d --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_shader_texture.nativegen.cs @@ -0,0 +1,30 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_shader_texture +{ + // From: ufbx_find_shader_texture_input_len(ufbx_shader_texture*, sbyte*, nuint) + public ufbx_shader_texture_input* find_shader_texture_input_len(ReadOnlySpan name) + { + fixed (byte* pname = name) + { + return Api.ufbx_find_shader_texture_input_len( + (ufbx_shader_texture*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)pname, + (nuint)name.Length); + } + } + + // From: ufbx_find_shader_texture_input(ufbx_shader_texture*, sbyte*) + public ufbx_shader_texture_input* find_shader_texture_input(sbyte* name) + { + return Api.ufbx_find_shader_texture_input( + (ufbx_shader_texture*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + name); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_stream.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_stream.nativegen.cs new file mode 100644 index 0000000..a2c9a2f --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_stream.nativegen.cs @@ -0,0 +1,82 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_stream +{ + // From: ufbx_load_stream(ufbx_stream*, ufbx_load_opts*, ufbx_error*) + public ufbx_scene* load(ufbx_load_opts* opts, ufbx_error* error) + { + return Api.ufbx_load_stream( + (ufbx_stream*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + opts, + error); + } + + // From: ufbx_load_stream_prefix(ufbx_stream*, void*, nuint, ufbx_load_opts*, ufbx_error*) + public ufbx_scene* load_stream_prefix(void* prefix, nuint prefix_size, ufbx_load_opts* opts, ufbx_error* error) + { + return Api.ufbx_load_stream_prefix( + (ufbx_stream*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + prefix, + prefix_size, + opts, + error); + } + + // From: ufbx_open_file(ufbx_stream*, sbyte*, nuint, ufbx_open_file_opts*, ufbx_error*) + public bool open_file(ReadOnlySpan path, ufbx_open_file_opts* opts, ufbx_error* error) + { + fixed (byte* ppath = path) + { + return Api.ufbx_open_file( + (ufbx_stream*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + (sbyte*)ppath, + (nuint)path.Length, + opts, + error); + } + } + + // From: ufbx_open_file_ctx(ufbx_stream*, nuint, sbyte*, nuint, ufbx_open_file_opts*, ufbx_error*) + public bool open_file_ctx(nuint ctx, ReadOnlySpan path, ufbx_open_file_opts* opts, ufbx_error* error) + { + fixed (byte* ppath = path) + { + return Api.ufbx_open_file_ctx( + (ufbx_stream*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + ctx, + (sbyte*)ppath, + (nuint)path.Length, + opts, + error); + } + } + + // From: ufbx_open_memory(ufbx_stream*, void*, nuint, ufbx_open_memory_opts*, ufbx_error*) + public bool open_memory(void* data, nuint data_size, ufbx_open_memory_opts* opts, ufbx_error* error) + { + return Api.ufbx_open_memory( + (ufbx_stream*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + data, + data_size, + opts, + error); + } + + // From: ufbx_open_memory_ctx(ufbx_stream*, nuint, void*, nuint, ufbx_open_memory_opts*, ufbx_error*) + public bool open_memory_ctx(nuint ctx, void* data, nuint data_size, ufbx_open_memory_opts* opts, ufbx_error* error) + { + return Api.ufbx_open_memory_ctx( + (ufbx_stream*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + ctx, + data, + data_size, + opts, + error); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_topo_edge.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_topo_edge.nativegen.cs new file mode 100644 index 0000000..34c2296 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_topo_edge.nativegen.cs @@ -0,0 +1,28 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_topo_edge +{ + // From: ufbx_topo_next_vertex_edge(ufbx_topo_edge*, nuint, uint) + public uint topo_next_vertex_edge(nuint num_topo, uint index) + { + return Api.ufbx_topo_next_vertex_edge( + (ufbx_topo_edge*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + num_topo, + index); + } + + // From: ufbx_topo_prev_vertex_edge(ufbx_topo_edge*, nuint, uint) + public uint topo_prev_vertex_edge(nuint num_topo, uint index) + { + return Api.ufbx_topo_prev_vertex_edge( + (ufbx_topo_edge*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + num_topo, + index); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_transform.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_transform.nativegen.cs new file mode 100644 index 0000000..628f368 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_transform.nativegen.cs @@ -0,0 +1,16 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_transform +{ + // From: ufbx_transform_to_matrix(ufbx_transform*) + public Misaki.HighPerformance.Mathematics.float3x4 to_matrix() + { + return Api.ufbx_transform_to_matrix((ufbx_transform*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_vertex_stream.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_vertex_stream.nativegen.cs new file mode 100644 index 0000000..2384a3b --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_vertex_stream.nativegen.cs @@ -0,0 +1,22 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_vertex_stream +{ + // From: ufbx_generate_indices(ufbx_vertex_stream*, nuint, uint*, nuint, ufbx_allocator_opts*, ufbx_error*) + public nuint generate_indices(nuint num_streams, uint* indices, nuint num_indices, ufbx_allocator_opts* allocator, ufbx_error* error) + { + return Api.ufbx_generate_indices( + (ufbx_vertex_stream*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + num_streams, + indices, + num_indices, + allocator, + error); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_vertex_vec3.nativegen.cs b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_vertex_vec3.nativegen.cs new file mode 100644 index 0000000..01c7b29 --- /dev/null +++ b/src/ThridParty/Ghost.Ufbx/Wrapper/ufbx_vertex_vec3.nativegen.cs @@ -0,0 +1,18 @@ +// +// This file is generated by Ghost.NativeWrapperGen. Do not edit manually. +// + +using System.Runtime.CompilerServices; + +namespace Ghost.Ufbx; + +public unsafe partial struct ufbx_vertex_vec3 +{ + // From: ufbx_get_weighted_face_normal(ufbx_vertex_vec3*, ufbx_face) + public Misaki.HighPerformance.Mathematics.float3 get_weighted_face_normal(ufbx_face face) + { + return Api.ufbx_get_weighted_face_normal( + (ufbx_vertex_vec3*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this), + face); + } +} diff --git a/src/ThridParty/Ghost.Ufbx/cstring.cs b/src/ThridParty/Ghost.Ufbx/cstring.cs deleted file mode 100644 index 5706491..0000000 --- a/src/ThridParty/Ghost.Ufbx/cstring.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System.Runtime.InteropServices; -using System.Text; - -namespace Ghost.Ufbx; - -public unsafe struct cstring : IDisposable, IEquatable -{ - public byte* ptr; - public int length; - - public cstring(byte* ptr, nuint length) - { - if (length == 0) - { - return; - } - - this.ptr = (byte*)NativeMemory.Alloc(length); - this.length = (int)length; - } - - public cstring(ReadOnlySpan str) - { - if (str.Length == 0) - { - return; - } - - length = Encoding.UTF8.GetByteCount(str); - ptr = (byte*)NativeMemory.Alloc((nuint)length); - fixed (char* p = str) - { - Encoding.UTF8.GetBytes(p, str.Length, ptr, length); - } - } - - public cstring(ReadOnlySpan str) - { - if (str.Length == 0) - { - return; - } - - length = str.Length; - ptr = (byte*)NativeMemory.Alloc((nuint)length); - fixed (byte* p = str) - { - NativeMemory.Copy(p, ptr, (nuint)length); - } - } - - public cstring(cstring other) - { - if (other.length == 0) - { - return; - } - - length = other.length; - ptr = (byte*)NativeMemory.Alloc((nuint)length); - NativeMemory.Copy(other.ptr, ptr, (nuint)length); - } - - public void Dispose() - { - if (ptr != null) - { - NativeMemory.Free(ptr); - } - - ptr = null; - length = 0; - } - - public readonly bool Equals(cstring other) - { - return length == other.length && ptr == other.ptr; - } - - public override bool Equals(object? obj) - { - return obj is cstring cstring && Equals(cstring); - } - - public override readonly int GetHashCode() - { - return HashCode.Combine((nint)ptr, length); - } - - public override readonly string ToString() - { - return Encoding.UTF8.GetString(ptr, length); - } - - public static bool operator ==(cstring left, cstring right) - { - return left.Equals(right); - } - - public static bool operator !=(cstring left, cstring right) - { - return !(left == right); - } -} diff --git a/src/ThridParty/Ghost.Ufbx/ufbx_string.cs b/src/ThridParty/Ghost.Ufbx/ufbx_string.cs index 2df28fb..18494e7 100644 --- a/src/ThridParty/Ghost.Ufbx/ufbx_string.cs +++ b/src/ThridParty/Ghost.Ufbx/ufbx_string.cs @@ -1,5 +1,3 @@ -using System.Text; - namespace Ghost.Ufbx; public unsafe partial struct ufbx_string @@ -7,15 +5,22 @@ public unsafe partial struct ufbx_string public readonly ReadOnlySpan AsSpan() { if (data == null || length == 0) + { return ReadOnlySpan.Empty; + } + return new ReadOnlySpan((byte*)data, checked((int)length)); } - public static implicit operator ReadOnlySpan(ufbx_string s) => s.AsSpan(); - public override readonly string ToString() { - var span = AsSpan(); - return span.IsEmpty ? string.Empty : Encoding.UTF8.GetString(span); + if (data == null || length == 0) + { + return string.Empty; + } + + return new string(data, 0, checked((int)length)); } + + public static implicit operator ReadOnlySpan(ufbx_string s) => s.AsSpan(); } \ No newline at end of file diff --git a/src/Tools/Ghost.NativeWrapperGen/Config/WrapperConfig.cs b/src/Tools/Ghost.NativeWrapperGen/Config/WrapperConfig.cs index d5f6100..b6bc7e7 100644 --- a/src/Tools/Ghost.NativeWrapperGen/Config/WrapperConfig.cs +++ b/src/Tools/Ghost.NativeWrapperGen/Config/WrapperConfig.cs @@ -1,108 +1,149 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Ghost.NativeWrapperGen.Transform; + namespace Ghost.NativeWrapperGen.Config; public sealed class WrapperConfig { public required string LibraryName { get; init; } public required string NativeNamespace { get; init; } - public required string WrapperNamespace { get; init; } + public required string OutputNamespace { get; init; } public required string NativeTypePrefix { get; init; } - public string? StaticApiClassName { get; init; } public List SkipTypes { get; init; } = []; - public Dictionary TypeNameOverrides { get; init; } = new(StringComparer.Ordinal); - public Dictionary PublicTypeOverrides { get; init; } = new(StringComparer.Ordinal); - public WrapperKindsConfig Wrappers { get; init; } = new(); - public SpecialTypesConfig SpecialTypes { get; init; } = new(); - public List OwnedTypes { get; init; } = []; + public List SkipFunctions { get; init; } = []; + public List Remaps { get; init; } = []; + public List Actions { get; init; } = []; +} + +/// +/// Describes how to remap a native type to a C# type at a call site. +/// +public sealed class RemapConfig +{ + /// Native C# type to match (e.g. "sbyte*", "ufbx_string"). + public required string Src { get; init; } + /// C# type to expose in the generated method signature (e.g. "ReadOnlySpan<byte>"). + public required string Dst { get; init; } + /// Which scopes this remap applies to: "parameter" and/or "return". + public List Scope { get; init; } = []; + /// Optional regex patterns applied to parameter names. If specified, only matching params are remapped. + public List? Filter { get; init; } + /// If set, a sibling parameter with this suffix is consumed and replaced by the given expression. + public DerivesFromConfig? DerivesFrom { get; init; } + /// How to convert between src and dst. + public AdapterConfig? Adapter { get; init; } +} + +/// +/// Describes a parameter that is derived from another (e.g. name_len derived from name.Length). +/// +public sealed class DerivesFromConfig +{ + /// The suffix of the sibling parameter name to consume (e.g. "_len"). + public required string ParamSuffix { get; init; } + /// Expression to pass in place of the consumed parameter. $arg is replaced with the source param name. + public required string Expr { get; init; } +} + +/// +/// Adapter: how to convert between src (native) and dst (C#) types. +/// +public sealed class AdapterConfig +{ + /// dst → src conversion: wraps the call site and substitutes the argument. + public ConvertBackConfig? ConvertBack { get; init; } + /// src → dst conversion expression (for return values). $result is replaced with the src expression. + public string? ConvertTo { get; init; } +} + +/// +/// Specifies how to wrap the generated call and what expression to pass for the remapped parameter. +/// Magic variables: $arg = C# parameter name, $CALL = the full Api.xxx(...) call expression. +/// +public sealed class ConvertBackConfig +{ /// - /// Manual overrides for specific functions (adapters, special parameters, etc.). - /// Functions not listed here are auto-routed by the 3-rule dispatch logic. + /// Template that wraps the entire call. Use $arg for the parameter name, $CALL for the call. + /// Example: "fixed (byte* p$arg = $arg) { $CALL }" /// - public List StaticMethods { get; init; } = []; - public List MarshalledTypes { get; init; } = []; - public List PartialTypes { get; init; } = []; + public required string WrapCall { get; init; } /// - /// Native types that are treated as plain value types in wrapper land (not wrapped in a pointer struct). - /// Functions returning or taking these as non-pointer params pass them by value. + /// Expression passed as the native argument. Use $arg for the parameter name. + /// Example: "(sbyte*)p$arg" /// - public List SkipFunctionPrefixes { get; init; } = []; + public required string PassAs { get; init; } } -public sealed class WrapperKindsConfig +/// +/// Routing rule: determines where a function gets emitted and as what kind of method. +/// +public sealed class ActionConfig { - public string DefaultKind { get; init; } = "struct"; - public string DefaultOwnedKind { get; init; } = "class"; - public Dictionary Kinds { get; init; } = new(StringComparer.Ordinal); -} - -public sealed class SpecialTypesConfig -{ - public List Strings { get; init; } = []; - public List Blobs { get; init; } = []; -} - -public sealed class StringTypeConfig -{ - public required string Type { get; init; } - public string DataField { get; init; } = "data"; - public string LengthField { get; init; } = "length"; - public int CharSize { get; init; } = 8; - public string Encoding { get; init; } = "utf8"; - public bool EmitRawSpanProperty { get; init; } = true; - public bool EmitStringProperty { get; init; } = true; -} - -public sealed class BlobTypeConfig -{ - public required string Type { get; init; } - public string DataField { get; init; } = "data"; - public string LengthField { get; init; } = "size"; - public string ElementType { get; init; } = "byte"; -} - -public sealed class OwnedTypeConfig -{ - public required string NativeType { get; init; } - public string? FreeFunction { get; init; } - public string? RetainFunction { get; init; } - public string? WrapperKind { get; init; } - public string? StaticType { get; init; } -} - -public sealed class StaticMethodConfig -{ - public required string NativeFunction { get; init; } - public string? MethodName { get; init; } - public string? StaticType { get; init; } - public bool ThrowOnNullReturn { get; init; } - public string? FailureMessageMember { get; init; } - public List Parameters { get; init; } = []; -} - -public sealed class StaticParameterConfig -{ - public required string Native { get; init; } - public required string Adapter { get; init; } - public string? PublicName { get; init; } - public string? Type { get; init; } - public string? Source { get; init; } - public bool OptionalDefault { get; init; } -} - -public sealed class MarshalledTypeConfig -{ - public required string NativeType { get; init; } + /// "EXTERN_API" = all DllImport methods on the Api class. + public required string Filter { get; init; } /// - /// Fields that need special (user-implemented partial) marshalling logic. - /// The generator emits a backing field + partial property stub for these; - /// the Dispose() partial stub is always emitted so the user can free them. + /// Conditions that must all be true: + /// "SELF_PTR" — first param type is T* where T is a known binding struct + /// "FIRST_PARAM_OTHER_TYPE" — first param is NOT a known struct pointer + /// "RETURN_BINDING_TYPE" — return type is T* where T is a known binding struct + /// "VOID_RETURN" — return type is void + /// "NAME_CONDITION(regex)" — native function name matches the regex ($TSelf/$TBare substituted) /// - public List MarshalledProperties { get; init; } = []; + public List Conditions { get; init; } = []; + /// "FIRST_PARAM_TYPE" or "RETURN_TYPE" — which type the method is placed on. + public required string TargetType { get; init; } + /// + /// One or more apply steps. In JSON can be a single object or an array. + /// Supported types: "INSTANCE_METHOD", "STATIC_METHOD", "INHERITANCE". + /// + [JsonConverter(typeof(ActionApplyListConverter))] + public required List Apply { get; init; } + public string? Comment { get; init; } } -public sealed class MarshalledPropertyConfig +/// +/// Describes a single apply step within an action. +/// +public sealed class ActionApplyConfig { - /// Native field name (snake_case). - public required string Native { get; init; } - /// The C# wrapper type for this field (e.g. "cstring"). + /// "INSTANCE_METHOD", "STATIC_METHOD", or "INHERITANCE". public required string Type { get; init; } + /// + /// Optional per-apply-step options. Accessed dynamically: + /// opts.removeFirstParam — bool [INSTANCE_METHOD] skip first param from public signature + /// opts.passAs — string [INSTANCE_METHOD] self-pointer expression ($TSelf substituted) + /// opts.name.set — string [INSTANCE/STATIC] fixed method name + /// opts.name.remove — array [INSTANCE/STATIC] removal token list + /// opts.baseType — array [INHERITANCE] list of base type strings + /// + [JsonConverter(typeof(DynamicJsonConverter))] + public dynamic? Opts { get; init; } +} + +/// +/// Deserializes the "apply" JSON field as either a single object or an array of objects, +/// always producing a List<ActionApplyConfig>. +/// +internal sealed class ActionApplyListConverter : JsonConverter> +{ + public override List Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType == JsonTokenType.StartArray) + { + return JsonSerializer.Deserialize>(ref reader, options) + ?? []; + } + + if (reader.TokenType == JsonTokenType.StartObject) + { + var single = JsonSerializer.Deserialize(ref reader, options); + return single is not null ? [single] : []; + } + + throw new JsonException($"Expected object or array for 'apply', got {reader.TokenType}."); + } + + public override void Write(Utf8JsonWriter writer, List value, JsonSerializerOptions options) + => JsonSerializer.Serialize(writer, value, options); } diff --git a/src/Tools/Ghost.NativeWrapperGen/Emit/CodeWriter.cs b/src/Tools/Ghost.NativeWrapperGen/Emit/CodeWriter.cs index 49df06a..8191999 100644 --- a/src/Tools/Ghost.NativeWrapperGen/Emit/CodeWriter.cs +++ b/src/Tools/Ghost.NativeWrapperGen/Emit/CodeWriter.cs @@ -7,6 +7,8 @@ internal sealed class CodeWriter private readonly StringBuilder _builder = new(); private int _indent; + public string CurrentIndentString => new(' ', _indent * 4); + public void WriteLine(string line = "") { if (line.Length == 0) diff --git a/src/Tools/Ghost.NativeWrapperGen/Emit/WrapperGeneratorEmitter.cs b/src/Tools/Ghost.NativeWrapperGen/Emit/WrapperGeneratorEmitter.cs index bce31a3..48787f7 100644 --- a/src/Tools/Ghost.NativeWrapperGen/Emit/WrapperGeneratorEmitter.cs +++ b/src/Tools/Ghost.NativeWrapperGen/Emit/WrapperGeneratorEmitter.cs @@ -1,1090 +1,635 @@ using Ghost.NativeWrapperGen.Config; using Ghost.NativeWrapperGen.Model; -using Ghost.NativeWrapperGen.Parsing; using Ghost.NativeWrapperGen.Transform; +using System.Text.RegularExpressions; namespace Ghost.NativeWrapperGen.Emit; +/// +/// Emits partial struct files containing low-level method wrappers that route +/// DllImport functions from the Api class into the native struct types they belong to. +/// No wrapper classes, no properties, no owned/marshalled types — just methods. +/// public sealed class WrapperGeneratorEmitter { public IEnumerable Emit(NativeLibrary library, WrapperConfig config) { var naming = new NamingConventions(config); - var resolver = new PublicTypeResolver(library, config, naming); - var ownedTypes = config.OwnedTypes.ToDictionary(static o => o.NativeType, StringComparer.Ordinal); - var marshalledTypes = config.MarshalledTypes.ToDictionary(static m => m.NativeType, StringComparer.Ordinal); - var partialTypes = new HashSet(config.PartialTypes, StringComparer.Ordinal); - var manualMethods = config.StaticMethods.ToDictionary(static m => m.NativeFunction, StringComparer.Ordinal); + var resolver = new BindingTypeResolver(library); + var skipFunctions = new HashSet(config.SkipFunctions, StringComparer.Ordinal); - yield return EmitHelpers(config); + // Collect all DllImport functions, grouped by the target struct they'll be emitted on. + // Each struct tracks a list of methods AND a set of base types (from INHERITANCE apply steps). + var methodsByStruct = new Dictionary>(StringComparer.Ordinal); + var baseTypesByStruct = new Dictionary>(StringComparer.Ordinal); - foreach (var @struct in library.Structs.Where(static s => !s.Name.StartsWith("_", StringComparison.Ordinal)).OrderBy(static s => s.Name, StringComparer.Ordinal)) + foreach (var func in library.Functions) { - if (@struct.IsList) - { - if (@struct.IsPointerList && @struct.ListElementType is not null && resolver.HasWrapper(@struct.ListElementType)) - { - yield return EmitPointerList(config, naming, @struct); - } - else if (string.Equals(@struct.ListElementType, "void", StringComparison.Ordinal)) - { - yield return EmitVoidList(config, naming, @struct); - } - - continue; - } - - ownedTypes.TryGetValue(@struct.Name, out var owned); - marshalledTypes.TryGetValue(@struct.Name, out var marshalled); - var isPartialType = partialTypes.Contains(@struct.Name); - - if (marshalled is not null) - { - yield return EmitMarshalledWrapper(library, config, naming, resolver, @struct, marshalled, owned); - } - else - { - yield return EmitWrapper(library, config, naming, resolver, @struct, owned, isPartialType, manualMethods); - } - } - - yield return EmitAutoStaticApi(library, config, naming, resolver, manualMethods); - } - - // ─── Helpers file ──────────────────────────────────────────────────────── - - private static GeneratedFile EmitHelpers(WrapperConfig config) - { - var writer = new CodeWriter(); - writer.WriteLine("using System.Text;"); - writer.WriteLine(); - writer.WriteLine($"namespace {config.WrapperNamespace};"); - writer.WriteLine(); - writer.WriteLine("internal static unsafe class NativeWrapperHelpers"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - foreach (var stringType in config.SpecialTypes.Strings) - { - EmitStringHelpers(writer, stringType); - writer.WriteLine(); - } - - foreach (var blobType in config.SpecialTypes.Blobs) - { - EmitBlobHelpers(writer, blobType); - writer.WriteLine(); - } - - writer.WriteLine("public static void ThrowIfOutOfRange(int index, int count)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("if ((uint)index >= (uint)count)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("throw new ArgumentOutOfRangeException(nameof(index));"); - } - writer.WriteLine("}"); - } - writer.WriteLine("}"); - } - writer.WriteLine("}"); - - return new GeneratedFile - { - FileName = "NativeWrapperHelpers.nativegen.cs", - Content = writer.ToString(), - }; - } - - private static void EmitStringHelpers(CodeWriter writer, StringTypeConfig config) - { - writer.WriteLine($"public static ReadOnlySpan AsByteSpan({config.Type} value)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine($"if (value.{config.DataField} == null || value.{config.LengthField} == 0)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("return ReadOnlySpan.Empty;"); - } - writer.WriteLine("}"); - writer.WriteLine(); - writer.WriteLine($"return new ReadOnlySpan((byte*)value.{config.DataField}, checked((int)value.{config.LengthField}) * {Math.Max(1, config.CharSize / 8)});"); - } - writer.WriteLine("}"); - writer.WriteLine(); - writer.WriteLine($"public static string GetString({config.Type} value)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("var bytes = AsByteSpan(value);"); - writer.WriteLine("if (bytes.IsEmpty)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("return string.Empty;"); - } - writer.WriteLine("}"); - writer.WriteLine(); - writer.WriteLine(config.Encoding.ToLowerInvariant() switch - { - "utf16" => "return Encoding.Unicode.GetString(bytes);", - "utf32" => "return Encoding.UTF32.GetString(bytes);", - _ => "return Encoding.UTF8.GetString(bytes);", - }); - } - writer.WriteLine("}"); - } - - private static void EmitBlobHelpers(CodeWriter writer, BlobTypeConfig config) - { - writer.WriteLine($"public static ReadOnlySpan<{config.ElementType}> AsSpan({config.Type} value)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine($"if (value.{config.DataField} == null || value.{config.LengthField} == 0)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine($"return ReadOnlySpan<{config.ElementType}>.Empty;"); - } - writer.WriteLine("}"); - writer.WriteLine(); - writer.WriteLine($"return new ReadOnlySpan<{config.ElementType}>(value.{config.DataField}, checked((int)value.{config.LengthField}));"); - } - writer.WriteLine("}"); - } - - // ─── Marshalled type wrapper (heap-pointer struct) ──────────────────────── - - private static GeneratedFile EmitMarshalledWrapper(NativeLibrary library, WrapperConfig config, NamingConventions naming, PublicTypeResolver resolver, NativeStruct @struct, MarshalledTypeConfig marshalled, OwnedTypeConfig? owned) - { - var writer = new CodeWriter(); - writer.WriteLine($"namespace {config.WrapperNamespace};"); - writer.WriteLine(); - - var wrapperName = naming.GetWrapperTypeName(@struct.Name); - var wrapperKind = GetWrapperKind(config, @struct.Name, owned); - var marshalledPropsByNative = marshalled.MarshalledProperties.ToDictionary(static p => p.Native, StringComparer.Ordinal); - - writer.WriteLine($"public unsafe partial {wrapperKind} {wrapperName} : System.IDisposable"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - // Pointer + alloc flag - writer.WriteLine($"private {@struct.Name}* _ptr;"); - writer.WriteLine("private bool _csAlloc;"); - writer.WriteLine(); - - // Default constructor — alloc on heap, zero-fill - writer.WriteLine($"public {wrapperName}()"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine($"_ptr = ({@struct.Name}*)System.Runtime.InteropServices.NativeMemory.AllocZeroed((nuint)sizeof({@struct.Name}));"); - writer.WriteLine("_csAlloc = true;"); - } - writer.WriteLine("}"); - writer.WriteLine(); - - // Internal constructor from existing pointer (e.g. native API returned it) - writer.WriteLine($"internal {wrapperName}({@struct.Name}* ptr)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("_ptr = ptr;"); - writer.WriteLine("_csAlloc = false;"); - } - writer.WriteLine("}"); - writer.WriteLine(); - - writer.WriteLine("public bool IsNull => _ptr == null;"); - writer.WriteLine(); - - // Partial Dispose stub — hand-written impl frees cstrings + conditionally frees _ptr - writer.WriteLine("public partial void Dispose();"); - writer.WriteLine(); - - // Emit properties for each member - foreach (var member in @struct.Members.Where(static m => - m.Name != "Anonymous" - && !m.Name.StartsWith("_", StringComparison.Ordinal) - && !m.TypeName.StartsWith("_", StringComparison.Ordinal) - && !m.TypeName.Contains("<", StringComparison.Ordinal) - && !m.TypeName.Contains("ref ", StringComparison.Ordinal))) - { - EmitMarshalledMember(writer, config, naming, resolver, wrapperName, member, marshalledPropsByNative); - } - - writer.WriteLine($"internal {@struct.Name}* GetUnsafePtr() => _ptr;"); - } - writer.WriteLine("}"); - - return new GeneratedFile - { - FileName = $"{wrapperName}.nativegen.cs", - Content = writer.ToString(), - }; - } - - private static void EmitMarshalledMember(CodeWriter writer, WrapperConfig config, NamingConventions naming, PublicTypeResolver resolver, string wrapperName, NativeMember member, Dictionary marshalledProps) - { - var propertyName = GetSafePropertyName(wrapperName, naming.GetPropertyName(member.Name)); - - // Marshalled property → emit partial property stub + backing field (hand-written impl manages cstring lifetime) - if (marshalledProps.TryGetValue(member.Name, out var marshalledProp)) - { - var fieldName = "_" + char.ToLowerInvariant(propertyName[0]) + propertyName[1..]; - writer.WriteLine($"private {marshalledProp.Type} {fieldName};"); - writer.WriteLine($"public partial {marshalledProp.Type} {propertyName} {{ get; set; }}"); - writer.WriteLine(); - return; - } - - var pointerDepth = BindingParser.GetPointerDepth(member.TypeName); - - // Skip function pointer and deep pointer fields - if (pointerDepth > 1) - { - return; - } - - // String special type → read-only helpers via pointer dereference - var stringType = config.SpecialTypes.Strings.FirstOrDefault(s => s.Type == member.TypeName); - if (stringType is not null) - { - if (stringType.EmitRawSpanProperty) - { - writer.WriteLine($"public ReadOnlySpan {propertyName}Bytes => NativeWrapperHelpers.AsByteSpan(_ptr->{member.Name});"); - } - if (stringType.EmitStringProperty) - { - writer.WriteLine($"public string {propertyName} => NativeWrapperHelpers.GetString(_ptr->{member.Name});"); - } - writer.WriteLine(); - return; - } - - // Blob special type → read-only span via pointer dereference - var blobType = config.SpecialTypes.Blobs.FirstOrDefault(b => b.Type == member.TypeName); - if (blobType is not null) - { - writer.WriteLine($"public ReadOnlySpan<{blobType.ElementType}> {propertyName} => NativeWrapperHelpers.AsSpan(_ptr->{member.Name});"); - writer.WriteLine(); - return; - } - - // Pointer field (depth == 1) — expose raw pointer as read/write - if (pointerDepth == 1) - { - writer.WriteLine($"public {member.TypeName} {propertyName} {{ get => _ptr->{member.Name}; set => _ptr->{member.Name} = value; }}"); - writer.WriteLine(); - return; - } - - // Plain value field — direct read/write through pointer - writer.WriteLine($"public {resolver.GetPublicType(member.TypeName)} {propertyName} {{ get => _ptr->{member.Name}; set => _ptr->{member.Name} = value; }}"); - writer.WriteLine(); - } - - // ─── Pointer-based wrapper (read-only view) ─────────────────────────────── - - private static GeneratedFile EmitWrapper(NativeLibrary library, WrapperConfig config, NamingConventions naming, PublicTypeResolver resolver, NativeStruct @struct, OwnedTypeConfig? owned, bool isPartialType, Dictionary manualMethods) - { - var writer = new CodeWriter(); - writer.WriteLine($"namespace {config.WrapperNamespace};"); - writer.WriteLine(); - - var wrapperName = naming.GetWrapperTypeName(@struct.Name); - var wrapperKind = GetWrapperKind(config, @struct.Name, owned); - var implementsIDisposable = wrapperKind == "class" && !string.IsNullOrWhiteSpace(owned?.FreeFunction); - var partialKeyword = isPartialType ? "partial " : string.Empty; - - writer.WriteLine($"public unsafe {partialKeyword}{GetWrapperDeclaration(wrapperName, wrapperKind, implementsIDisposable)}"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine(GetPointerFieldDeclaration(@struct.Name, wrapperKind)); - writer.WriteLine(); - writer.WriteLine($"internal {wrapperName}({@struct.Name}* ptr)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("_ptr = ptr;"); - } - writer.WriteLine("}"); - writer.WriteLine(); - writer.WriteLine("public bool IsNull => _ptr == null;"); - writer.WriteLine(); - - if (!string.IsNullOrWhiteSpace(owned?.FreeFunction)) - { - writer.WriteLine("public void Dispose()"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("if (_ptr != null)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine($"Api.{owned.FreeFunction}(_ptr);"); - writer.WriteLine("_ptr = null;"); - } - writer.WriteLine("}"); - } - writer.WriteLine("}"); - writer.WriteLine(); - } - - // Emit instance methods auto-routed to this wrapper type - foreach (var func in library.Functions.Where(f => f.IsDllImport)) - { - var routing = ResolveAutoTarget(library, config, naming, func, manualMethods); - if (routing.TargetType != wrapperName) - { - continue; - } - - if (manualMethods.TryGetValue(func.Name, out var manual)) - { - EmitStaticMethod(writer, library, config, naming, resolver, manual, routing.Kind == RoutingKind.InstanceMethod ? wrapperName : null); - } - else - { - EmitAutoMethod(writer, library, config, naming, resolver, func, routing.Kind == RoutingKind.InstanceMethod ? wrapperName : null); - } - writer.WriteLine(); - } - - foreach (var member in @struct.Members.Where(static m => m.Name != "Anonymous" && !m.Name.StartsWith("_", StringComparison.Ordinal))) - { - EmitMember(writer, library, config, naming, resolver, wrapperName, member); - } - - writer.WriteLine($"internal {@struct.Name}* GetUnsafePtr() => _ptr;"); - } - writer.WriteLine("}"); - - return new GeneratedFile - { - FileName = $"{wrapperName}.nativegen.cs", - Content = writer.ToString(), - }; - } - - // ─── Member emission (pointer-based) ───────────────────────────────────── - - private static void EmitMember(CodeWriter writer, NativeLibrary library, WrapperConfig config, NamingConventions naming, PublicTypeResolver resolver, string wrapperName, NativeMember member) - { - if (member.TypeName.StartsWith("_", StringComparison.Ordinal)) - { - return; - } - - if (member.TypeName.Contains("<", StringComparison.Ordinal) || member.TypeName.Contains("ref ", StringComparison.Ordinal)) - { - return; - } - - var propertyName = GetSafePropertyName(wrapperName, naming.GetPropertyName(member.Name)); - var pointerDepth = BindingParser.GetPointerDepth(member.TypeName); - var baseType = BindingParser.TrimPointers(member.TypeName); - - var stringType = config.SpecialTypes.Strings.FirstOrDefault(s => s.Type == member.TypeName); - if (stringType is not null) - { - if (stringType.EmitRawSpanProperty) - { - writer.WriteLine($"public ReadOnlySpan {propertyName}Bytes => NativeWrapperHelpers.AsByteSpan(_ptr->{member.Name});"); - } - - if (stringType.EmitStringProperty) - { - writer.WriteLine($"public string {propertyName} => NativeWrapperHelpers.GetString(_ptr->{member.Name});"); - } - - writer.WriteLine(); - return; - } - - var blobType = config.SpecialTypes.Blobs.FirstOrDefault(b => b.Type == member.TypeName); - if (blobType is not null) - { - writer.WriteLine($"public ReadOnlySpan<{blobType.ElementType}> {propertyName} => NativeWrapperHelpers.AsSpan(_ptr->{member.Name});"); - writer.WriteLine(); - return; - } - - if (library.StructsByName.TryGetValue(baseType, out var listStruct) && listStruct.IsList) - { - EmitListMember(writer, naming, resolver, member, listStruct, propertyName); - return; - } - - if (pointerDepth == 1 && resolver.HasWrapper(baseType)) - { - var wrapperType = resolver.GetPublicType(member.TypeName); - writer.WriteLine($"public bool Has{propertyName} => _ptr->{member.Name} != null;"); - writer.WriteLine($"public {wrapperType} {propertyName} => _ptr->{member.Name} != null ? new(_ptr->{member.Name}) : throw new InvalidOperationException(\"{propertyName} is null.\");"); - writer.WriteLine(); - return; - } - - if (pointerDepth > 0) - { - writer.WriteLine($"public {member.TypeName} {propertyName} => _ptr->{member.Name};"); - writer.WriteLine(); - return; - } - - if (resolver.HasWrapper(baseType)) - { - var wrapperType = naming.GetWrapperTypeName(baseType); - writer.WriteLine($"public {wrapperType} {propertyName} => new(({baseType}*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _ptr->{member.Name}));"); - writer.WriteLine(); - return; - } - - writer.WriteLine($"public {resolver.GetPublicType(member.TypeName)} {propertyName} => _ptr->{member.Name};"); - writer.WriteLine(); - } - - private static void EmitListMember(CodeWriter writer, NamingConventions naming, PublicTypeResolver resolver, NativeMember member, NativeStruct listStruct, string propertyName) - { - if (listStruct.ListElementType is null) - { - writer.WriteLine($"public {member.TypeName} {propertyName} => _ptr->{member.Name};"); - writer.WriteLine(); - return; - } - - if (listStruct.IsPointerList && resolver.HasWrapper(listStruct.ListElementType)) - { - var listWrapperName = naming.GetWrapperTypeName(listStruct.Name); - writer.WriteLine($"public {listWrapperName} {propertyName} => new(_ptr->{member.Name}.data, _ptr->{member.Name}.count);"); - writer.WriteLine(); - return; - } - - if (string.Equals(listStruct.ListElementType, "void", StringComparison.Ordinal)) - { - var listWrapperName = naming.GetWrapperTypeName(listStruct.Name); - writer.WriteLine($"public {listWrapperName} {propertyName} => new(_ptr->{member.Name}.data, _ptr->{member.Name}.count);"); - writer.WriteLine(); - return; - } - - var elementType = resolver.GetPublicType(listStruct.ListElementType); - writer.WriteLine($"public ReadOnlySpan<{elementType}> {propertyName} => _ptr->{member.Name}.data == null ? ReadOnlySpan<{elementType}>.Empty : new ReadOnlySpan<{elementType}>(_ptr->{member.Name}.data, checked((int)_ptr->{member.Name}.count));"); - writer.WriteLine(); - } - - // ─── List wrappers ──────────────────────────────────────────────────────── - - private static GeneratedFile EmitPointerList(WrapperConfig config, NamingConventions naming, NativeStruct listStruct) - { - var writer = new CodeWriter(); - var wrapperName = naming.GetWrapperTypeName(listStruct.Name); - var elementType = listStruct.ListElementType!; - var elementWrapperName = naming.GetWrapperTypeName(elementType); - - writer.WriteLine($"namespace {config.WrapperNamespace};"); - writer.WriteLine(); - writer.WriteLine($"public unsafe readonly ref struct {wrapperName}"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine($"private readonly {elementType}** _data;"); - writer.WriteLine("public int Count { get; }"); - writer.WriteLine(); - writer.WriteLine($"internal {wrapperName}({elementType}** data, nuint count)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("_data = data;"); - writer.WriteLine("Count = checked((int)count);"); - } - writer.WriteLine("}"); - writer.WriteLine(); - writer.WriteLine($"public {elementWrapperName} this[int index]"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("get"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("NativeWrapperHelpers.ThrowIfOutOfRange(index, Count);"); - writer.WriteLine("return new(_data[index]);"); - } - writer.WriteLine("}"); - } - writer.WriteLine("}"); - writer.WriteLine(); - writer.WriteLine("public Enumerator GetEnumerator() => new(_data, Count);"); - writer.WriteLine(); - writer.WriteLine("public unsafe ref struct Enumerator"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine($"private readonly {elementType}** _data;"); - writer.WriteLine("private readonly int _count;"); - writer.WriteLine("private int _index;"); - writer.WriteLine(); - writer.WriteLine($"internal Enumerator({elementType}** data, int count)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("_data = data;"); - writer.WriteLine("_count = count;"); - writer.WriteLine("_index = -1;"); - } - writer.WriteLine("}"); - writer.WriteLine(); - writer.WriteLine($"public {elementWrapperName} Current => new(_data[_index]);"); - writer.WriteLine(); - writer.WriteLine("public bool MoveNext()"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("var next = _index + 1;"); - writer.WriteLine("if (next >= _count)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("return false;"); - } - writer.WriteLine("}"); - writer.WriteLine(); - writer.WriteLine("_index = next;"); - writer.WriteLine("return true;"); - } - writer.WriteLine("}"); - } - writer.WriteLine("}"); - } - writer.WriteLine("}"); - - return new GeneratedFile - { - FileName = $"{wrapperName}.nativegen.cs", - Content = writer.ToString(), - }; - } - - private static GeneratedFile EmitVoidList(WrapperConfig config, NamingConventions naming, NativeStruct listStruct) - { - var writer = new CodeWriter(); - var wrapperName = naming.GetWrapperTypeName(listStruct.Name); - - writer.WriteLine($"namespace {config.WrapperNamespace};"); - writer.WriteLine(); - writer.WriteLine($"public unsafe readonly ref struct {wrapperName}"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("private readonly void* _data;"); - writer.WriteLine("public int Count { get; }"); - writer.WriteLine(); - writer.WriteLine($"internal {wrapperName}(void* data, nuint count)"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - writer.WriteLine("_data = data;"); - writer.WriteLine("Count = checked((int)count);"); - } - writer.WriteLine("}"); - writer.WriteLine(); - writer.WriteLine("public void* Data => _data;"); - } - writer.WriteLine("}"); - - return new GeneratedFile - { - FileName = $"{wrapperName}.nativegen.cs", - Content = writer.ToString(), - }; - } - - // ─── Auto-dispatch static API ───────────────────────────────────────────── - - private static GeneratedFile EmitAutoStaticApi(NativeLibrary library, WrapperConfig config, NamingConventions naming, PublicTypeResolver resolver, Dictionary manualMethods) - { - var staticTypeName = config.StaticApiClassName ?? (config.LibraryName + "Global"); - var writer = new CodeWriter(); - - writer.WriteLine($"namespace {config.WrapperNamespace};"); - writer.WriteLine(); - writer.WriteLine($"public static unsafe class {staticTypeName}"); - writer.WriteLine("{"); - using (writer.IndentScope()) - { - foreach (var func in library.Functions.Where(static f => f.IsDllImport).OrderBy(static f => f.Name, StringComparer.Ordinal)) - { - var routing = ResolveAutoTarget(library, config, naming, func, manualMethods); - if (routing.TargetType != staticTypeName) + if (!func.IsDllImport) { continue; } - if (manualMethods.TryGetValue(func.Name, out var manual)) + if (skipFunctions.Contains(func.Name)) { - EmitStaticMethod(writer, library, config, naming, resolver, manual, null); + continue; } - else - { - EmitAutoMethod(writer, library, config, naming, resolver, func, null); - } - writer.WriteLine(); - } - } - writer.WriteLine("}"); - return new GeneratedFile + RouteFunction(func, config, resolver, methodsByStruct, baseTypesByStruct); + } + + // Emit one file per struct that has at least one routed method. + foreach (var (structName, methods) in methodsByStruct.OrderBy(static kv => kv.Key, StringComparer.Ordinal)) { - FileName = $"{staticTypeName}.nativegen.cs", - Content = writer.ToString(), - }; + baseTypesByStruct.TryGetValue(structName, out var baseTypes); + yield return EmitStructFile(structName, methods, baseTypes, config, naming); + } } - // ─── Auto routing ───────────────────────────────────────────────────────── - - private enum RoutingKind { GlobalStatic, InstanceMethod, StaticOnType } - - private sealed record RoutingResult(string TargetType, RoutingKind Kind); + // ─── Routing ───────────────────────────────────────────────────────────── /// - /// Classifies a native function into one of three routing categories: - /// a) TKnown* func(somethingElse...) → return-type wrapper class (static factory) - /// b) TKnown1 func(TKnown0*, ...) → first-param wrapper type (instance method) - /// c) everything else → global static class - /// Manual configs that set StaticType override the auto-routing. - /// Manual configs with selfPointer adapter force route (b). + /// Attempts to match the function against each action in order. On match, processes + /// every apply step in the action's Apply list — INSTANCE_METHOD/STATIC_METHOD steps + /// produce a RoutedMethod; INHERITANCE steps record base types on the target struct. + /// Only the first matching action is used (first-match-wins). /// - private static RoutingResult ResolveAutoTarget(NativeLibrary library, WrapperConfig config, NamingConventions naming, NativeFunction func, Dictionary manualMethods) + private static void RouteFunction( + NativeFunction func, + WrapperConfig config, + BindingTypeResolver resolver, + Dictionary> methodsByStruct, + Dictionary> baseTypesByStruct) { - var staticTypeName = config.StaticApiClassName ?? (config.LibraryName + "Global"); - - // Manual override: StaticType wins - if (manualMethods.TryGetValue(func.Name, out var manual) && !string.IsNullOrWhiteSpace(manual.StaticType)) + foreach (var action in config.Actions) { - return new(manual.StaticType, RoutingKind.StaticOnType); - } - - // Manual override: selfPointer wins (route to that type as instance method) - if (manualMethods.TryGetValue(func.Name, out manual)) - { - var selfParam = manual.Parameters.FirstOrDefault(static p => p.Adapter == "selfPointer"); - if (selfParam is not null) + if (!string.Equals(action.Filter, "EXTERN_API", StringComparison.Ordinal)) { - var nativeParam = func.Parameters.FirstOrDefault(p => string.Equals(p.Name, selfParam.Native, StringComparison.Ordinal)); - if (nativeParam is not null) - { - var baseType = BindingParser.TrimPointers(nativeParam.TypeName); - if (library.StructsByName.ContainsKey(baseType)) - { - return new(naming.GetWrapperTypeName(baseType), RoutingKind.InstanceMethod); - } - } - } - } - - // Rule (b): first param is T* where T is a known wrapper type → instance on T - if (func.Parameters.Count > 0) - { - var firstParam = func.Parameters[0]; - var firstBase = BindingParser.TrimPointers(firstParam.TypeName); - if (BindingParser.GetPointerDepth(firstParam.TypeName) == 1 && library.StructsByName.ContainsKey(firstBase)) - { - return new(naming.GetWrapperTypeName(firstBase), RoutingKind.InstanceMethod); - } - } - - // Rule (a): return type is T* where T is a known wrapper type → static on T - var returnPointerDepth = BindingParser.GetPointerDepth(func.ReturnType); - if (returnPointerDepth == 1) - { - var returnBase = BindingParser.TrimPointers(func.ReturnType); - if (library.StructsByName.ContainsKey(returnBase)) - { - return new(naming.GetWrapperTypeName(returnBase), RoutingKind.StaticOnType); - } - } - - // Rule (c): global static - return new(staticTypeName, RoutingKind.GlobalStatic); - } - - // ─── Auto method emission ───────────────────────────────────────────────── - - private static void EmitAutoMethod(CodeWriter writer, NativeLibrary library, WrapperConfig config, NamingConventions naming, PublicTypeResolver resolver, NativeFunction func, string? instanceTypeName) - { - var isInstanceMethod = instanceTypeName is not null; - - // Build parameter list, skipping the first param if it's the self pointer - var parameters = new List(); - var argumentExpressions = new List(); - var marshalledTypes = config.MarshalledTypes.ToDictionary(static m => m.NativeType, StringComparer.Ordinal); - var skipFirst = isInstanceMethod; - - foreach (var param in func.Parameters) - { - if (skipFirst) - { - skipFirst = false; - argumentExpressions.Add("_ptr"); continue; } - var publicName = NamingConventions.ToPascalCase(param.Name); - publicName = char.ToLowerInvariant(publicName[0]) + publicName[1..]; - - var pointerDepth = BindingParser.GetPointerDepth(param.TypeName); - var baseType = BindingParser.TrimPointers(param.TypeName); - - if (pointerDepth == 1 && marshalledTypes.TryGetValue(baseType, out _)) + // Determine the target struct name before evaluating NAME_CONDITION + // (because NAME_CONDITION may reference $TSelf / $TBare). + var targetStruct = ResolveTargetType(func, action.TargetType, resolver); + if (targetStruct is null) { - // Pass marshalled wrapper by pointer directly — no copy needed - var wrapperType = naming.GetWrapperTypeName(baseType); - parameters.Add($"{wrapperType} {publicName}"); - argumentExpressions.Add($"{publicName}.GetUnsafePtr()"); + continue; } - else if (pointerDepth == 1 && library.StructsByName.ContainsKey(baseType)) + + if (!EvaluateConditions(func, action.Conditions, resolver, targetStruct, config)) { - var wrapperType = naming.GetWrapperTypeName(baseType); - parameters.Add($"{wrapperType} {publicName}"); - argumentExpressions.Add($"{publicName}.GetUnsafePtr()"); + continue; } - else + + // Process each apply step. + foreach (var apply in action.Apply) { - parameters.Add($"{param.TypeName} {publicName}"); - argumentExpressions.Add(publicName); + var applyType = apply.Type; + + if (string.Equals(applyType, "INSTANCE_METHOD", StringComparison.Ordinal) || + string.Equals(applyType, "STATIC_METHOD", StringComparison.Ordinal)) + { + var isInstance = string.Equals(applyType, "INSTANCE_METHOD", StringComparison.Ordinal); + + var routed = new RoutedMethod + { + Function = func, + TargetStructName = targetStruct, + IsInstance = isInstance, + Apply = apply, + }; + + if (!methodsByStruct.TryGetValue(targetStruct, out var list)) + { + list = []; + methodsByStruct[targetStruct] = list; + } + + list.Add(routed); + } + else if (string.Equals(applyType, "INHERITANCE", StringComparison.Ordinal)) + { + var baseTypes = apply.Opts?.baseType as object?[]; + if (baseTypes is { Length: > 0 }) + { + if (!baseTypesByStruct.TryGetValue(targetStruct, out var set)) + { + set = new HashSet(StringComparer.Ordinal); + baseTypesByStruct[targetStruct] = set; + } + + foreach (var bt in baseTypes) + { + if (bt is string s) set.Add(s); + } + } + } + } + + // First-match-wins: stop after the first matching action. + return; + } + } + + private static bool EvaluateConditions( + NativeFunction func, + List conditions, + BindingTypeResolver resolver, + string targetStructName, + WrapperConfig config) + { + foreach (var condition in conditions) + { + // Handle parameterised conditions before the switch. + if (condition.StartsWith("NAME_CONDITION(", StringComparison.Ordinal) && + condition.EndsWith(')')) + { + var pattern = condition["NAME_CONDITION(".Length..^1]; + // $TSelf → full struct name (e.g. "NvttSurface") + // $TBare → struct name with the library prefix stripped (e.g. "Surface") + var bareName = StripPrefix(targetStructName, config.NativeTypePrefix); + var resolvedPattern = pattern + .Replace("$TBare", bareName, StringComparison.Ordinal) + .Replace("$TSelf", targetStructName, StringComparison.Ordinal); + if (!Regex.IsMatch(func.Name, resolvedPattern, RegexOptions.IgnoreCase)) + { + return false; + } + + continue; + } + + switch (condition) + { + case "SELF_PTR": + if (func.Parameters.Count == 0 || + resolver.TryGetBindingStructName(func.Parameters[0].TypeName) is null) + { + return false; + } + + break; + + case "FIRST_PARAM_OTHER_TYPE": + if (func.Parameters.Count > 0 && + resolver.TryGetBindingStructName(func.Parameters[0].TypeName) is not null) + { + return false; + } + + break; + + case "RETURN_BINDING_TYPE": + if (resolver.TryGetBindingStructName(func.ReturnType) is null) + { + return false; + } + + break; + + case "VOID_RETURN": + if (!string.Equals(func.ReturnType, "void", StringComparison.Ordinal)) + { + return false; + } + + break; + + default: + // Unknown condition — treat as not-matched. + return false; } } - var (returnType, returnConversion) = ResolveReturnConversion(config, resolver, naming, func.ReturnType); - var methodName = naming.GetWrapperTypeName(func.Name); - var staticKeyword = isInstanceMethod ? string.Empty : "static "; - var signatureLine = $"public {staticKeyword}{returnType} {methodName}({string.Join(", ", parameters)})"; + return true; + } - writer.WriteLine(signatureLine); + private static string? ResolveTargetType( + NativeFunction func, + string targetTypeRule, + BindingTypeResolver resolver) + { + return targetTypeRule switch + { + "FIRST_PARAM_TYPE" when func.Parameters.Count > 0 => + resolver.TryGetBindingStructName(func.Parameters[0].TypeName), + "RETURN_TYPE" => + resolver.TryGetBindingStructName(func.ReturnType), + _ => null, + }; + } + + // ─── Code emission ──────────────────────────────────────────────────────── + + private static GeneratedFile EmitStructFile( + string structName, + List methods, + HashSet? baseTypes, + WrapperConfig config, + NamingConventions naming) + { + var writer = new CodeWriter(); + + writer.WriteLine("// "); + writer.WriteLine("// This file is generated by Ghost.NativeWrapperGen. Do not edit manually."); + writer.WriteLine("// "); + writer.WriteLine(); + writer.WriteLine($"namespace {config.OutputNamespace};"); + writer.WriteLine(); + + // Build struct header with optional base-type list. + var baseTypeList = baseTypes is { Count: > 0 } + ? " : " + string.Join(", ", baseTypes.Order(StringComparer.Ordinal)) + : ""; + writer.WriteLine($"public unsafe partial struct {structName}{baseTypeList}"); writer.WriteLine("{"); + using (writer.IndentScope()) { - var callExpression = $"Api.{func.Name}({string.Join(", ", argumentExpressions)})"; - var returnsWrappedType = BindingParser.GetPointerDepth(func.ReturnType) == 1 && resolver.HasWrapper(BindingParser.TrimPointers(func.ReturnType)); - var returnsVoid = string.Equals(func.ReturnType, "void", StringComparison.Ordinal); + var first = true; + foreach (var method in methods) + { + if (!first) + { + writer.WriteLine(); + } - if (returnsWrappedType) - { - writer.WriteLine($"return new({callExpression});"); - } - else if (returnsVoid) - { - writer.WriteLine($"{callExpression};"); - } - else if (returnConversion is not null) - { - writer.WriteLine($"return {string.Format(returnConversion, callExpression)};"); - } - else - { - writer.WriteLine($"return {callExpression};"); + first = false; + EmitMethod(writer, method, config, naming); } } + + writer.WriteLine("}"); + + return new GeneratedFile + { + FileName = $"{structName}.nativegen.cs", + Content = writer.ToString(), + }; + } + + private static void EmitMethod( + CodeWriter writer, + RoutedMethod routed, + WrapperConfig config, + NamingConventions naming) + { + var func = routed.Function; + var nameOpts = routed.Apply.Opts?.name; + var methodName = naming.GetMethodName(func.Name, nameOpts, routed.TargetStructName); + + // Build the parameter plan: for each native parameter, determine the public type + // and how to pass it to the Api call (applying remaps). + var plan = BuildParameterPlan(func, config, routed); + + // Comment showing the source function. + writer.WriteLine($"// From: {func.Name}({string.Join(", ", func.Parameters.Select(static p => p.TypeName))})"); + + // Signature + var staticModifier = routed.IsInstance ? "" : "static "; + var publicParams = plan.PublicParams; + var paramList = string.Join(", ", publicParams.Select(static p => $"{p.PublicType} {p.PublicName}")); + writer.WriteLine($"public {staticModifier}{func.ReturnType} {methodName}({paramList})"); + writer.WriteLine("{"); + + using (writer.IndentScope()) + { + EmitMethodBody(writer, func, routed, plan, config); + } + writer.WriteLine("}"); } - // ─── Manual method emission ─────────────────────────────────────────────── - - private static void EmitStaticMethod(CodeWriter writer, NativeLibrary library, WrapperConfig config, NamingConventions naming, PublicTypeResolver resolver, StaticMethodConfig methodConfig, string? wrapperName) + private static void EmitMethodBody( + CodeWriter writer, + NativeFunction func, + RoutedMethod routed, + ParameterPlan plan, + WrapperConfig config) { - if (!library.FunctionsByName.TryGetValue(methodConfig.NativeFunction, out var nativeFunction)) + // Collect the remapped params that need wrapCall blocks, in order. + var wrappedParams = plan.PublicParams + .Where(static p => p.WrapCall is not null) + .ToList(); + + // Build the Api call arguments. + var args = new List(); + + if (routed.IsInstance) { + // Self pointer — first native param is skipped from the public signature. + // Use the passAs expression from apply opts if present, substituting $TSelf. + var passAs = (string?)routed.Apply.Opts?.passAs; + if (passAs is not null) + { + args.Add(passAs.Replace("$TSelf", routed.TargetStructName, StringComparison.Ordinal)); + } + else + { + // Fallback: construct the self pointer expression directly. + args.Add($"({routed.TargetStructName}*)Unsafe.AsPointer(ref this)"); + } + } + + foreach (var p in plan.AllNativeParams) + { + if (p.IsConsumedByDerivesFrom) + { + args.Add(p.DerivedExpr!); + } + else if (p.IsSelfParam) + { + // Already handled above. + } + else if (p.PassAs is not null) + { + args.Add(p.PassAs.Replace("$arg", p.PublicName, StringComparison.Ordinal)); + } + else + { + args.Add(p.PublicName); + } + } + + var hasReturn = !string.Equals(func.ReturnType, "void", StringComparison.Ordinal); + var returnKeyword = hasReturn ? "return " : ""; + + // Wrap the call in nested fixed() blocks (one per remapped parameter with a wrapCall). + EmitNestedWrapCall(writer, wrappedParams, 0, (w) => + { + if (args.Count <= 1) + { + var callExpr = $"Api.{func.Name}({string.Join(", ", args)})"; + w.WriteLine($"{returnKeyword}{callExpr};"); + } + else + { + w.WriteLine($"{returnKeyword}Api.{func.Name}("); + using (w.IndentScope()) + { + for (var i = 0; i < args.Count; i++) + { + var trailing = i < args.Count - 1 ? "," : ");"; + w.WriteLine($"{args[i]}{trailing}"); + } + } + } + }); + } + + private static void EmitNestedWrapCall( + CodeWriter writer, + List wrappedParams, + int index, + Action emitInner) + { + if (index >= wrappedParams.Count) + { + emitInner(writer); return; } - var signature = BuildMethodSignature(library, config, naming, resolver, methodConfig, nativeFunction, wrapperName); - writer.WriteLine(signature.SignatureLine); - writer.WriteLine("{"); - using (writer.IndentScope()) + var param = wrappedParams[index]; + var wrapCall = param.WrapCall!; + + var callPlaceholder = "$CALL"; + var splitIndex = wrapCall.IndexOf(callPlaceholder, StringComparison.Ordinal); + + if (splitIndex < 0) { - foreach (var line in signature.BodyLines) - { - writer.WriteLine(line); - } + writer.WriteLine(wrapCall.Replace("$arg", param.PublicName, StringComparison.Ordinal)); + EmitNestedWrapCall(writer, wrappedParams, index + 1, emitInner); + return; } - writer.WriteLine("}"); - } - private static GeneratedMethod BuildMethodSignature(NativeLibrary library, WrapperConfig config, NamingConventions naming, PublicTypeResolver resolver, StaticMethodConfig methodConfig, NativeFunction nativeFunction, string? wrapperName) - { - var parameters = new List(); - var preCallLines = new List(); - var argumentExpressions = new List(); - string? pendingSpanSource = null; - string? failureVariable = null; - var isInstanceMethod = false; + var before = wrapCall[..splitIndex].Replace("$arg", param.PublicName, StringComparison.Ordinal).Trim(); + var after = wrapCall[(splitIndex + callPlaceholder.Length)..].Replace("$arg", param.PublicName, StringComparison.Ordinal).Trim(); - foreach (var parameter in nativeFunction.Parameters) + if (before.EndsWith('{')) { - var configParameter = methodConfig.Parameters.FirstOrDefault(p => p.Native == parameter.Name); - if (configParameter is null) + writer.WriteLine(before[..^1].TrimEnd()); + writer.WriteLine("{"); + using (writer.IndentScope()) { - // Implicit selfPointer: first unconfigured T* param where T is a known struct - if (!isInstanceMethod && argumentExpressions.Count == 0) + EmitNestedWrapCall(writer, wrappedParams, index + 1, emitInner); + } + + if (after.StartsWith('}')) + { + writer.WriteLine("}"); + var remaining = after[1..].Trim(); + if (remaining.Length > 0) { - var pd = BindingParser.GetPointerDepth(parameter.TypeName); - var bt = BindingParser.TrimPointers(parameter.TypeName); - if (pd == 1 && library.StructsByName.ContainsKey(bt)) - { - isInstanceMethod = true; - argumentExpressions.Add("_ptr"); - continue; - } + writer.WriteLine(remaining); } - - argumentExpressions.Add(parameter.Name); - parameters.Add($"{parameter.TypeName} {parameter.Name}"); - continue; } - - var publicName = configParameter.PublicName ?? NamingConventions.ToPascalCase(parameter.Name); - publicName = char.ToLowerInvariant(publicName[0]) + publicName[1..]; - - switch (configParameter.Adapter) - { - case "selfPointer": - isInstanceMethod = true; - argumentExpressions.Add("_ptr"); - break; - case "utf8Path": - parameters.Add($"ReadOnlySpan {publicName}"); - preCallLines.Add($"fixed (byte* {publicName}Ptr = {publicName})"); - argumentExpressions.Add($"(sbyte*){publicName}Ptr"); - pendingSpanSource = publicName; - break; - case "utf8Length": - argumentExpressions.Add($"(nuint){configParameter.Source ?? pendingSpanSource}.Length"); - break; - case "byteSpan": - parameters.Add($"ReadOnlySpan {publicName}"); - preCallLines.Add($"fixed (byte* {publicName}Ptr = {publicName})"); - argumentExpressions.Add($"{publicName}Ptr"); - pendingSpanSource = publicName; - break; - case "byteSpanLength": - argumentExpressions.Add($"(nuint){configParameter.Source ?? pendingSpanSource}.Length"); - break; - case "inValue": - { - var typeName = configParameter.Type ?? parameter.TypeName.TrimEnd('*').Trim(); - var defaultValue = configParameter.OptionalDefault ? " = default" : string.Empty; - parameters.Add($"in {typeName} {publicName}{defaultValue}"); - preCallLines.Add($"var {publicName}Local = {publicName};"); - argumentExpressions.Add($"&{publicName}Local"); - break; - } - case "errorOut": - { - var typeName = configParameter.Type ?? parameter.TypeName.TrimEnd('*').Trim(); - failureVariable = publicName; - preCallLines.Add($"{typeName} {publicName} = default;"); - argumentExpressions.Add($"&{publicName}"); - break; - } - case "getPtr": - { - var typeName = configParameter.Type ?? parameter.TypeName.TrimEnd('*').Trim(); - parameters.Add($"{typeName} {publicName}"); - argumentExpressions.Add($"{publicName}.GetUnsafePtr()"); - break; - } - default: - parameters.Add($"{configParameter.Type ?? parameter.TypeName} {publicName}"); - argumentExpressions.Add(publicName); - break; - } - } - - var (returnType, returnConversion) = ResolveReturnConversion(config, resolver, naming, nativeFunction.ReturnType); - var methodName = methodConfig.MethodName ?? naming.GetWrapperTypeName(methodConfig.NativeFunction); - var staticKeyword = isInstanceMethod ? string.Empty : "static "; - var signatureLine = $"public {staticKeyword}{returnType} {methodName}({string.Join(", ", parameters)})"; - - var body = new List(); - var fixedLines = preCallLines.Where(static l => l.StartsWith("fixed ", StringComparison.Ordinal)).ToList(); - var normalLines = preCallLines.Where(static l => !l.StartsWith("fixed ", StringComparison.Ordinal)).ToList(); - body.AddRange(normalLines); - - if (fixedLines.Count > 0) - { - foreach (var fixedLine in fixedLines) - { - body.Add(fixedLine); - } - - body.Add("{"); - } - - var callExpression = $"Api.{nativeFunction.Name}({string.Join(", ", argumentExpressions)})"; - var returnsWrappedType = BindingParser.GetPointerDepth(nativeFunction.ReturnType) == 1 && resolver.HasWrapper(BindingParser.TrimPointers(nativeFunction.ReturnType)); - - if (returnsWrappedType) - { - body.Add($"var value = {callExpression};"); - if (methodConfig.ThrowOnNullReturn) - { - body.Add("if (value == null)"); - body.Add("{"); - if (!string.IsNullOrWhiteSpace(failureVariable) && !string.IsNullOrWhiteSpace(methodConfig.FailureMessageMember)) - { - body.Add($" throw new InvalidOperationException(NativeWrapperHelpers.GetString({failureVariable}.{methodConfig.FailureMessageMember}));"); - } - else - { - body.Add(" throw new InvalidOperationException(\"Native call failed.\");"); - } - body.Add("}"); - } - - body.Add("return new(value);"); - } - else if (string.Equals(nativeFunction.ReturnType, "void", StringComparison.Ordinal)) - { - body.Add($"{callExpression};"); - } - else if (returnConversion is not null) - { - body.Add($"return {string.Format(returnConversion, callExpression)};"); } else { - body.Add($"return {callExpression};"); - } - - if (fixedLines.Count > 0) - { - body.Add("}"); - } - - return new GeneratedMethod(signatureLine, body); - } - - // ─── Helpers ────────────────────────────────────────────────────────────── - - /// - /// Returns (publicReturnType, conversionWrapper) where conversionWrapper is - /// a format string like "NativeWrapperHelpers.GetString({0})" if the native - /// return type is a special string/blob that needs conversion, or null otherwise. - /// - private static (string PublicType, string? ConversionFormat) ResolveReturnConversion( - WrapperConfig config, PublicTypeResolver resolver, NamingConventions naming, string nativeReturnType) - { - // Bare void - if (string.Equals(nativeReturnType, "void", StringComparison.Ordinal)) - { - return ("void", null); - } - - // Special string types (e.g. ufbx_string → string via GetString) - var stringType = config.SpecialTypes.Strings.FirstOrDefault(s => - string.Equals(s.Type, nativeReturnType, StringComparison.Ordinal)); - if (stringType is not null) - { - return ("string", "NativeWrapperHelpers.GetString({0})"); - } - - // Special blob types (e.g. ufbx_blob → ReadOnlySpan via AsSpan) - var blobType = config.SpecialTypes.Blobs.FirstOrDefault(b => - string.Equals(b.Type, nativeReturnType, StringComparison.Ordinal)); - if (blobType is not null) - { - return ($"ReadOnlySpan<{blobType.ElementType}>", "NativeWrapperHelpers.AsSpan({0})"); - } - - var publicType = ResolveGeneratedReturnType(resolver, naming, nativeReturnType); - return (publicType, null); - } - - private static string ResolveGeneratedReturnType(PublicTypeResolver resolver, NamingConventions naming, string nativeReturnType) - { - // Bare void — never convert to void* - if (string.Equals(nativeReturnType, "void", StringComparison.Ordinal)) - { - return "void"; - } - - var pointerDepth = BindingParser.GetPointerDepth(nativeReturnType); - if (pointerDepth == 1) - { - var baseType = BindingParser.TrimPointers(nativeReturnType); - if (resolver.HasWrapper(baseType)) + writer.WriteLine(before); + using (writer.IndentScope()) { - return naming.GetWrapperTypeName(baseType); + EmitNestedWrapCall(writer, wrappedParams, index + 1, emitInner); + } + + if (after.Length > 0) + { + writer.WriteLine(after); + } + } + } + + // ─── Parameter planning ─────────────────────────────────────────────────── + + private static ParameterPlan BuildParameterPlan( + NativeFunction func, + WrapperConfig config, + RoutedMethod routed) + { + var allNativeParams = new List(); + var publicParams = new List(); + + var consumedByDerivesFrom = new HashSet(); + var derivedExprs = new Dictionary(); + var remapHasSibling = new HashSet(); + + for (var i = 0; i < func.Parameters.Count; i++) + { + var param = func.Parameters[i]; + var remap = FindRemap(param, config); + if (remap?.DerivesFrom is null) + { + continue; + } + + var expectedSiblingName = param.Name + remap.DerivesFrom.ParamSuffix; + for (var j = i + 1; j < func.Parameters.Count; j++) + { + if (string.Equals(func.Parameters[j].Name, expectedSiblingName, StringComparison.Ordinal)) + { + consumedByDerivesFrom.Add(j); + derivedExprs[j] = remap.DerivesFrom.Expr.Replace("$arg", param.Name, StringComparison.Ordinal); + remapHasSibling.Add(i); + break; + } } } - return resolver.GetPublicType(nativeReturnType); - } + var selfParamIndex = routed.IsInstance ? 0 : -1; - private static string GetWrapperKind(WrapperConfig config, string nativeTypeName, OwnedTypeConfig? owned) - { - if (owned?.WrapperKind is not null) + for (var i = 0; i < func.Parameters.Count; i++) { - return owned.WrapperKind; + var param = func.Parameters[i]; + var isSelf = i == selfParamIndex; + var isConsumed = consumedByDerivesFrom.Contains(i); + + if (isSelf) + { + allNativeParams.Add(new NativeParamInfo + { + NativeName = param.Name, + PublicName = param.Name, + IsSelfParam = true, + }); + continue; + } + + if (isConsumed) + { + allNativeParams.Add(new NativeParamInfo + { + NativeName = param.Name, + PublicName = param.Name, + IsConsumedByDerivesFrom = true, + DerivedExpr = derivedExprs[i], + }); + continue; + } + + var matchedRemap = FindRemap(param, config); + + if (matchedRemap?.DerivesFrom is not null && !remapHasSibling.Contains(i)) + { + matchedRemap = null; + } + + if (matchedRemap?.Adapter?.ConvertBack is not null) + { + var convertBack = matchedRemap.Adapter.ConvertBack; + var publicParam = new PublicParam + { + PublicType = matchedRemap.Dst, + PublicName = param.Name, + WrapCall = convertBack.WrapCall, + PassAs = convertBack.PassAs, + }; + publicParams.Add(publicParam); + allNativeParams.Add(new NativeParamInfo + { + NativeName = param.Name, + PublicName = param.Name, + PassAs = convertBack.PassAs, + }); + } + else + { + publicParams.Add(new PublicParam + { + PublicType = param.TypeName, + PublicName = param.Name, + }); + allNativeParams.Add(new NativeParamInfo + { + NativeName = param.Name, + PublicName = param.Name, + }); + } } - if (config.Wrappers.Kinds.TryGetValue(nativeTypeName, out var kind)) + return new ParameterPlan { - return kind; - } - - return owned is null ? config.Wrappers.DefaultKind : config.Wrappers.DefaultOwnedKind; - } - - private static string GetWrapperDeclaration(string wrapperName, string wrapperKind, bool implementsIDisposable = false) - { - var baseDeclaration = wrapperKind switch - { - "class" => $"class {wrapperName}", - "ref struct" => $"ref struct {wrapperName}", - "readonly ref struct" => $"readonly ref struct {wrapperName}", - _ => $"struct {wrapperName}", - }; - - if (implementsIDisposable && wrapperKind == "class") - { - return $"{baseDeclaration} : IDisposable"; - } - - return baseDeclaration; - } - - private static string GetPointerFieldDeclaration(string nativeTypeName, string wrapperKind) - { - return wrapperKind switch - { - "class" => $"private {nativeTypeName}* _ptr;", - "ref struct" => $"private {nativeTypeName}* _ptr;", - "readonly ref struct" => $"private readonly {nativeTypeName}* _ptr;", - _ => $"private {nativeTypeName}* _ptr;", + PublicParams = publicParams, + AllNativeParams = allNativeParams, }; } - private static string GetSafePropertyName(string wrapperName, string propertyName) + private static string StripPrefix(string name, string? prefix) { - if (string.Equals(wrapperName, propertyName, StringComparison.Ordinal)) + if (string.IsNullOrEmpty(prefix)) { - return propertyName + "Value"; + return name; } - return propertyName; + if (name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) + { + return name[prefix.Length..]; + } + + return name; } - private sealed record GeneratedMethod(string SignatureLine, IReadOnlyList BodyLines); + private static RemapConfig? FindRemap(NativeParameter param, WrapperConfig config) + { + foreach (var remap in config.Remaps) + { + if (!remap.Scope.Contains("parameter", StringComparer.Ordinal)) + { + continue; + } + + if (!string.Equals(remap.Src, param.TypeName, StringComparison.Ordinal)) + { + continue; + } + + if (remap.Filter is { Count: > 0 } filters) + { + var matches = filters.Any(f => + Regex.IsMatch(param.Name, f, RegexOptions.IgnoreCase)); + if (!matches) + { + continue; + } + } + + return remap; + } + + return null; + } + + // ─── Inner types ────────────────────────────────────────────────────────── + + private sealed class RoutedMethod + { + public required NativeFunction Function { get; init; } + public required string TargetStructName { get; init; } + public required bool IsInstance { get; init; } + /// The specific INSTANCE_METHOD/STATIC_METHOD apply step that produced this method. + public required ActionApplyConfig Apply { get; init; } + } + + private sealed class ParameterPlan + { + public required List PublicParams { get; init; } + public required List AllNativeParams { get; init; } + } + + private sealed class PublicParam + { + public required string PublicType { get; init; } + public required string PublicName { get; init; } + public string? WrapCall { get; init; } + public string? PassAs { get; init; } + } + + private sealed class NativeParamInfo + { + public required string NativeName { get; init; } + public required string PublicName { get; init; } + public bool IsSelfParam { get; init; } + public bool IsConsumedByDerivesFrom { get; init; } + public string? DerivedExpr { get; init; } + public string? PassAs { get; init; } + } } diff --git a/src/Tools/Ghost.NativeWrapperGen/Parsing/BindingParser.cs b/src/Tools/Ghost.NativeWrapperGen/Parsing/BindingParser.cs index be5a4c3..143bb2f 100644 --- a/src/Tools/Ghost.NativeWrapperGen/Parsing/BindingParser.cs +++ b/src/Tools/Ghost.NativeWrapperGen/Parsing/BindingParser.cs @@ -82,7 +82,7 @@ public sealed class BindingParser ReturnType = NormalizeType(method.ReturnType.ToString()), Parameters = method.ParameterList.Parameters.Select(static p => new NativeParameter { - Name = p.Identifier.ValueText, + Name = p.Identifier.Text, // .Text preserves @ prefix for reserved keywords (e.g. @params, @base) TypeName = NormalizeType(p.Type?.ToString() ?? "void"), }).ToArray(), IsDllImport = method.AttributeLists.SelectMany(static a => a.Attributes).Any(static a => a.Name.ToString().Contains("DllImport", StringComparison.Ordinal)), diff --git a/src/Tools/Ghost.NativeWrapperGen/Transform/BindingTypeResolver.cs b/src/Tools/Ghost.NativeWrapperGen/Transform/BindingTypeResolver.cs new file mode 100644 index 0000000..da0fd9c --- /dev/null +++ b/src/Tools/Ghost.NativeWrapperGen/Transform/BindingTypeResolver.cs @@ -0,0 +1,38 @@ +using Ghost.NativeWrapperGen.Model; +using Ghost.NativeWrapperGen.Parsing; + +namespace Ghost.NativeWrapperGen.Transform; + +/// +/// Resolves whether a given C# type is a pointer to a known binding struct. +/// Used by the emitter to apply the SELF_PTR / RETURN_BINDING_TYPE action conditions. +/// +public sealed class BindingTypeResolver +{ + private readonly NativeLibrary _library; + + public BindingTypeResolver(NativeLibrary library) + { + _library = library; + } + + /// + /// Returns the base struct name if is a single-pointer to a known binding struct, + /// otherwise returns null. + /// Example: "ufbx_scene*" → "ufbx_scene", "ufbx_scene**" → null, "sbyte*" → null. + /// + public string? TryGetBindingStructName(string typeName) + { + if (BindingParser.GetPointerDepth(typeName) != 1) + { + return null; + } + + var baseName = BindingParser.TrimPointers(typeName); + return _library.StructsByName.ContainsKey(baseName) ? baseName : null; + } + + /// Returns true if the type is a known binding struct (without pointer). + public bool IsBindingStruct(string typeName) => + _library.StructsByName.ContainsKey(typeName); +} diff --git a/src/Tools/Ghost.NativeWrapperGen/Transform/JsonConverter.cs b/src/Tools/Ghost.NativeWrapperGen/Transform/JsonConverter.cs new file mode 100644 index 0000000..d89f184 --- /dev/null +++ b/src/Tools/Ghost.NativeWrapperGen/Transform/JsonConverter.cs @@ -0,0 +1,59 @@ +using System.Dynamic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Ghost.NativeWrapperGen.Transform; + +internal class DynamicJsonConverter : JsonConverter +{ + public override dynamic Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + // Parse the JSON into a strict JsonElement, then wrap it in our dynamic class + using var document = JsonDocument.ParseValue(ref reader); + return DynamicJsonWrapper.Wrap(document.RootElement.Clone())!; + } + + public override void Write(Utf8JsonWriter writer, dynamic value, JsonSerializerOptions options) + { + // (Skipped for brevity, but you would serialize the object back here if needed) + throw new NotImplementedException(); + } +} + +internal class DynamicJsonWrapper : DynamicObject +{ + private readonly JsonElement _element; + + public DynamicJsonWrapper(JsonElement element) + { + _element = element; + } + + // This method intercepts dynamic property access (e.g., .NestedValue) + public override bool TryGetMember(GetMemberBinder binder, out object? result) + { + if (_element.ValueKind == JsonValueKind.Object && _element.TryGetProperty(binder.Name, out var property)) + { + result = Wrap(property); + return true; // Property found! + } + + result = null; + return true; // Property not found — return null instead of throwing RuntimeBinderException. + } + + // Converts JsonElements into primitives or wraps nested objects + public static object? Wrap(JsonElement element) + { + return element.ValueKind switch + { + JsonValueKind.Object => new DynamicJsonWrapper(element), + JsonValueKind.String => element.GetString(), + JsonValueKind.Number => element.TryGetInt32(out int i) ? i : element.GetDouble(), + JsonValueKind.Array => element.EnumerateArray().Select(Wrap).ToArray(), + JsonValueKind.True => true, + JsonValueKind.False => false, + _ => null + }; + } +} \ No newline at end of file diff --git a/src/Tools/Ghost.NativeWrapperGen/Transform/NamingConventions.cs b/src/Tools/Ghost.NativeWrapperGen/Transform/NamingConventions.cs index 27b7840..b2bbbd3 100644 --- a/src/Tools/Ghost.NativeWrapperGen/Transform/NamingConventions.cs +++ b/src/Tools/Ghost.NativeWrapperGen/Transform/NamingConventions.cs @@ -11,39 +11,91 @@ public sealed class NamingConventions _config = config; } - public string GetWrapperTypeName(string nativeTypeName) + /// + /// Converts a native function name to a method name using the action's name.remove chain. + /// Each entry in the remove list is applied in order, then leading/trailing underscores are trimmed. + /// + /// Supported remove tokens: + /// "PREFIX" — strip the config's NativeTypePrefix from the start (e.g. "nvtt", "ufbx_") + /// "NO_PREFIX($TSelf)" — strip the target struct name minus its type prefix from the start, + /// case-insensitively (e.g. NvttSurface → "Surface" stripped from "SurfaceWidth") + /// + /// nameOpts is the dynamic opts.name object from JSON (may be null). + /// If no nameOpts are provided, the name is returned with only the library prefix stripped. + /// + public string GetMethodName(string nativeFunctionName, dynamic? nameOpts, string targetStructName) { - if (_config.TypeNameOverrides.TryGetValue(nativeTypeName, out var overrideName)) + var name = nativeFunctionName; + + if (nameOpts is null) { - return overrideName; + // Fallback: just strip the library prefix. + return TrimUnderscores(StripPrefixIgnoreCase(name, _config.NativeTypePrefix)); } - return ToPascalCase(StripKnownPrefix(nativeTypeName)); - } - - public string GetPropertyName(string nativeName) - { - return ToPascalCase(nativeName); - } - - private string StripKnownPrefix(string nativeTypeName) - { - if (nativeTypeName.StartsWith(_config.NativeTypePrefix, StringComparison.Ordinal)) + string? set = nameOpts.set as string; + if (!string.IsNullOrEmpty(set)) { - return nativeTypeName[_config.NativeTypePrefix.Length..]; + return set; } - return nativeTypeName; - } - - public static string ToPascalCase(string value) - { - var parts = value.Split('_', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); - if (parts.Length == 0) + var removeTokens = nameOpts.remove as object?[] ?? []; + foreach (var tokenObj in removeTokens) { - return value; + var token = tokenObj as string ?? string.Empty; + if (string.Equals(token, "PREFIX", StringComparison.Ordinal)) + { + name = StripPrefixIgnoreCase(name, _config.NativeTypePrefix); + } + else if (token.StartsWith("NO_PREFIX(", StringComparison.Ordinal) && token.EndsWith(')')) + { + // Extract $TSelf — it's the literal token "NO_PREFIX($TSelf)", so the struct name + // is resolved from the targetStructName argument passed in. + // Strip the config prefix from the struct name to get the "bare" part. + // Try prefix first, then suffix (handles both nvtt "SurfaceWidth"→"Width" + // and ufbx "free_scene"→"free_" styles). + var bareStructName = StripPrefixIgnoreCase(targetStructName, _config.NativeTypePrefix); + + // Remove directly, the name maybe nvttSetOutputOptionsOutputHeader, if we only remove prefix and suffix, OutputOptions in the middle will be ignored, so we remove the bare struct name directly, case-insensitively. + name = name.Replace(bareStructName, string.Empty, StringComparison.OrdinalIgnoreCase); + } + + name = TrimUnderscores(name); } - return string.Concat(parts.Select(static part => char.ToUpperInvariant(part[0]) + part[1..])); + return name; + } + + /// Strips the native type prefix (e.g. "ufbx_") from a type name. + public string StripKnownPrefix(string nativeTypeName) + { + return StripPrefixIgnoreCase(nativeTypeName, _config.NativeTypePrefix); + } + + // ─── Helpers ────────────────────────────────────────────────────────────── + + private static string StripPrefixIgnoreCase(string name, string prefix) + { + if (name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) + { + return name[prefix.Length..]; + } + + return name; + } + + private static string StripSuffixIgnoreCase(string name, string suffix) + { + if (name.EndsWith(suffix, StringComparison.OrdinalIgnoreCase)) + { + return name[..^suffix.Length]; + } + + return name; + } + + private static string TrimUnderscores(string name) + { + return name.Trim('_'); } } diff --git a/src/Tools/Ghost.NativeWrapperGen/Transform/PublicTypeResolver.cs b/src/Tools/Ghost.NativeWrapperGen/Transform/PublicTypeResolver.cs deleted file mode 100644 index f48b8b1..0000000 --- a/src/Tools/Ghost.NativeWrapperGen/Transform/PublicTypeResolver.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Ghost.NativeWrapperGen.Config; -using Ghost.NativeWrapperGen.Model; -using Ghost.NativeWrapperGen.Parsing; - -namespace Ghost.NativeWrapperGen.Transform; - -public sealed class PublicTypeResolver -{ - private readonly NativeLibrary _library; - private readonly WrapperConfig _config; - private readonly NamingConventions _naming; - - public PublicTypeResolver(NativeLibrary library, WrapperConfig config, NamingConventions naming) - { - _library = library; - _config = config; - _naming = naming; - } - - public string GetPublicType(string nativeTypeName) - { - if (string.Equals(nativeTypeName, "void", StringComparison.Ordinal)) - { - return "void*"; - } - - if (_config.PublicTypeOverrides.TryGetValue(nativeTypeName, out var overrideType)) - { - return overrideType; - } - - var pointerDepth = BindingParser.GetPointerDepth(nativeTypeName); - var baseType = BindingParser.TrimPointers(nativeTypeName); - - if (pointerDepth == 0) - { - return baseType; - } - - if (_library.StructsByName.ContainsKey(baseType)) - { - return pointerDepth switch - { - 1 => _naming.GetWrapperTypeName(baseType), - _ => nativeTypeName, - }; - } - - return nativeTypeName; - } - - public bool HasWrapper(string nativeTypeName) - { - return _library.StructsByName.ContainsKey(nativeTypeName); - } -} diff --git a/src/Tools/Ghost.NativeWrapperGen/configs/nvtt.json b/src/Tools/Ghost.NativeWrapperGen/configs/nvtt.json new file mode 100644 index 0000000..6efab19 --- /dev/null +++ b/src/Tools/Ghost.NativeWrapperGen/configs/nvtt.json @@ -0,0 +1,96 @@ +{ + "libraryName": "nvtt", + "nativeNamespace": "Ghost.Nvtt", + "outputNamespace": "Ghost.Nvtt", + "nativeTypePrefix": "Nvtt", + "skipTypes": [ + "NativeAnnotationAttribute", + "NativeTypeNameAttribute" + ], + "skipFunctions": [], + + "remaps": [ + { + // sbyte* parameters whose names match name/filename/path/prop patterns + // get remapped to ReadOnlySpan, with a fixed() wrapper and _len sibling consumed. + "src": "sbyte*", + "dst": "ReadOnlySpan", + "scope": [ "parameter" ], + "filter": [ ".*name", ".*filename", ".*path", ".*prop$" ], + "adapter": { + "convertBack": { + "wrapCall": "fixed (byte* p$arg = $arg) { $CALL }", + "passAs": "(sbyte*)p$arg" + } + } + } + ], + + "actions": [ + { + // Dispose pattern: void return + T* param + name matches .*Destroy → IDisposable.Dispose on T + // Must come BEFORE the general INSTANCE_METHOD rule so it matches first. + "comment": "Dispose pattern: void return + T* param → Dispose method on T", + "filter": "EXTERN_API", + "conditions": [ "VOID_RETURN", "SELF_PTR", "NAME_CONDITION(.*Destroy$TBare)" ], + "targetType": "FIRST_PARAM_TYPE", + "apply": [ + { + "type": "INSTANCE_METHOD", + "opts": { + "removeFirstParam": true, + "passAs": "($TSelf*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)", + "name": { + "set": "Dispose" + } + } + }, + { + "type": "INHERITANCE", + "opts": { + "baseType": [ "System.IDisposable" ] + } + } + ] + }, + { + // Instance method: first param is T* of a known binding struct → method on T + "comment": "First param is T* of a known binding struct → instance method on T", + "filter": "EXTERN_API", + "conditions": [ "SELF_PTR" ], + "targetType": "FIRST_PARAM_TYPE", + "apply": { + "type": "INSTANCE_METHOD", + "opts": { + "removeFirstParam": true, + "passAs": "($TSelf*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)", + // Change "nvttCreateSurface" to "Create" + "name": { + "remove": [ + "PREFIX", + "NO_PREFIX($TSelf)" // NO_PREFIX(NvttSurface) will change "NvttSurface" to "Surface", the prefix is determined by the "nativeTypePrefix" field at the top level of this config + ] + } + } + } + }, + { + // Static method: first param is NOT a known struct pointer, but return type is T* → static on T + "comment": "Return type is T* of a known binding struct → static method on T", + "filter": "EXTERN_API", + "conditions": [ "FIRST_PARAM_OTHER_TYPE", "RETURN_BINDING_TYPE" ], + "targetType": "RETURN_TYPE", + "apply": { + "type": "STATIC_METHOD", + "opts": { + "name": { + "remove": [ + "PREFIX", + "NO_PREFIX($TSelf)" + ] + } + } + } + } + ] +} diff --git a/src/Tools/Ghost.NativeWrapperGen/configs/ufbx.json b/src/Tools/Ghost.NativeWrapperGen/configs/ufbx.json index e096d2e..efd1f21 100644 --- a/src/Tools/Ghost.NativeWrapperGen/configs/ufbx.json +++ b/src/Tools/Ghost.NativeWrapperGen/configs/ufbx.json @@ -1,221 +1,71 @@ { "libraryName": "ufbx", "nativeNamespace": "Ghost.Ufbx", - "wrapperNamespace": "Ghost.Ufbx", + "outputNamespace": "Ghost.Ufbx", "nativeTypePrefix": "ufbx_", - "staticApiClassName": "Ufbx", "skipTypes": [ "NativeAnnotationAttribute", "NativeTypeNameAttribute" ], - "wrappers": { - "defaultKind": "struct", - "defaultOwnedKind": "class", - "kinds": { - "ufbx_node": "ref struct", - "ufbx_mesh": "ref struct", - "ufbx_element": "ref struct", - "ufbx_anim": "ref struct", - "ufbx_material": "ref struct", - "ufbx_texture": "ref struct", - "ufbx_props": "ref struct", - "ufbx_prop": "ref struct", - "ufbx_load_opts": "class" - } - }, - "specialTypes": { - "strings": [ - { - "type": "ufbx_string", - "dataField": "data", - "lengthField": "length", - "charSize": 8, - "encoding": "utf8", - "emitRawSpanProperty": true, - "emitStringProperty": true + "skipFunctions": [], + + "remaps": [ + { + // sbyte* parameters whose names match name/filename/path/prop patterns + // get remapped to ReadOnlySpan, with a fixed() wrapper and _len sibling consumed. + "src": "sbyte*", + "dst": "ReadOnlySpan", + "scope": [ "parameter" ], + "filter": [ ".*name", ".*filename", ".*path", ".*prop$" ], + "derivesFrom": { "paramSuffix": "_len", "expr": "(nuint)$arg.Length" }, + "adapter": { + "convertBack": { + "wrapCall": "fixed (byte* p$arg = $arg) { $CALL }", + "passAs": "(sbyte*)p$arg" + } } - ], - "blobs": [ - { - "type": "ufbx_blob", - "dataField": "data", - "lengthField": "size", - "elementType": "byte" + } + ], + + "actions": [ + { + // Instance method: first param is T* of a known binding struct → method on T + "comment": "First param is T* of a known binding struct → instance method on T", + "filter": "EXTERN_API", + "conditions": [ "SELF_PTR" ], + "targetType": "FIRST_PARAM_TYPE", + "apply": { + "type": "INSTANCE_METHOD", + "opts": { + "removeFirstParam": true, + "passAs": "($TSelf*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)", + // Change "ufbx_free_scene" to "free" + "name": { + "remove": [ + "PREFIX", + "NO_PREFIX($TSelf)" // NO_PREFIX(ufbx_scene) will output "scene" change "free_scene" to "free", the prefix is determined by the "nativeTypePrefix" field at the top level of this config + ] + } + } } - ] - }, - "ownedTypes": [ + }, { - "nativeType": "ufbx_scene", - "freeFunction": "ufbx_free_scene", - "retainFunction": "ufbx_retain_scene", - "wrapperKind": "class" + // Static method: first param is NOT a known struct pointer, but return type is T* → static on T + "comment": "Return type is T* of a known binding struct → static method on T", + "filter": "EXTERN_API", + "conditions": [ "FIRST_PARAM_OTHER_TYPE", "RETURN_BINDING_TYPE" ], + "targetType": "RETURN_TYPE", + "apply": { + "type": "STATIC_METHOD", + "opts": { + "name": { + "remove": [ + "PREFIX", + "NO_PREFIX($TSelf)" + ] + } + } + } } - ], - "staticMethods": [ - { - "nativeFunction": "ufbx_load_file_len", - "methodName": "LoadFile", - "throwOnNullReturn": true, - "failureMessageMember": "description", - "parameters": [ - { - "native": "filename", - "adapter": "utf8Path", - "publicName": "pathUtf8" - }, - { - "native": "filename_len", - "adapter": "utf8Length", - "source": "pathUtf8" - }, - { - "native": "opts", - "adapter": "getPtr", - "type": "LoadOpts", - "publicName": "options" - }, - { - "native": "error", - "adapter": "errorOut", - "type": "ufbx_error", - "publicName": "error" - } - ] - }, - { - "nativeFunction": "ufbx_load_memory", - "methodName": "LoadMemory", - "throwOnNullReturn": true, - "failureMessageMember": "description", - "parameters": [ - { - "native": "data", - "adapter": "byteSpan", - "publicName": "data" - }, - { - "native": "data_size", - "adapter": "byteSpanLength", - "source": "data" - }, - { - "native": "opts", - "adapter": "inValue", - "type": "ufbx_load_opts", - "publicName": "options", - "optionalDefault": true - }, - { - "native": "error", - "adapter": "errorOut", - "type": "ufbx_error", - "publicName": "error" - } - ] - }, - { - "nativeFunction": "ufbx_find_node_len", - "methodName": "FindNode", - "parameters": [ - { - "native": "name", - "adapter": "utf8Path", - "publicName": "name" - }, - { - "native": "name_len", - "adapter": "utf8Length", - "source": "name" - } - ] - }, - { - "nativeFunction": "ufbx_find_element_len", - "methodName": "FindElement", - "parameters": [ - { - "native": "name", - "adapter": "utf8Path", - "publicName": "name" - }, - { - "native": "name_len", - "adapter": "utf8Length", - "source": "name" - } - ] - }, - { - "nativeFunction": "ufbx_find_material_len", - "methodName": "FindMaterial", - "parameters": [ - { - "native": "name", - "adapter": "utf8Path", - "publicName": "name" - }, - { - "native": "name_len", - "adapter": "utf8Length", - "source": "name" - } - ] - }, - { - "nativeFunction": "ufbx_find_anim_stack_len", - "methodName": "FindAnimStack", - "parameters": [ - { - "native": "name", - "adapter": "utf8Path", - "publicName": "name" - }, - { - "native": "name_len", - "adapter": "utf8Length", - "source": "name" - } - ] - }, - { - "nativeFunction": "ufbx_find_prop_len", - "methodName": "FindProp", - "parameters": [ - { - "native": "name", - "adapter": "utf8Path", - "publicName": "name" - }, - { - "native": "name_len", - "adapter": "utf8Length", - "source": "name" - } - ] - } - ], - "marshalledTypes": [ - { - "nativeType": "ufbx_load_opts", - "marshalledProperties": [ - { - "native": "obj_mtl_path", - "type": "cstring" - }, - { - "native": "filename", - "type": "cstring" - } - ] - } - ], - "typeNameOverrides": { - "ufbx_string": "UfbxString", - "ufbx_blob": "UfbxBlob" - }, - "publicTypeOverrides": { - "ufbx_string": "string", - "ufbx_blob": "ReadOnlySpan" - } + ] }