recastnavigation / recastnavigation

Industry-standard navigation-mesh toolset for games

Home Page:http://recastnav.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variables and functions named "Y" are used throughout the codebase to refer to Z values

grahamboree opened this issue · comments

It's super confusing that there are cases where z coordinate values are used in variables with the name y. The use of the ambiguous height and width rather than a name that indicates the axis to which that size applies is also confusing. There's nothing functionaly wrong about the code, it's just using very misleading variable names.

rcGetDirOffsetY is a great example case

/// 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.
inline int rcGetDirOffsetY(int dir)
{
static const int offset[4] = { 0, 1, 0, -1 };
return offset[dir&0x03];
}

We should endevor to name things what they are, and avoid ambiguous terms like "width" and "height".

Since many of these cases are user-facing in the Recast interface, we should take care to not introduce breaking changes to the API outside of a major release.

I've started renaming things in implementations to be more accurate and am making notes of places in the interface that would require a major update to change.

"Height" is also used ambiguously to sometimes refer to the number of cells of the heightfield along the z-axis, and sometimes to refer to the number of heightfield cells along the y-axis.

Z-axis "height":

/// The height of the field along the z-axis. [Limit: >= 0] [Units: vx]
int height;

Y-axis "height":

/// Defines the number of bits allocated to rcSpan::smin and rcSpan::smax.
static const int RC_SPAN_HEIGHT_BITS = 13;
/// Defines the maximum value for rcSpan::smin and rcSpan::smax.
static const int RC_SPAN_MAX_HEIGHT = (1 << RC_SPAN_HEIGHT_BITS) - 1;