From 0dde5978e02aa7f1c31fe80cbf434ca42640ec81 Mon Sep 17 00:00:00 2001 From: Briggs Baltzell Date: Thu, 5 Mar 2026 12:35:45 -0600 Subject: [PATCH] Refactor vertex handling in `d_menu_cloth` to group vertex and texture operations for improved readability and structure. --- src/d/d_menu_cloth.cpp | 43 ++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/d/d_menu_cloth.cpp b/src/d/d_menu_cloth.cpp index 61e0664cf..92720a9b3 100644 --- a/src/d/d_menu_cloth.cpp +++ b/src/d/d_menu_cloth.cpp @@ -332,13 +332,19 @@ void dMCloth_c::plot(float xMin, float yMin, float xMax, float yMax) { switch (mClothType) { case MENU_CLOTH_TYPE_0: case MENU_CLOTH_TYPE_2: { - GXPosition1x16(x + y * INNER_SIZE); - GXPosition1x16(x + y * INNER_SIZE); - GXPosition2f32(xPos, yPos); + // Vertex 1 + { + const s16 idx = x + y * INNER_SIZE; + GXPosition2s16(idx, idx); + GXTexCoord2f32(xPos, yPos); + } - GXPosition1x16(xNext + y * INNER_SIZE); - GXPosition1x16(xNext + y * INNER_SIZE); - GXPosition2f32(xPos + xStep, yPos); + // Vertex 2 + { + const s16 idx = xNext + y * INNER_SIZE; + GXPosition2s16(idx, idx); + GXTexCoord2f32(xPos + xStep, yPos); + } } break; case MENU_CLOTH_TYPE_1: { @@ -352,6 +358,7 @@ void dMCloth_c::plot(float xMin, float yMin, float xMax, float yMax) { alpha1 = cLib_maxLimit(fromTopRightNext * 25, 0xFF); } + // Vertex 1 { const s16 idx = x + y * INNER_SIZE; GXPosition2s16(idx, idx); @@ -359,6 +366,7 @@ void dMCloth_c::plot(float xMin, float yMin, float xMax, float yMax) { GXTexCoord2f32(xPos, yPos); } + // Vertex 2 { const s16 idx = xNext + y * INNER_SIZE; GXPosition2s16(idx, idx); @@ -388,17 +396,22 @@ void dMCloth_c::plot_shadow(float xMin, float yMin, float xMax, float yMax) { GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT0, INNER_SIZE * 2); f32 yPos = yMax; for (int y = 0; y < INNER_SIZE; y++) { - f32 xPos2 = xPos + xStep; switch (mClothType) { case MENU_CLOTH_TYPE_0: case MENU_CLOTH_TYPE_2: { - GXPosition1x16(x + y * INNER_SIZE); - GXPosition1x16(x + y * INNER_SIZE); - GXTexCoord2f32(xPos, yPos); + // Vertex 1 + { + const s16 idx = x + y * INNER_SIZE; + GXPosition2s16(idx, idx); + GXTexCoord2f32(xPos, yPos); + } - GXPosition1x16(xNext + y * INNER_SIZE); - GXPosition1x16(xNext + y * INNER_SIZE); - GXTexCoord2f32(xPos2, yPos); + // Vertex 2 + { + const s16 idx = xNext + y * INNER_SIZE; + GXPosition2s16(idx, idx); + GXTexCoord2f32(xPos + xStep, yPos); + } } break; case MENU_CLOTH_TYPE_1: { @@ -412,6 +425,7 @@ void dMCloth_c::plot_shadow(float xMin, float yMin, float xMax, float yMax) { alpha1 = cLib_maxLimit(fromTopRightNext * 25, 0xFF); } + // Vertex 1 { const s16 idx = x + y * INNER_SIZE; GXPosition2u16(idx, idx); @@ -419,11 +433,12 @@ void dMCloth_c::plot_shadow(float xMin, float yMin, float xMax, float yMax) { GXTexCoord2f32(xPos, yPos); } + // Vertex 2 { const s16 idx = xNext + y * INNER_SIZE; GXPosition2u16(idx, idx); GXColor4x8(mColor2.r, mColor2.g, mColor2.b, alpha1); - GXTexCoord2f32(xPos2, yPos); + GXTexCoord2f32(xPos + xStep, yPos); } } break; }