Skip to content

Commit

Permalink
libtrx/anims/types: simplify ANIM_BONE struct
Browse files Browse the repository at this point in the history
This replaces the bit flags on the ANIM_BONE struct with equivalent
bool properties, and updates all relevant references to use the correct
type.
  • Loading branch information
lahm86 committed Jan 4, 2025
1 parent 1d6017e commit b798fe5
Show file tree
Hide file tree
Showing 41 changed files with 76 additions and 79 deletions.
7 changes: 6 additions & 1 deletion src/libtrx/game/level/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ void Level_ReadAnimBones(
{
for (int32_t i = 0; i < num_bones; i++) {
ANIM_BONE *const bone = Anim_GetBone(base_idx + i);
bone->flags = VFile_ReadS32(file);
const int32_t flags = VFile_ReadS32(file);
bone->matrix_pop = (flags & 1) != 0;
bone->matrix_push = (flags & 2) != 0;
bone->rot_x = false;
bone->rot_y = false;
bone->rot_z = false;
bone->pos.x = VFile_ReadS32(file);
bone->pos.y = VFile_ReadS32(file);
bone->pos.z = VFile_ReadS32(file);
Expand Down
18 changes: 5 additions & 13 deletions src/libtrx/include/libtrx/game/anims/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,11 @@ typedef struct __PACKING {
} ANIM_RANGE;

typedef struct {
union {
int32_t flags;
// clang-format off
struct {
uint32_t matrix_pop: 1;
uint32_t matrix_push: 1;
uint32_t rot_x: 1;
uint32_t rot_y: 1;
uint32_t rot_z: 1;
uint32_t pad: 11;
};
// clang-format on
};
bool matrix_pop;
bool matrix_push;
bool rot_x;
bool rot_y;
bool rot_z;
XYZ_32 pos;
} ANIM_BONE;

Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/ape.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void Ape_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 13)->rot_y = 1;
Object_GetBone(obj, 13)->rot_y = true;
}

void Ape_Control(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/baldy.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void Baldy_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 0)->rot_y = 1;
Object_GetBone(obj, 0)->rot_y = true;
}

void Baldy_Initialise(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/bear.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void Bear_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 13)->rot_y = 1;
Object_GetBone(obj, 13)->rot_y = true;
}

void Bear_Control(int16_t item_num)
Expand Down
4 changes: 2 additions & 2 deletions src/tr1/game/objects/creatures/centaur.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void Centaur_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 10)->rot_x = 1;
Object_GetBone(obj, 10)->rot_y = 1;
Object_GetBone(obj, 10)->rot_x = true;
Object_GetBone(obj, 10)->rot_y = true;
}

void Centaur_Control(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/cowboy.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void Cowboy_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 0)->rot_y = 1;
Object_GetBone(obj, 0)->rot_y = true;
}

void Cowboy_Control(int16_t item_num)
Expand Down
4 changes: 2 additions & 2 deletions src/tr1/game/objects/creatures/crocodile.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void Croc_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 7)->rot_y = 1;
Object_GetBone(obj, 7)->rot_y = true;
}

void Croc_Control(int16_t item_num)
Expand Down Expand Up @@ -221,7 +221,7 @@ void Alligator_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 7)->rot_y = 1;
Object_GetBone(obj, 7)->rot_y = true;
}

void Alligator_Control(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/larson.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void Larson_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 6)->rot_y = 1;
Object_GetBone(obj, 6)->rot_y = true;
}

void Larson_Control(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/lion.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static void M_SetupBase(OBJECT *const obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 19)->rot_y = 1;
Object_GetBone(obj, 19)->rot_y = true;
}

void Lion_SetupLion(OBJECT *obj)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/mummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void Mummy_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;

Object_GetBone(obj, 2)->rot_y = 1;
Object_GetBone(obj, 2)->rot_y = true;
}

void Mummy_Initialise(int16_t item_num)
Expand Down
4 changes: 2 additions & 2 deletions src/tr1/game/objects/creatures/mutant.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ void Mutant_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 0)->rot_y = 1;
Object_GetBone(obj, 2)->rot_y = 1;
Object_GetBone(obj, 0)->rot_y = true;
Object_GetBone(obj, 2)->rot_y = true;
}

void Mutant_Setup2(OBJECT *obj)
Expand Down
4 changes: 2 additions & 2 deletions src/tr1/game/objects/creatures/natla.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void Natla_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 2)->rot_x = 1;
Object_GetBone(obj, 2)->rot_z = 1;
Object_GetBone(obj, 2)->rot_x = true;
Object_GetBone(obj, 2)->rot_z = true;
}

void Natla_Control(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/pierre.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Pierre_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 6)->rot_y = 1;
Object_GetBone(obj, 6)->rot_y = true;
}

void Pierre_Control(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/raptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void Raptor_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 21)->rot_y = 1;
Object_GetBone(obj, 21)->rot_y = true;
}

void Raptor_Control(int16_t item_num)
Expand Down
4 changes: 2 additions & 2 deletions src/tr1/game/objects/creatures/rat.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void Rat_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 1)->rot_y = 1;
Object_GetBone(obj, 1)->rot_y = true;
}

void Rat_Control(int16_t item_num)
Expand Down Expand Up @@ -187,7 +187,7 @@ void Vole_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 1)->rot_y = 1;
Object_GetBone(obj, 1)->rot_y = true;
}

void Vole_Control(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/skate_kid.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void SkateKid_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 0)->rot_y = 1;
Object_GetBone(obj, 0)->rot_y = true;

if (!g_Objects[O_SKATEBOARD].loaded) {
LOG_WARNING(
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/torso.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void Torso_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 1)->rot_y = 1;
Object_GetBone(obj, 1)->rot_y = true;
}

void Torso_Control(int16_t item_num)
Expand Down
4 changes: 2 additions & 2 deletions src/tr1/game/objects/creatures/trex.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ void TRex_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 10)->rot_y = 1;
Object_GetBone(obj, 11)->rot_y = 1;
Object_GetBone(obj, 10)->rot_y = true;
Object_GetBone(obj, 11)->rot_y = true;
}

void TRex_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/wolf.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void Wolf_Setup(OBJECT *obj)
obj->save_anim = 1;
obj->save_flags = 1;

Object_GetBone(obj, 2)->rot_y = 1;
Object_GetBone(obj, 2)->rot_y = true;
}

void Wolf_Initialise(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/phase/phase_inventory.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ static void Inv_DrawItem(INVENTORY_ITEM *const inv_item, const int32_t frames)
const int32_t frac = InvItem_GetFrames(inv_item, &frame1, &frame2, &rate);
if (inv_item->object_id == O_MAP_OPTION) {
const int16_t extra_rotation[1] = { Option_Compass_GetNeedleAngle() };
Object_GetBone(obj, 0)->rot_y = 1;
Object_GetBone(obj, 0)->rot_y = true;
Object_DrawInterpolatedObject(
obj, inv_item->drawn_meshes, extra_rotation, frame1, frame2, frac,
rate);
Expand Down
4 changes: 2 additions & 2 deletions src/tr2/game/objects/creatures/bandit_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void Bandit1_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 6)->rot_y = 1;
Object_GetBone(obj, 8)->rot_y = 1;
Object_GetBone(obj, 6)->rot_y = true;
Object_GetBone(obj, 8)->rot_y = true;
}

void Bandit1_Control(const int16_t item_num)
Expand Down
8 changes: 4 additions & 4 deletions src/tr2/game/objects/creatures/bandit_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void Bandit2_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 6)->rot_y = 1;
Object_GetBone(obj, 8)->rot_y = 1;
Object_GetBone(obj, 6)->rot_y = true;
Object_GetBone(obj, 8)->rot_y = true;
}

void Bandit2B_Setup(void)
Expand Down Expand Up @@ -100,8 +100,8 @@ void Bandit2B_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 6)->rot_y = 1;
Object_GetBone(obj, 8)->rot_y = 1;
Object_GetBone(obj, 6)->rot_y = true;
Object_GetBone(obj, 8)->rot_y = true;
}

void Bandit2_Control(const int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/objects/creatures/barracuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void Barracuda_Setup(void)
obj->save_anim = 1;
obj->water_creature = 1;

Object_GetBone(obj, 6)->rot_y = 1;
Object_GetBone(obj, 6)->rot_y = true;
}

void Barracuda_Control(const int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/objects/creatures/bird_guardian.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void BirdGuardian_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 14)->rot_y = 1;
Object_GetBone(obj, 14)->rot_y = true;
}

void BirdGuardian_Control(const int16_t item_num)
Expand Down
6 changes: 3 additions & 3 deletions src/tr2/game/objects/creatures/cultist_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Cultist1_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 0)->rot_y = 1;
Object_GetBone(obj, 0)->rot_y = true;
}

void Cultist1A_Setup(void)
Expand Down Expand Up @@ -98,7 +98,7 @@ void Cultist1A_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 0)->rot_y = 1;
Object_GetBone(obj, 0)->rot_y = true;
}

void Cultist1B_Setup(void)
Expand Down Expand Up @@ -127,7 +127,7 @@ void Cultist1B_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 0)->rot_y = 1;
Object_GetBone(obj, 0)->rot_y = true;
}

void Cultist1_Initialise(const int16_t item_num)
Expand Down
4 changes: 2 additions & 2 deletions src/tr2/game/objects/creatures/cultist_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ void Cultist2_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 0)->rot_y = 1;
Object_GetBone(obj, 8)->rot_y = 1;
Object_GetBone(obj, 0)->rot_y = true;
Object_GetBone(obj, 8)->rot_y = true;
}

void Cultist2_Control(const int16_t item_num)
Expand Down
4 changes: 2 additions & 2 deletions src/tr2/game/objects/creatures/diver.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ void Diver_Setup(void)
obj->save_anim = 1;
obj->water_creature = 1;

Object_GetBone(obj, 10)->rot_y = 1;
Object_GetBone(obj, 14)->rot_z = 1;
Object_GetBone(obj, 10)->rot_y = true;
Object_GetBone(obj, 14)->rot_z = true;
}

void Diver_Control(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/objects/creatures/dog.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void Dog_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 19)->rot_y = 1;
Object_GetBone(obj, 19)->rot_y = true;
}

void Dog_Control(const int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/objects/creatures/dragon.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void Dragon_SetupFront(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 10)->rot_z = 1;
Object_GetBone(obj, 10)->rot_z = true;
}

void Dragon_SetupBack(void)
Expand Down
4 changes: 2 additions & 2 deletions src/tr2/game/objects/creatures/monk.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void Monk1_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 6)->rot_y = 1;
Object_GetBone(obj, 6)->rot_y = true;
}

void Monk2_Setup(void)
Expand All @@ -97,7 +97,7 @@ void Monk2_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 6)->rot_y = 1;
Object_GetBone(obj, 6)->rot_y = true;
}

void Monk_Control(const int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/objects/creatures/mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void Mouse_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 3)->rot_y = 1;
Object_GetBone(obj, 3)->rot_y = true;
}

void Mouse_Control(const int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/objects/creatures/shark.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void Shark_Setup(void)
obj->save_anim = 1;
obj->water_creature = 1;

Object_GetBone(obj, 9)->rot_y = 1;
Object_GetBone(obj, 9)->rot_y = true;
}

void Shark_Control(const int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/objects/creatures/tiger.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void Tiger_Setup(void)
obj->save_flags = 1;
obj->save_anim = 1;

Object_GetBone(obj, 21)->rot_y = 1;
Object_GetBone(obj, 21)->rot_y = true;
}

void Tiger_Control(const int16_t item_num)
Expand Down
Loading

0 comments on commit b798fe5

Please sign in to comment.