Skip to content
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

Use Kaze's folded polynomials #64

Open
wants to merge 7 commits into
base: develop/1.0.0
Choose a base branch
from

Conversation

ariahiro64
Copy link
Collaborator

@ariahiro64 ariahiro64 commented Sep 11, 2023

this uses Kaze Emuar's "folded polynomial" sine and cosine functions. it works by calculating a small section of the polynomial and mirrors it for the rest. this not only saves ram but seems faster than the lookup table.

Edit: forgot to mention this vastly improves animation quality.

@ariahiro64 ariahiro64 added the needs testing The pull request needs to be tested to make sure it works properly label Sep 11, 2023
Copy link
Collaborator

@Yanis002 Yanis002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand a lot how this is working (I'm bad at maths) but here we are

include/config/config_game.h Outdated Show resolved Hide resolved

#ifdef DISABLE_LOOKUP_TABLE

#define ONE 1.0f
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using a macro for this? it looks weird to me 🤔 (the ONE one)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i thought i would need to do the function twice and forgot

include/macros.h Show resolved Hide resolved
src/code/z_lib.c Outdated Show resolved Hide resolved
@Yanis002
Copy link
Collaborator

it would be nice if we're implementing more optimisation stuff like this, also you should change the target of the PR to dev

should I make dev the default branch and rename master to something like "release"? idk if this would break something (I'll probably do it after all opened PRs targeting master are merged if everyone agrees on that idea)

@ariahiro64 ariahiro64 changed the base branch from master to dev September 11, 2023 19:01
Copy link
Collaborator

@Yanis002 Yanis002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll approve as soon as I test this

@ariahiro64
Copy link
Collaborator Author

should be good for testing

@Yanis002
Copy link
Collaborator

I already said this on discord but I'm writing it here just for history purposes, the camera is acting weird so I'll wait until this is fixed

Copy link
Collaborator

@Yanis002 Yanis002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the camera is still acting weird

@@ -9,6 +9,9 @@
// Disables AA (Improves console performance but causes visible seams between unconnected geometry).
//#define DISABLE_AA

// Use a folded polynomial instead of a lookup table. This has a speed boots and makes the calculation more precise.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boots

/**
* @param angle binang
* @return sin(angle)*0x7FFF
*/
s16 sins(u16 angle) {
#ifdef DISABLE_SIN_COS_LOOKUP_TABLE
return Math_SinS(angle) * 0x7FFF;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function isn't declared (just add #include "functions.h") and it returns a f32, not s16, I feel like we should add a cast here (same comment for coss for the cast)

@Yanis002 Yanis002 changed the title use_kazes_folded_polynomial Use Kaze's folded polynomials Sep 12, 2023
@Yanis002 Yanis002 added the 1.0 The PR targets HackerOoT v1.0 label Sep 12, 2023
@Yanis002 Yanis002 added the help wanted Extra attention is needed label Oct 13, 2023
@ariahiro64
Copy link
Collaborator Author

farores wind crashes

@ariahiro64
Copy link
Collaborator Author

so ive been looking into this
the issues we are having is due to the lookup table snapping where the snapping is causing unhanded behavior based on nintendo just not anticipating it. this also effects controls. we need discussions on whether its actually important to address this or make the user do it as its only slightly harmful to certain camera cases that would require heavy fixes and possible rewrite. this would make syncing difficult for little pay off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 The PR targets HackerOoT v1.0 help wanted Extra attention is needed needs testing The pull request needs to be tested to make sure it works properly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants