Ejemplo n.º 1
0
        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);
        }