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


C++ OctreeElementPointer类代码示例

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


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

示例1: getOrCreateChildElementContaining

OctreeElementPointer OctreeElement::getOrCreateChildElementContaining(const AABox& box) {
    OctreeElementPointer child = NULL;

    int childIndex = getMyChildContaining(box);

    // If getMyChildContaining() returns CHILD_UNKNOWN then it means that our level
    // is the correct level for this cube
    if (childIndex == CHILD_UNKNOWN) {
        return shared_from_this();
    }

    // Now, check if we have a child at that location
    child = getChildAtIndex(childIndex);
    if (!child) {
        child = addChildAtIndex(childIndex);
    }

    // if we've made a really small child, then go ahead and use that one.
    if (child->getScale() <= SMALLEST_REASONABLE_OCTREE_ELEMENT_SCALE) {
        return child;
    }

    // Now that we have the child to recurse down, let it answer the original question...
    return child->getOrCreateChildElementContaining(box);
}
开发者ID:Giugiogia,项目名称:hifi,代码行数:25,代码来源:OctreeElement.cpp

示例2: getOrCreateChildElementAt

// TODO: consider removing this, or switching to using getOrCreateChildElementContaining(const AACube& box)...
OctreeElementPointer OctreeElement::getOrCreateChildElementAt(float x, float y, float z, float s) {
    OctreeElementPointer child = NULL;
    // If the requested size is less than or equal to our scale, but greater than half our scale, then
    // we are the Element they are looking for.
    float ourScale = getScale();
    float halfOurScale = ourScale / 2.0f;

    if(s > ourScale) {
        qCDebug(octree, "UNEXPECTED -- OctreeElement::getOrCreateChildElementAt() s=[%f] > ourScale=[%f] ",
                (double)s, (double)ourScale);
    }

    if (s > halfOurScale) {
        return shared_from_this();
    }

    int childIndex = getMyChildContainingPoint(glm::vec3(x, y, z));

    // Now, check if we have a child at that location
    child = getChildAtIndex(childIndex);
    if (!child) {
        child = addChildAtIndex(childIndex);
    }

    // Now that we have the child to recurse down, let it answer the original question...
    return child->getOrCreateChildElementAt(x, y, z, s);
}
开发者ID:Giugiogia,项目名称:hifi,代码行数:28,代码来源:OctreeElement.cpp

示例3: postRecursion

bool UpdateEntityOperator::postRecursion(OctreeElementPointer element) {
    // Post-recursion is the unwinding process. For this operation, while we
    // unwind we want to mark the path as being dirty if we changed it below.
    // We might have two paths, one for the old entity and one for the new entity.
    bool keepSearching = !_foundOld || !_foundNew;

    bool subtreeContainsOld = subTreeContainsOldEntity(element);
    bool subtreeContainsNew = subTreeContainsNewEntity(element);

    // As we unwind, if we're in either of these two paths, we mark our element
    // as dirty.
    if ((_foundOld && subtreeContainsOld) ||
            (_foundNew && subtreeContainsNew)) {
        element->markWithChangedTime();
    }

    // It's not OK to prune if we have the potential of deleting the original containig element.
    // because if we prune the containing element then new might end up reallocating the same memory later 
    // and that will confuse our logic.
    // 
    // it's ok to prune if:
    // 1) we're not removing the old
    // 2) we are removing the old, but this subtree doesn't contain the old
    // 3) we are removing the old, this subtree contains the old, but this element isn't a direct parent of _containingElement
    if (!_removeOld || !subtreeContainsOld || !element->isParentOf(_containingElement)) {
        EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
        entityTreeElement->pruneChildren(); // take this opportunity to prune any empty leaves
    }
    
    return keepSearching; // if we haven't yet found it, keep looking
}
开发者ID:GabrielPathfinder,项目名称:hifi,代码行数:31,代码来源:UpdateEntityOperator.cpp

示例4: shouldRecurseSubTree

// does this entity tree element contain the old entity
bool MovingEntitiesOperator::shouldRecurseSubTree(const OctreeElementPointer& element) {
    bool containsEntity = false;

    // If we don't have an old entity, then we don't contain the entity, otherwise
    // check the bounds
    if (_entitiesToMove.size() > 0) {
        const AACube& elementCube = element->getAACube();
        int detailIndex = 0;
        foreach(const EntityToMoveDetails& details, _entitiesToMove) {

            if (_wantDebug) {
                qCDebug(entities) << "MovingEntitiesOperator::shouldRecurseSubTree() details["<< detailIndex <<"]-----------------------------";
                qCDebug(entities) << "    element:" << element->getAACube();
                qCDebug(entities) << "    details.entity:" << details.entity->getEntityItemID();
                qCDebug(entities) << "    details.oldContainingElementCube:" << details.oldContainingElementCube;
                qCDebug(entities) << "    details.newCube:" << details.newCube;
                qCDebug(entities) << "    details.newCubeClamped:" << details.newCubeClamped;
                qCDebug(entities) << "    elementCube.contains(details.newCube)" << elementCube.contains(details.newCube);
                qCDebug(entities) << "    elementCube.contains(details.newCubeClamped)" << elementCube.contains(details.newCubeClamped);
                qCDebug(entities) << "--------------------------------------------------------------------------";
            }

            if (elementCube.contains(details.oldContainingElementCube) || elementCube.contains(details.newCubeClamped)) {
                containsEntity = true;
                break; // if it contains at least one, we're good to go
            }
            detailIndex++;
        }
    }
    return containsEntity;
}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:32,代码来源:MovingEntitiesOperator.cpp

示例5: postRecursion

bool AddEntityOperator::postRecursion(const OctreeElementPointer& element) {
    // Post-recursion is the unwinding process. For this operation, while we
    // unwind we want to mark the path as being dirty if we changed it below.
    // We might have two paths, one for the old entity and one for the new entity.
    bool keepSearching = !_foundNew;

    // As we unwind, if we're in either of these two paths, we mark our element
    // as dirty.
    if ((_foundNew && element->getAACube().contains(_newEntityBox))) {
        element->markWithChangedTime();
    }
    return keepSearching; // if we haven't yet found it, keep looking
}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:13,代码来源:AddEntityOperator.cpp

示例6: getChildAtIndex

void OctreeElement::deleteChildAtIndex(int childIndex) {
    OctreeElementPointer childAt = getChildAtIndex(childIndex);
    if (childAt) {
        childAt.reset();
        setChildAtIndex(childIndex, NULL);
        _isDirty = true;
        markWithChangedTime();

        // after deleting the child, check to see if we're a leaf
        if (isLeaf()) {
            _voxelNodeLeafCount++;
        }
    }
}
开发者ID:Giugiogia,项目名称:hifi,代码行数:14,代码来源:OctreeElement.cpp

示例7: renderOperation

bool OctreeRenderer::renderOperation(OctreeElementPointer element, void* extraData) {
    RenderArgs* args = static_cast<RenderArgs*>(extraData);
    if (element->isInView(*args->_viewFrustum)) {
        if (element->hasContent()) {
            if (element->calculateShouldRender(args->_viewFrustum, args->_sizeScale, args->_boundaryLevelAdjust)) {
                args->_renderer->renderElement(element, args);
            } else {
                return false; // if we shouldn't render, then we also should stop recursing.
            }
        }
        return true; // continue recursing
    }
    // if not in view stop recursing
    return false;
}
开发者ID:JamesLinus,项目名称:hifi,代码行数:15,代码来源:OctreeRenderer.cpp

示例8: subTreeContainsNewEntity

bool UpdateEntityOperator::subTreeContainsNewEntity(OctreeElementPointer element) {
    bool elementContainsNewBox = element->getAACube().contains(_newEntityBox);

    if (_wantDebug) {
        bool elementContainsNewCube = element->getAACube().contains(_newEntityCube);
        qCDebug(entities) << "UpdateEntityOperator::subTreeContainsNewEntity()....";
        qCDebug(entities) << "    element->getAACube()=" << element->getAACube();
        qCDebug(entities) << "    _newEntityCube=" << _newEntityCube;
        qCDebug(entities) << "    _newEntityBox=" << _newEntityBox;
        qCDebug(entities) << "    elementContainsNewCube=" << elementContainsNewCube;
        qCDebug(entities) << "    elementContainsNewBox=" << elementContainsNewBox;
    }

    return elementContainsNewBox;
}
开发者ID:GabrielPathfinder,项目名称:hifi,代码行数:15,代码来源:UpdateEntityOperator.cpp

示例9: preRecursion

bool AddEntityOperator::preRecursion(const OctreeElementPointer& element) {
    EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);

    // In Pre-recursion, we're generally deciding whether or not we want to recurse this
    // path of the tree. For this operation, we want to recurse the branch of the tree if
    // any of the following are true:
    //   * We have not yet found the location for the new entity, and this branch contains the bounds of the new entity
    
    bool keepSearching = false; // assume we don't need to search any more
    
    // If we haven't yet found the new entity,  and this subTreeContains our new
    // entity, then we need to keep searching.
    if (!_foundNew && element->getAACube().contains(_newEntityBox)) {

        // If this element is the best fit for the new entity properties, then add/or update it
        if (entityTreeElement->bestFitBounds(_newEntityBox)) {
            _tree->addEntityMapEntry(_newEntity);
            entityTreeElement->addEntityItem(_newEntity);
            _foundNew = true;
            keepSearching = false;
        } else {
            keepSearching = true;
        }
    }
    
    return keepSearching; // if we haven't yet found it, keep looking
}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:27,代码来源:AddEntityOperator.cpp

示例10: subTreeContainsOldEntity

// does this entity tree element contain the old entity
bool UpdateEntityOperator::subTreeContainsOldEntity(OctreeElementPointer element) {

    // We've found cases where the old entity might be placed in an element that is not actually the best fit
    // so when we're searching the tree for the old element, we use the known cube for the known containing element
    bool elementContainsOldBox = element->getAACube().contains(_containingElementCube);

    if (_wantDebug) {
        bool elementContainsOldCube = element->getAACube().contains(_oldEntityCube);
        qCDebug(entities) << "UpdateEntityOperator::subTreeContainsOldEntity()....";
        qCDebug(entities) << "    element->getAACube()=" << element->getAACube();
        qCDebug(entities) << "    _oldEntityCube=" << _oldEntityCube;
        qCDebug(entities) << "    _oldEntityBox=" << _oldEntityBox;
        qCDebug(entities) << "    elementContainsOldCube=" << elementContainsOldCube;
        qCDebug(entities) << "    elementContainsOldBox=" << elementContainsOldBox;
    }
    return elementContainsOldBox;
}
开发者ID:GabrielPathfinder,项目名称:hifi,代码行数:18,代码来源:UpdateEntityOperator.cpp

示例11: didntFit

void OctreeSceneStats::didntFit(const OctreeElementPointer element) {
    _didntFit++;
    if (element->isLeaf()) {
        _leavesDidntFit++;
    } else {
        _internalDidntFit++;
    }
}
开发者ID:CryptArc,项目名称:hifi,代码行数:8,代码来源:OctreeSceneStats.cpp

示例12: colorSent

void OctreeSceneStats::colorSent(const OctreeElementPointer element) {
    _colorSent++;
    if (element->isLeaf()) {
        _leavesColorSent++;
    } else {
        _internalColorSent++;
    }
}
开发者ID:CryptArc,项目名称:hifi,代码行数:8,代码来源:OctreeSceneStats.cpp

示例13: skippedOccluded

void OctreeSceneStats::skippedOccluded(const OctreeElementPointer element) {
    _skippedOccluded++;
    if (element->isLeaf()) {
        _leavesSkippedOccluded++;
    } else {
        _internalSkippedOccluded++;
    }
}
开发者ID:CryptArc,项目名称:hifi,代码行数:8,代码来源:OctreeSceneStats.cpp

示例14: traversed

void OctreeSceneStats::traversed(const OctreeElementPointer element) {
    _traversed++;
    if (element->isLeaf()) {
        _leaves++;
    } else {
        _internal++;
    }
}
开发者ID:CryptArc,项目名称:hifi,代码行数:8,代码来源:OctreeSceneStats.cpp

示例15: possiblyCreateChildAt

OctreeElementPointer AddEntityOperator::possiblyCreateChildAt(const OctreeElementPointer& element, int childIndex) {
    // If we're getting called, it's because there was no child element at this index while recursing.
    // We only care if this happens while still searching for the new entity location.
    // Check to see if 
    if (!_foundNew) {
        float childElementScale = element->getAACube().getScale() / 2.0f; // all of our children will be half our scale
        // if the scale of our desired cube is smaller than our children, then consider making a child
        if (_newEntityBox.getLargestDimension() <= childElementScale) {
            int indexOfChildContainingNewEntity = element->getMyChildContaining(_newEntityBox);
        
            if (childIndex == indexOfChildContainingNewEntity) {
                return element->addChildAtIndex(childIndex);
            }
        }
    }
    return NULL; 
}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:17,代码来源:AddEntityOperator.cpp


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