diff options
| author | engineer124 <47598039+engineer124@users.noreply.github.com> | 2023-08-15 00:08:45 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-14 10:08:45 -0400 |
| commit | affb1eaf0f037858ab020e6b7fd8d105dff262f8 (patch) | |
| tree | 6fe548aeb9e35caa3f9d3f026402c93038657cc3 /src/code | |
| parent | 05c2221769ffdbbfd774d856bac77b6d7c2413a0 (diff) | |
Body Parts Docs (#1333)
* body parts WIP
* continue WIP
* finish body parts
* cleanup
* missed one
* Missed Enum
* PR Review
* next PR review
* s32 cast
* TRUNCF_BINANG
* rm unnecessary shadow
* PR Review
* missed some
* oops
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/z_actor.c | 98 | ||||
| -rw-r--r-- | src/code/z_camera.c | 2 | ||||
| -rw-r--r-- | src/code/z_en_hy_code.c | 55 | ||||
| -rw-r--r-- | src/code/z_sub_s.c | 2 |
4 files changed, 103 insertions, 54 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c index ef1ca4b48..5debc583d 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4706,20 +4706,20 @@ TexturePtr sElectricSparkTextures[] = { }; /** - * Draw common damage effects applied to each limb provided in limbPos + * Draw common damage effects applied to each body part provided in bodyPartsPos */ -void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, +void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[], s16 bodyPartsCount, f32 effectScale, f32 frozenSteamScale, f32 effectAlpha, u8 type) { if (effectAlpha > 0.001f) { s32 twoTexScrollParam; - s16 limbIndex; + s16 bodyPartIndex; MtxF* currentMatrix; f32 alpha; f32 frozenScale; f32 lightOrbsScale; f32 electricSparksScale; f32 steamScale; - Vec3f* limbPosStart = limbPos; + Vec3f* bodyPartsPosStart = bodyPartsPos; u32 gameplayFrames = play->gameplayFrames; f32 effectAlphaScaled; @@ -4747,7 +4747,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 case ACTOR_DRAW_DMGEFF_FROZEN_SFX: frozenScale = ((KREG(19) * 0.01f) + 2.3f) * effectScale; steamScale = ((KREG(28) * 0.0001f) + 0.035f) * frozenSteamScale; - func_800BCC68(limbPos, play); + func_800BCC68(bodyPartsPos, play); // Setup to draw ice over frozen actor @@ -4759,11 +4759,11 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 effectAlphaScaled = effectAlpha * 255.0f; - // Apply and draw ice over each limb of frozen actor - for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { - alpha = limbIndex & 3; + // Apply and draw ice over each body part of frozen actor + for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) { + alpha = bodyPartIndex & 3; alpha = effectAlphaScaled - (30.0f * alpha); - if (effectAlphaScaled < (30.0f * (limbIndex & 3))) { + if (effectAlphaScaled < (30.0f * (bodyPartIndex & 3))) { alpha = 0.0f; } if (alpha > 255.0f) { @@ -4772,14 +4772,14 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 200, KREG(21) + 200, KREG(22) + 255, (u8)alpha); - Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_Translate(bodyPartsPos->x, bodyPartsPos->y, bodyPartsPos->z, MTXMODE_NEW); Matrix_Scale(frozenScale, frozenScale, frozenScale, MTXMODE_APPLY); - if (limbIndex & 1) { + if (bodyPartIndex & 1) { Matrix_RotateYF(M_PI, MTXMODE_APPLY); } - if (limbIndex & 2) { + if (bodyPartIndex & 2) { Matrix_RotateZF(M_PI, MTXMODE_APPLY); } @@ -4789,7 +4789,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment2ModelDL); } - limbPos = limbPosStart; // reset limbPos + bodyPartsPos = bodyPartsPosStart; // reset bodyPartsPos // Setup to draw steam over frozen actor @@ -4804,14 +4804,14 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)alpha); - // Apply and draw steam over each limb of frozen actor - for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { - twoTexScrollParam = ((limbIndex * 3) + gameplayFrames); + // Apply and draw steam over each body part of frozen actor + for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) { + twoTexScrollParam = ((bodyPartIndex * 3) + gameplayFrames); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, twoTexScrollParam * 3, twoTexScrollParam * -12, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_Translate(bodyPartsPos->x, bodyPartsPos->y, bodyPartsPos->z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY); @@ -4838,11 +4838,11 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 effectAlphaScaled = effectAlpha * 255.0f; - // Apply and draw fire on every limb - for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { - alpha = limbIndex & 3; + // Apply and draw fire on every body part + for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) { + alpha = bodyPartIndex & 3; alpha = effectAlphaScaled - 30.0f * alpha; - if (effectAlphaScaled < 30.0f * (limbIndex & 3)) { + if (effectAlphaScaled < 30.0f * (bodyPartIndex & 3)) { alpha = 0.0f; } if (alpha > 255.0f) { @@ -4856,12 +4856,12 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, - ((limbIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128)); + ((bodyPartIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128)); Matrix_RotateYF(M_PI, MTXMODE_APPLY); - currentMatrix->mf[3][0] = limbPos->x; - currentMatrix->mf[3][1] = limbPos->y; - currentMatrix->mf[3][2] = limbPos->z; + currentMatrix->mf[3][0] = bodyPartsPos->x; + currentMatrix->mf[3][1] = bodyPartsPos->y; + currentMatrix->mf[3][2] = bodyPartsPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4898,12 +4898,12 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 Matrix_Put(&play->billboardMtxF); Matrix_Scale(lightOrbsScale, lightOrbsScale, 1.0f, MTXMODE_APPLY); - // Apply and draw a light orb over each limb of frozen actor - for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + // Apply and draw a light orb over each body part of frozen actor + for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) { Matrix_RotateZF(Rand_CenteredFloat(2 * M_PI), MTXMODE_APPLY); - currentMatrix->mf[3][0] = limbPos->x; - currentMatrix->mf[3][1] = limbPos->y; - currentMatrix->mf[3][2] = limbPos->z; + currentMatrix->mf[3][0] = bodyPartsPos->x; + currentMatrix->mf[3][1] = bodyPartsPos->y; + currentMatrix->mf[3][2] = bodyPartsPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4936,14 +4936,14 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 Matrix_Put(&play->billboardMtxF); Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY); - // Every limb draws two electric sparks at random orientations - for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + // Every body part draws two electric sparks at random orientations + for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) { // first electric spark Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); - currentMatrix->mf[3][0] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->x; - currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->y; - currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->z; + currentMatrix->mf[3][0] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->x; + currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->y; + currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4953,9 +4953,9 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 // second electric spark Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); - currentMatrix->mf[3][0] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->x; - currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->y; - currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->z; + currentMatrix->mf[3][0] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->x; + currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->y; + currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4970,11 +4970,11 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 } } -void Actor_SpawnIceEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, - f32 scale, f32 scaleRange) { - static Color_RGBA8 primColor = { 170, 255, 255, 255 }; - static Color_RGBA8 envColor = { 200, 200, 255, 255 }; - static Vec3f accel = { 0.0f, -1.0f, 0.0f }; +void Actor_SpawnIceEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[], s32 bodyPartsCount, + s32 effectsPerBodyPart, f32 scale, f32 scaleRange) { + static Color_RGBA8 sPrimColor = { 170, 255, 255, 255 }; + static Color_RGBA8 sEnvColor = { 200, 200, 255, 255 }; + static Vec3f sAccel = { 0.0f, -1.0f, 0.0f }; s32 i; s32 pad; Vec3f velocity; @@ -4984,10 +4984,10 @@ void Actor_SpawnIceEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s32 l SoundSource_PlaySfxAtFixedWorldPos(play, &actor->world.pos, 30, NA_SE_EV_ICE_BROKEN); - for (i = 0; i < limbPosCount; i++) { - yaw = Actor_WorldYawTowardPoint(actor, limbPos); + for (i = 0; i < bodyPartsCount; i++) { + yaw = Actor_WorldYawTowardPoint(actor, bodyPartsPos); - for (j = 0; j < effectsPerLimb; j++) { + for (j = 0; j < effectsPerBodyPart; j++) { randomYaw = ((s32)Rand_Next() >> 0x13) + yaw; velocity.z = Rand_ZeroFloat(5.0f); @@ -4996,10 +4996,10 @@ void Actor_SpawnIceEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s32 l velocity.y = Rand_ZeroFloat(4.0f) + 8.0f; velocity.z *= Math_CosS(randomYaw); - EffectSsEnIce_Spawn(play, limbPos, Rand_ZeroFloat(scaleRange) + scale, &velocity, &accel, &primColor, - &envColor, 30); + EffectSsEnIce_Spawn(play, bodyPartsPos, Rand_ZeroFloat(scaleRange) + scale, &velocity, &sAccel, &sPrimColor, + &sEnvColor, 30); } - limbPos++; + bodyPartsPos++; } } diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 3703eda0f..95d2e36f9 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -481,7 +481,7 @@ s32 Camera_GetFocalActorPos(Vec3f* dst, Camera* camera) { Actor* focalActor = camera->focalActor; if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { - *dst = ((Player*)focalActor)->bodyPartsPos[0]; + *dst = ((Player*)focalActor)->bodyPartsPos[PLAYER_BODYPART_WAIST]; return dst; } else { Actor_GetWorldPosShapeRot(&focalPosRot, camera->focalActor); diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index b5992dec4..d59d31000 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -35,11 +35,60 @@ static AnimationInfoS sAnimationInfo[] = { { &object_boj_Anim_005D9C, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, }; -s8 gEnHyBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; +s8 gEnHyLimbToBodyParts[ENHY_LIMB_MAX] = { + BODYPART_NONE, // ENHY_LIMB_NONE + ENHY_BODYPART_1, // ENHY_LIMB_PELVIS + ENHY_BODYPART_12, // ENHY_LIMB_LEFT_THIGH + ENHY_BODYPART_13, // ENHY_LIMB_LEFT_SHIN + ENHY_BODYPART_14, // ENHY_LIMB_LEFT_FOOT + ENHY_BODYPART_9, // ENHY_LIMB_RIGHT_THIGH + ENHY_BODYPART_10, // ENHY_LIMB_RIGHT_SHIN + ENHY_BODYPART_11, // ENHY_LIMB_RIGHT_FOOT + ENHY_BODYPART_0, // ENHY_LIMB_TORSO + ENHY_BODYPART_6, // ENHY_LIMB_LEFT_UPPER_ARM + ENHY_BODYPART_7, // ENHY_LIMB_LEFT_FOREARM + ENHY_BODYPART_8, // ENHY_LIMB_LEFT_HAND + ENHY_BODYPART_3, // ENHY_LIMB_RIGHT_UPPER_ARM + ENHY_BODYPART_4, // ENHY_LIMB_RIGHT_FOREARM + ENHY_BODYPART_5, // ENHY_LIMB_RIGHT_HAND + ENHY_BODYPART_2, // ENHY_LIMB_HEAD +}; -s8 gEnHyParentBodyParts[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; +s8 gEnHyParentShadowBodyParts[ENHY_BODYPART_MAX] = { + ENHY_BODYPART_0, // ENHY_BODYPART_0 + ENHY_BODYPART_0, // ENHY_BODYPART_1 + ENHY_BODYPART_0, // ENHY_BODYPART_2 + ENHY_BODYPART_0, // ENHY_BODYPART_3 + ENHY_BODYPART_3, // ENHY_BODYPART_4 + ENHY_BODYPART_4, // ENHY_BODYPART_5 + ENHY_BODYPART_0, // ENHY_BODYPART_6 + ENHY_BODYPART_6, // ENHY_BODYPART_7 + ENHY_BODYPART_7, // ENHY_BODYPART_8 + ENHY_BODYPART_0, // ENHY_BODYPART_9 + ENHY_BODYPART_9, // ENHY_BODYPART_10 + ENHY_BODYPART_10, // ENHY_BODYPART_11 + ENHY_BODYPART_0, // ENHY_BODYPART_12 + ENHY_BODYPART_12, // ENHY_BODYPART_13 + ENHY_BODYPART_13, // ENHY_BODYPART_14 +}; -u8 gEnHyShadowSizes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +u8 gEnHyShadowSizes[ENHY_BODYPART_MAX] = { + 0, // ENHY_BODYPART_0 + 0, // ENHY_BODYPART_1 + 0, // ENHY_BODYPART_2 + 0, // ENHY_BODYPART_3 + 0, // ENHY_BODYPART_4 + 0, // ENHY_BODYPART_5 + 0, // ENHY_BODYPART_6 + 0, // ENHY_BODYPART_7 + 0, // ENHY_BODYPART_8 + 0, // ENHY_BODYPART_9 + 0, // ENHY_BODYPART_10 + 0, // ENHY_BODYPART_11 + 0, // ENHY_BODYPART_12 + 0, // ENHY_BODYPART_13 + 0, // ENHY_BODYPART_14 +}; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 frameCount; diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 4060c3361..427cc85d0 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -974,7 +974,7 @@ void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween s32 startRow; for (i = 0; i < bodyPartsNum; i++) { - if (parentBodyParts[i] >= 0) { + if (parentBodyParts[i] > BODYPART_NONE) { parentBodyPart = parentBodyParts[i]; bodyPartPos = &bodyPartsPos[i]; |
