mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
allow GEOMETRY in addition to PATH for contains()
This commit is contained in:
@@ -3023,9 +3023,11 @@ public class PShape implements PConstants {
|
||||
/**
|
||||
* Return true if this x, y coordinate is part of this shape. Only works
|
||||
* with PATH shapes or GROUP shapes that contain other GROUPs or PATHs.
|
||||
* This method is not imperfect and doesn't account for all cases
|
||||
* (not all complex shapes: concave shapes or holes may have issues).
|
||||
*/
|
||||
public boolean contains(float x, float y) {
|
||||
if (family == PATH) {
|
||||
if (family == PATH || family == GEOMETRY) {
|
||||
PVector p = new PVector(x, y);
|
||||
if (matrix != null) {
|
||||
// apply the inverse transformation matrix to the point coordinates
|
||||
|
||||
@@ -2730,12 +2730,16 @@ public class PShapeOpenGL extends PShape {
|
||||
|
||||
//
|
||||
|
||||
// Geometry utils
|
||||
|
||||
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
||||
/**
|
||||
* Return true if this x, y coordinate is part of this shape. Only works
|
||||
* with PATH shapes or GROUP shapes that contain other GROUPs or PATHs.
|
||||
* This method is not imperfect and doesn't account for all cases
|
||||
* (not all complex shapes: concave shapes or holes may have issues).
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(float x, float y) {
|
||||
if (family == PATH) {
|
||||
if (family == PATH || family == GEOMETRY) {
|
||||
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
||||
boolean c = false;
|
||||
for (int i = 0, j = inGeo.vertexCount-1; i < inGeo.vertexCount; j = i++) {
|
||||
if (((inGeo.vertices[3 * i + 1] > y) != (inGeo.vertices[3 * j + 1] > y)) &&
|
||||
|
||||
@@ -3,6 +3,8 @@ X support extensions for directories with listFiles/listPaths
|
||||
X otherwise asking for .jpg will return root folders (unless 'only files' specified)
|
||||
X but because macOS actually puts extensions on folders (.app, etc), support it
|
||||
X fix for disableStyle() with 2D shapes in P3D
|
||||
X allow GEOMETRY (not just PATH) with contains() in PShape
|
||||
X the method is still incomplete, but added a note about that too
|
||||
X added workaround in PShapeOpenGL to get access to vertex data
|
||||
_ still need to find the root cause
|
||||
_ also need to check for other reports about this
|
||||
|
||||
Reference in New Issue
Block a user