Some interpolation fixes

This commit is contained in:
KiritoDv
2026-01-07 14:10:07 -06:00
parent 599c127adb
commit 9cf7439b78
6 changed files with 22 additions and 5 deletions
+1
View File
@@ -92,6 +92,7 @@ struct GraphNodeRoot {
/*0x1C*/ s16 height; // half height
/*0x1E*/ s16 numViews; // number of entries in mystery array
/*0x20*/ struct GraphNode **views;
u64 nodeId;
};
/** A node that sets up an orthographic projection based on the global
+1 -1
View File
@@ -185,7 +185,7 @@ void mtxf_identity(Mat4 mtx) {
*/
void mtxf_translate(Mat4 dest, Vec3f b) {
// TODO: FrameInterpolation is broken, fix it
// FrameInterpolation_RecordMatrixTranslate(dest, b);
FrameInterpolation_RecordMatrixTranslate(dest, b);
mtxf_identity(dest);
dest[3][0] = b[0];
dest[3][1] = b[1];
+3 -1
View File
@@ -28,6 +28,7 @@
#include "paintings.h"
#include "engine/graph_node.h"
#include "level_table.h"
#include "port/interpolation/FrameInterpolation.h"
#define CBUTTON_MASK (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS)
@@ -3510,11 +3511,12 @@ void create_camera(struct GraphNodeCamera *gc, struct AllocOnlyPool *pool) {
void update_graph_node_camera(struct GraphNodeCamera *gc) {
UNUSED u8 filler[8];
UNUSED struct Camera *c = gc->config.camera;
FrameInterpolation_ShouldInterpolateFrame(sFramesPaused == 0);
gc->rollScreen = gLakituState.roll;
vec3f_copy(gc->pos, gLakituState.pos);
vec3f_copy(gc->focus, gLakituState.focus);
zoom_out_if_paused_and_outside(gc);
FrameInterpolation_ShouldInterpolateFrame(true);
}
Gfx *geo_camera_main(s32 callContext, struct GraphNode *g, void *context) {
+2 -2
View File
@@ -364,7 +364,7 @@ static void geo_process_translation_rotation(struct GraphNodeTranslationRotation
Mat4 mtxf;
Vec3f translation;
Mtx *mtx = alloc_display_list(sizeof(*mtx));
FrameInterpolation_RecordOpenChild("geo_process_translation_rotation", (uintptr_t)node);
FrameInterpolation_RecordOpenChild("geo_process_translation_rotation", TAG_OBJECT(node));
vec3s_to_vec3f(translation, node->translation);
mtxf_rotate_zxy_and_translate(mtxf, translation, node->rotation);
@@ -1102,7 +1102,7 @@ void geo_process_root(struct GraphNodeRoot *node, Vp *b, Vp *c, s32 clearColor)
UNUSED s32 unused;
if (node->node.flags & GRAPH_RENDER_ACTIVE) {
FrameInterpolation_RecordOpenChild("geo_process_root", (uintptr_t)node);
FrameInterpolation_RecordOpenChild("geo_process_root", (uintptr_t)node->nodeId);
Mtx *initialMatrix;
Vp *viewport = alloc_display_list(sizeof(*viewport));
+7
View File
@@ -288,6 +288,12 @@ void process_cmd_update_node_flags() {
}
}
uint64_t generate_uuid64() {
uint64_t high = rand();
uint64_t low = rand();
return (high << 32) | low;
}
void process_cmd_node_root() {
gGeoNumViews = GeoLayoutParser::mReader->ReadInt16() + 2;
const auto x = GeoLayoutParser::mReader->ReadInt16();
@@ -299,6 +305,7 @@ void process_cmd_node_root() {
gGeoViews = static_cast<GraphNode**>(alloc_only_pool_alloc(gGraphNodePool, gGeoNumViews * sizeof(GraphNode *)));
graphNode->nodeId = generate_uuid64();
graphNode->views = gGeoViews;
graphNode->numViews = gGeoNumViews;
@@ -297,6 +297,13 @@ struct InterpolateCtx {
}
}
void translate_mtxf(Mat4 dest, Vec3f b) {
mtxf_identity(dest);
dest[3][0] = b[0];
dest[3][1] = b[1];
dest[3][2] = b[2];
}
float lerp(f32 o, f32 n) {
return w * o + step * n;
}
@@ -436,7 +443,7 @@ struct InterpolateCtx {
temp[1] = lerp(old_op.matrix_translate.b.y, new_op.matrix_translate.b.y);
temp[2] = lerp(old_op.matrix_translate.b.z, new_op.matrix_translate.b.z);
mtxf_translate(*gInterpolationMatrix, temp);
translate_mtxf(*gInterpolationMatrix, temp);
break;
case Op::MatrixPosRotXYZ: {
Vec3f tempF;