From 55a910587027e01c42f3d061316604accb3acb85 Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Thu, 30 Jan 2025 12:59:52 +0100 Subject: [PATCH] com.atteneder.gltfast Release 6.10.1 --- CHANGELOG.md | 27 ++ Documentation~/ProjectSetup.md | 15 +- Documentation~/config.json | 2 +- Runtime/Scripts/Export/Constants.cs | 2 +- Runtime/Scripts/Jobs.cs | 472 ++++++++++++++++++- Runtime/Scripts/MeshGenerator.cs | 41 +- Runtime/Scripts/UvTransform.cs | 4 + Runtime/Scripts/VertexBufferBones.cs | 26 +- Runtime/Scripts/VertexBufferColors.cs | 20 +- Runtime/Scripts/VertexBufferGenerator.cs | 1 + Runtime/Scripts/VertexBufferGeneratorBase.cs | 86 +++- Runtime/Scripts/VertexBufferTexCoords.cs | 46 +- Runtime/Scripts/glTFast.asmdef | 11 + package.json | 6 +- 14 files changed, 675 insertions(+), 84 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2867bf2..d7718b1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,33 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [6.10.1] - 2025-01-09 + +### Added +- Test for `ConvertBoneWeightsUInt8ToFloatInterleavedJob` +- Test for `ConvertBoneWeightsUInt16ToFloatInterleavedJob` +- *BoundsTests* which certifies correct mesh bounds. + +### Changed +- Downgraded package dependencies to version bundled with Editor. + - `com.unity.collections` to version `1.2.4` (from `1.5.1`) + - `com.unity.mathematics` to version `1.2.6` (from `1.3.1`) +- When a position accessor lacks min/max properties, the corresponding error message is communicated via the `ICodeLogger` instead of a plain console log. + +### Fixed +- Build error when used along with packages that depend on `com.unity.collections` versions older than 1.5 (e.g. Polyspatial 1.x; fixes [#730](https://github.com/atteneder/glTFast/issues/730)). +- Invalid mesh bounds on meshes with one submesh (fixes [#743](https://github.com/atteneder/glTFast/issues/743)). + +### Removed + + +### Deprecated + + +### Security + + + ## [6.10.0] - 2024-12-16 ### Added diff --git a/Documentation~/ProjectSetup.md b/Documentation~/ProjectSetup.md index e6b57930..96c5ed45 100644 --- a/Documentation~/ProjectSetup.md +++ b/Documentation~/ProjectSetup.md @@ -47,6 +47,16 @@ Built-In render pipe projects can optionally use the shader graphs instead of th For example, if you don't need PNG/Jpeg support (because you use only KTX™ 2.0 textures or no textures at all), you can disable the *Image Conversion* and *UnityWebRequestTexture* modules. +## Performance Increase via Collections Package + +> [!CAUTION] +> Don't apply this if your project or one of its packages (e.g. [Polyspatial 1.3]) has a dependency on [Collections] 1.4 or older. Unfortunately [Collections] version 1.5.0 introduced breaking changes that might lead to compiler errors otherwise. + +Projects running Editor versions 2020 or 2021 can increase the performance of certain low-level C# jobs by upgrading the [Collections] package to version 1.5.1 (or newer). *glTFast* then utilizes [IJobParallelForBatch] for increased loading speed. + +> [!NOTE] +> Performance measurements showed that in Unity 2022 and later the Burst compiler has gotten so advanced that performance is excellent out-of-the-box and adjusting the [Collections] package versions makes little to no difference. + ## Readable Mesh Data By default *Unity glTFast* discards mesh data after it was uploaded to the GPU to free up main memory (see [`markNoLongerReadable`](https://docs.unity3d.com/ScriptReference/Mesh.UploadMeshData.html)). You can disable this globally by using the scripting define `GLTFAST_KEEP_MESH_DATA`. @@ -75,9 +85,10 @@ add `GLTFAST_EDITOR_IMPORT_OFF` to the *Scripting Define Symbols* in the *Player *KTX™* and the KTX logo are trademarks of the [The Khronos Group Inc][khronos]. -[ImgConv]: https://docs.unity3d.com/2021.3/Documentation/ScriptReference/UnityEngine.ImageConversionModule.html +[Collections]: https://docs.unity3d.com/Packages/com.unity.collections@1.5/manual/index.html +[IJobParallelForBatch]: https://docs.unity3d.com/Packages/com.unity.collections@1.5/api/Unity.Jobs.IJobParallelForBatch.html?q=IJobParallelForBatch [Khronos]: https://www.khronos.org [MRTK]: https://github.com/microsoft/MixedRealityToolkit-Unity +[Polyspatial 1.3]: https://docs.unity3d.com/Packages/com.unity.polyspatial.visionos@1.3/manual/index.html [shader-variants]: https://docs.unity3d.com/Manual/shader-variants.html [Unity]: https://unity.com -[uwrt]: https://docs.unity3d.com/2021.3/Documentation/ScriptReference/UnityEngine.UnityWebRequestTextureModule.html diff --git a/Documentation~/config.json b/Documentation~/config.json index df2b0d87..b73898e2 100644 --- a/Documentation~/config.json +++ b/Documentation~/config.json @@ -1,3 +1,3 @@ { - "DefineConstants": "DRACO_UNITY;KTX_UNITY;KTX_UNITY_1_3_OR_NEWER;KTX_UNITY_2_2_OR_NEWER;USING_URP;USING_HDRP;USING_HDRP_10_OR_NEWER;UNITY_PHYSICS;UNITY_IMAGECONVERSION;UNITY_WEBREQUEST_TEXTURE;MESHOPT;USING_URP_12_OR_NEWER;UNITY_SHADER_GRAPH;UNITY_SHADER_GRAPH_12_OR_NEWER;UNITY_ANIMATION;UNITY_ENTITIES_GRAPHICS;NEWTONSOFT_JSON" + "DefineConstants": "DRACO_UNITY;KTX_UNITY;KTX_UNITY_1_3_OR_NEWER;KTX_UNITY_2_2_OR_NEWER;USING_URP;USING_HDRP;USING_HDRP_10_OR_NEWER;UNITY_PHYSICS;UNITY_IMAGECONVERSION;UNITY_WEBREQUEST_TEXTURE;MESHOPT;USING_URP_12_OR_NEWER;UNITY_SHADER_GRAPH;UNITY_SHADER_GRAPH_12_OR_NEWER;UNITY_ANIMATION;UNITY_ENTITIES_GRAPHICS;NEWTONSOFT_JSON;UNITY_COLLECTIONS" } \ No newline at end of file diff --git a/Runtime/Scripts/Export/Constants.cs b/Runtime/Scripts/Export/Constants.cs index 46a21c88..c6d9149d 100644 --- a/Runtime/Scripts/Export/Constants.cs +++ b/Runtime/Scripts/Export/Constants.cs @@ -7,7 +7,7 @@ namespace GLTFast.Export { static class Constants { - public const string version = "6.10.0"; + public const string version = "6.10.1"; internal const string mimeTypePNG = "image/png"; internal const string mimeTypeJPG = "image/jpeg"; diff --git a/Runtime/Scripts/Jobs.cs b/Runtime/Scripts/Jobs.cs index 6166a60e..aaba50ae 100644 --- a/Runtime/Scripts/Jobs.cs +++ b/Runtime/Scripts/Jobs.cs @@ -643,7 +643,12 @@ public void Execute(int i) // } [BurstCompile] - unsafe struct ConvertUVsUInt8ToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertUVsUInt8ToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] public int inputByteStride; @@ -659,6 +664,7 @@ unsafe struct ConvertUVsUInt8ToFloatInterleavedJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float2* result; +#if UNITY_COLLECTIONS public void Execute(int index, int count) { var resultV = (float2*)((byte*)result + index * outputByteStride); @@ -671,6 +677,14 @@ public void Execute(int index, int count) off += inputByteStride; } } +#else + public void Execute(int i) + { + var resultV = (float2*)(((byte*)result) + (i * outputByteStride)); + var off = input + inputByteStride * i; + *resultV = new float2(off[0], 1 - off[1]); + } +#endif } [BurstCompile] @@ -705,7 +719,12 @@ public void Execute(int i) } [BurstCompile] - unsafe struct ConvertUVsUInt16ToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertUVsUInt16ToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -722,6 +741,7 @@ unsafe struct ConvertUVsUInt16ToFloatInterleavedJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float2* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float2*)((byte*)result + i * outputByteStride); @@ -734,6 +754,14 @@ public void Execute(int i, int count) uv = (ushort*)((byte*)uv + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float2*)(((byte*)result) + (i * outputByteStride)); + var uv = (ushort*)(input + inputByteStride * i); + *resultV = new float2(uv[0], 1 - uv[1]); + } +#endif } [BurstCompile] @@ -768,7 +796,12 @@ public void Execute(int i) } [BurstCompile] - unsafe struct ConvertUVsInt16ToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertUVsInt16ToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -785,6 +818,7 @@ unsafe struct ConvertUVsInt16ToFloatInterleavedJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float2* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float2*)((byte*)result + i * outputByteStride); @@ -797,10 +831,23 @@ public void Execute(int i, int count) uv = (short*)((byte*)uv + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float2*)(((byte*)result) + (i * outputByteStride)); + var uv = (short*)((byte*)input + inputByteStride * i); + *resultV = new float2(uv[0], 1 - uv[1]); + } +#endif } [BurstCompile] - unsafe struct ConvertUVsInt16ToFloatInterleavedNormalizedJob : IJobParallelForBatch + unsafe struct ConvertUVsInt16ToFloatInterleavedNormalizedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -817,6 +864,7 @@ unsafe struct ConvertUVsInt16ToFloatInterleavedNormalizedJob : IJobParallelForBa [NativeDisableUnsafePtrRestriction] public float2* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float2*)((byte*)result + i * outputByteStride); @@ -833,10 +881,27 @@ public void Execute(int i, int count) uv = (short*)((byte*)uv + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float2*)(((byte*)result) + (i * outputByteStride)); + var uv = (short*)((byte*)input + inputByteStride * i); + + var tmp = new float2(uv[0], uv[1]) / short.MaxValue; + var tmp2 = max(tmp, -1f); + tmp2.y = 1 - tmp2.y; + *resultV = tmp2; + } +#endif } [BurstCompile] - unsafe struct ConvertUVsInt8ToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertUVsInt8ToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -853,6 +918,7 @@ unsafe struct ConvertUVsInt8ToFloatInterleavedJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float2* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float2*)((byte*)result + i * outputByteStride); @@ -865,10 +931,23 @@ public void Execute(int i, int count) off += inputByteStride; } } +#else + public void Execute(int i) + { + var resultV = (float2*)(((byte*)result) + (i * outputByteStride)); + var off = input + inputByteStride * i; + *resultV = new float2(off[0], 1 - off[1]); + } +#endif } [BurstCompile] - unsafe struct ConvertUVsInt8ToFloatInterleavedNormalizedJob : IJobParallelForBatch + unsafe struct ConvertUVsInt8ToFloatInterleavedNormalizedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -885,6 +964,7 @@ unsafe struct ConvertUVsInt8ToFloatInterleavedNormalizedJob : IJobParallelForBat [NativeDisableUnsafePtrRestriction] public float2* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float2*)((byte*)result + i * outputByteStride); @@ -901,6 +981,17 @@ public void Execute(int i, int count) off += inputByteStride; } } +#else + public void Execute(int i) + { + var resultV = (float2*)(((byte*)result) + (i * outputByteStride)); + var off = input + inputByteStride * i; + var tmp = new float2(off[0], off[1]) / 127f; + var tmp2 = max(tmp, -1f); + tmp2.y = 1 - tmp2.y; + *resultV = tmp2; + } +#endif } [BurstCompile] @@ -974,7 +1065,12 @@ public void Execute(int i) } [BurstCompile] - unsafe struct ConvertColorsRgbaUInt16ToRGBAFloatJob : IJobParallelForBatch + unsafe struct ConvertColorsRgbaUInt16ToRGBAFloatJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -988,6 +1084,7 @@ unsafe struct ConvertColorsRgbaUInt16ToRGBAFloatJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float4* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var src = (ushort*)((byte*)input + i * inputByteStride); @@ -1003,10 +1100,27 @@ public void Execute(int i, int count) src = (ushort*)((byte*)src + inputByteStride); } } +#else + public void Execute(int i) + { + var src = (ushort*)(((byte*)input) + (i * inputByteStride)); + result[i] = new float4( + src[0] / (float)ushort.MaxValue, + src[1] / (float)ushort.MaxValue, + src[2] / (float)ushort.MaxValue, + src[3] / (float)ushort.MaxValue + ); + } +#endif } [BurstCompile] - unsafe struct ConvertColorsRGBAFloatToRGBAFloatJob : IJobParallelForBatch + unsafe struct ConvertColorsRGBAFloatToRGBAFloatJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1020,6 +1134,7 @@ unsafe struct ConvertColorsRGBAFloatToRGBAFloatJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float4* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var src = (float4*)(input + i * inputByteStride); @@ -1030,6 +1145,13 @@ public void Execute(int i, int count) src = (float4*)((byte*)src + inputByteStride); } } +#else + public void Execute(int i) + { + var src = (float4*)(input + (i * inputByteStride)); + result[i] = *src; + } +#endif } [BurstCompile] @@ -1169,7 +1291,12 @@ public void Execute(int i) } [BurstCompile] - unsafe struct ConvertUVsFloatToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertUVsFloatToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1186,6 +1313,7 @@ unsafe struct ConvertUVsFloatToFloatInterleavedJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float2* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float2*)((byte*)result + i * outputByteStride); @@ -1201,13 +1329,28 @@ public void Execute(int i, int count) off = (float2*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float2*)(((byte*)result) + (i * outputByteStride)); + var off = (float2*)(input + (i * inputByteStride)); + var tmp = *off; + tmp.y = 1 - tmp.y; + *resultV = tmp; + } +#endif } /// /// General purpose vector 3 (position or normal) conversion /// [BurstCompile] - unsafe struct ConvertVector3FloatToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertVector3FloatToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1224,6 +1367,7 @@ unsafe struct ConvertVector3FloatToFloatInterleavedJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float3* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1239,6 +1383,16 @@ public void Execute(int i, int count) off = (float3*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + var off = (float3*)(input + i * inputByteStride); + var tmp = *off; + tmp.x *= -1; + *resultV = tmp; + } +#endif } /// @@ -1279,7 +1433,12 @@ public void Execute(int i) } [BurstCompile] - unsafe struct ConvertTangentsFloatToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertTangentsFloatToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1296,6 +1455,7 @@ unsafe struct ConvertTangentsFloatToFloatInterleavedJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float4* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float4*)((byte*)result + i * outputByteStride); @@ -1311,10 +1471,25 @@ public void Execute(int i, int count) off = (float4*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float4*)(((byte*)result) + (i * outputByteStride)); + var off = input + (i * inputByteStride); + var tmp = *((float4*)off); + tmp.z *= -1; + *resultV = tmp; + } +#endif } [BurstCompile] - unsafe struct ConvertBoneWeightsFloatToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertBoneWeightsFloatToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1331,6 +1506,7 @@ unsafe struct ConvertBoneWeightsFloatToFloatInterleavedJob : IJobParallelForBatc [NativeDisableUnsafePtrRestriction] public float4* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float4*)((byte*)result + i * outputByteStride); @@ -1343,10 +1519,23 @@ public void Execute(int i, int count) off = (float4*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float4*)(((byte*)result) + (i * outputByteStride)); + var off = input + (i * inputByteStride); + *resultV = *((float4*)off); + } +#endif } [BurstCompile] - unsafe struct ConvertBoneWeightsUInt8ToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertBoneWeightsUInt8ToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1363,6 +1552,7 @@ unsafe struct ConvertBoneWeightsUInt8ToFloatInterleavedJob : IJobParallelForBatc [NativeDisableUnsafePtrRestriction] public float4* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float4*)((byte*)result + i * outputByteStride); @@ -1380,10 +1570,28 @@ public void Execute(int i, int count) off += inputByteStride; } } +#else + public void Execute(int i) + { + var resultV = (float4*)(((byte*)result) + (i * outputByteStride)); + var off = input + (i * inputByteStride); + *resultV = new float4( + off[0] / 255f, + off[1] / 255f, + off[2] / 255f, + off[3] / 255f + ); + } +#endif } [BurstCompile] - unsafe struct ConvertBoneWeightsUInt16ToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertBoneWeightsUInt16ToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1400,6 +1608,7 @@ unsafe struct ConvertBoneWeightsUInt16ToFloatInterleavedJob : IJobParallelForBat [NativeDisableUnsafePtrRestriction] public float4* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float4*)((byte*)result + i * outputByteStride); @@ -1417,10 +1626,28 @@ public void Execute(int i, int count) off = (ushort*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float4*)(((byte*)result) + (i * outputByteStride)); + var off = (ushort*)(input + i * inputByteStride); + *resultV = new float4( + off[0] / (float)ushort.MaxValue, + off[1] / (float)ushort.MaxValue, + off[2] / (float)ushort.MaxValue, + off[3] / (float)ushort.MaxValue + ); + } +#endif } [BurstCompile] - unsafe struct ConvertTangentsInt16ToFloatInterleavedNormalizedJob : IJobParallelForBatch + unsafe struct ConvertTangentsInt16ToFloatInterleavedNormalizedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1437,6 +1664,7 @@ unsafe struct ConvertTangentsInt16ToFloatInterleavedNormalizedJob : IJobParallel [NativeDisableUnsafePtrRestriction] public float4* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float4*)((byte*)result + i * outputByteStride); @@ -1453,10 +1681,26 @@ public void Execute(int i, int count) off = (short*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float4*)(((byte*)result) + (i * outputByteStride)); + var off = (short*)(((byte*)input) + (i * inputByteStride)); + var tmp = new float4(off[0], off[1], off[2], off[3]) / short.MaxValue; + var tmp2 = max(tmp, -1f); + tmp2.z *= -1; + *resultV = normalize(tmp2); + } +#endif } [BurstCompile] - unsafe struct ConvertTangentsInt8ToFloatInterleavedNormalizedJob : IJobParallelForBatch + unsafe struct ConvertTangentsInt8ToFloatInterleavedNormalizedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1473,6 +1717,7 @@ unsafe struct ConvertTangentsInt8ToFloatInterleavedNormalizedJob : IJobParallelF [NativeDisableUnsafePtrRestriction] public float4* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float4*)((byte*)result + i * outputByteStride); @@ -1489,10 +1734,26 @@ public void Execute(int i, int count) off += inputByteStride; } } +#else + public void Execute(int i) + { + var resultV = (float4*)(((byte*)result) + (i * outputByteStride)); + var off = input + (i * inputByteStride); + var tmp = new float4(off[0], off[1], off[2], off[3]) / 127f; + var tmp2 = max(tmp, -1f); + tmp2.z *= -1; + *resultV = normalize(tmp2); + } +#endif } [BurstCompile] - unsafe struct ConvertPositionsUInt16ToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertPositionsUInt16ToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1509,6 +1770,7 @@ unsafe struct ConvertPositionsUInt16ToFloatInterleavedJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float3* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1521,10 +1783,23 @@ public void Execute(int i, int count) off = (ushort*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + var off = (ushort*)(input + (inputByteStride * i)); + *resultV = new float3(-(float)off[0], off[1], off[2]); + } +#endif } [BurstCompile] - unsafe struct ConvertPositionsUInt16ToFloatInterleavedNormalizedJob : IJobParallelForBatch + unsafe struct ConvertPositionsUInt16ToFloatInterleavedNormalizedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] public int inputByteStride; @@ -1540,6 +1815,7 @@ unsafe struct ConvertPositionsUInt16ToFloatInterleavedNormalizedJob : IJobParall [NativeDisableUnsafePtrRestriction] public float3* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1557,10 +1833,27 @@ public void Execute(int i, int count) off = (ushort*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + var off = (ushort*)(input + (inputByteStride * i)); + *resultV = new float3( + -(off[0] / (float)ushort.MaxValue), + off[1] / (float)ushort.MaxValue, + off[2] / (float)ushort.MaxValue + ); + } +#endif } [BurstCompile] - unsafe struct ConvertPositionsInt16ToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertPositionsInt16ToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1578,6 +1871,7 @@ unsafe struct ConvertPositionsInt16ToFloatInterleavedJob : IJobParallelForBatch [ReadOnly] public int outputByteStride; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1590,6 +1884,14 @@ public void Execute(int i, int count) off = (short*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + var off = (short*)(input + (i * inputByteStride)); + *resultV = new float3(-(float)off[0], off[1], off[2]); + } +#endif } /// @@ -1597,7 +1899,12 @@ public void Execute(int i, int count) /// Result is not normalized (scaled to unit length) /// [BurstCompile] - unsafe struct ConvertVector3Int16ToFloatInterleavedNormalizedJob : IJobParallelForBatch + unsafe struct ConvertVector3Int16ToFloatInterleavedNormalizedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1614,6 +1921,7 @@ unsafe struct ConvertVector3Int16ToFloatInterleavedNormalizedJob : IJobParallelF [NativeDisableUnsafePtrRestriction] public float3* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1630,6 +1938,18 @@ public void Execute(int i, int count) off = (short*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + var off = (short*)(input + (i * inputByteStride)); + + var tmp = new float3(off[0], off[1], off[2]) / short.MaxValue; + var tmp2 = max(tmp, -1f); + tmp2.x *= -1; + *resultV = tmp2; + } +#endif } /// @@ -1637,7 +1957,12 @@ public void Execute(int i, int count) /// Result is normalized (scaled to unit length) /// [BurstCompile] - unsafe struct ConvertNormalsInt16ToFloatInterleavedNormalizedJob : IJobParallelForBatch + unsafe struct ConvertNormalsInt16ToFloatInterleavedNormalizedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1654,6 +1979,7 @@ unsafe struct ConvertNormalsInt16ToFloatInterleavedNormalizedJob : IJobParallelF [NativeDisableUnsafePtrRestriction] public float3* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1670,10 +1996,27 @@ public void Execute(int i, int count) off = (short*)((byte*)off + inputByteStride); } } +#else + public void Execute(int i) + { + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + var off = (short*)(input + (i * inputByteStride)); + + var tmp = new float3(off[0], off[1], off[2]) / short.MaxValue; + var tmp2 = max(tmp, -1f); + tmp2.x *= -1; + *resultV = normalize(tmp2); + } +#endif } [BurstCompile] - unsafe struct ConvertPositionsInt8ToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertPositionsInt8ToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1690,6 +2033,7 @@ unsafe struct ConvertPositionsInt8ToFloatInterleavedJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float3* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1702,6 +2046,14 @@ public void Execute(int i, int count) off += inputByteStride; } } +#else + public void Execute(int i) + { + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + var off = input + (inputByteStride * i); + *resultV = new float3(-(float)off[0], off[1], off[2]); + } +#endif } /// @@ -1709,7 +2061,12 @@ public void Execute(int i, int count) /// Result is not normalized (scaled to unit length) /// [BurstCompile] - unsafe struct ConvertVector3Int8ToFloatInterleavedNormalizedJob : IJobParallelForBatch + unsafe struct ConvertVector3Int8ToFloatInterleavedNormalizedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1726,6 +2083,7 @@ unsafe struct ConvertVector3Int8ToFloatInterleavedNormalizedJob : IJobParallelFo [NativeDisableUnsafePtrRestriction] public float3* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1742,6 +2100,18 @@ public void Execute(int i, int count) off += inputByteStride; } } +#else + public void Execute(int i) + { + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + var off = input + (inputByteStride * i); + + var tmp = new float3(off[0], off[1], off[2]) / 127f; + var tmp2 = max(tmp, -1); + tmp2.x *= -1; + *resultV = tmp2; + } +#endif } /// @@ -1749,7 +2119,12 @@ public void Execute(int i, int count) /// Result is normalized (scaled to unit length) /// [BurstCompile] - unsafe struct ConvertNormalsInt8ToFloatInterleavedNormalizedJob : IJobParallelForBatch + unsafe struct ConvertNormalsInt8ToFloatInterleavedNormalizedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1766,6 +2141,7 @@ unsafe struct ConvertNormalsInt8ToFloatInterleavedNormalizedJob : IJobParallelFo [NativeDisableUnsafePtrRestriction] public float3* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1782,10 +2158,27 @@ public void Execute(int i, int count) off += inputByteStride; } } +#else + public void Execute(int i) + { + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + var off = input + (inputByteStride * i); + + var tmp = new float3(off[0], off[1], off[2]) / 127f; + var tmp2 = max(tmp, -1); + tmp2.x *= -1; + *resultV = normalize(tmp2); + } +#endif } [BurstCompile] - unsafe struct ConvertPositionsUInt8ToFloatInterleavedJob : IJobParallelForBatch + unsafe struct ConvertPositionsUInt8ToFloatInterleavedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1802,6 +2195,7 @@ unsafe struct ConvertPositionsUInt8ToFloatInterleavedJob : IJobParallelForBatch [NativeDisableUnsafePtrRestriction] public float3* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1814,10 +2208,23 @@ public void Execute(int i, int count) off += inputByteStride; } } +#else + public void Execute(int i) + { + var off = input + (i * inputByteStride); + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + *resultV = new float3(-(float)off[0], off[1], off[2]); + } +#endif } [BurstCompile] - unsafe struct ConvertPositionsUInt8ToFloatInterleavedNormalizedJob : IJobParallelForBatch + unsafe struct ConvertPositionsUInt8ToFloatInterleavedNormalizedJob : +#if UNITY_COLLECTIONS + IJobParallelForBatch +#else + IJobParallelFor +#endif { [ReadOnly] @@ -1834,6 +2241,7 @@ unsafe struct ConvertPositionsUInt8ToFloatInterleavedNormalizedJob : IJobParalle [NativeDisableUnsafePtrRestriction] public float3* result; +#if UNITY_COLLECTIONS public void Execute(int i, int count) { var resultV = (float3*)((byte*)result + i * outputByteStride); @@ -1850,6 +2258,18 @@ public void Execute(int i, int count) off += inputByteStride; } } +#else + public void Execute(int i) + { + var resultV = (float3*)(((byte*)result) + (i * outputByteStride)); + var off = input + (i * inputByteStride); + *resultV = new float3( + -(off[0] / 255f), + off[1] / 255f, + off[2] / 255f + ); + } +#endif } [BurstCompile] diff --git a/Runtime/Scripts/MeshGenerator.cs b/Runtime/Scripts/MeshGenerator.cs index 474d5482..201b90c6 100644 --- a/Runtime/Scripts/MeshGenerator.cs +++ b/Runtime/Scripts/MeshGenerator.cs @@ -332,7 +332,7 @@ async Task CreateMeshResultAsync() Profiler.EndSample(); msh.subMeshCount = m_Indices.Length; indexCount = 0; - var boundsAreValid = true; + Bounds bounds = default; for (var i = 0; i < m_Indices.Length; i++) { Profiler.BeginSample("SetIndexBufferData"); @@ -342,7 +342,7 @@ async Task CreateMeshResultAsync() Profiler.BeginSample("SetSubMesh"); var vertexBufferIndex = m_SubMeshAssignments != null ? m_SubMeshAssignments[i].VertexBufferIndex : i; m_VertexData.GetVertexRange(vertexBufferIndex, out var baseVertex, out var vertexCount); - boundsAreValid &= m_VertexData.TryGetBounds(vertexBufferIndex, out var bounds); + var subMeshBoundsValid = m_VertexData.TryGetBounds(vertexBufferIndex, out var subMeshBounds); var subMeshDescriptor = new SubMeshDescriptor { indexStart = indexCount, @@ -351,12 +351,35 @@ async Task CreateMeshResultAsync() baseVertex = baseVertex, firstVertex = baseVertex, vertexCount = vertexCount, - bounds = bounds + bounds = subMeshBounds }; - msh.SetSubMesh(i, subMeshDescriptor, defaultMeshUpdateFlags); + msh.SetSubMesh( + i, + subMeshDescriptor, + subMeshBoundsValid + ? defaultMeshUpdateFlags + : defaultMeshUpdateFlags & ~MeshUpdateFlags.DontRecalculateBounds + ); + if (!subMeshBoundsValid) + { + subMeshDescriptor = msh.GetSubMesh(i); + subMeshBounds = subMeshDescriptor.bounds; + } + + if (i == 0) + { + bounds = subMeshBounds; + } + else + { + bounds.Encapsulate(subMeshBounds); + } Profiler.EndSample(); indexCount += m_Indices[i].Length; } + + msh.bounds = bounds; + Profiler.EndSample(); if (m_Topology == MeshTopology.Triangles || m_Topology == MeshTopology.Quads) @@ -375,16 +398,6 @@ async Task CreateMeshResultAsync() } } - if (!boundsAreValid) - { - Profiler.BeginSample("RecalculateBounds"); -#if DEBUG - Debug.LogError("Bounds have to be recalculated (slow operation). Check if position accessors have proper min/max values"); -#endif - msh.RecalculateBounds(); - Profiler.EndSample(); - } - if (m_MorphTargetsGenerator != null) { await m_MorphTargetsGenerator.ApplyOnMeshAndDispose(msh); diff --git a/Runtime/Scripts/UvTransform.cs b/Runtime/Scripts/UvTransform.cs index e49ace06..65c681b3 100644 --- a/Runtime/Scripts/UvTransform.cs +++ b/Runtime/Scripts/UvTransform.cs @@ -33,7 +33,11 @@ public static UvTransform FromMatrix(float2x2 scaleRotation) var acos = math.acos(r1.x); if (r2.x < 0) acos = math.PI * 2 - acos; +#if UNITY_MATH_1_3_OR_NEWER result.rotation = acos * math.TODEGREES; +#else + result.rotation = math.degrees(acos); +#endif return result; } } diff --git a/Runtime/Scripts/VertexBufferBones.cs b/Runtime/Scripts/VertexBufferBones.cs index fe740b56..24e2325e 100644 --- a/Runtime/Scripts/VertexBufferBones.cs +++ b/Runtime/Scripts/VertexBufferBones.cs @@ -114,7 +114,7 @@ IGltfBuffers buffers bones = m_Data, skinWeights = math.max(1, skinWeights) }; - jobHandle = job.Schedule(m_Data.Length, GltfImportBase.DefaultBatchCount, jobHandle); + jobHandle = job.Schedule(m_Data.Length, GltfImport.DefaultBatchCount, jobHandle); } #if GLTFAST_SAFE else { @@ -122,7 +122,7 @@ IGltfBuffers buffers var job = new RenormalizeBoneWeightsJob { bones = m_Data, }; - jobHandle = job.Schedule(m_Data.Length, GltfImportBase.DefaultBatchCount, jobHandle); + jobHandle = job.Schedule(m_Data.Length, GltfImport.DefaultBatchCount, jobHandle); } #endif @@ -174,7 +174,11 @@ int outputByteStride jobTangentI.input = (byte*)input; jobTangentI.outputByteStride = outputByteStride; jobTangentI.result = output; - jobHandle = jobTangentI.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = jobTangentI.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = jobTangentI.Schedule(count, GltfImport.DefaultBatchCount); +#endif break; case GltfComponentType.UnsignedShort: { @@ -185,7 +189,11 @@ int outputByteStride outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif break; } case GltfComponentType.UnsignedByte: @@ -197,7 +205,11 @@ int outputByteStride outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif break; } default: @@ -230,7 +242,7 @@ ICodeLogger logger jointsUInt8Job.input = (byte*)input; jointsUInt8Job.outputByteStride = outputByteStride; jointsUInt8Job.result = output; - jobHandle = jointsUInt8Job.Schedule(count, GltfImportBase.DefaultBatchCount); + jobHandle = jointsUInt8Job.Schedule(count, GltfImport.DefaultBatchCount); break; case GltfComponentType.UnsignedShort: var jointsUInt16Job = new ConvertBoneJointsUInt16ToUInt32Job(); @@ -238,7 +250,7 @@ ICodeLogger logger jointsUInt16Job.input = (byte*)input; jointsUInt16Job.outputByteStride = outputByteStride; jointsUInt16Job.result = output; - jobHandle = jointsUInt16Job.Schedule(count, GltfImportBase.DefaultBatchCount); + jobHandle = jointsUInt16Job.Schedule(count, GltfImport.DefaultBatchCount); break; default: logger?.Error(LogCode.TypeUnsupported, "Joints", inputType.ToString()); diff --git a/Runtime/Scripts/VertexBufferColors.cs b/Runtime/Scripts/VertexBufferColors.cs index 1a893d23..7ecabb04 100644 --- a/Runtime/Scripts/VertexBufferColors.cs +++ b/Runtime/Scripts/VertexBufferColors.cs @@ -110,7 +110,7 @@ NativeSlice output inputByteStride = inputByteStride > 0 ? inputByteStride : 3, result = output }; - jobHandle = job.Schedule(output.Length, GltfImportBase.DefaultBatchCount); + jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); } break; case GltfComponentType.Float: @@ -121,7 +121,7 @@ NativeSlice output inputByteStride = inputByteStride > 0 ? inputByteStride : 12, result = (float4*)output.GetUnsafePtr() }; - jobHandle = job.Schedule(output.Length, GltfImportBase.DefaultBatchCount); + jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); } break; case GltfComponentType.UnsignedShort: @@ -132,7 +132,7 @@ NativeSlice output inputByteStride = inputByteStride > 0 ? inputByteStride : 6, result = output }; - jobHandle = job.Schedule(output.Length, GltfImportBase.DefaultBatchCount); + jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); } break; default: @@ -152,7 +152,7 @@ NativeSlice output inputByteStride = inputByteStride > 0 ? inputByteStride : 4, result = output }; - jobHandle = job.Schedule(output.Length, GltfImportBase.DefaultBatchCount); + jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); } break; case GltfComponentType.Float: @@ -175,7 +175,11 @@ NativeSlice output inputByteStride = inputByteStride, result = (float4*)output.GetUnsafePtr() }; - jobHandle = job.ScheduleBatch(output.Length, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(output.Length,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); +#endif } } break; @@ -187,7 +191,11 @@ NativeSlice output inputByteStride = inputByteStride > 0 ? inputByteStride : 8, result = (float4*)output.GetUnsafePtr() }; - jobHandle = job.ScheduleBatch(output.Length, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(output.Length,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); +#endif } break; default: diff --git a/Runtime/Scripts/VertexBufferGenerator.cs b/Runtime/Scripts/VertexBufferGenerator.cs index 379dc71f..dc628532 100644 --- a/Runtime/Scripts/VertexBufferGenerator.cs +++ b/Runtime/Scripts/VertexBufferGenerator.cs @@ -58,6 +58,7 @@ public override bool TryGetBounds(int subMesh, out Bounds bounds) bounds = boundsOpt.Value; return true; } + m_GltfImport.Logger?.Error(LogCode.MeshBoundsMissing, m_Attributes[subMesh].POSITION.ToString()); bounds = default; return false; } diff --git a/Runtime/Scripts/VertexBufferGeneratorBase.cs b/Runtime/Scripts/VertexBufferGeneratorBase.cs index 8823f60c..fcca721c 100644 --- a/Runtime/Scripts/VertexBufferGeneratorBase.cs +++ b/Runtime/Scripts/VertexBufferGeneratorBase.cs @@ -89,7 +89,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } else if (inputType == GltfComponentType.UnsignedShort) @@ -103,7 +107,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } else { @@ -114,7 +122,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } } else @@ -132,7 +144,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } else { @@ -143,7 +159,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } } else @@ -155,7 +175,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } } else @@ -172,7 +196,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } else { @@ -183,7 +211,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } } else @@ -196,7 +228,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } } else @@ -212,7 +248,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } else { @@ -223,7 +263,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } } else @@ -258,7 +302,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = jobTangent.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = jobTangent.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = jobTangent.Schedule(count, GltfImport.DefaultBatchCount); +#endif break; } case GltfComponentType.Short: @@ -271,7 +319,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = jobTangent.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = jobTangent.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = jobTangent.Schedule(count, GltfImport.DefaultBatchCount); +#endif break; } case GltfComponentType.Byte: @@ -284,7 +336,11 @@ public void Dispose() outputByteStride = outputByteStride, result = output }; - jobHandle = jobTangent.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = jobTangent.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = jobTangent.Schedule(count, GltfImport.DefaultBatchCount); +#endif break; } default: @@ -323,7 +379,7 @@ public void Dispose() JobHandle? jobHandle = job.Schedule( sparseCount, - GltfImportBase.DefaultBatchCount, + GltfImport.DefaultBatchCount, dependsOn: dependsOn ?? default(JobHandle) ); Profiler.EndSample(); diff --git a/Runtime/Scripts/VertexBufferTexCoords.cs b/Runtime/Scripts/VertexBufferTexCoords.cs index bbe03b32..26d53a18 100644 --- a/Runtime/Scripts/VertexBufferTexCoords.cs +++ b/Runtime/Scripts/VertexBufferTexCoords.cs @@ -163,7 +163,11 @@ protected override void Dispose(bool disposing) outputByteStride = outputByteStride, result = output }; - jobHandle = jobUv.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = jobUv.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = jobUv.Schedule(count, GltfImport.DefaultBatchCount); +#endif } break; case GltfComponentType.UnsignedByte: @@ -176,7 +180,7 @@ protected override void Dispose(bool disposing) outputByteStride = outputByteStride, result = output }; - jobHandle = jobUv.Schedule(count, GltfImportBase.DefaultBatchCount); + jobHandle = jobUv.Schedule(count, GltfImport.DefaultBatchCount); } else { @@ -187,7 +191,11 @@ protected override void Dispose(bool disposing) outputByteStride = outputByteStride, result = output }; - jobHandle = jobUv.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = jobUv.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = jobUv.Schedule(count, GltfImport.DefaultBatchCount); +#endif } break; case GltfComponentType.UnsignedShort: @@ -200,7 +208,7 @@ protected override void Dispose(bool disposing) outputByteStride = outputByteStride, result = output }; - jobHandle = jobUv.Schedule(count, GltfImportBase.DefaultBatchCount); + jobHandle = jobUv.Schedule(count, GltfImport.DefaultBatchCount); } else { @@ -211,7 +219,11 @@ protected override void Dispose(bool disposing) outputByteStride = outputByteStride, result = output }; - jobHandle = jobUv.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = jobUv.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = jobUv.Schedule(count, GltfImport.DefaultBatchCount); +#endif } break; case GltfComponentType.Short: @@ -224,7 +236,11 @@ protected override void Dispose(bool disposing) outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } else { @@ -235,7 +251,11 @@ protected override void Dispose(bool disposing) outputByteStride = outputByteStride, result = output }; - jobHandle = job.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = job.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = job.Schedule(count, GltfImport.DefaultBatchCount); +#endif } break; case GltfComponentType.Byte: @@ -248,7 +268,11 @@ protected override void Dispose(bool disposing) outputByteStride = outputByteStride, result = output }; - jobHandle = jobInt8.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = jobInt8.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = jobInt8.Schedule(count, GltfImport.DefaultBatchCount); +#endif } else { @@ -259,7 +283,11 @@ protected override void Dispose(bool disposing) outputByteStride = outputByteStride, result = output }; - jobHandle = jobInt8.ScheduleBatch(count, GltfImportBase.DefaultBatchCount); +#if UNITY_COLLECTIONS + jobHandle = jobInt8.ScheduleBatch(count,GltfImport.DefaultBatchCount); +#else + jobHandle = jobInt8.Schedule(count, GltfImport.DefaultBatchCount); +#endif } break; default: diff --git a/Runtime/Scripts/glTFast.asmdef b/Runtime/Scripts/glTFast.asmdef index f2c3b0f0..d6d77ddb 100644 --- a/Runtime/Scripts/glTFast.asmdef +++ b/Runtime/Scripts/glTFast.asmdef @@ -5,6 +5,7 @@ "Unity.Mathematics", "Unity.Burst", "Unity.Collections", + "Unity.Jobs", "Draco", "Ktx", "Unity.Meshopt.Decompress", @@ -79,6 +80,11 @@ "expression": "", "define": "UNITY_WEBREQUEST_TEXTURE" }, + { + "name": "com.unity.collections", + "expression": "1.5.0", + "define": "UNITY_COLLECTIONS" + }, { "name": "com.unity.meshopt.decompress", "expression": "", @@ -103,6 +109,11 @@ "name": "com.unity.nuget.newtonsoft-json", "expression": "3", "define": "NEWTONSOFT_JSON" + }, + { + "name": "com.unity.mathematics", + "expression": "1.3", + "define": "UNITY_MATH_1_3_OR_NEWER" } ], "noEngineReferences": false diff --git a/package.json b/package.json index 1a97634e..e3e78323 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.atteneder.gltfast", - "version": "6.10.0", + "version": "6.10.1", "displayName": "glTFast", "description": "Use glTFast to import and export glTF 3D files efficiently at runtime or in the Editor", "unity": "2020.3", @@ -23,9 +23,9 @@ "dependencies": { "com.unity.modules.jsonserialize": "1.0.0", "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.mathematics": "1.3.1", + "com.unity.mathematics": "1.2.6", "com.unity.burst": "1.8.4", - "com.unity.collections": "1.5.1" + "com.unity.collections": "1.2.4" }, "unityRelease": "48f1" }