Skip to content

Commit

Permalink
Add BiomeStructure.Factory.createIndexStructure, for biome palette in…
Browse files Browse the repository at this point in the history
…dices implementation

It defaults to the previous implementation
  • Loading branch information
NotStirred committed May 21, 2022
1 parent 78e36c8 commit 01941b8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 1 addition & 6 deletions chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java
Expand Up @@ -966,13 +966,8 @@ public synchronized void loadChunks(TaskTracker taskTracker, World world, Collec
Set<ChunkPosition> nonEmptyChunks = new HashSet<>();
Set<ChunkPosition> legacyChunks = new HashSet<>();

Position2IntStructure biomePaletteIdxStructure;
Position2IntStructure biomePaletteIdxStructure = biomeStructureFactory.createIndexStructure();
boolean use3dBiomes = biomeStructureFactory.is3d();
if (use3dBiomes) {
biomePaletteIdxStructure = new Position3d2IntPackedArray();
} else {
biomePaletteIdxStructure = new Position2d2IntPackedArray();
}

final Mutable<ChunkData> chunkData1 = new Mutable<>(null); // chunk loading will switch between these two, using one asynchronously to load the data
final Mutable<ChunkData> chunkData2 = new Mutable<>(null); // while the other is used to add to the octree
Expand Down
Expand Up @@ -4,7 +4,10 @@
import se.llbit.chunky.world.Chunk;
import se.llbit.chunky.world.WorldTexture;
import se.llbit.log.Log;
import se.llbit.math.structures.Position2IntStructure;
import se.llbit.math.structures.Position2ReferenceStructure;
import se.llbit.math.structures.Position2d2IntPackedArray;
import se.llbit.math.structures.Position3d2IntPackedArray;
import se.llbit.util.annotation.NotNull;

import java.io.DataInputStream;
Expand Down Expand Up @@ -198,6 +201,18 @@ interface Factory {
*/
BiomeStructure create();

/**
* Create an empty {@link Position2IntStructure} for the biome palette indices
* (used only for biome blending, does not need to be saved)
*/
default Position2IntStructure createIndexStructure() {
if(is3d()) {
return new Position3d2IntPackedArray();
} else {
return new Position2d2IntPackedArray();
}
}

/**
* Load a saved {@link BiomeStructure} of this implementation from a {@link DataInputStream}
*/
Expand Down

0 comments on commit 01941b8

Please sign in to comment.