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


C++ Vec3f::MaxComponentIndex方法代码示例

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


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

示例1: _SplitPoints

uint32_t GatherForestBuilder::_SplitPoints(vector<GatherNode> &tree, vector<GatherPoint> &gps, vector<GatherPoint>::iterator start, vector<GatherPoint>::iterator end )
{
    Range3f pBox(Vec3f(FLT_MAX, FLT_MAX, FLT_MAX), Vec3f(-FLT_MAX, -FLT_MAX, -FLT_MAX));
    Range3f nBox(Vec3f(FLT_MAX, FLT_MAX, FLT_MAX), Vec3f(-FLT_MAX, -FLT_MAX, -FLT_MAX));
    Conef   cone;

    vector<GatherPoint>::iterator it = start;
    while (it != end)
    {
        pBox.Grow(it->position);
        nBox.Grow(it->normal);
        if (it == start)
            cone = Conef(it->normal);
        else
            cone.Grow(it->normal);
        it++;
    }

    GatherNode node(_tsample);
    node.bbox = pBox;
    node.cone = cone;
    tree.push_back(node);
    uint32_t curIdx = tree.size() - 1;

#ifdef _DEBUG
    vector<GatherPoint> gp(start, end);
#endif // _DEBUG
    if (end - start > 2)
    {
        Vec3f nbSize = nBox.GetSize();
        Vec3f pbSize = pBox.GetSize();

        bool splitType;
        uint32_t splitDim;
        if (pbSize.MaxComponent() > nbSize.MaxComponent())
        {
            splitType = true;
            splitDim = pbSize.MaxComponentIndex();
        }
        else
        {
            splitType = false;
            splitDim = nbSize.MaxComponentIndex();
        }
        vector<GatherPoint>::iterator splitPos = start + (end - start) / 2;
        std::nth_element(start, splitPos, end, CompareNode<GatherPoint>(splitType, splitDim));
#ifdef _DEBUG
        vector<GatherPoint> gp1(start, splitPos);
        vector<GatherPoint> gp2(splitPos, end);
#endif // _DEBUG

        uint32_t leftIdx  = _SplitPoints(tree, gps, start, splitPos);
        uint32_t rightIdx = _SplitPoints(tree, gps, splitPos, end);

        GatherNode &curNode = tree[curIdx];
        curNode.leftIdx = leftIdx;
        curNode.rightIdx = rightIdx;
        vector<uint32_t> &reps = curNode.reps;
        vector<uint32_t> &lreps = tree[leftIdx].reps;
        vector<uint32_t> &rreps = tree[rightIdx].reps;
        
        
        for (uint32_t i = 0; i < reps.size(); i++)
        {
            if (lreps[i] != -1 && rreps[i] != -1)
            {
                //GatherPoint &p1 = gps[lreps[i]];
                //GatherPoint &p2 = gps[reps[i]];
                reps[i] = (__rand() > 0.5f) ? lreps[i] : rreps[i];
            }
            else
            {
                reps[i] = lreps[i] + 1 + rreps[i];
            }
        }
    }
    else
    {
        vector<GatherPoint>::iterator it = start;
        while (it != end)
        {
            gps.push_back(*it);
            tree[curIdx].reps[it->timeInst] = gps.size() - 1;
            it++;
        }
    }
    
    return curIdx;
}
开发者ID:ema0j,项目名称:cs482-icg-pj,代码行数:89,代码来源:GatherForestBuilder.cpp


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