Skip to content

Commit

Permalink
libtrx/anims/enum: merge bone flags enum
Browse files Browse the repository at this point in the history
This merges the bone flags enum for both games (TR2 naming used).
  • Loading branch information
lahm86 committed Jan 2, 2025
1 parent a83e2b3 commit 4eeb41a
Show file tree
Hide file tree
Showing 26 changed files with 61 additions and 69 deletions.
8 changes: 8 additions & 0 deletions src/libtrx/include/libtrx/game/anims/enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ typedef enum {
ACE_LAND = 1,
ACE_WATER = 2,
} ANIM_COMMAND_ENVIRONMENT;

typedef enum {
BF_MATRIX_POP = 1,
BF_MATRIX_PUSH = 2,
BF_ROT_X = 4,
BF_ROT_Y = 8,
BF_ROT_Z = 16,
} BONE_FLAGS;
// clang-format on
20 changes: 10 additions & 10 deletions src/tr1/game/collide.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,23 +533,23 @@ int32_t Collide_GetSpheres(ITEM *item, SPHERE *ptr, int32_t world_space)
int16_t *extra_rotation = item->data ? item->data : &null_rotation;
for (int i = 1; i < object->nmeshes; i++) {
int32_t bone_extra_flags = bone[0];
if (bone_extra_flags & BEB_POP) {
if (bone_extra_flags & BF_MATRIX_POP) {
Matrix_Pop();
}
if (bone_extra_flags & BEB_PUSH) {
if (bone_extra_flags & BF_MATRIX_PUSH) {
Matrix_Push();
}

Matrix_TranslateRel(bone[1], bone[2], bone[3]);
Matrix_RotYXZpack(*packed_rotation++);

if (bone_extra_flags & BEB_ROT_Y) {
if (bone_extra_flags & BF_ROT_Y) {
Matrix_RotY(*extra_rotation++);
}
if (bone_extra_flags & BEB_ROT_X) {
if (bone_extra_flags & BF_ROT_X) {
Matrix_RotX(*extra_rotation++);
}
if (bone_extra_flags & BEB_ROT_Z) {
if (bone_extra_flags & BF_ROT_Z) {
Matrix_RotZ(*extra_rotation++);
}

Expand Down Expand Up @@ -624,23 +624,23 @@ void Collide_GetJointAbsPosition(ITEM *item, XYZ_32 *vec, int32_t joint)
int16_t *extra_rotation = (int16_t *)item->data;
for (int i = 0; i < joint; i++) {
int32_t bone_extra_flags = bone[0];
if (bone_extra_flags & BEB_POP) {
if (bone_extra_flags & BF_MATRIX_POP) {
Matrix_Pop();
}
if (bone_extra_flags & BEB_PUSH) {
if (bone_extra_flags & BF_MATRIX_PUSH) {
Matrix_Push();
}

Matrix_TranslateRel(bone[1], bone[2], bone[3]);
Matrix_RotYXZpack(*packed_rotation++);

if (bone_extra_flags & BEB_ROT_Y) {
if (bone_extra_flags & BF_ROT_Y) {
Matrix_RotY(*extra_rotation++);
}
if (bone_extra_flags & BEB_ROT_X) {
if (bone_extra_flags & BF_ROT_X) {
Matrix_RotX(*extra_rotation++);
}
if (bone_extra_flags & BEB_ROT_Z) {
if (bone_extra_flags & BF_ROT_Z) {
Matrix_RotZ(*extra_rotation++);
}

Expand Down
12 changes: 6 additions & 6 deletions src/tr1/game/items.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,10 +900,10 @@ int32_t Item_Explode(int16_t item_num, int32_t mesh_bits, int16_t damage)

for (int i = 1; i < obj->nmeshes; i++) {
int32_t bone_extra_flags = *bone++;
if (bone_extra_flags & BEB_POP) {
if (bone_extra_flags & BF_MATRIX_POP) {
Matrix_Pop();
}
if (bone_extra_flags & BEB_PUSH) {
if (bone_extra_flags & BF_MATRIX_PUSH) {
Matrix_Push();
}

Expand All @@ -912,14 +912,14 @@ int32_t Item_Explode(int16_t item_num, int32_t mesh_bits, int16_t damage)

#if 0
if (extra_rotation) {
if (bone_extra_flags & (BEB_ROT_X | BEB_ROT_Y | BEB_ROT_Z)) {
if (bone_extra_flags & BEB_ROT_Y) {
if (bone_extra_flags & (BF_ROT_X | BF_ROT_Y | BF_ROT_Z)) {
if (bone_extra_flags & BF_ROT_Y) {
Matrix_RotY(*extra_rotation++);
}
if (bone_extra_flags & BEB_ROT_X) {
if (bone_extra_flags & BF_ROT_X) {
Matrix_RotX(*extra_rotation++);
}
if (bone_extra_flags & BEB_ROT_Z) {
if (bone_extra_flags & BF_ROT_Z) {
Matrix_RotZ(*extra_rotation++);
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/tr1/game/objects/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ void Object_DrawPickupItem(ITEM *item)

for (int i = 1; i < object->nmeshes; i++) {
int32_t bone_extra_flags = *bone;
if (bone_extra_flags & BEB_POP) {
if (bone_extra_flags & BF_MATRIX_POP) {
Matrix_Pop();
}

if (bone_extra_flags & BEB_PUSH) {
if (bone_extra_flags & BF_MATRIX_PUSH) {
Matrix_Push();
}

Expand Down Expand Up @@ -264,24 +264,24 @@ void Object_DrawInterpolatedObject(

for (int i = 1; i < object->nmeshes; i++) {
int32_t bone_flags = *bone;
if (bone_flags & BEB_POP) {
if (bone_flags & BF_MATRIX_POP) {
Matrix_Pop();
}

if (bone_flags & BEB_PUSH) {
if (bone_flags & BF_MATRIX_PUSH) {
Matrix_Push();
}

Matrix_TranslateRel(bone[1], bone[2], bone[3]);
Matrix_RotYXZpack(*packed_rotation++);

if (extra_rotation != NULL && (bone_flags & BEB_ROT_Y) != 0) {
if (extra_rotation != NULL && (bone_flags & BF_ROT_Y) != 0) {
Matrix_RotY(*extra_rotation++);
}
if (extra_rotation != NULL && (bone_flags & BEB_ROT_X) != 0) {
if (extra_rotation != NULL && (bone_flags & BF_ROT_X) != 0) {
Matrix_RotX(*extra_rotation++);
}
if (extra_rotation != NULL && (bone_flags & BEB_ROT_Z) != 0) {
if (extra_rotation != NULL && (bone_flags & BF_ROT_Z) != 0) {
Matrix_RotZ(*extra_rotation++);
}

Expand All @@ -308,24 +308,24 @@ void Object_DrawInterpolatedObject(

for (int i = 1; i < object->nmeshes; i++) {
int32_t bone_flags = *bone;
if (bone_flags & BEB_POP) {
if (bone_flags & BF_MATRIX_POP) {
Matrix_Pop_I();
}

if (bone_flags & BEB_PUSH) {
if (bone_flags & BF_MATRIX_PUSH) {
Matrix_Push_I();
}

Matrix_TranslateRel_I(bone[1], bone[2], bone[3]);
Matrix_RotYXZpack_I(*packed_rotation1++, *packed_rotation2++);

if (extra_rotation != NULL && (bone_flags & BEB_ROT_Y) != 0) {
if (extra_rotation != NULL && (bone_flags & BF_ROT_Y) != 0) {
Matrix_RotY_I(*extra_rotation++);
}
if (extra_rotation != NULL && (bone_flags & BEB_ROT_X) != 0) {
if (extra_rotation != NULL && (bone_flags & BF_ROT_X) != 0) {
Matrix_RotX_I(*extra_rotation++);
}
if (extra_rotation != NULL && (bone_flags & BEB_ROT_Z) != 0) {
if (extra_rotation != NULL && (bone_flags & BF_ROT_Z) != 0) {
Matrix_RotZ_I(*extra_rotation++);
}

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 @@ -126,7 +126,7 @@ void Ape_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 52] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 52] |= BF_ROT_Y;
}

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 @@ -46,7 +46,7 @@ void Baldy_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx] |= BF_ROT_Y;
}

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 @@ -69,7 +69,7 @@ void Bear_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 52] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 52] |= BF_ROT_Y;
}

void Bear_Control(int16_t item_num)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/centaur.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Centaur_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 40] |= BEB_ROT_X | BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 40] |= BF_ROT_X | BF_ROT_Y;
}

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 @@ -49,7 +49,7 @@ void Cowboy_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx] |= BF_ROT_Y;
}

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 @@ -81,7 +81,7 @@ void Croc_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 28] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 28] |= BF_ROT_Y;
}

void Croc_Control(int16_t item_num)
Expand Down Expand Up @@ -219,7 +219,7 @@ void Alligator_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 28] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 28] |= BF_ROT_Y;
}

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 @@ -49,7 +49,7 @@ void Larson_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 24] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 24] |= BF_ROT_Y;
}

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 @@ -57,7 +57,7 @@ static void M_SetupBase(OBJECT *const obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 76] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 76] |= BF_ROT_Y;
}

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 @@ -31,7 +31,7 @@ void Mummy_Setup(OBJECT *obj)
obj->save_flags = 1;
obj->save_hitpoints = 1;
obj->save_anim = 1;
g_AnimBones[obj->bone_idx + 8] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 8] |= BF_ROT_Y;
}

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 @@ -82,8 +82,8 @@ void Mutant_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 8] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx] |= BF_ROT_Y;
g_AnimBones[obj->bone_idx + 8] |= BF_ROT_Y;
}

void Mutant_Setup2(OBJECT *obj)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/objects/creatures/natla.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Natla_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 8] |= BEB_ROT_Z | BEB_ROT_X;
g_AnimBones[obj->bone_idx + 8] |= BF_ROT_Z | BF_ROT_X;
}

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 @@ -57,7 +57,7 @@ void Pierre_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 24] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 24] |= BF_ROT_Y;
}

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 @@ -58,7 +58,7 @@ void Raptor_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 84] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 84] |= BF_ROT_Y;
}

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 @@ -75,7 +75,7 @@ void Rat_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 4] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 4] |= BF_ROT_Y;
}

void Rat_Control(int16_t item_num)
Expand Down Expand Up @@ -185,7 +185,7 @@ void Vole_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 4] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 4] |= BF_ROT_Y;
}

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 @@ -57,7 +57,7 @@ void SkateKid_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx] |= BF_ROT_Y;

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 @@ -67,7 +67,7 @@ void Torso_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 4] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 4] |= BF_ROT_Y;
}

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 @@ -58,8 +58,8 @@ void TRex_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 40] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 44] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 40] |= BF_ROT_Y;
g_AnimBones[obj->bone_idx + 44] |= BF_ROT_Y;
}

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 @@ -65,7 +65,7 @@ void Wolf_Setup(OBJECT *obj)
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
g_AnimBones[obj->bone_idx + 8] |= BEB_ROT_Y;
g_AnimBones[obj->bone_idx + 8] |= BF_ROT_Y;
}

void Wolf_Initialise(int16_t item_num)
Expand Down
4 changes: 2 additions & 2 deletions src/tr1/game/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,11 @@ static void M_DrawPickup3D(DISPLAY_PICKUP *pu)

for (int i = 1; i < obj->nmeshes; i++) {
int32_t bone_extra_flags = *bone;
if (bone_extra_flags & BEB_POP) {
if (bone_extra_flags & BF_MATRIX_POP) {
Matrix_Pop();
}

if (bone_extra_flags & BEB_PUSH) {
if (bone_extra_flags & BF_MATRIX_PUSH) {
Matrix_Push();
}

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 @@ -568,7 +568,7 @@ static void Inv_DrawItem(INVENTORY_ITEM *const inv_item, const int32_t frames)
if (inv_item->object_id == O_MAP_OPTION) {
const int16_t extra_rotation[1] = { Option_Compass_GetNeedleAngle() };
int32_t *const bone = &g_AnimBones[obj->bone_idx];
bone[0] |= BEB_ROT_Y;
bone[0] |= BF_ROT_Y;
Object_DrawInterpolatedObject(
obj, inv_item->drawn_meshes, extra_rotation, frame1, frame2, frac,
rate);
Expand Down
8 changes: 0 additions & 8 deletions src/tr1/global/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,6 @@ typedef enum {
HT_BIG_SLOPE = 2,
} HEIGHT_TYPE;

typedef enum {
BEB_POP = 1 << 0,
BEB_PUSH = 1 << 1,
BEB_ROT_X = 1 << 2,
BEB_ROT_Y = 1 << 3,
BEB_ROT_Z = 1 << 4,
} BONE_EXTRA_BITS;

typedef enum {
RF_UNDERWATER = 1,
} ROOM_FLAG;
Expand Down
Loading

0 comments on commit 4eeb41a

Please sign in to comment.