Skip to content
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

bug: when calling pickShapesInRegion(), if there is a TriangleMesh in… #791

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

rocketsarefast
Copy link

… the pick region, the function fails and throws an exception. This is because "pickShapesInRegion()" uses a rectangle region to do picking, not a point. Instead, it makes a temporary frustum and checks if shapes are visible inside that frustum. This means that the pickRay property is null throughout the picking process. The "AbstractMesh.prototype.computePickPosition()" function will crash when the pickRay is null, but the result is only needed for normal "pick()". When using "pickShapesInRegion()", the result from computePickPosition() is ignored, and the temporary frustum is used instead. So we just need to add "if(dc.pickRay==null) {return null;}" to the top of the "AbstractMesh.prototype.computePickPosition()" function. This allows the code to move on and the pickShapesInRegion() function can complete successfully. This problem does not happen with WorldWind.Polygons, but does happen with WorldWind.TriangleMesh, and probably everything that inherits from WorldWind.AbstractMesh.

Description of the Change

One line of code at the top of AbstractMesh.prototype.computePickPosition().
if(dc.pickRay==null) {return null;}

Why Should This Be In Core?

pickShapesInRegion fails to pick TriangleMesh objects without this bug fix.

Benefits

pickShapesInRegion now properly adds TrianlgeMesh objects to the returned pickList.

Potential Drawbacks

Though unfathomable to me, it is possible that someone actually wanted this function to throw an exception and cause the AbstractMesh.prototype.doRenderOrdered() function to fail. If so, I will need to find another way to fix this bug.

Applicable Issues

pickShapesInRegion() not working with TriangleMesh.

Here is a screenshot before the bug fix. After calling pickShapesInRegion with a region containing the aircraft TriangleMesh, I get no results in the returned pickList.
without bugfix

Here is a screenshot after the bugfix. Now the TriangleMesh aircraft is returned in the pickList.
with bugfix

If the code style is wrong or I have not considered some functionality, I apologize. Though I have been using WebWorldWind for a couple years now, this is my first attempt at contributing code to the project.

… the pick region, the function fails and throws an exception. This is because "pickShapesInRegion()" uses a rectangle region to do picking, not a point. Instead, it makes a temporary frustum and checks if shapes are visible inside that frustum. This means that the pickRay property is null throughout the picking process. The "AbstractMesh.prototype.computePickPosition()" function will crash when the pickRay is null, but the result is only needed for normal "pick()". When using "pickShapesInRegion()", the result from computePickPosition() is ignored, and the temporary frustum is used instead. So we just need to add "if(dc.pickRay==null) {return null;}" to the top of the "AbstractMesh.prototype.computePickPosition()" function. This allows the code to move on and the pickShapesInRegion() function can complete successfully. This problem does not happen with WorldWind.Polygons, but does happen with WorldWind.TriangleMesh, and probably everything that inherits from WorldWind.AbstractMesh.
@Beak-man Beak-man self-requested a review July 6, 2022 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants