Only use simple interpolation on models that use bones. (#23)

* Only push new matrices and simple interpolation on models that use bones.

* Rework patch.

* Update comment.

* Fix typo.
This commit is contained in:
Darío
2025-12-26 14:37:33 -03:00
committed by GitHub
parent a321fad91c
commit 7e7d5d4907
2 changed files with 23 additions and 8 deletions
+4 -1
View File
@@ -62,7 +62,7 @@ void osWriteBackDCacheAll(void);
#define gEXMatrixGroupSimpleVerts(cmd, id, push, proj, edit) \
gEXMatrixGroup(cmd, id, G_EX_INTERPOLATE_SIMPLE, push, proj, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR, edit, G_EX_ASPECT_AUTO, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_AUTO)
#define gEXMatrixGroupSimpleVertsNoRotation(cmd, id, push, proj, edit) \
#define gEXMatrixGroupSimpleVertsSkipRot(cmd, id, push, proj, edit) \
gEXMatrixGroup(cmd, id, G_EX_INTERPOLATE_SIMPLE, push, proj, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR, edit, G_EX_ASPECT_AUTO, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_AUTO)
#define gEXMatrixGroupDecomposedNormal(cmd, id, push, proj, edit) \
@@ -77,6 +77,9 @@ void osWriteBackDCacheAll(void);
#define gEXMatrixGroupDecomposedVerts(cmd, id, push, proj, edit) \
gEXMatrixGroupDecomposed(cmd, id, push, proj, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR, edit, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_AUTO)
#define gEXMatrixGroupDecomposedVertsSkipRot(cmd, id, push, proj, edit) \
gEXMatrixGroupDecomposed(cmd, id, push, proj, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR, edit, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_AUTO)
#define gEXMatrixGroupDecomposedVertsOrderAuto(cmd, id, push, proj, edit) \
gEXMatrixGroupDecomposed(cmd, id, push, proj, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_AUTO, edit, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_AUTO)
+19 -7
View File
@@ -31,6 +31,7 @@ s32 cur_drawn_model_is_map = FALSE;
s32 cur_drawn_model_transform_id = 0;
s32 cur_drawn_model_transform_id_skip_interpolation = FALSE;
s32 cur_model_transform_id_offset = 0;
s32 cur_model_uses_bones = FALSE;
Mtx identity_fixed_mtx = {{
{
@@ -207,15 +208,24 @@ bool set_model_matrix_group(Gfx **gfx, void *geo_list, bool skip_rotation) {
// Skip interpolation if all interpolation is currently skipped or the transform was specified to be skipped.
gEXMatrixGroupSkipAll((*gfx)++, group_id, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE);
}
else {
// Tag the matrix.
else if (cur_model_uses_bones) {
// Tag the matrix with simple matrix interpolation if the model uses bones.
if (skip_rotation) {
gEXMatrixGroupSimpleVertsNoRotation((*gfx)++, group_id, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE);
gEXMatrixGroupSimpleVertsSkipRot((*gfx)++, group_id, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE);
}
else {
gEXMatrixGroupSimpleVerts((*gfx)++, group_id, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE);
}
}
else {
// Tag the matrix with decomposed matrix interpolation on any other model.
if (skip_rotation) {
gEXMatrixGroupDecomposedVertsSkipRot((*gfx)++, group_id, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE);
}
else {
gEXMatrixGroupDecomposedVerts((*gfx)++, group_id, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE);
}
}
return TRUE;
}
else if (skip_all_interpolation) {
@@ -231,14 +241,14 @@ void pop_model_matrix_group(Gfx **gfx) {
gEXPopMatrixGroup((*gfx)++, G_MTX_MODELVIEW);
}
// @recomp Patched to multiply the identity matrix to create a new matrix group and count up if drawing a map model.
// @recomp Patched to multiply the identity matrix and create a new matrix group for each display list.
RECOMP_PATCH void func_80338904(Gfx **gfx, Mtx **mtx, void *arg2){
GeoCmd3 *cmd = (GeoCmd3 *)arg2;
Gfx *vptr;
if(D_80370990){
bool pushed_matrix_group = FALSE;
// @recomp Create a new matrix by multiplying in the identity matrix.
bool pushed_matrix_group = FALSE;
gSPMatrix((*gfx)++, &identity_fixed_mtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
pushed_matrix_group = set_model_matrix_group(gfx, arg2, FALSE);
@@ -258,8 +268,9 @@ RECOMP_PATCH void func_803387F8(Gfx **gfx, Mtx **mtx, void *arg2){
GeoCmd2 *cmd = (GeoCmd2 *)arg2;
bool pushed_matrix_group = FALSE;
// @recomp Increment the transform ID offset when encountering a bone command.
// @recomp Increment the transform ID offset when encountering a bone command and set the flag.
cur_model_transform_id_offset++;
cur_model_uses_bones = TRUE;
if(D_8038371C){
mlMtx_push_multiplied_2(&D_80383BF8, animMtxList_get(D_8038371C, cmd->unk9));
@@ -731,8 +742,9 @@ RECOMP_PATCH BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3],
// @recomp Disable frustum checks before processing bones.
set_frustum_checks_enabled(FALSE);
// @recomp Reset the transform ID offset.
// @recomp Reset the transform ID offset and the bones flag.
cur_model_transform_id_offset = 0;
cur_model_uses_bones = FALSE;
func_80339124(gfx, mtx, (BKGeoList *)((u8 *)model_bin + model_bin->geo_list_offset_4));