X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Frenderer%2Foctree%2FOctreeVolume.java;h=a4f43829ff9cb25d07c21a14c411d3a80df92d62;hb=99cc27235b226ba7a6d94bc3c8308601f611daad;hp=e1b7269fb24db80a592b72cbaca340b406699740;hpb=3f589bbc56ebfb1bd35b538b8a77d4019396b5aa;p=sixth-3d.git diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/octree/OctreeVolume.java b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/octree/OctreeVolume.java index e1b7269..a4f4382 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/octree/OctreeVolume.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/octree/OctreeVolume.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine. Author: Svjatoslav Agejenko. + * Sixth 3D engine. Author: Svjatoslav Agejenko. * This project is released under Creative Commons Zero (CC0) license. */ package eu.svjatoslav.sixth.e3d.renderer.octree; @@ -7,7 +7,9 @@ package eu.svjatoslav.sixth.e3d.renderer.octree; import eu.svjatoslav.sixth.e3d.geometry.Point3D; import eu.svjatoslav.sixth.e3d.renderer.octree.raytracer.Ray; import eu.svjatoslav.sixth.e3d.renderer.raster.Color; -import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance; + +import static java.lang.Integer.max; +import static java.lang.Integer.min; /** *
@@ -36,14 +38,18 @@ public class OctreeVolume { // unused cell private static final int CELL_STATE_UNUSED = -1; - public int[] ce1; - public int[] ce2; - public int[] ce3; - public int[] ce4; - public int[] ce5; - public int[] ce6; - public int[] ce7; - public int[] ce8; + public int[] cell1; + public int[] cell2; + public int[] cell3; + public int[] cell4; + public int[] cell5; + public int[] cell6; + public int[] cell7; + public int[] cell8; + + /** + * Pointer to the first unused cell. + */ public int cellAllocationPointer = 0; public int usedCellsCount = 0; public int masterCellSize; @@ -56,31 +62,35 @@ public class OctreeVolume { final int color = getCellColor(pointer); final int illumination = getCellIllumination(pointer); - ce1[pointer] = makeNewCell(color, illumination); - ce2[pointer] = makeNewCell(color, illumination); - ce3[pointer] = makeNewCell(color, illumination); - ce4[pointer] = makeNewCell(color, illumination); - ce5[pointer] = makeNewCell(color, illumination); - ce6[pointer] = makeNewCell(color, illumination); - ce7[pointer] = makeNewCell(color, illumination); - ce8[pointer] = makeNewCell(color, illumination); + cell1[pointer] = makeNewCell(color, illumination); + cell2[pointer] = makeNewCell(color, illumination); + cell3[pointer] = makeNewCell(color, illumination); + cell4[pointer] = makeNewCell(color, illumination); + cell5[pointer] = makeNewCell(color, illumination); + cell6[pointer] = makeNewCell(color, illumination); + cell7[pointer] = makeNewCell(color, illumination); + cell8[pointer] = makeNewCell(color, illumination); } + /** + * Clears the cell. + * @param pointer Pointer to the cell. + */ public void clearCell(final int pointer) { - ce1[pointer] = 0; - ce2[pointer] = 0; - ce3[pointer] = 0; - ce4[pointer] = 0; - - ce5[pointer] = 0; - ce6[pointer] = 0; - ce7[pointer] = 0; - ce8[pointer] = 0; + cell1[pointer] = 0; + cell2[pointer] = 0; + cell3[pointer] = 0; + cell4[pointer] = 0; + + cell5[pointer] = 0; + cell6[pointer] = 0; + cell7[pointer] = 0; + cell8[pointer] = 0; } public void deleteCell(final int cellPointer) { clearCell(cellPointer); - ce1[cellPointer] = CELL_STATE_UNUSED; + cell1[cellPointer] = CELL_STATE_UNUSED; usedCellsCount--; } @@ -204,40 +214,27 @@ public class OctreeVolume { /** * Fill 3D rectangle. */ - public void fillRect3D(int x1, int y1, int z1, int x2, int y2, int z2, - final Color color) { - int t; - if (x1 > x2) { - t = x1; - x1 = x2; - x2 = t; - } + public void fillRectangle(IntegerPoint p1, IntegerPoint p2, Color color) { - if (y1 > y2) { - t = y1; - y1 = y2; - y2 = t; - } - - if (z1 > z2) { - t = z1; - z1 = z2; - z2 = t; - } + int x1 = min(p1.x, p2.x); + int x2 = max(p1.x, p2.x); + int y1 = min(p1.y, p2.y); + int y2 = max(p1.y, p2.y); + int z1 = min(p1.z, p2.z); + int z2 = max(p1.z, p2.z); for (int x = x1; x <= x2; x++) for (int y = y1; y <= y2; y++) for (int z = z1; z <= z2; z++) putCell(x, y, z, 0, 0, 0, masterCellSize, 0, color); - } public int getCellColor(final int pointer) { - return ce2[pointer]; + return cell2[pointer]; } public int getCellIllumination(final int pointer) { - return ce3[pointer]; + return cell3[pointer]; } public void initWorld(final int bufferLength, final int masterCellSize) { @@ -246,34 +243,39 @@ public class OctreeVolume { // initialize world storage buffer this.masterCellSize = masterCellSize; - ce1 = new int[bufferLength]; - ce2 = new int[bufferLength]; - ce3 = new int[bufferLength]; - ce4 = new int[bufferLength]; + cell1 = new int[bufferLength]; + cell2 = new int[bufferLength]; + cell3 = new int[bufferLength]; + cell4 = new int[bufferLength]; - ce5 = new int[bufferLength]; - ce6 = new int[bufferLength]; - ce7 = new int[bufferLength]; - ce8 = new int[bufferLength]; + cell5 = new int[bufferLength]; + cell6 = new int[bufferLength]; + cell7 = new int[bufferLength]; + cell8 = new int[bufferLength]; for (int i = 0; i < bufferLength; i++) - ce1[i] = CELL_STATE_UNUSED; + cell1[i] = CELL_STATE_UNUSED; // initialize master cell clearCell(0); } public boolean isCellSolid(final int pointer) { - return ce1[pointer] == CELL_STATE_SOLID; + return cell1[pointer] == CELL_STATE_SOLID; } - public int makeNewCell() { - for (; ; ) { - if (cellAllocationPointer >= ce1.length) + /** + * Scans cells arrays and returns pointer to found unused cell. + * @return pointer to found unused cell + */ + public int getNewCellPointer() { + while (true) { + // ensure that cell allocation pointer is in bounds + if (cellAllocationPointer >= cell1.length) cellAllocationPointer = 0; - if (ce1[cellAllocationPointer] == CELL_STATE_UNUSED) { - + if (cell1[cellAllocationPointer] == CELL_STATE_UNUSED) { + // unused cell found clearCell(cellAllocationPointer); usedCellsCount++; @@ -284,15 +286,20 @@ public class OctreeVolume { } public int makeNewCell(final int color, final int illumination) { - final int pointer = makeNewCell(); + final int pointer = getNewCellPointer(); markCellAsSolid(pointer); setCellColor(pointer, color); setCellIllumination(pointer, illumination); return pointer; } + /** + * Mark cell as solid. + * + * @param pointer pointer to cell + */ public void markCellAsSolid(final int pointer) { - ce1[pointer] = CELL_STATE_SOLID; + cell1[pointer] = CELL_STATE_SOLID; } public void putCell(final int x, final int y, final int z, final Color color) { @@ -329,22 +336,22 @@ public class OctreeVolume { if (z > cellZ) { subZ = (cellSize / 2) + cellZ; // 7 - subCubeArray = ce7; + subCubeArray = cell7; } else { subZ = (-cellSize / 2) + cellZ; // 3 - subCubeArray = ce3; + subCubeArray = cell3; } } else { subY = (-cellSize / 2) + cellY; if (z > cellZ) { subZ = (cellSize / 2) + cellZ; // 6 - subCubeArray = ce6; + subCubeArray = cell6; } else { subZ = (-cellSize / 2) + cellZ; // 2 - subCubeArray = ce2; + subCubeArray = cell2; } } } else { @@ -354,22 +361,22 @@ public class OctreeVolume { if (z > cellZ) { subZ = (cellSize / 2) + cellZ; // 8 - subCubeArray = ce8; + subCubeArray = cell8; } else { subZ = (-cellSize / 2) + cellZ; // 4 - subCubeArray = ce4; + subCubeArray = cell4; } } else { subY = (-cellSize / 2) + cellY; if (z > cellZ) { subZ = (cellSize / 2) + cellZ; // 5 - subCubeArray = ce5; + subCubeArray = cell5; } else { subZ = (-cellSize / 2) + cellZ; // 1 - subCubeArray = ce1; + subCubeArray = cell1; } } } @@ -377,7 +384,7 @@ public class OctreeVolume { int subCubePointer; if (subCubeArray[cellPointer] == 0) { // create empty cluster - subCubePointer = makeNewCell(); + subCubePointer = getNewCellPointer(); subCubeArray[cellPointer] = subCubePointer; } else subCubePointer = subCubeArray[cellPointer]; @@ -385,19 +392,19 @@ public class OctreeVolume { putCell(x, y, z, subX, subY, subZ, cellSize / 2, subCubePointer, color); } else { - ce1[cellPointer] = CELL_STATE_SOLID; - ce2[cellPointer] = color.toInt(); - ce3[cellPointer] = CELL_STATE_UNUSED; + cell1[cellPointer] = CELL_STATE_SOLID; + cell2[cellPointer] = color.toInt(); + cell3[cellPointer] = CELL_STATE_UNUSED; // System.out.println("Cell written!"); } } public void setCellColor(final int pointer, final int color) { - ce2[pointer] = color; + cell2[pointer] = color; } public void setCellIllumination(final int pointer, final int illumination) { - ce3[pointer] = illumination; + cell3[pointer] = illumination; } /** @@ -428,70 +435,70 @@ public class OctreeVolume { // 7 // 6 8 3 5 2 4 1 - if (ce7[pointer] != 0) { + if (cell7[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ + halfOfCellSize, halfOfCellSize, - ce7[pointer], ray); + cell7[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce6[pointer] != 0) { + if (cell6[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ + halfOfCellSize, halfOfCellSize, - ce6[pointer], ray); + cell6[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce8[pointer] != 0) { + if (cell8[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ + halfOfCellSize, halfOfCellSize, - ce8[pointer], ray); + cell8[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce3[pointer] != 0) { + if (cell3[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - halfOfCellSize, halfOfCellSize, - ce3[pointer], ray); + cell3[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce2[pointer] != 0) { + if (cell2[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - halfOfCellSize, halfOfCellSize, - ce2[pointer], ray); + cell2[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce4[pointer] != 0) { + if (cell4[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - halfOfCellSize, halfOfCellSize, - ce4[pointer], ray); + cell4[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce5[pointer] != 0) { + if (cell5[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ + halfOfCellSize, halfOfCellSize, - ce5[pointer], ray); + cell5[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce1[pointer] != 0) { + if (cell1[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - halfOfCellSize, halfOfCellSize, - ce1[pointer], ray); + cell1[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } @@ -499,71 +506,71 @@ public class OctreeVolume { } else { // 3 // 2 4 7 1 6 8 5 - if (ce3[pointer] != 0) { + if (cell3[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - halfOfCellSize, halfOfCellSize, - ce3[pointer], ray); + cell3[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce2[pointer] != 0) { + if (cell2[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - halfOfCellSize, halfOfCellSize, - ce2[pointer], ray); + cell2[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce4[pointer] != 0) { + if (cell4[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - halfOfCellSize, halfOfCellSize, - ce4[pointer], ray); + cell4[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce7[pointer] != 0) { + if (cell7[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ + halfOfCellSize, halfOfCellSize, - ce7[pointer], ray); + cell7[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce6[pointer] != 0) { + if (cell6[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ + halfOfCellSize, halfOfCellSize, - ce6[pointer], ray); + cell6[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce8[pointer] != 0) { + if (cell8[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ + halfOfCellSize, halfOfCellSize, - ce8[pointer], ray); + cell8[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce1[pointer] != 0) { + if (cell1[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - halfOfCellSize, halfOfCellSize, - ce1[pointer], ray); + cell1[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce5[pointer] != 0) { + if (cell5[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ + halfOfCellSize, halfOfCellSize, - ce5[pointer], ray); + cell5[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } @@ -572,68 +579,68 @@ public class OctreeVolume { } else if (ray.origin.z > cellZ) { // 6 // 5 2 7 8 1 3 4 - if (ce6[pointer] != 0) { + if (cell6[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce6[pointer], + + halfOfCellSize, halfOfCellSize, cell6[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce7[pointer] != 0) { + if (cell7[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce7[pointer], + + halfOfCellSize, halfOfCellSize, cell7[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce2[pointer] != 0) { + if (cell2[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce2[pointer], + - halfOfCellSize, halfOfCellSize, cell2[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce5[pointer] != 0) { + if (cell5[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce5[pointer], + + halfOfCellSize, halfOfCellSize, cell5[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce8[pointer] != 0) { + if (cell8[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce8[pointer], + + halfOfCellSize, halfOfCellSize, cell8[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce3[pointer] != 0) { + if (cell3[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce3[pointer], + - halfOfCellSize, halfOfCellSize, cell3[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce1[pointer] != 0) { + if (cell1[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce1[pointer], + - halfOfCellSize, halfOfCellSize, cell1[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce4[pointer] != 0) { + if (cell4[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce4[pointer], + - halfOfCellSize, halfOfCellSize, cell4[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; @@ -642,69 +649,69 @@ public class OctreeVolume { } else { // 2 // 1 3 6 5 4 7 8 - if (ce2[pointer] != 0) { + if (cell2[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce2[pointer], + - halfOfCellSize, halfOfCellSize, cell2[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce3[pointer] != 0) { + if (cell3[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce3[pointer], + - halfOfCellSize, halfOfCellSize, cell3[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce1[pointer] != 0) { + if (cell1[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce1[pointer], + - halfOfCellSize, halfOfCellSize, cell1[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce6[pointer] != 0) { + if (cell6[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce6[pointer], + + halfOfCellSize, halfOfCellSize, cell6[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce7[pointer] != 0) { + if (cell7[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce7[pointer], + + halfOfCellSize, halfOfCellSize, cell7[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce5[pointer] != 0) { + if (cell5[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce5[pointer], + + halfOfCellSize, halfOfCellSize, cell5[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce4[pointer] != 0) { + if (cell4[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce4[pointer], + - halfOfCellSize, halfOfCellSize, cell4[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce8[pointer] != 0) { + if (cell8[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce8[pointer], + + halfOfCellSize, halfOfCellSize, cell8[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; @@ -716,69 +723,69 @@ public class OctreeVolume { // 8 // 5 7 4 1 6 3 2 - if (ce8[pointer] != 0) { + if (cell8[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce8[pointer], + + halfOfCellSize, halfOfCellSize, cell8[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce7[pointer] != 0) { + if (cell7[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce7[pointer], + + halfOfCellSize, halfOfCellSize, cell7[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce5[pointer] != 0) { + if (cell5[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce5[pointer], + + halfOfCellSize, halfOfCellSize, cell5[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce4[pointer] != 0) { + if (cell4[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce4[pointer], + - halfOfCellSize, halfOfCellSize, cell4[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce3[pointer] != 0) { + if (cell3[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce3[pointer], + - halfOfCellSize, halfOfCellSize, cell3[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce1[pointer] != 0) { + if (cell1[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce1[pointer], + - halfOfCellSize, halfOfCellSize, cell1[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce6[pointer] != 0) { + if (cell6[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce6[pointer], + + halfOfCellSize, halfOfCellSize, cell6[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce2[pointer] != 0) { + if (cell2[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce2[pointer], + - halfOfCellSize, halfOfCellSize, cell2[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; @@ -788,69 +795,69 @@ public class OctreeVolume { // 4 // 1 3 8 5 7 2 6 - if (ce4[pointer] != 0) { + if (cell4[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce4[pointer], + - halfOfCellSize, halfOfCellSize, cell4[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce8[pointer] != 0) { + if (cell8[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce8[pointer], + + halfOfCellSize, halfOfCellSize, cell8[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce3[pointer] != 0) { + if (cell3[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce3[pointer], + - halfOfCellSize, halfOfCellSize, cell3[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce1[pointer] != 0) { + if (cell1[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce1[pointer], + - halfOfCellSize, halfOfCellSize, cell1[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce7[pointer] != 0) { + if (cell7[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce7[pointer], + + halfOfCellSize, halfOfCellSize, cell7[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce5[pointer] != 0) { + if (cell5[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce5[pointer], + + halfOfCellSize, halfOfCellSize, cell5[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce2[pointer] != 0) { + if (cell2[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - - halfOfCellSize, halfOfCellSize, ce2[pointer], + - halfOfCellSize, halfOfCellSize, cell2[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce6[pointer] != 0) { + if (cell6[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - + halfOfCellSize, halfOfCellSize, ce6[pointer], + + halfOfCellSize, halfOfCellSize, cell6[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; @@ -861,66 +868,66 @@ public class OctreeVolume { // 5 // 1 6 8 4 2 7 3 - if (ce5[pointer] != 0) { + if (cell5[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ + halfOfCellSize, - halfOfCellSize, ce5[pointer], ray); + halfOfCellSize, cell5[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce1[pointer] != 0) { + if (cell1[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - halfOfCellSize, - halfOfCellSize, ce1[pointer], ray); + halfOfCellSize, cell1[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce6[pointer] != 0) { + if (cell6[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ + halfOfCellSize, - halfOfCellSize, ce6[pointer], ray); + halfOfCellSize, cell6[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce8[pointer] != 0) { + if (cell8[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ + halfOfCellSize, - halfOfCellSize, ce8[pointer], ray); + halfOfCellSize, cell8[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce4[pointer] != 0) { + if (cell4[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - halfOfCellSize, - halfOfCellSize, ce4[pointer], ray); + halfOfCellSize, cell4[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce7[pointer] != 0) { + if (cell7[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ + halfOfCellSize, - halfOfCellSize, ce7[pointer], ray); + halfOfCellSize, cell7[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce2[pointer] != 0) { + if (cell2[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - halfOfCellSize, - halfOfCellSize, ce2[pointer], ray); + halfOfCellSize, cell2[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce3[pointer] != 0) { + if (cell3[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - halfOfCellSize, - halfOfCellSize, ce3[pointer], ray); + halfOfCellSize, cell3[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } @@ -929,64 +936,64 @@ public class OctreeVolume { // 1 // 5 2 4 8 6 3 7 - if (ce1[pointer] != 0) { + if (cell1[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ - halfOfCellSize, - halfOfCellSize, ce1[pointer], ray); + halfOfCellSize, cell1[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce5[pointer] != 0) { + if (cell5[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY - halfOfCellSize, cellZ + halfOfCellSize, - halfOfCellSize, ce5[pointer], ray); + halfOfCellSize, cell5[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce2[pointer] != 0) { + if (cell2[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ - halfOfCellSize, - halfOfCellSize, ce2[pointer], ray); + halfOfCellSize, cell2[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce4[pointer] != 0) { + if (cell4[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ - halfOfCellSize, - halfOfCellSize, ce4[pointer], ray); + halfOfCellSize, cell4[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce6[pointer] != 0) { + if (cell6[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY - halfOfCellSize, cellZ + halfOfCellSize, - halfOfCellSize, ce6[pointer], ray); + halfOfCellSize, cell6[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce8[pointer] != 0) { + if (cell8[pointer] != 0) { rayIntersectionResult = traceCell(cellX - halfOfCellSize, cellY + halfOfCellSize, cellZ + halfOfCellSize, - halfOfCellSize, ce8[pointer], ray); + halfOfCellSize, cell8[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce3[pointer] != 0) { + if (cell3[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ - halfOfCellSize, - halfOfCellSize, ce3[pointer], ray); + halfOfCellSize, cell3[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; } - if (ce7[pointer] != 0) { + if (cell7[pointer] != 0) { rayIntersectionResult = traceCell(cellX + halfOfCellSize, cellY + halfOfCellSize, cellZ + halfOfCellSize, - halfOfCellSize, ce7[pointer], ray); + halfOfCellSize, cell7[pointer], ray); if (rayIntersectionResult >= 0) return rayIntersectionResult; }