Ejemplo n.º 1
0
void TerrainShaderUpdateTask::executeTaskInBackgroundThread(Tasks::TaskExecutionContext& context)
{
	GeometryPtrVector updatedPages;
	for (GeometryPtrVector::const_iterator J = mGeometry.begin(); J != mGeometry.end(); ++J) {
		TerrainPageGeometryPtr geometry = *J;
		TerrainPage& page = geometry->getPage();
		bool shouldUpdate = false;
		for (AreaStore::const_iterator K = mAreas.begin(); K != mAreas.end(); ++K) {
			if (WFMath::Intersect(page.getWorldExtent(), *K, true) || WFMath::Contains(page.getWorldExtent(), *K, true)) {
				shouldUpdate = true;
				break;
			}
		}
		if (shouldUpdate) {
			for (std::vector<const TerrainShader*>::const_iterator I = mShaders.begin(); I != mShaders.end(); ++I) {
				//repopulate the layer
				page.updateShaderTexture(*I, *geometry, true);
			}
			updatedPages.push_back(geometry);
		}
	}

	context.executeTask(new TerrainMaterialCompilationTask(updatedPages, mSignalMaterialRecompiled, mLightDirection));
	//Release Segment references as soon as we can
	mGeometry.clear();
}
Ejemplo n.º 2
0
void GeometryUpdateTask::executeTaskInBackgroundThread(Tasks::TaskExecutionContext& context)
{
	std::vector<Mercator::Segment*> segments;

	//first populate the geometry for all pages, and then regenerate the shaders
	for (BridgeBoundGeometryPtrVector::const_iterator I = mGeometry.begin(); I != mGeometry.end(); ++I) {
		TerrainPageGeometryPtr geometry = I->first;
		geometry->repopulate();
		const SegmentVector& segmentVector = geometry->getValidSegments();
		for (SegmentVector::const_iterator I = segmentVector.begin(); I != segmentVector.end(); ++I) {
			segments.push_back(I->segment);
		}
		GeometryPtrVector geometries;
		geometries.push_back(geometry);
		for (ShaderStore::const_iterator J = mShaders.begin(); J != mShaders.end(); ++J) {
			context.executeTask(new TerrainShaderUpdateTask(geometries, J->second, mAreas, mHandler.EventLayerUpdated));
		}
	}
	context.executeTask(new HeightMapUpdateTask(mHeightMapBufferProvider, mHeightMap, segments));

	for (BridgeBoundGeometryPtrVector::const_iterator I = mGeometry.begin(); I != mGeometry.end(); ++I) {
		const TerrainPageGeometryPtr& geometry = I->first;
		const ITerrainPageBridgePtr& bridge = I->second;
		if (bridge.get()) {
			bridge->updateTerrain(*geometry);
		}
	}

	for (BridgeBoundGeometryPtrVector::const_iterator I = mGeometry.begin(); I != mGeometry.end(); ++I) {
		TerrainPage* page = &(I->first)->getPage();
		mPages.insert(page);
	}
	//Release Segment references as soon as we can
	mGeometry.clear();
}
Ejemplo n.º 3
0
void GeometryUpdateTask::executeTaskInBackgroundThread(Tasks::TaskExecutionContext& context)
{
	std::vector<Mercator::Segment*> segments;
	// build a vector of shaders so we can more efficiently update them
	std::vector<const Terrain::TerrainShader*> shaderList;

	for (auto& entry : mShaders) {
		shaderList.push_back(entry.second);
	}

	//first populate the geometry for all pages, and then regenerate the shaders
	for (BridgeBoundGeometryPtrVector::const_iterator I = mGeometry.begin(); I != mGeometry.end(); ++I) {
		TerrainPageGeometryPtr geometry = I->first;
		geometry->repopulate();
		const SegmentVector& segmentVector = geometry->getValidSegments();
		for (SegmentVector::const_iterator I = segmentVector.begin(); I != segmentVector.end(); ++I) {
			segments.push_back(I->segment);
		}
		GeometryPtrVector geometries;
		geometries.push_back(geometry);

		context.executeTask(new TerrainShaderUpdateTask(geometries, shaderList, mAreas, mHandler.EventLayerUpdated, mHandler.EventTerrainMaterialRecompiled, mLightDirection));
	}
	context.executeTask(new HeightMapUpdateTask(mHeightMapBufferProvider, mHeightMap, segments));

	for (BridgeBoundGeometryPtrVector::const_iterator I = mGeometry.begin(); I != mGeometry.end(); ++I) {
		const TerrainPageGeometryPtr& geometry = I->first;
		const ITerrainPageBridgePtr& bridge = I->second;
		if (bridge.get()) {
			bridge->updateTerrain(*geometry);
			mBridgesToNotify.insert(bridge);
		}
	}
	for (BridgeBoundGeometryPtrVector::const_iterator I = mGeometry.begin(); I != mGeometry.end(); ++I) {
		TerrainPage* page = &(I->first)->getPage();
		mPages.insert(page);
	}

	//Release Segment references as soon as we can
	mGeometry.clear();
}