Advertisement
Guest User

Untitled

a guest
Sep 15th, 2020
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.68 KB | None | 0 0
  1. commit 46aa52c82a0ac458aba060108a32d79f7ab42d97
  2. Author: Aron Granberg <[email protected]>
  3. Date:   Tue Sep 8 14:05:13 2020 +0200
  4.  
  5.     Fixed burstified recast code not sometimes throwing an exception in standalone IL2CPP builds.
  6.  
  7. diff --git a/Assets/AstarPathfindingProject/Generators/Utilities/RecastMeshGathererBurst.cs b/Assets/AstarPathfindingProject/Generators/Utilities/RecastMeshGathererBurst.cs
  8. index 54415ebc..71aa7df9 100644
  9. --- a/Assets/AstarPathfindingProject/Generators/Utilities/RecastMeshGathererBurst.cs
  10. +++ b/Assets/AstarPathfindingProject/Generators/Utilities/RecastMeshGathererBurst.cs
  11. @@ -3,6 +3,7 @@ using UnityEngine;
  12.  using System.Collections.Generic;
  13.  using Unity.Mathematics;
  14.  using Unity.Collections;
  15. +using Unity.Collections.LowLevel.Unsafe;
  16.  using Unity.Burst;
  17.  
  18.  namespace Pathfinding.Recast {
  19. @@ -71,13 +72,13 @@ namespace Pathfinding.Recast {
  20.  
  21.         [BurstCompile]
  22.         [AOT.MonoPInvokeCallback(typeof(CalculateBoundsDelegate))]
  23. -       static void CalculateBounds (ref NativeSlice<float3> vertices, ref float4x4 localToWorldMatrix, out Bounds bounds) {
  24. -           if (vertices.Length == 0) {
  25. +       unsafe static void CalculateBounds (float3* vertices, int numVertices, ref float4x4 localToWorldMatrix, out Bounds bounds) {
  26. +           if (numVertices == 0) {
  27.                 bounds = new Bounds();
  28.             } else {
  29.                 float3 max = float.NegativeInfinity;
  30.                 float3 min = float.PositiveInfinity;
  31. -               for (int i = 0; i < vertices.Length; i++) {
  32. +               for (int i = 0; i < numVertices; i++) {
  33.                     var v = math.mul(localToWorldMatrix, new float4(vertices[i], 1)).xyz;
  34.                     max = math.max(max, v);
  35.                     min = math.min(min, v);
  36. @@ -86,8 +87,8 @@ namespace Pathfinding.Recast {
  37.             }
  38.         }
  39.  
  40. -       delegate void CalculateBoundsDelegate(ref NativeSlice<float3> vertices, ref float4x4 localToWorldMatrix, out Bounds bounds);
  41. -       private readonly static CalculateBoundsDelegate CalculateBoundsInvoke = BurstCompiler.CompileFunctionPointer<CalculateBoundsDelegate>(CalculateBounds).Invoke;
  42. +       unsafe delegate void CalculateBoundsDelegate(float3* vertices, int numVertices, ref float4x4 localToWorldMatrix, out Bounds bounds);
  43. +       private readonly unsafe static CalculateBoundsDelegate CalculateBoundsInvoke = BurstCompiler.CompileFunctionPointer<CalculateBoundsDelegate>(CalculateBounds).Invoke;
  44.  
  45.         public MeshCollection Finalize () {
  46.             #if UNITY_2020_1_OR_NEWER
  47. @@ -127,12 +128,14 @@ namespace Pathfinding.Recast {
  48.                 }
  49.  
  50.                 var bounds = gatheredMesh.bounds;
  51. -               var slice = vertexBuffers[bufferIndex].Slice().SliceConvert<float3>();
  52. +               var slice = vertexBuffers[bufferIndex].Reinterpret<float3>();
  53.                 if (bounds == new Bounds()) {
  54.                     UnityEngine.Profiling.Profiler.BeginSample("CalculateBounds");
  55.                     // Recalculate bounding box
  56.                     float4x4 m = gatheredMesh.matrix;
  57. -                   CalculateBoundsInvoke(ref slice, ref m, out bounds);
  58. +                   unsafe {
  59. +                       CalculateBoundsInvoke((float3*)slice.GetUnsafeReadOnlyPtr(), slice.Length, ref m, out bounds);
  60. +                   }
  61.                     UnityEngine.Profiling.Profiler.EndSample();
  62.                 }
  63.  
  64. diff --git a/Assets/AstarPathfindingProject/changelog.cs b/Assets/AstarPathfindingProject/changelog.cs
  65. index d11c2dad..3bf35bd8 100644
  66. --- a/Assets/AstarPathfindingProject/changelog.cs
  67. +++ b/Assets/AstarPathfindingProject/changelog.cs
  68. @@ -1,6 +1,9 @@
  69.  /** \page changelog Changelog
  70.  \order{-10}
  71.  
  72. +- 4.3.35
  73. +   - Fixed burstified recast code not sometimes throwing an exception in standalone IL2CPP builds.
  74. +
  75.  - 4.3.34 (2020-09-04)
  76.     - Added a setter for the rotation property of all movement scripts (\reflink{IAstarAI.rotation}).
  77.     - Fixed RichAI always teleporting to the closest point on the navmesh when the script is enabled even if \reflink{RichAI.canMove} is false.
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement