actorwithbody splitted in favour of new particle type

Former-commit-id: 121bd069d0a9eeef60f5ecb085a11a93c4b4a84d
Former-commit-id: 539b4b6916e808c01298190cf347e928f61fe62e
This commit is contained in:
Song Minjae
2017-01-21 16:52:16 +09:00
parent c9d83455a9
commit 56a012d843
49 changed files with 752 additions and 428 deletions

View File

@@ -4,5 +4,5 @@ package net.torvald.terrarum.mapgenerator
* Created by minjaesong on 16-03-31.
*/
interface NoiseFilter {
fun getGrad(func_argX: Int, start: Float, end: Float): Float
fun getGrad(func_argX: Int, start: Double, end: Double): Double
}

View File

@@ -30,7 +30,7 @@ import com.jme3.math.FastMath
* Created by minjaesong on 16-03-31.
*/
object NoiseFilterCubic : NoiseFilter {
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
override fun getGrad(func_argX: Int, start: Double, end: Double): Double {
val graph_gradient = -FastMath.pow(FastMath.pow((1 - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat(), 3f), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
(start - end) / FastMath.pow(WorldGenerator.HEIGHT.toFloat(), 3f) *
FastMath.pow((func_argX - WorldGenerator.HEIGHT).toFloat(), 3f) + end

View File

@@ -30,7 +30,7 @@ import com.jme3.math.FastMath
* Created by minjaesong on 16-03-31.
*/
object NoiseFilterMinusQuadratic : NoiseFilter {
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
override fun getGrad(func_argX: Int, start: Double, end: Double): Double {
val graph_gradient = -FastMath.pow(FastMath.sqr((1 - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
(start - end) / FastMath.sqr(WorldGenerator.HEIGHT.toFloat()) *
FastMath.sqr((func_argX - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) + start

View File

@@ -31,7 +31,7 @@ import com.jme3.math.FastMath
* Created by minjaesong on 16-03-31.
*/
object NoiseFilterQuadratic : NoiseFilter {
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
override fun getGrad(func_argX: Int, start: Double, end: Double): Double {
val graph_gradient = FastMath.pow(FastMath.sqr((1 - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
(start - end) / FastMath.sqr(WorldGenerator.HEIGHT.toFloat()) *
FastMath.sqr((func_argX - WorldGenerator.HEIGHT).toFloat()) + end

View File

@@ -6,7 +6,7 @@ import com.jme3.math.FastMath
* Created by minjaesong on 16-03-31.
*/
object NoiseFilterSqrt : NoiseFilter {
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
override fun getGrad(func_argX: Int, start: Double, end: Double): Double {
val graph_gradient = (end - start) / FastMath.sqrt((WorldGenerator.HEIGHT - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) * FastMath.sqrt((func_argX - WorldGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) + start
if (func_argX < WorldGenerator.TERRAIN_AVERAGE_HEIGHT) {

View File

@@ -4,7 +4,7 @@ package net.torvald.terrarum.mapgenerator
* Created by minjaesong on 16-03-31.
*/
object NoiseFilterUniform : NoiseFilter {
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
return 1f
override fun getGrad(func_argX: Int, start: Double, end: Double): Double {
return 1.0
}
}

View File

@@ -32,11 +32,11 @@ object WorldGenerator {
var TERRAIN_AVERAGE_HEIGHT: Int = 0
private var minimumFloatingIsleHeight: Int = 0
private val NOISE_GRAD_START = 0.67f
private val NOISE_GRAD_END = 0.56f
private val NOISE_GRAD_START = 0.67
private val NOISE_GRAD_END = 0.56
private val NOISE_SIMPLEX_ORE_START = 1.42f
private val NOISE_SIMPLEX_ORE_END = 1.28f
private val NOISE_SIMPLEX_ORE_START = 1.42
private val NOISE_SIMPLEX_ORE_END = 1.28
private val HILL_WIDTH = 256 // power of two!
//private val MAX_HILL_HEIGHT = 100
@@ -51,8 +51,8 @@ object WorldGenerator {
private var GLACIER_MOUNTAIN_WIDTH = 900
private val GLACIER_MOUNTAIN_HEIGHT = 300
private val CAVEGEN_THRE_START = 0.95f
private val CAVEGEN_THRE_END = 0.67f
private val CAVEGEN_THRE_START = 0.95
private val CAVEGEN_THRE_END = 0.67
private var worldOceanPosition: Int = -1
@@ -113,12 +113,12 @@ object WorldGenerator {
*/
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("Collapsing caves", noiseBlobs(0.5f, 0.5f), 0.3f, Tile.AIR, Tile.STONE, Tile.STONE, NoiseFilterUniform)
TaggedJoise("Carving caves", noiseRidged(1.7, 1.4), 1.0, TILE_MACRO_ALL, TILE_MACRO_ALL, Tile.AIR, NoiseFilterSqrt, CAVEGEN_THRE_START, CAVEGEN_THRE_END)
, TaggedJoise("Collapsing caves", noiseBlobs(0.5), 0.3, 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("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("Quarrying some stone into gravels", noiseBlobs(0.5f, 0.5f), 0.98f, Tile.STONE, Tile.STONE, Tile.GRAVEL, NoiseFilterQuadratic, NOISE_GRAD_END, NOISE_GRAD_START)
//, TaggedJoise("Putting stone patches on the ground", noiseBlobs(0.8), 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.5), 0.98f, Tile.STONE, Tile.STONE, Tile.DIRT, NoiseFilterQuadratic, NOISE_GRAD_END, NOISE_GRAD_START)
//, TaggedJoise("Quarrying some stone into gravels", noiseBlobs(0.5), 0.98f, Tile.STONE, Tile.STONE, Tile.GRAVEL, NoiseFilterQuadratic, NOISE_GRAD_END, NOISE_GRAD_START)
//
//, TaggedJoise("Growing copper veins", noiseRidged(1.7f, 1.7f), 1.68f, Tile.STONE, Tile.STONE, Tile.ORE_COPPER)
//, TaggedJoise("Cutting copper veins", noiseBlobs(0.4f, 0.4f), 0.26f, Tile.ORE_COPPER, Tile.STONE, Tile.STONE)
@@ -165,7 +165,7 @@ object WorldGenerator {
/* 1. Raise */
private fun noiseRidged(xStretch: Float, yStretch: Float): Joise {
private fun noiseRidged(xStretch: Double, yStretch: Double): Joise {
val ridged = ModuleFractal()
ridged.setType(ModuleFractal.FractalType.RIDGEMULTI)
ridged.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
@@ -185,18 +185,21 @@ object WorldGenerator {
return Joise(ridged_scale)
}
private fun noiseBlobs(xStretch: Float, yStretch: Float): Joise {
val gradval = ModuleBasisFunction()
gradval.seed = SEED xor random.nextLong()
gradval.setType(ModuleBasisFunction.BasisType.GRADVAL)
gradval.setInterpolation(ModuleBasisFunction.InterpolationType.QUINTIC)
private fun noiseBlobs(frequency: Double): Joise {
val ridged = ModuleFractal()
ridged.setType(ModuleFractal.FractalType.FBM)
ridged.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
ridged.setNumOctaves(2)
ridged.setFrequency(frequency)
ridged.seed = Random().nextLong()
val gradval_scale = ModuleScaleDomain()
gradval_scale.setScaleX(1.0 / xStretch)
gradval_scale.setScaleY(1.0 / yStretch)
gradval_scale.setSource(gradval)
val brownian_select = ModuleSelect()
brownian_select.setControlSource(ridged)
brownian_select.setThreshold(0.8)
brownian_select.setLowSource(0.0)
brownian_select.setHighSource(1.0)
return Joise(gradval_scale)
return Joise(ridged)
}
/**
@@ -596,8 +599,8 @@ object WorldGenerator {
*/
private fun carveByMap(noisemap: Any, scarcity: Float, tile: Int, message: String,
filter: NoiseFilter = NoiseFilterQuadratic,
filterStart: Float = NOISE_GRAD_START,
filterEnd: Float = NOISE_GRAD_END) {
filterStart: Double = NOISE_GRAD_START,
filterEnd: Double = NOISE_GRAD_END) {
println("[mapgenerator] " + message)
for (y in 0..HEIGHT - 1) {
@@ -626,8 +629,8 @@ object WorldGenerator {
private fun fillByMap(noisemap: Any, scarcity: Float, replaceFrom: Int, replaceTo: Int, message: String,
filter: NoiseFilter = NoiseFilterQuadratic,
filterStart: Float = NOISE_GRAD_START,
filterEnd: Float = NOISE_GRAD_END) {
filterStart: Double = NOISE_GRAD_START,
filterEnd: Double = NOISE_GRAD_END) {
println("[mapgenerator] " + message)
for (y in 0..HEIGHT - 1) {
@@ -657,8 +660,8 @@ object WorldGenerator {
private fun fillByMap(noisemap: Any, scarcity: Float, replaceFrom: Int, tile: IntArray, message: String,
filter: NoiseFilter = NoiseFilterQuadratic,
filterStart: Float = NOISE_GRAD_START,
filterEnd: Float = NOISE_GRAD_END) {
filterStart: Double = NOISE_GRAD_START,
filterEnd: Double = NOISE_GRAD_END) {
println("[mapgenerator] " + message)
for (y in 0..HEIGHT - 1) {
@@ -953,10 +956,10 @@ object WorldGenerator {
data class TaggedSimplexNoise(var noiseModule: SimplexNoise, var xStretch: Float, var yStretch: Float)
data class TaggedJoise(var message: String,
var noiseModule: Joise, var scarcity: Float,
var noiseModule: Joise, var scarcity: Double,
var replaceFromTerrain: Any, var replaceFromWall: Int,
var replaceTo: Any,
var filter: NoiseFilter = NoiseFilterQuadratic,
var filterArg1: Float = NOISE_GRAD_START,
var filterArg2: Float = NOISE_GRAD_END)
var filterArg1: Double = NOISE_GRAD_START,
var filterArg2: Double = NOISE_GRAD_END)
}