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

PShape array index out of bounds when using P3D (PShapeOpenGL.java) #4773

Closed
aarondbaron opened this Issue Dec 14, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@aarondbaron

aarondbaron commented Dec 14, 2016

When trying to edit a PShape childs vertex using the setVertex(index, int, int) method , this ArrayIndexOutOfBoundsException: 2 occurs at line 1667 of the file PShapeOpenGL.java : "if (is3D) vertices[index][Z] = z;"

It will not throw this problem if you use a different renderer because it's not 3D.

To replicate, load an svg file that has one or more children. Set renderer to P3d. Load the svg, get a child, try to edit the vertex using setVertex(index, int, int), and the error will occur.

@aarondbaron aarondbaron changed the title from PShape array index out of bounds when using P3D to PShape array index out of bounds when using P3D (PShapeOpenGL.java) Dec 14, 2016

@aarondbaron

This comment has been minimized.

Show comment
Hide comment
@aarondbaron

aarondbaron Dec 15, 2016

As a result of this, one cannot change the vertices of a pshape usign p3d. So when the children are loaded, they will be offset according ot however they are on the sheet. In order to fix to get an absolute position, one has to calculate the centroid of the points, and while displaying the shape, offset the drawing by the centroid amount. shape(pShape, mouseX -c.x, mouseY-c.y); where c is the centroid for that particular shape. This is what one would have to do if doing p3d. if using regular renderer, centroid still needs to be calculated, but setvertex can be called to actually subract the centroid from all the vertices. SetVertex needs to be fixed for p3d

aarondbaron commented Dec 15, 2016

As a result of this, one cannot change the vertices of a pshape usign p3d. So when the children are loaded, they will be offset according ot however they are on the sheet. In order to fix to get an absolute position, one has to calculate the centroid of the points, and while displaying the shape, offset the drawing by the centroid amount. shape(pShape, mouseX -c.x, mouseY-c.y); where c is the centroid for that particular shape. This is what one would have to do if doing p3d. if using regular renderer, centroid still needs to be calculated, but setvertex can be called to actually subract the centroid from all the vertices. SetVertex needs to be fixed for p3d

@benfry benfry added the opengl label Dec 15, 2016

@codeanticode

This comment has been minimized.

Show comment
Hide comment
@codeanticode

codeanticode Dec 20, 2016

Member

Fixed. However, you can only edit the vertices of shapes that are of GEOMETRY type. PRIMITIVE shapes will be reset to their original parameters (width, height, etc) when they are re-tessellated.

Member

codeanticode commented Dec 20, 2016

Fixed. However, you can only edit the vertices of shapes that are of GEOMETRY type. PRIMITIVE shapes will be reset to their original parameters (width, height, etc) when they are re-tessellated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment