Merge branch 'transformfuncsforint' of https://github.com/HarbourMasters/SpaghettiKart into transformfuncsforint

This commit is contained in:
MegaMech
2025-05-21 21:02:50 -06:00
10 changed files with 116 additions and 64 deletions
-2
View File
@@ -1125,7 +1125,6 @@ void func_8001EE98(Player* player, Camera* camera, s8 index) {
break;
}
if (gIsGamePaused == 0) {
FrameInterpolation_ShouldInterpolateFrame(false);
switch (D_80152300[cameraIndex]) {
case 3:
func_8001A588(&D_80152300[cameraIndex], camera, player, index, cameraIndex);
@@ -1150,7 +1149,6 @@ void func_8001EE98(Player* player, Camera* camera, s8 index) {
func_8001EA0C(camera, player, index);
break;
}
FrameInterpolation_ShouldInterpolateFrame(true);
}
}
+6
View File
@@ -18,6 +18,7 @@
#include "code_80281C40.h"
#include "math_util.h"
#include <string.h>
#include "port/interpolation/FrameInterpolation.h"
#include "src/port/Game.h"
#include "engine/Matrix.h"
@@ -262,6 +263,9 @@ void render_fireworks(Vec3f arg0, f32 arg1, s32 rgb, s16 alpha) {
void firework_update(Firework* actor) {
s32 i;
Vec3f pos;
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("render_fireworks", (uintptr_t) actor);
if (actor->unk44 < 30) {
for (i = 0; i < 10; i++) {
pos[0] = actor->pos[0];
@@ -290,6 +294,8 @@ void firework_update(Firework* actor) {
}
}
actor->unk44 += 1;
// @port Pop the transform id.
FrameInterpolation_RecordCloseChild();
}
void unused_80280FA0(UNUSED CeremonyActor* actor) {
+30 -25
View File
@@ -23,7 +23,7 @@ OBat::OBat(const FVector& pos, const IRotator& rot) {
Name = "Bat";
find_unused_obj_index(&_objectIndex);
init_texture_object(_objectIndex, (uint8_t*)d_course_banshee_boardwalk_bat_tlut, sBoardwalkTexList, 0x20U,
init_texture_object(_objectIndex, (uint8_t*) d_course_banshee_boardwalk_bat_tlut, sBoardwalkTexList, 0x20U,
(u16) 0x00000040);
gObjectList[_objectIndex].orientation[0] = rot.pitch;
gObjectList[_objectIndex].orientation[1] = rot.roll;
@@ -102,59 +102,64 @@ void OBat::Tick() {
}
void OBat::Draw(s32 cameraId) {
s32 var_s2;
s32 objectIndex;
Camera* temp_s7;
s32 i;
s32 objectIndex = _objectIndex;
Camera* cam = &camera1[cameraId];
objectIndex = _objectIndex;
temp_s7 = &camera1[cameraId];
OBat::func_80046F60((u8*)gObjectList[objectIndex].activeTLUT, (u8*)gObjectList[objectIndex].activeTexture, 0x00000020, 0x00000040,
5);
OBat::func_80046F60((u8*) gObjectList[objectIndex].activeTLUT, (u8*) gObjectList[objectIndex].activeTexture,
0x00000020, 0x00000040, 5);
D_80183E80[0] = gObjectList[objectIndex].orientation[0];
D_80183E80[2] = gObjectList[objectIndex].orientation[2];
if ((D_8018CFB0 != 0) || (D_8018CFC8 != 0)) {
for (var_s2 = 0; var_s2 < 40; var_s2++) {
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("Bat set 1", var_s2);
objectIndex = gObjectParticle2[var_s2];
for (i = 0; i < 40; i++) {
objectIndex = gObjectParticle2[i];
if (objectIndex == -1) {
continue;
}
if ((gObjectList[objectIndex].state >= 2) && (gMatrixHudCount < 0x2EF)) {
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("Bat set 1", (uintptr_t) &gObjectList[objectIndex]);
D_80183E80[1] =
func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], temp_s7->pos);
func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], cam->pos);
func_800431B0(gObjectList[objectIndex].pos, D_80183E80, gObjectList[objectIndex].sizeScaling,
(Vtx*)D_0D0062B0);
(Vtx*) D_0D0062B0);
// @port Pop the transform id.
FrameInterpolation_RecordCloseChild();
}
// @port Pop the transform id.
FrameInterpolation_RecordCloseChild();
}
}
if ((D_8018CFE8 != 0) || (D_8018D000 != 0)) {
for (var_s2 = 0; var_s2 < 30; var_s2++) {
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("Bat set 2", var_s2);
objectIndex = gObjectParticle3[var_s2];
for (i = 0; i < 30; i++) {
objectIndex = gObjectParticle3[i];
if (objectIndex == -1) {
continue;
}
if ((gObjectList[objectIndex].state >= 2) && (gMatrixHudCount < 0x2EF)) {
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("Bat set 2", (uintptr_t) &gObjectList[objectIndex]);
D_80183E80[1] =
func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], temp_s7->pos);
func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], cam->pos);
func_800431B0(gObjectList[objectIndex].pos, D_80183E80, gObjectList[objectIndex].sizeScaling,
(Vtx*)D_0D0062B0);
(Vtx*) D_0D0062B0);
// @port Pop the transform id.
FrameInterpolation_RecordCloseChild();
}
// @port Pop the transform id.
FrameInterpolation_RecordCloseChild();
}
}
gSPTexture(gDisplayListHead++, 0x0001, 0x0001, 0, G_TX_RENDERTILE, G_OFF);
}
void OBat::func_80046F60(u8* tlut, u8* arg1, s32 arg2, s32 arg3, s32 arg4) {
gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D007D78);
gSPDisplayList(gDisplayListHead++, (Gfx*) D_0D007D78);
gDPLoadTLUT_pal256(gDisplayListHead++, tlut);
rsp_load_texture_mask(arg1, arg2, arg3, arg4);
}
+7 -4
View File
@@ -83,20 +83,23 @@ void OBoos::Draw(s32 cameraId) {
s32 objectIndex;
for (size_t i = 0; i < _numBoos; i++) {
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("Boo", i);
objectIndex = _indices[i]; //indexObjectList3[i];
if (gObjectList[objectIndex].state >= 2) {
temp_s2 = func_8008A364(objectIndex, cameraId, 0x4000U, 0x00000320);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_s2 = MIN(temp_s2, 0x15F91U);
}
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("Boo", (uintptr_t)&gObjectList[objectIndex]);
if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
func_800523B8(objectIndex, cameraId, temp_s2);
}
// @port Pop the transform id.
FrameInterpolation_RecordCloseChild();
}
// @port Pop the transform id.
FrameInterpolation_RecordCloseChild();
}
}
+3 -1
View File
@@ -323,6 +323,7 @@ void OMole::func_800821AC(s32 objectIndex, s32 arg1) {
}
}
// Holes
void OMole::func_80054E10(s32 objectIndex) {
if (gObjectList[objectIndex].state > 0) {
if (is_obj_flag_status_active(objectIndex, 0x00800000) != 0) {
@@ -362,7 +363,7 @@ void OMole::func_80054D00(s32 objectIndex, s32 cameraId) {
if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("func_80054D00", TAG_OBJECT(&gObjectList[objectIndex]));
FrameInterpolation_RecordOpenChild("func_80054D00", (uintptr_t)&gObjectList[objectIndex]);
D_80183E80[0] = (s16) gObjectList[objectIndex].orientation[0];
D_80183E80[1] =
@@ -378,6 +379,7 @@ void OMole::func_80054D00(s32 objectIndex, s32 cameraId) {
}
}
// Mole rocks
void OMole::func_80054F04(s32 cameraId) {
Camera* camera = &camera1[cameraId];
+1 -1
View File
@@ -65,7 +65,7 @@ void OTrashBin::Draw(s32 cameraId) {
Vec3s Rot = { 0, 0x4000, 0 };
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("Bin", mtx);
FrameInterpolation_RecordOpenChild("OTrashBin", (uintptr_t) object);
mtxf_pos_rotation_xyz(mtx, Pos, Rot);
//mtxf_scale(mtx, 1.0f);
+5
View File
@@ -1,6 +1,7 @@
#include "StarEmitter.h"
#include "port/interpolation/FrameInterpolation.h"
extern "C" {
#include "render_objects.h"
@@ -107,9 +108,13 @@ void StarEmitter::Draw(s32 cameraId) { // func_80054BE8
D_80183E80[0] = 0;
for (var_s0 = 0; var_s0 < gObjectParticle3_SIZE; var_s0++) {
temp_a0 = ObjectIndex[var_s0];
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("Ceremony Stars", (uintptr_t) &ObjectIndex[var_s0]);
if ((temp_a0 != -1) && (gObjectList[temp_a0].state >= 2)) {
StarEmitter::func_80054AFC(temp_a0, camera->pos);
}
// @port Pop the transform id.
FrameInterpolation_RecordCloseChild();
}
}
+40 -13
View File
@@ -690,13 +690,13 @@ UNUSED void func_800421FC(s32 x, s32 y, f32 scale) {
void func_80042330(s32 x, s32 y, u16 angle, f32 scale) {
Mat4 matrix;
//printf("panel %d %d %d\n", x, (s32)OTRGetDimensionFromLeftEdge(x), (s32)OTRGetDimensionFromLeftEdge(0));
// printf("panel %d %d %d\n", x, (s32)OTRGetDimensionFromLeftEdge(x), (s32)OTRGetDimensionFromLeftEdge(0));
if (gHUDModes != 2) {
if (x < (SCREEN_WIDTH / 2)) {
x = (s32)OTRGetDimensionFromLeftEdge(x);
x = (s32) OTRGetDimensionFromLeftEdge(x);
} else {
x = (s32)OTRGetDimensionFromRightEdge(x);
x = (s32) OTRGetDimensionFromRightEdge(x);
}
}
@@ -710,7 +710,7 @@ void func_80042330(s32 x, s32 y, u16 angle, f32 scale) {
void func_80042330_unchanged(s32 x, s32 y, u16 angle, f32 scale) {
Mat4 matrix;
//printf("panel %d %d %d\n", x, (s32)OTRGetDimensionFromLeftEdge(x), (s32)OTRGetDimensionFromLeftEdge(0));
// printf("panel %d %d %d\n", x, (s32)OTRGetDimensionFromLeftEdge(x), (s32)OTRGetDimensionFromLeftEdge(0));
mtxf_translation_x_y_rotate_z_scale_x_y(matrix, x, y, angle, scale);
// convert_to_fixed_point_matrix(&gGfxPool->mtxHud[gMatrixHudCount], matrix);
@@ -723,13 +723,13 @@ void func_80042330_unchanged(s32 x, s32 y, u16 angle, f32 scale) {
// Allows a different way of lining up the portraits at the end of race sequence
void func_80042330_portrait(s32 x, s32 y, u16 angle, f32 scale, s16 lapCount) {
Mat4 matrix;
//printf("panel %d %d %d\n", x, (s32)OTRGetDimensionFromLeftEdge(x), (s32)OTRGetDimensionFromLeftEdge(0));
// printf("panel %d %d %d\n", x, (s32)OTRGetDimensionFromLeftEdge(x), (s32)OTRGetDimensionFromLeftEdge(0));
if ((gHUDModes != 2) && (D_801657E2 == 0) || (CVarGetInteger("gImprovements", 0) == true)) {
if (x < (SCREEN_WIDTH / 2)) {
x = (s32)OTRGetDimensionFromLeftEdge(x);
x = (s32) OTRGetDimensionFromLeftEdge(x);
} else {
x = (s32)OTRGetDimensionFromRightEdge(x);
x = (s32) OTRGetDimensionFromRightEdge(x);
}
}
@@ -745,9 +745,9 @@ void func_80042330_wide(s32 x, s32 y, u16 angle, f32 scale) {
Mat4 matrix;
if (x < (SCREEN_WIDTH / 2)) {
x = (s32)OTRGetDimensionFromLeftEdge(x);
x = (s32) OTRGetDimensionFromLeftEdge(x);
} else {
x = (s32)OTRGetDimensionFromRightEdge(x);
x = (s32) OTRGetDimensionFromRightEdge(x);
}
mtxf_translation_x_y_rotate_z_scale_x_y(matrix, x, y, angle, scale);
@@ -808,8 +808,7 @@ UNUSED void func_8004252C(Mat4 arg0, u16 arg1, u16 arg2) {
arg0[2][2] = sp28 * cos_theta_y;
}
void mtxf_set_matrix_transformation(Mat4 transformMatrix, Vec3f location, Vec3su rotation,
f32 scale) {
void mtxf_set_matrix_transformation(Mat4 transformMatrix, Vec3f location, Vec3su rotation, f32 scale) {
FrameInterpolation_RecordSetMatrixTransformation(transformMatrix, location, rotation, scale);
f32 sinX = sins(rotation[0]);
@@ -864,7 +863,13 @@ void mtxf_set_matrix_scale_transl(Mat4 transformMatrix, Vec3f vec1, Vec3f vec2,
* @param arg1
**/
void mtxf_set_matrix_gObjectList(s32 objectIndex, Mat4 transformMatrix) {
struct ObjectInterpData2 {
s32 objectIndex;
f32 x, y;
};
struct ObjectInterpData2 prevObject2[OBJECT_LIST_SIZE] = { 0 };
s32 mtxf_set_matrix_gObjectList(s32 objectIndex, Mat4 transformMatrix) {
f32 sinX;
Object* object = &gObjectList[objectIndex];
f32 sinY;
@@ -896,6 +901,26 @@ void mtxf_set_matrix_gObjectList(s32 objectIndex, Mat4 transformMatrix) {
transformMatrix[1][3] = 0.0f;
transformMatrix[2][3] = 0.0f;
transformMatrix[3][3] = 1.0f;
// Search all recorded objects for the one we're drawing
for (int i = 0; i < OBJECT_LIST_SIZE; i++) {
if (objectIndex == prevObject2[i].objectIndex) {
// Coincidence!
// Skip drawing the object this frame if it warped to the other side of the screen
if ((fabsf(object->pos[0] - prevObject2[i].x) > 20) || (fabsf(object->pos[1] - prevObject2[i].y) > 20)) {
prevObject2[objectIndex].x = object->pos[0];
prevObject2[objectIndex].y = object->pos[1];
prevObject2[objectIndex].objectIndex = objectIndex;
// printf("IDX: %d X: %f Y: %f Z: %f\n", objectIndex, object->pos[0], object->pos[1], object->pos[2]);
return 1;
}
}
}
prevObject2[objectIndex].x = object->pos[0];
prevObject2[objectIndex].y = object->pos[1];
prevObject2[objectIndex].objectIndex = objectIndex;
return 0;
}
UNUSED void mtxf_mult_first_column(Mat4 arg0, f32 arg1) {
@@ -1065,7 +1090,9 @@ void rsp_set_matrix_transl_rot_scale(Vec3f arg0, Vec3f arg1, f32 arg2) {
void rsp_set_matrix_gObjectList(s32 transformIndex) {
Mat4 matrix;
mtxf_set_matrix_gObjectList(transformIndex, matrix);
if (mtxf_set_matrix_gObjectList(transformIndex, matrix)) {
return;
}
// convert_to_fixed_point_matrix(&gGfxPool->mtxHud[gMatrixHudCount], matrix);
// gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxHud[gMatrixHudCount++]),
+1 -1
View File
@@ -76,7 +76,7 @@ void func_80042330_portrait(s32, s32, u16, f32, s16);
void func_80042330_wide(s32, s32, u16, f32);
void mtxf_set_matrix_transformation(Mat4, Vec3f, Vec3su, f32);
void mtxf_set_matrix_scale_transl(Mat4, Vec3f, Vec3f, f32);
void mtxf_set_matrix_gObjectList(s32, Mat4);
s32 mtxf_set_matrix_gObjectList(s32, Mat4);
void set_transform_matrix(Mat4 dest, Vec3f orientationVector, Vec3f positionVector, u16 rotationAngle,
f32 scaleFactor);
void vec3f_rotate_x_y(Vec3f, Vec3f, Vec3s);
+23 -17
View File
@@ -2630,7 +2630,7 @@ void draw_simplified_lap_count(s32 playerId) {
void func_8004E800(s32 playerId) {
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("Player place HUD", playerId << 8);
FrameInterpolation_RecordOpenChild("Player place HUD", playerId);
if (playerHUD[playerId].unk_81 != 0) {
if (playerHUD[playerId].lapCount != 3) {
func_8004A384(playerHUD[playerId].rankX + playerHUD[playerId].slideRankX,
@@ -3453,23 +3453,24 @@ void render_object_snowflakes_particles(void) {
gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF);
}
struct CloudInterpData {
struct ObjectInterpData {
s32 objectIndex;
s16 x;
s16 x, y;
};
struct CloudInterpData prevClouds[OBJECT_LIST_SIZE] = { 0 };
struct ObjectInterpData prevObject[OBJECT_LIST_SIZE] = { 0 };
void func_800518F8(s32 objectIndex, s16 x, s16 y) {
// Search all recorded clouds for the one we're drawing
// Search all recorded objects for the one we're drawing
for (int i = 0; i < OBJECT_LIST_SIZE; i++) {
if (objectIndex == prevClouds[i].objectIndex) {
if (objectIndex == prevObject[i].objectIndex) {
// Coincidence!
// Skip drawing the cloud this frame if it warped to the other side of the screen
if (fabs(x - prevClouds[i].x) > SCREEN_WIDTH / 2) {
prevClouds[objectIndex].x = x;
prevClouds[objectIndex].objectIndex = objectIndex;
// Skip drawing the object this frame if it warped to the other side of the screen
if ((fabs(x - prevObject[i].x) > SCREEN_WIDTH / 2) || (fabs(y - prevObject[i].y) > SCREEN_HEIGHT / 2)) {
prevObject[objectIndex].x = x;
prevObject[objectIndex].y = y;
prevObject[objectIndex].objectIndex = objectIndex;
return;
}
}
@@ -3494,8 +3495,9 @@ void func_800518F8(s32 objectIndex, s16 x, s16 y) {
}
// Save current cloud index and x position
prevClouds[objectIndex].x = x;
prevClouds[objectIndex].objectIndex = objectIndex;
prevObject[objectIndex].x = x;
prevObject[objectIndex].y = y;
prevObject[objectIndex].objectIndex = objectIndex;
}
void func_800519D4(s32 objectIndex, s16 arg1, s16 arg2) {
@@ -3512,6 +3514,7 @@ void func_800519D4(s32 objectIndex, s16 arg1, s16 arg2) {
}
}
// Render clouds
void func_80051ABC(s16 arg0, s32 arg1) {
s32 var_s0;
s32 objectIndex;
@@ -3928,21 +3931,23 @@ void func_8005477C(s32 objectIndex, u8 arg1, Vec3f arg2) {
void render_object_smoke_particles(s32 cameraId) {
UNUSED s32 stackPadding[2];
Camera* sp54;
s32 var_s0;
s32 i;
s32 objectIndex;
Object* object;
sp54 = &camera1[cameraId];
FrameInterpolation_RecordOpenChild("SmokeParticles", TAG_OBJECT(sp54));
gSPDisplayList(gDisplayListHead++, D_0D007AE0);
load_texture_block_i8_nomirror(common_texture_particle_smoke[D_80165598], 32, 32);
func_8004B72C(255, 255, 255, 255, 255, 255, 255);
D_80183E80[0] = 0;
D_80183E80[2] = 0x8000;
for (var_s0 = 0; var_s0 < gObjectParticle4_SIZE; var_s0++) {
objectIndex = gObjectParticle4[var_s0];
for (i = 0; i < gObjectParticle4_SIZE; i++) {
objectIndex = gObjectParticle4[i];
if (objectIndex != NULL_OBJECT_ID) {
object = &gObjectList[objectIndex];
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("SmokeParticles", (uintptr_t) object);
if (object->state >= 2) {
if (object->unk_0D8 == 3) {
func_8008A364(objectIndex, cameraId, 0x4000U, 0x00000514);
@@ -3953,9 +3958,10 @@ void render_object_smoke_particles(s32 cameraId) {
func_8005477C(objectIndex, object->unk_0D8, sp54->pos);
}
}
// @port Pop the transform id.
FrameInterpolation_RecordCloseChild();
}
}
FrameInterpolation_RecordCloseChild();
}
UNUSED void func_800557AC() {