mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
cavegen now loops (fine-tune required)
Former-commit-id: 5a59323f39ca1cfcfcc0c89c0d7f71f0e2d92762 Former-commit-id: f7d35ae69fcb49af0d1342624eb9f3b0027db398
This commit is contained in:
@@ -36,5 +36,11 @@ class PhysTestBall : ActorWithBody() {
|
|||||||
hitbox.posY.toFloat(),
|
hitbox.posY.toFloat(),
|
||||||
hitbox.width.toFloat(),
|
hitbox.width.toFloat(),
|
||||||
hitbox.height.toFloat())
|
hitbox.height.toFloat())
|
||||||
|
|
||||||
|
g.fillOval(
|
||||||
|
hitbox.posX.toFloat() - Terrarum.ingame.world.width * TILE_SIZE,
|
||||||
|
hitbox.posY.toFloat(),
|
||||||
|
hitbox.width.toFloat(),
|
||||||
|
hitbox.height.toFloat())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,10 +12,21 @@ class ThreadProcessNoiseLayers(val startIndex: Int, val endIndex: Int,
|
|||||||
println("[mapgenerator] ${record.message}...")
|
println("[mapgenerator] ${record.message}...")
|
||||||
for (y in startIndex..endIndex) {
|
for (y in startIndex..endIndex) {
|
||||||
for (x in 0..WorldGenerator.WIDTH - 1) {
|
for (x in 0..WorldGenerator.WIDTH - 1) {
|
||||||
val noise: Float = record.noiseModule.get(
|
// straight-line sampling
|
||||||
|
/*val noise: Float = record.noiseModule.get(
|
||||||
x.toDouble() / 48.0, // 48: Fixed value
|
x.toDouble() / 48.0, // 48: Fixed value
|
||||||
y.toDouble() / 48.0
|
y.toDouble() / 48.0
|
||||||
).toFloat()
|
).toFloat()*/
|
||||||
|
// circular sampling
|
||||||
|
// Mapping function:
|
||||||
|
// World(x, y) -> Joise(sin x, y, cos x)
|
||||||
|
val sampleDensity = 48.0 / 2 // 48.0: magic number from old code
|
||||||
|
val sampleTheta = (x.toDouble() / WorldGenerator.WIDTH) * WorldGenerator.TWO_PI
|
||||||
|
val sampleOffset = (WorldGenerator.WIDTH / sampleDensity) / 8.0
|
||||||
|
val sampleX = Math.sin(sampleTheta) * sampleOffset + sampleOffset // plus sampleOffset to make only
|
||||||
|
val sampleY = Math.cos(sampleTheta) * sampleOffset + sampleOffset // positive points are to be sampled
|
||||||
|
val sampleZ = y / sampleDensity
|
||||||
|
val noise: Double = record.noiseModule.get(sampleX, sampleY, sampleZ)
|
||||||
|
|
||||||
val fromTerr = record.replaceFromTerrain
|
val fromTerr = record.replaceFromTerrain
|
||||||
val fromWall = record.replaceFromWall
|
val fromWall = record.replaceFromWall
|
||||||
|
|||||||
@@ -111,9 +111,9 @@ object WorldGenerator {
|
|||||||
* Done: variants of beach (SAND, SAND_BEACH, SAND_BLACK, SAND_GREEN)
|
* Done: variants of beach (SAND, SAND_BEACH, SAND_BLACK, SAND_GREEN)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//val noiseArray = arrayOf(
|
val noiseArray = arrayOf(
|
||||||
// TaggedJoise("Carving caves", noiseRidged(1.7f, 1.4f), 1f, TILE_MACRO_ALL, TILE_MACRO_ALL, Tile.AIR, NoiseFilterSqrt, CAVEGEN_THRE_START, CAVEGEN_THRE_END)
|
TaggedJoise("Carving caves", noiseRidged(1.7f, 1.4f), 1f, TILE_MACRO_ALL, TILE_MACRO_ALL, Tile.AIR, NoiseFilterSqrt, CAVEGEN_THRE_START, CAVEGEN_THRE_END)
|
||||||
//, TaggedJoise("Collapsing caves", noiseBlobs(0.5f, 0.5f), 0.3f, Tile.AIR, Tile.STONE, Tile.STONE, NoiseFilterUniform)
|
, TaggedJoise("Collapsing caves", noiseBlobs(0.5f, 0.5f), 0.3f, Tile.AIR, Tile.STONE, Tile.STONE, NoiseFilterUniform)
|
||||||
//
|
//
|
||||||
//, TaggedJoise("Putting stone patches on the ground", noiseBlobs(0.8f, 0.8f), 1.02f, intArrayOf(Tile.DIRT, Tile.GRASS), Tile.DIRT, Tile.STONE, NoiseFilterQuadratic, NOISE_GRAD_END, NOISE_GRAD_START)
|
//, TaggedJoise("Putting stone patches on the ground", noiseBlobs(0.8f, 0.8f), 1.02f, intArrayOf(Tile.DIRT, Tile.GRASS), Tile.DIRT, Tile.STONE, NoiseFilterQuadratic, NOISE_GRAD_END, NOISE_GRAD_START)
|
||||||
//, TaggedJoise("Placing dirt spots in the cave", noiseBlobs(0.5f, 0.5f), 0.98f, Tile.STONE, Tile.STONE, Tile.DIRT, NoiseFilterQuadratic, NOISE_GRAD_END, NOISE_GRAD_START)
|
//, TaggedJoise("Placing dirt spots in the cave", noiseBlobs(0.5f, 0.5f), 0.98f, Tile.STONE, Tile.STONE, Tile.DIRT, NoiseFilterQuadratic, NOISE_GRAD_END, NOISE_GRAD_START)
|
||||||
@@ -138,8 +138,8 @@ object WorldGenerator {
|
|||||||
//, TaggedJoise("Growing hearts of violet", noiseRidged(2.5f, 2.5f), 1.75f, Tile.STONE, Tile.STONE, Tile.RAW_AMETHYST)
|
//, TaggedJoise("Growing hearts of violet", noiseRidged(2.5f, 2.5f), 1.75f, Tile.STONE, Tile.STONE, Tile.RAW_AMETHYST)
|
||||||
//
|
//
|
||||||
//, TaggedJoise("Cutting over-grown hearts", noiseBlobs(0.7f, 0.7f), 0.17f, Tile.RAW_AMETHYST, Tile.STONE, Tile.STONE)
|
//, TaggedJoise("Cutting over-grown hearts", noiseBlobs(0.7f, 0.7f), 0.17f, Tile.RAW_AMETHYST, Tile.STONE, Tile.STONE)
|
||||||
//)
|
)
|
||||||
//processNoiseLayers(noiseArray)
|
processNoiseLayers(noiseArray)
|
||||||
|
|
||||||
/** TODO Cobaltite, Ilmenite, Aurichalcum (and possibly pitchblende?) */
|
/** TODO Cobaltite, Ilmenite, Aurichalcum (and possibly pitchblende?) */
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ object WorldGenerator {
|
|||||||
return noiseArrayLocal
|
return noiseArrayLocal
|
||||||
}
|
}
|
||||||
|
|
||||||
private val TWO_PI = Math.PI * 2.0
|
val TWO_PI = Math.PI * 2.0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http://accidentalnoise.sourceforge.net/minecraftworlds.html
|
* http://accidentalnoise.sourceforge.net/minecraftworlds.html
|
||||||
@@ -694,8 +694,8 @@ object WorldGenerator {
|
|||||||
ThreadPool.map(
|
ThreadPool.map(
|
||||||
i,
|
i,
|
||||||
ThreadProcessNoiseLayers(
|
ThreadProcessNoiseLayers(
|
||||||
((HEIGHT / Terrarum.CORES) * i).toInt(),
|
((HEIGHT / Terrarum.CORES) * i),
|
||||||
((HEIGHT / Terrarum.CORES) * i.plus(1)).toInt() - 1,
|
((HEIGHT / Terrarum.CORES) * i.plus(1)) - 1,
|
||||||
noiseRecords
|
noiseRecords
|
||||||
),
|
),
|
||||||
"SampleJoiseMap"
|
"SampleJoiseMap"
|
||||||
|
|||||||
Reference in New Issue
Block a user