mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-04-21 14:55:15 +02:00
Work around wrong character bone rotations on Luanti 5.11+
This commit is contained in:
parent
b7b337887d
commit
3bab7a2287
2 changed files with 22 additions and 11 deletions
|
@ -527,16 +527,13 @@ function mcl_util.set_properties(obj, props)
|
|||
end
|
||||
|
||||
-- Update bones, but only when changed
|
||||
function mcl_util.set_bone_position(obj, bone, pos, rot)
|
||||
if core.get_bone_override then -- minetest >= 5.9
|
||||
local over = obj:get_bone_override(bone)
|
||||
local pos_equal = not pos or not over.position.absolute or vector.equals(vector.round(over.position.vec), vector.round(pos))
|
||||
local rot_equal = not rot or not over.rotation.absolute or vector.equals(vector.round(over.rotation.vec), vector.round(rot))
|
||||
if not pos_equal or not rot_equal then
|
||||
if pos then over.position = { vec = pos, absolute = true, interpolation = 0.1 } end
|
||||
if rot then over.rotation = { vec = rot, absolute = true, interpolation = 0.1 } end
|
||||
obj:set_bone_override(bone, over)
|
||||
end
|
||||
function mcl_util.set_bone_position(obj, bone, pos, rot, scale)
|
||||
if obj.set_bone_override then -- minetest >= 5.9
|
||||
obj:set_bone_override(bone, {
|
||||
position = pos and { vec = pos, absolute = true } or nil,
|
||||
rotation = rot and { vec = rot, absolute = true } or nil,
|
||||
scale = scale and { vec = scale, absolute = true } or nil,
|
||||
})
|
||||
else -- minetest up to 5.8
|
||||
rot = rot and rot:apply(math.deg)
|
||||
local current_pos, current_rot = obj:get_bone_position(bone)
|
||||
|
|
|
@ -114,7 +114,21 @@ end
|
|||
local node_stand, node_stand_below, node_head, node_feet, node_head_top
|
||||
local is_swimming
|
||||
|
||||
local set_bone_pos = mcl_util.set_bone_position
|
||||
-- HACK work around https://github.com/luanti-org/luanti/issues/15692
|
||||
-- Scales corresponding to default perfect 180° rotations in the character b3d model
|
||||
local bone_workaround_scales = {
|
||||
Body_Control = vector.new(-1, 1, -1),
|
||||
Leg_Right = vector.new(1, -1, -1),
|
||||
Leg_Left = vector.new(1, -1, -1),
|
||||
Cape = vector.new(1, -1, 1),
|
||||
Arm_Right_Pitch_Control = vector.new(1, -1, -1),
|
||||
Arm_Left_Pitch_Control = vector.new(1, -1, -1),
|
||||
}
|
||||
|
||||
local function set_bone_pos(player, bonename, pos, rot)
|
||||
return mcl_util.set_bone_position(player, bonename, pos, rot, bone_workaround_scales[bonename])
|
||||
end
|
||||
|
||||
local set_properties = mcl_util.set_properties
|
||||
|
||||
local function anglediff(a1, a2)
|
||||
|
|
Loading…
Add table
Reference in a new issue