MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / pickObjectsInRect

Method pickObjectsInRect

source/MRViewer/MRViewportGL.cpp:279–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279ViewportGL::ScaledPickRes ViewportGL::pickObjectsInRect( const PickParameters& params, const Box2i& rect, int maxRenderResolutionSide ) const
280{
281 if ( !rect.valid() )
282 return {};
283
284 double maxBoxSide = double( maxRenderResolutionSide );
285 double rWidth = double( width( rect ) );
286 double rHeight = double( height( rect ) );
287 Box2i updatedRect = rect;
288 PickParameters updatedParams = params;
289 if ( rWidth > maxBoxSide || rHeight > maxBoxSide )
290 {
291 double downScaleRatio = 1.0f;
292 if ( rWidth > rHeight )
293 downScaleRatio = maxBoxSide / rWidth;
294 else
295 downScaleRatio = maxBoxSide / rHeight;
296
297 updatedRect.min = Vector2i( Vector2d( updatedRect.min ) * downScaleRatio );
298 updatedRect.max = Vector2i( Vector2d( updatedRect.max ) * downScaleRatio );
299 updatedParams.baseRenderParams.viewport =
300 Vector4i( Vector4d( updatedParams.baseRenderParams.viewport ) * downScaleRatio );
301 }
302
303 auto resColors = pickObjectsInRect_( updatedParams, updatedRect );
304 BasePickResults res( resColors.size() );
305 ParallelFor( resColors, [&] ( size_t i )
306 {
307 auto geomId = resColors[i].color[1];
308 if ( geomId >= params.renderVector.size() || !params.renderVector[geomId] )
309 return;
310 res[i].geomId = geomId;
311 res[i].primId = resColors[i].color[0];
312 } );
313 return { res,updatedRect };
314}
315
316std::vector<ViewportGL::PickColor> ViewportGL::pickObjectsInRect_( const PickParameters& params, const Box2i& rect ) const
317{

Callers 1

findVisibleFacesMethod · 0.80

Calls 5

widthFunction · 0.85
heightFunction · 0.85
ParallelForFunction · 0.85
validMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected