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_acceleration({x=0,y=0,z=0})
|
||||
|
||||
if object._flowing then
|
||||
object._flowing = false
|
||||
end
|
||||
|
||||
object:move_to(checkpos)
|
||||
|
||||
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
|
||||
|
||||
-- apply gravity *before* drag computations
|
||||
oldvel.y = oldvel.y - get_gravity() * dtime
|
||||
|
||||
-- drag
|
||||
local fluid_drag = item_drop_settings.fluid_drag
|
||||
|
||||
|
@ -808,12 +815,6 @@ minetest.register_entity(":__builtin:item", {
|
|||
newv.x = newv.x - (oldvel.x - newv.x) * 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.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})
|
||||
|
||||
|
|
Loading…
Reference in New Issue