1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Add node texture variants

This commit is contained in:
Jude Melton-Houghton 2022-11-03 21:18:49 -04:00 committed by SFENCE
parent 81d62d01d1
commit e638072e15
29 changed files with 984 additions and 208 deletions

View file

@ -180,6 +180,25 @@ function core.strip_param2_color(param2, paramtype2)
end
end
function core.strip_param2_variant(param2, def)
if not def or def.variant_count <= 1 or not def.param2_variant then
return 0
end
local bf = def.param2_variant
local right_mask = bit.lshift(1, bf.width) - 1
return bit.band(bit.rshift(param2, bf.offset), right_mask) % def.variant_count
end
function core.set_param2_variant(param2, variant, def)
if not def or not def.param2_variant then
return param2
end
local bf = def.param2_variant
local mask = bit.lshift(bit.lshift(1, bf.width) - 1, bf.offset)
local new_bits = bit.band(bit.lshift(variant, bf.offset), mask)
return bit.bor(bit.band(param2, bit.bnot(mask)), new_bits)
end
-- Content ID caching
local old_get_content_id = core.get_content_id