Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public class TerrainQuad extends Node implements Terrain {
protected NeighbourFinder neighbourFinder;

private final int DIR_RIGHT = 0, DIR_DOWN = 1, DIR_LEFT = 2, DIR_TOP = 3;

public TerrainQuad() {
super("Terrain");
}
Expand Down Expand Up @@ -370,6 +370,15 @@ public int getNumMajorSubdivisions() {
}


/**
* <code>hasLodChanged</code> retrieves a boolean value based on the result of the calculateLod method
* in a lodCalculator subclass.
*
* @param location the Vector3f location
* @param updates HashMap with updates to the TerrainPatches
* @param lodCalculator the kind of lodCalculator
* @return
*/
protected boolean hasLodChanged(List<Vector3f> location, HashMap<String, UpdatedTerrainPatch> updates, LodCalculator lodCalculator) {

boolean lodChanged = false;
Expand Down Expand Up @@ -1347,19 +1356,27 @@ protected TerrainQuad findQuad(int direction) {
if (quadrant == 0) {
if (useFinder) {
switch (direction) {
case DIR_RIGHT : return neighbourFinder.getRightQuad(this);
case DIR_DOWN : return neighbourFinder.getDownQuad(this);
case DIR_LEFT : return neighbourFinder.getLeftQuad(this);
case DIR_TOP : return neighbourFinder.getTopQuad(this);
case DIR_RIGHT:
return neighbourFinder.getRightQuad(this);
case DIR_DOWN:
return neighbourFinder.getDownQuad(this);
case DIR_LEFT:
return neighbourFinder.getLeftQuad(this);
case DIR_TOP:
return neighbourFinder.getTopQuad(this);
}
}
}

switch (direction) {
case DIR_RIGHT : return getRightNeighbourQuad();
case DIR_DOWN : return getDownNeighbourQuad();
case DIR_LEFT : return getLeftNeighbourQuad();
case DIR_TOP : return getTopNeighbourQuad();
case DIR_RIGHT:
return getRightNeighbourQuad();
case DIR_DOWN:
return getDownNeighbourQuad();
case DIR_LEFT:
return getLeftNeighbourQuad();
case DIR_TOP:
return getTopNeighbourQuad();
}

return null;
Expand All @@ -1369,14 +1386,17 @@ private TerrainQuad getRightNeighbourQuad() {
TerrainQuad pQuad = (TerrainQuad) getParent();
TerrainQuad neighbourQuad;
switch (quadrant) {
case 1: return pQuad.getQuad(3);
case 2: return pQuad.getQuad(4);
case 1:
return pQuad.getQuad(3);
case 2:
return pQuad.getQuad(4);
case 3:
neighbourQuad = pQuad.findQuad(DIR_RIGHT);
if (neighbourQuad != null)
return neighbourQuad.getQuad(1);
break;
case 4: case DIR_RIGHT:
case 4:
case DIR_RIGHT:
neighbourQuad = pQuad.findQuad(DIR_RIGHT);
if (neighbourQuad != null)
return neighbourQuad.getQuad(2);
Expand All @@ -1389,12 +1409,15 @@ private TerrainQuad getDownNeighbourQuad() {
TerrainQuad pQuad = (TerrainQuad) getParent();
TerrainQuad neighbourQuad;
switch (quadrant) {
case 1: return pQuad.getQuad(2);
case 2: neighbourQuad = pQuad.findQuad(DIR_DOWN);
case 1:
return pQuad.getQuad(2);
case 2:
neighbourQuad = pQuad.findQuad(DIR_DOWN);
if (neighbourQuad != null)
return neighbourQuad.getQuad(1);
break;
case 3: return pQuad.getQuad(4);
case 3:
return pQuad.getQuad(4);
case 4:
neighbourQuad = pQuad.findQuad(DIR_DOWN);
if (neighbourQuad != null)
Expand All @@ -1418,8 +1441,10 @@ private TerrainQuad getLeftNeighbourQuad() {
if (neighbourQuad != null)
return neighbourQuad.getQuad(4);
break;
case 3: return pQuad.getQuad(1);
case 4: return pQuad.getQuad(2);
case 3:
return pQuad.getQuad(1);
case 4:
return pQuad.getQuad(2);
}
return null;
}
Expand All @@ -1433,13 +1458,15 @@ private TerrainQuad getTopNeighbourQuad() {
if (neighbourQuad != null)
return neighbourQuad.getQuad(2);
break;
case 2: return pQuad.getQuad(1);
case 2:
return pQuad.getQuad(1);
case 3:
neighbourQuad = pQuad.findQuad(DIR_TOP);
if (neighbourQuad != null)
return neighbourQuad.getQuad(4);
break;
case 4: return pQuad.getQuad(3);
case 4:
return pQuad.getQuad(3);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public void testFindQuad() {
/**
* Tests the calculateLod method, which name has been refactored to hasLodChanged.
* We came to the conclusion that the method does belong to TerrainQuad, but should be renamed
* as it does not calculate anything. Is only retrieves values from users of the LodCalculator interface.
* as it does not calculate anything. Is only retrieves values from subclasses of the LodCalculator interface.
* The actual lodCalculator is defined in the calculateLod method of these childs.
*/
@Test
Expand Down