MCPcopy Index your code
hub / github.com/ad-si/LuaCAD / subtractPrimitives

Function subtractPrimitives

OpenCSG/src/renderSCS.cpp:520–605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518 }
519
520 void subtractPrimitives(const std::vector<Batch>& batches,
521 const unsigned int depthComplexity = 0) {
522
523 int setting = getOption(CameraOutsideOptimization);
524 bool cameraInsideModel = (setting == OptimizationOff);
525
526 glStencilMask(OpenGL::stencilMask);
527 glEnable(GL_STENCIL_TEST);
528 glEnable(GL_CULL_FACE);
529
530 size_t numberOfBatches = batches.size();
531 BouncingSequencer bounce(numberOfBatches);
532 SchoenfieldSequencer schoenfield(numberOfBatches);
533 Sequencer * sequencer = 0;
534 size_t numIterations;
535 if (depthComplexity == 0)
536 {
537 sequencer = &schoenfield;
538 numIterations = sequencer->size();
539 }
540 else
541 {
542 sequencer = &bounce;
543 numIterations = sequencer->sizeForDepthComplexity(depthComplexity);
544 }
545
546 unsigned int stencilref = 0;
547 for (size_t i = 0; i < numIterations; ++i)
548 {
549 const Batch& batch = batches[sequencer->index(i)];
550
551 // create a distinct reference value
552 ++stencilref;
553 if (stencilref == OpenGL::stencilMax) {
554 glClear(GL_STENCIL_BUFFER_BIT);
555 stencilref = 1;
556 }
557
558 channelMgr->renderToChannel(false);
559
560 glDepthMask(GL_FALSE );
561 glStencilFunc(GL_ALWAYS, stencilref, OpenGL::stencilMask);
562 glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
563
564 if (cameraInsideModel)
565 {
566 glDepthFunc(GL_GREATER);
567 glCullFace(GL_FRONT);
568
569 for (Batch::const_iterator j = batch.begin(); j != batch.end(); ++j) {
570 (*j)->render();
571 }
572
573 glStencilFunc(GL_EQUAL, stencilref, OpenGL::stencilMask);
574 glStencilOp(GL_ZERO, GL_ZERO, GL_KEEP);
575 }
576
577 glDepthFunc(GL_LESS);

Callers 1

renderSCSFunction · 0.85

Calls 10

getOptionFunction · 0.85
getRenderDataFunction · 0.85
renderToChannelMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
vecMethod · 0.80
sizeMethod · 0.45
indexMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected