Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/t3d/t3dmath.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,10 @@ void t3d_mat4_from_srt(T3DMat4 *mat, const float scale[3], const float quat[4],

void t3d_mat4_from_srt_euler(T3DMat4 *mat, const float scale[3], const float rot[3], const float translate[3])
{
float cosR0 = fm_cosf(rot[0]);
float cosR2 = fm_cosf(rot[2]);
float cosR1 = fm_cosf(rot[1]);

float sinR0 = fm_sinf(rot[0]);
float sinR1 = fm_sinf(rot[1]);
float sinR2 = fm_sinf(rot[2]);
float sinR0, sinR1, sinR2, cosR0, cosR1, cosR2;
fm_sincosf(rot[0], &sinR0, &cosR0);
fm_sincosf(rot[1], &sinR1, &cosR1);
fm_sincosf(rot[2], &sinR2, &cosR2);

*mat = (T3DMat4){{
{scale[0] * cosR2 * cosR1, scale[0] * (cosR2 * sinR1 * sinR0 - sinR2 * cosR0), scale[0] * (cosR2 * sinR1 * cosR0 + sinR2 * sinR0), 0.0f},
Expand Down Expand Up @@ -290,10 +287,7 @@ void t3d_mat4fp_from_srt(T3DMat4FP *mat, const float scale[3], const float rotQu
void t3d_mat4_rotate(T3DMat4 *mat, const T3DVec3* axis, float angleRad)
{
float s, c;
// @TODO: currently buggy in libdragon, use once fixed
// fm_sincosf(angleRad, &s, &c);
s = fm_sinf(angleRad);
c = fm_cosf(angleRad);
fm_sincosf(angleRad, &s, &c);

float t = 1.0f - c;

Expand Down
14 changes: 6 additions & 8 deletions src/t3d/t3dmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@ inline static void t3d_quat_identity(T3DQuat *quat) {
*/
inline static void t3d_quat_from_euler(T3DQuat *quat, const float rotEuler[3])
{
float c1 = fm_cosf(rotEuler[0] / 2.0f);
float s1 = fm_sinf(rotEuler[0] / 2.0f);
float c2 = fm_cosf(rotEuler[1] / 2.0f);
float s2 = fm_sinf(rotEuler[1] / 2.0f);
float c3 = fm_cosf(rotEuler[2] / 2.0f);
float s3 = fm_sinf(rotEuler[2] / 2.0f);
float c1, c2, c3, s1, s2, s3;
fm_sincosf(rotEuler[0] / 2.0f, &s1, &c1);
fm_sincosf(rotEuler[1] / 2.0f, &s2, &c2);
fm_sincosf(rotEuler[2] / 2.0f, &s3, &c3);

quat->v[0] = c1 * c2 * s3 - s1 * s2 * c3;
quat->v[1] = s1 * c2 * c3 - c1 * s2 * s3;
Expand All @@ -174,8 +172,8 @@ inline static void t3d_quat_from_euler(T3DQuat *quat, const float rotEuler[3])
*/
inline static void t3d_quat_from_rotation(T3DQuat *quat, float axis[3], float angleRad)
{
float s = fm_sinf(angleRad / 2.0f);
float c = fm_cosf(angleRad / 2.0f);
float s, c;
fm_sincosf(angleRad / 2.0f, &s, &c);
*quat = (T3DQuat){{axis[0] * s, axis[1] * s, axis[2] * s, c}};
}

Expand Down