simplify Particle struct

This commit is contained in:
Unnunu
2025-04-17 09:16:41 +03:00
parent 30cfc0e604
commit b5022dc9fa
9 changed files with 565 additions and 576 deletions
-11
View File
@@ -1732,16 +1732,6 @@ typedef struct SegmentPropertiesObject {
/* 0x003B */ s8 animationID;
} SegmentPropertiesObject;
typedef struct SegmentPropertiesParticle {
/* 0x002C */ s16 kind;
/* 0x002E */ s16 segmentID;
/* 0x0030 */ f32 unk30;
/* 0x0034 */ f32 unk34;
/* 0x0038 */ u8 unk38;
/* 0x0039 */ u8 movementType;
/* 0x003A */ s16 destroyTimer;
} SegmentPropertiesParticle;
typedef struct SegmentPropertiesCamera {
/* 0x002C */ f32 unk2C;
/* 0x0030 */ f32 distanceToCamera;
@@ -1761,7 +1751,6 @@ typedef struct ObjectSegment {
/* 0x0028 */ f32 unk28;
union {
SegmentPropertiesObject object;
SegmentPropertiesParticle particle;
SegmentPropertiesCamera camera;
};
/* 0x003C */ LevelObjectEntry* level_entry;
+19 -19
View File
@@ -2064,11 +2064,11 @@ s32 obj_init_emitter(Object *obj, ParticleEmitter *emitter) {
for (i = 0; i < obj->segment.header->particleCount; i++) {
if ((particleDataEntry[i].upper & 0xFFFF0000) == 0xFFFF0000) {
emitter_init(&obj->particleEmitter[i], (particleDataEntry[i].upper >> 8) & 0xFF,
particleDataEntry[i].upper & 0xFF);
particleDataEntry[i].upper & 0xFF);
} else {
emitter_init_with_pos(&obj->particleEmitter[i], (particleDataEntry[i].upper >> 0x18) & 0xFF,
(particleDataEntry[i].upper >> 0x10) & 0xFF, particleDataEntry[i].upper & 0xFFFF,
(particleDataEntry[i].lower >> 0x10) & 0xFFFF, particleDataEntry[i].lower & 0xFFFF);
(particleDataEntry[i].upper >> 0x10) & 0xFF, particleDataEntry[i].upper & 0xFFFF,
(particleDataEntry[i].lower >> 0x10) & 0xFFFF, particleDataEntry[i].lower & 0xFFFF);
}
}
return ((obj->segment.header->particleCount * sizeof(ParticleEmitter)) + 3) & ~3;
@@ -2365,7 +2365,7 @@ void func_80010994(s32 updateRate) {
obj = gObjPtrList[i];
if (obj->segment.trans.flags & OBJ_FLAGS_PARTICLE) {
// Why is this object being treated as a Particle?
handle_particle_movement((Particle *) obj, updateRate);
particle_update((Particle *) obj, updateRate);
}
}
}
@@ -3347,8 +3347,7 @@ void func_80012F94(Object *obj) {
void render_object_parts(Object *obj) {
func_80012F94(obj);
if (obj->segment.trans.flags & OBJ_FLAGS_PARTICLE) {
render_particle((Particle *) obj, &gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList,
PARTICLE_F40_8000);
render_particle((Particle *) obj, &gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, PARTICLE_F40_8000);
} else {
if (obj->segment.header->modelType == OBJECT_MODEL_TYPE_3D_MODEL) {
render_3d_model(obj);
@@ -3745,11 +3744,11 @@ s32 func_80014B50(s32 arg0, s32 arg1, f32 arg2, u32 arg3) {
case 0:
while (arg1 >= arg0) {
while ((var_a1 >= arg0) && ((gObjPtrList[arg0]->segment.trans.x_position -
gObjPtrList[arg0]->segment.particle.unk34) < arg2)) {
gObjPtrList[arg0]->segment.camera.unk34) < arg2)) {
arg0++;
}
while ((arg1 >= var_a0) && (arg2 <= (gObjPtrList[arg1]->segment.trans.x_position -
gObjPtrList[arg1]->segment.particle.unk34))) {
gObjPtrList[arg1]->segment.camera.unk34))) {
arg1--;
}
if (arg0 < arg1) {
@@ -3764,11 +3763,11 @@ s32 func_80014B50(s32 arg0, s32 arg1, f32 arg2, u32 arg3) {
case 1:
while (arg1 >= arg0) {
while ((var_a1 >= arg0) && ((gObjPtrList[arg0]->segment.trans.y_position -
gObjPtrList[arg0]->segment.particle.unk34) < arg2)) {
gObjPtrList[arg0]->segment.camera.unk34) < arg2)) {
arg0++;
}
while ((arg1 >= var_a0) && (arg2 <= (gObjPtrList[arg1]->segment.trans.y_position -
gObjPtrList[arg1]->segment.particle.unk34))) {
gObjPtrList[arg1]->segment.camera.unk34))) {
arg1--;
}
if (arg0 < arg1) {
@@ -3783,11 +3782,11 @@ s32 func_80014B50(s32 arg0, s32 arg1, f32 arg2, u32 arg3) {
case 2:
while (arg1 >= arg0) {
while ((var_a1 >= arg0) && ((gObjPtrList[arg0]->segment.trans.z_position -
gObjPtrList[arg0]->segment.particle.unk34) < arg2)) {
gObjPtrList[arg0]->segment.camera.unk34) < arg2)) {
arg0++;
}
while ((arg1 >= var_a0) && (arg2 <= (gObjPtrList[arg1]->segment.trans.z_position -
gObjPtrList[arg1]->segment.particle.unk34))) {
gObjPtrList[arg1]->segment.camera.unk34))) {
arg1--;
}
if (arg0 < arg1) {
@@ -3802,11 +3801,11 @@ s32 func_80014B50(s32 arg0, s32 arg1, f32 arg2, u32 arg3) {
case 8:
while (arg1 >= arg0) {
while ((var_a1 >= arg0) && ((gObjPtrList[arg0]->segment.trans.x_position +
gObjPtrList[arg0]->segment.particle.unk34) < arg2)) {
gObjPtrList[arg0]->segment.camera.unk34) < arg2)) {
arg0++;
}
while ((arg1 >= var_a0) && (arg2 <= (gObjPtrList[arg1]->segment.trans.x_position +
gObjPtrList[arg1]->segment.particle.unk34))) {
gObjPtrList[arg1]->segment.camera.unk34))) {
arg1--;
}
if (arg0 < arg1) {
@@ -3821,11 +3820,11 @@ s32 func_80014B50(s32 arg0, s32 arg1, f32 arg2, u32 arg3) {
case 9:
while (arg1 >= arg0) {
while ((var_a1 >= arg0) && ((gObjPtrList[arg0]->segment.trans.y_position +
gObjPtrList[arg0]->segment.particle.unk34) < arg2)) {
gObjPtrList[arg0]->segment.camera.unk34) < arg2)) {
arg0++;
}
while ((arg1 >= var_a0) && (arg2 <= (gObjPtrList[arg1]->segment.trans.y_position +
gObjPtrList[arg1]->segment.particle.unk34))) {
gObjPtrList[arg1]->segment.camera.unk34))) {
arg1--;
}
if (arg0 < arg1) {
@@ -3840,11 +3839,11 @@ s32 func_80014B50(s32 arg0, s32 arg1, f32 arg2, u32 arg3) {
case 10:
while (arg1 >= arg0) {
while ((var_a1 >= arg0) && ((gObjPtrList[arg0]->segment.trans.z_position +
gObjPtrList[arg0]->segment.particle.unk34) < arg2)) {
gObjPtrList[arg0]->segment.camera.unk34) < arg2)) {
arg0++;
}
while ((arg1 >= var_a0) && (arg2 <= (gObjPtrList[arg1]->segment.trans.z_position +
gObjPtrList[arg1]->segment.particle.unk34))) {
gObjPtrList[arg1]->segment.camera.unk34))) {
arg1--;
}
if (arg0 < arg1) {
@@ -4354,7 +4353,8 @@ Object *find_taj_object(void) {
Object *current_obj;
for (i = gObjectListStart; i < gObjectCount; i++) {
current_obj = gObjPtrList[i];
if (!(current_obj->segment.trans.flags & OBJ_FLAGS_PARTICLE) && (current_obj->behaviorId == BHV_PARK_WARDEN)) {
if (!(current_obj->segment.trans.flags & OBJ_FLAGS_PARTICLE) &&
(current_obj->behaviorId == BHV_PARK_WARDEN)) {
return current_obj;
}
}
+506 -500
View File
File diff suppressed because it is too large Load Diff
+30 -36
View File
@@ -122,38 +122,31 @@ enum ParticleField40 {
PARTICLE_F40_8000 = 0x8000,
};
typedef struct ParticleProperties {
typedef struct ParticleDescriptor {
/* 0x00 */ u8 kind; // ParticleKind
/* 0x01 */ u8 movementType; // ParticleMovement
/* 0x02 */ u16 unk2;
/* 0x04 */ s16 textureID;
/* 0x06 */ s16 unk6;
/* 0x08 */ s16 lifeTime;
union {
/* 0x0A */ s16 lifeTimeRange;
struct {
/* 0x08 */ s16 lifeTime;
union {
/* 0x0A */ s16 lifeTimeRange;
/* 0x0A */ u16 lifeTimeRangeUnsigned;
};
/* 0x0A */ u16 unkA : 6;
/* 0x0A */ u16 unkB : 6;
};
/* 0x08 */ s32 lifeTimeWord;
};
/* 0x0C */ u8 opacity;
/* 0x0D */ u8 opacityVel;
/* 0x0E */ s16 opacityTimer;
/* 0x10 */ f32 scale;
/* 0x14 */ ColourRGBA colour;
} ParticleProperties;
} ParticleDescriptor;
typedef struct XYStruct {
s16 x, y;
} XYStruct;
typedef struct unk800B1CB8_44_8 {
u8 pad0[6];
s16 unk6;
} unk800B1CB8_44_8;
typedef struct ColorLoopEntry {
s32 unk0;
u8 r;
@@ -228,12 +221,16 @@ typedef struct unk800AF29C_C_400 {
typedef struct ParticleEmitter {
/* 0x00 */ ParticleBehavior *behaviour;
/* 0x04 */ s16 flags;
/* 0x06 */ u8 unk6;
union {
/* 0x06 */ u8 general_unk6; // Used by general particles
/* 0x06 */ u8 line_unk6; // Used by line particles
/* 0x06 */ u8 pointsNumber; // Used by point particles
};
/* 0x07 */ u8 lifeTime;
/* 0x08 */ s16 propertyID;
/* 0x08 */ s16 descriptorID;
/* 0x0A */ s16 opacity;
union {
/* 0x000C */ Vec3f pos; // Valid for line particle
/* 0x000C */ Vec3f lineAnchor; // Valid for line particle
/* 0x000C */ unk800AF29C_C_400 unkC_400;
/* 0x000C */ ParticleAngle angle;
};
@@ -241,22 +238,6 @@ typedef struct ParticleEmitter {
/* 0x001E */ s16 colorIndex;
} ParticleEmitter;
// TODO merge this struct with ObjectSegment
typedef struct ParticleSegment {
/* 0x0000 */ ObjectTransform trans;
/* 0x0018 */ s16 textureFrame;
/* 0x001A */ s16 unk1A;
/* 0x001C */ Vec3f velocity;
/* 0x0028 */ f32 scaleVelocity;
union {
SegmentPropertiesObject object;
SegmentPropertiesParticle particle;
SegmentPropertiesCamera camera;
};
/* 0x003C */ Object *parentObj;
/* 0x0040 */ s32 unk40;
} ParticleSegment;
typedef struct ParticleModel {
/* 0x00 */ TextureHeader *texture;
/* 0x04 */ s16 vertexCount;
@@ -266,12 +247,25 @@ typedef struct ParticleModel {
} ParticleModel;
typedef struct Particle {
/* 0x0000 */ ParticleSegment segment;
/* 0x0000 */ ObjectTransform trans;
/* 0x0018 */ s16 textureFrame;
/* 0x001A */ s16 unk1A;
/* 0x001C */ Vec3f velocity;
/* 0x0028 */ f32 scaleVelocity;
/* 0x002C */ s16 kind;
/* 0x002E */ s16 segmentID;
/* 0x0030 */ f32 unk30;
/* 0x0034 */ f32 unk34;
/* 0x0038 */ u8 unk38;
/* 0x0039 */ u8 movementType;
/* 0x003A */ s16 destroyTimer;
/* 0x003C */ Object *parentObj;
/* 0x0040 */ s32 unk40;
union {
/* 0x0044 */ ParticleModel *model;
/* 0x0044 */ Sprite *sprite; // Unclear whether this is the same as unk80068514_arg4
};
/* 0x0048 */ s16 behaviorId;
/* 0x0048 */ s16 unk_48;
/* 0x004A */ s16 brightness;
/* 0x004C */ Vec3f localPos;
union {
@@ -327,7 +321,7 @@ void init_particle_assets(void);
void set_particle_texture_frame(Particle *particle);
void setup_particle_position(Particle *particle, Object *obj, ParticleEmitter *emitter, ParticleBehavior *behaviour);
void particle_deallocate(Particle *particle);
void handle_particle_movement(Particle *particle, s32 updateRate);
void particle_update(Particle *particle, s32 updateRate);
void setup_particle_velocity(Particle *particle, Object *obj, ParticleEmitter *emitter, ParticleBehavior *behavior);
PointParticle *init_point_particle(Object *obj, ParticleEmitter *emitter);
Particle *particle_allocate(s32 kind);
@@ -340,7 +334,7 @@ void func_800B4668(Object *obj, s32 idx, s32 arg2, s32 arg3);
void func_800B46BC(Object *obj, s32 idx, s32 arg2, s32 arg3);
void obj_spawn_particle(Object *obj, s32 updateRate);
void func_800B3E64(PointParticle *obj);
void move_line_particle(Particle *particle);
void update_line_particle(Particle *particle);
void func_800AF714(Object *racerObj, s32 updateRate);
Particle* init_line_particle(Object* obj, ParticleEmitter* emitter);
+2 -2
View File
@@ -1653,9 +1653,9 @@ init_general_particle = 0x800B1730;
particle_allocate = 0x800B22B8;
particle_deallocate = 0x800B2640;
emitter_cleanup = 0x800B2860;
handle_particle_movement = 0x800B28FC;
particle_update = 0x800B28FC;
func_800B263C = 0x800B2C3C;
move_line_particle = 0x800B2CE0;
update_line_particle = 0x800B2CE0;
set_particle_texture_frame = 0x800B35BC;
move_particle_basic_parent = 0x800B3740;
move_particle_velocity_parent = 0x800B3840;
+2 -2
View File
@@ -1642,9 +1642,9 @@ init_general_particle = 0x800B11C0;
particle_allocate = 0x800B1D48;
particle_deallocate = 0x800B20D0;
emitter_cleanup = 0x800B22F0;
handle_particle_movement = 0x800B238C;
particle_update = 0x800B238C;
func_800B263C = 0x800B26CC;
move_line_particle = 0x800B2770;
update_line_particle = 0x800B2770;
set_particle_texture_frame = 0x800B304C;
move_particle_basic_parent = 0x800B31D0;
move_particle_velocity_parent = 0x800B32D0;
+2 -2
View File
@@ -1563,9 +1563,9 @@ init_general_particle = 0x800B1720;
particle_allocate = 0x800B22A8;
particle_deallocate = 0x800B2630;
emitter_cleanup = 0x800B2850;
handle_particle_movement = 0x800B28EC;
particle_update = 0x800B28EC;
func_800B263C = 0x800B2C2C;
move_line_particle = 0x800B2CD0;
update_line_particle = 0x800B2CD0;
set_particle_texture_frame = 0x800B35AC;
move_particle_basic_parent = 0x800B3730;
move_particle_velocity_parent = 0x800B3830;
+2 -2
View File
@@ -1648,9 +1648,9 @@ init_general_particle = 0x800B1130;
particle_allocate = 0x800B1CB8;
particle_deallocate = 0x800B2040;
emitter_cleanup = 0x800B2260;
handle_particle_movement = 0x800B22FC;
particle_update = 0x800B22FC;
func_800B263C = 0x800B263C;
move_line_particle = 0x800B26E0;
update_line_particle = 0x800B26E0;
set_particle_texture_frame = 0x800B2FBC;
move_particle_basic_parent = 0x800B3140;
move_particle_velocity_parent = 0x800B3240;
+2 -2
View File
@@ -1562,9 +1562,9 @@ init_general_particle = 0x800B1690;
particle_allocate = 0x800B2218;
particle_deallocate = 0x800B25A0;
emitter_cleanup = 0x800B27C0;
handle_particle_movement = 0x800B285C;
particle_update = 0x800B285C;
func_800B263C = 0x800B2B9C;
move_line_particle = 0x800B2C40;
update_line_particle = 0x800B2C40;
set_particle_texture_frame = 0x800B351C;
move_particle_basic_parent = 0x800B36A0;
move_particle_velocity_parent = 0x800B37A0;