Skip to content

Commit

Permalink
update twinmold effect tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez committed Nov 29, 2024
1 parent e7bd18a commit 8fb1868
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
22 changes: 9 additions & 13 deletions mm/src/overlays/actors/ovl_Boss_02/z_boss_02.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ void Boss02_SpawnEffectSand(TwinmoldEffect* effects, Vec3f* pos, f32 scale) {
effects->timer = 0;
effects->targetScale = 2.0f * scale;
effects->accel.x = effects->accel.z = 0.0f;
effects->justSpawned = true;
effects->epoch++;
break;
}
}
Expand All @@ -557,7 +557,7 @@ void Boss02_SpawnEffectFragment(TwinmoldEffect* effects, Vec3f* pos) {
effects->scale = Rand_ZeroFloat(0.04f) + 0.02f;
effects->rotY = Rand_ZeroFloat(32767.0f);
effects->rotX = Rand_ZeroFloat(32767.0f);
effects->justSpawned = true;
effects->epoch++;
break;
}
}
Expand All @@ -574,7 +574,7 @@ void Boss02_SpawnEffectFlash(TwinmoldEffect* effects, Vec3f* pos) {
Math_Vec3f_Copy(&effects->accel, &gZeroVec3f);
effects->alpha = 255;
effects->scale = 0.0f;
effects->justSpawned = true;
effects->epoch++;
break;
}
}
Expand Down Expand Up @@ -1573,10 +1573,9 @@ void Boss02_DrawEffects(PlayState* play) {

for (i = 0; i < TWINMOLD_EFFECT_COUNT; i++, effect++) {
if (effect->type == TWINMOLD_EFFECT_SAND) {
// Here and below, set a highbit for effects that just spawned to skip interoplating from an old effect
FrameInterpolation_RecordOpenChild(effect, effect->type | (effect->justSpawned ? (1 << 30) : 0));
// Here and below, key by effect type merged with epoch
FrameInterpolation_RecordOpenChild(effect, (effect->epoch << 4) | effect->type);
FrameInterpolation_IgnoreActorMtx();
effect->justSpawned = false;
if (!flag) {
gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL);
gDPSetEnvColor(POLY_XLU_DISP++, 185, 140, 70, 128);
Expand Down Expand Up @@ -1607,9 +1606,8 @@ void Boss02_DrawEffects(PlayState* play) {
effect = (TwinmoldEffect*)play->specialEffects;
for (i = 0, flag = false; i < TWINMOLD_EFFECT_COUNT; i++, effect++) {
if (effect->type == TWINMOLD_EFFECT_FRAGMENT) {
FrameInterpolation_RecordOpenChild(effect, effect->type | (effect->justSpawned ? (1 << 30) : 0));
FrameInterpolation_RecordOpenChild(effect, (effect->epoch << 4) | effect->type);
FrameInterpolation_IgnoreActorMtx();
effect->justSpawned = false;
if (!flag) {
gDPSetCombineLERP(POLY_OPA_DISP++, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE,
0, SHADE, 0, PRIMITIVE, 0);
Expand All @@ -1632,9 +1630,8 @@ void Boss02_DrawEffects(PlayState* play) {
effect = (TwinmoldEffect*)play->specialEffects;
for (i = 0, flag = false; i < TWINMOLD_EFFECT_COUNT; i++, effect++) {
if (effect->type == TWINMOLD_EFFECT_FLASH) {
FrameInterpolation_RecordOpenChild(effect, effect->type | (effect->justSpawned ? (1 << 30) : 0));
FrameInterpolation_RecordOpenChild(effect, (effect->epoch << 4) | effect->type);
FrameInterpolation_IgnoreActorMtx();
effect->justSpawned = false;
if (!flag) { //! @bug - dev forgot to set flag to 1, should only apply to first entry?
gSPDisplayList(POLY_XLU_DISP++, gLightOrbMaterial1DL);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128);
Expand All @@ -1656,9 +1653,8 @@ void Boss02_DrawEffects(PlayState* play) {
effect = (TwinmoldEffect*)play->specialEffects;
for (i = 0, flag = false; i < TWINMOLD_EFFECT_COUNT; i++, effect++) {
if (effect->type == TWINMOLD_EFFECT_BLACK_DUST) {
FrameInterpolation_RecordOpenChild(effect, effect->type | (effect->justSpawned ? (1 << 30) : 0));
FrameInterpolation_RecordOpenChild(effect, (effect->epoch << 4) | effect->type);
FrameInterpolation_IgnoreActorMtx();
effect->justSpawned = false;
if (!flag) {
gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL);
gDPSetEnvColor(POLY_XLU_DISP++, 30, 30, 30, 128);
Expand Down Expand Up @@ -2365,6 +2361,6 @@ void Boss02_Reset(void) {

for (int i = 0; i < TWINMOLD_EFFECT_COUNT; i++) {
sTwinmoldEffects[i].type = TWINMOLD_EFFECT_NONE;
sTwinmoldEffects[i].justSpawned = false;
sTwinmoldEffects[i].epoch = 0;
}
}
2 changes: 1 addition & 1 deletion mm/src/overlays/actors/ovl_Boss_02/z_boss_02.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef struct {
/* 0x34 */ f32 scale;
/* 0x38 */ f32 targetScale;
// 2S2H [Port]
/* */ u8 justSpawned; // Tracks when an effect is spawned for use with interpolation skipping
/* */ s16 epoch; // Tracks when an effect is spawned for use with interpolation skipping
} TwinmoldEffect; // size = 0x3C

typedef enum {
Expand Down
4 changes: 2 additions & 2 deletions mm/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void EnTanron5_SpawnEffectSand(TwinmoldEffect* effect, Vec3f* pos, f32 scale) {
effect->timer = 0;
effect->scale = scale;
effect->targetScale = 2.0f * scale;
effect->justSpawned = true;
effect->epoch++;
break;
}
}
Expand All @@ -207,7 +207,7 @@ void EnTanron5_SpawnEffectBlackDust(TwinmoldEffect* effect, Vec3f* pos, f32 scal
effect->timer = 0;
effect->scale = scale;
effect->targetScale = 2.0f * scale;
effect->justSpawned = true;
effect->epoch++;
break;
}
}
Expand Down
2 changes: 0 additions & 2 deletions mm/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@ void func_808DD3C8(Actor* thisx, PlayState* play2) {
Matrix_Scale(0.05f + tempf, 0.05f + tempf, 0.05f + tempf, MTXMODE_APPLY);
temp_f2 = Math_Vec3f_DistXYZ(&worldPos, &play->view.eye) / 300.0f;
temp_f2 = ((1.0f < temp_f2) ? 0.0f : (((1.0f - temp_f2) > 1.0f) ? 1.0f : 1.0f - temp_f2));
temp_f2 = 1.59375f;

gDPPipeSync(POLY_XLU_DISP++);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(160.0f * temp_f2));
Expand Down Expand Up @@ -658,7 +657,6 @@ void func_808DD970(Actor* thisx, PlayState* play2) {
Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY);
temp_f0 = Math_Vec3f_DistXYZ(&worldPos, &play->view.eye);
temp_f0 = (u8)(255.0f * phi_f26) * (1.0f - (temp_f0 / 300.0f));
temp_f0 = 255;

gDPPipeSync(POLY_XLU_DISP++);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 55, temp_f0);
Expand Down

0 comments on commit 8fb1868

Please sign in to comment.