mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
better buoyancy but still wip
This commit is contained in:
@@ -347,11 +347,11 @@ $BULLET Foleys:
|
|||||||
℗ 2011, 2013, 2015, 2020, 2021 Klankbeeld
|
℗ 2011, 2013, 2015, 2020, 2021 Klankbeeld
|
||||||
Sound from <https://www.freesound.org/people/klankbeeld>
|
Sound from <https://www.freesound.org/people/klankbeeld>
|
||||||
|
|
||||||
- effects/steps/GRSS.*.ogg
|
- effects/{mining|steps}/GRSS.*.wav
|
||||||
- effects/steps/GRVL.*.ogg
|
- effects/{mining|steps}/GRVL.*.wav
|
||||||
- effects/steps/ROCK.*.ogg
|
- effects/{mining|steps}/ROCK.*.wav
|
||||||
- effects/steps/SAND.*.ogg
|
- effects/{mining|steps}/SAND.*.wav
|
||||||
- effects/steps/WOOD.*.ogg
|
- effects/{mining|steps}/WOOD.*.wav
|
||||||
- effects/door/wooden_open.*.ogg
|
- effects/door/wooden_open.*.ogg
|
||||||
- effects/door/wooden_close.*.ogg
|
- effects/door/wooden_close.*.ogg
|
||||||
℗ 2020, 2021, 2022 Nox Sound
|
℗ 2020, 2021, 2022 Nox Sound
|
||||||
@@ -373,12 +373,12 @@ Sound from <https://freesound.org/people/joedeshon>
|
|||||||
℗ 2019 DrinkingWindGames
|
℗ 2019 DrinkingWindGames
|
||||||
Sound from <https://freesound.org/people/DrinkingWindGames>
|
Sound from <https://freesound.org/people/DrinkingWindGames>
|
||||||
|
|
||||||
- effects/explosion/bang_bomb.ogg
|
- effects/explosion/bang_bomb.wav
|
||||||
℗ 2019 Richwise
|
℗ 2019 Richwise
|
||||||
Sound from <https://freesound.org/people/richwise>
|
Remixed sound from <https://freesound.org/people/richwise>
|
||||||
|
|
||||||
- effects/explosion/fuse.ogg
|
- effects/explosion/fuse.wav
|
||||||
- effects/explosion/fuse_continue.ogg
|
- effects/explosion/fuse_continue.wav
|
||||||
℗ 2012, 2015 j1987 and ScouseMouseJB
|
℗ 2012, 2015 j1987 and ScouseMouseJB
|
||||||
Remixed sound from <https://freesound.org/people/j1987> and <https://freesound.org/people/ScouseMouseJB>
|
Remixed sound from <https://freesound.org/people/j1987> and <https://freesound.org/people/ScouseMouseJB>
|
||||||
|
|
||||||
@@ -394,6 +394,11 @@ Sound from <https://freesound.org/people/CuriousTorvald/>
|
|||||||
℗ 2013 Ubikphonik
|
℗ 2013 Ubikphonik
|
||||||
Sound from <https://freesound.org/people/UbikPhonik/>
|
Sound from <https://freesound.org/people/UbikPhonik/>
|
||||||
|
|
||||||
|
- effects/throwing/throw_low_short.wav
|
||||||
|
℗ 2023 Killerkipler
|
||||||
|
Remixed sound from <https://freesound.org/people/killerkipler/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$BULLET Impulse Responses:
|
$BULLET Impulse Responses:
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,11 @@ import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
|||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.blockproperties.BlockProp
|
import net.torvald.terrarum.blockproperties.BlockProp
|
||||||
import net.torvald.terrarum.blockproperties.Fluid
|
|
||||||
import net.torvald.terrarum.blockproperties.FluidCodex
|
|
||||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||||
import net.torvald.terrarum.gameitems.ItemID
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
import net.torvald.terrarum.gameparticles.createRandomBlockParticle
|
import net.torvald.terrarum.gameparticles.createRandomBlockParticle
|
||||||
import net.torvald.terrarum.gameworld.BlockAddress
|
import net.torvald.terrarum.gameworld.BlockAddress
|
||||||
|
import net.torvald.terrarum.gameworld.FLUID_MIN_MASS
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.itemproperties.Calculate
|
import net.torvald.terrarum.itemproperties.Calculate
|
||||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||||
@@ -690,10 +689,7 @@ open class ActorWithBody : Actor {
|
|||||||
feetPosPoint.set(hitbox.centeredX, hitbox.endY)
|
feetPosPoint.set(hitbox.centeredX, hitbox.endY)
|
||||||
feetPosTile.set(hIntTilewiseHitbox.centeredX.floorToInt(), hIntTilewiseHitbox.endY.floorToInt())
|
feetPosTile.set(hIntTilewiseHitbox.centeredX.floorToInt(), hIntTilewiseHitbox.endY.floorToInt())
|
||||||
|
|
||||||
submergedHeight = max(
|
submergedHeight = getSubmergedHeight()
|
||||||
getContactingAreaFluid(COLLIDING_LEFT),
|
|
||||||
getContactingAreaFluid(COLLIDING_RIGHT)
|
|
||||||
).toDouble()
|
|
||||||
submergedVolume = submergedHeight * hitbox.width * hitbox.width
|
submergedVolume = submergedHeight * hitbox.width * hitbox.width
|
||||||
submergedRatio = if (hitbox.height == 0.0) throw RuntimeException("Hitbox.height is zero")
|
submergedRatio = if (hitbox.height == 0.0) throw RuntimeException("Hitbox.height is zero")
|
||||||
else submergedHeight / hitbox.height
|
else submergedHeight / hitbox.height
|
||||||
@@ -712,6 +708,11 @@ open class ActorWithBody : Actor {
|
|||||||
// isStationary = (hitbox - oldHitbox).magnitudeSquared < PHYS_EPSILON_VELO
|
// isStationary = (hitbox - oldHitbox).magnitudeSquared < PHYS_EPSILON_VELO
|
||||||
isStationary = isCloseEnough(hitbox.startX, oldHitbox.startX) && // this is supposed to be more accurate, idk
|
isStationary = isCloseEnough(hitbox.startX, oldHitbox.startX) && // this is supposed to be more accurate, idk
|
||||||
isCloseEnough(hitbox.startY, oldHitbox.startY)
|
isCloseEnough(hitbox.startY, oldHitbox.startY)
|
||||||
|
|
||||||
|
|
||||||
|
if (this is IngamePlayer) {
|
||||||
|
printdbg(this, "Submerged=$submergedVolume rho=$tileDensityFluid")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDrag(externalForce: Vector2): Vector2 {
|
fun getDrag(externalForce: Vector2): Vector2 {
|
||||||
@@ -1507,8 +1508,29 @@ open class ActorWithBody : Actor {
|
|||||||
// TODO: as for the platform, only apply it when it's a feet tile
|
// TODO: as for the platform, only apply it when it's a feet tile
|
||||||
|
|
||||||
|
|
||||||
|
private fun getSubmergedHeight(): Double {
|
||||||
|
if (world == null) return 0.0
|
||||||
|
val straightGravity = (world!!.gravitation.y > 0)
|
||||||
|
|
||||||
private fun getContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int {
|
val dbgTYLs = HashSet<Int>()
|
||||||
|
|
||||||
|
val txL = (hitbox.startX / TILE_SIZED).floorToInt()
|
||||||
|
val txR = (hitbox.endX / TILE_SIZED).floorToInt()
|
||||||
|
var hL = 0
|
||||||
|
var hR = 0
|
||||||
|
for (q in 0 until hitbox.height.toInt()) {
|
||||||
|
val y = if (straightGravity) hitbox.endY - q else hitbox.startX + q
|
||||||
|
val ty = (y / TILE_SIZED).floorToInt()
|
||||||
|
if (world!!.getFluid(txL, ty).amount >= FLUID_MIN_MASS) hL += 1
|
||||||
|
if (world!!.getFluid(txR, ty).amount >= FLUID_MIN_MASS) hR += 1
|
||||||
|
dbgTYLs.add(ty)
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns average of two sides
|
||||||
|
return (hL + hR) / 2.0
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun xxxxgetContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int {
|
||||||
if (world == null) return 0
|
if (world == null) return 0
|
||||||
|
|
||||||
var contactAreaCounter = 0
|
var contactAreaCounter = 0
|
||||||
@@ -1621,7 +1643,7 @@ open class ActorWithBody : Actor {
|
|||||||
* F(bo) = density * submerged_volume * gravitational_acceleration [N]
|
* F(bo) = density * submerged_volume * gravitational_acceleration [N]
|
||||||
*/
|
*/
|
||||||
private fun applyBuoyancy(): Vector2 {
|
private fun applyBuoyancy(): Vector2 {
|
||||||
val rho = FluidCodex[Fluid.WATER].density //tileDensityFluid // kg / m^3
|
val rho = tileDensityFluid // kg / m^3
|
||||||
val V = submergedVolume / (METER.pow(3)) // m^3
|
val V = submergedVolume / (METER.pow(3)) // m^3
|
||||||
val g = world?.gravitation ?: Vector2() // m / s^2
|
val g = world?.gravitation ?: Vector2() // m / s^2
|
||||||
val F = g * (rho * V / SI_TO_GAME_VELO) // Newtons = kg * m / s^2
|
val F = g * (rho * V / SI_TO_GAME_VELO) // Newtons = kg * m / s^2
|
||||||
|
|||||||
@@ -263,6 +263,8 @@ open class GameWorld(
|
|||||||
fun coordInWorldStrict(x: Int, y: Int) = x in 0 until width && y in 0 until height // ROUNDWORLD implementation
|
fun coordInWorldStrict(x: Int, y: Int) = x in 0 until width && y in 0 until height // ROUNDWORLD implementation
|
||||||
|
|
||||||
fun renumberTilesAfterLoad() {
|
fun renumberTilesAfterLoad() {
|
||||||
|
printdbg(this, "renumberTilesAfterLoad()")
|
||||||
|
|
||||||
// patch the "old"map
|
// patch the "old"map
|
||||||
tileNumberToNameMap[0] = Block.AIR
|
tileNumberToNameMap[0] = Block.AIR
|
||||||
tileNumberToNameMap[1] = Block.UPDATE
|
tileNumberToNameMap[1] = Block.UPDATE
|
||||||
@@ -307,6 +309,8 @@ open class GameWorld(
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlocksDrawer.rebuildInternalPrecalculations()
|
BlocksDrawer.rebuildInternalPrecalculations()
|
||||||
|
|
||||||
|
printdbg(this, "renumberTilesAfterLoad done!")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -769,7 +773,7 @@ open class GameWorld(
|
|||||||
|
|
||||||
val fluidNumber = tileNameToNumberMap[fluidType] ?: throw NullPointerException("No such fluid: $fluidType")
|
val fluidNumber = tileNameToNumberMap[fluidType] ?: throw NullPointerException("No such fluid: $fluidType")
|
||||||
|
|
||||||
if (fill > WorldSimulator.FLUID_MIN_MASS) {
|
if (fill > FLUID_MIN_MASS) {
|
||||||
//setTileTerrain(x, y, fluidTypeToBlock(fluidType))
|
//setTileTerrain(x, y, fluidTypeToBlock(fluidType))
|
||||||
layerFluids.unsafeSetTile(x, y, fluidNumber, fill)
|
layerFluids.unsafeSetTile(x, y, fluidNumber, fill)
|
||||||
}
|
}
|
||||||
@@ -804,7 +808,7 @@ open class GameWorld(
|
|||||||
|
|
||||||
data class FluidInfo(val type: ItemID = Fluid.NULL, val amount: Float = 0f) {
|
data class FluidInfo(val type: ItemID = Fluid.NULL, val amount: Float = 0f) {
|
||||||
/** test if this fluid should be considered as one */
|
/** test if this fluid should be considered as one */
|
||||||
fun isFluid() = type != Fluid.NULL && amount >= WorldSimulator.FLUID_MIN_MASS
|
fun isFluid() = type != Fluid.NULL && amount >= FLUID_MIN_MASS
|
||||||
fun getProp() = FluidCodex[type]
|
fun getProp() = FluidCodex[type]
|
||||||
override fun toString() = "Fluid type: ${type}, amount: $amount"
|
override fun toString() = "Fluid type: ${type}, amount: $amount"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ object WorldSimulator {
|
|||||||
|
|
||||||
const val FLUID_MAX_MASS = 1f // The normal, un-pressurized mass of a full water cell
|
const val FLUID_MAX_MASS = 1f // The normal, un-pressurized mass of a full water cell
|
||||||
const val FLUID_MAX_COMP = 0.02f // How much excess water a cell can store, compared to the cell above it. A tile of fluid can contain more than MaxMass water.
|
const val FLUID_MAX_COMP = 0.02f // How much excess water a cell can store, compared to the cell above it. A tile of fluid can contain more than MaxMass water.
|
||||||
const val FLUID_MIN_MASS = net.torvald.terrarum.gameworld.FLUID_MIN_MASS //Ignore cells that are almost dry (smaller than epsilon of float16)
|
// const val FLUID_MIN_MASS = net.torvald.terrarum.gameworld.FLUID_MIN_MASS //Ignore cells that are almost dry (smaller than epsilon of float16)
|
||||||
const val minFlow = 1f / 512f
|
const val minFlow = 1f / 512f
|
||||||
const val maxSpeed = 1f // max units of water moved out of one block to another, per timestamp
|
const val maxSpeed = 1f // max units of water moved out of one block to another, per timestamp
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
|||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||||
import net.torvald.terrarum.gameitems.ItemID
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
|
import net.torvald.terrarum.gameworld.FLUID_MIN_MASS
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.gameworld.fmod
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
import net.torvald.terrarum.modulebasegame.WorldSimulator.FLUID_MIN_MASS
|
|
||||||
import net.torvald.terrarum.realestate.LandUtil
|
import net.torvald.terrarum.realestate.LandUtil
|
||||||
import net.torvald.terrarum.serialise.toBig64
|
import net.torvald.terrarum.serialise.toBig64
|
||||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.Companion.WALL_OVERLAY_COLOUR
|
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.Companion.WALL_OVERLAY_COLOUR
|
||||||
|
|||||||
BIN
work_files/graphics/terrain/fluid_wetting.kra
LFS
Normal file
BIN
work_files/graphics/terrain/fluid_wetting.kra
LFS
Normal file
Binary file not shown.
Reference in New Issue
Block a user