forked from bit/DotRecastNetSim
remove int[] offset = new int[] { 0, 1, 0, -1 };
This commit is contained in:
parent
bab26f529b
commit
1f80b70461
|
@ -30,10 +30,11 @@ namespace DotRecast.Detour.TileCache
|
|||
{
|
||||
public class TileCacheBuilder
|
||||
{
|
||||
const int DT_TILECACHE_NULL_AREA = 0;
|
||||
const int DT_TILECACHE_WALKABLE_AREA = 63;
|
||||
const int DT_TILECACHE_NULL_IDX = 0xffff;
|
||||
|
||||
public const int DT_TILECACHE_NULL_AREA = 0;
|
||||
public const int DT_TILECACHE_WALKABLE_AREA = 63;
|
||||
public const int DT_TILECACHE_NULL_IDX = 0xffff;
|
||||
private static readonly int[] DirOffsetX = { -1, 0, 1, 0, };
|
||||
private static readonly int[] DirOffsetY = { 0, 1, 0, -1 };
|
||||
|
||||
private readonly TileCacheLayerHeaderReader reader = new TileCacheLayerHeaderReader();
|
||||
|
||||
|
@ -339,14 +340,12 @@ namespace DotRecast.Detour.TileCache
|
|||
|
||||
private int GetDirOffsetX(int dir)
|
||||
{
|
||||
int[] offset = new int[] { -1, 0, 1, 0, };
|
||||
return offset[dir & 0x03];
|
||||
return DirOffsetX[dir & 0x03];
|
||||
}
|
||||
|
||||
private int GetDirOffsetY(int dir)
|
||||
{
|
||||
int[] offset = new int[] { 0, 1, 0, -1 };
|
||||
return offset[dir & 0x03];
|
||||
return DirOffsetY[dir & 0x03];
|
||||
}
|
||||
|
||||
private void WalkContour(TileCacheLayer layer, int x, int y, TempContour cont)
|
||||
|
|
|
@ -29,22 +29,20 @@ namespace DotRecast.Recast
|
|||
private static readonly int[] DirForOffset = { 3, 0, -1, 2, 1 };
|
||||
|
||||
/// Sets the neighbor connection data for the specified direction.
|
||||
/// @param[in] s The span to update.
|
||||
/// @param[in] dir The direction to set. [Limits: 0 <= value < 4]
|
||||
/// @param[in] i The index of the neighbor span.
|
||||
public static void SetCon(CompactSpan s, int dir, int i)
|
||||
/// @param[in] span The span to update.
|
||||
/// @param[in] direction The direction to set. [Limits: 0 <= value < 4]
|
||||
/// @param[in] neighborIndex The index of the neighbor span.
|
||||
public static void SetCon(CompactSpan span, int direction, int neighborIndex)
|
||||
{
|
||||
int shift = dir * 6;
|
||||
int con = s.con;
|
||||
s.con = (con & ~(0x3f << shift)) | ((i & 0x3f) << shift);
|
||||
int shift = direction * 6;
|
||||
int con = span.con;
|
||||
span.con = (con & ~(0x3f << shift)) | ((neighborIndex & 0x3f) << shift);
|
||||
}
|
||||
|
||||
/// Gets neighbor connection data for the specified direction.
|
||||
/// @param[in] s The span to check.
|
||||
/// @param[in] dir The direction to check. [Limits: 0 <= value < 4]
|
||||
/// @return The neighbor connection data for the specified direction,
|
||||
/// or #RC_NOT_CONNECTED if there is no connection.
|
||||
///
|
||||
/// @param[in] span The span to check.
|
||||
/// @param[in] direction The direction to check. [Limits: 0 <= value < 4]
|
||||
/// @return The neighbor connection data for the specified direction, or #RC_NOT_CONNECTED if there is no connection.
|
||||
public static int GetCon(CompactSpan s, int dir)
|
||||
{
|
||||
int shift = dir * 6;
|
||||
|
@ -52,26 +50,25 @@ namespace DotRecast.Recast
|
|||
}
|
||||
|
||||
/// Gets the standard width (x-axis) offset for the specified direction.
|
||||
/// @param[in] dir The direction. [Limits: 0 <= value < 4]
|
||||
/// @return The width offset to apply to the current cell position to move
|
||||
/// in the direction.
|
||||
/// @param[in] direction The direction. [Limits: 0 <= value < 4]
|
||||
/// @return The width offset to apply to the current cell position to move in the direction.
|
||||
public static int GetDirOffsetX(int dir)
|
||||
{
|
||||
return DirOffsetX[dir & 0x03];
|
||||
}
|
||||
|
||||
// TODO (graham): Rename this to rcGetDirOffsetZ
|
||||
/// Gets the standard height (z-axis) offset for the specified direction.
|
||||
/// @param[in] dir The direction. [Limits: 0 <= value < 4]
|
||||
/// @return The height offset to apply to the current cell position to move
|
||||
/// in the direction.
|
||||
/// @param[in] direction The direction. [Limits: 0 <= value < 4]
|
||||
/// @return The height offset to apply to the current cell position to move in the direction.
|
||||
public static int GetDirOffsetY(int dir)
|
||||
{
|
||||
return DirOffsetY[dir & 0x03];
|
||||
}
|
||||
|
||||
/// Gets the direction for the specified offset. One of x and y should be 0.
|
||||
/// @param[in] x The x offset. [Limits: -1 <= value <= 1]
|
||||
/// @param[in] y The y offset. [Limits: -1 <= value <= 1]
|
||||
/// @param[in] offsetX The x offset. [Limits: -1 <= value <= 1]
|
||||
/// @param[in] offsetZ The z offset. [Limits: -1 <= value <= 1]
|
||||
/// @return The direction that represents the offset.
|
||||
public static int GetDirForOffset(int x, int y)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue