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


C++ BBox::getUnitcubePosOf方法代码示例

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


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

示例1: BVHNode

BVHAccel::BVHAccel(const std::vector<Primitive *> &_primitives,
                   size_t max_leaf_size) 
{

  this->primitives = _primitives;

  // edge case
  if (primitives.empty()) {
    return;
  }

  // calculate root AABB size
  BBox bb;
  for (size_t i = 0; i < primitives.size(); ++i) {
    bb.expand(primitives[i]->get_bbox());
  }
  root = new BVHNode(bb, 0, primitives.size());

  // calculate morton code for each primitives
  for (size_t i = 0; i < primitives.size(); ++i) {
    unsigned int morton_code = morton3D(bb.getUnitcubePosOf(primitives[i]->get_bbox().centroid()));
    primitives[i]->morton_code = morton_code;
  }

  // sort primitives using morton code
  std::sort(primitives.begin(), primitives.end(), mortonCompare);

  //construct BVH based on the mortan code
  constructBVH(root);

}
开发者ID:Jerrypiglet,项目名称:cmu-15462-project-YuMao-RuiZhu,代码行数:31,代码来源:bvh.cpp

示例2: builder

BVHAccel::BVHAccel(const std::vector<Primitive *> &_primitives,
                   size_t max_leaf_size) 
{
  this->primitives = _primitives;

  // edge case
  if (primitives.empty()) {
    return;
  }

  // calculate root AABB size
  BBox bb;
  for (size_t i = 0; i < primitives.size(); ++i) {
    bb.expand(primitives[i]->get_bbox());
  }
  root = new BVHNode(bb, 0, primitives.size());

  // calculate morton code for each primitives
  for (size_t i = 0; i < primitives.size(); ++i) {
    unsigned int morton_code = morton3D(bb.getUnitcubePosOf(primitives[i]->get_bbox().centroid()));
    primitives[i]->morton_code = morton_code;
  }

  // sort primitives using morton code
  std::sort(primitives.begin(), primitives.end(), mortonCompare);
  
  // extract bboxes array
  std::vector<BBox> bboxes(primitives.size());
  for(int i=0; i<primitives.size(); i++) bboxes[i] = primitives[i]->get_bbox();

  
  // extract sorted morton code for parallel binary radix tree construction
  unsigned int sorted_morton_codes[primitives.size()];
  for (size_t i = 0; i < primitives.size(); ++i) {
    sorted_morton_codes[i] = primitives[i]->morton_code;
  }

  // delegate the binary radix tree construction process to GPU
  cout << "start building parallel brtree" << endl;
  ParallelBRTreeBuilder builder(sorted_morton_codes, &bboxes[0], primitives.size());
  builder.build();
  cout << "done." << endl;

  leaf_nodes = builder.get_leaf_nodes();
  internal_nodes = builder.get_internal_nodes();
  
  builder.freeDeviceMemory();
 
  // construct BVH based on Binary Radix Tree
  constructBVHFromBRTree();
  
  // free the host memory because I am a good programmer
  builder.freeHostMemory();
}
开发者ID:Jerrypiglet,项目名称:cmu-15462-project-YuMao-RuiZhu,代码行数:54,代码来源:bvh.cpp


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