本文整理汇总了C++中BBox::expand方法的典型用法代码示例。如果您正苦于以下问题:C++ BBox::expand方法的具体用法?C++ BBox::expand怎么用?C++ BBox::expand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBox
的用法示例。
在下文中一共展示了BBox::expand方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_bbox
BBox Triangle::get_bbox() const {
// TODO:
// Compute the bounding box of the triangle.
BBox bb;
bb.expand(mesh->positions[v1]);
bb.expand(mesh->positions[v2]);
bb.expand(mesh->positions[v3]);
return bb;
}
示例2: 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);
}
示例3: bbox
void CPUFontBase::bbox(const wchar_t * wstr, BBox & bbox)
{
if(wstr && (*wstr != wchar_t('\0')))
{
#ifndef WIN32
const unsigned wchar_t * wc = (const unsigned wchar_t *)wstr;
#else
const wchar_t * wc = (const wchar_t *)wstr;
#endif
float advance = 0.f;
if(checkGlyph(*wc))
{
bbox = m_glyphList->bbox(*wc);
advance = m_glyphList->advance(*wc, *(wc + 1));
}
while(*++wc)
{
if(checkGlyph(*wc))
{
BBox tempBBox = m_glyphList->bbox(*wc);
tempBBox.move(Nimble::Vector2(advance, 0.0f));
bbox.expand(tempBBox);
advance += m_glyphList->advance(*wc, *(wc + 1));
}
}
}
}
示例4: get_bbox
BBox Scene::get_bbox() {
BBox bbox;
for (SceneObject *obj : objects) {
bbox.expand(obj->get_bbox());
}
return bbox;
}
示例5: generate_bounding_box
/**
* generate bounding box
*/
BBox BVHAccel::generate_bounding_box(int start, int span)
{
BBox bb;
for (size_t i = start; i < start + span; ++i) {
bb.expand(primitives[i]->get_bbox());
}
return bb;
}
示例6: 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();
}
示例7: test_bbox
void test_bbox() {
dgd_start_scope( geom, "test_bbox()" );
BBox bbox;
dgd_echo( dgd_expand(bbox) << std::endl );
bbox.expand( Vector( 1, 1, 1 ) );
dgd_echo( dgd_expand(bbox) << std::endl );
bbox.expand( Vector( 1, -1, 1 ) );
dgd_echo( dgd_expand(bbox) << std::endl );
bbox.expand( Vector( -1, -1, -1 ) );
dgd_echo( dgd_expand(bbox) << std::endl );
dgd_end_scope( geom );
}
示例8: setupCells
void Mesh::setupCells() {
double root = 3.0 * pow(faces.size(), 1.0 / 3.0);
double voxelsPerUnit = root / bbox.maxExtent();
nx = (int) clamp(round(bbox.wx * voxelsPerUnit), 0, 32) + 1;
ny = (int) clamp(round(bbox.wy * voxelsPerUnit), 0, 32) + 1;
nz = (int) clamp(round(bbox.wz * voxelsPerUnit), 0, 32) + 1;
numCells = nx * ny * nz;
voxels = new Voxel*[numCells];
memset(voxels, 0, sizeof(Voxel*) * numCells);
for(FaceIter it = faces.begin(), end = faces.end(); it != end; ++it) {
BBox fbox;
fbox.expand(*points[(*it)->vertIdxs[0]]);
fbox.expand(*points[(*it)->vertIdxs[1]]);
fbox.expand(*points[(*it)->vertIdxs[2]]);
int ixmin = (int) clamp((fbox.x0 - bbox.x0) * nx / bbox.wx, 0, nx - 1);
int iymin = (int) clamp((fbox.y0 - bbox.y0) * ny / bbox.wy, 0, ny - 1);
int izmin = (int) clamp((fbox.z0 - bbox.z0) * nz / bbox.wz, 0, nz - 1);
int ixmax = (int) clamp((fbox.x1 - bbox.x0) * nx / bbox.wx, 0, nx - 1);
int iymax = (int) clamp((fbox.y1 - bbox.y0) * ny / bbox.wy, 0, ny - 1);
int izmax = (int) clamp((fbox.z1 - bbox.z0) * nz / bbox.wz, 0, nz - 1);
// add the object to the cells
for(int iz = izmin; iz <= izmax; iz++) {
for(int iy = iymin; iy <= iymax; iy++) {
for(int ix = ixmin; ix <= ixmax; ix++) {
int index = ix + nx * iy + nx * ny * iz;
if(voxels[index] == NULL) {
voxels[index] = new Voxel();
}
voxels[index]->add(*it);
}
}
}
}
}