From e0263e0009c842593fa2cd596f102824ea5713f1 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Wed, 17 Dec 2025 10:10:12 -0600 Subject: [PATCH 1/8] zLasso: 100% match for zLasso_SetGuide --- src/SB/Game/zLasso.cpp | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/SB/Game/zLasso.cpp b/src/SB/Game/zLasso.cpp index 34b3885a0..74e19582c 100644 --- a/src/SB/Game/zLasso.cpp +++ b/src/SB/Game/zLasso.cpp @@ -18,52 +18,35 @@ static s32 negativeHondaX = 1; void zLasso_SetGuide(xEnt* ent, xAnimState* lassoAnim) { - // FIXME: 90% disassembly match, needs more work to get all the way - zLassoGuideList* temp_r5; - zLassoGuideList* var_r3; - zLassoGuideList* var_r5; - sCurrentGuide = NULL; - if (ent == NULL || lassoAnim == NULL) { return; } - var_r5 = sGuideList; - u32 guideListIdx = 0; - - for (u32 i = sNumGuideLists; i > 0; i--) + U32 guideListIdx = 0; + for (U32 i = 0; i < sNumGuideLists; i++, guideListIdx++) { - if (var_r5->target == ent) + if (sGuideList[i].target == ent) { break; } - - var_r5 += 1; - guideListIdx += 1; } if (guideListIdx < sNumGuideLists) { - u32 guideIdx = 0; - - temp_r5 = &sGuideList[guideListIdx]; - var_r3 = temp_r5; - for (u32 i = temp_r5->numGuides; i > 0; i--) + U32 guideIdx = 0; + for (U32 i = 0; i < sGuideList[guideListIdx].numGuides; i++, guideIdx++) { - if (var_r3->guide[0].lassoAnim == lassoAnim) + if (sGuideList[guideListIdx].guide[i].lassoAnim == lassoAnim) { break; } - - var_r3 += 1; - guideIdx += 1; } if (guideIdx < sGuideList[guideListIdx].numGuides) { - sCurrentGuide = &temp_r5->guide[guideIdx]; + sCurrentGuide = &sGuideList[guideListIdx].guide[guideIdx]; } } From 8e59831e92a3964cb26d16bb0c7d88a82b966937 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Wed, 17 Dec 2025 19:53:01 -0600 Subject: [PATCH 2/8] zLasso: 100% match for bakeMorphAnim --- src/SB/Game/zLasso.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/SB/Game/zLasso.cpp b/src/SB/Game/zLasso.cpp index 74e19582c..84eb005fd 100644 --- a/src/SB/Game/zLasso.cpp +++ b/src/SB/Game/zLasso.cpp @@ -2,7 +2,7 @@ #include "xMath3.h" #include "xMathInlines.h" - +#include "iAnim.h" #include "iModel.h" #include @@ -267,3 +267,33 @@ void vec2vecMat(xMat4x3* m, xVec3* v1, xVec3* v2) F32 f1 = xasin(xVec3Normalize(&v3, &v3)); xMat4x3Rot(m, &v3, f1); } + +static void bakeMorphAnim(RpGeometry* geom, void* anim) { + + if (*(U32*)anim & 0x80000000) + { + return; + } + + *(U32*)anim |= 0x80000000; + + xMat4x3 mat; + xVec3 tran[64]; + xQuat quat[64]; + + iAnimEval(anim, 0.0f, 0x0, tran, quat); + xQuatToMat(quat, &mat); + mat.pos = tran[0]; + + S32 i, j; + for (i = 0; i < geom->numMorphTargets; i++) + { + S32 numV = geom->numVertices; + xVec3* v = (xVec3*)geom->morphTarget[i].verts; + + for (j = 0; j < numV; j++) + { + xMat4x3Toworld(&v[j], &mat, &v[j]); + } + } +} From b2c4a9c01c08033fc2c55f1056bcfc055d7342a1 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Thu, 18 Dec 2025 22:15:36 -0600 Subject: [PATCH 3/8] zLasso: Use DWARF symbols to clean up zLasso_InterpToGuide --- src/SB/Game/zLasso.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/SB/Game/zLasso.cpp b/src/SB/Game/zLasso.cpp index 84eb005fd..f77678deb 100644 --- a/src/SB/Game/zLasso.cpp +++ b/src/SB/Game/zLasso.cpp @@ -58,33 +58,33 @@ void zLasso_SetGuide(xEnt* ent, xAnimState* lassoAnim) void zLasso_InterpToGuide(zLasso* lasso) { - xVec3 sp14; - xVec3 sp8; + xVec3 rad1; + xVec3 rad2; - RwV3d* morphTargetVector; - S32 currentGuideNumTris; + RwV3d* v; + S32 numVerts; if (sCurrentGuide != NULL) { - currentGuideNumTris = sCurrentGuide->poly->Data->geometry->numTriangles; - morphTargetVector = sCurrentGuide->poly->Data->geometry->morphTarget->verts; + numVerts = sCurrentGuide->poly->Data->geometry->numTriangles; + v = sCurrentGuide->poly->Data->geometry->morphTarget->verts; xVec3Init(&lasso->tgCenter, 0.0f, 0.0f, 0.0f); S32 vertMapIdx = 0; - for (S32 i = 0; i < currentGuideNumTris; i++) + for (S32 i = 0; i < numVerts; i++) { xVec3AddTo(&lasso->tgCenter, - (xVec3*)morphTargetVector + sCurrentGuide->vertMap[vertMapIdx]); + (xVec3*)v + sCurrentGuide->vertMap[vertMapIdx]); vertMapIdx += 1; } - xVec3SMul(&lasso->tgCenter, &lasso->tgCenter, 1.0f / (f32)currentGuideNumTris); - xVec3Sub(&sp14, (xVec3*)morphTargetVector + sCurrentGuide->vertMap[0], &lasso->tgCenter); - xVec3Sub(&sp8, (xVec3*)morphTargetVector + sCurrentGuide->vertMap[1], &lasso->tgCenter); + xVec3SMul(&lasso->tgCenter, &lasso->tgCenter, 1.0f / (f32)numVerts); + xVec3Sub(&rad1, (xVec3*)v + sCurrentGuide->vertMap[0], &lasso->tgCenter); + xVec3Sub(&rad2, (xVec3*)v + sCurrentGuide->vertMap[1], &lasso->tgCenter); - lasso->tgRadius = xVec3Normalize(&sp14, &sp14); + lasso->tgRadius = xVec3Normalize(&rad1, &rad1); - xVec3Cross(&lasso->tgNormal, &sp14, &sp8); + xVec3Cross(&lasso->tgNormal, &rad1, &rad2); xVec3Normalize(&lasso->tgNormal, &lasso->tgNormal); if (lasso->tgNormal.y < 0.0f) From f03d57429d13c60e810a9c3e55c06d2712fff7fe Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Thu, 18 Dec 2025 23:06:36 -0600 Subject: [PATCH 4/8] zLasso: Clean up fizzical static functions --- src/SB/Game/zLasso.cpp | 54 ++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/src/SB/Game/zLasso.cpp b/src/SB/Game/zLasso.cpp index f77678deb..76d1ec16e 100644 --- a/src/SB/Game/zLasso.cpp +++ b/src/SB/Game/zLasso.cpp @@ -155,22 +155,22 @@ void zLasso_ResetTimer(zLasso* lasso, F32 interpTime) xVec3Add(&lasso->stCenter, &lasso->crCenter, &lasso->anchor); } -void fizzicalRadius(zLasso* lasso, f32 arg1, xVec3* arg2) +static void fizzicalRadius(zLasso* lasso, F32 dt, xVec3* newPoint) { - lasso->crRadius = -((2.0f * (0.75f - lasso->crSlack) * arg1) - lasso->crRadius); + lasso->crRadius = -((2.0f * (0.75f - lasso->crSlack) * dt) - lasso->crRadius); if (lasso->crRadius < 0.0f) { lasso->crRadius = 0.0f; } } -void fizzicalCenter(zLasso* lasso, f32 arg1, xVec3* arg2) +static void fizzicalCenter(zLasso* lasso, F32 dt, xVec3* newPoint) { xVec3AddScaled(&lasso->crCenter, &lasso->lastRefs[lasso->reindex[4]], -0.2f); - xVec3AddScaled(&lasso->crCenter, arg2, 0.2f); + xVec3AddScaled(&lasso->crCenter, newPoint, 0.2f); } -void fizzicalNormal(zLasso* lasso, f32 arg1, xVec3* arg2) +static void fizzicalNormal(zLasso* lasso, F32 dt, xVec3* newPoint) { xVec3 sp8; f32 temp_f31; @@ -181,39 +181,38 @@ void fizzicalNormal(zLasso* lasso, f32 arg1, xVec3* arg2) xVec3Normalize(&lasso->crNormal, &lasso->crNormal); } -void fizzicalHonda(zLasso* lasso, f32 arg1, xVec3* arg2) +static void fizzicalHonda(zLasso* lasso, F32 dt, xVec3* newPoint) { - xVec3* temp_r3; - - xVec3SMul(&lasso->honda, arg2, -1.0f); + xVec3SMul(&lasso->honda, newPoint, -1.0f); xVec3AddScaled(&lasso->honda, &lasso->lastRefs[lasso->reindex[0]], 0.571429f); xVec3AddScaled(&lasso->honda, &lasso->lastRefs[lasso->reindex[1]], 0.285714f); xVec3AddScaled(&lasso->honda, &lasso->lastRefs[lasso->reindex[2]], 0.142857f); xVec3AddScaled(&lasso->honda, &lasso->crNormal, -xVec3Dot(&lasso->crNormal, &lasso->honda)); - temp_r3 = &lasso->honda; - xVec3Normalize(temp_r3, temp_r3); + xVec3Normalize(&lasso->honda, &lasso->honda); xVec3SMulBy(&lasso->honda, lasso->crRadius); - if (((s32)negativeHondaX != 0) && (lasso->honda.x > 0.0f)) + + if ((negativeHondaX != 0) && (lasso->honda.x > 0.0f)) { - xSndPlay3D(xStrHash(&"rope\0sound_rope_windup"[5]), 0.77f, 0.0f, 0U, 0x10000U, - &lasso->anchor, 100.0f, (sound_category)0, 0.0f); + xSndPlay3D(xStrHash("sound_rope_windup"), 0.77f, 0.0f, 0U, 0x10000U, &lasso->anchor, 100.0f, + SND_CAT_GAME, 0.0f); negativeHondaX = 0; } + if (lasso->honda.x < 0.0f) { negativeHondaX = 1; } + xVec3AddTo(&lasso->honda, &lasso->crCenter); } -void nonfizzicalHonda(zLasso* lasso, f32 arg1, xVec3* arg2) +static void nonfizzicalHonda(zLasso* lasso, F32 dt, xVec3* newPoint) { - f32 temp_f1; - - xVec3Sub(&lasso->honda, arg2, &lasso->crCenter); + xVec3Sub(&lasso->honda, newPoint, &lasso->crCenter); xVec3AddScaled(&lasso->honda, &lasso->crNormal, -xVec3Dot(&lasso->honda, &lasso->crNormal)); - temp_f1 = xVec3Length2(&lasso->honda); - if (temp_f1 < 0.00001f) + + F32 hondaLength = xVec3Length2(&lasso->honda); + if (hondaLength < 0.00001f) { lasso->honda.x = lasso->crNormal.y; lasso->honda.y = -lasso->crNormal.x; @@ -222,22 +221,21 @@ void nonfizzicalHonda(zLasso* lasso, f32 arg1, xVec3* arg2) xVec3AddTo(&lasso->honda, &lasso->crCenter); return; } - xVec3SMulBy(&lasso->honda, lasso->crRadius / xsqrt(temp_f1)); + + xVec3SMulBy(&lasso->honda, lasso->crRadius / xsqrt(hondaLength)); xVec3AddTo(&lasso->honda, &lasso->crCenter); } -void fizzicalSlack(zLasso* lasso, f32 arg1, xVec3* arg2) +static void fizzicalSlack(zLasso* lasso, F32 dt, xVec3* newPoint) { - f32 temp_f1; - - lasso->crSlack += (2.0f * (lasso->lastDist - lasso->currDist)) - (0.6f * arg1); - temp_f1 = lasso->crSlack; - if (temp_f1 < 0.0f) + lasso->crSlack += (2.0f * (lasso->lastDist - lasso->currDist)) - (0.6f * dt); + if (lasso->crSlack < 0.0f) { lasso->crSlack = 0.0f; return; } - if (temp_f1 > 1.0f) + + if (lasso->crSlack > 1.0f) { lasso->crSlack = 1.0f; } From 1b6ee0955d3cae939ec92288f6f16a508418dd5f Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Thu, 18 Dec 2025 23:07:07 -0600 Subject: [PATCH 5/8] zLasso: Mark vec2vecMat as static --- src/SB/Game/zLasso.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SB/Game/zLasso.cpp b/src/SB/Game/zLasso.cpp index 76d1ec16e..5d1bb8a4f 100644 --- a/src/SB/Game/zLasso.cpp +++ b/src/SB/Game/zLasso.cpp @@ -258,7 +258,7 @@ void xMat4x3Rot(xMat4x3* m, const xVec3* v, F32 f) xMat4x3RotC(m, v->x, v->y, v->z, f); } -void vec2vecMat(xMat4x3* m, xVec3* v1, xVec3* v2) +static void vec2vecMat(xMat4x3* m, xVec3* v1, xVec3* v2) { xVec3 v3; xVec3Cross(&v3, v1, v2); @@ -266,8 +266,8 @@ void vec2vecMat(xMat4x3* m, xVec3* v1, xVec3* v2) xMat4x3Rot(m, &v3, f1); } -static void bakeMorphAnim(RpGeometry* geom, void* anim) { - +static void bakeMorphAnim(RpGeometry* geom, void* anim) +{ if (*(U32*)anim & 0x80000000) { return; From a2e6fee307516e716bf858bffb7ae666ec622b9a Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Fri, 19 Dec 2025 12:25:54 -0600 Subject: [PATCH 6/8] zLasso: Match on zLasso_Update --- src/SB/Game/zLasso.cpp | 136 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/src/SB/Game/zLasso.cpp b/src/SB/Game/zLasso.cpp index 5d1bb8a4f..d0ab4e49e 100644 --- a/src/SB/Game/zLasso.cpp +++ b/src/SB/Game/zLasso.cpp @@ -104,6 +104,142 @@ void zLasso_Render(zLasso* l) } } +void zLasso_Update(zLasso* lasso, xEnt* ent, F32 dt) +{ + xVec3 newPoint; + iModelTagEval(ent->model->Data, &lasso->tag, lasso->model->Mat, &newPoint); + xVec3Copy(&lasso->anchor, (xVec3*)&ent->model->Mat->pos); + xVec3SubFrom(&newPoint, &lasso->anchor); + + if (!(lasso->flags & 0x800)) + { + lasso->secsLeft -= dt; + + if (lasso->secsLeft < 0.0f) + { + lasso->secsLeft = 0.0f; + lasso->flags |= 0x800; + } + + F32 interp = 1.0f - (lasso->secsLeft / lasso->secsTotal); + if (!(lasso->flags & 0x2000)) + { + if (lasso->flags & 0x8) + { + fizzicalRadius(lasso, dt, &newPoint); + } + else + { + lasso->crRadius = lasso->stRadius * (1.0f - interp) + lasso->tgRadius * interp; + } + + if (lasso->flags & 0x2) + { + fizzicalCenter(lasso, dt, &newPoint); + } + else + { + xVec3SMul(&lasso->crCenter, &lasso->stCenter, 1.0f - interp); + xVec3AddScaled(&lasso->crCenter, &lasso->tgCenter, interp); + xVec3SubFrom(&lasso->crCenter, &lasso->anchor); + } + + if (lasso->flags & 0x4) + { + fizzicalNormal(lasso, dt, &newPoint); + } + else + { + xVec3SMul(&lasso->crNormal, &lasso->stNormal, 1.0f - interp); + xVec3AddScaled(&lasso->crNormal, &lasso->tgNormal, interp); + } + + xVec3SMulBy(&lasso->crNormal, 1.0f / xVec3Length(&lasso->crNormal)); + + if (lasso->flags & 0x10) + { + fizzicalHonda(lasso, dt, &newPoint); + } + else + { + nonfizzicalHonda(lasso, dt, &newPoint); + } + } + + if (lasso->flags & 0x20) + { + fizzicalSlack(lasso, dt, &newPoint); + } + else + { + lasso->crSlack = lasso->stSlack * (1.0f - interp) + lasso->tgSlack * interp; + } + } + else + { + if (!(lasso->flags & 0x4000)) + { + if (lasso->flags & 0x100) + { + fizzicalRadius(lasso, dt, &newPoint); + } + + if (lasso->flags & 0x40) + { + fizzicalCenter(lasso, dt, &newPoint); + } + + if (lasso->flags & 0x80) + { + fizzicalNormal(lasso, dt, &newPoint); + xVec3SMulBy(&lasso->crNormal, 1.0f / xVec3Length(&lasso->crNormal)); + } + + if (lasso->flags & 0x200) + { + fizzicalHonda(lasso, dt, &newPoint); + } + else + { + nonfizzicalHonda(lasso, dt, &newPoint); + } + } + + if (lasso->flags & 0x400) + { + fizzicalSlack(lasso, dt, &newPoint); + } + } + + xVec3Copy(&lasso->lastRefs[lasso->reindex[4]], &newPoint); + + lasso->reindex[0] = lasso->reindex[4]; + + lasso->reindex[1] = lasso->reindex[0] + 1; + if (lasso->reindex[1] > 4) + { + lasso->reindex[1] -= 5; + } + + lasso->reindex[2] = lasso->reindex[0] + 2; + if (lasso->reindex[2] > 4) + { + lasso->reindex[2] -= 5; + } + + lasso->reindex[3] = lasso->reindex[0] + 3; + if (lasso->reindex[3] > 4) + { + lasso->reindex[3] -= 5; + } + + lasso->reindex[4] = lasso->reindex[0] + 4; + if (lasso->reindex[4] > 4) + { + lasso->reindex[4] -= 5; + } +} + void zLasso_InitTimer(zLasso* lasso, F32 interpTime) { lasso->secsTotal = interpTime; From 2c4a0ce0574d67bd27e4fd51dc71e3e6056f63ef Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Fri, 19 Dec 2025 12:30:17 -0600 Subject: [PATCH 7/8] zLasso: Add static decls, start zLasso_AddGuide and zLasso_Init --- src/SB/Core/gc/iParMgr.h | 4 +-- src/SB/Game/zLasso.cpp | 64 ++++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/src/SB/Core/gc/iParMgr.h b/src/SB/Core/gc/iParMgr.h index e13f769e4..ce6920843 100644 --- a/src/SB/Core/gc/iParMgr.h +++ b/src/SB/Core/gc/iParMgr.h @@ -9,7 +9,6 @@ struct tagiRenderArrays { // total size: 0x5280 - public: U16 m_index[960]; // offset 0x0, size 0x780 RxObjSpace3DVertex m_vertex[480]; // offset 0x780, size 0x4380 F32 m_vertexTZ[480]; // offset 0x4B00, size 0x780 @@ -32,7 +31,8 @@ struct tagiRenderInput xVec4 m_camViewU; // offset 0x70, size 0x10 }; -extern tagiRenderInput gRenderBuffer; +extern tagiRenderArrays gRenderArr; +extern tagiRenderInput gRenderBuffer; void iParMgrInit(); void iParMgrUpdate(F32 elapsedTime); diff --git a/src/SB/Game/zLasso.cpp b/src/SB/Game/zLasso.cpp index d0ab4e49e..c2ac21e70 100644 --- a/src/SB/Game/zLasso.cpp +++ b/src/SB/Game/zLasso.cpp @@ -4,17 +4,64 @@ #include "xMathInlines.h" #include "iAnim.h" #include "iModel.h" +#include "xstransvc.h" +#include "iParMgr.h" #include -static u32 sLassoRaster; -static u32 sNumGuideLists; +static RwRaster* sLassoRaster; +static U32 sNumGuideLists; static zLassoGuide* sCurrentGuide; -static void* lnverts; +static RxObjSpace3DVertex* lnverts; static zLassoGuideList sGuideList[64]; -static s32 negativeHondaX = 1; +static S32 negativeHondaX = 1; + +static void fizzicalRadius(zLasso* lasso, f32 arg1, xVec3* arg2); +static void fizzicalCenter(zLasso* lasso, f32 arg1, xVec3* arg2); +static void fizzicalNormal(zLasso* lasso, f32 arg1, xVec3* arg2); +static void fizzicalHonda(zLasso* lasso, f32 arg1, xVec3* arg2); +static void nonfizzicalHonda(zLasso* lasso, f32 arg1, xVec3* arg2); +static void fizzicalSlack(zLasso* lasso, f32 arg1, xVec3* arg2); +static void initVertMap(zLassoGuide* guide); +static void bakeMorphAnim(RpGeometry* geom, void* anim); + +void zLasso_Init(zLasso* lasso, xModelInstance* model, F32 x, F32 y, F32 z) +{ + if (sLassoRaster == NULL) + { + RwTexture* tempTexture = (RwTexture*)xSTFindAsset(xStrHash("rope"), NULL); + if (tempTexture != NULL) + { + sLassoRaster = tempTexture->raster; + } + else + { + sLassoRaster = NULL; + } + } + + iModelTagSetup(&lasso->tag, model->Data, x, y, z); + + lasso->model = model; + lnverts = gRenderArr.m_vertex; +} + +void zLasso_AddGuide(xEnt* ent, xAnimState* lassoAnim, xModelInstance* lassoModel) +{ + S32 givenSlot = -1; + for (U32 i = 0; i < sNumGuideLists; i++) + { + } + + sGuideList[0].numGuides = sGuideList[0].numGuides + 1; + // sGuideList[0].guide[0].poly = lassoModel; + // sGuideList[0].guide[0].lassoAnim = lassoAnim; + initVertMap(sGuideList[0].guide); + + bakeMorphAnim(lassoModel->Data->geometry, *lassoAnim->Data->RawData); +} void zLasso_SetGuide(xEnt* ent, xAnimState* lassoAnim) { @@ -73,8 +120,7 @@ void zLasso_InterpToGuide(zLasso* lasso) S32 vertMapIdx = 0; for (S32 i = 0; i < numVerts; i++) { - xVec3AddTo(&lasso->tgCenter, - (xVec3*)v + sCurrentGuide->vertMap[vertMapIdx]); + xVec3AddTo(&lasso->tgCenter, (xVec3*)v + sCurrentGuide->vertMap[vertMapIdx]); vertMapIdx += 1; } @@ -98,7 +144,7 @@ void zLasso_InterpToGuide(zLasso* lasso) void zLasso_Render(zLasso* l) { - if ((((l->flags & 0x800) != 0) && ((l->flags & 0x4000) != 0)) || + if ((((l->flags & 0x800) != 0) && ((l->flags & 0x4000) != 0)) || (((l->flags & 0x800) == 0 && ((l->flags & 0x2000) != 0)))) { } @@ -408,9 +454,9 @@ static void bakeMorphAnim(RpGeometry* geom, void* anim) { return; } - + *(U32*)anim |= 0x80000000; - + xMat4x3 mat; xVec3 tran[64]; xQuat quat[64]; From e14ca353ccd8ca4f5d63dc87ccdbb5544347b8f9 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Fri, 19 Dec 2025 21:36:51 -0600 Subject: [PATCH 8/8] zLasso: Partial match for initVertMap --- src/SB/Game/zLasso.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/SB/Game/zLasso.cpp b/src/SB/Game/zLasso.cpp index c2ac21e70..a1b347c85 100644 --- a/src/SB/Game/zLasso.cpp +++ b/src/SB/Game/zLasso.cpp @@ -440,6 +440,65 @@ void xMat4x3Rot(xMat4x3* m, const xVec3* v, F32 f) xMat4x3RotC(m, v->x, v->y, v->z, f); } +static void initVertMap(zLassoGuide* guide) +{ + RpGeometry* geom = guide->poly->Data->geometry; + RpTriangle* tris = geom->triangles; + S32 numTri = geom->numTriangles; + + S32 center = tris->vertIndex[0]; + S32 init = tris->vertIndex[0]; + + if (((init != tris->vertIndex[4] && init != tris->vertIndex[5] && init != tris->vertIndex[6]) || + (init != tris->vertIndex[8] && init != tris->vertIndex[9] && init != tris->vertIndex[10])) && + ((init = tris->vertIndex[1], init != tris->vertIndex[4] && init != tris->vertIndex[5] && init != tris->vertIndex[6]) || + (init != tris->vertIndex[8] && init != tris->vertIndex[9] && init != tris->vertIndex[10]))) + { + init = tris->vertIndex[2]; + } + + if (init == tris->vertIndex[0]) { + init = tris->vertIndex[1]; + } + + S32 vertIdx = 0; + S32 curr = init; + S32 currTri; + ushort* puVar5; + + do { + vertIdx = vertIdx + 1; + guide->vertMap[vertIdx - 1] = curr; + + if (vertIdx == numTri) { + vertIdx = 0; + } + + while (true) { + puVar5 = &tris->vertIndex[vertIdx]; + currTri = puVar5[0]; + + if (curr == currTri || curr == puVar5[1] || curr == puVar5[2]) { + break; + } + + vertIdx = vertIdx + 1; + if (vertIdx == numTri) { + vertIdx = 0; + } + } + + if ((curr != currTri && center != currTri)) { + currTri = puVar5[1]; + if ((curr != currTri && center != currTri)) { + currTri = puVar5[2]; + } + } + + curr = currTri; + } while (currTri != init); +} + static void vec2vecMat(xMat4x3* m, xVec3* v1, xVec3* v2) { xVec3 v3;