-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libtrx/anims/frames: expand TR1 frame rotations #2244
Conversation
Download the built assets for this pull request: |
src/libtrx/game/anims/frames.c
Outdated
@@ -5,11 +5,17 @@ | |||
#include "game/objects/common.h" | |||
#include "log.h" | |||
|
|||
#define EXTRACT_ROT_X(r) ((r & 0x3FF0) << 2) | |||
#define EXTRACT_ROT_Y(r1, r2) ((((r1 & 0xF) << 6) | ((r2 & 0xFC00) >> 10)) << 6) | |||
#define EXTRACT_ROT_Z(r) ((r & 0x3FF) << 6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's forgo these macros and put the code directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kinda nice to have the nice defined names though. Because that code is ugly and dense to read. 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've create a M_ExtractRotation
function. For TR2 rots with two values, we will still need to utilise this but its words are reversed so a function will avoid repetition when the time comes.
ASSERT_FAIL(); | ||
return 0; | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function could take a double pointer removing the need for a return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/tr1/math/matrix.h
Outdated
@@ -20,7 +20,7 @@ void Matrix_RotX(int16_t rx); | |||
void Matrix_RotY(int16_t ry); | |||
void Matrix_RotZ(int16_t rz); | |||
void Matrix_RotYXZ(int16_t ry, int16_t rx, int16_t rz); | |||
void Matrix_RotYXZpack(int32_t rots); | |||
void Matrix_RotYXZ_16(const XYZ_16 *rotation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just call it Rot or RotXYZ as the order doesn't matter anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also ok with XYZ16, as underscores are used in a different way in our function names, and this nane would clearly distinguish this function's signature from, say, TranslateRel which take individual components still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone with Matrix_RotXYZ16
, agreed it keeps it clear.
|
This uses the object's mesh count for reading the number of rotations per frame, although for TR1 we retain using what's defined in the frame.
This parses TR1 frame mesh rotations fully once on level load, which means we eliminate the need to pass packed values to matrix.c and have it extract the values on every call.
@aredfan Thanks, fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Kickass changes. Thank you.
Checklist
Description
This parses TR1 frame mesh rotations fully once on level load, which means we eliminate the need to pass packed values to
matrix.c
and have it extract the individual values on every call.I'm not sure if I like the name
Matrix_RotYXZ_16
. I can see potential though to changeMatrix_RotYXZ
's signature in a follow-up task to accept anXYZ_16
instead of the individual values.The extraction macros are a little more complex ready for TR2, as it won't always have two
int16_t
s so we can't cast toint32_t
and use the previous approach. Similarly, theM_ParseMeshRotation
function returns the number of values read because of what's to come with TR2.This also removes
nmeshes
fromANIM_FRAME
- now taken from the related object.