Remove useless buildat.voxel_heuristic_has_sunlight()
This commit is contained in:
parent
b0de2e16ce
commit
2c6b64fbd7
@ -193,20 +193,6 @@ function buildat.safe.clear_voxel_physics_boxes(safe_node)
|
||||
__buildat_clear_voxel_physics_boxes(node)
|
||||
end
|
||||
|
||||
function buildat.safe.voxel_heuristic_has_sunlight(safe_buffer, ...)
|
||||
buffer = nil
|
||||
if type(safe_buffer) == 'string' then
|
||||
buffer = safe_buffer
|
||||
else
|
||||
if not getmetatable(safe_buffer) or
|
||||
getmetatable(safe_buffer).type_name ~= "VectorBuffer" then
|
||||
error("safe_buffer is not a sandboxed VectorBuffer instance")
|
||||
end
|
||||
buffer = getmetatable(safe_buffer).unsafe
|
||||
end
|
||||
return __buildat_voxel_heuristic_has_sunlight(buffer, ...)
|
||||
end
|
||||
|
||||
local Vector3_prototype = {
|
||||
x = 0,
|
||||
y = 0,
|
||||
|
@ -995,31 +995,6 @@ void set_voxel_physics_boxes(Node *node, Context *context,
|
||||
set_voxel_physics_boxes(node, context, result_boxes, true);
|
||||
}
|
||||
|
||||
bool voxel_heuristic_has_sunlight(pv::RawVolume<VoxelInstance> &volume,
|
||||
VoxelRegistry *voxel_reg)
|
||||
{
|
||||
auto region = volume.getEnclosingRegion();
|
||||
auto &lc = region.getLowerCorner();
|
||||
auto &uc = region.getUpperCorner();
|
||||
|
||||
int num = 0;
|
||||
int y = uc.getY()-1;
|
||||
for(int z = lc.getZ()+1; z <= uc.getZ()-1; z++){
|
||||
for(int x = lc.getX()+1; x <= uc.getX()-1; x++){
|
||||
VoxelInstance v = volume.getVoxelAt(x, y, z);
|
||||
const interface::CachedVoxelDefinition *def = voxel_reg->get_cached(v);
|
||||
if(!def)
|
||||
throw Exception(ss_()+"Undefined voxel: "+itos(v.getId()));
|
||||
// TODO: Some proper lighting property
|
||||
bool light_passes = (!def || !def->physically_solid);
|
||||
if(light_passes)
|
||||
num++;
|
||||
}
|
||||
}
|
||||
log_w(MODULE, "num=%i", num);
|
||||
return (num >= 3);
|
||||
}
|
||||
|
||||
} // namespace mesh
|
||||
} // namespace interface
|
||||
// vim: set noet ts=4 sw=4:
|
||||
|
@ -127,11 +127,6 @@ namespace interface
|
||||
void set_voxel_physics_boxes(Node *node, Context *context,
|
||||
pv::RawVolume<VoxelInstance> &volume,
|
||||
VoxelRegistry *voxel_reg);
|
||||
|
||||
// Heuristics
|
||||
|
||||
bool voxel_heuristic_has_sunlight(pv::RawVolume<VoxelInstance> &volume,
|
||||
VoxelRegistry *voxel_reg);
|
||||
}
|
||||
}
|
||||
// vim: set noet ts=4 sw=4:
|
||||
|
@ -442,21 +442,6 @@ void clear_voxel_physics_boxes(const luabind::object &node_o)
|
||||
node->RemoveComponent(previous_shapes[i]);
|
||||
}
|
||||
|
||||
bool voxel_heuristic_has_sunlight(const luabind::object &buffer_o,
|
||||
sp_<VoxelRegistry> voxel_reg, lua_State *L)
|
||||
{
|
||||
TRY_GET_TOLUA_STUFF(buf, 1, const VectorBuffer);
|
||||
|
||||
ss_ data;
|
||||
if(buf == nullptr)
|
||||
data = lua_tocppstring(L, 2);
|
||||
else
|
||||
data.assign((const char*)&buf->GetBuffer()[0], buf->GetBuffer().Size());
|
||||
|
||||
up_<pv::RawVolume<VoxelInstance>> volume = interface::deserialize_volume(data);
|
||||
return interface::mesh::voxel_heuristic_has_sunlight(*volume, voxel_reg.get());
|
||||
}
|
||||
|
||||
#define LUABIND_FUNC(name) def("__buildat_" #name, name)
|
||||
|
||||
void init_mesh(lua_State *L)
|
||||
@ -469,8 +454,7 @@ void init_mesh(lua_State *L)
|
||||
LUABIND_FUNC(set_voxel_lod_geometry),
|
||||
LUABIND_FUNC(clear_voxel_geometry),
|
||||
LUABIND_FUNC(set_voxel_physics_boxes),
|
||||
LUABIND_FUNC(clear_voxel_physics_boxes),
|
||||
LUABIND_FUNC(voxel_heuristic_has_sunlight)
|
||||
LUABIND_FUNC(clear_voxel_physics_boxes)
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user