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

VFPU: Ensure that sin(4*x) returns 0.0 (and cos 1) for all x. Fixes #2921 #6329

Merged
merged 2 commits into from
Jun 15, 2014

Conversation

hrydgard
Copy link
Owner

This also makes it easier to replace our VFPU sin/cos implementations with some approximation later.

Note that our sinf/cosf function replacements should not call these, they are expected to behave like libc sinf/cosf, I would think.

Fixes #2921

@solarmystic
Copy link
Contributor

Was just perusing the comments in #2921, and that was some fine investigative work that led to the solution by @unknownbrackets (even if I didn't understand most of it, was not a math major in college, heh.)

Just wanted to point that out.

@hrydgard
Copy link
Owner Author

Ah yes, sorry :) I did compliment unknown on his work in the thread though :)

@daniel229
Copy link
Collaborator

cause logic problem in Saint Seiya Omega.
the NPC always runs to the opposite directions
06

angle -= floorf(angle * 4.0f) * 0.25f;
angle *= (float)M_PI_2;
sine = sinf(angle);
cosine = cosf(angle);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Android has sincosf() these days (latest ndks) right? Though not sure what our build req is.

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

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

Is the buildbot upgraded to the latest?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Last I checked it seemed to have ndk-r9b, from October 2013.

https://code.google.com/p/android/issues/detail?id=38423
Was marked "released" October 31, 2013. Not sure if that means it's in b or c...

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

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

I think it didn't actually make it until d, but not sure. Maybe c. Pretty sure not b.

@daniel229
Copy link
Collaborator

also bug in tekken 6
07

}

inline void vfpu_sincos(float angle, float &sine, float &cosine) {
angle -= floorf(angle * 4.0f) * 0.25f;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, not sure this is rounding right?

Angle 1 = 1_pi/2 = sin=1,cos=0
Angle 2 = 2_pi/2 = sin=0,cos=-1
Angle 3 = 3_pi/2 = sin=-1,cos=0
Angle 4 = 4_pi/2 = sin=0,cos=1

However, 3 - floor(3 * 4) * 0.25 = 3 - 12 * 0.25 = 0. Should be * 0.25 / 4, right?

-[Unknown]

@hrydgard
Copy link
Owner Author

Hmm, oops. Logic shortcircuit in my brain, heh. Will fix.

@daniel229
Copy link
Collaborator

Problems have been fixed.

hrydgard added a commit that referenced this pull request Jun 15, 2014
VFPU: Ensure that sin(4*x) returns 0.0 (and cos 1) for all x. Fixes #2921
@hrydgard hrydgard merged commit a325049 into master Jun 15, 2014
@hrydgard hrydgard deleted the vfpu-sincos branch June 15, 2014 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Final Fantasy III and lines problems
4 participants