Skip to content

Commit

Permalink
Fix graphene_ray_transform
Browse files Browse the repository at this point in the history
We can't use graphene_matrix_transform_vec3() to transform the origin
because we need to point to respect transformations (but not the
directions, so we can use vec3 there instead of reconstructing
the direction).
  • Loading branch information
alexlarsson authored and ebassi committed Aug 25, 2019
1 parent 735918a commit c0fdadc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/graphene-matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,13 +1090,13 @@ graphene_matrix_transform_ray (const graphene_matrix_t *m,
graphene_ray_t *res)
{
graphene_vec3_t origin, direction;
graphene_vec4_t origin4;

graphene_vec3_add (&r->direction, &r->origin, &direction);
graphene_matrix_transform_vec3 (m, &direction, &direction);
graphene_vec4_init_from_vec3 (&origin4, &r->origin, 1);
graphene_matrix_transform_vec4 (m, &origin4, &origin4);
graphene_vec4_get_xyz (&origin4, &origin);

graphene_matrix_transform_vec3 (m, &r->origin, &origin);

graphene_vec3_subtract (&direction, &origin, &direction);
graphene_matrix_transform_vec3 (m, &r->direction, &direction);

graphene_ray_init_from_vec3 (res, &origin, &direction);
}
Expand Down

0 comments on commit c0fdadc

Please sign in to comment.