m: Generalize math_matrix_4x4_quad_model, making scaling a vec3

This commit is contained in:
Christoph Haag 2020-08-20 03:58:09 +02:00
parent 8a17481301
commit 370f6820aa
3 changed files with 9 additions and 9 deletions

View file

@ -297,9 +297,9 @@ math_matrix_4x4_view_from_pose(const struct xrt_pose *pose,
* @ingroup aux_math
*/
void
math_matrix_4x4_quad_model(const struct xrt_pose *pose,
const struct xrt_vec2 *size,
struct xrt_matrix_4x4 *result);
math_matrix_4x4_model(const struct xrt_pose *pose,
const struct xrt_vec3 *size,
struct xrt_matrix_4x4 *result);
/*
*

View file

@ -293,14 +293,14 @@ math_matrix_4x4_view_from_pose(const struct xrt_pose *pose,
}
void
math_matrix_4x4_quad_model(const struct xrt_pose *pose,
const struct xrt_vec2 *size,
struct xrt_matrix_4x4 *result)
math_matrix_4x4_model(const struct xrt_pose *pose,
const struct xrt_vec3 *size,
struct xrt_matrix_4x4 *result)
{
Eigen::Vector3f position = copy(&pose->position);
Eigen::Quaternionf orientation = copy(&pose->orientation);
auto scale = Eigen::Scaling(size->x, size->y, 1.0f);
auto scale = Eigen::Scaling(size->x, size->y, size->z);
Eigen::Translation3f translation(position);
Eigen::Affine3f transformation = translation * orientation * scale;

View file

@ -491,9 +491,9 @@ comp_renderer_set_quad_layer(struct comp_renderer *r,
r->lr->layers[layer], image->sampler,
get_image_view(image, data->flags, data->quad.sub.array_index));
struct xrt_vec3 s = {data->quad.size.x, data->quad.size.y, 1.0f};
struct xrt_matrix_4x4 model_matrix;
math_matrix_4x4_quad_model(&data->quad.pose, &data->quad.size,
&model_matrix);
math_matrix_4x4_model(&data->quad.pose, &s, &model_matrix);
comp_layer_set_model_matrix(r->lr->layers[layer], &model_matrix);