Skip to content

Commit

Permalink
Fix edge picks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Gillespie committed Feb 15, 2024
1 parent acc6afc commit d2a5db5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion deps/glfw
Submodule glfw updated 70 files
+9 −10 .github/workflows/build.yml
+4 −6 CMakeLists.txt
+0 −42 CONTRIBUTORS.md
+8 −27 README.md
+14 −6 deps/glad/vk_platform.h
+353 −2,381 deps/glad/vulkan.h
+208 −348 deps/glad_vulkan.c
+127 −803 deps/stb_image_write.h
+0 −0 docs/CODEOWNERS
+2 −2 docs/CONTRIBUTING.md
+944 −1,853 docs/Doxyfile.in
+2 −2 docs/build.dox
+8 −12 docs/compat.dox
+7 −10 docs/compile.dox
+6 −7 docs/context.dox
+18 −36 docs/input.dox
+7 −32 docs/intro.dox
+2 −2 docs/monitor.dox
+3 −3 docs/moving.dox
+0 −39 docs/news.dox
+5 −1 docs/quick.dox
+4 −11 docs/vulkan.dox
+1 −2 docs/window.dox
+47 −70 include/GLFW/glfw3.h
+35 −75 include/GLFW/glfw3native.h
+0 −1 src/CMakeLists.txt
+6 −16 src/cocoa_init.m
+10 −16 src/cocoa_joystick.m
+4 −0 src/cocoa_monitor.m
+2 −13 src/cocoa_platform.h
+32 −123 src/cocoa_window.m
+11 −22 src/context.c
+35 −95 src/egl_context.c
+0 −2 src/egl_context.h
+1 −1 src/glfw3.pc.in
+2 −0 src/glfw_config.h.in
+6 −13 src/glx_context.c
+1 −0 src/glx_context.h
+1 −101 src/init.c
+17 −36 src/input.c
+2 −11 src/internal.h
+6 −10 src/linux_joystick.c
+0 −1 src/linux_joystick.h
+2 −2 src/monitor.c
+2 −4 src/nsgl_context.h
+5 −4 src/nsgl_context.m
+0 −3 src/null_window.c
+0 −2 src/osmesa_context.c
+0 −2 src/vulkan.c
+17 −6 src/wgl_context.c
+4 −19 src/win32_init.c
+7 −14 src/win32_joystick.c
+1 −1 src/win32_monitor.c
+1 −9 src/win32_platform.h
+105 −228 src/win32_window.c
+24 −21 src/window.c
+820 −244 src/wl_init.c
+26 −68 src/wl_monitor.c
+57 −232 src/wl_platform.h
+815 −1,969 src/wl_window.c
+2 −65 src/x11_init.c
+0 −3 src/x11_platform.h
+196 −237 src/x11_window.c
+2 −2 src/xkb_unicode.c
+1 −3 src/xkb_unicode.h
+1 −1 tests/events.c
+0 −6 tests/gamma.c
+81 −132 tests/glfwinfo.c
+3 −3 tests/iconify.c
+9 −15 tests/triangle-vulkan.c
6 changes: 3 additions & 3 deletions include/polyscope/pick.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ inline glm::vec3 indToVec(size_t globalInd) {
globalInd = globalInd >> bitsForPickPacking;
uint64_t high = globalInd;

return glm::vec3{static_cast<double>(low) / factorF, static_cast<double>(med) / factorF,
static_cast<double>(high) / factorF};
return 2500.f * glm::vec3{static_cast<double>(low) / factorF, static_cast<double>(med) / factorF,
static_cast<double>(high) / factorF};
}
inline uint64_t vecToInd(glm::vec3 vec) {

vec /= 2500.f;
uint64_t factor = 1 << bitsForPickPacking;
double factorF = factor;

Expand Down
5 changes: 2 additions & 3 deletions include/polyscope/surface_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ class SurfaceMesh : public QuantityStructure<SurfaceMesh> {
size_t nEdges(); // NOTE causes population of nEdgesCount

size_t nCornersCount = 0; // = nHalfedges = sum face degree
size_t nCorners() const { return nCornersCount; }
size_t nHalfedges() const { return nCornersCount; }
size_t nCorners() const { return cornerDataSize == INVALID_IND ? nCornersCount : cornerDataSize; }
size_t nHalfedges() const { return halfedgeDataSize == INVALID_IND ? nCornersCount : halfedgeDataSize; }

// = Mesh helpers
void nestedFacesToFlat(const std::vector<std::vector<size_t>>& nestedInds);
Expand Down Expand Up @@ -334,7 +334,6 @@ class SurfaceMesh : public QuantityStructure<SurfaceMesh> {
std::vector<uint32_t>
halfedgeEdgeCorrespondence; // ugly hack used to save a pick buffer attr, filled out lazily w/ edge indices


// Visualization settings
PersistentValue<glm::vec3> surfaceColor;
PersistentValue<glm::vec3> edgeColor;
Expand Down
6 changes: 6 additions & 0 deletions include/polyscope/surface_mesh.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ void SurfaceMesh::setEdgePermutation(const T& perm, size_t expectedSize) {

// now that we have edge indexing, enable edge-related stuff
markEdgesAsUsed();

triangleAllEdgeInds.recomputeIfPopulated();
}

template <class T>
Expand Down Expand Up @@ -163,6 +165,8 @@ void SurfaceMesh::setHalfedgePermutation(const T& perm, size_t expectedSize) {
}

markHalfedgesAsUsed();
triangleAllEdgeInds.recomputeIfPopulated();
triangleAllHalfedgeInds.recomputeIfPopulated();
}

template <class T>
Expand Down Expand Up @@ -190,6 +194,8 @@ void SurfaceMesh::setCornerPermutation(const T& perm, size_t expectedSize) {
}

markCornersAsUsed();
triangleAllEdgeInds.recomputeIfPopulated();
triangleAllCornerInds.recomputeIfPopulated();
}


Expand Down
11 changes: 8 additions & 3 deletions src/surface_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ void SurfaceMesh::computeTriangleAllEdgeInds() {
triangleAllEdgeInds.data.resize(3 * 3 * nFacesTriangulation());
halfedgeEdgeCorrespondence.resize(nHalfedges());

bool haveCustomHalfedgeIndex = !halfedgePerm.empty();

// used to loop over edges
std::unordered_map<std::pair<size_t, size_t>, size_t, polyscope::hash_combine::hash<std::pair<size_t, size_t>>>
seenEdgeInds;
Expand Down Expand Up @@ -238,7 +240,10 @@ void SurfaceMesh::computeTriangleAllEdgeInds() {
thisEdgeInd = seenEdgeInds[key];
}

halfedgeEdgeCorrespondence[start + j] = thisEdgeInd;
size_t he = start + j;
if (haveCustomHalfedgeIndex) he = halfedgePerm[he];

halfedgeEdgeCorrespondence[he] = thisEdgeInd;
thisTriInds[j] = thisEdgeInd;
}

Expand Down Expand Up @@ -1130,7 +1135,7 @@ void SurfaceMesh::buildFaceInfoGui(size_t fInd) {
void SurfaceMesh::buildEdgeInfoGui(size_t eInd) {
size_t displayInd = eInd;
if (edgePerm.size() > 0) {
displayInd = edgePerm[eInd];
// displayInd = edgePerm[eInd];
}
ImGui::TextUnformatted(("Edge #" + std::to_string(displayInd)).c_str());

Expand All @@ -1153,7 +1158,7 @@ void SurfaceMesh::buildEdgeInfoGui(size_t eInd) {
void SurfaceMesh::buildHalfedgeInfoGui(size_t heInd) {
size_t displayInd = heInd;
if (halfedgePerm.size() > 0) {
displayInd = halfedgePerm[heInd];
// displayInd = halfedgePerm[heInd];
}
ImGui::TextUnformatted(("Halfedge #" + std::to_string(displayInd)).c_str());

Expand Down

0 comments on commit d2a5db5

Please sign in to comment.