Allow users to select between accurate or fast interpolations

This commit is contained in:
MysterD 2022-05-21 21:47:53 -07:00
parent ac6ce708c3
commit f5e245590f
6 changed files with 20 additions and 36 deletions

View File

@ -351,7 +351,7 @@ static void geo_process_master_list_sub(struct GraphNodeMasterList *node) {
if ((currList = node->listHeads[i]) != NULL) {
gDPSetRenderMode(gDisplayListHead++, modeList->modes[i], mode2List->modes[i]);
while (currList != NULL) {
//detect_and_skip_mtx_interpolation(&currList->transform, &currList->transformPrev);
detect_and_skip_mtx_interpolation(&currList->transform, &currList->transformPrev);
if ((u32) gMtxTblSize < sizeof(gMtxTbl) / sizeof(gMtxTbl[0])) {
gMtxTbl[gMtxTblSize].pos = gDisplayListHead;
gMtxTbl[gMtxTblSize].mtx = currList->transform;

View File

@ -138,6 +138,7 @@ unsigned int configFrameLimit = 60;
unsigned int configDrawDistance = 5;
bool configDisablePopups = 0;
bool configDisableDownloadedModels = 0;
unsigned int configInterpolationMode = 1;
static const struct ConfigOption options[] = {
{.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configWindow.fullscreen},
@ -218,6 +219,7 @@ static const struct ConfigOption options[] = {
{.name = "share_lives", .type = CONFIG_TYPE_BOOL , .boolValue = &configShareLives},
{.name = "disable_popups", .type = CONFIG_TYPE_BOOL , .boolValue = &configDisablePopups},
{.name = "disable_downloaded_models", .type = CONFIG_TYPE_BOOL , .boolValue = &configDisableDownloadedModels},
{.name = "interpolation_mode", .type = CONFIG_TYPE_UINT , .uintValue = &configInterpolationMode}
};
// FunctionConfigOption functions

View File

@ -92,6 +92,7 @@ extern unsigned int configFrameLimit;
extern unsigned int configDrawDistance;
extern bool configDisablePopups;
extern bool configDisableDownloadedModels;
extern unsigned int configInterpolationMode;
void configfile_load(const char *filename);
void configfile_save(const char *filename);

View File

@ -61,10 +61,6 @@ void djui_panel_display_create(struct DjuiBase* caller) {
djui_base_set_size_type(&checkbox5->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox5->base, 1.0f, 32);
struct DjuiCheckbox* checkbox6 = djui_checkbox_create(&body->base, "Disable Downloaded Models", &configDisableDownloadedModels);
djui_base_set_size_type(&checkbox6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox6->base, 1.0f, 32);
#ifdef EXTERNAL_DATA
struct DjuiCheckbox* checkbox7 = djui_checkbox_create(&body->base, "Preload Textures", &configPrecacheRes);
djui_base_set_size_type(&checkbox7->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
@ -106,11 +102,16 @@ void djui_panel_display_create(struct DjuiBase* caller) {
sFrameLimitInput = inputbox1;
}
char* filterChoices[3] = { "Nearest", "Linear", "Tripoint" };
struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(&body->base, "Filtering", filterChoices, 3, &configFiltering);
char* interpChoices[2] = { "Fast", "Accurate" };
struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(&body->base, "Interpolation", interpChoices, 2, &configInterpolationMode);
djui_base_set_size_type(&selectionbox1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&selectionbox1->base, 1.0f, 32);
char* filterChoices[3] = { "Nearest", "Linear", "Tripoint" };
struct DjuiSelectionbox* selectionbox2 = djui_selectionbox_create(&body->base, "Filtering", filterChoices, 3, &configFiltering);
djui_base_set_size_type(&selectionbox2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&selectionbox2->base, 1.0f, 32);
char* drawDistanceChoices[6] = { "0.5x", "1x", "1.5x", "3x", "10x", "100x" };
struct DjuiSelectionbox* selectionbox3 = djui_selectionbox_create(&body->base, "Draw Distance", drawDistanceChoices, 6, &configDrawDistance);
djui_base_set_size_type(&selectionbox3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);

View File

@ -11,6 +11,7 @@
#include "game/level_update.h"
#include "game/save_file.h"
#include "engine/math_util.h"
#include "pc/configfile.h"
float smoothstep(float edge0, float edge1, float x) {
float t = (x - edge0) / (edge1 - edge0);
@ -117,7 +118,6 @@ next_get:
/////////////////
/*
static f32 sm64_to_radians(f32 val) {
return val * M_PI / 0x8000;
}
@ -474,7 +474,7 @@ static void rematrix(Mtx * mat, f32 tranfs[13]) {
}
}
void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta) {
void delta_interpolate_mtx_accurate(Mtx* out, Mtx* a, Mtx* b, f32 delta) {
register int i;
f32 matTranfsA[13], matTranfsB[13];
@ -496,31 +496,12 @@ void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta) {
rematrix(out, matTranfsB);
}
/*
static s16 delta_interpolate_angle(s16 a, s16 b, f32 delta) {
s32 absDiff = b - a;
if (absDiff < 0) {
absDiff = -absDiff;
}
if (absDiff >= 0x4000 && absDiff <= 0xC000) {
return b;
}
f32 antiDelta = 1.0f - delta;
if (absDiff <= 0x8000) {
return (a * antiDelta) + (b * delta);
} else {
return (a * antiDelta) + (b * delta) + 0x8000;
}
}
static void delta_interpolate_angles(Vec3s res, Vec3s a, Vec3s b, f32 delta) {
res[0] = delta_interpolate_angle(a[0], b[0], delta);
res[1] = delta_interpolate_angle(a[1], b[1], delta);
res[2] = delta_interpolate_angle(a[2], b[2], delta);
}
void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta) {
if (configInterpolationMode) {
delta_interpolate_mtx_accurate(out, a, b, delta);
return;
}
// this isn't the right way to do things.
f32 antiDelta = 1.0f - delta;
for (s32 i = 0; i < 4; i++) {
@ -545,8 +526,7 @@ void detect_and_skip_mtx_interpolation(Mtx** mtxPrev, Mtx** mtx) {
f32 dotY = vec3f_dot(prevY, nextY);
f32 dotZ = vec3f_dot(prevZ, nextZ);
if ((dotX < minDot) | (dotY < minDot) || (dotZ < minDot)) {
if ((dotX < minDot) || (dotY < minDot) || (dotZ < minDot)) {
*mtx = *mtxPrev;
}
}
*/

View File

@ -21,6 +21,6 @@ void delta_interpolate_vec3s(Vec3s res, Vec3s a, Vec3s b, f32 delta);
void delta_interpolate_normal(s8* res, s8* a, s8* b, f32 delta);
void delta_interpolate_rgba(u8* res, u8* a, u8* b, f32 delta);
void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta);
//void detect_and_skip_mtx_interpolation(Mtx** mtxPrev, Mtx** mtx);
void detect_and_skip_mtx_interpolation(Mtx** mtxPrev, Mtx** mtx);
#endif