public VoxelUpdateInfo(VoxelUpdateInfo super, byte xi, byte yi, byte zi)
			: this() {
			size = super.size / VoxelBlock.CHILD_DIMENSION;
			detailLevel = (byte)(super.detailLevel + 1);
			control = super.control;
			x = super.x * VoxelBlock.CHILD_DIMENSION + xi;
			y = super.y * VoxelBlock.CHILD_DIMENSION + yi;
			z = super.z * VoxelBlock.CHILD_DIMENSION + zi;
			for (byte xii = 0; xii < DIMENSION; ++xii) {
				for (byte yii = 0; yii < DIMENSION; ++yii) {
					for (byte zii = 0; zii < DIMENSION; ++zii) {
						blocks[xii, yii, zii] = super.getSub(VoxelBlock.CHILD_COUNT_POWER, (byte)(xii + xi + VoxelBlock.CHILD_DIMENSION - 1), (byte)(yii + yi + VoxelBlock.CHILD_DIMENSION - 1), (byte)(zii + zi + VoxelBlock.CHILD_DIMENSION - 1));
						if (renderers[xii, yii, zii] == null || renderers[xii, yii, zii].old)
							renderers[xii, yii, zii] = control.getRenderer(new Index((byte)(detailLevel), (uint)(x -1 +xii), (uint)(y -1 +yii), (uint)(z -1 +zii)));
						if (renderers[xii, yii, zii] != null && renderers[xii, yii, zii].old)
							renderers[xii, yii, zii] = null;
					}
				}
			}
		}
Exemple #2
0
		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);
		}