Last active
September 14, 2022 18:33
-
-
Save untodesu/1dbfd33ab284934aa179c90b811b41f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"render": { "mode": "solid_box" }, | |
"faces": { | |
"north": { | |
"culls_neighbours": true, | |
"culled_by_relatives": true, | |
"textures": [ | |
"/textures/stone_0.png", | |
"/textures/stone_1.png" | |
] | |
}, | |
"south": { "copy": "north" }, | |
"east": { "copy": "north" }, | |
"west": { "copy": "north" }, | |
"top": { "copy": "north" }, | |
"bottom": { "copy": "north" } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
static bool shouldCullFace(const chunk_pos_t &cpos, const local_pos_t &lpos, voxel_t voxel, VoxelFace face, VoxelFace neighbour_face) | |
{ | |
// Sometimes local position can go off limits | |
// (we can check voxels in neighbouring chunks), | |
// so to avoid any accesses to non-existent areas | |
// we have to pack it into voxel_pos_t and unpack it back. | |
const voxel_pos_t vpos = convert::toVoxelPosition(cpos, lpos); | |
const chunk_pos_t cpos_p = convert::toChunkPosition(vpos); | |
const local_pos_t lpos_p = convert::toLocalPosition(vpos); | |
const auto chunk = voxel_pool.find(convert::toChunkPosition(vpos)); | |
if(chunk != voxel_pool.cend()) { | |
const voxel_t neighbour = chunk->second.at(convert::toVoxelIndex(lpos_p)); | |
if(neighbour != voxel) { | |
if(const VoxelInfo *info = voxels::find(voxel)) { | |
const auto info_face = info->faces.find(neighbour_face); | |
if(info_face != info->faces.cend()) | |
return info_face->second.culls_neighbours; | |
return false; | |
} | |
// Assume NULL_VOXEL | |
return false; | |
} | |
if(const VoxelInfo *info = voxels::find(voxel)) { | |
const auto info_face = info->faces.find(face); | |
if(info_face != info->faces.cend()) | |
return info_face->second.culled_by_relatives; | |
return true; | |
} | |
return true; | |
} | |
// Assume NULL_VOXEL | |
return false; | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment