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

incorrect axis rotation in gfc_matrix4_from_vectors and gfc_vector3d_angle_vectors2 #221

Open
JoshDunn88 opened this issue Dec 17, 2024 · 0 comments

Comments

@JoshDunn88
Copy link

JoshDunn88 commented Dec 17, 2024

When trying to use axis rotation input for gfc_matrix4_from_vectors, I found that the x rotation input labeled "about the x axis" was actually rotating the model about the y axis, and vice versa. Simply creating a new vector to input with the swapped values fixed this.

The same applied for getting gfc_vector3d_angle_vectors2 to work as intended, along with some additional modification. I had to duplicate the function (so as to not modify gfc) and swapped the x and y angle calculations within the function (to avoid having to swap them on the input). I also found that in this function, the right and forward vectors were swapped, and some of the code required sign changes. The modified portion is this:
...
angle = angles.y;
sp = sinf(angle);
cp = cosf(angle);
angle = angles.x;
sr = sinf(angle);
cr = cosf(angle);

if (forward)
{
forward->x = (-1 * sr * sp * cy + -1 * cr * -sy);
forward->y = (-1 * sr * sp * sy + -1 * cr * cy);
forward->z = -1 * sr * cp;
}
if (right)
{
right->x = -1 * cp * cy;
right->y = -1 * cp * sy;
right->z = sp;
}
if (up)
{
up->x = (cr * sp * cy + -sr * -sy);
up->y = (cr * sp * sy + -sr * cy);
up->z = cr * cp;
}

Note: These issues arose from my experience only, I have not verified if anyone else experienced these issues. I submitted this as a gf3d issue since they're more easily tested in gf3d despite being a part of gfc.

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

No branches or pull requests

1 participant