evas: Update eina_vector, add new function.

Summary: Add direction transform for eina_vector3.

Reviewers: cedric, Hermet, jpeg

Reviewed By: jpeg

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D3692
This commit is contained in:
se.osadchy 2016-02-17 14:14:24 +09:00 committed by Jean-Philippe Andre
parent 7940a6d9a5
commit a1584c8a5d
3 changed files with 29 additions and 0 deletions

View File

@ -282,6 +282,20 @@ eina_vector3_transform(Eina_Vector3 *out, const Eina_Matrix3 *m, const Eina_Vec
out->z = (m->xz * v->x) + (m->yz * v->y) + (m->zz * v->z);
}
static inline void
eina_vector3_homogeneous_direction_transform(Eina_Vector3 *out, const Eina_Matrix4 *m, const Eina_Vector3 *v)
{
if (eina_matrix4_type_get(m) == EINA_MATRIX_TYPE_IDENTITY)
{
eina_vector3_copy(out, v);
return;
}
out->x = (m->xx * v->x) + (m->yx * v->y) + (m->zx * v->z);
out->y = (m->xy * v->x) + (m->yy * v->y) + (m->zy * v->z);
out->z = (m->xz * v->x) + (m->yz * v->y) + (m->zz * v->z);
}
static inline void
eina_vector3_homogeneous_position_transform(Eina_Vector3 *out, const Eina_Matrix4 *m,
const Eina_Vector3 *v)

View File

@ -423,6 +423,18 @@ static inline void eina_vector3_normalize(Eina_Vector3 *out, const Eina_Vector3
static inline void eina_vector3_transform(Eina_Vector3 *out, const Eina_Matrix3 *m,
const Eina_Vector3 *v);
/**
* @brief Homogeneous direction transform vector.
*
* @param out The resulting vector.
* @param m The matrix for transform.
* @param v The vector for transform.
*
* @since 1.18
*/
static inline void eina_vector3_homogeneous_direction_transform(Eina_Vector3 *out, const Eina_Matrix4 *m,
const Eina_Vector3 *v);
/**
* @brief Homogeneous position transform vector.
*

View File

@ -217,6 +217,9 @@ START_TEST(eina_test_vector3_operations)
&v1, &v2, &v3);
fail_if(res2 != EINA_TRUE);
eina_vector3_homogeneous_direction_transform(&v3, &m4, &v1);
fail_if((v3.x != 12) || (v3.y != 12) || (v3.z != 12));
eina_shutdown();
}
END_TEST