Jump to content
  • Advertisement
Sign in to follow this  
Numsgil

Broadphase for segments

This topic is 2611 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a segment "soup" (that is, a raw list of segments) produced from one or more (possibly complex (self intersecting)) polygons' edges. I want to implement a broadphase for it that will help me detect potential overlaps between segments. I'll be using this for some basic CSG operations on polygons, like flattening complex polygons to simple polygons, adding holes to polygons, finding the union of two polygons, polygon triangulation, that sort of thing.

Right now I'm using a 1 axis sweep of the segments' AABBs. My main nitpick with this is that it's not great at non-batched queries. For instance, for triangulation, I'm using ear clipping, so I need a way to test a newly created segment against existing edges efficiently. With a sort-n-sweep algorithm you have to do a binary search over the sorted handles, which means it's an O(log n) operation. Which isn't bad but it would be better if that was a constant term (as with some sort of spatial hash implementation).

So my current thinking is to use a spatial hash. A well chosen uniform cell size (say, chosen so that 50% of segments would fit in a single cell) would mean most segments overlap only a few cells, and I think I could make that work efficiently. But I'm wondering if there's some other broadphase scheme that would be better suited to this use case, or if anyone has any relevant experience they could share.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!