Skip to content

Commit 3879a84

Browse files
committed
clean up pick.cpp
1 parent c159e57 commit 3879a84

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

src/pick.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,6 @@ void setSelection(PickResult newPick) {
8080

8181
namespace pick {
8282

83-
PickResult& currSelectionPickResult = state::globalContext.currSelectionPickResult;
84-
bool& haveSelectionVal = state::globalContext.haveSelectionVal;
85-
86-
// The next pick index that a structure can use to identify its elements
87-
// (get it by calling request pickBufferRange())
88-
uint64_t& nextPickBufferInd = state::globalContext.nextPickBufferInd; // 0 reserved for "none"
89-
90-
// Track which ranges have been allocated to which structures
91-
std::unordered_map<Structure*, std::tuple<uint64_t, uint64_t>> structureRanges = state::globalContext.structureRanges;
92-
93-
9483
// == Set up picking
9584
uint64_t requestPickBufferRange(Structure* requestingStructure, uint64_t count) {
9685

@@ -106,14 +95,15 @@ uint64_t requestPickBufferRange(Structure* requestingStructure, uint64_t count)
10695
}
10796
#pragma GCC diagnostic pop
10897

109-
if (count > maxPickInd || maxPickInd - count < nextPickBufferInd) {
98+
if (count > maxPickInd || maxPickInd - count < state::globalContext.nextPickBufferInd) {
11099
exception("Wow, you sure do have a lot of stuff, Polyscope can't even count it all. (Ran out of indices while "
111100
"enumerating structure elements for pick buffer.)");
112101
}
113102

114-
uint64_t ret = nextPickBufferInd;
115-
nextPickBufferInd += count;
116-
structureRanges[requestingStructure] = std::make_tuple(ret, nextPickBufferInd);
103+
uint64_t ret = state::globalContext.nextPickBufferInd;
104+
state::globalContext.nextPickBufferInd += count;
105+
state::globalContext.structureRanges[requestingStructure] =
106+
std::make_tuple(ret, state::globalContext.nextPickBufferInd);
117107
return ret;
118108
}
119109

@@ -124,7 +114,7 @@ std::pair<Structure*, uint64_t> globalIndexToLocal(uint64_t globalInd) {
124114
// ONEDAY: this could be asymptotically better if we cared
125115

126116
// Loop through the ranges that we have allocated to find the one correpsonding to this structure.
127-
for (const auto& x : structureRanges) {
117+
for (const auto& x : state::globalContext.structureRanges) {
128118

129119
Structure* structure = x.first;
130120
uint64_t rangeStart = std::get<0>(x.second);
@@ -141,11 +131,11 @@ std::pair<Structure*, uint64_t> globalIndexToLocal(uint64_t globalInd) {
141131
uint64_t localIndexToGlobal(std::pair<Structure*, uint64_t> localPick) {
142132
if (localPick.first == nullptr) return 0;
143133

144-
if (structureRanges.find(localPick.first) == structureRanges.end()) {
134+
if (state::globalContext.structureRanges.find(localPick.first) == state::globalContext.structureRanges.end()) {
145135
exception("structure does not match any allocated pick range");
146136
}
147137

148-
std::tuple<uint64_t, uint64_t> range = structureRanges[localPick.first];
138+
std::tuple<uint64_t, uint64_t> range = state::globalContext.structureRanges[localPick.first];
149139
uint64_t rangeStart = std::get<0>(range);
150140
uint64_t rangeEnd = std::get<1>(range);
151141
return rangeStart + localPick.second;
@@ -198,6 +188,4 @@ std::pair<Structure*, uint64_t> evaluatePickQuery(int xPos, int yPos) {
198188
}
199189

200190
} // namespace pick
201-
202-
203191
} // namespace polyscope

0 commit comments

Comments
 (0)