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

bugfix for camera pick missing normal buffer crash (fixes #264) #267

Merged
merged 2 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/camera_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ void CameraView::fillCameraWidgetGeometry(render::ShaderProgram* nodeProgram, re
addPolygon({triangleTop, triangleRight, triangleLeft});

pickFrameProgram->setAttribute("a_vertexPositions", positions);
// pickFrameProgram->setAttribute("a_vertexNormals", normals); // unused
if (pickFrameProgram->hasAttribute("a_vertexNormals")) {
// // this is not actually used, but it only gets optimized out on some platforms, not all
pickFrameProgram->setAttribute("a_vertexNormals", normals);
}
pickFrameProgram->setAttribute("a_barycoord", bcoord);

size_t nFaces = 7;
Expand Down
15 changes: 15 additions & 0 deletions test/src/camera_view_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ TEST_F(PolyscopeTest, CameraViewUpdate) {
polyscope::removeAllStructures();
}

TEST_F(PolyscopeTest, CameraViewPick) {

polyscope::CameraView* cam1 = polyscope::registerCameraView(
"cam1", polyscope::CameraParameters(polyscope::CameraIntrinsics::fromFoVDegVerticalAndAspect(60, 2.),
polyscope::CameraExtrinsics::fromVectors(
glm::vec3{2., 2., 2.}, glm::vec3{-1., -1., -1.}, glm::vec3{0., 1., 0.})));

// This probably doesn't actually click on anything, but it does populate the pick buffers and makes sure that nothing crashes
polyscope::pick::pickAtScreenCoords(glm::vec2{0.3, 0.8});

polyscope::show(3);

polyscope::removeAllStructures();
}

TEST_F(PolyscopeTest, AddCameraViewColorImage) {

polyscope::CameraView* cam1 = polyscope::registerCameraView(
Expand Down