diff --git a/src/game/body.c b/src/game/body.c index e72eeaac3..598e66cc1 100644 --- a/src/game/body.c +++ b/src/game/body.c @@ -184,7 +184,7 @@ struct model *body0f02ce8c(s32 bodynum, s32 headnum, struct modelfiledata *bodyf bodyfiledata = g_HeadsAndBodies[bodynum].filedata; } - modelCalculateRwDataLen(bodyfiledata); + modelAllocateRwData(bodyfiledata); if (!g_HeadsAndBodies[bodynum].unk00_01) { if (bodyfiledata->skel == &g_SkelChr) { @@ -210,7 +210,7 @@ struct model *body0f02ce8c(s32 bodynum, s32 headnum, struct modelfiledata *bodyf } } - modelCalculateRwDataLen(headfiledata); + modelAllocateRwData(headfiledata); bodyfiledata->rwdatalen += headfiledata->rwdatalen; @@ -259,7 +259,7 @@ struct model *body0f02ce8c(s32 bodynum, s32 headnum, struct modelfiledata *bodyf if (headfiledata && !g_HeadsAndBodies[bodynum].unk00_01) { bodyfiledata->rwdatalen -= headfiledata->rwdatalen; - modelmgr0f0b32a0(model, node, headfiledata); + modelmgrAttachHead(model, node, headfiledata); if ((s16)*(s32 *)&headfiledata->skel == SKEL_HEAD) { struct modelnode *node2; diff --git a/src/game/bondgun.c b/src/game/bondgun.c index 1fd6d86b5..7cdb8e26b 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -655,7 +655,7 @@ void bgun0f0981e8(struct hand *hand, struct modelfiledata *modeldef) if (hand->unk0ce8 && animspeed < 0.0f) { modelSetAnimation(&hand->gunmodel, hand->animload, false, 0.0f, animspeedmult * animspeed, 0.0f); - model0001e018(&hand->gunmodel, modelGetNumAnimFrames(&hand->gunmodel)); + modelSetAnimFrame(&hand->gunmodel, modelGetNumAnimFrames(&hand->gunmodel)); } else { modelSetAnimation(&hand->gunmodel, hand->animload, false, 0.0f, animspeedmult * animspeed, 0.0f); } @@ -772,7 +772,7 @@ void bgun0f0981e8(struct hand *hand, struct modelfiledata *modeldef) hand->animframeinc = 0; #endif - model0001e018(&hand->gunmodel, sp78); + modelSetAnimFrame(&hand->gunmodel, sp78); hand->animloopcount++; s2 = sp78; } @@ -795,9 +795,9 @@ void bgun0f0981e8(struct hand *hand, struct modelfiledata *modeldef) #if VERSION >= VERSION_PAL_BETA modelSetAnimPlaySpeed(&hand->gunmodel, PALUPF(4.0f), 0); - model0001ee18(&hand->gunmodel, hand->animframeinc, true); + modelTickAnimQuarterSpeed(&hand->gunmodel, hand->animframeinc, true); #else - model0001f314(&hand->gunmodel, hand->animframeinc, true); + modelTickAnim(&hand->gunmodel, hand->animframeinc, true); #endif s2 = bgun0f09815c(hand); @@ -2093,7 +2093,7 @@ bool bgun0f09aba4(struct hand *hand, struct handweaponinfo *info, s32 handnum, s if (unk27 > frames - hand->statevar1) { mult1 = cosf((f32)(unk27 - frames + hand->statevar1) * 1.5707963705063f / (f32)unk27) * 0.5f + 0.5f; - hand->rotxoffset = model0001afe8(hand->rotxstart, hand->rotxend, mult1); + hand->rotxoffset = modelTweenRotAxis(hand->rotxstart, hand->rotxend, mult1); hand->useposrot = true; hand->posoffset.x = (hand->posend.x - hand->posstart.x) * mult1 + hand->posstart.x; @@ -2133,7 +2133,7 @@ bool bgun0f09aba4(struct hand *hand, struct handweaponinfo *info, s32 handnum, s mult2 = cosf((f32)(frames - unk24) * M_PI / (f32)unk25) * 0.5f + 0.5f; } - hand->rotxoffset = model0001afe8(hand->rotxstart, hand->rotxend, mult2); + hand->rotxoffset = modelTweenRotAxis(hand->rotxstart, hand->rotxend, mult2); hand->useposrot = true; hand->posoffset.x = (hand->posend.x - hand->posstart.x) * mult2 + hand->posstart.x; @@ -3894,7 +3894,7 @@ void bgunTickGunLoad(void) fileGetLoadedSize(player->gunctrl.loadfilenum); fileGetLoadedSize(player->gunctrl.loadfilenum); - modelCalculateRwDataLen(modeldef); + modelAllocateRwData(modeldef); osSyncPrintf("BriGun: propgfx_decompress 0x%08x\n"); osSyncPrintf("BriGun: DL waste space %d from %d (Used %d, Ramlen %d, ObSize %d)\n"); @@ -4648,7 +4648,7 @@ void bgunUpdateHeldRocket(s32 handnum) model->matrices = gfxAllocate(model->filedata->nummatrices * sizeof(Mtxf)); mtx4Copy(&hand->muzzlemat, &model->matrices[0]); - model0001cb0c(model, model->filedata->rootnode); + modelUpdateRelationsQuick(model, model->filedata->rootnode); objprop->flags |= PROPFLAG_ONANYSCREENTHISTICK | PROPFLAG_ONTHISSCREENTHISTICK; objprop->z = -model->matrices[0].m[3][2]; @@ -6376,7 +6376,7 @@ void bgunExecuteModelCmdList(s32 *ptr) break; case 2: rwdata = (union modelrwdata *)ptr[1]; - rwdata->headspot.modelfiledata = NULL; + rwdata->headspot.headmodeldef = NULL; rwdata->headspot.rwdatas = NULL; ptr += 2; break; @@ -6446,7 +6446,7 @@ s32 bgunCreateModelCmdList(struct model *model, struct modelnode *nodearg, s32 * break; case MODELNODETYPE_HEADSPOT: rwdata = modelGetNodeRwData(model, node); - rwdata->headspot.modelfiledata = NULL; + rwdata->headspot.headmodeldef = NULL; rwdata->headspot.rwdatas = NULL; ptr[0] = 2; ptr[1] = (s32)rwdata; @@ -6473,7 +6473,7 @@ s32 bgunCreateModelCmdList(struct model *model, struct modelnode *nodearg, s32 * rodata = node->rodata; rwdata = modelGetNodeRwData(model, node); rwdata->dl.vertices = rodata->dl.vertices; - rwdata->dl.gdl = rodata->dl.primary; + rwdata->dl.gdl = rodata->dl.opagdl; rwdata->dl.colours = (void *)ALIGN8((u32)&rodata->dl.vertices[rodata->dl.numvertices]); ptr[0] = 5; ptr[1] = (s32)rwdata; @@ -6782,7 +6782,7 @@ void bgunUpdateLasersight(struct hand *hand, struct modelfiledata *modeldef, s32 node = modelGetPart(modeldef, MODELPART_FALCON2_0034); if (node) { - mtxindex = model0001a524(node, 0); + mtxindex = modelFindNodeMtxIndex(node, 0); beamnear.x = ((Mtxf *)((u32)allocation + mtxindex * sizeof(Mtxf)))->m[3][0]; beamnear.y = ((Mtxf *)((u32)allocation + mtxindex * sizeof(Mtxf)))->m[3][1]; @@ -6830,7 +6830,7 @@ void bgunUpdateLasersight(struct hand *hand, struct modelfiledata *modeldef, s32 } if (busy) { - mtxindex = model0001a524(node, 0); + mtxindex = modelFindNodeMtxIndex(node, 0); beamfar.x = 0.0f; beamfar.y = 0.0f; @@ -6935,7 +6935,7 @@ void bgunUpdateReaper(struct hand *hand, struct modelfiledata *modeldef) } if (node) { - var8009d0dc = model0001a524(node, 0); + var8009d0dc = modelFindNodeMtxIndex(node, 0); g_ModelJointPositionedFunc = bgun0f0a256c; var8009d0f0[0] = var8009d0f0[1] = var8009d0f0[2] = -1; } @@ -6943,19 +6943,19 @@ void bgunUpdateReaper(struct hand *hand, struct modelfiledata *modeldef) node = modelGetPart(modeldef, MODELPART_REAPER_002D); if (node) { - var8009d0f0[0] = model0001a524(node, 0); + var8009d0f0[0] = modelFindNodeMtxIndex(node, 0); } node = modelGetPart(modeldef, MODELPART_REAPER_002E); if (node) { - var8009d0f0[1] = model0001a524(node, 0); + var8009d0f0[1] = modelFindNodeMtxIndex(node, 0); } node = modelGetPart(modeldef, MODELPART_REAPER_002F); if (node) { - var8009d0f0[2] = model0001a524(node, 0); + var8009d0f0[2] = modelFindNodeMtxIndex(node, 0); } } @@ -6981,7 +6981,7 @@ void bgunUpdateSniperRifle(struct modelfiledata *modeldef, u8 *allocation) for (i = 0; i < 4; i++) { if (nodes[i]) { f32 f20 = f26 * 4.0f; - mtxindex = model0001a524(nodes[i], 0); + mtxindex = modelFindNodeMtxIndex(nodes[i], 0); sp88[i] = f20 - i; if (f20 < i) { @@ -7011,7 +7011,7 @@ void bgunUpdateDevastator(struct hand *hand, u8 *allocation, struct modelfiledat struct modelnode *node = modelGetPart(modeldef, MODELPART_DEVASTATOR_0028); if (node) { - s32 mtxindex = model0001a524(node, 0); + s32 mtxindex = modelFindNodeMtxIndex(node, 0); struct coord sp24; hand->loadslide += 0.01f * LVUPDATE60FREAL(); @@ -7061,7 +7061,7 @@ void bgunUpdateShotgun(struct hand *hand, u8 *allocation, bool *arg2, struct mod *arg2 = true; if (node) { - sp34 = model0001a524(node, 0); + sp34 = modelFindNodeMtxIndex(node, 0); mtx00015ea8((1.0f - hand->matmot1) * 8.0f + 0.5f, (Mtxf *)((u32)allocation + sp34 * sizeof(Mtxf))); mtx00015df0((1.0f - hand->matmot1) * 3.0f + 1.0f, (Mtxf *)((u32)allocation + sp34 * sizeof(Mtxf))); @@ -7101,7 +7101,7 @@ void bgunUpdateMagnum(struct hand *hand, s32 handnum, struct modelfiledata *mode struct modelnode *node = modelGetPart(modeldef, 0x0a + random() % 6); if (node) { - s32 index = model0001a524(node, 0); + s32 index = modelFindNodeMtxIndex(node, 0); Mtxf *tmp = mtx; Mtxf sp4c; @@ -7152,7 +7152,7 @@ void bgun0f0a45d0(struct hand *hand, struct modelfiledata *filedata, bool isdeto } if (node) { - var8009d148 = model0001a524(node, 0); + var8009d148 = modelFindNodeMtxIndex(node, 0); g_ModelJointPositionedFunc = bgun0f0a256c; } else { var8009d148 = -1; @@ -7330,7 +7330,7 @@ void bgun0f0a4e44(struct hand *hand, struct weapon *weapondef, struct modelfiled if (node && weaponnum != WEAPON_REAPER && weaponnum != WEAPON_SHOTGUN) { struct modelrodata_position *rodata = &node->rodata->position; - s32 mtxindex = model0001a524(node, 0); + s32 mtxindex = modelFindNodeMtxIndex(node, 0); sp60.x = rodata->pos.x * spd8.m[0][0] + rodata->pos.y * spd8.m[1][0] + rodata->pos.z * spd8.m[2][0] + spd8.m[3][0]; sp60.y = rodata->pos.x * spd8.m[0][1] + rodata->pos.y * spd8.m[1][1] + rodata->pos.z * spd8.m[2][1] + spd8.m[3][1]; @@ -7384,7 +7384,7 @@ void bgunCreateFx(struct hand *hand, s32 handnum, struct weaponfunc *funcdef, s3 Mtxf *mtx = (Mtxf *)allocation; Mtxf sp24; - mtx += model0001a524(node, 0); + mtx += modelFindNodeMtxIndex(node, 0); mtx4Copy(mtx, &sp24); mtx00015f04(9.999999f, &sp24); @@ -7818,7 +7818,7 @@ void bgun0f0a5550(s32 handnum) var8005efb0_2 = true; } - model0001cebc(&renderdata, &hand->gunmodel); + modelSetMatricesWithAnim(&renderdata, &hand->gunmodel); var8005efd8_2 = false; @@ -7826,7 +7826,7 @@ void bgun0f0a5550(s32 handnum) var8005efb0_2 = false; } #else - model0001cebc(&renderdata, &hand->gunmodel); + modelSetMatricesWithAnim(&renderdata, &hand->gunmodel); #endif player->hands[HAND_RIGHT].unk0dd4 = 1; @@ -7850,7 +7850,7 @@ void bgun0f0a5550(s32 handnum) var8005efb0_2 = true; } - model0001cebc(&renderdata, &hand->gunmodel); + modelSetMatricesWithAnim(&renderdata, &hand->gunmodel); var8005efd8_2 = false; @@ -7858,7 +7858,7 @@ void bgun0f0a5550(s32 handnum) var8005efb0_2 = false; } #else - model0001cebc(&renderdata, &hand->gunmodel); + modelSetMatricesWithAnim(&renderdata, &hand->gunmodel); #endif } @@ -7867,7 +7867,7 @@ void bgun0f0a5550(s32 handnum) node = modelGetPart(modeldef, MODELPART_PISTOL_0033); if (node) { - sp80 = model0001a524(node, 0); + sp80 = modelFindNodeMtxIndex(node, 0); bgunUpdateSlide(handnum); @@ -7920,7 +7920,7 @@ void bgun0f0a5550(s32 handnum) } if (node) { - sp6c = model0001a524(node, 0); + sp6c = modelFindNodeMtxIndex(node, 0); mtx = (Mtxf *)mtxallocation; mtx += sp6c; @@ -7942,7 +7942,7 @@ void bgun0f0a5550(s32 handnum) || weaponnum == WEAPON_REMOTEMINE || weaponnum == WEAPON_PROXIMITYMINE || weaponnum == WEAPON_NBOMB) { - sp6c = model0001a524(modelGetPart(modeldef, 0x37), 0); + sp6c = modelFindNodeMtxIndex(modelGetPart(modeldef, 0x37), 0); mtx = (Mtxf *)mtxallocation; mtx += sp6c; @@ -9036,7 +9036,7 @@ glabel var7f1aca90 /* f0a7b5c: 26050534 */ addiu $a1,$s0,0x534 /* f0a7b60: 00a02025 */ or $a0,$a1,$zero /* f0a7b64: ae0e0540 */ sw $t6,0x540($s0) -/* f0a7b68: 0c007308 */ jal model0001cc20 +/* f0a7b68: 0c007308 */ jal modelUpdateRelations /* f0a7b6c: afa50054 */ sw $a1,0x54($sp) /* f0a7b70: 8fa50054 */ lw $a1,0x54($sp) /* f0a7b74: afb50140 */ sw $s5,0x140($sp) @@ -9877,7 +9877,7 @@ glabel var7f1aca90 /* f0a7b5c: 26050534 */ addiu $a1,$s0,0x534 /* f0a7b60: 00a02025 */ or $a0,$a1,$zero /* f0a7b64: ae0e0540 */ sw $t6,0x540($s0) -/* f0a7b68: 0c007308 */ jal model0001cc20 +/* f0a7b68: 0c007308 */ jal modelUpdateRelations /* f0a7b6c: afa50054 */ sw $a1,0x54($sp) /* f0a7b70: 8fa50054 */ lw $a1,0x54($sp) /* f0a7b74: afb50140 */ sw $s5,0x140($sp) @@ -10709,7 +10709,7 @@ glabel var7f1aca90 /* f0a5888: 26050534 */ addiu $a1,$s0,0x534 /* f0a588c: 00a02025 */ or $a0,$a1,$zero /* f0a5890: ae0f0540 */ sw $t7,0x540($s0) -/* f0a5894: 0c007728 */ jal model0001cc20 +/* f0a5894: 0c007728 */ jal modelUpdateRelations /* f0a5898: afa50050 */ sw $a1,0x50($sp) /* f0a589c: 8fa50050 */ lw $a1,0x50($sp) /* f0a58a0: afb50138 */ sw $s5,0x138($sp) @@ -11061,7 +11061,7 @@ void bgunRender(Gfx **gdlptr) hand->handmodel.matrices = hand->gunmodel.matrices; - model0001cc20(&hand->handmodel); + modelUpdateRelations(&hand->handmodel); renderdata.envcolour = colour; modelRender(&renderdata, &hand->handmodel); diff --git a/src/game/bondhead.c b/src/game/bondhead.c index 070c2c8cb..c574ed8c5 100644 --- a/src/game/bondhead.c +++ b/src/game/bondhead.c @@ -144,19 +144,19 @@ void bheadUpdate(f32 arg0, f32 arg1) struct modelrenderdata sp80 = {NULL, 1, 3}; Mtxf sp40; struct coord modelpos = {0, 0, 0}; - bool somebool = model0001e2a8(); + bool mergeenabled = modelIsAnimMergingEnabled(); g_Vars.currentplayer->resetheadtick = false; - model0001e29c(false); - model0001ee18(&g_Vars.currentplayer->model, g_Vars.lvupdate240, true); - model0001e29c(somebool); - model0001b3bc(&g_Vars.currentplayer->model); + modelSetAnimMergingEnabled(false); + modelTickAnimQuarterSpeed(&g_Vars.currentplayer->model, g_Vars.lvupdate240, true); + modelSetAnimMergingEnabled(mergeenabled); + modelUpdateInfo(&g_Vars.currentplayer->model); mtx4LoadIdentity(&sp40); sp80.unk00 = &sp40; sp80.unk10 = g_Vars.currentplayer->bondheadmatrices; - model0001cebc(&sp80, &g_Vars.currentplayer->model); + modelSetMatricesWithAnim(&sp80, &g_Vars.currentplayer->model); g_Vars.currentplayer->headbodyoffset.x = g_Vars.currentplayer->standbodyoffset.x; g_Vars.currentplayer->headbodyoffset.y = g_Vars.currentplayer->standbodyoffset.y; diff --git a/src/game/bondheadreset.c b/src/game/bondheadreset.c index 103fe315e..f7f81a834 100644 --- a/src/game/bondheadreset.c +++ b/src/game/bondheadreset.c @@ -99,11 +99,11 @@ void bheadReset(void) modelSetAnimation(&g_Vars.currentplayer->model, 1, 0, 0, 0.5f, 0); - model0001b3bc(&g_Vars.currentplayer->model); + modelUpdateInfo(&g_Vars.currentplayer->model); mtx4LoadIdentity(&sp48); sp88.unk00 = &sp48; sp88.unk10 = g_Vars.currentplayer->bondheadmatrices; - model0001cebc(&sp88, &g_Vars.currentplayer->model); + modelSetMatricesWithAnim(&sp88, &g_Vars.currentplayer->model); g_Vars.currentplayer->standheight = g_Vars.currentplayer->bondheadmatrices[0].m[3][1]; diff --git a/src/game/bot.c b/src/game/bot.c index 14e15d258..f04752d19 100644 --- a/src/game/bot.c +++ b/src/game/bot.c @@ -245,10 +245,10 @@ void botSpawn(struct chrdata *chr, u8 respawning) thing = scenarioChooseSpawnLocation(chr->radius, &pos, rooms, chr->prop); chr->hidden |= CHRHFLAG_00100000; chrMoveToPos(chr, &pos, rooms, thing, true); - chr->aibot->unk0a4 = model0001ae44(chr->model); + chr->aibot->unk0a4 = modelGetChrRotY(chr->model); chr->aibot->angleoffset = 0; chr->aibot->speedtheta = 0; - chr->aibot->unk0b0 = model0001ae44(chr->model); + chr->aibot->unk0b0 = modelGetChrRotY(chr->model); chr->aibot->unk0b4 = 0; chr->aibot->unk0b8 = 0; func0f02e9a0(chr, 0); @@ -751,7 +751,7 @@ bool botApplyMovement(struct chrdata *chr) angle2 -= M_BADTAU; } - model0001ae90(chr->model, angle2); + modelSetChrRotY(chr->model, angle2); return true; } diff --git a/src/game/botmgr.c b/src/game/botmgr.c index e14d0347c..caae54dce 100644 --- a/src/game/botmgr.c +++ b/src/game/botmgr.c @@ -201,10 +201,10 @@ void botmgrAllocateBot(s32 chrnum, s32 aibotnum) aibot->reaperspeed[HAND_RIGHT] = 0; aibot->maulercharge[HAND_LEFT] = 0.0f; aibot->maulercharge[HAND_RIGHT] = 0.0f; - aibot->unk0a4 = model0001ae44(chr->model); + aibot->unk0a4 = modelGetChrRotY(chr->model); aibot->angleoffset = 0.0f; aibot->speedtheta = 0.0f; - aibot->unk0b0 = model0001ae44(chr->model); + aibot->unk0b0 = modelGetChrRotY(chr->model); aibot->unk0b4 = 0.0f; aibot->unk0b8 = 0.0f; diff --git a/src/game/chr.c b/src/game/chr.c index 362f29237..ee29d2450 100644 --- a/src/game/chr.c +++ b/src/game/chr.c @@ -1907,7 +1907,7 @@ void chr0f0220ac(struct chrdata *chr) propRegisterRooms(chr->prop); } -void chr0f0220ec(struct chrdata *chr, s32 arg1, s32 arg2) +void chr0f0220ec(struct chrdata *chr, s32 lvupdate240, bool arg2) { struct model *model = chr->model; @@ -1918,9 +1918,9 @@ void chr0f0220ec(struct chrdata *chr, s32 arg1, s32 arg2) if (model->anim && (g_Anims[model->anim->animnum].flags & ANIMFLAG_02) - && arg1 > 0 + && lvupdate240 > 0 && g_Vars.cutsceneskip60ths > 0) { - arg1 += g_Vars.cutsceneskip60ths * 4; + lvupdate240 += g_Vars.cutsceneskip60ths * 4; } } @@ -1929,11 +1929,11 @@ void chr0f0220ec(struct chrdata *chr, s32 arg1, s32 arg2) } else if (arg2) { if ((chr->hidden & CHRHFLAG_00000800) == 0) { modelGetRootPosition(model, &chr->prevpos); - model0001ee18(model, arg1, 1); - model0001b3bc(model); + modelTickAnimQuarterSpeed(model, lvupdate240, true); + modelUpdateInfo(model); } } else { - model0001ee18(model, arg1, 0); + modelTickAnimQuarterSpeed(model, lvupdate240, false); } } @@ -1952,7 +1952,7 @@ void chr0f022214(struct chrdata *chr, struct prop *prop, bool fulltick) if (model->attachedtomodel && model->attachedtonode && (obj->hidden & OBJHFLAG_00000800) == 0 && (obj->flags2 & OBJFLAG2_INVISIBLE) == 0) { - Mtxf *sp104 = model0001a5cc(model->attachedtomodel, model->attachedtonode, 0); + Mtxf *sp104 = modelFindNodeMtx(model->attachedtomodel, model->attachedtonode, 0); struct modelrenderdata thing = {NULL, 1, 3}; u32 stack; Mtxf sp80; @@ -1980,7 +1980,7 @@ void chr0f022214(struct chrdata *chr, struct prop *prop, bool fulltick) } thing.unk10 = gfxAllocate(model->filedata->nummatrices * sizeof(Mtxf)); - model0001ce64(&thing, model); + modelSetMatrices(&thing, model); func0f07063c(prop, fulltick); @@ -2454,11 +2454,11 @@ s32 chrTick(struct prop *prop) if (eyespy == g_Vars.currentplayer->eyespy && eyespy->active) { onscreen = false; } else { - onscreen = func0f08e8ac(prop, &prop->pos, model0001af80(model), true); + onscreen = func0f08e8ac(prop, &prop->pos, modelGetEffectiveScale(model), true); } if (fulltick) { - chr0f0220ec(chr, lvupdate240, 1); + chr0f0220ec(chr, lvupdate240, true); } } else { onscreen = false; @@ -2477,9 +2477,9 @@ s32 chrTick(struct prop *prop) model->anim->average = false; if (chr->actiontype == ACT_ANIM && !chr->act_anim.movewheninvis && chr->act_anim.lockpos) { - chr0f0220ec(chr, lvupdate240, 0); + chr0f0220ec(chr, lvupdate240, false); } else { - chr0f0220ec(chr, lvupdate240, 1); + chr0f0220ec(chr, lvupdate240, true); } } @@ -2499,19 +2499,19 @@ s32 chrTick(struct prop *prop) } else if (chr->actiontype == ACT_PATROL || chr->actiontype == ACT_GOPOS) { if ((chr->actiontype == ACT_PATROL && chr->act_patrol.waydata.mode == WAYMODE_MAGIC) || (chr->actiontype == ACT_GOPOS && chr->act_gopos.waydata.mode == WAYMODE_MAGIC)) { - onscreen = func0f08e8ac(prop, &prop->pos, model0001af80(model), true); + onscreen = func0f08e8ac(prop, &prop->pos, modelGetEffectiveScale(model), true); if (onscreen) { model->anim->average = false; modelGetRootPosition(model, &chr->prevpos); - model0001b3bc(model); + modelUpdateInfo(model); } } else { if (fulltick) { - chr0f0220ec(chr, lvupdate240, 1); + chr0f0220ec(chr, lvupdate240, true); } - onscreen = func0f08e8ac(prop, &prop->pos, model0001af80(model), true); + onscreen = func0f08e8ac(prop, &prop->pos, modelGetEffectiveScale(model), true); if (onscreen) { if (chr->actiontype == ACT_PATROL) { @@ -2525,63 +2525,63 @@ s32 chrTick(struct prop *prop) && !((prop->flags & (PROPFLAG_ONANYSCREENTHISTICK | PROPFLAG_ONANYSCREENPREVTICK)) != 0); } } else if (chr->actiontype == ACT_ANIM && !chr->act_anim.movewheninvis) { - onscreen = func0f08e8ac(prop, &prop->pos, model0001af80(model), true); + onscreen = func0f08e8ac(prop, &prop->pos, modelGetEffectiveScale(model), true); if (fulltick) { model->anim->average = false; if (onscreen && !chr->act_anim.lockpos) { - chr0f0220ec(chr, lvupdate240, 1); + chr0f0220ec(chr, lvupdate240, true); } else { - chr0f0220ec(chr, lvupdate240, 0); + chr0f0220ec(chr, lvupdate240, false); } } } else if (chr->actiontype == ACT_STAND) { model->anim->average = false; if (chr->chrflags & CHRCFLAG_00000001) { - chr0f0220ec(chr, lvupdate240, 1); - onscreen = func0f08e8ac(prop, &prop->pos, model0001af80(model), true); + chr0f0220ec(chr, lvupdate240, true); + onscreen = func0f08e8ac(prop, &prop->pos, modelGetEffectiveScale(model), true); } else { - onscreen = func0f08e8ac(prop, &prop->pos, model0001af80(model), true); + onscreen = func0f08e8ac(prop, &prop->pos, modelGetEffectiveScale(model), true); if (g_Vars.mplayerisrunning) { if (fulltick) { if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) { if (onscreen) { - chr0f0220ec(chr, lvupdate240, 1); + chr0f0220ec(chr, lvupdate240, true); } else if (model->anim->animnum2 != 0) { - chr0f0220ec(chr, lvupdate240, 0); + chr0f0220ec(chr, lvupdate240, false); } } else { - chr0f0220ec(chr, lvupdate240, 1); + chr0f0220ec(chr, lvupdate240, true); } } } else if (onscreen) { if (chr->act_stand.playwalkanim == true) { - chr0f0220ec(chr, lvupdate240, 0); + chr0f0220ec(chr, lvupdate240, false); } else { - chr0f0220ec(chr, lvupdate240, 1); + chr0f0220ec(chr, lvupdate240, true); } } else if (model->anim->animnum2 != 0) { - chr0f0220ec(chr, lvupdate240, 0); + chr0f0220ec(chr, lvupdate240, false); } } } else if (chr->actiontype == ACT_DEAD) { - onscreen = func0f08e8ac(prop, &prop->pos, model0001af80(model), true); + onscreen = func0f08e8ac(prop, &prop->pos, modelGetEffectiveScale(model), true); } else if (prop->type == PROPTYPE_PLAYER && (g_Vars.mplayerisrunning || (player = g_Vars.players[playermgrGetPlayerNumByProp(prop)], player->cameramode == CAMERAMODE_EYESPY) || (player->cameramode == CAMERAMODE_THIRDPERSON && player->visionmode == VISIONMODE_SLAYERROCKET))) { model->anim->average = false; - chr0f0220ec(chr, lvupdate240, 1); - onscreen = func0f08e8ac(prop, &prop->pos, model0001af80(model), true); + chr0f0220ec(chr, lvupdate240, true); + onscreen = func0f08e8ac(prop, &prop->pos, modelGetEffectiveScale(model), true); } else { offscreen2 = false; if (fulltick) { model->anim->average = false; - chr0f0220ec(chr, lvupdate240, 1); + chr0f0220ec(chr, lvupdate240, true); } if (chr->model && chr->model->anim && (g_Anims[chr->model->anim->animnum].flags & ANIMFLAG_04)) { @@ -2594,7 +2594,7 @@ s32 chrTick(struct prop *prop) if (offscreen2) { onscreen = false; } else { - onscreen = func0f08e8ac(prop, &prop->pos, model0001af80(model), true); + onscreen = func0f08e8ac(prop, &prop->pos, modelGetEffectiveScale(model), true); } } @@ -2758,7 +2758,7 @@ s32 chrTick(struct prop *prop) } } - model0001cebc(&sp210, model); + modelSetMatricesWithAnim(&sp210, model); if (restore) { anim->frac = prevfrac; @@ -2774,7 +2774,7 @@ s32 chrTick(struct prop *prop) colourTween(chr->shadecol, chr->nextcol); } - prop->z = model0001a9e8(model); + prop->z = modelGetScreenDistance(model); child = prop->child; while (child) { @@ -2827,8 +2827,8 @@ s32 chrTick(struct prop *prop) if (headspotnode && headspotnode->type == MODELNODETYPE_HEADSPOT) { union modelrwdata *rwdata = modelGetNodeRwData(model, headspotnode); - if (rwdata->headspot.modelfiledata != NULL) { - struct modelnode *hatnode = modelGetPart(rwdata->headspot.modelfiledata, MODELPART_HEAD_HAT); + if (rwdata->headspot.headmodeldef != NULL) { + struct modelnode *hatnode = modelGetPart(rwdata->headspot.headmodeldef, MODELPART_HEAD_HAT); if (hatnode != NULL) { union modelrwdata *hatrwdata = modelGetNodeRwData(model, hatnode); @@ -2901,8 +2901,8 @@ void chrSetHudpieceVisible(struct chrdata *chr, bool visible) if (headspotnode && headspotnode->type == MODELNODETYPE_HEADSPOT) { union modelrwdata *rwdata = modelGetNodeRwData(chr->model, headspotnode); - if (rwdata->headspot.modelfiledata) { - struct modelnode *hudpiecenode = modelGetPart(rwdata->headspot.modelfiledata, MODELPART_HEAD_HUDPIECE); + if (rwdata->headspot.headmodeldef) { + struct modelnode *hudpiecenode = modelGetPart(rwdata->headspot.headmodeldef, MODELPART_HEAD_HUDPIECE); if (hudpiecenode) { union modelrwdata *rwdata2 = modelGetNodeRwData(chr->model, hudpiecenode); @@ -3094,7 +3094,7 @@ bool chr0f024b18(struct model *model, struct modelnode *node) if (bboxnode) { bbox = &bboxnode->rodata->bbox; - mtx = model0001a5cc(model, node, 0); + mtx = modelFindNodeMtx(model, node, 0); for (i = 0; i < var80062964; i++) { if (var80062960[i].unk004) { @@ -3365,7 +3365,7 @@ Gfx *chrRender(struct prop *prop, Gfx *gdl, bool xlupass) chrGetBloodColour(chr->bodynum, spec, NULL); chr0f0246e4(spec); - alpha *= func0f08e6bc(prop, model0001af80(model)); + alpha *= func0f08e6bc(prop, modelGetEffectiveScale(model)); if (g_Vars.currentplayer->visionmode == VISIONMODE_XRAY) { f32 fadedist; @@ -3516,9 +3516,9 @@ Gfx *chrRender(struct prop *prop, Gfx *gdl, bool xlupass) if (headspotnode && headspotnode->type == MODELNODETYPE_HEADSPOT) { union modelrwdata *headrwdata = modelGetNodeRwData(model, headspotnode); - if (headrwdata->headspot.modelfiledata) { - struct modelnode *node1 = modelGetPart(headrwdata->headspot.modelfiledata, MODELPART_HEAD_EYESOPEN); - struct modelnode *node2 = modelGetPart(headrwdata->headspot.modelfiledata, MODELPART_HEAD_EYESCLOSED); + if (headrwdata->headspot.headmodeldef) { + struct modelnode *node1 = modelGetPart(headrwdata->headspot.headmodeldef, MODELPART_HEAD_EYESOPEN); + struct modelnode *node2 = modelGetPart(headrwdata->headspot.headmodeldef, MODELPART_HEAD_EYESCLOSED); if (node1 && node2) { union modelrwdata *data1 = modelGetNodeRwData(model, node1); @@ -3703,7 +3703,7 @@ glabel chr0f0260c4 /* f026120: 25cf0014 */ addiu $t7,$t6,0x14 /* f026124: afaf00cc */ sw $t7,0xcc($sp) /* f026128: afa000c0 */ sw $zero,0xc0($sp) -/* f02612c: 0c0069d0 */ jal model0001a740 +/* f02612c: 0c0069d0 */ jal modelNodeFindMtxNode /* f026130: 02602025 */ or $a0,$s3,$zero /* f026134: 8fa40128 */ lw $a0,0x128($sp) /* f026138: 00402825 */ or $a1,$v0,$zero @@ -3865,7 +3865,7 @@ glabel chr0f0260c4 /* f026380: 3c0100ff */ lui $at,0xff /* f026384: 3421ffff */ ori $at,$at,0xffff /* f026388: 0041c824 */ and $t9,$v0,$at -/* f02638c: 0c00698d */ jal model0001a634 +/* f02638c: 0c00698d */ jal modelFindNodeByMtxIndex /* f026390: 00192982 */ srl $a1,$t9,0x6 /* f026394: afa20100 */ sw $v0,0x100($sp) /* f026398: 8fa40128 */ lw $a0,0x128($sp) @@ -3895,19 +3895,19 @@ glabel chr0f0260c4 /* f0263f4: 1000ff91 */ b .L0f02623c /* f0263f8: 27de0008 */ addiu $s8,$s8,0x8 .L0f0263fc: -/* f0263fc: 0c0071e1 */ jal model0001c784 +/* f0263fc: 0c0071e1 */ jal modelApplyDistanceRelations /* f026400: afa50110 */ sw $a1,0x110($sp) /* f026404: 8fa50110 */ lw $a1,0x110($sp) /* f026408: 1000000a */ b .L0f026434 /* f02640c: 8ca20014 */ lw $v0,0x14($a1) .L0f026410: -/* f026410: 0c0071f4 */ jal model0001c7d0 +/* f026410: 0c0071f4 */ jal modelApplyToggleRelations /* f026414: afa50110 */ sw $a1,0x110($sp) /* f026418: 8fa50110 */ lw $a1,0x110($sp) /* f02641c: 10000005 */ b .L0f026434 /* f026420: 8ca20014 */ lw $v0,0x14($a1) .L0f026424: -/* f026424: 0c007207 */ jal modelAttachHead +/* f026424: 0c007207 */ jal modelApplyHeadRelations /* f026428: afa50110 */ sw $a1,0x110($sp) /* f02642c: 8fa50110 */ lw $a1,0x110($sp) /* f026430: 8ca20014 */ lw $v0,0x14($a1) @@ -4159,7 +4159,7 @@ glabel chr0f0260c4 /* f0267a8: 3c0100ff */ lui $at,0xff /* f0267ac: 3421ffff */ ori $at,$at,0xffff /* f0267b0: 00417024 */ and $t6,$v0,$at -/* f0267b4: 0c00698d */ jal model0001a634 +/* f0267b4: 0c00698d */ jal modelFindNodeByMtxIndex /* f0267b8: 000e2982 */ srl $a1,$t6,0x6 /* f0267bc: afa20100 */ sw $v0,0x100($sp) /* f0267c0: 8fa40128 */ lw $a0,0x128($sp) @@ -4181,21 +4181,21 @@ glabel chr0f0260c4 /* f0267f8: 1000ff5b */ b .L0f026568 /* f0267fc: 27de0008 */ addiu $s8,$s8,0x8 .L0f026800: -/* f026800: 0c0071e1 */ jal model0001c784 +/* f026800: 0c0071e1 */ jal modelApplyDistanceRelations /* f026804: afa50110 */ sw $a1,0x110($sp) /* f026808: 8fa50110 */ lw $a1,0x110($sp) /* f02680c: 8fa40128 */ lw $a0,0x128($sp) /* f026810: 1000000c */ b .L0f026844 /* f026814: 8ca20014 */ lw $v0,0x14($a1) .L0f026818: -/* f026818: 0c0071f4 */ jal model0001c7d0 +/* f026818: 0c0071f4 */ jal modelApplyToggleRelations /* f02681c: afa50110 */ sw $a1,0x110($sp) /* f026820: 8fa50110 */ lw $a1,0x110($sp) /* f026824: 8fa40128 */ lw $a0,0x128($sp) /* f026828: 10000006 */ b .L0f026844 /* f02682c: 8ca20014 */ lw $v0,0x14($a1) .L0f026830: -/* f026830: 0c007207 */ jal modelAttachHead +/* f026830: 0c007207 */ jal modelApplyHeadRelations /* f026834: afa50110 */ sw $a1,0x110($sp) /* f026838: 8fa50110 */ lw $a1,0x110($sp) /* f02683c: 8fa40128 */ lw $a0,0x128($sp) @@ -4263,7 +4263,7 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc s32 op; s32 nodetype; - modelNodeGetModelRelativePosition(model, model0001a740(node), &relpos); + modelNodeGetModelRelativePosition(model, modelNodeFindMtxNode(node), &relpos); spc8.f[0] = arg3->x - relpos.x; spc8.f[1] = arg3->y - relpos.y; @@ -4288,14 +4288,14 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc // one in the model definition. If it hasn't been changed we'll // use the space... after the model definition's colour table? // Let's hope that's not being used by other instances... - if (rwdata->gdl == rodata->primary) { - gdlptr = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->primary & 0xffffff)); + if (rwdata->gdl == rodata->opagdl) { + gdlptr = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->opagdl & 0xffffff)); } else { gdlptr = rwdata->gdl; } - if (rodata->secondary) { - gdlptr2 = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->secondary & 0xffffff)); + if (rodata->xlugdl) { + gdlptr2 = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->xlugdl & 0xffffff)); } else { gdlptr2 = NULL; } @@ -4344,7 +4344,7 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc } } else if (op == G_MTX) { u32 addr = gdlptr->words.w1 & 0xffffff; - posnode = model0001a634(model, addr / sizeof(Mtxf)); + posnode = modelFindNodeByMtxIndex(model, addr / sizeof(Mtxf)); modelNodeGetModelRelativePosition(model, posnode, &spd4); spbc[0] = spd4.x + spc8.x; @@ -4357,13 +4357,13 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc } break; case MODELNODETYPE_DISTANCE: - model0001c784(model, curnode); + modelApplyDistanceRelations(model, curnode); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, curnode); + modelApplyToggleRelations(model, curnode); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, curnode); + modelApplyHeadRelations(model, curnode); break; } @@ -4407,14 +4407,14 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc break; } - if (rwdata->gdl == rodata->primary) { - gdlptr = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->primary & 0xffffff)); + if (rwdata->gdl == rodata->opagdl) { + gdlptr = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->opagdl & 0xffffff)); } else { gdlptr = rwdata->gdl; } - if (rodata->secondary) { - gdlptr2 = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->secondary & 0xffffff)); + if (rodata->xlugdl) { + gdlptr2 = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->xlugdl & 0xffffff)); } else { gdlptr2 = NULL; } @@ -4478,7 +4478,7 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc } } else if (op == G_MTX) { u32 addr = gdlptr->words.w1 & 0xffffff; - posnode = model0001a634(model, addr / sizeof(Mtxf)); + posnode = modelFindNodeByMtxIndex(model, addr / sizeof(Mtxf)); modelNodeGetModelRelativePosition(model, posnode, &spd4); } else if (op == G_SETCOLOR) { spac = gdlptr->words.w1 & 0xffffff; @@ -4489,13 +4489,13 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc } break; case MODELNODETYPE_DISTANCE: - model0001c784(model, curnode); + modelApplyDistanceRelations(model, curnode); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, curnode); + modelApplyToggleRelations(model, curnode); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, curnode); + modelApplyHeadRelations(model, curnode); break; } @@ -4543,7 +4543,7 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct struct modelrwdata_dl *rwdata; s32 spac = 0; - modelNodeGetModelRelativePosition(model, model0001a740(node), &relpos); + modelNodeGetModelRelativePosition(model, modelNodeFindMtxNode(node), &relpos); spc8.f[0] = arg3->f[0] - relpos.f[0]; spc8.f[1] = arg3->f[1] - relpos.f[1]; @@ -4568,14 +4568,14 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct // one in the model definition. If it hasn't been changed we'll // use the space... after the model definition's colour table? // Let's hope that's not being used by other instances... - if (rwdata->gdl == rodata->primary) { - gdlptr = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->primary & 0xffffff)); + if (rwdata->gdl == rodata->opagdl) { + gdlptr = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->opagdl & 0xffffff)); } else { gdlptr = rwdata->gdl; } - if (rodata->secondary) { - gdlptr2 = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->secondary & 0xffffff)); + if (rodata->xlugdl) { + gdlptr2 = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->xlugdl & 0xffffff)); } else { gdlptr2 = NULL; } @@ -4624,7 +4624,7 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct } } else if (op == G_MTX) { u32 addr = gdlptr->words.w1 & 0xffffff; - posnode = model0001a634(model, addr / sizeof(Mtxf)); + posnode = modelFindNodeByMtxIndex(model, addr / sizeof(Mtxf)); modelNodeGetModelRelativePosition(model, posnode, &spd4); spbc[0] = spd4.x + spc8.x; @@ -4637,13 +4637,13 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct } break; case MODELNODETYPE_DISTANCE: - model0001c784(model, curnode); + modelApplyDistanceRelations(model, curnode); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, curnode); + modelApplyToggleRelations(model, curnode); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, curnode); + modelApplyHeadRelations(model, curnode); break; } @@ -4706,14 +4706,14 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct break; } - if (rwdata->gdl == rodata->primary) { - gdlptr = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->primary & 0xffffff)); + if (rwdata->gdl == rodata->opagdl) { + gdlptr = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->opagdl & 0xffffff)); } else { gdlptr = rwdata->gdl; } - if (rodata->secondary) { - gdlptr2 = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->secondary & 0xffffff)); + if (rodata->xlugdl) { + gdlptr2 = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->xlugdl & 0xffffff)); } else { gdlptr2 = NULL; } @@ -4777,7 +4777,7 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct } } else if (op == G_MTX) { u32 addr = gdlptr->words.w1 & 0xffffff; - posnode = model0001a634(model, addr / sizeof(Mtxf)); + posnode = modelFindNodeByMtxIndex(model, addr / sizeof(Mtxf)); modelNodeGetModelRelativePosition(model, posnode, &spd4); } else if (op == G_SETCOLOR) { spac = gdlptr->words.w1 & 0xffffff; @@ -4789,13 +4789,13 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct } break; case MODELNODETYPE_DISTANCE: - model0001c784(model, curnode); + modelApplyDistanceRelations(model, curnode); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, curnode); + modelApplyToggleRelations(model, curnode); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, curnode); + modelApplyHeadRelations(model, curnode); break; } @@ -4897,14 +4897,14 @@ void chrDisfigure(struct chrdata *chr, struct coord *exppos, f32 damageradius) // MTX and VTX pointers if (rwdata->vertices != rodata->vertices && (u32)rwdata->colours != ALIGN8((u32)&rodata->vertices[rodata->numvertices])) { - if (rwdata->gdl == rodata->primary) { - gdlptr = (Gfx *)((u32)rodata->colourtable + ((s32)rodata->primary & 0xffffff)); + if (rwdata->gdl == rodata->opagdl) { + gdlptr = (Gfx *)((u32)rodata->colourtable + ((s32)rodata->opagdl & 0xffffff)); } else { gdlptr = rwdata->gdl; } - if (rodata->secondary) { - gdlptr2 = (Gfx *)((u32)rodata->colourtable + ((s32)rodata->secondary & 0xffffff)); + if (rodata->xlugdl) { + gdlptr2 = (Gfx *)((u32)rodata->colourtable + ((s32)rodata->xlugdl & 0xffffff)); } else { gdlptr2 = NULL; } @@ -4961,7 +4961,7 @@ void chrDisfigure(struct chrdata *chr, struct coord *exppos, f32 damageradius) } else if (op == G_MTX) { // Get the position of the node relative to the model u32 addr = gdlptr->words.w1 & 0xffffff; - posnode = model0001a634(model, addr / sizeof(Mtxf)); + posnode = modelFindNodeByMtxIndex(model, addr / sizeof(Mtxf)); modelNodeGetModelRelativePosition(model, posnode, &pos); } @@ -4986,13 +4986,13 @@ void chrDisfigure(struct chrdata *chr, struct coord *exppos, f32 damageradius) } break; case MODELNODETYPE_DISTANCE: - model0001c784(model, node); + modelApplyDistanceRelations(model, node); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, node); + modelApplyToggleRelations(model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, node); + modelApplyHeadRelations(model, node); break; } @@ -5019,12 +5019,12 @@ f32 chr0f0278a4(struct chrdata *chr) f32 highest = 0; if (chr->model) { - result = model0001af80(chr->model); + result = modelGetEffectiveScale(chr->model); for (i = 0; i < 2; i++) { if (chr->weapons_held[i]) { struct defaultobj *obj = chr->weapons_held[i]->obj; - f32 value = model0001af80(obj->model) * chr->model->scale; + f32 value = modelGetEffectiveScale(obj->model) * chr->model->scale; if (value > highest) { highest = value; @@ -5055,13 +5055,13 @@ void chr0f027994(struct prop *prop, struct shotdata *shotdata, bool arg2, bool a if (prop->z - fStack32 < shotdata->unk34) { struct model *model = chr->model; - s32 spc0 = 0; + s32 hitpart = 0; struct modelnode *node = NULL; s32 spb8 = 0; struct hitthing sp88; s32 sp84 = 0; struct modelnode *sp80 = NULL; - Mtxf *iVar5 = model0001a60c(model); + Mtxf *iVar5 = modelGetRootMtx(model); struct prop *next; struct prop *child; f32 sp70; @@ -5070,10 +5070,10 @@ void chr0f027994(struct prop *prop, struct shotdata *shotdata, bool arg2, bool a if (func0f06b39c(&shotdata->unk00, &shotdata->unk0c, (struct coord *)iVar5->m[3], fStack32)) { spb8 = 1; - spc0 = 1; + hitpart = 1; } - if (spc0) { + if (hitpart) { if (chrGetShield(chr) > 0.0f) { var8005efc0 = 10.0f / model->scale; } @@ -5087,9 +5087,9 @@ void chr0f027994(struct prop *prop, struct shotdata *shotdata, bool arg2, bool a } if (arg3 || var8005efc0 > 0.0f) { - spc0 = model000225d4(model, &shotdata->unk00, &shotdata->unk0c, &node); + hitpart = modelTestForHit(model, &shotdata->unk00, &shotdata->unk0c, &node); - while (spc0 > 0) { + while (hitpart > 0) { if (func0f084594(model, node, &shotdata->unk00, &shotdata->unk0c, &sp88, &sp84, &sp80)) { mtx4TransformVec(&model->matrices[sp84], &sp88.unk00, &spdc); mtx4TransformVecInPlace(camGetProjectionMtxF(), &spdc); @@ -5098,18 +5098,18 @@ void chr0f027994(struct prop *prop, struct shotdata *shotdata, bool arg2, bool a break; } - spc0 = model000225d4(model, &shotdata->unk00, &shotdata->unk0c, &node); + hitpart = modelTestForHit(model, &shotdata->unk00, &shotdata->unk0c, &node); } } else { - spc0 = model000225d4(model, &shotdata->unk00, &shotdata->unk0c, &node); + hitpart = modelTestForHit(model, &shotdata->unk00, &shotdata->unk0c, &node); - if (spc0 > 0) { + if (hitpart > 0) { if (func0f06bea0(model, model->filedata->rootnode, model->filedata->rootnode, &shotdata->unk00, - &shotdata->unk0c, &sp88.unk00, &sp70, &node, &spc0, &sp84, &sp80)) { + &shotdata->unk0c, &sp88.unk00, &sp70, &node, &hitpart, &sp84, &sp80)) { mtx4TransformVec(camGetProjectionMtxF(), &sp88.unk00, &spdc); mtx4RotateVec(camGetProjectionMtxF(), &sp88.unk0c, &spd0); } else { - spc0 = 0; + hitpart = 0; } } } @@ -5119,17 +5119,17 @@ void chr0f027994(struct prop *prop, struct shotdata *shotdata, bool arg2, bool a } } - if (spc0 > 0) { + if (hitpart > 0) { mtx = camGetWorldToScreenMtxf(); sp68 = spdc.x * mtx->m[0][2] + spdc.y * mtx->m[1][2] + spdc.z * mtx->m[2][2] + mtx->m[3][2]; sp68 = -sp68; if (sp68 < shotdata->unk34) { - func0f061fa8(shotdata, prop, sp68, spc0, node, &sp88, sp84, sp80, model, 1, chrGetShield(chr) > 0.0f, &spdc, &spd0); + func0f061fa8(shotdata, prop, sp68, hitpart, node, &sp88, sp84, sp80, model, 1, chrGetShield(chr) > 0.0f, &spdc, &spd0); } } - if (spb8 && spc0 <= 0 && prop->z <= shotdata->unk34 && arg2) { + if (spb8 && hitpart <= 0 && prop->z <= shotdata->unk34 && arg2) { if (chrGetTargetProp(chr) == g_Vars.currentplayer->prop) { chr->chrflags |= CHRCFLAG_NEAR_MISS; } @@ -5294,7 +5294,7 @@ void chrHit(struct shotdata *shotdata, struct hit *hit) // Shot a chr in the flesh s32 race = CHRRACE(chr); struct coord sp5c; - Mtxf *sp58 = model0001a5cc(hit->model, hit->node, 0); + Mtxf *sp58 = modelFindNodeMtx(hit->model, hit->node, 0); // Create blood mtx0001719c(sp58->m, spb0.m); @@ -5617,7 +5617,7 @@ bool chrCalculateAutoAim(struct prop *prop, struct coord *arg1, f32 *arg2, f32 * bool chr0f028d50(struct prop *arg0, struct prop *arg1, struct modelnode *node, struct model *model, s32 *total) { if (arg1 == arg0) { - *total += model0001a524(node, 0); + *total += modelFindNodeMtxIndex(node, 0); return true; } @@ -5673,7 +5673,7 @@ bool chr0f028e6c(s32 arg0, struct prop *prop, struct prop **propptr, struct mode } } else { *propptr = prop; - *nodeptr = model0001a634(model, arg0); + *nodeptr = modelFindNodeByMtxIndex(model, arg0); *modelptr = model; result = true; } @@ -5830,7 +5830,7 @@ s32 chr0f02932c(struct prop *prop, s32 arg1) struct model *model; if (chr0f028e6c(arg1, prop, &prop2, &node, &model) && node) { - node2 = model0001a784(node); + node2 = modelNodeFindParentMtxNode(node); if (node2) { result = chr0f028e18(prop2, node2, model, prop); @@ -5851,7 +5851,7 @@ s32 chr0f0293ec(struct prop *prop, s32 cmnum) struct model *model; if (chr0f028e6c(cmnum, prop, &prop2, &node, &model) && node) { - node2 = model0001a7cc(node); + node2 = modelNodeFindChildMtxNode(node); if (node2) { result = chr0f028e18(prop2, node2, model, prop); @@ -5885,11 +5885,11 @@ s32 chr0f0294cc(struct prop *prop, s32 arg1) struct model *model2; if (chr0f028e6c(arg1, prop, &prop2, &node2, &model2) && node2) { - struct modelnode *node3 = model0001a85c(node2); + struct modelnode *node3 = modelNodeFindChildOrParentMtxNode(node2); if (node3) { result = chr0f028e18(prop2, node3, model2, prop); - } else if (model0001a784(node2) == NULL && prop2->parent) { + } else if (modelNodeFindParentMtxNode(node2) == NULL && prop2->parent) { child = prop2->parent->child; while (child && child != prop2) { @@ -6041,7 +6041,7 @@ Gfx *chrRenderShieldComponent(Gfx *gdl, struct shieldhit *hit, struct prop *prop shieldamount = (obj->flags3 & OBJFLAG3_SHOWSHIELD) ? 4.0f : 8.0f; } - mtxindex = model0001a524(node, 0); + mtxindex = modelFindNodeMtxIndex(node, 0); modelmtx = &model->matrices[mtxindex]; xmin = bbox->xmin - gap; @@ -6887,7 +6887,7 @@ Gfx *chrRenderCloak(Gfx *gdl, struct prop *chrprop, struct prop *thisprop) } if (index <= 19) { - Mtxf *mtx = model0001a5cc(model, model0001a740(node), 0); + Mtxf *mtx = modelFindNodeMtx(model, modelNodeFindMtxNode(node), 0); s32 uls; // upper left s coordinate s32 ult; // upper left t coordinate struct coord coord; diff --git a/src/game/chraction.c b/src/game/chraction.c index d1da6a5ca..27a786499 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -8840,7 +8840,7 @@ f32 chrGetInverseTheta(struct chrdata *chr) return angle; } - return model0001ae44(chr->model); + return modelGetChrRotY(chr->model); } void chrSetLookAngle(struct chrdata *chr, f32 angle) @@ -8848,7 +8848,7 @@ void chrSetLookAngle(struct chrdata *chr, f32 angle) if (chr->aibot) { chr->aibot->unk0b0 = angle; } else { - model0001ae90(chr->model, angle); + modelSetChrRotY(chr->model, angle); } } @@ -8858,7 +8858,7 @@ f32 func0f03e578(struct chrdata *chr) return chr->aibot->unk0a4; } - return model0001ae44(chr->model); + return modelGetChrRotY(chr->model); } void func0f03e5b0(struct chrdata *chr, f32 arg1) @@ -8866,7 +8866,7 @@ void func0f03e5b0(struct chrdata *chr, f32 arg1) if (chr->aibot) { chr->aibot->unk0a4 = arg1; } else { - model0001ae90(chr->model, arg1); + modelSetChrRotY(chr->model, arg1); } } @@ -9141,7 +9141,7 @@ bool func0f03e9f4(struct chrdata *chr, struct attackanimconfig *animcfg, bool fi burstnode = modelGetPart(gunmodel->filedata, MODELPART_CHRGUN_GUNFIRE); if (burstnode) { - sp108 = model0001a5cc(gunmodel, burstnode, 0); + sp108 = modelFindNodeMtx(gunmodel, burstnode, 0); burstrodata = &burstnode->rodata->chrgunfire; spb4 = cam0f0b53a4((u8 *)sp108); @@ -9164,7 +9164,7 @@ bool func0f03e9f4(struct chrdata *chr, struct attackanimconfig *animcfg, bool fi posnode = modelGetPart(gunmodel->filedata, MODELPART_CHRGUN_0001); if (posnode) { - spb0 = model0001a5cc(gunmodel, posnode, 0); + spb0 = modelFindNodeMtx(gunmodel, posnode, 0); sp6c = cam0f0b53a4((u8 *)spb0); if (sp6c) { @@ -9584,7 +9584,7 @@ bool chrGetGunPos(struct chrdata *chr, s32 handnum, struct coord *gunpos) if ((chr->prop->flags & PROPFLAG_ONTHISSCREENTHISTICK) && (weaponprop->flags & PROPFLAG_ONTHISSCREENTHISTICK)) { if ((part0 = modelGetPart(model->filedata, MODELPART_0000))) { - spac = model0001a5cc(model, part0, 0); + spac = modelFindNodeMtx(model, part0, 0); rodata = &part0->rodata->chrgunfire; gunpos->x = rodata->pos.x; @@ -9595,7 +9595,7 @@ bool chrGetGunPos(struct chrdata *chr, s32 handnum, struct coord *gunpos) mtx4TransformVecInPlace(&sp6c, gunpos); result = true; } else if ((part1 = modelGetPart(model->filedata, MODELPART_0001))) { - sp64 = model0001a5cc(model, part1, 0); + sp64 = modelFindNodeMtx(model, part1, 0); mtx00015be4(camGetProjectionMtxF(), sp64, &sp24); @@ -9664,7 +9664,7 @@ void chrCalculateShieldHit(struct chrdata *chr, struct coord *pos, struct coord while (node) { if ((node->type & 0xff) == MODELNODETYPE_BBOX) { - mtxptr1 = model0001a5cc(chr->model, node, 0); + mtxptr1 = modelFindNodeMtx(chr->model, node, 0); if (isdifferentmtx) { mtx00016798(mtxptr1, &spc8); @@ -9712,7 +9712,7 @@ void chrCalculateShieldHit(struct chrdata *chr, struct coord *pos, struct coord *modelptr = chr->model; *sideptr = 0; - mtxptr2 = model0001a5cc(chr->model, bestnode, 0); + mtxptr2 = modelFindNodeMtx(chr->model, bestnode, 0); if (isdifferentmtx) { mtx00016798(mtxptr2, &sp48); @@ -10862,7 +10862,7 @@ void func0f0429d8(struct chrdata *chr, f32 arg1, f32 arg2) { struct prop *prop = chrGetTargetProp(chr); f32 distance = atan2f(prop->pos.x - chr->prop->pos.x, prop->pos.z - chr->prop->pos.z); - f32 value = model0001afe8(arg2, distance, arg1); + f32 value = modelTweenRotAxis(arg2, distance, arg1); chrSetLookAngle(chr, value); } @@ -13192,7 +13192,7 @@ void chrTickSkJump(struct chrdata *chr) switch (chr->act_skjump.state) { case SKJUMPSTATE_TAKEOFF: fVar6 = chrGetInverseTheta(chr); - fVar5 = model0001afe8(fVar6, chr->act_skjump.roty, 0.35); + fVar5 = modelTweenRotAxis(fVar6, chr->act_skjump.roty, 0.35); chrSetLookAngle(chr, fVar5); frame = modelGetCurAnimFrame(chr->model); @@ -14446,7 +14446,7 @@ bool chrCanSeeTargetWithExtraCheck(struct chrdata *chr) struct coord sp68; struct coord sp56; struct coord sp44; - f32 somefloat = model0001af80(model) * 0.8f; + f32 somefloat = modelGetEffectiveScale(model) * 0.8f; bgun0f0a0c08(&sp68, &sp56); modelGetRootPosition(model, &sp44); @@ -16132,7 +16132,7 @@ void chrAvoid(struct chrdata *chr) f32 xdiff; f32 zdiff; f32 halfchrradius; - f32 chrangle = model0001ae44(chr->model); + f32 chrangle = modelGetChrRotY(chr->model); s16 dstrooms[8]; struct coord dstpos; diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index 547918d3b..739f75e3a 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -433,7 +433,7 @@ bool aiChrDoAnimation(void) chrTryStartAnim(chr, anim_id, fstartframe, fendframe, cmd[8], cmd[9], speed); if (startframe == 0xfffe) { - chr0f0220ec(chr, 1, 1); + chr0f0220ec(chr, 1, true); if (chr->prop->type == PROPTYPE_PLAYER) { u32 playernum = playermgrGetPlayerNumByProp(chr->prop); diff --git a/src/game/gunfx.c b/src/game/gunfx.c index 85ddf5c3e..226709cd0 100644 --- a/src/game/gunfx.c +++ b/src/game/gunfx.c @@ -1968,7 +1968,7 @@ void casingRender(struct casing *casing, Gfx **gdlptr) s32 j; bool render = true; - modelCalculateRwDataLen(modeldef); + modelAllocateRwData(modeldef); modelInit(&model, modeldef, NULL, true); model.matrices = matrices; diff --git a/src/game/menu.c b/src/game/menu.c index 1537c156c..ccd535b9b 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -1812,7 +1812,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) thing->bodynum = bodynum; thing->bodymodeldef = modeldefLoad(bodyfilenum, thing->unk004, totalfilelen, &texpool); bodyfilelen2 = ALIGN64(fileGetLoadedSize(bodyfilenum)); - modelCalculateRwDataLen(thing->bodymodeldef); + modelAllocateRwData(thing->bodymodeldef); if (headnum < 0) { thing->headmodeldef = NULL; @@ -1820,7 +1820,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) thing->headmodeldef = modeldefLoad(headfilenum, thing->unk004 + bodyfilelen2, totalfilelen - bodyfilelen2, &texpool); fileGetLoadedSize(headfilenum); bodyCalculateHeadOffset(thing->headmodeldef, headnum, bodynum); - modelCalculateRwDataLen(thing->headmodeldef); + modelAllocateRwData(thing->headmodeldef); } modelInit(&thing->bodymodel, thing->bodymodeldef, &thing->unk110, true); @@ -1841,7 +1841,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) thing->bodymodeldef = modeldefLoad(thing->unk00c, thing->unk004, totalfilelen, &texpool); fileGetLoadedSize(thing->unk00c); - modelCalculateRwDataLen(thing->bodymodeldef); + modelAllocateRwData(thing->bodymodeldef); modelInit(&thing->bodymodel, thing->bodymodeldef, &thing->unk110, true); animInit(&thing->bodyanim); @@ -2135,7 +2135,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) struct coord newpos = {0, 0, 0}; u32 stack[3]; - model0001b3bc(&thing->bodymodel); + modelUpdateInfo(&thing->bodymodel); modelGetRootPosition(&thing->bodymodel, &oldpos); @@ -2214,7 +2214,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) if (thing->unk05c && thing->unk05e != thing->unk05c) { if (thing->unk5b1_04) { modelSetAnimation(&thing->bodymodel, thing->unk05c, false, 0, PALUPF(-0.5f), 0.0f); - model0001e018(&thing->bodymodel, modelGetNumAnimFrames(&thing->bodymodel)); + modelSetAnimFrame(&thing->bodymodel, modelGetNumAnimFrames(&thing->bodymodel)); } else { modelSetAnimation(&thing->bodymodel, thing->unk05c, false, 0, PALUPF(0.5f), 0.0f); } @@ -2228,7 +2228,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) f32 sp178; u32 stack; - model0001ee18(&thing->bodymodel, g_Vars.diffframe240, true); + modelTickAnimQuarterSpeed(&thing->bodymodel, g_Vars.diffframe240, true); if (thing->unk5b1_04) { sp178 = modelGetNumAnimFrames(&thing->bodymodel) - modelGetCurAnimFrame(&thing->bodymodel); @@ -2246,7 +2246,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) renderdata.unk00 = &thing->unk014; renderdata.unk10 = thing->bodymodel.matrices; - model0001cebc(&renderdata, &thing->bodymodel); + modelSetMatricesWithAnim(&renderdata, &thing->bodymodel); if (thing->bodymodeldef->skel == &g_SkelHudPiece) { struct modelnode *node = modelGetPart(thing->bodymodeldef, MODELPART_HUDPIECE_0000); @@ -2277,7 +2277,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) s32 sp160; Mtxf sp120; Mtxf spe0; - sp160 = model0001a524(node, 0); + sp160 = modelFindNodeMtxIndex(node, 0); mtx4LoadIdentity(&sp120); mtx4LoadXRotation(menuGetCosOscFrac(4), &sp120); mtx4MultMtx4((Mtxf *)((u32)sp3b4 + sp160 * sizeof(Mtxf)), &sp120, &spe0); @@ -2291,7 +2291,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) || g_MenuData.root == MENUROOT_FILEMGR || g_MenuData.root == MENUROOT_MPSETUP || g_MenuData.root == MENUROOT_TRAINING) { - s32 index = model0001a524(node, 0); + s32 index = modelFindNodeMtxIndex(node, 0); struct coord spd0; f32 spc8[2]; diff --git a/src/game/modelmgr.c b/src/game/modelmgr.c index d701ff3ee..01c127260 100644 --- a/src/game/modelmgr.c +++ b/src/game/modelmgr.c @@ -319,9 +319,9 @@ struct model *modelmgrInstantiateModelWithAnim(struct modelfiledata *modelfileda return modelmgrInstantiateModel(modelfiledata, true); } -void modelmgr0f0b32a0(struct model *model, struct modelnode *node, struct modelfiledata *headmodeldef) +void modelmgrAttachHead(struct model *model, struct modelnode *node, struct modelfiledata *headmodeldef) { - model00023108(model, model->filedata, node, headmodeldef); + modelAttachHead(model, model->filedata, node, headmodeldef); modelInitRwData(model, headmodeldef->rootnode); } diff --git a/src/game/player.c b/src/game/player.c index 91c58fcd6..9bdcaf5dc 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -1007,7 +1007,7 @@ void playerSpawn(void) if (g_Vars.lvframenum > 0 && (g_ChrSlots[i].hidden & CHRHFLAG_00800000) - && func0f06b39c(&sp78, &sp90, &g_ChrSlots[i].prop->pos, model0001af80(g_ChrSlots[i].model)) + && func0f06b39c(&sp78, &sp90, &g_ChrSlots[i].prop->pos, modelGetEffectiveScale(g_ChrSlots[i].model)) && (random() % 8)) { sqdist += 1000000; } @@ -1407,10 +1407,10 @@ void playerTickChrBody(void) offset1 = ALIGN64(fileGetLoadedSize(g_HeadsAndBodies[headnum].filenum) + offset1); } - modelCalculateRwDataLen(bodyfiledata); + modelAllocateRwData(bodyfiledata); if (headfiledata != NULL) { - modelCalculateRwDataLen(headfiledata); + modelAllocateRwData(headfiledata); } modelInit(model, bodyfiledata, rwdatas, false); @@ -1503,7 +1503,7 @@ void playerTickChrBody(void) if (g_Vars.mplayerisrunning == false) { weaponfiledata = modeldefLoad(g_ModelStates[weaponmodelnum].fileid, allocation + offset1, offset2 - offset1, &texpool); fileGetLoadedSize(g_ModelStates[weaponmodelnum].fileid); - modelCalculateRwDataLen(weaponfiledata); + modelAllocateRwData(weaponfiledata); } else { weaponobj = NULL; weaponfiledata = NULL; diff --git a/src/game/prop.c b/src/game/prop.c index 746ec06d5..a1514ba67 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -1206,7 +1206,7 @@ void handInflictCloseRangeDamage(s32 handnum, struct gset *gset, bool arg2) bgunCalculatePlayerShotSpread(&spd8, &spcc, handnum, true); - if (model000225d4(model, &spd8, &spcc, &node) > 0) { + if (modelTestForHit(model, &spd8, &spcc, &node) > 0) { f32 damage = gsetGetDamage(gset) * 2.5f; skipthething = true; bgunPlayGlassHitSound(&playerprop->pos, playerprop->rooms, -1); @@ -2597,7 +2597,7 @@ void autoaimTick(void) if (bestprop->flags & PROPFLAG_ONTHISSCREENTHISTICK) { struct defaultobj *obj = bestprop->obj; - Mtxf *mtx = model0001a60c(obj->model); + Mtxf *mtx = modelGetRootMtx(obj->model); struct coord spac; spac.z = mtx->m[3][2]; diff --git a/src/game/propobj.c b/src/game/propobj.c index f67d65a8a..b3f6ea2ac 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -737,7 +737,7 @@ bool func0f0679ac(struct model *model, f32 *max, f32 *min, f32 arg3[2], f32 arg4 if (type == MODELNODETYPE_BBOX) { struct modelrodata_bbox *bbox = &node->rodata->bbox; - Mtxf *mtx = model0001a5cc(model, node, 0); + Mtxf *mtx = modelFindNodeMtx(model, node, 0); f32 dist1; f32 dist2; @@ -794,7 +794,7 @@ void func0f067bc4(struct model *model, f32 *max, f32 *min, s32 axis) if (type == MODELNODETYPE_BBOX) { struct modelrodata_bbox *bbox = &node->rodata->bbox; - Mtxf *mtx = model0001a5cc(model, node, 0); + Mtxf *mtx = modelFindNodeMtx(model, node, 0); f32 dist1; f32 dist2; @@ -863,7 +863,7 @@ bool modelGetScreenCoords2(struct model *model, f32 *x2, f32 *x1, f32 *y2, f32 * f32 sp64[2]; f32 sp5c[2]; struct coord sp50; - Mtxf *mtx = model0001a5cc(model, node, 0); + Mtxf *mtx = modelFindNodeMtx(model, node, 0); if (mtx->m[3][2] < 0.0f) { sp50.x = mtx->m[3][0]; @@ -1230,13 +1230,13 @@ struct modelnode *func0f0687e4(struct model *model) case MODELNODETYPE_DL: return node; case MODELNODETYPE_DISTANCE: - model0001c784(model, node); + modelApplyDistanceRelations(model, node); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, node); + modelApplyToggleRelations(model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, node); + modelApplyHeadRelations(model, node); break; } @@ -1305,13 +1305,13 @@ struct modelnode *modelFindBboxNode(struct model *model) case MODELNODETYPE_BBOX: return node; case MODELNODETYPE_DISTANCE: - model0001c784(model, node); + modelApplyDistanceRelations(model, node); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, node); + modelApplyToggleRelations(model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, node); + modelApplyHeadRelations(model, node); break; } @@ -2652,7 +2652,7 @@ bool func0f06b488(struct prop *prop, struct coord *arg1, struct coord *arg2, str bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coord *arg2, struct coord *arg3, f32 arg4, struct coord *arg5, struct coord *arg6, struct coord *arg7, struct coord *arg8, f32 *arg9) { struct model *model = obj->model; - f32 f0 = model0001af80(model); + f32 f0 = modelGetEffectiveScale(model); f32 xdiff; f32 ydiff; f32 zdiff; @@ -2685,7 +2685,7 @@ bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 if (sum1 >= -f0 && sum1 <= arg4 + f0) { if (prop->flags & PROPFLAG_ONTHISSCREENTHISTICK) { if (var8005efc0 > 0.0f) { - hitpart = model000225d4(model, arg5, arg6, &spe4); + hitpart = modelTestForHit(model, arg5, arg6, &spe4); while (hitpart > 0) { if (func0f084594(model, spe4, arg5, arg6, &thing1, &mtxindex1, &node1)) { @@ -2723,11 +2723,11 @@ bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 } } - hitpart = model000225d4(model, arg5, arg6, &spe4); + hitpart = modelTestForHit(model, arg5, arg6, &spe4); } } else { do { - hitpart = model000225d4(model, arg5, arg6, &spe4); + hitpart = modelTestForHit(model, arg5, arg6, &spe4); if (hitpart > 0) { if (func0f0849dc(model, spe4, arg5, arg6, &thing1, &mtxindex1, &node1)) { @@ -2806,7 +2806,7 @@ bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 } } } else { - if (func0f06b39c(arg1, arg3, &prop->pos, model0001af80(model)) + if (func0f06b39c(arg1, arg3, &prop->pos, modelGetEffectiveScale(model)) && func0f06b488(prop, arg1, arg2, arg3, arg7, arg8, arg9)) { g_EmbedModel = model; g_EmbedNode = model->filedata->rootnode; @@ -2885,7 +2885,7 @@ bool func0f06bea0(struct model *model, struct modelnode *endnode, struct modelno case MODELNODETYPE_BBOX: rodata = node->rodata; - if (model000220fc(&rodata->bbox, model0001a5cc(model, node, 0), arg3, arg4)) { + if (modelTestBboxNodeForHit(&rodata->bbox, modelFindNodeMtx(model, node, 0), arg3, arg4)) { s7 = true; sp84 = node; @@ -2897,7 +2897,7 @@ bool func0f06bea0(struct model *model, struct modelnode *endnode, struct modelno s7 = false; var8005efc0 = 10.0f / model->scale; - if (model000220fc(&rodata->bbox, model0001a5cc(model, node, 0), arg3, arg4)) { + if (modelTestBboxNodeForHit(&rodata->bbox, modelFindNodeMtx(model, node, 0), arg3, arg4)) { if (g_Vars.hitboundscount < ARRAYCOUNT(g_Vars.hitnodes)) { g_Vars.hitnodes[g_Vars.hitboundscount] = node; g_Vars.hitboundscount++; @@ -2913,14 +2913,14 @@ bool func0f06bea0(struct model *model, struct modelnode *endnode, struct modelno rwdata = modelGetNodeRwData(model, node); if (rwdata->gdl != NULL) { - if (rwdata->gdl == rodata->dl.primary) { - s4 = (Gfx *)((u32)rodata->dl.colourtable + ((u32)rodata->dl.primary & 0xffffff)); + if (rwdata->gdl == rodata->dl.opagdl) { + s4 = (Gfx *)((u32)rodata->dl.colourtable + ((u32)rodata->dl.opagdl & 0xffffff)); } else { s4 = rwdata->gdl; } - if (rodata->dl.secondary != NULL) { - s6 = (Gfx *)((u32)rodata->dl.colourtable + ((u32)rodata->dl.secondary & 0xffffff)); + if (rodata->dl.xlugdl != NULL) { + s6 = (Gfx *)((u32)rodata->dl.colourtable + ((u32)rodata->dl.xlugdl & 0xffffff)); } vertices = rwdata->vertices; @@ -2929,13 +2929,13 @@ bool func0f06bea0(struct model *model, struct modelnode *endnode, struct modelno break; case MODELNODETYPE_GUNDL: if (s7) { - if (node->rodata->gundl.primary != NULL) { + if (node->rodata->gundl.opagdl != NULL) { s32 base = (s32)node->rodata->gundl.baseaddr; - s4 = (Gfx *)(base + ((u32)node->rodata->gundl.primary & 0xffffff)); + s4 = (Gfx *)(base + ((u32)node->rodata->gundl.opagdl & 0xffffff)); - if (node->rodata->gundl.secondary != NULL) { - s6 = (Gfx *)(base + ((u32)node->rodata->gundl.secondary & 0xffffff)); + if (node->rodata->gundl.xlugdl != NULL) { + s6 = (Gfx *)(base + ((u32)node->rodata->gundl.xlugdl & 0xffffff)); } vertices = (struct gfxvtx *)base; @@ -2943,13 +2943,13 @@ bool func0f06bea0(struct model *model, struct modelnode *endnode, struct modelno } break; case MODELNODETYPE_DISTANCE: - model0001c784(model, node); + modelApplyDistanceRelations(model, node); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, node); + modelApplyToggleRelations(model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, node); + modelApplyHeadRelations(model, node); break; } @@ -2982,7 +2982,7 @@ bool func0f06bea0(struct model *model, struct modelnode *endnode, struct modelno if (ok) { *arg6 = sqrtf(sp98); *arg10 = sp88; - *arg9 = model0001a524(sp88, 0); + *arg9 = modelFindNodeMtxIndex(sp88, 0); } var8005efc0 = 0.0f; @@ -3017,7 +3017,7 @@ bool func0f06c28c(struct chrdata *chr, struct coord *arg1, struct coord *arg2, s if (-spe4 <= spd4 && spd4 <= arg4 + spe4 && func0f06b39c(arg1, arg3, &prop->pos, spe4)) { if ((prop->flags & PROPFLAG_ONTHISSCREENTHISTICK)) { if (var8005efc0 > 0.0f) { - hitpart = model000225d4(model, arg5, arg6, &spcc); + hitpart = modelTestForHit(model, arg5, arg6, &spcc); while (hitpart > 0) { if (func0f084594(model, spcc, arg5, arg6, &sp7c, &sp78, &sp74)) { @@ -3055,10 +3055,10 @@ bool func0f06c28c(struct chrdata *chr, struct coord *arg1, struct coord *arg2, s } } - hitpart = model000225d4(model, arg5, arg6, &spcc); + hitpart = modelTestForHit(model, arg5, arg6, &spcc); } } else { - hitpart = model000225d4(model, arg5, arg6, &spcc); + hitpart = modelTestForHit(model, arg5, arg6, &spcc); if (hitpart > 0 && func0f06bea0(model, model->filedata->rootnode, model->filedata->rootnode, arg5, arg6, &sp7c.unk00, &spec, &spcc, &hitpart, &sp78, &sp74) @@ -4061,7 +4061,7 @@ bool objEmbed(struct prop *prop, struct prop *parent, struct model *model, struc obj->embedment = embedmentAllocate(); if (obj->embedment) { - sp24 = model0001a5cc(model, node, 0); + sp24 = modelFindNodeMtx(model, node, 0); obj->hidden |= OBJHFLAG_EMBEDDED; @@ -4181,7 +4181,7 @@ bool propExplode(struct prop *prop, s32 exptype) } if (prop->flags & PROPFLAG_ONTHISSCREENTHISTICK) { - Mtxf *mtx = model0001a60c(obj->model); + Mtxf *mtx = modelGetRootMtx(obj->model); pos.x = mtx->m[3][0]; pos.y = mtx->m[3][1]; @@ -4757,7 +4757,7 @@ void func0f07079c(struct prop *prop, bool fulltick) } if (model->attachedtonode && (obj->hidden & OBJHFLAG_EMBEDDED)) { - Mtxf *mtx = model0001a5cc(model->attachedtomodel, model->attachedtonode, 0); + Mtxf *mtx = modelFindNodeMtx(model->attachedtomodel, model->attachedtonode, 0); struct modelrenderdata renderdata = {NULL, true, 3}; u32 stack; Mtxf sp30; @@ -4768,7 +4768,7 @@ void func0f07079c(struct prop *prop, bool fulltick) renderdata.unk10 = gfxAllocate(model->filedata->nummatrices * sizeof(Mtxf)); renderdata.unk00 = &sp30; - model0001ce64(&renderdata, model); + modelSetMatrices(&renderdata, model); func0f07063c(prop, fulltick); child = prop->child; @@ -6040,8 +6040,8 @@ bool rocketTickFbw(struct weaponobj *rocket) yrot = atan2f(ydist, sqrtf(xdist * xdist + zdist * zdist)); for (i = 0; i < g_Vars.lvupdate240; i++) { - projectile->unk018 = model0001afe8(projectile->unk018, xrot, PAL ? 0.02246f : 0.01875f); - projectile->unk014 = model0001afe8(projectile->unk014, yrot, PAL ? 0.02246f : 0.01875f); + projectile->unk018 = modelTweenRotAxis(projectile->unk018, xrot, PAL ? 0.02246f : 0.01875f); + projectile->unk014 = modelTweenRotAxis(projectile->unk014, yrot, PAL ? 0.02246f : 0.01875f); } mtx4LoadXRotation(M_BADTAU - projectile->unk014, &sp118); @@ -6995,7 +6995,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) Mtxf sp188; Mtxf *sp184; - sp184 = model0001a5cc(g_EmbedModel, g_EmbedNode, 0); + sp184 = modelFindNodeMtx(g_EmbedModel, g_EmbedNode, 0); mtx4TransformVec(camGetWorldToScreenMtxf(), &sp5e8, &sp1c8); mtx0001719c(sp184->m, sp188.m); mtx4TransformVecInPlace(&sp188, &sp1c8); @@ -8946,7 +8946,7 @@ void autogunInitMatrices(struct prop *prop, Mtxf *mtx) mtx4SetTranslation(&rodata->position.pos, &matrices[2]); mtx00015be0(&matrices[1], &matrices[2]); - tmp = model0001a5cc(model, node2, 0x100); + tmp = modelFindNodeMtx(model, node2, 0x100); if (tmp != NULL) { mtx4LoadZRotation(xrot * 0.5f, tmp); @@ -8957,7 +8957,7 @@ void autogunInitMatrices(struct prop *prop, Mtxf *mtx) node3 = modelGetPart(model->filedata, MODELPART_AUTOGUN_0003); if (node3 != NULL) { - tmp = model0001a5cc(model, node3, 0); + tmp = modelFindNodeMtx(model, node3, 0); rodata = node3->rodata; mtx4LoadXRotation(autogun->barrelrot, tmp); mtx4SetTranslation(&rodata->position.pos, tmp); @@ -8967,7 +8967,7 @@ void autogunInitMatrices(struct prop *prop, Mtxf *mtx) node4 = modelGetPart(model->filedata, MODELPART_AUTOGUN_0004); if (node4 != NULL) { - tmp = model0001a5cc(model, node4, 0); + tmp = modelFindNodeMtx(model, node4, 0); rodata = node4->rodata; mtx4LoadTranslation(&rodata->position.pos, tmp); mtx00015be0(&matrices[2], tmp); @@ -8976,7 +8976,7 @@ void autogunInitMatrices(struct prop *prop, Mtxf *mtx) node6 = modelGetPart(model->filedata, MODELPART_AUTOGUN_0006); if (node6 != NULL) { - tmp = model0001a5cc(model, node6, 0); + tmp = modelFindNodeMtx(model, node6, 0); rodata = node6->rodata; mtx4LoadXRotation(autogun->barrelrot, tmp); mtx4SetTranslation(&rodata->position.pos, tmp); @@ -9048,14 +9048,14 @@ void autogunTickShoot(struct prop *autogunprop) union modelrodata *rodata; if (flashnode) { - sp108 = model0001a5cc(model, flashnode, 0); + sp108 = modelFindNodeMtx(model, flashnode, 0); rodata = flashnode->rodata; gunpos.x = rodata->chrgunfire.pos.x; gunpos.y = rodata->chrgunfire.pos.y; gunpos.z = rodata->chrgunfire.pos.z; } else { - sp108 = model0001a5cc(model, posnode, 0); + sp108 = modelFindNodeMtx(model, posnode, 0); gunpos.x = 0.0f; gunpos.y = 0.0f; @@ -10829,7 +10829,7 @@ void objInitMatrices(struct prop *prop) thing.unk10 = obj->model->matrices; thing.unk00 = &sp28; - model0001ce64(&thing, obj->model); + modelSetMatrices(&thing, obj->model); } } } @@ -11029,13 +11029,13 @@ s32 objTickPlayer(struct prop *prop) struct hov *hov = NULL; if (fulltick) { - s32 iVar10 = g_Vars.lvupdate240; + s32 lvupdate240 = g_Vars.lvupdate240; - if (g_Vars.tickmode == TICKMODE_CUTSCENE && iVar10 > 0 && g_Vars.cutsceneskip60ths > 0) { - iVar10 += g_Vars.cutsceneskip60ths * 4; + if (g_Vars.tickmode == TICKMODE_CUTSCENE && lvupdate240 > 0 && g_Vars.cutsceneskip60ths > 0) { + lvupdate240 += g_Vars.cutsceneskip60ths * 4; } - model0001ee18(model, iVar10, true); + modelTickAnimQuarterSpeed(model, lvupdate240, true); } anim00023d38(model->anim->animnum); @@ -11045,13 +11045,13 @@ s32 objTickPlayer(struct prop *prop) sp552 = true; } else { if (fulltick) { - model0001b3bc(model); + modelUpdateInfo(model); } sp556 = true; sp476.unk10 = gfxAllocate(model->filedata->nummatrices * sizeof(Mtxf)); sp476.unk00 = camGetWorldToScreenMtxf(); - model0001cebc(&sp476, model); + modelSetMatricesWithAnim(&sp476, model); if (fulltick) { mtx00015be4(camGetProjectionMtxF(), model->matrices, &sp412); @@ -11128,7 +11128,7 @@ s32 objTickPlayer(struct prop *prop) if (fulltick) { sp148 = floorf(model->anim->frame); sp148++; - model0001ee18(model, g_Vars.lvupdate240, 1); + modelTickAnimQuarterSpeed(model, g_Vars.lvupdate240, true); sp144 = floorf(model->anim->frame); for (i = sp148; i <= sp144; i++) { @@ -11149,7 +11149,7 @@ s32 objTickPlayer(struct prop *prop) sp556 = true; sp312.unk10 = gfxAllocate(model->filedata->nummatrices * sizeof(Mtxf)); sp312.unk00 = &sp152; - model0001cebc(&sp312, model); + modelSetMatricesWithAnim(&sp312, model); if (fulltick) { sp236.x = (f32)sp116.x + prop->pos.x; @@ -11268,7 +11268,7 @@ s32 objTickPlayer(struct prop *prop) } else if (obj->flags2 & OBJFLAG2_04000000) { pass2 = posIsInDrawDistance(&prop->pos); } else if ((obj->hidden & OBJHFLAG_00000800) == 0 && (obj->flags2 & OBJFLAG2_INVISIBLE) == 0) { - pass2 = func0f08e8ac(prop, &prop->pos, model0001af80(model), sp564); + pass2 = func0f08e8ac(prop, &prop->pos, modelGetEffectiveScale(model), sp564); } else { pass2 = false; } @@ -11300,7 +11300,7 @@ s32 objTickPlayer(struct prop *prop) if (sp556 == false) { model->matrices = gfxAllocate(model->filedata->nummatrices * sizeof(Mtxf)); objInitMatrices(prop); - model0001cb0c(model, model->filedata->rootnode); + modelUpdateRelationsQuick(model, model->filedata->rootnode); } prop->z = -model->matrices[0].m[3][2]; @@ -13582,7 +13582,7 @@ Gfx *objRender(struct prop *prop, Gfx *gdl, bool xlupass) } if (obj->type != OBJTYPE_TINTEDGLASS) { - frac = func0f08e6bc(prop, model0001af80(obj->model)); + frac = func0f08e6bc(prop, modelGetEffectiveScale(obj->model)); if (prop->timetoregen > 0 && prop->timetoregen < TICKS(60)) { frac *= (TICKS(60.0f) - prop->timetoregen) * (PAL ? 0.019999999552965f : 0.016666667535901f); @@ -14060,13 +14060,13 @@ void objDeform(struct defaultobj *obj, s32 level) } break; case MODELNODETYPE_DISTANCE: - model0001c784(obj->model, node); + modelApplyDistanceRelations(obj->model, node); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(obj->model, node); + modelApplyToggleRelations(obj->model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(obj->model, node); + modelApplyHeadRelations(obj->model, node); break; } @@ -14422,10 +14422,10 @@ bool objDrop(struct prop *prop, bool lazy) f32 spa0; node1 = objFindBboxNode(obj); - modelNodeGetPosition(obj->model, model0001a740(node1), &spb8); + modelNodeGetPosition(obj->model, modelNodeFindMtxNode(node1), &spb8); node2 = objFindBboxNode(rootobj); - modelNodeGetPosition(rootobj->model, model0001a740(node2), &spa8); + modelNodeGetPosition(rootobj->model, modelNodeFindMtxNode(node2), &spa8); spe4.x = spb8.x - spa8.x; spe4.y = spb8.y - spa8.y; @@ -14530,7 +14530,7 @@ bool objDrop(struct prop *prop, bool lazy) if (!lazy && (prop->flags & PROPFLAG_ONTHISSCREENTHISTICK)) { // Do collision checks - Mtxf *sp48 = model0001a60c(model); + Mtxf *sp48 = modelGetRootMtx(model); mtx00015be4(camGetProjectionMtxF(), sp48, &spf0); propSetPerimEnabled(root, false); @@ -14828,7 +14828,7 @@ bool func0f084594(struct model *model, struct modelnode *node, struct coord *arg rodata = &node->rodata->bbox; - mtxindex = model0001a524(node, 0); + mtxindex = modelFindNodeMtxIndex(node, 0); mtx000172f0(model->matrices[mtxindex].m, mtx.m); spb8.x = arg2->x; @@ -14971,14 +14971,14 @@ bool func0f0849dc(struct model *model, struct modelnode *nodearg, struct coord * struct modelrwdata_dl *rwdata = modelGetNodeRwData(model, node); if (rwdata->gdl != NULL) { - if (rwdata->gdl == rodata->primary) { - s3 = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->primary & 0xffffff)); + if (rwdata->gdl == rodata->opagdl) { + s3 = (Gfx *)((u32)rodata->colourtable + ((u32)rodata->opagdl & 0xffffff)); } else { s3 = rwdata->gdl; } - if (rodata->secondary != NULL) { - s5 = (void *)((u32)rodata->colourtable + ((u32)rodata->secondary & 0xffffff)); + if (rodata->xlugdl != NULL) { + s5 = (void *)((u32)rodata->colourtable + ((u32)rodata->xlugdl & 0xffffff)); } vertices = rwdata->vertices; @@ -14989,11 +14989,11 @@ bool func0f0849dc(struct model *model, struct modelnode *nodearg, struct coord * { struct modelrodata_gundl *rodata = &node->rodata->gundl; - if (rodata->primary != NULL) { - s3 = (Gfx *)((u32)rodata->baseaddr + ((u32)rodata->primary & 0xffffff)); + if (rodata->opagdl != NULL) { + s3 = (Gfx *)((u32)rodata->baseaddr + ((u32)rodata->opagdl & 0xffffff)); - if (rodata->secondary != NULL) { - s5 = (Gfx *)((u32)rodata->baseaddr + ((u32)rodata->secondary & 0xffffff)); + if (rodata->xlugdl != NULL) { + s5 = (Gfx *)((u32)rodata->baseaddr + ((u32)rodata->xlugdl & 0xffffff)); } vertices = (void *)(u32)rodata->baseaddr; @@ -15001,18 +15001,18 @@ bool func0f0849dc(struct model *model, struct modelnode *nodearg, struct coord * } break; case MODELNODETYPE_DISTANCE: - model0001c784(model, node); + modelApplyDistanceRelations(model, node); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, node); + modelApplyToggleRelations(model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, node); + modelApplyHeadRelations(model, node); break; } if (s3 != NULL) { - s32 mtxindex = model0001a524(node, 0); + s32 mtxindex = modelFindNodeMtxIndex(node, 0); Mtxf *mtx = NULL; Mtxf sp64; @@ -15170,7 +15170,7 @@ void cctvHandleLensShot(struct defaultobj *obj) if (prop->flags & PROPFLAG_ONTHISSCREENTHISTICK) { rodata = modelGetPartRodata(model->filedata, MODELPART_CCTV_0002); - sp7c = model0001a5cc(model, modelGetPart(model->filedata, MODELPART_CCTV_LENS), 0); + sp7c = modelFindNodeMtx(model, modelGetPart(model->filedata, MODELPART_CCTV_LENS), 0); mtx00015be4(camGetProjectionMtxF(), sp7c, &matrix); shardsCreate((struct coord *) matrix.m[3], matrix.m[0], matrix.m[1], matrix.m[2], @@ -15564,18 +15564,18 @@ void func0f0859a0(struct prop *prop, struct shotdata *shotdata) } if (var8005efc0 > 0.0f) { - lVar3 = model000225d4(model, &shotdata->unk00, &shotdata->unk0c, &node1); + lVar3 = modelTestForHit(model, &shotdata->unk00, &shotdata->unk0c, &node1); while (lVar3 > 0) { if (func0f084594(model, node1, &shotdata->unk00, &shotdata->unk0c, &hitthing1, &spe4, &node2)) { break; } - lVar3 = model000225d4(model, &shotdata->unk00, &shotdata->unk0c, &node1); + lVar3 = modelTestForHit(model, &shotdata->unk00, &shotdata->unk0c, &node1); } } else { do { - lVar3 = model000225d4(model, &shotdata->unk00, &shotdata->unk0c, &node1); + lVar3 = modelTestForHit(model, &shotdata->unk00, &shotdata->unk0c, &node1); if (lVar3 > 0 && func0f0849dc(model, node1, &shotdata->unk00, &shotdata->unk0c, &hitthing1, &spe4, &node2)) { break; @@ -16240,7 +16240,7 @@ void objGetBbox(struct prop *prop, f32 *radius, f32 *ymax, f32 *ymin) *ymin = obj->geocyl->ymin; *ymax = obj->geocyl->ymax; } else { - *radius = model0001af80(obj->model); + *radius = modelGetEffectiveScale(obj->model); *ymin = obj->geoblock->ymin; *ymax = obj->geoblock->ymax; } @@ -17640,7 +17640,7 @@ bool func0f0899dc(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3) { if (prop->flags & PROPFLAG_ONTHISSCREENTHISTICK) { struct defaultobj *obj = prop->obj; - Mtxf *matrix = model0001a60c(obj->model); + Mtxf *matrix = modelGetRootMtx(obj->model); arg1->z = matrix->m[3][2]; @@ -17699,13 +17699,13 @@ void modelFreeVertices(s32 vtxstoretype, struct model *model) } break; case MODELNODETYPE_DISTANCE: - model0001c784(model, node); + modelApplyDistanceRelations(model, node); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, node); + modelApplyToggleRelations(model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, node); + modelApplyHeadRelations(model, node); break; } diff --git a/src/game/setuputils.c b/src/game/setuputils.c index bb0d25451..954e22a9d 100644 --- a/src/game/setuputils.c +++ b/src/game/setuputils.c @@ -155,7 +155,7 @@ bool setupLoadModeldef(s32 modelnum) { if (g_ModelStates[modelnum].filedata == NULL) { g_ModelStates[modelnum].filedata = modeldefLoadToNew(g_ModelStates[modelnum].fileid); - modelCalculateRwDataLen(g_ModelStates[modelnum].filedata); + modelAllocateRwData(g_ModelStates[modelnum].filedata); return true; } diff --git a/src/game/title.c b/src/game/title.c index 9aabf9621..e81828968 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -560,7 +560,7 @@ void titleInitPdLogo(void) size = ALIGN64(fileGetLoadedSize(g_ModelStates[MODEL_NLOGO].fileid)); nextaddr += size; remaining = 0x47800 - size; - modelCalculateRwDataLen(g_ModelStates[MODEL_NLOGO].filedata); + modelAllocateRwData(g_ModelStates[MODEL_NLOGO].filedata); g_TitleModel = modelmgrInstantiateModelWithAnim(g_ModelStates[MODEL_NLOGO].filedata); modelSetScale(g_TitleModel, 1); @@ -573,7 +573,7 @@ void titleInitPdLogo(void) size = ALIGN64(fileGetLoadedSize(g_ModelStates[MODEL_NLOGO2].fileid)); nextaddr += size; remaining -= size; - modelCalculateRwDataLen(g_ModelStates[MODEL_NLOGO2].filedata); + modelAllocateRwData(g_ModelStates[MODEL_NLOGO2].filedata); g_TitleModelNLogo2 = modelmgrInstantiateModelWithAnim(g_ModelStates[MODEL_NLOGO2].filedata); modelSetScale(g_TitleModelNLogo2, 1); @@ -586,7 +586,7 @@ void titleInitPdLogo(void) size = ALIGN64(fileGetLoadedSize(g_ModelStates[MODEL_PDTWO].fileid)); nextaddr += size; remaining -= size; - modelCalculateRwDataLen(g_ModelStates[MODEL_PDTWO].filedata); + modelAllocateRwData(g_ModelStates[MODEL_PDTWO].filedata); g_TitleModelPdTwo = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_PDTWO].filedata); modelSetScale(g_TitleModelPdTwo, 1); @@ -600,7 +600,7 @@ void titleInitPdLogo(void) size = ALIGN64(fileGetLoadedSize(g_ModelStates[MODEL_JPNLOGO].fileid)); nextaddr += size; remaining -= size; - modelCalculateRwDataLen(g_ModelStates[MODEL_JPNLOGO].filedata); + modelAllocateRwData(g_ModelStates[MODEL_JPNLOGO].filedata); g_TitleModelJpnLogo1 = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_JPNLOGO].filedata); g_TitleModelJpnLogo2 = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_JPNLOGO].filedata); @@ -613,7 +613,7 @@ void titleInitPdLogo(void) size = ALIGN64(fileGetLoadedSize(g_ModelStates[MODEL_JPNPD].fileid)); nextaddr += size; remaining -= size; - modelCalculateRwDataLen(g_ModelStates[MODEL_JPNPD].filedata); + modelAllocateRwData(g_ModelStates[MODEL_JPNPD].filedata); g_TitleModelJpnPd = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_JPNPD].filedata); modelSetScale(g_TitleModelJpnPd, 1); @@ -627,7 +627,7 @@ void titleInitPdLogo(void) size = ALIGN64(fileGetLoadedSize(g_ModelStates[MODEL_PDTHREE].fileid)); nextaddr += size; remaining -= size; - modelCalculateRwDataLen(g_ModelStates[MODEL_PDTHREE].filedata); + modelAllocateRwData(g_ModelStates[MODEL_PDTHREE].filedata); g_TitleModelPdThree = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_PDTHREE].filedata); modelSetScale(g_TitleModelPdThree, 1); @@ -886,7 +886,7 @@ Gfx *titleRenderPdLogoModel(Gfx *gdl, struct model *model, bool arg2, f32 arg3, model->matrices = renderdata.unk10; - model0001cc20(model); + modelUpdateRelations(model); renderdata.flags = 3; renderdata.zbufferenabled = false; @@ -2518,7 +2518,7 @@ glabel var7f1a8ff4jf /* f019488: 8c4f0000 */ lw $t7,0x0($v0) /* f01948c: 8fb804b0 */ lw $t8,0x4b0($sp) /* f019490: adf8000c */ sw $t8,0xc($t7) -/* f019494: 0c0072fc */ jal model0001cc20 +/* f019494: 0c0072fc */ jal modelUpdateRelations /* f019498: 8c440000 */ lw $a0,0x0($v0) /* f01949c: 8fb80198 */ lw $t8,0x198($sp) /* f0194a0: 240e0005 */ li $t6,0x5 @@ -2812,7 +2812,7 @@ glabel var7f1a8ff4jf /* f0198e4: 8c590000 */ lw $t9,0x0($v0) /* f0198e8: 8fae04b0 */ lw $t6,0x4b0($sp) /* f0198ec: af2e000c */ sw $t6,0xc($t9) -/* f0198f0: 0c0072fc */ jal model0001cc20 +/* f0198f0: 0c0072fc */ jal modelUpdateRelations /* f0198f4: 8c440000 */ lw $a0,0x0($v0) /* f0198f8: 8fa80154 */ lw $t0,0x154($sp) /* f0198fc: 24180005 */ li $t8,0x5 @@ -2928,7 +2928,7 @@ glabel var7f1a8ff4jf /* f019aa4: 8c580000 */ lw $t8,0x0($v0) /* f019aa8: 8fb904b0 */ lw $t9,0x4b0($sp) /* f019aac: af19000c */ sw $t9,0xc($t8) -/* f019ab0: 0c0072fc */ jal model0001cc20 +/* f019ab0: 0c0072fc */ jal modelUpdateRelations /* f019ab4: 8c440000 */ lw $a0,0x0($v0) /* f019ab8: 8fb804e0 */ lw $t8,0x4e0($sp) /* f019abc: 240f0005 */ li $t7,0x5 @@ -7572,7 +7572,7 @@ Gfx *titleRenderPdLogo(Gfx *gdl) g_TitleModelJpnLogo2->matrices = renderdata.unk10; - model0001cc20(g_TitleModelJpnLogo2); + modelUpdateRelations(g_TitleModelJpnLogo2); renderdata.unk30 = 5; renderdata.zbufferenabled = false; @@ -7630,7 +7630,7 @@ Gfx *titleRenderPdLogo(Gfx *gdl) g_TitleModelJpnPd->matrices = renderdata.unk10; - model0001cc20(g_TitleModelJpnPd); + modelUpdateRelations(g_TitleModelJpnPd); renderdata.zbufferenabled = false; renderdata.unk30 = 5; @@ -7667,7 +7667,7 @@ Gfx *titleRenderPdLogo(Gfx *gdl) g_TitleModelJpnLogo1->matrices = renderdata.unk10; - model0001cc20(g_TitleModelJpnLogo1); + modelUpdateRelations(g_TitleModelJpnLogo1); renderdata.zbufferenabled = false; renderdata.unk30 = 5; @@ -7869,7 +7869,7 @@ void titleInitNintendoLogo(void) g_ModelStates[MODEL_NINTENDOLOGO].filedata = modeldefLoad(g_ModelStates[MODEL_NINTENDOLOGO].fileid, nextaddr, 0x47800, 0); - modelCalculateRwDataLen(g_ModelStates[MODEL_NINTENDOLOGO].filedata); + modelAllocateRwData(g_ModelStates[MODEL_NINTENDOLOGO].filedata); g_TitleModel = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_NINTENDOLOGO].filedata); modelSetScale(g_TitleModel, 1); modelSetRootPosition(g_TitleModel, &coord); @@ -7998,7 +7998,7 @@ Gfx *titleRenderNintendoLogo(Gfx *gdl) mtx4Copy(&sp108, renderdata.unk10); g_TitleModel->matrices = renderdata.unk10; - model0001cc20(g_TitleModel); + modelUpdateRelations(g_TitleModel); renderdata.flags = 3; renderdata.zbufferenabled = false; @@ -8028,7 +8028,7 @@ void titleInitRareLogo(void) g_ModelStates[MODEL_RARELOGO].filedata = modeldefLoad(g_ModelStates[MODEL_RARELOGO].fileid, nextaddr, 0x47800, 0); - modelCalculateRwDataLen(g_ModelStates[MODEL_RARELOGO].filedata); + modelAllocateRwData(g_ModelStates[MODEL_RARELOGO].filedata); g_TitleModel = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_RARELOGO].filedata); modelSetScale(g_TitleModel, 1); modelSetRootPosition(g_TitleModel, &coord); @@ -8196,7 +8196,7 @@ Gfx *titleRenderRareLogo(Gfx *gdl) g_TitleModel->matrices = renderdata.unk10; - model0001cc20(g_TitleModel); + modelUpdateRelations(g_TitleModel); rwdata = modelGetNodeRwData(g_TitleModel, modelGetPart(g_TitleModel->filedata, MODELPART_RARELOGO_000B)); diff --git a/src/game/vtxstore.c b/src/game/vtxstore.c index fac1397a1..3314c9efe 100644 --- a/src/game/vtxstore.c +++ b/src/game/vtxstore.c @@ -69,13 +69,13 @@ void vtxstoreFixRefs(union modelrwdata *find, union modelrwdata *replacement) } break; case MODELNODETYPE_DISTANCE: - model0001c784(obj->model, node); + modelApplyDistanceRelations(obj->model, node); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(obj->model, node); + modelApplyToggleRelations(obj->model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(obj->model, node); + modelApplyHeadRelations(obj->model, node); break; } diff --git a/src/include/constants.h b/src/include/constants.h index 24a34f721..cec4bbc41 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -2581,6 +2581,9 @@ #define MODELPART_0066 0x0066 #define MODELPART_0067 0x0067 +#define MODELRENDERFLAG_OPA 1 +#define MODELRENDERFLAG_XLU 2 + #define MODFILE_GAME 1 #define MODFILE_MPSETUP 2 #define MODFILE_BOSS 4 diff --git a/src/include/data.h b/src/include/data.h index 2e0d01ec2..7a90fec4d 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -53,7 +53,7 @@ extern f32 var8005efc0; extern u8 var8005efb0_2; extern u32 var8005efd0; extern bool var8005efd8_2; -extern bool var8005efdc; +extern bool g_ModelAnimMergingEnabled; extern u32 var8005efe0; extern u32 var8005efec; extern u32 var8005eff8; diff --git a/src/include/game/chr.h b/src/include/game/chr.h index ae9d8d1d4..f17a95dcf 100644 --- a/src/include/game/chr.h +++ b/src/include/game/chr.h @@ -24,7 +24,7 @@ void chrFlinchBody(struct chrdata *chr); void chrFlinchHead(struct chrdata *chr, f32 arg1); f32 chrGetFlinchAmount(struct chrdata *chr); void chr0f021fa8(struct chrdata *chr, struct coord *pos, s16 *rooms); -void chr0f0220ec(struct chrdata *chr, s32 lvupdate240, s32 arg2); +void chr0f0220ec(struct chrdata *chr, s32 lvupdate240, bool arg2); void chr0f022214(struct chrdata *chr, struct prop *child, bool fulltick); void chrUpdateCloak(struct chrdata *chr); s32 chrGetCloakAlpha(struct chrdata *chr); diff --git a/src/include/game/modelmgr.h b/src/include/game/modelmgr.h index 44496b4d2..557c093ee 100644 --- a/src/include/game/modelmgr.h +++ b/src/include/game/modelmgr.h @@ -10,7 +10,7 @@ struct model *modelmgrInstantiateModel(struct modelfiledata *modelfiledata, bool struct model *modelmgrInstantiateModelWithoutAnim(struct modelfiledata *modelfiledata); void modelmgrFreeModel(struct model *model); struct model *modelmgrInstantiateModelWithAnim(struct modelfiledata *modelfiledata); -void modelmgr0f0b32a0(struct model *model, struct modelnode *node, struct modelfiledata *headfiledata); +void modelmgrAttachHead(struct model *model, struct modelnode *node, struct modelfiledata *headfiledata); struct anim *modelmgrInstantiateAnim(void); void modelmgrFreeAnim(struct anim *anim); diff --git a/src/include/lib/model.h b/src/include/lib/model.h index cf9b7bcce..4930b5093 100644 --- a/src/include/lib/model.h +++ b/src/include/lib/model.h @@ -11,50 +11,50 @@ extern void (*g_ModelJointPositionedFunc)(s32 mtxindex, Mtxf *mtx); bool model00018680(struct modelrenderdata *renderdata, struct model *model); void modelSetDistanceScale(f32 value); void modelSetVtxAllocatorFunc(struct gfxvtx *(*fn)(s32 numvertices)); -s32 model0001a524(struct modelnode *node, s32 arg1); -Mtxf *model0001a5cc(struct model *model, struct modelnode *node, s32 arg2); -Mtxf *model0001a60c(struct model *model); -struct modelnode *model0001a634(struct model *model, s32 mtxindex); -struct modelnode *model0001a740(struct modelnode *node); -struct modelnode *model0001a784(struct modelnode *node); -struct modelnode *model0001a7cc(struct modelnode *node); -struct modelnode *model0001a85c(struct modelnode *node); +s32 modelFindNodeMtxIndex(struct modelnode *node, s32 arg1); +Mtxf *modelFindNodeMtx(struct model *model, struct modelnode *node, s32 arg2); +Mtxf *modelGetRootMtx(struct model *model); +struct modelnode *modelFindNodeByMtxIndex(struct model *model, s32 mtxindex); +struct modelnode *modelNodeFindMtxNode(struct modelnode *node); +struct modelnode *modelNodeFindParentMtxNode(struct modelnode *node); +struct modelnode *modelNodeFindChildMtxNode(struct modelnode *node); +struct modelnode *modelNodeFindChildOrParentMtxNode(struct modelnode *node); struct modelnode *modelGetPart(struct modelfiledata *arg0, s32 partnum); void *modelGetPartRodata(struct modelfiledata *modelfiledata, s32 partnum); -f32 model0001a9e8(struct model *model); +f32 modelGetScreenDistance(struct model *model); void *modelGetNodeRwData(struct model *model, struct modelnode *node); void modelNodeGetPosition(struct model *model, struct modelnode *node, struct coord *pos); void modelNodeSetPosition(struct model *model, struct modelnode *node, struct coord *pos); void modelGetRootPosition(struct model *model, struct coord *pos); void modelSetRootPosition(struct model *model, struct coord *pos); void modelNodeGetModelRelativePosition(struct model *model, struct modelnode *node, struct coord *pos); -f32 model0001ae44(struct model *model); -void model0001ae90(struct model *model, f32 angle); +f32 modelGetChrRotY(struct model *model); +void modelSetChrRotY(struct model *model, f32 angle); void modelSetScale(struct model *model, f32 scale); void modelSetAnimScale(struct model *model, f32 scale); -f32 model0001af80(struct model *model); -void model0001af98(struct coord *arg0, struct coord *arg1, f32 frac); -f32 model0001afe8(f32 arg0, f32 angle, f32 frac); -void model0001b07c(struct coord *arg0, struct coord *arg1, f32 mult); -void model0001b0e8(struct model *model, struct modelnode *node); -void model0001b3bc(struct model *model); -void model0001b400(struct modelrenderdata *arg0, struct model *model, struct modelnode *node); +f32 modelGetEffectiveScale(struct model *model); +void modelTweenPos(struct coord *pos, struct coord *to, f32 frac); +f32 modelTweenRotAxis(f32 arg0, f32 angle, f32 frac); +void modelTweenRot(struct coord *arg0, struct coord *arg1, f32 mult); +void modelUpdateChrInfo(struct model *model, struct modelnode *node); +void modelUpdateInfo(struct model *model); +void modelUpdateChrNodeMtx(struct modelrenderdata *arg0, struct model *model, struct modelnode *node); void modelPositionJointUsingVecRot(struct modelrenderdata *renderdata, struct model *model, struct modelnode *node, struct coord *rot, struct coord *pos, bool allowscale, struct coord *arg6); void modelPositionJointUsingQuatRot(struct modelrenderdata *renderdata, struct model *model, struct modelnode *node, f32 rot[4], struct coord *pos, struct coord *arg5); -void model0001bfa8(struct modelrenderdata *arg0, struct model *model, struct modelnode *node); -void model0001c5b4(struct modelrenderdata *arg0, struct model *model, struct modelnode *node); -void model0001c664(struct model *model, struct modelnode *node); -void model0001c784(struct model *model, struct modelnode *node); -void model0001c7d0(struct model *model, struct modelnode *node); -void modelAttachHead(struct model *model, struct modelnode *node); -void model0001c868(struct modelnode *node, bool visible); -void modelRenderNodeReorder(struct model *model, struct modelnode *node); -void model0001c950(struct model *model, struct modelnode *node); -void model0001cb0c(struct model *model, struct modelnode *node); -void model0001cc20(struct model *model); -void model0001cd18(struct modelrenderdata *arg0, struct model *model); -void model0001ce64(struct modelrenderdata *arg0, struct model *model); -void model0001cebc(struct modelrenderdata *renderdata, struct model *model); +void modelUpdatePositionNodeMtx(struct modelrenderdata *arg0, struct model *model, struct modelnode *node); +void modelUpdatePositionHeldNodeMtx(struct modelrenderdata *arg0, struct model *model, struct modelnode *node); +void modelUpdateDistanceRelations(struct model *model, struct modelnode *node); +void modelApplyDistanceRelations(struct model *model, struct modelnode *node); +void modelApplyToggleRelations(struct model *model, struct modelnode *node); +void modelApplyHeadRelations(struct model *model, struct modelnode *node); +void modelApplyReorderRelationsByArg(struct modelnode *basenode, bool reverse); +void modelApplyReorderRelations(struct model *model, struct modelnode *node); +void modelUpdateReorderRelations(struct model *model, struct modelnode *node); +void modelUpdateRelationsQuick(struct model *model, struct modelnode *node); +void modelUpdateRelations(struct model *model); +void modelUpdateMatrices(struct modelrenderdata *arg0, struct model *model); +void modelSetMatrices(struct modelrenderdata *arg0, struct model *model); +void modelSetMatricesWithAnim(struct modelrenderdata *renderdata, struct model *model); s16 modelGetAnimNum(struct model *model); bool modelIsFlipped(struct model *model); f32 modelGetCurAnimFrame(struct model *model); @@ -64,7 +64,7 @@ f32 modelGetAnimSpeed(struct model *model); f32 modelGetAbsAnimSpeed(struct model *model); s32 modelConstrainOrWrapAnimFrame(s32 frame, s16 animnum, f32 endframe); void modelCopyAnimForMerge(struct model *model, f32 merge); -void model0001d62c(struct model *model, s16 animnum, s32 flip, f32 fstartframe, f32 speed, f32 merge); +void modelSetAnimation2(struct model *model, s16 animnum, s32 flip, f32 fstartframe, f32 speed, f32 merge); bool modelIsAnimMerging(struct model *model); void modelSetAnimationWithMerge(struct model *model, s16 animnum, u32 flip, f32 startframe, f32 speed, f32 timemerge, bool domerge); void modelSetAnimation(struct model *model, s16 animnum, s32 flip, f32 fstartframe, f32 speed, f32 merge); @@ -76,34 +76,34 @@ void modelSetAnimSpeed(struct model *model, f32 speed, f32 startframe); void modelSetAnimSpeedAuto(struct model *model, f32 arg1, f32 startframe); void modelSetAnimPlaySpeed(struct model *model, f32 speed, f32 frame); void modelSetAnim70(struct model *model, void *callback); -void model0001e018(struct model *model, f32 startframe); -void model0001e14c(struct model *model, f32 arg1, f32 arg2); -void model0001e29c(bool value); -bool model0001e2a8(void); -void model0001e2b4(struct model *model, f32 frame, f32 arg2, f32 frame2, f32 arg4); -void model0001ee18(struct model *model, s32 lvupdate240, bool arg2); -void model0001f314(struct model *model, s32 lvupdate240, bool arg2); -void model0001f7e0(struct modelrenderdata *renderdata); -void model0001f890(struct modelrenderdata *renderdata, bool arg1); -void model00020248(struct modelrenderdata *renderdata, bool arg1); -void model00020bdc(struct modelrenderdata *renderdata); +void modelSetAnimFrame(struct model *model, f32 startframe); +void modelSetAnimFrame2(struct model *model, f32 arg1, f32 arg2); +void modelSetAnimMergingEnabled(bool value); +bool modelIsAnimMergingEnabled(void); +void modelSetAnimFrame2WithChrStuff(struct model *model, f32 frame, f32 arg2, f32 frame2, f32 arg4); +void modelTickAnimQuarterSpeed(struct model *model, s32 lvupdate240, bool arg2); +void modelTickAnim(struct model *model, s32 lvupdate240, bool arg2); +void modelApplyRenderModeType1(struct modelrenderdata *renderdata); +void modelApplyRenderModeType3(struct modelrenderdata *renderdata, bool arg1); +void modelApplyRenderModeType4(struct modelrenderdata *renderdata, bool arg1); +void modelApplyRenderModeType2(struct modelrenderdata *renderdata); void modelApplyCullMode(struct modelrenderdata *renderdata); void modelRenderNodeGundl(struct modelrenderdata *renderdata, struct model *model, struct modelnode *node); void modelRenderNodeDl(struct modelrenderdata *renderdata, struct model *model, struct modelnode *node); void modelRenderNodeStarGunfire(struct modelrenderdata *renderdata, struct modelnode *node); -void model000216cc(struct modelrenderdata *renderdata, struct textureconfig *tconfig, s32 arg2); +void modelSelectTexture(struct modelrenderdata *renderdata, struct textureconfig *tconfig, s32 arg2); void modelRenderNodeChrGunfire(struct modelrenderdata *renderdata, struct model *model, struct modelnode *node); void modelRender(struct modelrenderdata *renderdata, struct model *model); -bool model000220fc(struct modelrodata_bbox *bbox, Mtxf *mtx, struct coord *arg2, struct coord *arg3); -s32 model000225d4(struct model *model, struct coord *arg1, struct coord *arg2, struct modelnode **startnode); +bool modelTestBboxNodeForHit(struct modelrodata_bbox *bbox, Mtxf *mtx, struct coord *arg2, struct coord *arg3); +s32 modelTestForHit(struct model *model, struct coord *arg1, struct coord *arg2, struct modelnode **startnode); void modelPromoteNodeOffsetsToPointers(struct modelnode *node, u32 vma, u32 fileramaddr); void modelPromoteOffsetsToPointers(struct modelfiledata *filedata, u32 arg1, u32 arg2); s32 modelCalculateRwDataIndexes(struct modelnode *node); -void modelCalculateRwDataLen(struct modelfiledata *filedata); +void modelAllocateRwData(struct modelfiledata *filedata); void modelInitRwData(struct model *model, struct modelnode *node); void modelInit(struct model *model, struct modelfiledata *filedata, union modelrwdata **rwdatas, bool resetanim); void animInit(struct anim *anim); -void model00023108(struct model *model, struct modelfiledata *arg1, struct modelnode *node, struct modelfiledata *arg3); +void modelAttachHead(struct model *model, struct modelfiledata *arg1, struct modelnode *node, struct modelfiledata *arg3); void modelIterateDisplayLists(struct modelfiledata *filedata, struct modelnode **nodeptr, Gfx **gdlptr); void modelNodeReplaceGdl(struct modelfiledata *modeldef, struct modelnode *node, Gfx *find, Gfx *replacement); diff --git a/src/include/types.h b/src/include/types.h index 2a2fdd033..119fcdca2 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -422,8 +422,8 @@ struct modelrodata_position { // type 0x02 }; struct modelrodata_gundl { // type 0x04 - Gfx *primary; - Gfx *secondary; + Gfx *opagdl; + Gfx *xlugdl; void *baseaddr; struct gfxvtx *vertices; s16 numvertices; @@ -444,7 +444,7 @@ struct modelrodata_reorder { // type 0x09 f32 unk0c[3]; struct modelnode *unk18; struct modelnode *unk1c; - s16 unk20; + s16 side; u16 rwdataindex; }; @@ -531,8 +531,8 @@ struct modelrodata_headspot { // type 0x17 }; struct modelrodata_dl { // type 0x18 - /*0x00*/ Gfx *primary; - /*0x04*/ Gfx *secondary; + /*0x00*/ Gfx *opagdl; + /*0x04*/ Gfx *xlugdl; /*0x08*/ u32 *colourtable; /*0x0c*/ struct gfxvtx *vertices; // colours follow this array /*0x10*/ s16 numvertices; @@ -584,7 +584,7 @@ struct modelfiledata { s16 numparts; s16 nummatrices; - f32 unk10; + f32 scale; s16 rwdatalen; // in words s16 numtexconfigs; struct textureconfig *texconfigs; @@ -614,7 +614,7 @@ struct modelrwdata_chrinfo { // type 0x01 s8 unk02; f32 ground; struct coord pos; - f32 unk14; // angle + f32 yrot; // angle f32 unk18; f32 unk1c; f32 unk20; // angle @@ -636,7 +636,7 @@ struct modelrwdata_distance { // type 0x08 }; struct modelrwdata_reorder { // type 0x09 - bool visible; + bool reverse; }; struct modelrwdata_0b { // type 0x0b @@ -654,7 +654,7 @@ struct modelrwdata_toggle { // type 0x12 }; struct modelrwdata_headspot { // type 0x17 - struct modelfiledata *modelfiledata; + struct modelfiledata *headmodeldef; void *rwdatas; }; diff --git a/src/lib/model.c b/src/lib/model.c index b3184266b..3646c9065 100644 --- a/src/lib/model.c +++ b/src/lib/model.c @@ -52,7 +52,14 @@ void modelSetVtxAllocatorFunc(struct gfxvtx *(*fn)(s32 numvertices)) g_ModelVtxAllocatorFunc = fn; } -s32 model0001a524(struct modelnode *node, s32 arg1) +/** + * Ascend the node's parents until a node type is found which supports an mtx. + * Return the instance-local mtx index for that node. + * + * Position nodes support up to 3 matrices. In this case the desired one can be + * specified with arg1. + */ +s32 modelFindNodeMtxIndex(struct modelnode *node, s32 arg1) { s32 index; union modelrodata *rodata1; @@ -78,9 +85,9 @@ s32 model0001a524(struct modelnode *node, s32 arg1) return -1; } -Mtxf *model0001a5cc(struct model *model, struct modelnode *node, s32 arg2) +Mtxf *modelFindNodeMtx(struct model *model, struct modelnode *node, s32 arg2) { - s32 index = model0001a524(node, arg2); + s32 index = modelFindNodeMtxIndex(node, arg2); if (index >= 0) { return &model->matrices[index]; @@ -89,12 +96,12 @@ Mtxf *model0001a5cc(struct model *model, struct modelnode *node, s32 arg2) return NULL; } -Mtxf *model0001a60c(struct model *model) +Mtxf *modelGetRootMtx(struct model *model) { - return model0001a5cc(model, model->filedata->rootnode, 0); + return modelFindNodeMtx(model, model->filedata->rootnode, 0); } -struct modelnode *model0001a634(struct model *model, s32 mtxindex) +struct modelnode *modelFindNodeByMtxIndex(struct model *model, s32 mtxindex) { struct modelnode *node = model->filedata->rootnode; union modelrodata *rodata1; @@ -142,7 +149,7 @@ struct modelnode *model0001a634(struct model *model, s32 mtxindex) return NULL; } -struct modelnode *model0001a740(struct modelnode *node) +struct modelnode *modelNodeFindMtxNode(struct modelnode *node) { while (node) { u32 type = node->type & 0xff; @@ -159,7 +166,7 @@ struct modelnode *model0001a740(struct modelnode *node) return node; } -struct modelnode *model0001a784(struct modelnode *node) +struct modelnode *modelNodeFindParentMtxNode(struct modelnode *node) { while ((node = node->parent)) { u32 type = node->type & 0xff; @@ -174,7 +181,7 @@ struct modelnode *model0001a784(struct modelnode *node) return node; } -struct modelnode *model0001a7cc(struct modelnode *basenode) +struct modelnode *modelNodeFindChildMtxNode(struct modelnode *basenode) { struct modelnode *node = basenode->child; @@ -209,7 +216,7 @@ struct modelnode *model0001a7cc(struct modelnode *basenode) return node; } -struct modelnode *model0001a85c(struct modelnode *basenode) +struct modelnode *modelNodeFindChildOrParentMtxNode(struct modelnode *basenode) { struct modelnode *node = basenode; struct modelnode *next; @@ -299,9 +306,9 @@ void *modelGetPartRodata(struct modelfiledata *modelfiledata, s32 partnum) return NULL; } -f32 model0001a9e8(struct model *model) +f32 modelGetScreenDistance(struct model *model) { - Mtxf *mtx = model0001a60c(model); + Mtxf *mtx = modelGetRootMtx(model); if (mtx) { return -mtx->m[3][2]; @@ -466,21 +473,21 @@ void modelNodeGetModelRelativePosition(struct model *model, struct modelnode *no } } -f32 model0001ae44(struct model *model) +f32 modelGetChrRotY(struct model *model) { if ((model->filedata->rootnode->type & 0xff) == MODELNODETYPE_CHRINFO) { union modelrwdata *rwdata = modelGetNodeRwData(model, model->filedata->rootnode); - return rwdata->chrinfo.unk14; + return rwdata->chrinfo.yrot; } return 0; } -void model0001ae90(struct model *model, f32 angle) +void modelSetChrRotY(struct model *model, f32 angle) { if ((model->filedata->rootnode->type & 0xff) == MODELNODETYPE_CHRINFO) { struct modelrwdata_chrinfo *rwdata = modelGetNodeRwData(model, model->filedata->rootnode); - f32 diff = angle - rwdata->unk14; + f32 diff = angle - rwdata->yrot; if (diff < 0) { diff += M_BADTAU; @@ -498,7 +505,7 @@ void model0001ae90(struct model *model, f32 angle) rwdata->unk20 -= M_BADTAU; } - rwdata->unk14 = angle; + rwdata->yrot = angle; } } @@ -514,51 +521,51 @@ void modelSetAnimScale(struct model *model, f32 scale) } } -f32 model0001af80(struct model *model) +f32 modelGetEffectiveScale(struct model *model) { - return model->filedata->unk10 * model->scale; + return model->filedata->scale * model->scale; } -void model0001af98(struct coord *arg0, struct coord *arg1, f32 frac) +void modelTweenPos(struct coord *curpos, struct coord *goalpos, f32 frac) { - arg0->x += (arg1->x - arg0->x) * frac; - arg0->y += (arg1->y - arg0->y) * frac; - arg0->z += (arg1->z - arg0->z) * frac; + curpos->x += (goalpos->x - curpos->x) * frac; + curpos->y += (goalpos->y - curpos->y) * frac; + curpos->z += (goalpos->z - curpos->z) * frac; } -f32 model0001afe8(f32 arg0, f32 angle, f32 mult) +f32 modelTweenRotAxis(f32 curangle, f32 goalangle, f32 mult) { - f32 value = angle - arg0; + f32 diff = goalangle - curangle; - if (angle < arg0) { - value += M_BADTAU; + if (goalangle < curangle) { + diff += M_BADTAU; } - if (value < M_PI) { - arg0 += value * mult; + if (diff < M_PI) { + curangle += diff * mult; - if (arg0 >= M_BADTAU) { - arg0 -= M_BADTAU; + if (curangle >= M_BADTAU) { + curangle -= M_BADTAU; } } else { - arg0 -= (M_BADTAU - value) * mult; + curangle -= (M_BADTAU - diff) * mult; - if (arg0 < 0) { - arg0 += M_BADTAU; + if (curangle < 0) { + curangle += M_BADTAU; } } - return arg0; + return curangle; } -void model0001b07c(struct coord *arg0, struct coord *arg1, f32 mult) +void modelTweenRot(struct coord *currot, struct coord *goalrot, f32 mult) { - arg0->x = model0001afe8(arg0->x, arg1->x, mult); - arg0->y = model0001afe8(arg0->y, arg1->y, mult); - arg0->z = model0001afe8(arg0->z, arg1->z, mult); + currot->x = modelTweenRotAxis(currot->x, goalrot->x, mult); + currot->y = modelTweenRotAxis(currot->y, goalrot->y, mult); + currot->z = modelTweenRotAxis(currot->z, goalrot->z, mult); } -void model0001b0e8(struct model *model, struct modelnode *node) +void modelUpdateChrInfo(struct model *model, struct modelnode *node) { union modelrwdata *rwdata; struct anim *anim = model->anim; @@ -580,7 +587,7 @@ void model0001b0e8(struct model *model, struct modelnode *node) sp34.y = rwdata->chrinfo.unk34.y; sp34.z = rwdata->chrinfo.unk34.z; - rwdata->chrinfo.unk14 = rwdata->chrinfo.unk30; + rwdata->chrinfo.yrot = rwdata->chrinfo.unk30; if (g_Vars.in_cutscene && anim->speed > 0.0f) { #if VERSION >= VERSION_PAL_BETA @@ -593,9 +600,9 @@ void model0001b0e8(struct model *model, struct modelnode *node) } if (frac != 0.0f && rwdata->chrinfo.unk01) { - model0001af98(&sp34, &rwdata->chrinfo.unk24, frac); + modelTweenPos(&sp34, &rwdata->chrinfo.unk24, frac); - rwdata->chrinfo.unk14 = model0001afe8(rwdata->chrinfo.unk30, rwdata->chrinfo.unk20, frac); + rwdata->chrinfo.yrot = modelTweenRotAxis(rwdata->chrinfo.unk30, rwdata->chrinfo.unk20, frac); } if (anim->animnum2 || anim->fracmerge) { @@ -646,23 +653,23 @@ void model0001b0e8(struct model *model, struct modelnode *node) } } -void model0001b3bc(struct model *model) +void modelUpdateInfo(struct model *model) { struct modelnode *node = model->filedata->rootnode; if (node && (node->type & 0xff) == MODELNODETYPE_CHRINFO) { - model0001b0e8(model, node); + modelUpdateChrInfo(model, node); } } -void model0001b400(struct modelrenderdata *arg0, struct model *model, struct modelnode *node) +void modelUpdateChrNodeMtx(struct modelrenderdata *arg0, struct model *model, struct modelnode *node) { struct anim *anim = model->anim; union modelrodata *rodata = node->rodata; union modelrwdata *rwdata = modelGetNodeRwData(model, node); f32 scale = model->scale; struct coord *sp254 = &rwdata->chrinfo.pos; - f32 sp250 = rwdata->chrinfo.unk14; + f32 sp250 = rwdata->chrinfo.yrot; Mtxf *sp24c; u32 stack1; Mtxf *mtx = &model->matrices[rodata->chrinfo.mtxindex]; @@ -693,7 +700,7 @@ void model0001b400(struct modelrenderdata *arg0, struct model *model, struct mod if (rodata->chrinfo.mtxindex); if (node->parent) { - sp24c = model0001a5cc(model, node->parent, 0); + sp24c = modelFindNodeMtx(model, node->parent, 0); } else { sp24c = arg0->unk00; } @@ -712,7 +719,7 @@ void model0001b400(struct modelrenderdata *arg0, struct model *model, struct mod if (sp154 != 0.0f) { anim00024050(sp240, anim->flip, skel, anim->animnum, anim->unk05, &sp148, &sp13c, &sp130); - model0001b07c(&sp230, &sp148, sp154); + modelTweenRot(&sp230, &sp148, sp154); } if (anim->fracmerge != 0.0f) { @@ -720,11 +727,11 @@ void model0001b400(struct modelrenderdata *arg0, struct model *model, struct mod if (anim->frac2 != 0.0f) { anim00024050(sp240, anim->flip2, skel, anim->animnum2, anim->unk07, &spd0, &spc4, &spb8); - model0001b07c(&sp124, &spd0, anim->frac2); + modelTweenRot(&sp124, &spd0, anim->frac2); } if ((g_Anims[anim->animnum].flags & ANIMFLAG_02) && (g_Anims[anim->animnum2].flags & ANIMFLAG_02) == 0) { - mtx4LoadYRotation(rwdata->chrinfo.unk14, &sp78); + mtx4LoadYRotation(rwdata->chrinfo.yrot, &sp78); mtx4LoadRotation(&sp124, &sp38); mtx00015be0(&sp78, &sp38); quaternion0f097044(&sp38, spec); @@ -744,7 +751,7 @@ void model0001b400(struct modelrenderdata *arg0, struct model *model, struct mod mtx4LoadTranslation(sp254, &sp198); } else { if (rwdata->chrinfo.unk18 != 0.0f) { - sp250 = model0001afe8(sp250, rwdata->chrinfo.unk1c, rwdata->chrinfo.unk18); + sp250 = modelTweenRotAxis(sp250, rwdata->chrinfo.unk1c, rwdata->chrinfo.unk18); } mtx4LoadYRotationWithTranslation(sp254, sp250, &sp198); @@ -776,7 +783,7 @@ void modelPositionJointUsingVecRot(struct modelrenderdata *renderdata, struct mo Mtxf *matrices = model->matrices; if (node->parent != NULL) { - rendermtx = model0001a5cc(model, node->parent, 0); + rendermtx = modelFindNodeMtx(model, node->parent, 0); } else { rendermtx = renderdata->unk00; } @@ -890,7 +897,7 @@ void modelPositionJointUsingQuatRot(struct modelrenderdata *renderdata, struct m Mtxf *matrices = model->matrices; if (node->parent != NULL) { - rendermtx = model0001a5cc(model, node->parent, 0); + rendermtx = modelFindNodeMtx(model, node->parent, 0); } else { rendermtx = renderdata->unk00; } @@ -981,7 +988,7 @@ void modelPositionJointUsingQuatRot(struct modelrenderdata *renderdata, struct m } } -void model0001bfa8(struct modelrenderdata *renderdata, struct model *model, struct modelnode *node) +void modelUpdatePositionNodeMtx(struct modelrenderdata *renderdata, struct model *model, struct modelnode *node) { struct anim *anim; struct modelrodata_position *rodata = &node->rodata->position; @@ -1030,7 +1037,7 @@ void model0001bfa8(struct modelrenderdata *renderdata, struct model *model, stru if (spe0 != 0.0f) { anim00024050(partnum, anim->flip, skel, anim->animnum, anim->unk05, &spd4, &spc8, &spbc); - model0001b07c(&sp144, &spd4, spe0); + modelTweenRot(&sp144, &spd4, spe0); #if VERSION >= VERSION_PAL_BETA if (sp128 || var8005efd8_2) @@ -1038,7 +1045,7 @@ void model0001bfa8(struct modelrenderdata *renderdata, struct model *model, stru if (sp128) #endif { - model0001af98(&sp138, &spc8, spe0); + modelTweenPos(&sp138, &spc8, spe0); } } } else { @@ -1054,7 +1061,7 @@ void model0001bfa8(struct modelrenderdata *renderdata, struct model *model, stru if (anim->frac2 != 0.0f) { anim00024050(partnum, anim->flip2, skel, anim->animnum2, anim->unk07, &sp5c, &sp50, &sp44); - model0001b07c(&spb0, &sp5c, anim->frac2); + modelTweenRot(&spb0, &sp5c, anim->frac2); } quaternion0f096ca0(&sp144, sp88); @@ -1106,7 +1113,7 @@ void model0001bfa8(struct modelrenderdata *renderdata, struct model *model, stru } } else { if (node->parent) { - mtx = model0001a5cc(model, node->parent, 0); + mtx = modelFindNodeMtx(model, node->parent, 0); } else { mtx = renderdata->unk00; } @@ -1120,7 +1127,7 @@ void model0001bfa8(struct modelrenderdata *renderdata, struct model *model, stru } } -void model0001c5b4(struct modelrenderdata *arg0, struct model *model, struct modelnode *node) +void modelUpdatePositionHeldNodeMtx(struct modelrenderdata *arg0, struct model *model, struct modelnode *node) { union modelrodata *rodata = node->rodata; Mtxf *sp68; @@ -1129,7 +1136,7 @@ void model0001c5b4(struct modelrenderdata *arg0, struct model *model, struct mod Mtxf *matrices = model->matrices; if (node->parent) { - sp68 = model0001a5cc(model, node->parent, 0); + sp68 = modelFindNodeMtx(model, node->parent, 0); } else { sp68 = arg0->unk00; } @@ -1145,11 +1152,11 @@ void model0001c5b4(struct modelrenderdata *arg0, struct model *model, struct mod /** * For a distance node, set its target to visible based on distance. */ -void model0001c664(struct model *model, struct modelnode *node) +void modelUpdateDistanceRelations(struct model *model, struct modelnode *node) { union modelrodata *rodata = node->rodata; union modelrwdata *rwdata = modelGetNodeRwData(model, node); - Mtxf *mtx = model0001a5cc(model, node, 0); + Mtxf *mtx = modelFindNodeMtx(model, node, 0); f32 distance; if (g_ModelDistanceDisabled || !mtx) { @@ -1174,7 +1181,7 @@ void model0001c664(struct model *model, struct modelnode *node) node->child = NULL; } -void model0001c784(struct model *model, struct modelnode *node) +void modelApplyDistanceRelations(struct model *model, struct modelnode *node) { struct modelrodata_distance *rodata = &node->rodata->distance; struct modelrwdata_distance *rwdata = modelGetNodeRwData(model, node); @@ -1186,7 +1193,7 @@ void model0001c784(struct model *model, struct modelnode *node) } } -void model0001c7d0(struct model *model, struct modelnode *node) +void modelApplyToggleRelations(struct model *model, struct modelnode *node) { struct modelrodata_toggle *rodata = &node->rodata->toggle; struct modelrwdata_toggle *rwdata = modelGetNodeRwData(model, node); @@ -1203,12 +1210,12 @@ void model0001c7d0(struct model *model, struct modelnode *node) * * The given modelnode is assumed to be of type MODELNODETYPE_HEADSPOT. */ -void modelAttachHead(struct model *model, struct modelnode *bodynode) +void modelApplyHeadRelations(struct model *model, struct modelnode *bodynode) { struct modelrwdata_headspot *rwdata = modelGetNodeRwData(model, bodynode); - if (rwdata->modelfiledata) { - struct modelnode *headnode = rwdata->modelfiledata->rootnode; + if (rwdata->headmodeldef) { + struct modelnode *headnode = rwdata->headmodeldef->rootnode; bodynode->child = headnode; @@ -1219,14 +1226,14 @@ void modelAttachHead(struct model *model, struct modelnode *bodynode) } } -void model0001c868(struct modelnode *basenode, bool visible) +void modelApplyReorderRelationsByArg(struct modelnode *basenode, bool reverse) { union modelrodata *rodata = basenode->rodata; struct modelnode *node1; struct modelnode *node2; struct modelnode *loopnode; - if (visible) { + if (reverse) { node1 = rodata->reorder.unk18; node2 = rodata->reorder.unk1c; } else { @@ -1273,36 +1280,36 @@ void model0001c868(struct modelnode *basenode, bool visible) } } -void modelRenderNodeReorder(struct model *model, struct modelnode *node) +void modelApplyReorderRelations(struct model *model, struct modelnode *node) { union modelrwdata *rwdata = modelGetNodeRwData(model, node); - model0001c868(node, rwdata->reorder.visible); + modelApplyReorderRelationsByArg(node, rwdata->reorder.reverse); } -void model0001c950(struct model *model, struct modelnode *node) +void modelUpdateReorderRelations(struct model *model, struct modelnode *node) { union modelrodata *rodata = node->rodata; union modelrwdata *rwdata = modelGetNodeRwData(model, node); - Mtxf *mtx = model0001a5cc(model, node, 0); + Mtxf *mtx = modelFindNodeMtx(model, node, 0); struct coord sp38; struct coord sp2c; f32 tmp; - if (rodata->reorder.unk20 == 0) { + if (rodata->reorder.side == 0) { sp38.x = rodata->reorder.unk0c[0]; sp38.y = rodata->reorder.unk0c[1]; sp38.z = rodata->reorder.unk0c[2]; mtx4RotateVecInPlace(mtx, &sp38); - } else if (rodata->reorder.unk20 == 2) { + } else if (rodata->reorder.side == 2) { sp38.x = mtx->m[1][0] * rodata->reorder.unk0c[1]; sp38.y = mtx->m[1][1] * rodata->reorder.unk0c[1]; sp38.z = mtx->m[1][2] * rodata->reorder.unk0c[1]; - } else if (rodata->reorder.unk20 == 3) { + } else if (rodata->reorder.side == 3) { sp38.x = mtx->m[2][0] * rodata->reorder.unk0c[2]; sp38.y = mtx->m[2][1] * rodata->reorder.unk0c[2]; sp38.z = mtx->m[2][2] * rodata->reorder.unk0c[2]; - } else if (rodata->reorder.unk20 == 1) { + } else if (rodata->reorder.side == 1) { sp38.x = mtx->m[0][0] * rodata->reorder.unk0c[0]; sp38.y = mtx->m[0][1] * rodata->reorder.unk0c[0]; sp38.z = mtx->m[0][2] * rodata->reorder.unk0c[0]; @@ -1317,15 +1324,22 @@ void model0001c950(struct model *model, struct modelnode *node) tmp = sp38.f[0] * sp2c.f[0] + sp38.f[1] * sp2c.f[1] + sp38.f[2] * sp2c.f[2]; if (tmp < 0) { - rwdata->reorder.visible = true; + rwdata->reorder.reverse = true; } else { - rwdata->reorder.visible = false; + rwdata->reorder.reverse = false; } - modelRenderNodeReorder(model, node); + modelApplyReorderRelations(model, node); } -void model0001cb0c(struct model *model, struct modelnode *parent) +/** + * Update a model definition's node relations based on the rwdata from the given + * model instance, recalculating the rwdata where possible. + * + * However, several node types are not descended into, and toggle nodes are not + * applied to the model definition. + */ +void modelUpdateRelationsQuick(struct model *model, struct modelnode *parent) { struct modelnode *node = parent->child; @@ -1347,13 +1361,13 @@ void model0001cb0c(struct model *model, struct modelnode *parent) dochildren = false; break; case MODELNODETYPE_DISTANCE: - model0001c664(model, node); + modelUpdateDistanceRelations(model, node); break; case MODELNODETYPE_REORDER: - model0001c950(model, node); + modelUpdateReorderRelations(model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, node); + modelApplyHeadRelations(model, node); break; case MODELNODETYPE_DL: break; @@ -1379,7 +1393,11 @@ void model0001cb0c(struct model *model, struct modelnode *parent) } } -void model0001cc20(struct model *model) +/** + * Update a model definition's node relations based on the rwdata from the given + * model instance, recalculating the rwdata where possible. + */ +void modelUpdateRelations(struct model *model) { struct modelnode *node = model->filedata->rootnode; @@ -1388,16 +1406,16 @@ void model0001cc20(struct model *model) switch (type) { case MODELNODETYPE_DISTANCE: - model0001c664(model, node); + modelUpdateDistanceRelations(model, node); break; case MODELNODETYPE_REORDER: - model0001c950(model, node); + modelUpdateReorderRelations(model, node); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, node); + modelApplyToggleRelations(model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, node); + modelApplyHeadRelations(model, node); break; case MODELNODETYPE_CHRINFO: case MODELNODETYPE_DL: @@ -1420,7 +1438,7 @@ void model0001cc20(struct model *model) } } -void model0001cd18(struct modelrenderdata *arg0, struct model *model) +void modelUpdateMatrices(struct modelrenderdata *arg0, struct model *model) { struct modelnode *node = model->filedata->rootnode; @@ -1429,25 +1447,25 @@ void model0001cd18(struct modelrenderdata *arg0, struct model *model) switch (type) { case MODELNODETYPE_CHRINFO: - model0001b400(arg0, model, node); + modelUpdateChrNodeMtx(arg0, model, node); break; case MODELNODETYPE_POSITION: - model0001bfa8(arg0, model, node); + modelUpdatePositionNodeMtx(arg0, model, node); break; case MODELNODETYPE_POSITIONHELD: - model0001c5b4(arg0, model, node); + modelUpdatePositionHeldNodeMtx(arg0, model, node); break; case MODELNODETYPE_DISTANCE: - model0001c664(model, node); + modelUpdateDistanceRelations(model, node); break; case MODELNODETYPE_REORDER: - model0001c950(model, node); + modelUpdateReorderRelations(model, node); break; case MODELNODETYPE_TOGGLE: - model0001c7d0(model, node); + modelApplyToggleRelations(model, node); break; case MODELNODETYPE_HEADSPOT: - modelAttachHead(model, node); + modelApplyHeadRelations(model, node); break; case MODELNODETYPE_DL: default: @@ -1469,7 +1487,7 @@ void model0001cd18(struct modelrenderdata *arg0, struct model *model) } } -void model0001ce64(struct modelrenderdata *renderdata, struct model *model) +void modelSetMatrices(struct modelrenderdata *renderdata, struct model *model) { model->matrices = renderdata->unk10; @@ -1477,16 +1495,16 @@ void model0001ce64(struct modelrenderdata *renderdata, struct model *model) #if VERSION >= VERSION_PAL_BETA if (var8005efb0_2 || !model00018680(renderdata, model)) { - model0001cd18(renderdata, model); + modelUpdateMatrices(renderdata, model); } #else if (!model00018680(renderdata, model)) { - model0001cd18(renderdata, model); + modelUpdateMatrices(renderdata, model); } #endif } -void model0001cebc(struct modelrenderdata *arg0, struct model *model) +void modelSetMatricesWithAnim(struct modelrenderdata *renderdata, struct model *model) { struct anim *anim = model->anim; f32 speed; @@ -1528,7 +1546,7 @@ void model0001cebc(struct modelrenderdata *arg0, struct model *model) anim00023d0c(); } - model0001ce64(arg0, model); + modelSetMatrices(renderdata, model); if (PLAYERCOUNT() >= 2 && anim && anim->animnum) { anim->frac = frac; @@ -1695,7 +1713,7 @@ void modelCopyAnimForMerge(struct model *model, f32 merge) } } -void model0001d62c(struct model *model, s16 animnum, s32 flip, f32 fstartframe, f32 speed, f32 merge) +void modelSetAnimation2(struct model *model, s16 animnum, s32 flip, f32 fstartframe, f32 speed, f32 merge) { struct anim *anim = model->anim; @@ -1718,7 +1736,7 @@ void model0001d62c(struct model *model, s16 animnum, s32 flip, f32 fstartframe, anim->speed = speed; anim->timespeed = 0; - model0001e018(model, fstartframe); + modelSetAnimFrame(model, fstartframe); anim->looping = false; @@ -1756,7 +1774,7 @@ void model0001d62c(struct model *model, s16 animnum, s32 flip, f32 fstartframe, rwdata->unk34.x = sp88.x * sp64; rwdata->unk34.y = sp88.y * sp64; rwdata->unk34.z = sp88.z * sp64; - rwdata->unk30 = rwdata->unk14; + rwdata->unk30 = rwdata->yrot; if (anim->frac == 0) { rwdata->unk01 = 0; @@ -1769,7 +1787,7 @@ void model0001d62c(struct model *model, s16 animnum, s32 flip, f32 fstartframe, rwdata->unk24.x = sp88.x * sp64; rwdata->unk24.y = sp88.y * sp64; rwdata->unk24.z = sp88.z * sp64; - rwdata->unk20 = rwdata->unk14; + rwdata->unk20 = rwdata->yrot; rwdata->unk01 = 1; } @@ -1787,15 +1805,15 @@ void model0001d62c(struct model *model, s16 animnum, s32 flip, f32 fstartframe, sp88.y = rwdata->pos.y - rwdata->ground; } - sp98 = cosf(rwdata->unk14); - sp94 = sinf(rwdata->unk14); + sp98 = cosf(rwdata->yrot); + sp94 = sinf(rwdata->yrot); if (anim->frac == 0) { rwdata->unk34.x = rwdata->pos.f[0]; rwdata->unk34.y = rwdata->pos.f[1] - rwdata->ground; rwdata->unk34.z = rwdata->pos.f[2]; - rwdata->unk30 = rwdata->unk14; + rwdata->unk30 = rwdata->yrot; sp58.x = rwdata->unk34.f[0] + sp88.f[0] * sp98 + sp88.f[2] * sp94; sp58.y = sp88.f[1]; @@ -1831,13 +1849,13 @@ void model0001d62c(struct model *model, s16 animnum, s32 flip, f32 fstartframe, rwdata->unk34.f[1] = (rwdata->pos.f[1] - rwdata->ground) - (y - (rwdata->pos.f[1] - rwdata->ground)) * anim->frac / (1 - anim->frac); rwdata->unk34.f[2] = rwdata->unk24.f[2] - z; - angle = rwdata->unk14 - sp84; + angle = rwdata->yrot - sp84; if (angle < 0) { angle += M_BADTAU; } - rwdata->unk30 = model0001afe8(rwdata->unk14, angle, anim->frac); + rwdata->unk30 = modelTweenRotAxis(rwdata->yrot, angle, anim->frac); if (rwdata->unk18 == 0) { rwdata->unk20 = rwdata->unk30 + sp84; @@ -1881,7 +1899,7 @@ void modelSetAnimationWithMerge(struct model *model, s16 animnum, u32 flip, f32 modelCopyAnimForMerge(model, timemerge); } - model0001d62c(model, animnum, flip, startframe, speed, timemerge); + modelSetAnimation2(model, animnum, flip, startframe, speed, timemerge); } } @@ -1895,7 +1913,7 @@ void modelSetAnimation(struct model *model, s16 animnum, s32 flip, f32 startfram } modelCopyAnimForMerge(model, merge); - model0001d62c(model, animnum, flip, startframe, speed, merge); + modelSetAnimation2(model, animnum, flip, startframe, speed, merge); } } @@ -2004,79 +2022,79 @@ void modelSetAnim70(struct model *model, void *callback) } } -void model0001e018(struct model *model, f32 arg1) +void modelSetAnimFrame(struct model *model, f32 frame) { - s32 sp28; - s32 sp24; - bool sp20; + s32 framea; + s32 frameb; + bool forwards; struct anim *anim = model->anim; if (anim) { - sp28 = floor(arg1); - sp20 = anim->speed >= 0; + framea = floor(frame); + forwards = anim->speed >= 0; - sp24 = (sp20 ? sp28 + 1 : sp28 - 1); + frameb = (forwards ? framea + 1 : framea - 1); - anim->framea = modelConstrainOrWrapAnimFrame(sp28, anim->animnum, anim->endframe); - anim->frameb = modelConstrainOrWrapAnimFrame(sp24, anim->animnum, anim->endframe); + anim->framea = modelConstrainOrWrapAnimFrame(framea, anim->animnum, anim->endframe); + anim->frameb = modelConstrainOrWrapAnimFrame(frameb, anim->animnum, anim->endframe); if (anim->framea == anim->frameb) { anim->frac = 0; anim->frame = anim->framea; - } else if (sp20) { - anim->frac = arg1 - sp28; + } else if (forwards) { + anim->frac = frame - framea; anim->frame = anim->framea + anim->frac; } else { - anim->frac = 1 - (arg1 - sp24); + anim->frac = 1 - (frame - frameb); anim->frame = anim->frameb + (1 - anim->frac); } } } -void model0001e14c(struct model *model, f32 arg1, f32 arg2) +void modelSetAnimFrame2(struct model *model, f32 frame1, f32 frame2) { struct anim *anim = model->anim; if (anim) { - model0001e018(model, arg1); + modelSetAnimFrame(model, frame1); if (anim->animnum2) { - s32 sp28 = floor(arg2); - s32 sp24; - bool sp20 = anim->speed2 >= 0; + s32 framea = floor(frame2); + s32 frameb; + bool forwards = anim->speed2 >= 0; - sp24 = (sp20 ? sp28 + 1 : sp28 - 1); + frameb = (forwards ? framea + 1 : framea - 1); - anim->frame2a = modelConstrainOrWrapAnimFrame(sp28, anim->animnum2, anim->endframe2); - anim->frame2b = modelConstrainOrWrapAnimFrame(sp24, anim->animnum2, anim->endframe2); + anim->frame2a = modelConstrainOrWrapAnimFrame(framea, anim->animnum2, anim->endframe2); + anim->frame2b = modelConstrainOrWrapAnimFrame(frameb, anim->animnum2, anim->endframe2); if (anim->frame2a == anim->frame2b) { anim->frac2 = 0; anim->frame2 = anim->frame2a; - } else if (sp20) { - anim->frac2 = arg2 - sp28; + } else if (forwards) { + anim->frac2 = frame2 - framea; anim->frame2 = anim->frame2a + anim->frac2; } else { - anim->frac2 = 1 - (arg2 - sp24); + anim->frac2 = 1 - (frame2 - frameb); anim->frame2 = anim->frame2b + (1 - anim->frac2); } } } } -bool var8005efdc = true; +bool g_ModelAnimMergingEnabled = true; -void model0001e29c(bool value) +void modelSetAnimMergingEnabled(bool value) { - var8005efdc = value; + g_ModelAnimMergingEnabled = value; } -bool model0001e2a8(void) +bool modelIsAnimMergingEnabled(void) { - return var8005efdc; + return g_ModelAnimMergingEnabled; } -void model0001e2b4(struct model *model, f32 curframe, f32 endframe, f32 curframe2, f32 endframe2) +void modelSetAnimFrame2WithChrStuff(struct model *model, f32 curframe, f32 endframe, f32 curframe2, f32 endframe2) { struct anim *anim = model->anim; @@ -2245,8 +2263,8 @@ void model0001e2b4(struct model *model, f32 curframe, f32 endframe, f32 curframe spfc.y = rwdata->pos.y - rwdata->ground; } - cosine = cosf(rwdata->unk14); - sine = sinf(rwdata->unk14); + cosine = cosf(rwdata->yrot); + sine = sinf(rwdata->yrot); spe0.x += spfc.x * cosine + spfc.z * sine; spe0.y = spfc.y; @@ -2297,7 +2315,7 @@ void model0001e2b4(struct model *model, f32 curframe, f32 endframe, f32 curframe cosine = cosf(rwdata->unk30); sine = sinf(rwdata->unk30); - if (var8005efdc && anim->animnum2) { + if (g_ModelAnimMergingEnabled && anim->animnum2) { spd0.x = spfc.x * cosine + spfc.f[2] * sine; spd0.z = -spfc.x * sine + spfc.f[2] * cosine; @@ -2425,15 +2443,15 @@ void model0001e2b4(struct model *model, f32 curframe, f32 endframe, f32 curframe rwdata->unk02 = 0; } } else { - model0001e14c(model, endframe, endframe2); + modelSetAnimFrame2(model, endframe, endframe2); } } else { - model0001e14c(model, endframe, endframe2); + modelSetAnimFrame2(model, endframe, endframe2); } } } -void model0001ee18(struct model *model, s32 lvupdate240, bool arg2) +void modelTickAnimQuarterSpeed(struct model *model, s32 lvupdate240, bool arg2) { f32 frame; f32 frame2; @@ -2532,9 +2550,9 @@ void model0001ee18(struct model *model, s32 lvupdate240, bool arg2) f32 prevelapsespeed = anim->elapsespeed; if (arg2) { - model0001e2b4(model, anim->frame, endframe, 0, 0); + modelSetAnimFrame2WithChrStuff(model, anim->frame, endframe, 0, 0); } else { - model0001e14c(model, endframe, 0); + modelSetAnimFrame2(model, endframe, 0); } modelSetAnimation(model, anim->animnum, anim->flip, startframe, anim->speed, anim->loopmerge); @@ -2559,15 +2577,15 @@ void model0001ee18(struct model *model, s32 lvupdate240, bool arg2) if (arg2) { if (anim->animnum2) { - model0001e2b4(model, anim->frame, frame, anim->frame2, frame2); + modelSetAnimFrame2WithChrStuff(model, anim->frame, frame, anim->frame2, frame2); } else { - model0001e2b4(model, anim->frame, frame, 0, 0); + modelSetAnimFrame2WithChrStuff(model, anim->frame, frame, 0, 0); } } else { if (anim->animnum2) { - model0001e14c(model, frame, frame2); + modelSetAnimFrame2(model, frame, frame2); } else { - model0001e14c(model, frame, 0); + modelSetAnimFrame2(model, frame, 0); } } } @@ -2577,7 +2595,7 @@ void model0001ee18(struct model *model, s32 lvupdate240, bool arg2) /** * This is identical to the above function but removes the 0.25f multipliers. */ -void model0001f314(struct model *model, s32 lvupdate240, bool arg2) +void modelTickAnim(struct model *model, s32 lvupdate240, bool arg2) { f32 frame; f32 frame2; @@ -2676,9 +2694,9 @@ void model0001f314(struct model *model, s32 lvupdate240, bool arg2) f32 prevelapsespeed = anim->elapsespeed; if (arg2) { - model0001e2b4(model, anim->frame, endframe, 0, 0); + modelSetAnimFrame2WithChrStuff(model, anim->frame, endframe, 0, 0); } else { - model0001e14c(model, endframe, 0); + modelSetAnimFrame2(model, endframe, 0); } modelSetAnimation(model, anim->animnum, anim->flip, startframe, anim->speed, anim->loopmerge); @@ -2703,22 +2721,22 @@ void model0001f314(struct model *model, s32 lvupdate240, bool arg2) if (arg2) { if (anim->animnum2) { - model0001e2b4(model, anim->frame, frame, anim->frame2, frame2); + modelSetAnimFrame2WithChrStuff(model, anim->frame, frame, anim->frame2, frame2); } else { - model0001e2b4(model, anim->frame, frame, 0, 0); + modelSetAnimFrame2WithChrStuff(model, anim->frame, frame, 0, 0); } } else { if (anim->animnum2) { - model0001e14c(model, frame, frame2); + modelSetAnimFrame2(model, frame, frame2); } else { - model0001e14c(model, frame, 0); + modelSetAnimFrame2(model, frame, 0); } } } } #endif -void model0001f7e0(struct modelrenderdata *renderdata) +void modelApplyRenderModeType1(struct modelrenderdata *renderdata) { gDPPipeSync(renderdata->gdl++); gDPSetCycleType(renderdata->gdl++, G_CYC_1CYCLE); @@ -2732,7 +2750,7 @@ void model0001f7e0(struct modelrenderdata *renderdata) gDPSetCombineMode(renderdata->gdl++, G_CC_MODULATEIA, G_CC_MODULATEIA); } -void model0001f890(struct modelrenderdata *renderdata, bool arg1) +void modelApplyRenderModeType3(struct modelrenderdata *renderdata, bool arg1) { if (renderdata->unk30 == 7) { if (arg1) { @@ -2890,7 +2908,7 @@ void model0001f890(struct modelrenderdata *renderdata, bool arg1) } } -void model00020248(struct modelrenderdata *renderdata, bool arg1) +void modelApplyRenderModeType4(struct modelrenderdata *renderdata, bool arg1) { if (renderdata->unk30 == 7) { gDPPipeSync(renderdata->gdl++); @@ -3045,7 +3063,7 @@ void model00020248(struct modelrenderdata *renderdata, bool arg1) } } -void model00020bdc(struct modelrenderdata *renderdata) +void modelApplyRenderModeType2(struct modelrenderdata *renderdata) { gDPPipeSync(renderdata->gdl++); gDPSetCycleType(renderdata->gdl++, G_CYC_2CYCLE); @@ -3078,7 +3096,7 @@ void modelRenderNodeGundl(struct modelrenderdata *renderdata, struct model *mode return; } - if ((renderdata->flags & 1) && rodata->primary) { + if ((renderdata->flags & MODELRENDERFLAG_OPA) && rodata->opagdl) { gSPSegment(renderdata->gdl++, SPSEGMENT_MODEL_COL1, osVirtualToPhysical(rodata->baseaddr)); if (renderdata->cullmode) { @@ -3087,38 +3105,38 @@ void modelRenderNodeGundl(struct modelrenderdata *renderdata, struct model *mode switch (rodata->unk12) { case 1: - model0001f7e0(renderdata); + modelApplyRenderModeType1(renderdata); break; case 3: - model0001f890(renderdata, true); + modelApplyRenderModeType3(renderdata, true); break; case 4: - model00020248(renderdata, true); + modelApplyRenderModeType4(renderdata, true); break; case 2: - model00020bdc(renderdata); + modelApplyRenderModeType2(renderdata); break; } - gSPDisplayList(renderdata->gdl++, rodata->primary); + gSPDisplayList(renderdata->gdl++, rodata->opagdl); - if (rodata->unk12 == 3 && rodata->secondary) { - model0001f890(renderdata, false); + if (rodata->unk12 == 3 && rodata->xlugdl) { + modelApplyRenderModeType3(renderdata, false); - gSPDisplayList(renderdata->gdl++, rodata->secondary); + gSPDisplayList(renderdata->gdl++, rodata->xlugdl); } } - if ((renderdata->flags & 2) && rodata->primary && rodata->unk12 == 4 && rodata->secondary) { + if ((renderdata->flags & MODELRENDERFLAG_XLU) && rodata->opagdl && rodata->unk12 == 4 && rodata->xlugdl) { gSPSegment(renderdata->gdl++, SPSEGMENT_MODEL_COL1, osVirtualToPhysical(rodata->baseaddr)); if (renderdata->cullmode) { modelApplyCullMode(renderdata); } - model00020248(renderdata, false); + modelApplyRenderModeType4(renderdata, false); - gSPDisplayList(renderdata->gdl++, rodata->secondary); + gSPDisplayList(renderdata->gdl++, rodata->xlugdl); } } @@ -3130,7 +3148,7 @@ void modelRenderNodeDl(struct modelrenderdata *renderdata, struct model *model, return; } - if (renderdata->flags & 1) { + if (renderdata->flags & MODELRENDERFLAG_OPA) { union modelrwdata *rwdata = modelGetNodeRwData(model, node); if (rwdata->dl.gdl) { @@ -3142,16 +3160,16 @@ void modelRenderNodeDl(struct modelrenderdata *renderdata, struct model *model, switch (rodata->dl.mcount) { case 1: - model0001f7e0(renderdata); + modelApplyRenderModeType1(renderdata); break; case 3: - model0001f890(renderdata, true); + modelApplyRenderModeType3(renderdata, true); break; case 4: - model00020248(renderdata, true); + modelApplyRenderModeType4(renderdata, true); break; case 2: - model00020bdc(renderdata); + modelApplyRenderModeType2(renderdata); break; } @@ -3160,18 +3178,18 @@ void modelRenderNodeDl(struct modelrenderdata *renderdata, struct model *model, gSPDisplayList(renderdata->gdl++, rwdata->dl.gdl); - if (rodata->dl.mcount == 3 && rodata->dl.secondary) { - model0001f890(renderdata, false); + if (rodata->dl.mcount == 3 && rodata->dl.xlugdl) { + modelApplyRenderModeType3(renderdata, false); - gSPDisplayList(renderdata->gdl++, rodata->dl.secondary); + gSPDisplayList(renderdata->gdl++, rodata->dl.xlugdl); } } } - if (renderdata->flags & 2) { + if (renderdata->flags & MODELRENDERFLAG_XLU) { union modelrwdata *rwdata = modelGetNodeRwData(model, node); - if (rwdata->dl.gdl && rodata->dl.mcount == 4 && rodata->dl.secondary) { + if (rwdata->dl.gdl && rodata->dl.mcount == 4 && rodata->dl.xlugdl) { gSPSegment(renderdata->gdl++, SPSEGMENT_MODEL_COL1, osVirtualToPhysical(rodata->dl.colourtable)); if (renderdata->cullmode) { @@ -3181,9 +3199,9 @@ void modelRenderNodeDl(struct modelrenderdata *renderdata, struct model *model, gSPSegment(renderdata->gdl++, SPSEGMENT_MODEL_VTX, osVirtualToPhysical(rwdata->dl.vertices)); gSPSegment(renderdata->gdl++, SPSEGMENT_MODEL_COL2, osVirtualToPhysical(rwdata->dl.colours)); - model00020248(renderdata, false); + modelApplyRenderModeType4(renderdata, false); - gSPDisplayList(renderdata->gdl++, rodata->dl.secondary); + gSPDisplayList(renderdata->gdl++, rodata->dl.xlugdl); } } } @@ -3201,7 +3219,7 @@ void modelRenderNodeDl(struct modelrenderdata *renderdata, struct model *model, */ void modelRenderNodeStarGunfire(struct modelrenderdata *renderdata, struct modelnode *node) { - if (renderdata->flags & 2) { + if (renderdata->flags & MODELRENDERFLAG_XLU) { struct modelrodata_stargunfire *rodata = &node->rodata->stargunfire; s32 i; @@ -3263,7 +3281,7 @@ void modelRenderNodeStarGunfire(struct modelrenderdata *renderdata, struct model } } -void model000216cc(struct modelrenderdata *renderdata, struct textureconfig *tconfig, s32 arg2) +void modelSelectTexture(struct modelrenderdata *renderdata, struct textureconfig *tconfig, s32 arg2) { texSelect(&renderdata->gdl, tconfig, arg2, renderdata->zbufferenabled, 2, 1, NULL); } @@ -3300,8 +3318,8 @@ void modelRenderNodeChrGunfire(struct modelrenderdata *renderdata, struct model struct colour *colours; f32 distance; - if ((renderdata->flags & 2) && rwdata->chrgunfire.visible) { - s32 index = model0001a524(node, 0); + if ((renderdata->flags & MODELRENDERFLAG_XLU) && rwdata->chrgunfire.visible) { + s32 index = modelFindNodeMtxIndex(node, 0); mtx = &model->matrices[index]; spe0.x = -(rodata->pos.f[0] * mtx->m[0][0] + rodata->pos.f[1] * mtx->m[1][0] + rodata->pos.f[2] * mtx->m[2][0] + mtx->m[3][0]); @@ -3405,9 +3423,9 @@ void modelRenderNodeChrGunfire(struct modelrenderdata *renderdata, struct model vertices[3].s = centre - sp58; vertices[3].t = centre + sp5c; - model000216cc(renderdata, tconfig, 4); + modelSelectTexture(renderdata, tconfig, 4); } else { - model000216cc(renderdata, NULL, 1); + modelSelectTexture(renderdata, NULL, 1); } gSPSetGeometryMode(renderdata->gdl++, G_CULL_BACK); @@ -3448,8 +3466,8 @@ void modelRender(struct modelrenderdata *renderdata, struct model *model) case MODELNODETYPE_HEADSPOT: rwdata = modelGetNodeRwData(model, node); - if (rwdata->headspot.modelfiledata) { - struct modelnode *loopnode = rwdata->headspot.modelfiledata->rootnode; + if (rwdata->headspot.headmodeldef) { + struct modelnode *loopnode = rwdata->headspot.headmodeldef->rootnode; node->child = loopnode; while (loopnode) { @@ -3459,7 +3477,7 @@ void modelRender(struct modelrenderdata *renderdata, struct model *model) } break; case MODELNODETYPE_REORDER: - modelRenderNodeReorder(model, node); + modelApplyReorderRelations(model, node); break; case MODELNODETYPE_CHRGUNFIRE: modelRenderNodeChrGunfire(renderdata, model, node); @@ -3493,7 +3511,7 @@ void modelRender(struct modelrenderdata *renderdata, struct model *model) } } -bool model000220fc(struct modelrodata_bbox *bbox, Mtxf *mtx, struct coord *arg2, struct coord *arg3) +bool modelTestBboxNodeForHit(struct modelrodata_bbox *bbox, Mtxf *mtx, struct coord *arg2, struct coord *arg3) { f32 xthingx; f32 xthingy; @@ -3680,7 +3698,12 @@ bool model000220fc(struct modelrodata_bbox *bbox, Mtxf *mtx, struct coord *arg2, return true; } -s32 model000225d4(struct model *model, struct coord *arg1, struct coord *arg2, struct modelnode **startnode) +/** + * Note that this only checks bbox nodes. + * This is okay for most objects as well as shielded chrs. + * For non-shielded chrs, an accurate polygon test is done elsewhere. + */ +s32 modelTestForHit(struct model *model, struct coord *arg1, struct coord *arg2, struct modelnode **startnode) { struct modelnode *node; bool dochildren = true; @@ -3722,9 +3745,9 @@ s32 model000225d4(struct model *model, struct coord *arg1, struct coord *arg2, s switch (type) { case MODELNODETYPE_BBOX: rodata = node->rodata; - mtx = model0001a5cc(model, node, 0); + mtx = modelFindNodeMtx(model, node, 0); - if (model000220fc(&rodata->bbox, mtx, arg1, arg2)) { + if (modelTestBboxNodeForHit(&rodata->bbox, mtx, arg1, arg2)) { *startnode = node; return rodata->bbox.hitpart; } @@ -3744,8 +3767,8 @@ s32 model000225d4(struct model *model, struct coord *arg1, struct coord *arg2, s case MODELNODETYPE_HEADSPOT: rwdata = modelGetNodeRwData(model, node); - if (rwdata->headspot.modelfiledata) { - struct modelnode *loopnode = rwdata->headspot.modelfiledata->rootnode; + if (rwdata->headspot.headmodeldef) { + struct modelnode *loopnode = rwdata->headspot.headmodeldef->rootnode; node->child = loopnode; @@ -3944,7 +3967,7 @@ s32 modelCalculateRwDataIndexes(struct modelnode *basenode) rodata = node->rodata; rodata->reorder.rwdataindex = len; len += sizeof(struct modelrwdata_reorder) / 4; - model0001c868(node, false); + modelApplyReorderRelationsByArg(node, false); break; case MODELNODETYPE_0B: rodata = node->rodata; @@ -3987,7 +4010,7 @@ s32 modelCalculateRwDataIndexes(struct modelnode *basenode) return len; } -void modelCalculateRwDataLen(struct modelfiledata *filedata) +void modelAllocateRwData(struct modelfiledata *filedata) { filedata->rwdatalen = modelCalculateRwDataIndexes(filedata->rootnode); } @@ -4010,7 +4033,7 @@ void modelInitRwData(struct model *model, struct modelnode *startnode) rwdata->chrinfo.pos.x = 0; rwdata->chrinfo.pos.y = 0; rwdata->chrinfo.pos.z = 0; - rwdata->chrinfo.unk14 = 0; + rwdata->chrinfo.yrot = 0; rwdata->chrinfo.unk18 = 0; rwdata->chrinfo.unk1c = 0; @@ -4047,13 +4070,13 @@ void modelInitRwData(struct model *model, struct modelnode *startnode) break; case MODELNODETYPE_HEADSPOT: rwdata = modelGetNodeRwData(model, node); - rwdata->headspot.modelfiledata = NULL; + rwdata->headspot.headmodeldef = NULL; rwdata->headspot.rwdatas = NULL; break; case MODELNODETYPE_REORDER: rwdata = modelGetNodeRwData(model, node); - rwdata->reorder.visible = false; - modelRenderNodeReorder(model, node); + rwdata->reorder.reverse = false; + modelApplyReorderRelations(model, node); break; case MODELNODETYPE_0B: rwdata = modelGetNodeRwData(model, node); @@ -4067,7 +4090,7 @@ void modelInitRwData(struct model *model, struct modelnode *startnode) rodata = node->rodata; rwdata = modelGetNodeRwData(model, node); rwdata->dl.vertices = rodata->dl.vertices; - rwdata->dl.gdl = rodata->dl.primary; + rwdata->dl.gdl = rodata->dl.opagdl; rwdata->dl.colours = (void *) ALIGN8((u32)(rodata->dl.vertices + rodata->dl.numvertices)); if (rodata->dl.numvertices); if (rodata->dl.numvertices); @@ -4170,24 +4193,24 @@ void animInit(struct anim *anim) anim->animscale = 1; } -void model00023108(struct model *pmodel, struct modelfiledata *pmodeldef, struct modelnode *pnode, struct modelfiledata *cmodeldef) +void modelAttachHead(struct model *bodymode, struct modelfiledata *bodymodeldef, struct modelnode *headspotnode, struct modelfiledata *headmodeldef) { - struct modelrwdata_headspot *rwdata = modelGetNodeRwData(pmodel, pnode); + struct modelrwdata_headspot *rwdata = modelGetNodeRwData(bodymode, headspotnode); struct modelnode *node; - rwdata->modelfiledata = cmodeldef; - rwdata->rwdatas = &pmodel->rwdatas[pmodeldef->rwdatalen]; + rwdata->headmodeldef = headmodeldef; + rwdata->rwdatas = &bodymode->rwdatas[bodymodeldef->rwdatalen]; - pnode->child = cmodeldef->rootnode; + headspotnode->child = headmodeldef->rootnode; - node = pnode->child; + node = headspotnode->child; while (node) { - node->parent = pnode; + node->parent = headspotnode; node = node->next; } - pmodeldef->rwdatalen += modelCalculateRwDataIndexes(pnode->child); + bodymodeldef->rwdatalen += modelCalculateRwDataIndexes(headspotnode->child); } /** @@ -4220,18 +4243,18 @@ void modelIterateDisplayLists(struct modelfiledata *filedata, struct modelnode * rodata = node->rodata; if (node != *nodeptr) { - gdl = rodata->gundl.primary; - } else if (rodata->gundl.secondary != *gdlptr) { - gdl = rodata->gundl.secondary; + gdl = rodata->gundl.opagdl; + } else if (rodata->gundl.xlugdl != *gdlptr) { + gdl = rodata->gundl.xlugdl; } break; case MODELNODETYPE_DL: rodata = node->rodata; if (node != *nodeptr) { - gdl = rodata->dl.primary; - } else if (rodata->dl.secondary != *gdlptr) { - gdl = rodata->dl.secondary; + gdl = rodata->dl.opagdl; + } else if (rodata->dl.xlugdl != *gdlptr) { + gdl = rodata->dl.xlugdl; } break; case MODELNODETYPE_STARGUNFIRE: @@ -4250,7 +4273,7 @@ void modelIterateDisplayLists(struct modelfiledata *filedata, struct modelnode * node->child = rodata->toggle.target; break; case MODELNODETYPE_REORDER: - model0001c868(node, true); + modelApplyReorderRelationsByArg(node, true); break; } @@ -4285,26 +4308,26 @@ void modelNodeReplaceGdl(struct modelfiledata *modeldef, struct modelnode *node, case MODELNODETYPE_GUNDL: rodata = node->rodata; - if (rodata->gundl.primary == find) { - rodata->gundl.primary = replacement; + if (rodata->gundl.opagdl == find) { + rodata->gundl.opagdl = replacement; return; } - if (rodata->gundl.secondary == find) { - rodata->gundl.secondary = replacement; + if (rodata->gundl.xlugdl == find) { + rodata->gundl.xlugdl = replacement; return; } break; case MODELNODETYPE_DL: rodata = node->rodata; - if (rodata->dl.primary == find) { - rodata->dl.primary = replacement; + if (rodata->dl.opagdl == find) { + rodata->dl.opagdl = replacement; return; } - if (rodata->dl.secondary == find) { - rodata->dl.secondary = replacement; + if (rodata->dl.xlugdl == find) { + rodata->dl.xlugdl = replacement; return; } break;