|
@@ -58,17 +58,17 @@ static inline Direction ReverseDir(Direc
|
|
|
assert(IsValidDirection(d));
|
|
|
return (Direction)(4 ^ d);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Calculate the difference between to directions
|
|
|
* Calculate the difference between two directions
|
|
|
*
|
|
|
* @param d0 The first direction as the base
|
|
|
* @param d1 The second direction as the offset from the base
|
|
|
* @return The difference how the second directions drifts of the first one.
|
|
|
* @return The difference how the second direction drifts of the first one.
|
|
|
*/
|
|
|
static inline DirDiff DirDifference(Direction d0, Direction d1)
|
|
|
{
|
|
|
assert(IsValidDirection(d0));
|
|
|
assert(IsValidDirection(d1));
|
|
|
/* Cast to uint so compiler can use bitmask. If the difference is negative
|
|
@@ -76,13 +76,13 @@ static inline DirDiff DirDifference(Dire
|
|
|
return (DirDiff)((uint)(d0 - d1) % 8);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Applies two differences together
|
|
|
*
|
|
|
* This function adds two differences together and return the resulting
|
|
|
* This function adds two differences together and returns the resulting
|
|
|
* difference. So adding two DIRDIFF_REVERSE together results in the
|
|
|
* DIRDIFF_SAME difference.
|
|
|
*
|
|
|
* @param d The first difference
|
|
|
* @param delta The second difference to add on
|
|
|
* @return The resulting difference
|
|
@@ -120,12 +120,26 @@ static inline Direction ChangeDir(Direct
|
|
|
static inline DiagDirection ReverseDiagDir(DiagDirection d)
|
|
|
{
|
|
|
assert(IsValidDiagDirection(d));
|
|
|
return (DiagDirection)(2 ^ d);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Calculate the difference between two DiagDirection values
|
|
|
*
|
|
|
* @param d0 The first direction as the base
|
|
|
* @param d1 The second direction as the offset from the base
|
|
|
* @return The difference how the second direction drifts of the first one.
|
|
|
*/
|
|
|
static inline DiagDirDiff DiagDirDifference(DiagDirection d0, DiagDirection d1)
|
|
|
{
|
|
|
assert(IsValidDiagDirection(d0));
|
|
|
assert(IsValidDiagDirection(d1));
|
|
|
/* Cast to uint so compiler can use bitmask. Result can never be negative. */
|
|
|
return (DiagDirDiff)((uint)(d0 - d1) % 4);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Applies a difference on a DiagDirection
|
|
|
*
|
|
|
* This function applies a difference on a DiagDirection and returns
|
|
|
* the new DiagDirection.
|