Package org.terasology.world.chunks

Examples of org.terasology.world.chunks.RenderableChunk


                    blockChanges.put(worldPos, new BlockChange(worldPos, oldBlockType, type));
                } else {
                    oldChange.setTo(type);
                }
                for (Vector3i pos : TeraMath.getChunkRegionAroundWorldPos(worldPos, 1)) {
                    RenderableChunk dirtiedChunk = chunkProvider.getChunk(pos);
                    if (dirtiedChunk != null) {
                        dirtiedChunk.setDirty(true);
                    }
                }
                notifyBlockChanged(worldPos, type, oldBlockType);
            }
            return oldBlockType;
View Full Code Here


                    biomeChanges.put(worldPos, new BiomeChange(worldPos, oldBiomeType, biome));
                } else {
                    oldChange.setTo(biome);
                }
                for (Vector3i pos : TeraMath.getChunkRegionAroundWorldPos(worldPos, 1)) {
                    RenderableChunk dirtiedChunk = chunkProvider.getChunk(pos);
                    if (dirtiedChunk != null) {
                        dirtiedChunk.setDirty(true);
                    }
                }
                notifyBiomeChanged(worldPos, biome, oldBiomeType);
            }
            return oldBiomeType;
View Full Code Here


    @Override
    public void onChunkLoaded(Vector3i pos) {
        if (renderRegion.encompasses(pos)) {
            RenderableChunk chunk = chunkProvider.getChunk(pos);
            chunksInProximity.add(chunk);
            Collections.sort(chunksInProximity, new ChunkFrontToBackComparator());
        }
    }
View Full Code Here

    @Override
    public void onChunkUnloaded(Vector3i pos) {
        if (renderRegion.encompasses(pos)) {
            Iterator<RenderableChunk> iterator = chunksInProximity.iterator();
            while (iterator.hasNext()) {
                RenderableChunk chunk = iterator.next();
                if (chunk.getPosition().equals(pos)) {
                    chunk.disposeMesh();
                    iterator.remove();
                    Collections.sort(chunksInProximity, new ChunkFrontToBackComparator());
                    break;
                }
            }
View Full Code Here

            while (removeChunks.hasNext()) {
                Vector3i pos = removeChunks.next();

                Iterator<RenderableChunk> iterator = chunksInProximity.iterator();
                while (iterator.hasNext()) {
                    RenderableChunk chunk = iterator.next();
                    if (chunk.getPosition().equals(pos)) {
                        chunk.disposeMesh();
                        iterator.remove();
                        break;
                    }
                }
            }

            Iterator<Vector3i> addChunks = newRegion.subtract(renderRegion);
            while (addChunks.hasNext()) {
                Vector3i pos = addChunks.next();
                RenderableChunk c = chunkProvider.getChunk(pos);
                if (c != null) {
                    chunksInProximity.add(c);
                }
            }
View Full Code Here

            PerformanceMonitor.endActivity();
        }

        int processedChunks = 0;
        for (int i = 0; i < chunksInProximity.size(); i++) {
            RenderableChunk c = chunksInProximity.get(i);
            ChunkMesh[] mesh = c.getMesh();

            if (i < TeraMath.clamp(config.getRendering().getMaxChunksUsedForShadowMapping(), 64, 1024)
                    && config.getRendering().isDynamicShadows() && fillShadowRenderQueue) {
                if (isChunkVisibleLight(c) && isChunkValidForRender(c)) {
                    if (triangleCount(mesh, ChunkMesh.RenderPhase.OPAQUE) > 0) {
                        renderQueueChunksOpaqueShadow.add(c);
                    } else {
                        statIgnoredPhases++;
                    }
                }
            }

            if (isChunkValidForRender(c)) {
                if (isChunkVisible(c)) {
                    if (triangleCount(mesh, ChunkMesh.RenderPhase.OPAQUE) > 0) {
                        renderQueueChunksOpaque.add(c);
                    } else {
                        statIgnoredPhases++;
                    }

                    if (triangleCount(mesh, ChunkMesh.RenderPhase.REFRACTIVE) > 0) {
                        renderQueueChunksAlphaBlend.add(c);
                    } else {
                        statIgnoredPhases++;
                    }

                    if (triangleCount(mesh, ChunkMesh.RenderPhase.ALPHA_REJECT) > 0 && i < MAX_BILLBOARD_CHUNKS) {
                        renderQueueChunksAlphaReject.add(c);
                    } else {
                        statIgnoredPhases++;
                    }

                    statVisibleChunks++;

                    if (statVisibleChunks < MAX_ANIMATED_CHUNKS) {
                        c.setAnimated(true);
                    } else {
                        c.setAnimated(false);
                    }
                }

                if (isChunkVisibleReflection(c)) {
                    renderQueueChunksOpaqueReflection.add(c);
View Full Code Here

        Vector3i viewingDistance = config.getRendering().getViewDistance().getChunkDistance();

        chunkProvider.completeUpdate();
        chunkProvider.beginUpdate();
        for (Vector3i pos : Region3i.createFromCenterExtents(newChunkPos, new Vector3i(viewingDistance.x / 2, viewingDistance.y / 2, viewingDistance.z / 2))) {
            RenderableChunk chunk = chunkProvider.getChunk(pos);
            if (chunk == null) {
                complete = false;
            } else if (chunk.isDirty()) {
                ChunkView view = worldProvider.getLocalView(chunk.getPosition());
                if (view == null) {
                    continue;
                }
                chunk.setDirty(false);

                ChunkMesh[] newMeshes = new ChunkMesh[VERTICAL_SEGMENTS];
                for (int seg = 0; seg < VERTICAL_SEGMENTS; seg++) {
                    newMeshes[seg] = chunkTessellator.generateMesh(view,
                        ChunkConstants.SIZE_Y / VERTICAL_SEGMENTS, seg * (ChunkConstants.SIZE_Y / VERTICAL_SEGMENTS));
                }

                chunk.setPendingMesh(newMeshes);

                if (chunk.getPendingMesh() != null) {

                    for (int j = 0; j < chunk.getPendingMesh().length; j++) {
                        chunk.getPendingMesh()[j].generateVBOs();
                    }
                    if (chunk.getMesh() != null) {
                        for (int j = 0; j < chunk.getMesh().length; j++) {
                            chunk.getMesh()[j].dispose();
                        }
                    }
                    chunk.setMesh(chunk.getPendingMesh());
                    chunk.setPendingMesh(null);
                }
                return false;
            }
        }
        return complete;
View Full Code Here

            Region3i viewRegion = Region3i.createFromCenterExtents(newChunkPos, new Vector3i(viewingDistance.x / 2, viewingDistance.y / 2, viewingDistance.z / 2));
            if (chunksInProximity.size() == 0 || force || pendingChunks) {
                // just add all visible chunks
                chunksInProximity.clear();
                for (Vector3i chunkPosition : viewRegion) {
                    RenderableChunk c = chunkProvider.getChunk(chunkPosition);
                    if (c != null && worldProvider.getLocalView(c.getPosition()) != null) {
                        chunksInProximity.add(c);
                    } else {
                        chunksCurrentlyPending = true;
                    }
                }
            } else {
                Region3i oldRegion = Region3i.createFromCenterExtents(chunkPos, new Vector3i(viewingDistance.x / 2, viewingDistance.y / 2, viewingDistance.z / 2));

                Iterator<Vector3i> chunksForRemove = oldRegion.subtract(viewRegion);
                // remove
                while (chunksForRemove.hasNext()) {
                    Vector3i r = chunksForRemove.next();
                    RenderableChunk c = chunkProvider.getChunk(r);
                    if (c != null) {
                        chunksInProximity.remove(c);
                        c.disposeMesh();
                    }
                }

                // add
                for (Vector3i chunkPosition : viewRegion) {
                    RenderableChunk c = chunkProvider.getChunk(chunkPosition);
                    if (c != null && worldProvider.getLocalView(c.getPosition()) != null) {
                        chunksInProximity.add(c);
                    } else {
                        chunksCurrentlyPending = true;
                    }
                }
View Full Code Here

TOP

Related Classes of org.terasology.world.chunks.RenderableChunk

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.