Add Experimental Smooth Surface
This commit is contained in:
parent
c60873e80f
commit
f926fdc493
134
api.lua
134
api.lua
@ -105,61 +105,103 @@ function liquid_physics.register_liquid(namespace, source_name, flowing_name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Overwrite source
|
--Overwrite source
|
||||||
source_liquid_def.liquid_range = 0
|
-- source_liquid_def.liquid_range = 0
|
||||||
source_liquid_def.groups.liquid_physics = 1
|
source_liquid_def.groups.liquid_physics = 1
|
||||||
|
|
||||||
core.register_node(":" .. source_liquid_name, source_liquid_def)
|
-- core.register_node(":" .. source_liquid_name, {
|
||||||
|
-- description = source_liquid_def.description,
|
||||||
|
-- paramtype2 = "flowingliquid",
|
||||||
|
|
||||||
|
-- drawtype = "flowingliquid", -- Used by drawtype = "flowingliquid"
|
||||||
|
-- liquidtype = "", -- Flowing not needed here since condition is already met?
|
||||||
|
|
||||||
|
-- tiles = source_liquid_def.tiles, -- As needed by drawtype - copy from water
|
||||||
|
-- special_tiles = source_liquid_def.tiles,
|
||||||
|
-- use_texture_alpha = true,
|
||||||
|
|
||||||
|
-- liquid_renewable = false, -- Disallow any kind of spreading
|
||||||
|
-- liquid_range = 2,
|
||||||
|
|
||||||
|
-- buildable_to = true, -- For liquid_alternative_source = "test_water:test",
|
||||||
|
|
||||||
|
-- liquid_alternative_flowing = source_liquid_name, -- As requested in documentation
|
||||||
|
|
||||||
|
-- liquid_move_physics = true,
|
||||||
|
-- walkable = false,
|
||||||
|
|
||||||
|
-- })
|
||||||
|
|
||||||
|
core.override_item(source_liquid_name, {
|
||||||
|
paramtype2 = "flowingliquid",
|
||||||
|
drawtype = "flowingliquid",
|
||||||
|
liquidtype = "none",
|
||||||
|
liquid_renewable = false,
|
||||||
|
liquid_range = 3,
|
||||||
|
liquid_alternative_source = "",
|
||||||
|
liquid_alternative_flowing = source_liquid_name,
|
||||||
|
liquid_move_physics = true,
|
||||||
|
special_tiles = source_liquid_def.tiles,
|
||||||
|
groups = source_liquid_def.groups,
|
||||||
|
pointable = true,
|
||||||
|
}, nil)
|
||||||
|
|
||||||
|
-- core.register_node(":" .. source_liquid_name, source_liquid_def)
|
||||||
liquid_physics._liquid_ids[source_liquid_name] = id
|
liquid_physics._liquid_ids[source_liquid_name] = id
|
||||||
|
|
||||||
local liquids = {}
|
local liquids = {}
|
||||||
table.insert(liquids, "air")
|
table.insert(liquids, "air")
|
||||||
|
|
||||||
for i = 1, 7 do
|
for i = 1, 7 do
|
||||||
local node_name = "liquid_physics:" .. namespace .. "_" .. source_name .. "_level_" .. i
|
liquid_physics._liquid_ids[source_liquid_name] = id
|
||||||
|
table.insert(liquids, source_liquid_name)
|
||||||
local level_def = {
|
|
||||||
name = node_name,
|
|
||||||
description = source_liquid_def.description .. " Level " .. i,
|
|
||||||
tiles = source_liquid_def.tiles,
|
|
||||||
use_texture_alpha = source_liquid_def.use_texture_alpha,
|
|
||||||
paramtype = source_liquid_def.paramtype,
|
|
||||||
walkable = source_liquid_def.walkable,
|
|
||||||
pointable = source_liquid_def.pointable,
|
|
||||||
diggable = source_liquid_def.diggable,
|
|
||||||
buildable_to = source_liquid_def.buildable_to,
|
|
||||||
is_ground_content = source_liquid_def.is_ground_content,
|
|
||||||
drawtype = "nodebox",
|
|
||||||
drop = source_liquid_def.drop,
|
|
||||||
drowning = source_liquid_def.drowning,
|
|
||||||
liquidtype = "source",
|
|
||||||
liquid_alternative_flowing = node_name,
|
|
||||||
liquid_alternative_source = node_name,
|
|
||||||
liquid_range = 0,
|
|
||||||
liquid_viscosity = source_liquid_def.liquid_viscosity,
|
|
||||||
liquid_renewable = false,
|
|
||||||
waving = source_liquid_def.waving,
|
|
||||||
color = source_liquid_def.color,
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{ -0.5, -0.5, -0.5, 0.5, -0.375 + (0.125 * (i - 1)), 0.5 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
collision_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = { { -0.5, -0.5, -0.5, 0.5, -0.375 + (0.125 * (i - 1)), 0.5 }, },
|
|
||||||
},
|
|
||||||
post_effect_color = source_liquid_def.post_effect_color,
|
|
||||||
groups = source_liquid_def.groups,
|
|
||||||
sounds = source_liquid_def.sounds,
|
|
||||||
}
|
|
||||||
|
|
||||||
core.register_node(":" .. node_name, level_def)
|
|
||||||
liquid_physics._liquid_ids[node_name] = id
|
|
||||||
|
|
||||||
table.insert(liquids, node_name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- for i = 1, 7 do
|
||||||
|
-- local node_name = "liquid_physics:" .. namespace .. "_" .. source_name .. "_level_" .. i
|
||||||
|
|
||||||
|
-- local level_def = {
|
||||||
|
-- name = node_name,
|
||||||
|
-- description = source_liquid_def.description .. " Level " .. i,
|
||||||
|
-- tiles = source_liquid_def.tiles,
|
||||||
|
-- use_texture_alpha = source_liquid_def.use_texture_alpha,
|
||||||
|
-- paramtype = source_liquid_def.paramtype,
|
||||||
|
-- walkable = source_liquid_def.walkable,
|
||||||
|
-- pointable = source_liquid_def.pointable,
|
||||||
|
-- diggable = source_liquid_def.diggable,
|
||||||
|
-- buildable_to = source_liquid_def.buildable_to,
|
||||||
|
-- is_ground_content = source_liquid_def.is_ground_content,
|
||||||
|
-- drawtype = "nodebox",
|
||||||
|
-- drop = source_liquid_def.drop,
|
||||||
|
-- drowning = source_liquid_def.drowning,
|
||||||
|
-- liquidtype = "source",
|
||||||
|
-- liquid_alternative_flowing = node_name,
|
||||||
|
-- liquid_alternative_source = node_name,
|
||||||
|
-- liquid_range = 0,
|
||||||
|
-- liquid_viscosity = source_liquid_def.liquid_viscosity,
|
||||||
|
-- liquid_renewable = false,
|
||||||
|
-- waving = source_liquid_def.waving,
|
||||||
|
-- color = source_liquid_def.color,
|
||||||
|
-- node_box = {
|
||||||
|
-- type = "fixed",
|
||||||
|
-- fixed = {
|
||||||
|
-- { -0.5, -0.5, -0.5, 0.5, -0.375 + (0.125 * (i - 1)), 0.5 },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- collision_box = {
|
||||||
|
-- type = "fixed",
|
||||||
|
-- fixed = { { -0.5, -0.5, -0.5, 0.5, -0.375 + (0.125 * (i - 1)), 0.5 }, },
|
||||||
|
-- },
|
||||||
|
-- post_effect_color = source_liquid_def.post_effect_color,
|
||||||
|
-- groups = source_liquid_def.groups,
|
||||||
|
-- sounds = source_liquid_def.sounds,
|
||||||
|
-- }
|
||||||
|
|
||||||
|
-- core.register_node(":" .. node_name, level_def)
|
||||||
|
-- liquid_physics._liquid_ids[node_name] = id
|
||||||
|
|
||||||
|
-- table.insert(liquids, node_name)
|
||||||
|
-- end
|
||||||
|
|
||||||
table.insert(liquids, source_liquid_name)
|
table.insert(liquids, source_liquid_name)
|
||||||
|
|
||||||
-- Finally, stop flowing
|
-- Finally, stop flowing
|
||||||
@ -167,7 +209,7 @@ function liquid_physics.register_liquid(namespace, source_name, flowing_name)
|
|||||||
core.override_item(flowing_liquid_name, {
|
core.override_item(flowing_liquid_name, {
|
||||||
liquid_range = 0,
|
liquid_range = 0,
|
||||||
liquid_renewable = false,
|
liquid_renewable = false,
|
||||||
groups = flowing_liquid_def.groups
|
groups = flowing_liquid_def.groups,
|
||||||
}, nil)
|
}, nil)
|
||||||
liquid_physics._liquid_ids[flowing_liquid_name] = id
|
liquid_physics._liquid_ids[flowing_liquid_name] = id
|
||||||
|
|
||||||
|
@ -74,7 +74,13 @@ function internal.new_lpn(hash, pos)
|
|||||||
local liquid_id = internal.get_liquid_id(node.name)
|
local liquid_id = internal.get_liquid_id(node.name)
|
||||||
local liquid_level = -1
|
local liquid_level = -1
|
||||||
if liquid_id then
|
if liquid_id then
|
||||||
liquid_level = internal.get_liquid_level(liquid_id, node.name)
|
local node_level = core.get_node_level(pos)
|
||||||
|
if liquid_id == 0 then
|
||||||
|
node_level = 0
|
||||||
|
elseif node_level == 0 and node.name == liquid_physics.get_liquid_node_names(liquid_id)[8] then
|
||||||
|
node_level = 8
|
||||||
|
end
|
||||||
|
liquid_level = node_level --internal.get_liquid_level(liquid_id, node.name)
|
||||||
end
|
end
|
||||||
return {
|
return {
|
||||||
hash = hash,
|
hash = hash,
|
||||||
@ -100,6 +106,7 @@ end
|
|||||||
-- @param lpn table Liquid Physics Node
|
-- @param lpn table Liquid Physics Node
|
||||||
function internal.set_node(lpn)
|
function internal.set_node(lpn)
|
||||||
core.set_node(lpn.pos, { name = internal.get_liquid_node_name(lpn.liquid_id, lpn.liquid_level) })
|
core.set_node(lpn.pos, { name = internal.get_liquid_node_name(lpn.liquid_id, lpn.liquid_level) })
|
||||||
|
core.set_node_level(lpn.pos, lpn.liquid_level)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- This node will be checked in the next cycle
|
-- This node will be checked in the next cycle
|
||||||
|
@ -224,6 +224,7 @@ core.register_on_mapblocks_changed(function(modified_blocks, modified_blocks_cou
|
|||||||
end
|
end
|
||||||
-- Update only changed nodes from buffer
|
-- Update only changed nodes from buffer
|
||||||
for _, lpn in pairs(b) do
|
for _, lpn in pairs(b) do
|
||||||
|
--core.chat_send_all(dump(lpn))
|
||||||
if lpn.init_liquid_level ~= lpn.liquid_level then
|
if lpn.init_liquid_level ~= lpn.liquid_level then
|
||||||
internal.set_node(lpn)
|
internal.set_node(lpn)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user