Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
grahamboree opened this issue Dec 10, 2022 · 1 comment

Comments

@grahamboree
Copy link
Member

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.

@grahamboree
Copy link
Member Author

"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;

@grahamboree grahamboree added this to the 2.0.0 milestone Jul 4, 2023
@grahamboree grahamboree removed their assignment Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant