v0.4.2: array access and general performance improvements
This commit is contained in:
committed by
Evan Debenham
parent
e87ce8949e
commit
c23a284423
@@ -37,6 +37,7 @@ public class PathFinder {
|
||||
private static int[] dir;
|
||||
|
||||
//performance-light shortcuts for some common pathfinder cases
|
||||
//they are in array-access order for increased memory performance
|
||||
public static int[] NEIGHBOURS4;
|
||||
public static int[] NEIGHBOURS8;
|
||||
public static int[] NEIGHBOURS9;
|
||||
@@ -55,9 +56,9 @@ public class PathFinder {
|
||||
|
||||
dir = new int[]{-1, +1, -width, +width, -width-1, -width+1, +width-1, +width+1};
|
||||
|
||||
NEIGHBOURS4 = new int[]{-width, +1, +width, -1};
|
||||
NEIGHBOURS8 = new int[]{-width, +1-width, +1, +1+width, +width, -1+width, -1, -1-width};
|
||||
NEIGHBOURS9 = new int[]{0, -width, +1-width, +1, +1+width, +width, -1+width, -1, -1-width};
|
||||
NEIGHBOURS4 = new int[]{-width, -1, +1, +width};
|
||||
NEIGHBOURS8 = new int[]{-width-1, -width, -width+1, -1, +1, +width-1, +width, +width+1};
|
||||
NEIGHBOURS9 = new int[]{-width-1, -width, -width+1, -1, 0, +1, +width-1, +width, +width+1};
|
||||
}
|
||||
|
||||
//TODO currently this isn't used, and all pathfinding is recomputed each step.
|
||||
|
||||
Reference in New Issue
Block a user