当前位置: 首页>>代码示例>>C++>>正文


C++ PrimInfo::add方法代码示例

本文整理汇总了C++中PrimInfo::add方法的典型用法代码示例。如果您正苦于以下问题:C++ PrimInfo::add方法的具体用法?C++ PrimInfo::add怎么用?C++ PrimInfo::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PrimInfo的用法示例。


在下文中一共展示了PrimInfo::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: find

    FallBackSplit FallBackSplit::find(size_t threadIndex, PrimRefBlockAlloc<PrimRef>& alloc, PrimRefList& prims, 
				      PrimRefList& lprims_o, PrimInfo& linfo_o,
				      PrimRefList& rprims_o, PrimInfo& rinfo_o)
    {
      size_t num = 0;
      BBox3fa lbounds = empty, rbounds = empty;
      PrimRefList::item* lblock = lprims_o.insert(alloc.malloc(threadIndex));
      PrimRefList::item* rblock = rprims_o.insert(alloc.malloc(threadIndex));
      linfo_o.reset();
      rinfo_o.reset();

      while (PrimRefList::item* block = prims.take()) 
      {
	for (size_t i=0; i<block->size(); i++) 
	{
	  const PrimRef& prim = block->at(i); 
	  const BBox3fa bounds = prim.bounds();
	  
	  if ((num++)%2) 
	  {
	    linfo_o.add(bounds,prim.center2()); 
	    if (likely(lblock->insert(prim))) continue; 
	    lblock = lprims_o.insert(alloc.malloc(threadIndex));
	    lblock->insert(prim);
	  } 
	  else 
	  {
	    rinfo_o.add(bounds,prim.center2()); 
	    if (likely(rblock->insert(prim))) continue;
	    rblock = rprims_o.insert(alloc.malloc(threadIndex));
	    rblock->insert(prim);
	  }
	}
	alloc.free(threadIndex,block);
      }
      return FallBackSplit(linfo_o.geomBounds,linfo_o.size(),rinfo_o.geomBounds,rinfo_o.size());
    }
开发者ID:D-POWER,项目名称:embree,代码行数:37,代码来源:heuristic_fallback.cpp

示例2: while

    void StrandSplit::Split::split<false>(size_t threadIndex, size_t threadCount, LockStepTaskScheduler* scheduler, PrimRefBlockAlloc<BezierPrim>& alloc, 
					  BezierRefList& prims, 
					  BezierRefList& lprims_o, PrimInfo& linfo_o, 
					  BezierRefList& rprims_o, PrimInfo& rinfo_o) const 
    {
      BezierRefList::item* lblock = lprims_o.insert(alloc.malloc(threadIndex));
      BezierRefList::item* rblock = rprims_o.insert(alloc.malloc(threadIndex));
      linfo_o.reset();
      rinfo_o.reset();
      
      while (BezierRefList::item* block = prims.take()) 
      {
	for (size_t i=0; i<block->size(); i++) 
	{
	  const BezierPrim& prim = block->at(i); 
	  const Vec3fa axisi = normalize(prim.p3-prim.p0);
	  const float cos0 = abs(dot(axisi,axis0));
	  const float cos1 = abs(dot(axisi,axis1));
	  
	  if (cos0 > cos1) 
	  {
	    linfo_o.add(prim.bounds(),prim.center());
	    if (likely(lblock->insert(prim))) continue; 
	    lblock = lprims_o.insert(alloc.malloc(threadIndex));
	    lblock->insert(prim);
	  } 
	  else 
	  {
	    rinfo_o.add(prim.bounds(),prim.center());
	    if (likely(rblock->insert(prim))) continue;
	    rblock = rprims_o.insert(alloc.malloc(threadIndex));
	    rblock->insert(prim);
	  }
	}
	alloc.free(threadIndex,block);
      }
    }
开发者ID:utkarshayachit,项目名称:OSPRay,代码行数:37,代码来源:heuristic_strand_partition.cpp

示例3: pinfo


//.........这里部分代码省略.........
          
          /* create BVH and builder for new meshes */
          if (objects[objectID] == nullptr)
            createTriangleMeshAccel(mesh,(AccelData*&)objects[objectID],builders[objectID]);
        }
      });

      /* parallel build of acceleration structures */
      parallel_for(size_t(0), N, [&] (const range<size_t>& r) 
      {
        for (size_t objectID=r.begin(); objectID<r.end(); objectID++)
        {
          /* ignore if no triangle mesh or not enabled */
          TriangleMesh* mesh = scene->getTriangleMeshSafe(objectID);
          if (mesh == nullptr || !mesh->isEnabled() || mesh->numTimeSteps != 1) 
            continue;
        
          BVH4*    object  = objects [objectID]; assert(object);
          Builder* builder = builders[objectID]; assert(builder);
          
          /* build object if it got modified */
#if !PROFILE 
          if (mesh->isModified()) 
#endif
            builder->build(0,0);
          
          /* create build primitive */
          if (!object->bounds.empty())
            refs[nextRef++] = BVH4BuilderTwoLevel::BuildRef(object->bounds,object->root);
        }
      });
      
      /* fast path for single geometry scenes */
      if (nextRef == 1) { 
        bvh->set(refs[0].node,refs[0].bounds(),numPrimitives);
        return;
      }

      /* open all large nodes */
      refs.resize(nextRef);
      open_sequential(numPrimitives); 
      
      /* fast path for small geometries */
      if (refs.size() == 1) { 
        bvh->set(refs[0].node,refs[0].bounds(),numPrimitives);
        return;
      }

      /* compute PrimRefs */
      prims.resize(refs.size());
      const PrimInfo pinfo = parallel_reduce(size_t(0), refs.size(), size_t(1024), PrimInfo(empty), [&] (const range<size_t>& r) -> PrimInfo
      {
        PrimInfo pinfo(empty);
        for (size_t i=r.begin(); i<r.end(); i++) {
          pinfo.add(refs[i].bounds());
          prims[i] = PrimRef(refs[i].bounds(),(size_t)refs[i].node);
        }
        return pinfo;
      }, [] (const PrimInfo& a, const PrimInfo& b) { return PrimInfo::merge(a,b); });

      /* skip if all objects where empty */
      if (pinfo.size() == 0)
        bvh->set(BVH4::emptyNode,empty,0);

      /* otherwise build toplevel hierarchy */
      else
      {
        BVH4::NodeRef root;
        BVHBuilderBinnedSAH::build<BVH4::NodeRef>
          (root,
           [&] { return bvh->alloc.threadLocal2(); },
           [&] (const isa::BVHBuilderBinnedSAH::BuildRecord& current, BVHBuilderBinnedSAH::BuildRecord* children, const size_t N, FastAllocator::ThreadLocal2* alloc) -> int
           {
             BVH4::Node* node = (BVH4::Node*) alloc->alloc0.malloc(sizeof(BVH4::Node)); node->clear();
             for (size_t i=0; i<N; i++) {
               node->set(i,children[i].pinfo.geomBounds);
               children[i].parent = (size_t*)&node->child(i);
             }
             *current.parent = bvh->encodeNode(node);
             return 0;
           },
           [&] (const BVHBuilderBinnedSAH::BuildRecord& current, FastAllocator::ThreadLocal2* alloc) -> int
           {
             assert(current.prims.size() == 1);
             *current.parent = (BVH4::NodeRef) prims[current.prims.begin()].ID();
             return 1;
           },
           [&] (size_t dn) { bvh->scene->progressMonitor(0); },
           prims.data(),pinfo,BVH4::N,BVH4::maxBuildDepthLeaf,4,1,1,1.0f,1.0f);
        
        bvh->set(root,pinfo.geomBounds,numPrimitives);
      }

#if PROFILE
      }); 
#endif

      bvh->alloc.cleanup();
      bvh->postBuild(t0);
    }
开发者ID:eyalsoreq,项目名称:embree,代码行数:101,代码来源:bvh4_builder_twolevel.cpp

示例4: assert

    void SpatialSplit::Split::split<false>(size_t threadIndex, size_t threadCount, LockStepTaskScheduler* scheduler, PrimRefBlockAlloc<PrimRef>& alloc, 
					   Scene* scene, TriRefList& prims, 
					   TriRefList& lprims_o, PrimInfo& linfo_o, 
					   TriRefList& rprims_o, PrimInfo& rinfo_o) const
    {
      assert(valid());
      TriRefList::item* lblock = lprims_o.insert(alloc.malloc(threadIndex));
      TriRefList::item* rblock = rprims_o.insert(alloc.malloc(threadIndex));
      linfo_o.reset();
      rinfo_o.reset();
    
      /* sort each primitive to left, right, or left and right */
      while (atomic_set<PrimRefBlock>::item* block = prims.take()) 
      {
	for (size_t i=0; i<block->size(); i++) 
	{
	  const PrimRef& prim = block->at(i); 
	  const BBox3fa bounds = prim.bounds();
	  const int bin0 = mapping.bin(bounds.lower)[dim];
	  const int bin1 = mapping.bin(bounds.upper)[dim];

	  /* sort to the left side */
	  if (bin1 < pos)
	  {
	    linfo_o.add(bounds,center2(bounds));
	    if (likely(lblock->insert(prim))) continue; 
	    lblock = lprims_o.insert(alloc.malloc(threadIndex));
	    lblock->insert(prim);
	    continue;
	  }
	  
	  /* sort to the right side */
	  if (bin0 >= pos)
	  {
	    rinfo_o.add(bounds,center2(bounds));
	    if (likely(rblock->insert(prim))) continue;
	    rblock = rprims_o.insert(alloc.malloc(threadIndex));
	    rblock->insert(prim);
	    continue;
	  }
	  
	  /* split and sort to left and right */
	  TriangleMesh* mesh = (TriangleMesh*) scene->get(prim.geomID());
	  TriangleMesh::Triangle tri = mesh->triangle(prim.primID());
	  const Vec3fa v0 = mesh->vertex(tri.v[0]);
	  const Vec3fa v1 = mesh->vertex(tri.v[1]);
	  const Vec3fa v2 = mesh->vertex(tri.v[2]);
	  
	  PrimRef left,right;
	  float fpos = mapping.pos(pos,dim);
	  splitTriangle(prim,dim,fpos,v0,v1,v2,left,right);
	
	  if (!left.bounds().empty()) {
	    linfo_o.add(left.bounds(),center2(left.bounds()));
	    if (!lblock->insert(left)) {
	      lblock = lprims_o.insert(alloc.malloc(threadIndex));
	      lblock->insert(left);
	    }
	  }
	  
	  if (!right.bounds().empty()) {
	    rinfo_o.add(right.bounds(),center2(right.bounds()));
	    if (!rblock->insert(right)) {
	      rblock = rprims_o.insert(alloc.malloc(threadIndex));
	      rblock->insert(right);
	    }
	  }
	}
	alloc.free(threadIndex,block);
      }
    }
开发者ID:JianpingCAI,项目名称:libigl,代码行数:71,代码来源:heuristic_spatial_split.cpp


注:本文中的PrimInfo::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。