I have a brainteaser/challenge for anyone who is interested.
I’ve long been working on a sketch where I create a complex polygon, and then need to make an index of all integer points that fall within it (so basically, a vectorglm::vec2) which I later use for lots of different functions.
Initially I just used the point in polygon check, for an ofPolyline, iterating through the bounding rectangle of the polygon shape, and adding points to the vector if they returned inside.
But, this was pretty slow - because of the polygon complexity, and the fact that there were circa 500,000 points.
Then I moved to a different approach; drawing the polygon in pink to an ofFbo; using .readToPixels to copy the Fbo into a pixels object, and then iterating through the pixels using .getColor and adding points to the vector if they returned pink.
The second approach is much faster, albeit with a bottleneck around the readToPixels
Can anyone suggest a method that beats this? I am mainly intrigued to know if there is one.