MCPcopy Create free account
hub / github.com/city-super/Octree-GS / pixFromScreenPos

Method pixFromScreenPos

SIBR_viewers/src/core/view/interface/Interface.cpp:221–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219 //}
220
221 PixPos MultiViewInterface::pixFromScreenPos(const sibr::Vector2i & posScreen, const sibr::Vector2f & winSize)
222 {
223 UV01 uvScreen = UV10::from((posScreen.cast<float>()+0.5f*sibr::Vector2f(1,1)).cwiseQuotient(winSize));
224
225 //std::cout << uvScreen.transpose() << std::endl;
226
227 sibr::Vector2f posF = viewRectangle.tl() + (viewRectangle.br() - viewRectangle.tl()).cwiseProduct(uvScreen);
228 posF.y() = 1.0f - posF.y();
229
230 posF = posF.cwiseProduct(grid.cast<float>());
231
232 //std::cout << posF.transpose() << " " << numImgs << std::endl;
233
234 if (posF.x() < 0 || posF.y() < 0 || posF.x() >= grid.x() /* || posF.y() >= grid.y() */ ) {
235 return PixPos();
236 }
237
238 int x = (int)std::floor(posF.x());
239 int y = (int)std::floor(posF.y());
240 sibr::Vector2f frac = posF - sibr::Vector2f(x, y);
241
242 int n = x + grid.x() * y;
243 int j = (int)std::floor(frac.x()*scalesData[currentScale].imSize.x());
244 int i = (int)std::floor(frac.y()*scalesData[currentScale].imSize.y());
245
246 if (n >= numImgs) {
247 return PixPos();
248 }
249
250 return PixPos(n, sibr::Vector2i(j, i));
251 }
252
253 UV01 MultiViewInterface::screenPos(const PixPos & pix)
254 {

Callers

nothing calls this directly

Calls 3

PixPosClass · 0.85
tlMethod · 0.45
brMethod · 0.45

Tested by

no test coverage detected