From e49313202c759f70f6cf1113c8b53471122eb7da Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 29 Jul 2012 20:15:03 +0000 Subject: DistortedVoronoi BiomeGen now uses 4x4 linear interpolation for distortion, 50 % speed increase in the chunk generator with a hardly noticeable change in biome shapes. git-svn-id: http://mc-server.googlecode.com/svn/trunk@708 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/BioGen.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source/BioGen.cpp') diff --git a/source/BioGen.cpp b/source/BioGen.cpp index 73529abb6..a43d995df 100644 --- a/source/BioGen.cpp +++ b/source/BioGen.cpp @@ -258,14 +258,25 @@ void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::B { int BaseZ = cChunkDef::Width * a_ChunkZ; int BaseX = cChunkDef::Width * a_ChunkX; + + // Distortions for linear interpolation: + int DistortX[cChunkDef::Width + 1][cChunkDef::Width + 1]; + int DistortZ[cChunkDef::Width + 1][cChunkDef::Width + 1]; + for (int x = 0; x <= 4; x++) for (int z = 0; z <= 4; z++) + { + Distort(BaseX + x * 4, BaseZ + z * 4, DistortX[4 * x][4 * z], DistortZ[4 * x][4 * z]); + } + + IntArrayLinearInterpolate2D(&DistortX[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4); + IntArrayLinearInterpolate2D(&DistortZ[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4); + for (int z = 0; z < cChunkDef::Width; z++) { int AbsoluteZ = BaseZ + z; for (int x = 0; x < cChunkDef::Width; x++) { - int DistX, DistZ; - Distort(BaseX + x, AbsoluteZ, DistX, DistZ); - cChunkDef::SetBiome(a_BiomeMap, x, z, VoronoiBiome(DistX, DistZ)); + // Distort(BaseX + x, AbsoluteZ, DistX, DistZ); + cChunkDef::SetBiome(a_BiomeMap, x, z, VoronoiBiome(DistortX[x][z], DistortZ[x][z])); } // for x } // for z } -- cgit v1.2.3