Skip to content

Commit 5589bc5

Browse files
committed
make naming more consistent for coords/bufferinds
1 parent b4d7ef2 commit 5589bc5

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

include/polyscope/view.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ bool getWindowResizable();
137137

138138
// Get world geometry corresponding to a screen pixel (e.g. from a mouse click)
139139
glm::vec3 screenCoordsToWorldRay(glm::vec2 screenCoords);
140-
glm::vec3 bufferCoordsToWorldRay(int xPos, int yPos);
140+
glm::vec3 bufferIndsToWorldRay(glm::ivec2 bufferInds);
141141
glm::vec3 screenCoordsToWorldPosition(glm::vec2 screenCoords); // queries the depth buffer to get full position
142-
glm::vec3 bufferCoordsToWorldPosition(int xPos, int yPos);
142+
glm::vec3 bufferIndsToWorldPosition(glm::ivec2 bufferInds);
143143

144144
// Get and set camera from json string
145145
std::string getViewAsJson();
@@ -151,7 +151,9 @@ void setCameraFromJson(std::string jsonData, bool flyTo);
151151
std::string to_string(ProjectionMode mode);
152152
std::string to_string(NavigateStyle style);
153153
std::tuple<int, int> screenCoordsToBufferInds(glm::vec2 screenCoords);
154+
glm::ivec2 screenCoordsToBufferIndsVec(glm::vec2 screenCoords);
154155
glm::vec2 bufferIndsToScreenCoords(int xPos, int yPos);
156+
glm::vec2 bufferIndsToScreenCoords(glm::ivec2 bufferInds);
155157

156158
// == Internal helpers. Should probably not be called in user code.
157159

@@ -177,6 +179,10 @@ void processClipPlaneShift(double amount);
177179
void processZoom(double amount);
178180
void processKeyboardNavigation(ImGuiIO& io);
179181

182+
// deprecated, bad names, see variants above
183+
glm::vec3 bufferCoordsToWorldRay(glm::vec2 bufferCoords);
184+
glm::vec3 bufferCoordsToWorldPosition(int xPos, int yPos);
185+
180186

181187
} // namespace view
182188
} // namespace polyscope

src/view.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,21 @@ std::tuple<int, int> screenCoordsToBufferInds(glm::vec2 screenCoords) {
102102
return std::tuple<int, int>(xPos, yPos);
103103
}
104104

105+
glm::ivec2 screenCoordsToBufferIndsVec(glm::vec2 screenCoords) {
106+
glm::ivec2 out;
107+
std::tie(out.x, out.y) = screenCoordsToBufferInds(screenCoords);
108+
return out;
109+
}
110+
105111
glm::vec2 bufferIndsToScreenCoords(int xPos, int yPos) {
106112
return glm::vec2{xPos * static_cast<float>(view::windowWidth) / view::bufferWidth,
107113
yPos * static_cast<float>(view::windowHeight) / view::bufferHeight};
108114
}
109115

116+
glm::vec2 bufferIndsToScreenCoords(glm::ivec2 bufferInds) {
117+
return bufferIndsToScreenCoords(bufferInds.x, bufferInds.y);
118+
}
119+
110120
void processRotate(glm::vec2 startP, glm::vec2 endP) {
111121

112122
if (startP == endP) {
@@ -513,6 +523,8 @@ glm::vec3 screenCoordsToWorldRay(glm::vec2 screenCoords) {
513523
return worldRayDir;
514524
}
515525

526+
glm::vec3 bufferIndsToWorldRay(glm::vec2 bufferInds) { return bufferCoordsToWorldRay(bufferInds); }
527+
516528
glm::vec3 bufferCoordsToWorldRay(glm::vec2 bufferCoords) {
517529

518530
glm::mat4 view = getCameraViewMatrix();
@@ -532,6 +544,10 @@ glm::vec3 screenCoordsToWorldPosition(glm::vec2 screenCoords) {
532544
return bufferCoordsToWorldPosition(xInd, yInd);
533545
}
534546

547+
glm::vec3 bufferIndsToWorldPosition(glm::ivec2 bufferInds) {
548+
return bufferCoordsToWorldPosition(bufferInds.x, bufferInds.y);
549+
}
550+
535551
glm::vec3 bufferCoordsToWorldPosition(int xInd, int yInd) {
536552

537553
glm::vec2 screenCoords = bufferIndsToScreenCoords(xInd, yInd);

0 commit comments

Comments
 (0)