Rworked glass pane connection
- use in game data instead of manually calculating the adjacency data
This commit is contained in:
@@ -317,75 +317,6 @@ generate_pseudo_data(RenderState* state, uint16_t ancilData) {
|
||||
}
|
||||
return final_data;
|
||||
|
||||
} else if (block_class_is_subset(state->block, (mc_block_t[]){block_iron_bars, block_glass_pane, block_stained_glass_pane}, 3)) {
|
||||
|
||||
uint8_t pdata = 0;
|
||||
|
||||
PyObject* texrot;
|
||||
int32_t northdir;
|
||||
|
||||
struct {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t z;
|
||||
uint8_t direction; /*!< direction bit if glass pane should connect */
|
||||
} blocks[] = { {x + 1, y, z, 1 << 3},
|
||||
{x, y, z + 1, 1 << 2},
|
||||
{x - 1, y, z, 1 << 1},
|
||||
{x, y, z - 1, 1 << 0} };
|
||||
texrot = PyObject_GetAttrString(state->textures, "rotation");
|
||||
northdir = PyLong_AsLong(texrot) & 0x3;
|
||||
|
||||
for (size_t i = 0; i < sizeof(blocks)/sizeof(blocks[0]); ++i) {
|
||||
|
||||
mc_block_t block = get_data(state, BLOCKS, blocks[i].x, blocks[i].y, blocks[i].z);
|
||||
|
||||
if (block_class_is_subset(block, block_connects_to_glass_pane, block_connects_to_glass_pane_len)) {
|
||||
|
||||
pdata |= blocks[i].direction;
|
||||
|
||||
} else if (block_class_is_subset(block, block_class_stair, block_class_stair_len)) {
|
||||
|
||||
uint8_t stair_direction[4][4] = {
|
||||
{ 1, 3, 0, 2 }, // 'northdirection': 'upper-left'
|
||||
{ 2, 1, 3, 0 }, // 'northdirection': 'upper-right'
|
||||
{ 0, 2, 1, 3 }, // 'northdirection': 'lower-right'
|
||||
{ 3, 0, 2, 1 } // 'northdirection': 'lower-left'
|
||||
};
|
||||
|
||||
mc_block_t block_data = get_data(state, DATA, blocks[i].x, blocks[i].y, blocks[i].z);
|
||||
if ((block_data & 0xf) == stair_direction[northdir][i]) {
|
||||
pdata |= blocks[i].direction;
|
||||
}
|
||||
|
||||
} else if (block_class_is_subset(block, block_class_trapdoor, block_class_trapdoor_len)) {
|
||||
|
||||
uint8_t trapdoor_direction[4][4] = {
|
||||
{ 3, 1, 2, 0 }, // 'northdirection': 'upper-left'
|
||||
{ 0, 3, 1, 2 }, // 'northdirection': 'upper-right'
|
||||
{ 2, 0, 3, 1 }, // 'northdirection': 'lower-right'
|
||||
{ 1, 2, 0, 3 } // 'northdirection': 'lower-left'
|
||||
};
|
||||
|
||||
mc_block_t block_data = get_data(state, DATA, blocks[i].x, blocks[i].y, blocks[i].z);
|
||||
// only connects to "open" trapdoors
|
||||
if ((block_data & 0x4) == 0x4 && (block_data & 0x3) == trapdoor_direction[northdir][i]) {
|
||||
pdata |= blocks[i].direction;
|
||||
}
|
||||
|
||||
} else if (block == block_snow_layer) {
|
||||
|
||||
// glass pane only connect to full high snow layers
|
||||
mc_block_t skylight_data = get_data(state, SKYLIGHT, blocks[i].x, blocks[i].y, blocks[i].z);
|
||||
if (skylight_data == 0) {
|
||||
pdata |= blocks[i].direction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// shift up 4 bits because the lower 4 bits encode color
|
||||
return (pdata << 4) | (ancilData & 0xf);
|
||||
|
||||
} else if (block_class_is_subset(state->block, (mc_block_t[]){block_portal, block_nether_brick_fence}, 2)) {
|
||||
/* portal and nether brick fences */
|
||||
return check_adjacent_blocks(state, x, y, z, state->block);
|
||||
|
||||
Reference in New Issue
Block a user