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


C++ QuadTree::remove方法代码示例

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


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

示例1: remove

        //Returns false if the point could not be removed (it doesn't exist)
        //data is used to make sure it is the point requested
        //NOTE: X and Y are not used when comparing the point, just for walking the tree,
        //so if you have two of the same data, it might not remove the one
        //at the position specified (the system assumes you are using pointers)
        bool remove(T searchData, float x, float y)
        {
            //Point will not be in this node's bounds
            if(!isPointInRange(x, y, bounds)) return false;
            
            //Search through points for the data
            for (typename std::list<QuadPoint<T> >::iterator it = data.begin(); it!= data.end(); ++it)
            {
                //Found the data point; erase it (inefficient only in large vectors)
                //TODO: Replace vector with list or something?
                if ((*it).data==searchData)
                {
                    data.erase(it);
                    return true;
                }
            }
            //Search children (if any)
            if (!tL) return false;
            if (tL->remove(searchData, x, y) || tR->remove(searchData, x, y)
            || bL->remove(searchData, x, y) || bR->remove(searchData, x, y))
            {
                //All children are empty; delete them
                if (isEmpty())
                {
                    //TODO: Should this be a pool?
                    delete tL;
                    delete tR;
                    delete bL;
                    delete bR;
                    tL = NULL;
                }
                return true;
            }

            //Data point not in quadtree
            return false;
        }
开发者ID:makuto,项目名称:horizon,代码行数:42,代码来源:quadTree.hpp

示例2: removeActiveArea

bool ZoneContainerComponent::removeActiveArea(Zone* zone, ActiveArea* activeArea) {
	if (zone == NULL)
		return false;

	ManagedReference<SceneObject*> thisLocker = activeArea;

	Locker zoneLocker(zone);

	QuadTree* regionTree = zone->getRegionTree();

	regionTree->remove(activeArea);

	// lets remove the in range active areas of players
	SortedVector<QuadTreeEntry*> objects;
	float range = activeArea->getRadius() + 64;

	zone->getInRangeObjects(activeArea->getPositionX(), activeArea->getPositionY(), range, &objects, false);

	zone->dropSceneObject(activeArea);

	zoneLocker.release();

	for (int i = 0; i < objects.size(); ++i) {
		SceneObject* object = cast<SceneObject*>(objects.get(i));

	//	Locker olocker(object);

		if (!object->isTangibleObject()) {
			continue;
		}

		TangibleObject* tano = cast<TangibleObject*>(object);

		if (tano->hasActiveArea(activeArea)) {
			tano->dropActiveArea(activeArea);
			activeArea->enqueueExitEvent(object);
		}
	}

	activeArea->notifyObservers(ObserverEventType::OBJECTREMOVEDFROMZONE, NULL, 0);

	activeArea->setZone(NULL);

	return true;
}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:45,代码来源:ZoneContainerComponent.cpp


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