Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.54 KB | None | 0 0
  1. diff --git a/Assets/AstarPathfindingProject/Generators/LayerGridGraphGenerator.cs b/Assets/AstarPathfindingProject/Generators/LayerGridGraphGenerator.cs
  2. index ee748f4..45ba554 100644
  3. --- a/Assets/AstarPathfindingProject/Generators/LayerGridGraphGenerator.cs
  4. +++ b/Assets/AstarPathfindingProject/Generators/LayerGridGraphGenerator.cs
  5. @@ -59,6 +59,9 @@ namespace Pathfinding {
  6.         [JsonMember]
  7.         public float characterHeight = 0.4F;
  8.        
  9. +       internal int lastScannedWidth = 0;
  10. +       internal int lastScannedDepth = 0;
  11. +
  12.         public new LevelGridNode[] nodes;
  13.        
  14.         public override bool uniformWidthDepthGrid {
  15. @@ -353,14 +356,9 @@ namespace Pathfinding {
  16.                 Debug.LogError ("One of the grid's sides is longer than 1024 nodes");
  17.                 return;
  18.             }
  19. -          
  20. -           //GenerateBounds ();
  21. -          
  22. -           /*neighbourOffsets = new int[8] {
  23. -               -width-1,-width,-width+1,
  24. -               -1,1,
  25. -               width-1,width,width+1
  26. -           }*/
  27. +
  28. +           lastScannedWidth = width;
  29. +           lastScannedDepth = depth;
  30.            
  31.             SetUpOffsetsAndCosts ();
  32.            
  33. @@ -1498,7 +1496,7 @@ namespace Pathfinding {
  34.                             int nIndex = node.NodeInGridIndex + neighbourOffsets[i] + width*depth*conn;
  35.                                 //nodeCellIndices[node.GetIndex ()+neighbourOffsets[i]]+conn;//index-node.nodeOffset+neighbourOffsets[i]+conn;
  36.                            
  37. -                           if (nIndex < 0 || nIndex > nodes.Length) {
  38. +                           if (nIndex < 0 || nIndex >= nodes.Length) {
  39.                                 continue;
  40.                             }
  41.                            
  42. @@ -1560,12 +1558,13 @@ namespace Pathfinding {
  43.            
  44.             GenerateMatrix ();
  45.            
  46. +           lastScannedWidth = width;
  47. +           lastScannedDepth = depth;
  48. +          
  49.             SetUpOffsetsAndCosts ();
  50.            
  51.             if (nodes == null || nodes.Length == 0) return;
  52. -          
  53. -           //graphNodes = new GridNode[nodes.Length];
  54. -          
  55. +
  56.             LevelGridNode.SetGridGraph (AstarPath.active.astarData.GetGraphIndex(this),this);
  57.            
  58.             for (int z = 0; z < depth; z ++) {
  59. @@ -1715,7 +1714,7 @@ namespace Pathfinding {
  60.                 for (int i=0;i<4;i++) {
  61.                     int conn = GetConnectionValue(i);//(gridConnections >> i*4) & 0xF;
  62.                     if (conn != LevelGridNode.NoConnection) {
  63. -                       LevelGridNode other = nodes[NodeInGridIndex+neighbourOffsets[i] + graph.width*graph.depth*conn];
  64. +                       LevelGridNode other = nodes[NodeInGridIndex+neighbourOffsets[i] + graph.lastScannedWidth*graph.lastScannedDepth*conn];
  65.                         if (other != null) {
  66.                             //Remove reverse connection
  67.                             /** \todo Check if correct */
  68. @@ -1740,7 +1739,7 @@ namespace Pathfinding {
  69.             for (int i=0;i<4;i++) {
  70.                 int conn = GetConnectionValue(i);//(gridConnections >> i*4) & 0xF;
  71.                 if (conn != LevelGridNode.NoConnection) {
  72. -                   LevelGridNode other = nodes[index+neighbourOffsets[i] + graph.width*graph.depth*conn];
  73. +                   LevelGridNode other = nodes[index+neighbourOffsets[i] + graph.lastScannedWidth*graph.lastScannedDepth*conn];
  74.                     if (other != null) del (other);
  75.                 }
  76.             }
  77. @@ -1756,7 +1755,7 @@ namespace Pathfinding {
  78.             for (int i=0;i<4;i++) {
  79.                 int conn = GetConnectionValue(i);//(gridConnections >> i*4) & 0xF;
  80.                 if (conn != LevelGridNode.NoConnection) {
  81. -                   LevelGridNode other = nodes[index+neighbourOffsets[i] + graph.width*graph.depth*conn];
  82. +                   LevelGridNode other = nodes[index+neighbourOffsets[i] + graph.lastScannedWidth*graph.lastScannedDepth*conn];
  83.                     if (other != null && other.Area != region) {
  84.                         other.Area = region;
  85.                         stack.Push (other);
  86. @@ -1810,7 +1809,7 @@ namespace Pathfinding {
  87.             for (int i=0;i<4;i++) {
  88.                 int conn = GetConnectionValue(i);//(gridConnections >> i*4) & 0xF;
  89.                 if (conn != LevelGridNode.NoConnection) {
  90. -                   if (other == nodes[index+neighbourOffsets[i] + graph.width*graph.depth*conn]) {
  91. +                   if (other == nodes[index+neighbourOffsets[i] + graph.lastScannedWidth*graph.lastScannedDepth*conn]) {
  92.                         Vector3 middle = ((Vector3)(position + other.position))*0.5f;
  93.                         Vector3 cross = Vector3.Cross (graph.collision.up, (Vector3)(other.position-position));
  94.                         cross.Normalize();
  95. @@ -1840,7 +1839,7 @@ namespace Pathfinding {
  96.                 int conn = GetConnectionValue(i);//(gridConnections >> i*4) & 0xF;
  97.                 if (conn != LevelGridNode.NoConnection) {
  98.                    
  99. -                   LevelGridNode other = nodes[index+neighbourOffsets[i] + graph.width*graph.depth*conn];
  100. +                   LevelGridNode other = nodes[index+neighbourOffsets[i] + graph.lastScannedWidth*graph.lastScannedDepth*conn];
  101.                     PathNode otherPN = handler.GetPathNode (other);
  102.                    
  103.                     if (otherPN != null && otherPN.parent == pathNode && otherPN.pathID == handler.PathID) {
  104. @@ -1865,7 +1864,7 @@ namespace Pathfinding {
  105.                 int conn = GetConnectionValue(i);//(gridConnections >> i*4) & 0xF;
  106.                 if (conn != LevelGridNode.NoConnection) {
  107.                    
  108. -                   GraphNode other = nodes[index+neighbourOffsets[i] + graph.width*graph.depth*conn];
  109. +                   GraphNode other = nodes[index+neighbourOffsets[i] + graph.lastScannedWidth*graph.lastScannedDepth*conn];
  110.                    
  111.                     if (!path.CanTraverse (other)) {
  112.                         continue;
  113. diff --git a/Assets/AstarPathfindingProject/changelog.cs b/Assets/AstarPathfindingProject/changelog.cs
  114. index 5dd6059..e6659ef 100644
  115. --- a/Assets/AstarPathfindingProject/changelog.cs
  116. +++ b/Assets/AstarPathfindingProject/changelog.cs
  117. @@ -3,6 +3,10 @@
  118.     - Fix execution order for RVOSimulator
  119.    
  120.     - Fix RecastGraph.minRegionSize should be measured in world units
  121. +
  122. +- 3.6
  123. +   - Fixed an index out of range exception which could occur when scanning LayeredGridGraphs.
  124. +   - Fixed an index out of range exception which could occur when drawing gizmos for a LayeredGridGraph.
  125.    
  126.  - 3.5.9.1 (3.6 beta3, 2014-10-14)
  127.     - Added back isometric angle from 3.5.2 which had been removed by mistake from 3.5.9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement