Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 2D axis-aligned bounding box type #259

Merged
merged 13 commits into from
Aug 15, 2024
Merged

Add 2D axis-aligned bounding box type #259

merged 13 commits into from
Aug 15, 2024

Conversation

ebassi
Copy link
Owner

@ebassi ebassi commented Aug 10, 2023

Works like graphene_box_t, but in two dimensions.

Fixes: #204

@ebassi ebassi mentioned this pull request Aug 12, 2024
Like graphene_box_t, but for 2D areas. It's more efficient than
rectangles, at the cost of legibility.
Pack the minimum and maximum vertices into a single vector, and use
merge low/high operators to extract the values. This reduces the size of
a box2d instance, and makes it more compact. It's also more efficient to
extract both vertices when passing them to GL, by using a single read.
If we want to just know if two boxes intersect each other, we can do
that with an inlined function.

It's not the fastest possible function, because it still requires
calling into graphene_box2d_get_minmax(), as the calling code does not
have access to the private fields of the graphene_box2d_t type.
Equivalent of graphene_rect_scale() and graphene_rect_offset_r(), but in
a single operation. Scale and offset parameters are optional, so it's
easy to use for separate transformations as well.
Check that rectangles roundtrip between 2D boxes, and that the
transformation works.
GTK-doc gets very confused by static inlines, so we are going to need to
add a non-inline stub and use a macro to rename the inline function in
the header.
Meson's gnome.gtkdoc() can generate a test target that will run
gtkdoc-check, to verify that all the symbols are properly documented.
@ebassi ebassi merged commit 21e4bb3 into master Aug 15, 2024
5 checks passed
@ebassi ebassi deleted the box2d branch August 15, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2d bounding boxes
2 participants