Merge branch 'master' into simd-3

This commit is contained in:
Recep Aslantas
2021-05-07 14:08:56 +03:00
committed by GitHub
8 changed files with 108 additions and 2 deletions

View File

@@ -116,11 +116,15 @@ glmc_quat_mat3t(versor q, mat3 dest);
CGLM_EXPORT
void
glmc_quat_lerp(versor from, versor to, float t, versor dest);
CGLM_EXPORT
void
glmc_quat_lerpc(versor from, versor to, float t, versor dest);
CGLM_EXPORT
void
glmc_quat_nlerp(versor q, versor r, float t, versor dest);
CGLM_EXPORT
void
glmc_quat_slerp(versor q, versor r, float t, versor dest);

View File

@@ -99,7 +99,7 @@ glmc_vec4_scale(vec4 v, float s, vec4 dest);
CGLM_EXPORT
void
glmc_vec4_scale_as(vec3 v, float s, vec3 dest);
glmc_vec4_scale_as(vec4 v, float s, vec4 dest);
CGLM_EXPORT
void

View File

@@ -38,6 +38,7 @@
CGLM_INLINE void glm_quat_lerp(versor from, versor to, float t, versor dest);
CGLM_INLINE void glm_quat_lerpc(versor from, versor to, float t, versor dest);
CGLM_INLINE void glm_quat_slerp(versor q, versor r, float t, versor dest);
CGLM_INLINE void glm_quat_nlerp(versor q, versor r, float t, versor dest);
CGLM_INLINE void glm_quat_look(vec3 eye, versor ori, mat4 dest);
CGLM_INLINE void glm_quat_for(vec3 dir, vec3 fwd, vec3 up, versor dest);
CGLM_INLINE void glm_quat_forp(vec3 from,
@@ -628,6 +629,26 @@ glm_quat_lerpc(versor from, versor to, float t, versor dest) {
glm_vec4_lerpc(from, to, t, dest);
}
/*!
* @brief interpolates between two quaternions
* taking the shortest rotation path using
* normalized linear interpolation (NLERP)
*
* @param[in] from from
* @param[in] to to
* @param[in] t interpolant (amount)
* @param[out] dest result quaternion
*/
CGLM_INLINE
void
glm_quat_nlerp(versor from, versor to, float t, versor dest) {
float dot = glm_vec4_dot(from, to);
versor target;
glm_vec4_scale(to, (dot >= 0) ? 1 : -1, target);
glm_quat_lerp(from, target, t, dest);
glm_quat_normalize(dest);
}
/*!
* @brief interpolates between two quaternions
* using spherical linear interpolation (SLERP)

View File

@@ -34,6 +34,7 @@
CGLM_INLINE mat3s glms_quat_mat3t(versors q)
CGLM_INLINE versors glms_quat_lerp(versors from, versors to, float t)
CGLM_INLINE versors glms_quat_lerpc(versors from, versors to, float t)
CGLM_INLINE versors glms_quat_nlerp(versors from, versors to, float t)
CGLM_INLINE versors glms_quat_slerp(versors from, versors to, float t)
CGLM_INLINE mat4s. glms_quat_look(vec3s eye, versors ori)
CGLM_INLINE versors glms_quat_for(vec3s dir, vec3s fwd, vec3s up)
@@ -401,6 +402,24 @@ glms_quat_lerpc(versors from, versors to, float t) {
return dest;
}
/*!
* @brief interpolates between two quaternions
* taking the shortest rotation path using
* normalized linear interpolation (NLERP)
*
* @param[in] from from
* @param[in] to to
* @param[in] t interpolant (amount)
* @param[out] dest result quaternion
*/
CGLM_INLINE
versors
glms_quat_nlerp(versors from, versors to, float t) {
versors dest;
glm_quat_nlerp(from.raw, to.raw, t, dest.raw);
return dest;
}
/*!
* @brief interpolates between two quaternions
* using spherical linear interpolation (SLERP)