1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-23 07:21:19 +00:00

Cleanup pass on in-actor effects systems (#1167)

* Name in-actor effect functions / improve naming consistency

"particle" -> "effect"

Fixup: consistent effect functions names, missed a bunch

* Use `materialFlag` as int for the "is material already set" "boolean"

Fixup `materialFlag` (actually a boolean one), and `objectFlag`

More actually boolean `materialFlag`s

* Consistently use `_EFFECTS_COUNT` defines (except partial buffer usage, for now)

`BOSSFD_EFFECT_COUNT` -> `BOSSFD_EFFECTS_COUNT`

`EFFECT_COUNT` -> `FISHING_EFFECTS_COUNT`

Place `_EFFECTS_COUNT` defines before effect struct definition

* Name `countLimit` the "max new effect index" argument

* Rename all effect buffers to `effects`/`sEffects`

* Fixup some array/pointer usage

* `EnNiw` also has this pseudo-effects system

* `EnSyatekiNiw` also has this pseudo-effects system

* `EnFz` also has this pseudo-effects system

* `_EFFECTS_COUNT` -> `_EFFECT_COUNT`

* `effects` -> `effect` where used as iterator (hopefully covers everything)

* Run formatter
This commit is contained in:
Dragorn421 2022-04-09 02:29:26 +02:00 committed by GitHub
parent 7068ad3703
commit 76cffddf29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 871 additions and 833 deletions

View file

@ -9,10 +9,10 @@ void EfcErupc_Update(Actor* thisx, GlobalContext* globalCtx);
void EfcErupc_Draw(Actor* thisx, GlobalContext* globalCtx);
void EfcErupc_UpdateAction(EfcErupc* this, GlobalContext* globalCtx);
void EfcErupc_DrawParticles(EfcErupcParticles* particles, GlobalContext* globalCtx);
void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx);
void EfcErupc_AddParticle(EfcErupcParticles* particles, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scaleFactor);
void EfcErupc_InitParticles(EfcErupcParticles* particles);
void EfcErupc_DrawEffects(EfcErupcEffect* effect, GlobalContext* globalCtx);
void EfcErupc_UpdateEffects(EfcErupc* this, GlobalContext* globalCtx);
void EfcErupc_SpawnEffect(EfcErupcEffect* effect, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scaleFactor);
void EfcErupc_InitEffects(EfcErupcEffect* effect);
const ActorInit Efc_Erupc_InitVars = {
ACTOR_EFC_ERUPC,
@ -35,7 +35,7 @@ void EfcErupc_Init(Actor* thisx, GlobalContext* globalCtx) {
EfcErupc_SetupAction(this, EfcErupc_UpdateAction);
Actor_SetScale(&this->actor, 1.0f);
EfcErupc_InitParticles(this->particles);
EfcErupc_InitEffects(this->effects);
this->unk_14C = this->unk_14E = this->unk_150 = 0;
this->unk_152 = 5;
this->unk_154 = -100;
@ -99,7 +99,7 @@ void EfcErupc_UpdateAction(EfcErupc* this, GlobalContext* globalCtx) {
vel.y = Rand_ZeroFloat(100.0f);
vel.z = Rand_CenteredFloat(100.0f);
accel.y = this->unk_154 * 0.1f;
EfcErupc_AddParticle(this->particles, &pos, &vel, &accel, 80.0f);
EfcErupc_SpawnEffect(this->effects, &pos, &vel, &accel, 80.0f);
}
}
@ -107,7 +107,7 @@ void EfcErupc_Update(Actor* thisx, GlobalContext* globalCtx) {
EfcErupc* this = (EfcErupc*)thisx;
this->actionFunc(this, globalCtx);
EfcErupc_UpdateParticles(this, globalCtx);
EfcErupc_UpdateEffects(this, globalCtx);
}
void EfcErupc_Draw(Actor* thisx, GlobalContext* globalCtx) {
@ -156,26 +156,25 @@ void EfcErupc_Draw(Actor* thisx, GlobalContext* globalCtx) {
}
}
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_efc_erupc.c", 356);
EfcErupc_DrawParticles(this->particles, globalCtx);
EfcErupc_DrawEffects(this->effects, globalCtx);
}
void EfcErupc_DrawParticles(EfcErupcParticles* particles, GlobalContext* globalCtx) {
void EfcErupc_DrawEffects(EfcErupcEffect* effect, GlobalContext* globalCtx) {
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
s16 i;
s32 pad;
OPEN_DISPS(gfxCtx, "../z_efc_erupc.c", 368);
for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, particles++) {
if (particles->isActive) {
for (i = 0; i < EFC_ERUPC_EFFECT_COUNT; i++, effect++) {
if (effect->isActive) {
func_80093D84(globalCtx->state.gfxCtx);
gSPDisplayList(POLY_XLU_DISP++, object_efc_erupc_DL_002760);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, particles->color.r, particles->color.g, particles->color.b,
particles->alpha);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, effect->color.r, effect->color.g, effect->color.b, effect->alpha);
gDPSetEnvColor(POLY_XLU_DISP++, 150, 0, 0, 0);
gDPPipeSync(POLY_XLU_DISP++);
Matrix_Translate(particles->pos.x, particles->pos.y, particles->pos.z, MTXMODE_NEW);
Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW);
Matrix_ReplaceRotation(&globalCtx->billboardMtxF);
Matrix_Scale(particles->scale, particles->scale, 1.0f, MTXMODE_APPLY);
Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_efc_erupc.c", 393),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, object_efc_erupc_DL_0027D8);
@ -191,19 +190,19 @@ static Color_RGB8 D_8099D770[] = {
{ 255, 0, 0 },
};
void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx) {
void EfcErupc_UpdateEffects(EfcErupc* this, GlobalContext* globalCtx) {
s16 i;
s16 index;
Color_RGB8 particleColors[] = {
Color_RGB8 effectColors[] = {
{ 255, 128, 0 },
{ 255, 0, 0 },
{ 0, 0, 0 },
{ 100, 0, 0 },
};
Color_RGB8* color;
EfcErupcParticles* cur = this->particles;
EfcErupcEffect* cur = this->effects;
for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, cur++) {
for (i = 0; i < EFC_ERUPC_EFFECT_COUNT; i++, cur++) {
if (cur->isActive) {
cur->pos.x += cur->vel.x;
cur->pos.y += cur->vel.y;
@ -213,7 +212,7 @@ void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx) {
cur->vel.z += cur->accel.z;
cur->animTimer += 1;
index = cur->animTimer % 4;
color = &particleColors[index];
color = &effectColors[index];
cur->color.r = color->r;
cur->color.g = color->g;
cur->color.b = color->b;
@ -226,27 +225,27 @@ void EfcErupc_UpdateParticles(EfcErupc* this, GlobalContext* globalCtx) {
}
}
void EfcErupc_AddParticle(EfcErupcParticles* particles, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scaleFactor) {
void EfcErupc_SpawnEffect(EfcErupcEffect* effect, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scaleFactor) {
s16 i;
for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, particles++) {
if (!particles->isActive) {
particles->isActive = true;
particles->pos = *pos;
particles->vel = *vel;
particles->accel = *accel;
particles->scale = scaleFactor / 1000.0f;
particles->alpha = 255;
particles->animTimer = (s16)Rand_ZeroFloat(10.0f);
for (i = 0; i < EFC_ERUPC_EFFECT_COUNT; i++, effect++) {
if (!effect->isActive) {
effect->isActive = true;
effect->pos = *pos;
effect->vel = *vel;
effect->accel = *accel;
effect->scale = scaleFactor / 1000.0f;
effect->alpha = 255;
effect->animTimer = (s16)Rand_ZeroFloat(10.0f);
return;
}
}
}
void EfcErupc_InitParticles(EfcErupcParticles* particles) {
void EfcErupc_InitEffects(EfcErupcEffect* effect) {
s16 i;
for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, particles++) {
particles->isActive = false;
for (i = 0; i < EFC_ERUPC_EFFECT_COUNT; i++, effect++) {
effect->isActive = false;
}
}

View file

@ -8,6 +8,8 @@ struct EfcErupc;
typedef void (*EfcErupcActionFunc)(struct EfcErupc*, GlobalContext*);
#define EFC_ERUPC_EFFECT_COUNT 100
typedef struct {
/* 0x00 */ Vec3f pos;
/* 0x0C */ Vec3f vel;
@ -19,9 +21,7 @@ typedef struct {
/* 0x30 */ char unk_2C[4];
/* 0x34 */ f32 scale;
/* 0x38 */ char unk_34[8];
} EfcErupcParticles; // size 0x3C
#define EFC_ERUPC_NUM_PARTICLES 100
} EfcErupcEffect; // size 0x3C
typedef struct EfcErupc {
/* 0x0000 */ Actor actor;
@ -30,7 +30,7 @@ typedef struct EfcErupc {
/* 0x0150 */ s16 unk_150;
/* 0x0152 */ s16 unk_152;
/* 0x0154 */ s16 unk_154;
/* 0x0158 */ EfcErupcParticles particles[EFC_ERUPC_NUM_PARTICLES];
/* 0x0158 */ EfcErupcEffect effects[EFC_ERUPC_EFFECT_COUNT];
/* 0x18C8 */ EfcErupcActionFunc actionFunc;
} EfcErupc; // size = 0x18CC