mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
another wip
This commit is contained in:
@@ -481,7 +481,7 @@ open class ActorWithBody : Actor {
|
||||
* @param acc acceleration in Vector2, the unit is [px / InternalFrame^2]
|
||||
*/
|
||||
fun applyAcceleration(acc: Vector2) {
|
||||
externalV += acc * speedMultByTile
|
||||
externalV += acc
|
||||
}
|
||||
|
||||
private fun Vector2.applyViscoseDrag() {
|
||||
@@ -584,11 +584,11 @@ open class ActorWithBody : Actor {
|
||||
// printdbg(this, "BodyViscosity=$bodyViscosity FeetViscosity=$feetViscosity BodyFriction=$bodyFriction FeetFriction=$feetFriction")
|
||||
// }
|
||||
|
||||
externalV.applyViscoseDrag()
|
||||
// externalV.applyViscoseDrag()
|
||||
|
||||
// controllerV?.let {
|
||||
// it.applyViscoseDrag()
|
||||
// }
|
||||
controllerV?.let {
|
||||
it.applyViscoseDrag()
|
||||
}
|
||||
|
||||
val vecSum = (externalV + (controllerV ?: Vector2(0.0, 0.0)))
|
||||
/**
|
||||
@@ -653,7 +653,7 @@ open class ActorWithBody : Actor {
|
||||
|
||||
// --> Apply more forces <-- //
|
||||
// Actors are subject to the gravity and the buoyancy if they are not levitating
|
||||
val buoyancy = applyBuoyancy() * speedMultByTile
|
||||
val buoyancy = applyBuoyancy()
|
||||
if (!isNoSubjectToGrav) {
|
||||
hitbox.translate(buoyancy)
|
||||
clampHitbox()
|
||||
@@ -1681,11 +1681,11 @@ open class ActorWithBody : Actor {
|
||||
if (world == null) return Vector2()
|
||||
|
||||
val rho = tileDensityFluid // kg / m^3
|
||||
// V = submergedHeight in meters * f(object density)
|
||||
val V = mass * density // m^3
|
||||
val V_full = mass / density // density = mass / volume, simply rearrange this
|
||||
val V = V_full * submergedRatio
|
||||
val g = world!!.gravitation // m / s^2
|
||||
val F_k = g * mass // Newtons = kg * m / s^2
|
||||
val F_bo = (g * mass) * (rho / density) * submergedRatio
|
||||
val F_bo = g * (rho * V) // Newtons
|
||||
|
||||
// mh'' = mg - rho*gv
|
||||
// h'' = (mg - rho*gv) / m
|
||||
|
||||
@@ -866,7 +866,6 @@ object IngameRenderer : Disposable {
|
||||
}
|
||||
|
||||
private val bodyFriction = BlockCodex[Block.AIR].friction.frictionToMult()
|
||||
private val bodyViscosity = FluidCodex[Block.AIR].viscosity.viscosityToMult()
|
||||
|
||||
|
||||
private fun applyGravitation(gravitation: Vector2, hitboxWidth: Double) {
|
||||
@@ -877,8 +876,7 @@ object IngameRenderer : Disposable {
|
||||
private fun Int.viscosityToMult(): Double = 16.0 / (16.0 + this)
|
||||
|
||||
private fun applyForce(acc: Vector2) {
|
||||
val speedMultByTile = bodyViscosity
|
||||
externalV += acc * speedMultByTile
|
||||
externalV += acc
|
||||
}
|
||||
|
||||
private fun getDrag(externalForce: Vector2, gravitation: Vector2, hitboxWidth: Double): Vector2 {
|
||||
|
||||
@@ -499,7 +499,7 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
else {
|
||||
isWalkingH = true
|
||||
|
||||
readonly_totalX =
|
||||
readonly_totalX = speedMultByTile *
|
||||
if (absAxisVal == AXIS_KEYBOARD)
|
||||
avAcceleration * applyVelo(walkCounterX) * (if (left) -1f else 1f)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user