Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit 46aa52c82a0ac458aba060108a32d79f7ab42d97
- Author: Aron Granberg <[email protected]>
- Date: Tue Sep 8 14:05:13 2020 +0200
- Fixed burstified recast code not sometimes throwing an exception in standalone IL2CPP builds.
- diff --git a/Assets/AstarPathfindingProject/Generators/Utilities/RecastMeshGathererBurst.cs b/Assets/AstarPathfindingProject/Generators/Utilities/RecastMeshGathererBurst.cs
- index 54415ebc..71aa7df9 100644
- --- a/Assets/AstarPathfindingProject/Generators/Utilities/RecastMeshGathererBurst.cs
- +++ b/Assets/AstarPathfindingProject/Generators/Utilities/RecastMeshGathererBurst.cs
- @@ -3,6 +3,7 @@ using UnityEngine;
- using System.Collections.Generic;
- using Unity.Mathematics;
- using Unity.Collections;
- +using Unity.Collections.LowLevel.Unsafe;
- using Unity.Burst;
- namespace Pathfinding.Recast {
- @@ -71,13 +72,13 @@ namespace Pathfinding.Recast {
- [BurstCompile]
- [AOT.MonoPInvokeCallback(typeof(CalculateBoundsDelegate))]
- - static void CalculateBounds (ref NativeSlice<float3> vertices, ref float4x4 localToWorldMatrix, out Bounds bounds) {
- - if (vertices.Length == 0) {
- + unsafe static void CalculateBounds (float3* vertices, int numVertices, ref float4x4 localToWorldMatrix, out Bounds bounds) {
- + if (numVertices == 0) {
- bounds = new Bounds();
- } else {
- float3 max = float.NegativeInfinity;
- float3 min = float.PositiveInfinity;
- - for (int i = 0; i < vertices.Length; i++) {
- + for (int i = 0; i < numVertices; i++) {
- var v = math.mul(localToWorldMatrix, new float4(vertices[i], 1)).xyz;
- max = math.max(max, v);
- min = math.min(min, v);
- @@ -86,8 +87,8 @@ namespace Pathfinding.Recast {
- }
- }
- - delegate void CalculateBoundsDelegate(ref NativeSlice<float3> vertices, ref float4x4 localToWorldMatrix, out Bounds bounds);
- - private readonly static CalculateBoundsDelegate CalculateBoundsInvoke = BurstCompiler.CompileFunctionPointer<CalculateBoundsDelegate>(CalculateBounds).Invoke;
- + unsafe delegate void CalculateBoundsDelegate(float3* vertices, int numVertices, ref float4x4 localToWorldMatrix, out Bounds bounds);
- + private readonly unsafe static CalculateBoundsDelegate CalculateBoundsInvoke = BurstCompiler.CompileFunctionPointer<CalculateBoundsDelegate>(CalculateBounds).Invoke;
- public MeshCollection Finalize () {
- #if UNITY_2020_1_OR_NEWER
- @@ -127,12 +128,14 @@ namespace Pathfinding.Recast {
- }
- var bounds = gatheredMesh.bounds;
- - var slice = vertexBuffers[bufferIndex].Slice().SliceConvert<float3>();
- + var slice = vertexBuffers[bufferIndex].Reinterpret<float3>();
- if (bounds == new Bounds()) {
- UnityEngine.Profiling.Profiler.BeginSample("CalculateBounds");
- // Recalculate bounding box
- float4x4 m = gatheredMesh.matrix;
- - CalculateBoundsInvoke(ref slice, ref m, out bounds);
- + unsafe {
- + CalculateBoundsInvoke((float3*)slice.GetUnsafeReadOnlyPtr(), slice.Length, ref m, out bounds);
- + }
- UnityEngine.Profiling.Profiler.EndSample();
- }
- diff --git a/Assets/AstarPathfindingProject/changelog.cs b/Assets/AstarPathfindingProject/changelog.cs
- index d11c2dad..3bf35bd8 100644
- --- a/Assets/AstarPathfindingProject/changelog.cs
- +++ b/Assets/AstarPathfindingProject/changelog.cs
- @@ -1,6 +1,9 @@
- /** \page changelog Changelog
- \order{-10}
- +- 4.3.35
- + - Fixed burstified recast code not sometimes throwing an exception in standalone IL2CPP builds.
- +
- - 4.3.34 (2020-09-04)
- - Added a setter for the rotation property of all movement scripts (\reflink{IAstarAI.rotation}).
- - Fixed RichAI always teleporting to the closest point on the navmesh when the script is enabled even if \reflink{RichAI.canMove} is false.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement