forked from MineClone5/MineClone5
Merge pull request 'Improve underwater item physics' (#351) from Gustavo6046/MineClone5:item-physics into master
Reviewed-on: MineClone5/MineClone5#351
This commit is contained in:
commit
fa46332870
|
@ -156,6 +156,10 @@ minetest.register_globalstep(function(dtime)
|
||||||
object:set_velocity({x=0,y=0,z=0})
|
object:set_velocity({x=0,y=0,z=0})
|
||||||
object:set_acceleration({x=0,y=0,z=0})
|
object:set_acceleration({x=0,y=0,z=0})
|
||||||
|
|
||||||
|
if object._flowing then
|
||||||
|
object._flowing = false
|
||||||
|
end
|
||||||
|
|
||||||
object:move_to(checkpos)
|
object:move_to(checkpos)
|
||||||
|
|
||||||
pool[name] = pool[name] + 1
|
pool[name] = pool[name] + 1
|
||||||
|
@ -795,6 +799,9 @@ minetest.register_entity(":__builtin:item", {
|
||||||
|
|
||||||
local oldvel = self.object:get_velocity() -- v is vector, vel is velocity
|
local oldvel = self.object:get_velocity() -- v is vector, vel is velocity
|
||||||
|
|
||||||
|
-- apply gravity *before* drag computations
|
||||||
|
oldvel.y = oldvel.y - get_gravity() * dtime
|
||||||
|
|
||||||
-- drag
|
-- drag
|
||||||
local fluid_drag = item_drop_settings.fluid_drag
|
local fluid_drag = item_drop_settings.fluid_drag
|
||||||
|
|
||||||
|
@ -809,12 +816,6 @@ minetest.register_entity(":__builtin:item", {
|
||||||
newv.y = newv.y - (oldvel.y - newv.y) * fluid_drag * dtime
|
newv.y = newv.y - (oldvel.y - newv.y) * fluid_drag * dtime
|
||||||
newv.z = newv.z - (oldvel.z - newv.z) * fluid_drag * dtime
|
newv.z = newv.z - (oldvel.z - newv.z) * fluid_drag * dtime
|
||||||
|
|
||||||
newv.y = newv.y + -0.22 -- (keep slight downward thrust from previous version of code)
|
|
||||||
-- NOTE: is there any particular reason we have this, anyway?
|
|
||||||
-- since fluid drag is now on, we could as well just
|
|
||||||
-- apply gravity here; drag will slow down the fall
|
|
||||||
-- realistically
|
|
||||||
|
|
||||||
self.object:set_velocity({x = oldvel.x + newv.x * dtime, y = oldvel.y + newv.y * dtime, z = oldvel.z + newv.z * dtime})
|
self.object:set_velocity({x = oldvel.x + newv.x * dtime, y = oldvel.y + newv.y * dtime, z = oldvel.z + newv.z * dtime})
|
||||||
|
|
||||||
self.physical_state = true
|
self.physical_state = true
|
||||||
|
|
Loading…
Reference in New Issue