-
Notifications
You must be signed in to change notification settings - Fork 94
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
Fix bug retrieving depth buffer for mouse scene collision #620
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,10 +193,10 @@ public void render() | |
renderScene(RDXSceneLevel.MODEL.SINGLETON_SET); | ||
|
||
normalizedDeviceCoordinateDepthDirectByteBuffer.rewind(); // SIGSEV otherwise | ||
GL41.glReadBuffer(GL41.GL_COLOR_ATTACHMENT1); | ||
GL41.glReadBuffer(GL41.GL_DEPTH_ATTACHMENT); | ||
GL41.glPixelStorei(GL41.GL_UNPACK_ALIGNMENT, 4); // to read floats | ||
// Note: This line has significant performance impact | ||
GL41.glReadPixels(0, 0, (int) renderSizeX, (int) renderSizeY, GL41.GL_RED, GL41.GL_FLOAT, normalizedDeviceCoordinateDepthDirectByteBuffer); | ||
GL41.glReadPixels(0, 0, (int) renderSizeX, (int) renderSizeY, GL41.GL_DEPTH_COMPONENT, GL41.GL_FLOAT, normalizedDeviceCoordinateDepthDirectByteBuffer); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch to correctly using the DEPTH_COMPONENT |
||
GL41.glPixelStorei(GL41.GL_UNPACK_ALIGNMENT, 1); // undo what we did | ||
|
||
frameBuffer.end(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This demo class has been expanded to cover more cases for mouse scene collision. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,4 +65,20 @@ public static void clear(HeightMapMessage messageToClear) | |
messageToClear.getVariances().clear(); | ||
messageToClear.getCentroids().clear(); | ||
} | ||
|
||
public static void setToFlatGround(HeightMapMessage message) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useful for generating a flat ground height map graphic for testing purposes. |
||
{ | ||
int centerIndex = HeightMapTools.computeCenterIndex(message.getGridSizeXy(), message.getXyResolution()); | ||
int cellsPerAxis = 2 * centerIndex + 1; | ||
|
||
for (int xIndex = 0; xIndex < cellsPerAxis; xIndex++) | ||
{ | ||
for (int yIndex = 0; yIndex < cellsPerAxis; yIndex++) | ||
{ | ||
int key = HeightMapTools.indicesToKey(xIndex, yIndex, centerIndex); | ||
message.getKeys().add(key); | ||
message.getHeights().add(0.0f); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply the same math that's in the depth sensor shader