Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Sep 12, 2025

PR summary

Based on @scottshambaugh's comment, I took the existing 2D clipping algorithm and extended it to 3D. That turned out to be quite straightforward as it already worked on each direction independently. Most of the work was actually with regards to the plumbing to get things in and out. Then I implemented it for Poly3DCollection and Patch3D.

There are still a few things to finish this:

  1. Poly3DCollection supports masking on the input, both from the original input and also to allow combining ragged input into a single array for quicker processing. I have not tested either, and don't expect them to work properly.
  2. The 2D code drops any empty polygons after clipping. In 3D, this breaks depth shading since the order is broken. Instead of trying to track this change through clipping, it's probably easiest just to keep the empty polygons, but I have not tested it out.
  3. This is still under the axlim_clip flag; I don't know if we just want to enable this all the time and/or deprecate that option.
  4. Probably could warrant an API/what's new note.

Using the example from #8902 without clipping, the bars are quite misleading, as it seems like they are in a completely different spot initially compared to when looking at them edgewise.

Screencast.From.2025-09-12.05-24-46.mp4

whereas with clipping here, we get something that isn't so weird:

Screencast.From.2025-09-12.05-25-33.mp4

This is based on #30208.

PR checklist

... by replacing double pointers by fixed-size `std::array`, or a return
`tuple`. With gcc (and optimization enabled?), this has no effect on
code size, but gives compile-time (and better runtime) checks that there
are no out-of-bounds access.
... by avoiding double pointers.
It is `bool` for the Python wrapper, while internally `int`, but can be
`bool` consistently.

Also mark it as `inline` since it's used in a template and the compiler
warns about a possible ODR violation (which isn't a problem since it's
only used in one file.)
By using the existing `XY` type to replace x/y pairs, and taking
advantage of struct methods.
Use `XY` type to shorten internals, and `agg::rect_d::normalize` to
shorten initialization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant