// just handles storage in the array, doesn't test for occlusion or // determining if this is the correct map to store in! void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { _totalPolygons++; if (_polygonArraySize < _polygonCount + 1) { growPolygonArray(); } // This old code assumes that polygons will always be added in z-buffer order, but that doesn't seem to // be a good assumption. So instead, we will need to sort this by distance. Use a binary search to find the // insertion point in this array, and shift the array accordingly const int IGNORED = NULL; _polygonCount = insertIntoSortedArrays((void*)polygon, polygon->getDistance(), IGNORED, (void**)_polygons, _polygonDistances, IGNORED, _polygonCount, _polygonArraySize); // Debugging and Optimization Tuning code. if (_polygonCount > _maxPolygonsUsed) { _maxPolygonsUsed = _polygonCount; //printLog("CoverageRegion new _maxPolygonsUsed reached=%d region=%s\n",_maxPolygonsUsed, getRegionName()); //_myBoundingBox.printDebugDetails("map._myBoundingBox"); } else { //printLog("CoverageRegion::storeInArray() _polygonCount=%d region=%s\n",_polygonCount, getRegionName()); } }
// just handles storage in the array, doesn't test for occlusion or // determining if this is the correct map to store in! void CoverageRegion::storeInArray(OctreeProjectedPolygon* polygon) { _currentCoveredBounds.explandToInclude(polygon->getBoundingBox()); // Before we actually store this polygon in the array, check to see if this polygon can be merged to any of the existing // polygons already in our array. if (mergeItemsInArray(polygon, false)) { return; // exit early } // only after we attempt to merge! _totalPolygons++; if (_polygonArraySize < _polygonCount + 1) { growPolygonArray(); } // As an experiment we're going to see if we get an improvement by storing the polygons in coverage area sorted order // this means the bigger polygons are earlier in the array. We should have a higher probability of being occluded earlier // in the list. We still check to see if the polygon is "in front" of the target polygon before we test occlusion. Since // sometimes things come out of order. const bool SORT_BY_SIZE = false; const int IGNORED = 0; int* IGNORED_ADDRESS = NULL; if (SORT_BY_SIZE) { // This old code assumes that polygons will always be added in z-buffer order, but that doesn't seem to // be a good assumption. So instead, we will need to sort this by distance. Use a binary search to find the // insertion point in this array, and shift the array accordingly float area = polygon->getBoundingBox().area(); float reverseArea = 4.0f - area; //qDebug("store by size area=%f reverse area=%f\n", area, reverseArea); _polygonCount = insertIntoSortedArrays((void*)polygon, reverseArea, IGNORED, (void**)_polygons, _polygonSizes, IGNORED_ADDRESS, _polygonCount, _polygonArraySize); } else { _polygonCount = insertIntoSortedArrays((void*)polygon, polygon->getDistance(), IGNORED, (void**)_polygons, _polygonDistances, IGNORED_ADDRESS, _polygonCount, _polygonArraySize); } // Debugging and Optimization Tuning code. if (_polygonCount > _maxPolygonsUsed) { _maxPolygonsUsed = _polygonCount; //qDebug("CoverageRegion new _maxPolygonsUsed reached=%d region=%s\n",_maxPolygonsUsed, getRegionName()); //_myBoundingBox.printDebugDetails("map._myBoundingBox"); } else { //qDebug("CoverageRegion::storeInArray() _polygonCount=%d region=%s\n",_polygonCount, getRegionName()); } }