Example #1
0
void TerrainPageGeometry::blitSegmentToOgre(float* ogreHeightData, Mercator::Segment& segment, int startX, int startY)
{
	int segmentWidth = segment.getSize();
	int i, j;
	int pageWidth = mPage.getPageSize();
	size_t ogreDataSize = pageWidth * pageWidth;

	const float* sourcePtr = segment.getPoints();
	float* destPtr = ogreHeightData;

	float* dataEnd = ogreHeightData + ogreDataSize;

	float* end = destPtr + (pageWidth * ((segmentWidth - 1) + startY)) + (((segmentWidth - 1) + startX));

	float* tempPtr = end;
	for (i = 0; i < segmentWidth; ++i) {
		tempPtr -= segmentWidth;
		for (j = 0; j < segmentWidth; ++j) {

			if (tempPtr >= ogreHeightData && tempPtr < dataEnd) {
				*(tempPtr) = *(sourcePtr + j);
			}
			tempPtr += 1;
		}
		tempPtr -= pageWidth;
		sourcePtr += segmentWidth;
	}
}
Example #2
0
void TerrainPageGeometry::blitSegmentToOgre(float* ogreHeightData, Mercator::Segment& segment, int startX, int startY)
{
	int segmentWidth = segment.getSize();
	int pageWidth = mPage.getPageSize();
	size_t ogreDataSize = pageWidth * pageWidth;

	const float* sourcePtr = segment.getPoints();
	float* destPtr = ogreHeightData;

	float* dataEnd = ogreHeightData + ogreDataSize;
	
	// copy points line-by line
	float* tempPtr = destPtr + pageWidth * startY + startX;
	for (int i = 0; i < segmentWidth; ++i) {
		for (int j = 0; j < segmentWidth; ++j) {
			if ((tempPtr + j) >= ogreHeightData && (tempPtr + j) < dataEnd) {
				*(tempPtr + j) = *(sourcePtr + j);
			}
		}
		tempPtr += pageWidth;
		sourcePtr += segmentWidth;
	}
}
Example #3
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);
			}
		}
	}

}