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

Function appendGPUVisibleFaces

source/MRViewer/MRSelectScreenLasso.cpp:283–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void appendGPUVisibleFaces( const Viewport& viewport, const BitSet& pixBs,
284 const std::vector<std::shared_ptr<ObjectMesh>>& objects,
285 std::vector<FaceBitSet>& visibleFaces, bool includeBackfaces /*= true */ )
286{
287 const auto orthoBackwards = viewport.getBackwardDirection();
288 auto gpuPickerVisibleFaces = viewport.findVisibleFaces( pixBs );
289 for ( int i = 0; i < objects.size(); ++i )
290 {
291 const auto& selMesh = objects[i];
292 auto it = gpuPickerVisibleFaces.find( selMesh );
293 if ( it == gpuPickerVisibleFaces.end() )
294 continue;
295 if ( !includeBackfaces )
296 {
297 const auto xf = selMesh->worldXf();
298 BitSetParallelFor( it->second, [&] ( FaceId f )
299 {
300 auto n = selMesh->mesh()->dirDblArea( f );
301 Vector3f cameraDir;
302 if ( viewport.getParameters().orthographic )
303 cameraDir = orthoBackwards;
304 else
305 cameraDir = -viewport.unprojectPixelRay( to2dim( viewport.projectToViewportSpace( selMesh->mesh()->triCenter( f ) ) ) ).d;
306 if ( dot( xf.A * n, cameraDir ) < 0 )
307 it->second.set( f, false );
308 } );
309 }
310 visibleFaces[i] |= it->second;
311 }
312}
313
314VertBitSet findVertsInViewportArea( const Viewport& viewport, const BitSet& pixBs, const ObjectPoints& obj,
315 bool includeBackfaces /*= true */, bool onlyVisible /*= false */ )

Callers

nothing calls this directly

Calls 14

BitSetParallelForFunction · 0.85
to2dimFunction · 0.85
getBackwardDirectionMethod · 0.80
findVisibleFacesMethod · 0.80
worldXfMethod · 0.80
dirDblAreaMethod · 0.80
unprojectPixelRayMethod · 0.80
triCenterMethod · 0.80
dotFunction · 0.70
sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected