protected void apply(Application app, VoxelBlock block, Index pos) { Index cornerChild = pos.getChild(); for(byte c = 0; c<VoxelBlock.CHILD_COUNT; ++c) { // TODO: use min and max to reduce number of values considered Index childPos = cornerChild.getNeighbor(c); Action action = checkMutation(app, childPos); // check if voxel is outside of modifier area if (!action.modify) continue; // check if voxel is inside of masked area Action maskAction = checkMasks(app.tree, childPos); if (!maskAction.modify) continue; // recurse or set full voxel if (childPos.depth < app.tree.maximumDetail && (maskAction.doTraverse || action.doTraverse)) apply(app, block.expand(childPos.xLocal, childPos.yLocal, childPos.zLocal), childPos); else block.children[childPos.xLocal, childPos.yLocal, childPos.zLocal] = mutate(app, childPos, action, block.children[childPos.xLocal, childPos.yLocal, childPos.zLocal].toVoxel()); // update meshes if appropriate if (childPos.depth == app.tree.maximumDetail - VoxelRenderer.VOXEL_COUNT_POWER) { UpdateCheckJob job = new UpdateCheckJob(block, app.tree, childPos.depth); job.setOffset((byte)childPos.x, (byte)childPos.y, (byte)childPos.z); job.setForce(true); app.jobs.Add(job); } } }
public void updateAll(int x, int y, int z, byte detailLevel, VoxelTree control, bool force = false) { // check if this is a high enough detail level. If not, call the childrens' update methods if (!isRenderSize(control.sizes[detailLevel], control) && (!isRenderLod(x, y, z, control.sizes[detailLevel], control))) { for (byte xi = 0; xi < CHILD_DIMENSION; ++xi) { for (byte yi = 0; yi < CHILD_DIMENSION; ++yi) { for (byte zi = 0; zi < CHILD_DIMENSION; ++zi) { //VoxelUpdateInfo childInfo = new VoxelUpdateInfo(info, xi, yi, zi); if (children[xi, yi, zi].GetType() == typeof(Voxel)) { //if (!childInfo.isSolid()) children[xi, yi, zi] = new VoxelBlock((Voxel)children[xi, yi, zi]); //else //continue; } UpdateCheckJob job = new UpdateCheckJob((VoxelBlock)children[xi, yi, zi], control, (byte)(detailLevel + 1)); job.setOffset((byte)(x * CHILD_DIMENSION + xi), (byte)(y * CHILD_DIMENSION + yi), (byte)(z * CHILD_DIMENSION + zi)); control.enqueueCheck(job); } } } if (renderer != null) { //GameObject.Destroy(renderer.ob); //lock (myControl) { // myControl.enqueueJob(new DropRendererJob(renderer)); // renderer = null; //} renderer.old = true; } return; } // check if we already have a mesh if (renderer == null) { //clearSubRenderers(); renderer = new VoxelRenderer(new VoxelIndex(x, y, z, detailLevel), control); //info.renderers[1, 1, 1] = renderer; } else { renderer.old = false; if (!force) { return; } } // We should generate a mesh GenMeshJob updateJob = new GenMeshJob(this, control, detailLevel); updateJob.setOffset(x, y, z); control.enqueueUpdate(updateJob); }
public void updateAll(uint x, uint y, uint z, byte detailLevel, OcTree control, bool force = false) { // check if this is a high enough detail level. If not, call the childrens' update methods VoxelRenderer renderer = control.getRenderer(new Index(detailLevel, x, y, z)); if (!isRenderSize(control.sizes[detailLevel], control) && (!isRenderLod(x, y, z, control.sizes[detailLevel], control))) { for (byte xi = 0; xi < CHILD_DIMENSION; ++xi) { for (byte yi = 0; yi < CHILD_DIMENSION; ++yi) { for (byte zi = 0; zi < CHILD_DIMENSION; ++zi) { if (children[xi, yi, zi].GetType() == typeof(Voxel)) { children[xi, yi, zi] = new VoxelBlock((Voxel)children[xi, yi, zi]); } UpdateCheckJob job = new UpdateCheckJob((VoxelBlock)children[xi, yi, zi], control, (byte)(detailLevel + 1)); job.setOffset((byte)(x * CHILD_DIMENSION + xi), (byte)(y * CHILD_DIMENSION + yi), (byte)(z * CHILD_DIMENSION + zi)); control.enqueueCheck(job); } } } return; } // check if we already have a mesh if (renderer == null) { renderer = new VoxelRenderer(new Index(detailLevel, x, y, z), control); } else if (!force) { return; } // We should generate a mesh GenMeshJob updateJob = new GenMeshJob(this, control, detailLevel); updateJob.setOffset(x, y, z); control.enqueueUpdate(updateJob); }
public void updateAll(uint x, uint y, uint z, byte detailLevel, Tree control, bool force = false) { // check if this is a high enough detail level. If not, call the childrens' update methods VoxelRenderer renderer = control.getRenderer(new Index(detailLevel, x, y, z)); if (!isRenderSize(control.sizes[detailLevel], control) && (!isRenderLod(x, y, z, control.sizes[detailLevel], control))) { for (byte xi = 0; xi < CHILD_DIMENSION; ++xi) { for (byte yi = 0; yi < CHILD_DIMENSION; ++yi) { for (byte zi = 0; zi < CHILD_DIMENSION; ++zi) { //VoxelUpdateInfo childInfo = new VoxelUpdateInfo(info, xi, yi, zi); if (children[xi, yi, zi].GetType() == typeof(Voxel)) { //if (!childInfo.isSolid()) children[xi, yi, zi] = new VoxelBlock((Voxel)children[xi, yi, zi]); //else //continue; } UpdateCheckJob job = new UpdateCheckJob((VoxelBlock)children[xi, yi, zi], control, (byte)(detailLevel + 1)); job.setOffset((byte)(x * CHILD_DIMENSION + xi), (byte)(y * CHILD_DIMENSION + yi), (byte)(z * CHILD_DIMENSION + zi)); control.enqueueCheck(job); } } } if (renderer != null) { //GameObject.Destroy(renderer.ob); //lock (myControl) { // myControl.enqueueJob(new DropRendererJob(renderer)); // renderer = null; //} renderer.old = true; } return; } // check if we already have a mesh if (renderer == null) { //clearSubRenderers(); renderer = new VoxelRenderer(new Index(detailLevel, x, y, z), control); //info.renderers[1, 1, 1] = renderer; } else { renderer.old = false; if (!force) return; } // We should generate a mesh GenMeshJob updateJob = new GenMeshJob(this, control, detailLevel); updateJob.setOffset(x, y, z); control.enqueueUpdate(updateJob); }