Interpolation fixes (#167)

* hugebombiwa

* EnHanabi fireworks

* Clear tag - various non ss effects.

* Damage effects - sparks, fire, orbs, etc...
This commit is contained in:
louist103
2024-05-22 09:05:01 -05:00
committed by Garrett Cox
parent 63b6638e11
commit 081577ae65
5 changed files with 53 additions and 15 deletions
+13 -1
View File
@@ -4905,6 +4905,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
Vec3f* bodyPartsPosStart = bodyPartsPos;
u32 gameplayFrames = play->gameplayFrames;
f32 effectAlphaScaled;
static int effectEpoch = 0;
currentMatrix = Matrix_GetCurrent();
@@ -4944,6 +4945,8 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
// Apply and draw ice over each body part of frozen actor
for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) {
// BENTODO is using bodyPartsPos OK here? should actor be used instead?
FrameInterpolation_RecordOpenChild(bodyPartsPos, effectEpoch++);
alpha = bodyPartIndex & 3;
alpha = effectAlphaScaled - (30.0f * alpha);
if (effectAlphaScaled < (30.0f * (bodyPartIndex & 3))) {
@@ -4970,6 +4973,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment2ModelDL);
FrameInterpolation_RecordCloseChild();
}
bodyPartsPos = bodyPartsPosStart; // reset bodyPartsPos
@@ -4989,6 +4993,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
// Apply and draw steam over each body part of frozen actor
for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) {
FrameInterpolation_RecordOpenChild(bodyPartsPos, effectEpoch++);
twoTexScrollParam = ((bodyPartIndex * 3) + gameplayFrames);
gSPSegment(POLY_XLU_DISP++, 0x08,
Gfx_TwoTexScroll(play->state.gfxCtx, 0, twoTexScrollParam * 3, twoTexScrollParam * -12,
@@ -5002,6 +5007,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamModelDL);
FrameInterpolation_RecordCloseChild();
}
break;
@@ -5023,6 +5029,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
// Apply and draw fire on every body part
for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) {
FrameInterpolation_RecordOpenChild(bodyPartsPos, effectEpoch++);
alpha = bodyPartIndex & 3;
alpha = effectAlphaScaled - 30.0f * alpha;
if (effectAlphaScaled < 30.0f * (bodyPartIndex & 3)) {
@@ -5050,6 +5057,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL);
FrameInterpolation_RecordCloseChild();
}
break;
@@ -5083,6 +5091,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
// Apply and draw a light orb over each body part of frozen actor
for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) {
FrameInterpolation_RecordOpenChild(bodyPartsPos, effectEpoch++);
Matrix_RotateZF(Rand_CenteredFloat(2 * M_PI), MTXMODE_APPLY);
currentMatrix->mf[3][0] = bodyPartsPos->x;
currentMatrix->mf[3][1] = bodyPartsPos->y;
@@ -5092,6 +5101,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gLightOrbModelDL);
FrameInterpolation_RecordCloseChild();
}
break;
@@ -5121,6 +5131,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
// Every body part draws two electric sparks at random orientations
for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) {
FrameInterpolation_RecordOpenChild(bodyPartsPos, effectEpoch++);
// first electric spark
Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI));
Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY);
@@ -5144,11 +5155,12 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gElectricSparkModelDL);
FrameInterpolation_RecordCloseChild();
}
break;
}
effectEpoch = 0;
CLOSE_DISPS(play->state.gfxCtx);
}
}
+2 -1
View File
@@ -805,6 +805,7 @@ void EnBom_DrawKeg(PlayState* play, s32 timer) {
Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
// 2S2H [Port] This was originally a static DL in the OTR file. The normal texture is too small to be rendered by Fast3D
// and causes a crash.
// This adds a custom texture in the OTR file and changes the DList to use the new size. At some point this should be
@@ -823,7 +824,7 @@ void EnBom_DrawKeg(PlayState* play, s32 timer) {
temp_s5 = (timer / 240) + 1;
fuseSegmentPtr2 = &sPowderKegFuseSegments[1];
// Bentodo the fuse is not visible enough to see if this is broken. Verify once the long timer crash is fixed.
for (i = 1; i < temp_s5; i++, fuseSegmentPtr2++) {
Matrix_Translate(fuseSegmentPtr2->pos.x, fuseSegmentPtr2->pos.y, fuseSegmentPtr2->pos.z, MTXMODE_NEW);
Matrix_RotateZYX(fuseSegmentPtr2->rotX, fuseSegmentPtr2->rotY, 0, MTXMODE_APPLY);
@@ -6,6 +6,7 @@
#include "z_en_clear_tag.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#include "2s2h/Enhancements/FrameInterpolation/FrameInterpolation.h"
#define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_UNFRIENDLY | ACTOR_FLAG_10 | ACTOR_FLAG_20)
@@ -814,6 +815,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
// Draw all Debris effects.
for (i = 0; i < ARRAY_COUNT(this->effect); i++, effect++) {
if (effect->type == CLEAR_TAG_EFFECT_DEBRIS) {
FrameInterpolation_RecordOpenChild(effect, i);
// Apply the debris effect material if it has not already been applied.
if (!isMaterialApplied) {
isMaterialApplied++;
@@ -827,6 +829,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
Matrix_RotateXFApply(effect->rotationX);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, gClearTagDebrisEffectDL);
FrameInterpolation_RecordCloseChild();
}
}
@@ -835,6 +838,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
if (this->actor.floorPoly != NULL) {
for (i = 0; i < ARRAY_COUNT(this->effect); i++, effect++) {
if (effect->type == CLEAR_TAG_EFFECT_SHOCKWAVE) {
FrameInterpolation_RecordOpenChild(effect, i);
// Draw the shockwave effect.
gDPPipeSync(POLY_XLU_DISP++);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s8)effect->primColor.a);
@@ -844,6 +848,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gEffShockwaveDL);
FrameInterpolation_RecordCloseChild();
}
}
}
@@ -854,6 +859,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
if (this->actor.floorPoly != NULL) {
for (i = 0; i < ARRAY_COUNT(this->effect); i++, effect++) {
if (effect->type == CLEAR_TAG_EFFECT_FLASH) {
FrameInterpolation_RecordOpenChild(effect, i);
// Apply the flash ground effect material if it has not already been applied.
if (!isMaterialApplied) {
gDPPipeSync(POLY_XLU_DISP++);
@@ -868,6 +874,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
Matrix_Scale(effect->scale * 3.0f, 1.0f, effect->scale * 3.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectGroundDL);
FrameInterpolation_RecordCloseChild();
}
}
}
@@ -877,6 +884,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
isMaterialApplied = false;
for (i = 0; i < ARRAY_COUNT(this->effect); i++, effect++) {
if ((effect->type == CLEAR_TAG_EFFECT_SMOKE) || (effect->type == CLEAR_TAG_EFFECT_ISOLATED_SMOKE)) {
FrameInterpolation_RecordOpenChild(effect, i);
// Apply the smoke effect material if it has not already been applied.
if (!isMaterialApplied) {
gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectMaterialDL);
@@ -897,6 +905,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
Matrix_Translate(0.0f, 20.0f, 0.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL);
FrameInterpolation_RecordCloseChild();
}
}
@@ -905,6 +914,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
isMaterialApplied = false;
for (i = 0; i < ARRAY_COUNT(this->effect); i++, effect++) {
if (effect->type == CLEAR_TAG_EFFECT_FIRE) {
FrameInterpolation_RecordOpenChild(effect, i);
// Apply the fire effect material if it has not already been applied.
if (!isMaterialApplied) {
gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectMaterialDL);
@@ -921,6 +931,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL);
FrameInterpolation_RecordCloseChild();
}
}
@@ -929,6 +940,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
isMaterialApplied = false;
for (i = 0; i < ARRAY_COUNT(this->effect); i++, effect++) {
if (effect->type == CLEAR_TAG_EFFECT_FLASH) {
FrameInterpolation_RecordOpenChild(effect, i);
// Apply the flash billboard effect material if it has not already been applied.
if (!isMaterialApplied) {
gDPPipeSync(POLY_XLU_DISP++);
@@ -943,6 +955,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
Matrix_Scale(2.0f * effect->scale, 2.0f * effect->scale, 1.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectDL);
FrameInterpolation_RecordCloseChild();
}
}
@@ -951,6 +964,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
isMaterialApplied = false;
for (i = 0; i < ARRAY_COUNT(this->effect); i++, effect++) {
if (effect->type == CLEAR_TAG_EFFECT_LIGHT_RAYS) {
FrameInterpolation_RecordOpenChild(effect, i);
// Apply the light ray effect material if it has not already been applied.
if (!isMaterialApplied) {
gDPPipeSync(POLY_XLU_DISP++);
@@ -971,6 +985,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
Matrix_RotateXFApply(M_PI / 2);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gClearTagLightRayEffectDL);
FrameInterpolation_RecordCloseChild();
}
}
@@ -978,6 +993,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
effect = firstEffect;
for (i = 0; i < ARRAY_COUNT(this->effect); i++, effect++) {
if (effect->type == CLEAR_TAG_EFFECT_SPLASH) {
FrameInterpolation_RecordOpenChild(effect, i);
gDPPipeSync(POLY_XLU_DISP++);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 200);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 200);
@@ -988,6 +1004,8 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
// Apply material 16 times along a circle to give the appearance of a splash
for (j = 0; j < 16; j++) {
// BENTODO not sure if I did the math right.
FrameInterpolation_RecordOpenChild(effect, (i + ARRAY_COUNT(this->effect) + j));
Matrix_RotateYF(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_NEW);
Matrix_MultVecZ(effect->maxScale, &vec);
/**
@@ -1008,7 +1026,9 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) {
gSPDisplayList(POLY_XLU_DISP++, gEffWaterSplashDL);
}
}
FrameInterpolation_RecordCloseChild();
}
FrameInterpolation_RecordCloseChild();
}
}
@@ -6,6 +6,7 @@
#include "z_en_hanabi.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#include "2s2h/Enhancements/FrameInterpolation/FrameInterpolation.h"
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20)
@@ -154,7 +155,7 @@ void func_80B22FA8(EnHanabiStruct* arg0, PlayState* play2) {
if (arg0->unk_00 != 1) {
continue;
}
FrameInterpolation_RecordOpenChild(arg0, i);
Matrix_Translate(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW);
Matrix_ReplaceRotation(&play->billboardMtxF);
if (arg0->unk_01 < 40) {
@@ -184,6 +185,7 @@ void func_80B22FA8(EnHanabiStruct* arg0, PlayState* play2) {
}
gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL);
FrameInterpolation_RecordCloseChild();
}
CLOSE_DISPS(gfxCtx);
@@ -8,6 +8,7 @@
#include "z64quake.h"
#include "z64rumble.h"
#include "objects/object_bombiwa/object_bombiwa.h"
#include "2s2h/Enhancements/FrameInterpolation/FrameInterpolation.h"
#define FLAGS (ACTOR_FLAG_10)
@@ -63,8 +64,8 @@ static ColliderCylinderInit sCylinderInit = {
static Vec3f D_80A55D2C = { 0.0f, 0.3f, 0.0f };
void func_80A53BE0(PlayState* play, Vec3f* arg1) {
Vec3f spBC;
Vec3f spB0;
Vec3f pos;
Vec3f velocity;
s32 i;
s32 gravity;
s16 phi_v0;
@@ -72,17 +73,17 @@ void func_80A53BE0(PlayState* play, Vec3f* arg1) {
s16 phi_v1;
for (i = 0, gravity = -300; i < 16; i++, gravity -= 30) {
spBC.x = (Rand_ZeroOne() - 0.5f) * 260.0f;
spBC.y = i * (40.0f / 3);
spBC.z = (Rand_ZeroOne() - 0.5f) * 260.0f;
pos.x = (Rand_ZeroOne() - 0.5f) * 260.0f;
pos.y = i * (40.0f / 3);
pos.z = (Rand_ZeroOne() - 0.5f) * 260.0f;
spB0.x = ((Rand_ZeroOne() - 0.5f) * 5.7f) + (spBC.x * 0.035f);
spB0.y = (Rand_ZeroOne() * 16.0f) + 5.0f + ((16 - i) * 0.25f);
spB0.z = ((Rand_ZeroOne() - 0.5f) * 5.7f) + (spBC.z * 0.035f);
velocity.x = ((Rand_ZeroOne() - 0.5f) * 5.7f) + (pos.x * 0.035f);
velocity.y = (Rand_ZeroOne() * 16.0f) + 5.0f + ((16 - i) * 0.25f);
velocity.z = ((Rand_ZeroOne() - 0.5f) * 5.7f) + (pos.z * 0.035f);
spBC.x += arg1->x;
spBC.y += arg1->y;
spBC.z += arg1->z;
pos.x += arg1->x;
pos.y += arg1->y;
pos.z += arg1->z;
if (i >= 14) {
phi_v0 = 37;
@@ -107,7 +108,7 @@ void func_80A53BE0(PlayState* play, Vec3f* arg1) {
if (1) {}
}
EffectSsKakera_Spawn(play, &spBC, &spB0, &spBC, gravity, phi_v0, 15, 0, 0, phi_v1, 1, 0, life, -1,
EffectSsKakera_Spawn(play, &pos, &velocity, &pos, gravity, phi_v0, 15, 0, 0, phi_v1, 1, 0, life, -1,
OBJECT_BOMBIWA, object_bombiwa_DL_001990);
}
}
@@ -708,6 +709,7 @@ void func_80A55B34(Actor* thisx, PlayState* play) {
if (ptr->unk_24 != 0) {
continue;
}
FrameInterpolation_RecordOpenChild(this, i);
Matrix_SetTranslateRotateYXZ(ptr->unk_0C.x, ptr->unk_0C.y + (325.0f * ptr->unk_00.y), ptr->unk_0C.z,
&ptr->unk_1C);
@@ -716,6 +718,7 @@ void func_80A55B34(Actor* thisx, PlayState* play) {
gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(gfx++, object_bombiwa_DL_0009E0);
FrameInterpolation_RecordCloseChild();
}
POLY_OPA_DISP = gfx;