Style guide updates

Changes to match style recommendations
* Update function variables to camelCase
* Use dOxygen tags
* Use block comment
This commit is contained in:
Jed Grabman 2025-06-15 20:14:39 -04:00
parent b372dc7359
commit 806f992df7
1 changed files with 23 additions and 25 deletions

View File

@ -218,37 +218,35 @@ void mtxf_translate(Mat4 dest, Vec3f b) {
dest[3][1] = b[1];
dest[3][2] = b[2];
}
// Name: get_projection_matrix
// Description:
// Creates a projection matrix based on specified frustrum (i.e. where the camera can see)
// Arguments:
// proj_mat: A dummy variable that will be overwritten with the projection matrix
// arg1: Unknown dummy variable (will be overwritten)
// vert_fov: vertical field of view (in degrees)
// aspect_ratio: Width / Height of player screen
// near: near clipping distance
// far: far clipping distance
// homogeneous_scale: Scaling factor for homogeneous coordinates. Always 1.0 in game
// Note the use of `2` which generates diff asm than just using floats (2.0f).
void get_projection_matrix(Mat4 proj_mat, u16* arg1, f32 vert_fov, f32 aspect_ratio, f32 near, f32 far,
f32 homogeneous_scale) {
/*
* @brief Creates a projection matrix based on specified frustrum (i.e. where the camera can see)
* @param projMat A dummy variable that will be overwritten with the projection matrix
* @param arg1 Unknown dummy variable (will be overwritten)
* @param vertFov vertical field of view (in degrees)
* @param aspectRatio Width / Height of player screen
* @param near near clipping distance
* @param far far clipping distance
* @param homogeneousScale Scaling factor for homogeneous coordinates. Always 1.0 in game
* Note the use of `2` which generates diff asm than just using floats (2.0f).
*/
void get_projection_matrix(Mat4 projMat, u16* arg1, f32 vertFov, f32 aspectRatio, f32 near, f32 far,
f32 homogeneousScale) {
f32 half_cot;
s32 row_idx, col_idx;
mtxf_identity(proj_mat);
vert_fov *= 0.017453292222222222; // convert from degrees to radians
half_cot = cosf(vert_fov / 2) / sinf(vert_fov / 2);
proj_mat[0][0] = half_cot / aspect_ratio;
proj_mat[1][1] = half_cot;
mtxf_identity(projMat);
vertFov *= 0.017453292222222222; // convert from degrees to radians
half_cot = cosf(vertFov / 2) / sinf(vertFov / 2);
projMat[0][0] = half_cot / aspectRatio;
projMat[1][1] = half_cot;
// Literature usually prefers the clearer equivalent -(near + far) / (far - near)
proj_mat[2][2] = (near + far) / (near - far);
proj_mat[2][3] = -1.0f;
proj_mat[3][2] = (2 * near * far) / (near - far);
proj_mat[3][3] = 0.0f;
projMat[2][2] = (near + far) / (near - far);
projMat[2][3] = -1.0f;
projMat[3][2] = (2 * near * far) / (near - far);
projMat[3][3] = 0.0f;
for (row_idx = 0; row_idx < 4; row_idx++) {
for (col_idx = 0; col_idx < 4; col_idx++) {
proj_mat[row_idx][col_idx] *= homogeneous_scale;
projMat[row_idx][col_idx] *= homogeneousScale;
}
}