/** * Call this when you remove the terrain or this control from the scene. * It will clear up any threads it had. */ public void detachAndCleanUpControl() { if (indexer != null) { indexer.cancel(true); indexer = null; } getSpatial().removeControl(this); }
protected void prepareTerrain() { TerrainQuad terrain = (TerrainQuad) getSpatial(); // cache the terrain's world transforms so they can be accessed on the separate thread safely terrain.cacheTerrainTransforms(); }
public HashMap<String, UpdatedTerrainPatch> call() throws Exception { TerrainQuad terrainQuad = (TerrainQuad) getSpatial(); // go through each patch and calculate its LOD based on camera distance HashMap<String, UpdatedTerrainPatch> updated = new HashMap<>(); // 'updated' gets populated here boolean lodChanged = terrainQuad.calculateLod(camLocations, updated, lodCalculator); if (!lodChanged) { // not worth updating anything else since no one's LOD changed lodCalcRunning.set(false); return null; } // then calculate its neighbour LOD values for seaming in the shader terrainQuad.findNeighboursLod(updated); // 'updated' can get added to here terrainQuad.fixEdges(updated); terrainQuad.reIndexPages(updated, lodCalculator.usesVariableLod()); //setUpdateQuadLODs(updated); // set back to main ogl thread lodCalcRunning.set(false); return updated; } }
protected void updateLOD(final LodCalculator lodCalculator) { if (getSpatial() == null || camera == null) { return; } // update any existing ones that need updating updateQuadLODs(); if (updateLodOffCount(lodCalculator)) { return; } final Vector3f currentLocation = camera.getLocation(); if (!forceUpdate && previousCameraLocation.equals(currentLocation) && !lodCalculator.isLodOff()) { return; // don't update if in same spot } else { previousCameraLocation.set(currentLocation); } forceUpdate = false; if (!lodCalcRunning.compareAndSet(false, true)) { return; } prepareTerrain(); final TerrainExecutorService executorService = TerrainExecutorService.getInstance(); indexer = executorService.submit(createLodUpdateTask(singletonList(currentLocation), lodCalculator)); }
protected void updateLOD(final SafeArrayList<Vector3f> locations, final LodCalculator lodCalculator) { if (getSpatial() == null || locations.isEmpty()) { return;
/** * Call this when you remove the terrain or this control from the scene. * It will clear up any threads it had. */ public void detachAndCleanUpControl() { if (executor != null) executor.shutdownNow(); getSpatial().removeControl(this); }
protected void prepareTerrain() { TerrainQuad terrain = (TerrainQuad)getSpatial(); terrain.cacheTerrainTransforms();// cache the terrain's world transforms so they can be accessed on the separate thread safely }
public HashMap<String, UpdatedTerrainPatch> call() throws Exception { //long start = System.currentTimeMillis(); //if (isLodCalcRunning()) { // return null; //} setLodCalcRunning(true); TerrainQuad terrainQuad = (TerrainQuad)getSpatial(); // go through each patch and calculate its LOD based on camera distance HashMap<String,UpdatedTerrainPatch> updated = new HashMap<String,UpdatedTerrainPatch>(); boolean lodChanged = terrainQuad.calculateLod(camLocations, updated, lodCalculator); // 'updated' gets populated here if (!lodChanged) { // not worth updating anything else since no one's LOD changed setLodCalcRunning(false); return null; } // then calculate its neighbour LOD values for seaming in the shader terrainQuad.findNeighboursLod(updated); terrainQuad.fixEdges(updated); // 'updated' can get added to here terrainQuad.reIndexPages(updated, lodCalculator.usesVariableLod()); //setUpdateQuadLODs(updated); // set back to main ogl thread setLodCalcRunning(false); return updated; } }
protected void updateLOD(List<Vector3f> locations, LodCalculator lodCalculator) { if(getSpatial() == null){ return;