mostly time-consistent gravity
This commit is contained in:
parent
eb4e31a182
commit
ec715c4ee2
@ -834,7 +834,8 @@ function new_player(settings)
|
|||||||
this.vz = this.vz * alt_a
|
this.vz = this.vz * alt_a
|
||||||
|
|
||||||
if this.mode == PLM_NORMAL then
|
if this.mode == PLM_NORMAL then
|
||||||
this.vy = (this.vy + 2.0*MODE_GRAVITY*sec_delta) * alt_a
|
--this.vy = (this.vy + 2.0*MODE_GRAVITY*sec_delta) * alt_a
|
||||||
|
this.vy = (this.vy + 2.0*MODE_GRAVITY*sec_delta)
|
||||||
else
|
else
|
||||||
this.vy = (this.vy + mvy*mmul) * alt_a
|
this.vy = (this.vy + mvy*mmul) * alt_a
|
||||||
end
|
end
|
||||||
@ -1135,6 +1136,15 @@ function new_player(settings)
|
|||||||
local tx1,ty1,tz1
|
local tx1,ty1,tz1
|
||||||
ox, oy, oz = this.x, this.y, this.z
|
ox, oy, oz = this.x, this.y, this.z
|
||||||
nx, ny, nz = this.x + this.vx*sec_delta, this.y + this.vy*sec_delta, this.z + this.vz*sec_delta
|
nx, ny, nz = this.x + this.vx*sec_delta, this.y + this.vy*sec_delta, this.z + this.vz*sec_delta
|
||||||
|
if this.mode == PLM_NORMAL then
|
||||||
|
-- mostly correct gravity
|
||||||
|
-- FIXME: physics is still a bit of a hack
|
||||||
|
-- FIXME: need to incorporate air friction properly
|
||||||
|
local alt_a = math.exp(-sec_delta*mvchange*MODE_PSPEED_CONV_BRAKES)
|
||||||
|
local accel_grav = 2.0*MODE_GRAVITY
|
||||||
|
ny = ny + accel_grav/2.0*sec_delta*sec_delta
|
||||||
|
end
|
||||||
|
|
||||||
local wasgrounded = this.grounded
|
local wasgrounded = this.grounded
|
||||||
tx1, ty1, tz1 = this.calc_motion_trace(sec_current, sec_delta, ox, oy, oz, nx, ny, nz)
|
tx1, ty1, tz1 = this.calc_motion_trace(sec_current, sec_delta, ox, oy, oz, nx, ny, nz)
|
||||||
this.x, this.y, this.z = tx1, ty1, tz1
|
this.x, this.y, this.z = tx1, ty1, tz1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user