Exemplo n.º 1
0
void SegmentManager::addSegment(Mercator::Segment& segment)
{
	std::stringstream ss;
	ss << (segment.getXRef() / segment.getResolution()) << "_" << (segment.getYRef() / segment.getResolution());
	std::unique_lock<std::mutex> l(mSegmentsMutex);
	SegmentStore::const_iterator I = mSegments.find(ss.str());
	if (I == mSegments.end()) {
		mSegments.insert(SegmentStore::value_type(ss.str(), new SegmentHolder(new Segment(segment), *this)));
	}
}
Exemplo n.º 2
0
void HeightMapUpdateTask::createHeightMapSegments() {
	for (SegmentStore::const_iterator I = mSegments.begin(); I != mSegments.end(); ++I) {
		Mercator::Segment* segment = *I;
		if (segment) {
			IHeightMapSegment* heightMapSegment = 0;
			Mercator::Matrix<2, 2, Mercator::BasePoint>& basePoints(segment->getControlPoints());
			//If all of the base points are on the same level, and there are no mods, we know that the segment is completely flat, and we can save some memory by using a HeightMapFlatSegment instance.
			if (WFMath::Equal(basePoints[0].height(), basePoints[1].height()) && WFMath::Equal(basePoints[1].height(), basePoints[2].height()) && WFMath::Equal(basePoints[2].height(), basePoints[3].height()) && (segment->getMods().empty())) {
				heightMapSegment = new HeightMapFlatSegment(basePoints[0].height());
			} else {
				HeightMapBuffer* buffer = mProvider.checkout();
				if (buffer) {
					memcpy(buffer->getBuffer()->getData(), segment->getPoints(), sizeof(float) * segment->getSize() * segment->getSize());
					heightMapSegment = new HeightMapSegment(buffer);
				}
			}
			if (heightMapSegment) {
				mHeightMapSegments.emplace_back(WFMath::Point<2>(segment->getXRef() / segment->getResolution(), segment->getZRef() / segment->getResolution()), heightMapSegment);
			}
		}
	}

}