ebassi / graphene

A thin layer of graphic data types
http://ebassi.github.io/graphene
Other
373 stars 80 forks source link

Fix handling of projective transforms #199

Open matthiasclasen opened 4 years ago

matthiasclasen commented 4 years ago

When transforming points with projective matrices, we must divide the resulting vector by w, in order to get the normalized result.

This commit fixes graphene_matrix_transform_point, graphene_matrix_transform_point3d and graphene_matrix_transform_bounds. I suspect that some of the remaining transform functions need similar fixes, but they are not used in GTK, so I couldn't verify that.

Before:

Screenshot from 2020-08-31 22-47-27

After:

Screenshot from 2020-08-31 22-27-09

Notice how the bounding box for the projectively transformed button is much too small before, and just right after.

matthiasclasen commented 4 years ago

Here is a gtk-side fix for now: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2514

alexlarsson commented 4 years ago

Given things like https://gitlab.gnome.org/GNOME/gtk/-/commit/30ab8b3ecac15e22436f6c38c1149e54f42f0d50 it seems existing code relies on the current behaviour. So, is it safe to change this?