Skip to content

Commit

Permalink
Workaround child y pos + Skip posing on console
Browse files Browse the repository at this point in the history
  • Loading branch information
Kewlan committed Apr 6, 2024
1 parent d70b31b commit 58d3782
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
20 changes: 13 additions & 7 deletions code/src/actors/link_puppet.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ ActorInit EnLinkPuppet_InitVars = {
EnLinkPuppet_Draw, //
};

// When posing the model by copying the joint table, the model for some reason gets raised about 12 units.
u32 ChildYPosOffset() {
return playingOnCitra ? 12 : 0;
}

typedef void (*SkelAnime_InitLink_proc)(SkelAnime* skelAnime, ZARInfo* zarInfo, GlobalContext* globalCtx, void* cmbMan,
void* param_5, u32 animation, s32 limbBufCount, void* jointTable,
void* morphTable);
Expand Down Expand Up @@ -82,7 +87,13 @@ void EnLinkPuppet_Update(Actor* thisx, GlobalContext* globalCtx) {
Model_DisableMeshGroupByIndex(this->skelAnime.unk_28, index + BIT_COUNT(u32));
}
}
memcpy(this->skelAnime.jointTable, this->ghostPtr->ghostData.jointTable, sizeof(Vec3s[LINK_JOINT_COUNT]));
if (playingOnCitra) {
memcpy(this->skelAnime.jointTable, this->ghostPtr->ghostData.jointTable, sizeof(Vec3s[LINK_JOINT_COUNT]));
}

if (this->ghostPtr->ghostData.age != 0) {
this->base.world.pos.y -= ChildYPosOffset();
}
}

typedef void (*SkelAnime_DrawOpa_proc)(SkelAnime* skelAnime, nn_math_MTX34* modelMtx, u32* overrideLimbDraw,
Expand Down Expand Up @@ -128,14 +139,9 @@ void EnLinkPuppet_Draw(Actor* thisx, GlobalContext* globalCtx) {
s16 envB = 100 * colorB[(this->base.params - 1) % ARRAY_SIZE(colorB)];

Vec3f spawnPos = this->base.world.pos;
spawnPos.y += (this->ghostPtr->ghostData.age == 0 ? 50 : 35);
spawnPos.y += (this->ghostPtr->ghostData.age == 0 ? 50 : (35 + ChildYPosOffset()));
EffectSsDeadDb_Spawn(gGlobalContext, &spawnPos, &vecEmpty, &vecEmpty,
this->ghostPtr->ghostData.age == 0 ? 100 : 70, -1, 80, 80, 80, 0xFF, envR, envG, envB, 1,
8, 0);
}
}

// Returns the ID of the puppet, starting at 0!
u16 EnLinkPuppet_GetID(EnLinkPuppet* this) {
return this->base.params & 0xFF;
}
14 changes: 12 additions & 2 deletions code/src/multiplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,17 +922,27 @@ void Multiplayer_Send_GhostData(void) {
ghostData.meshGroups1 |= 0x7000000;
}

memcpy(&ghostData.jointTable, PLAYER->skelAnime.jointTable, sizeof(Vec3s[LINK_JOINT_COUNT]));
if (playingOnCitra) {
memcpy(&ghostData.jointTable, PLAYER->skelAnime.jointTable, sizeof(Vec3s[LINK_JOINT_COUNT]));
}

memcpy(&mBuffer[memSpacer], &ghostData, sizeof(GhostData));
memSpacer += sizeof(GhostData) / 4;

if (!playingOnCitra) {
memSpacer -= sizeof(Vec3s[LINK_JOINT_COUNT]) / 4;
}

Multiplayer_SendPacket(memSpacer, UDS_BROADCAST_NETWORKNODEID);
}

void Multiplayer_Receive_GhostData(u16 senderID) {
GhostData ghostData;
memcpy(&ghostData, &mBuffer[1], sizeof(GhostData));
u32 packetSize = sizeof(GhostData);
if (!playingOnCitra) {
packetSize -= sizeof(Vec3s[LINK_JOINT_COUNT]);
}
memcpy(&ghostData, &mBuffer[1], packetSize);

Multiplayer_Ghosts_UpdateGhostData(senderID, &ghostData);
}
Expand Down
2 changes: 1 addition & 1 deletion code/src/multiplayer_ghosts.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef struct {
// Animation vars here
u32 meshGroups1;
u32 meshGroups2;
Vec3s jointTable[LINK_JOINT_COUNT];
Vec3s jointTable[LINK_JOINT_COUNT]; // ALWAYS KEEP LAST
} GhostData;

typedef struct {
Expand Down

0 comments on commit 58d3782

Please sign in to comment.