block_class_is_subset implementation pass
This commit is contained in:
@@ -1,136 +1,190 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the Minecraft Overviewer.
|
* This file is part of the Minecraft Overviewer.
|
||||||
*
|
*
|
||||||
* Minecraft Overviewer is free software: you can redistribute it and/or
|
* Minecraft Overviewer is free software: you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as published
|
* modify it under the terms of the GNU General Public License as published
|
||||||
* by the Free Software Foundation, either version 3 of the License, or (at
|
* by the Free Software Foundation, either version 3 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* Minecraft Overviewer is distributed in the hope that it will be useful,
|
* Minecraft Overviewer is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
* Public License for more details.
|
* Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "block_class.h"
|
#include "block_class.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
bool block_class_is_subset(
|
#include <immintrin.h>
|
||||||
mc_block_t block,
|
#endif
|
||||||
const mc_block_t block_class[],
|
|
||||||
size_t block_class_len
|
bool block_class_is_subset(
|
||||||
)
|
mc_block_t block,
|
||||||
{
|
const mc_block_t block_class[],
|
||||||
size_t i;
|
size_t block_class_len
|
||||||
for( i = 0; i < block_class_len; ++i )
|
)
|
||||||
{
|
{
|
||||||
if( block == block_class[i] )
|
size_t i = 0;
|
||||||
{
|
|
||||||
return true;
|
#ifdef __SSE2__
|
||||||
}
|
for( ; i / 8 < block_class_len / 8; i += 8 )
|
||||||
}
|
{
|
||||||
return false;
|
const __m128i block_class_vec = _mm_loadu_si128(
|
||||||
}
|
(__m128i*)&block_class[i]
|
||||||
|
);
|
||||||
|
const __m128i block_vec = _mm_set1_epi16(block);
|
||||||
const mc_block_t block_class_stair[] = {
|
const __m128i block_cmp = _mm_cmpeq_epi16(block_vec,block_class_vec);
|
||||||
block_oak_stairs,
|
if( _mm_movemask_epi8(block_cmp) )
|
||||||
block_stone_stairs,
|
{
|
||||||
block_brick_stairs,
|
return true;
|
||||||
block_stone_brick_stairs,
|
}
|
||||||
block_nether_brick_stairs,
|
}
|
||||||
block_sandstone_stairs,
|
#endif
|
||||||
block_spruce_stairs,
|
#ifdef __MMX__
|
||||||
block_birch_stairs,
|
for( ; i / 4 < block_class_len / 4; i += 4 )
|
||||||
block_jungle_stairs,
|
{
|
||||||
block_quartz_stairs,
|
const __m64 block_class_vec = _mm_cvtsi64_m64(
|
||||||
block_acacia_stairs,
|
*(uint64_t*)&block_class[i]
|
||||||
block_dark_oak_stairs,
|
);
|
||||||
block_red_sandstone_stairs,
|
const __m64 block_vec = _mm_set1_pi16(block);
|
||||||
block_purpur_stairs
|
const __m64 block_cmp = _mm_cmpeq_pi16(block_vec,block_class_vec);
|
||||||
};
|
if( _mm_cvtm64_si64(block_cmp) )
|
||||||
const size_t block_class_stair_len = count_of(block_class_stair);
|
{
|
||||||
|
return true;
|
||||||
const mc_block_t block_class_door[] = {
|
}
|
||||||
block_wooden_door,
|
}
|
||||||
block_iron_door,
|
#endif
|
||||||
block_spruce_door,
|
for( ; i < block_class_len; ++i )
|
||||||
block_birch_door,
|
{
|
||||||
block_jungle_door,
|
if( block == block_class[i] )
|
||||||
block_acacia_door,
|
{
|
||||||
block_dark_oak_door
|
return true;
|
||||||
};
|
}
|
||||||
const size_t block_class_door_len = count_of(block_class_door);
|
}
|
||||||
|
return false;
|
||||||
const mc_block_t block_class_fence[] = {
|
}
|
||||||
block_fence,
|
|
||||||
block_nether_brick_fence,
|
|
||||||
block_spruce_fence,
|
const mc_block_t block_class_stair[] = {
|
||||||
block_birch_fence,
|
block_oak_stairs,
|
||||||
block_jungle_fence,
|
block_stone_stairs,
|
||||||
block_dark_oak_fence,
|
block_brick_stairs,
|
||||||
block_acacia_fence
|
block_stone_brick_stairs,
|
||||||
};
|
block_nether_brick_stairs,
|
||||||
const size_t block_class_fence_len = count_of(block_class_fence);
|
block_sandstone_stairs,
|
||||||
|
block_spruce_stairs,
|
||||||
const mc_block_t block_class_fence_gate[] = {
|
block_birch_stairs,
|
||||||
block_fence_gate,
|
block_jungle_stairs,
|
||||||
block_spruce_fence_gate,
|
block_quartz_stairs,
|
||||||
block_birch_fence_gate,
|
block_acacia_stairs,
|
||||||
block_jungle_fence_gate,
|
block_dark_oak_stairs,
|
||||||
block_dark_oak_fence_gate,
|
block_red_sandstone_stairs,
|
||||||
block_acacia_fence_gate
|
block_purpur_stairs
|
||||||
};
|
};
|
||||||
const size_t block_class_fence_gate_len = count_of(block_class_fence_gate);
|
const size_t block_class_stair_len = count_of(block_class_stair);
|
||||||
|
|
||||||
const mc_block_t block_class_ancil[] = {
|
const mc_block_t block_class_door[] = {
|
||||||
block_wooden_door,
|
block_wooden_door,
|
||||||
block_iron_door,
|
block_iron_door,
|
||||||
block_spruce_door,
|
block_spruce_door,
|
||||||
block_birch_door,
|
block_birch_door,
|
||||||
block_jungle_door,
|
block_jungle_door,
|
||||||
block_acacia_door,
|
block_acacia_door,
|
||||||
block_dark_oak_door,
|
block_dark_oak_door
|
||||||
block_oak_stairs,
|
};
|
||||||
block_stone_stairs,
|
const size_t block_class_door_len = count_of(block_class_door);
|
||||||
block_brick_stairs,
|
|
||||||
block_stone_brick_stairs,
|
const mc_block_t block_class_fence[] = {
|
||||||
block_nether_brick_stairs,
|
block_fence,
|
||||||
block_sandstone_stairs,
|
block_nether_brick_fence,
|
||||||
block_spruce_stairs,
|
block_spruce_fence,
|
||||||
block_birch_stairs,
|
block_birch_fence,
|
||||||
block_jungle_stairs,
|
block_jungle_fence,
|
||||||
block_quartz_stairs,
|
block_dark_oak_fence,
|
||||||
block_acacia_stairs,
|
block_acacia_fence
|
||||||
block_dark_oak_stairs,
|
};
|
||||||
block_red_sandstone_stairs,
|
const size_t block_class_fence_len = count_of(block_class_fence);
|
||||||
block_purpur_stairs,
|
|
||||||
block_grass,
|
const mc_block_t block_class_fence_gate[] = {
|
||||||
block_flowing_water,
|
block_fence_gate,
|
||||||
block_water,
|
block_spruce_fence_gate,
|
||||||
block_glass,
|
block_birch_fence_gate,
|
||||||
block_chest,
|
block_jungle_fence_gate,
|
||||||
block_redstone_wire,
|
block_dark_oak_fence_gate,
|
||||||
block_ice,
|
block_acacia_fence_gate
|
||||||
block_fence,
|
};
|
||||||
block_portal,
|
const size_t block_class_fence_gate_len = count_of(block_class_fence_gate);
|
||||||
block_iron_bars,
|
|
||||||
block_glass_pane,
|
const mc_block_t block_class_ancil[] = {
|
||||||
block_waterlily,
|
block_wooden_door,
|
||||||
block_nether_brick_fence,
|
block_iron_door,
|
||||||
block_cobblestone_wall,
|
block_spruce_door,
|
||||||
block_double_plant,
|
block_birch_door,
|
||||||
block_stained_glass_pane,
|
block_jungle_door,
|
||||||
block_stained_glass,
|
block_acacia_door,
|
||||||
block_trapped_chest,
|
block_dark_oak_door,
|
||||||
block_spruce_fence,
|
block_oak_stairs,
|
||||||
block_birch_fence,
|
block_stone_stairs,
|
||||||
block_jungle_fence,
|
block_brick_stairs,
|
||||||
block_dark_oak_fence,
|
block_stone_brick_stairs,
|
||||||
block_acacia_fence
|
block_nether_brick_stairs,
|
||||||
};
|
block_sandstone_stairs,
|
||||||
const size_t block_class_ancil_len = count_of(block_class_ancil);
|
block_spruce_stairs,
|
||||||
|
block_birch_stairs,
|
||||||
|
block_jungle_stairs,
|
||||||
|
block_quartz_stairs,
|
||||||
|
block_acacia_stairs,
|
||||||
|
block_dark_oak_stairs,
|
||||||
|
block_red_sandstone_stairs,
|
||||||
|
block_purpur_stairs,
|
||||||
|
block_grass,
|
||||||
|
block_flowing_water,
|
||||||
|
block_water,
|
||||||
|
block_glass,
|
||||||
|
block_chest,
|
||||||
|
block_redstone_wire,
|
||||||
|
block_ice,
|
||||||
|
block_fence,
|
||||||
|
block_portal,
|
||||||
|
block_iron_bars,
|
||||||
|
block_glass_pane,
|
||||||
|
block_waterlily,
|
||||||
|
block_nether_brick_fence,
|
||||||
|
block_cobblestone_wall,
|
||||||
|
block_double_plant,
|
||||||
|
block_stained_glass_pane,
|
||||||
|
block_stained_glass,
|
||||||
|
block_trapped_chest,
|
||||||
|
block_spruce_fence,
|
||||||
|
block_birch_fence,
|
||||||
|
block_jungle_fence,
|
||||||
|
block_dark_oak_fence,
|
||||||
|
block_acacia_fence
|
||||||
|
};
|
||||||
|
const size_t block_class_ancil_len = count_of(block_class_ancil);
|
||||||
|
|
||||||
|
const mc_block_t block_class_alt_height[] = {
|
||||||
|
block_stone_slab,
|
||||||
|
block_oak_stairs,
|
||||||
|
block_stone_stairs,
|
||||||
|
block_brick_stairs,
|
||||||
|
block_stone_brick_stairs,
|
||||||
|
block_nether_brick_stairs,
|
||||||
|
block_sandstone_stairs,
|
||||||
|
block_spruce_stairs,
|
||||||
|
block_birch_stairs,
|
||||||
|
block_jungle_stairs,
|
||||||
|
block_quartz_stairs,
|
||||||
|
block_acacia_stairs,
|
||||||
|
block_dark_oak_stairs,
|
||||||
|
block_red_sandstone_stairs,
|
||||||
|
block_stone_slab2,
|
||||||
|
block_purpur_stairs,
|
||||||
|
block_purpur_slab,
|
||||||
|
block_wooden_slab
|
||||||
|
};
|
||||||
|
const size_t block_class_alt_height_len = count_of(block_class_alt_height);
|
||||||
@@ -44,4 +44,7 @@ extern const size_t block_class_fence_gate_len;
|
|||||||
extern const mc_block_t block_class_ancil[];
|
extern const mc_block_t block_class_ancil[];
|
||||||
extern const size_t block_class_ancil_len;
|
extern const size_t block_class_ancil_len;
|
||||||
|
|
||||||
|
extern const mc_block_t block_class_alt_height[];
|
||||||
|
extern const size_t block_class_alt_height_len;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -259,13 +259,13 @@ generate_pseudo_data(RenderState *state, unsigned short ancilData) {
|
|||||||
if (get_data(state, BLOCKS, x, y+1, z) == 78)
|
if (get_data(state, BLOCKS, x, y+1, z) == 78)
|
||||||
return 0x10;
|
return 0x10;
|
||||||
return ancilData;
|
return ancilData;
|
||||||
} else if (state->block == block_flowing_water || state->block == block_water) { /* water */
|
} else if (block_class_is_subset(state->block,(mc_block_t[]){block_flowing_water,block_water},2)) { /* water */
|
||||||
data = check_adjacent_blocks(state, x, y, z, state->block) ^ 0x0f;
|
data = check_adjacent_blocks(state, x, y, z, state->block) ^ 0x0f;
|
||||||
/* an aditional bit for top is added to the 4 bits of check_adjacent_blocks */
|
/* an aditional bit for top is added to the 4 bits of check_adjacent_blocks */
|
||||||
if (get_data(state, BLOCKS, x, y+1, z) != state->block)
|
if (get_data(state, BLOCKS, x, y+1, z) != state->block)
|
||||||
data |= 0x10;
|
data |= 0x10;
|
||||||
return data;
|
return data;
|
||||||
} else if ((state->block == block_glass) || (state->block == block_ice) || (state->block == block_stained_glass)) { /* glass and ice and stained glass*/
|
} else if (block_class_is_subset(state->block,(mc_block_t[]){block_glass,block_ice,block_stained_glass},3)) { /* glass and ice and stained glass*/
|
||||||
/* an aditional bit for top is added to the 4 bits of check_adjacent_blocks
|
/* an aditional bit for top is added to the 4 bits of check_adjacent_blocks
|
||||||
* Note that stained glass encodes 16 colors using 4 bits. this pushes us over the 8-bits of an unsigned char,
|
* Note that stained glass encodes 16 colors using 4 bits. this pushes us over the 8-bits of an unsigned char,
|
||||||
* forcing us to use an unsigned short to hold 16 bits of pseudo ancil data
|
* forcing us to use an unsigned short to hold 16 bits of pseudo ancil data
|
||||||
@@ -317,7 +317,7 @@ generate_pseudo_data(RenderState *state, unsigned short ancilData) {
|
|||||||
}
|
}
|
||||||
return final_data;
|
return final_data;
|
||||||
|
|
||||||
} else if (state->block == block_chest || state->block == block_trapped_chest) {
|
} else if (block_class_is_subset(state->block,(mc_block_t[]){block_chest,block_trapped_chest},2)) {
|
||||||
/* Orientation is given by ancilData, pseudo data needed to
|
/* Orientation is given by ancilData, pseudo data needed to
|
||||||
* choose from single or double chest and the correct half of
|
* choose from single or double chest and the correct half of
|
||||||
* the chest. */
|
* the chest. */
|
||||||
@@ -354,7 +354,7 @@ generate_pseudo_data(RenderState *state, unsigned short ancilData) {
|
|||||||
}
|
}
|
||||||
return final_data;
|
return final_data;
|
||||||
|
|
||||||
} else if ((state->block == block_iron_bars) || (state->block == block_glass_pane) || (state->block == block_stained_glass_pane)) {
|
} else if (block_class_is_subset(state->block,(mc_block_t[]){block_iron_bars,block_glass_pane,block_stained_glass_pane},3)) {
|
||||||
/* iron bars and glass panes:
|
/* iron bars and glass panes:
|
||||||
* they seem to stick to almost everything but air,
|
* they seem to stick to almost everything but air,
|
||||||
* not sure yet! Still a TODO! */
|
* not sure yet! Still a TODO! */
|
||||||
@@ -363,7 +363,7 @@ generate_pseudo_data(RenderState *state, unsigned short ancilData) {
|
|||||||
data = (check_adjacent_blocks(state, x, y, z, 0) ^ 0x0f);
|
data = (check_adjacent_blocks(state, x, y, z, 0) ^ 0x0f);
|
||||||
return (data << 4) | (ancilData & 0xf);
|
return (data << 4) | (ancilData & 0xf);
|
||||||
|
|
||||||
} else if ((state->block == block_portal) || (state->block == block_nether_brick_fence)) {
|
} else if (block_class_is_subset(state->block,(mc_block_t[]){block_portal,block_nether_brick_fence},2)) {
|
||||||
/* portal and nether brick fences */
|
/* portal and nether brick fences */
|
||||||
return check_adjacent_blocks(state, x, y, z, state->block);
|
return check_adjacent_blocks(state, x, y, z, state->block);
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "../overviewer.h"
|
#include "../overviewer.h"
|
||||||
#include "../mc_id.h"
|
#include "../mc_id.h"
|
||||||
|
#include "../block_class.h"
|
||||||
#include "biomes.h"
|
#include "biomes.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -95,19 +96,20 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
|||||||
*/
|
*/
|
||||||
if (/* grass, but not snowgrass */
|
if (/* grass, but not snowgrass */
|
||||||
(state->block == block_grass && get_data(state, BLOCKS, state->x, state->y+1, state->z) != 78) ||
|
(state->block == block_grass && get_data(state, BLOCKS, state->x, state->y+1, state->z) != 78) ||
|
||||||
/* water */
|
block_class_is_subset(state->block,(mc_block_t[]){
|
||||||
state->block == block_flowing_water || state->block == block_water ||
|
block_vine,
|
||||||
/* leaves */
|
block_waterlily,
|
||||||
state->block == block_leaves || state->block == block_leaves2 ||
|
block_flowing_water,
|
||||||
|
block_water,
|
||||||
|
block_leaves,
|
||||||
|
block_leaves2
|
||||||
|
},
|
||||||
|
6) ||
|
||||||
/* tallgrass, but not dead shrubs */
|
/* tallgrass, but not dead shrubs */
|
||||||
(state->block == block_tallgrass && state->block_data != 0) ||
|
(state->block == block_tallgrass && state->block_data != 0) ||
|
||||||
/* pumpkin/melon stem, not fully grown. Fully grown stems
|
/* pumpkin/melon stem, not fully grown. Fully grown stems
|
||||||
* get constant brown color (see textures.py) */
|
* get constant brown color (see textures.py) */
|
||||||
(((state->block == block_pumpkin_stem) || (state->block == block_melon_stem)) && (state->block_data != 7)) ||
|
(((state->block == block_pumpkin_stem) || (state->block == block_melon_stem)) && (state->block_data != 7)) ||
|
||||||
/* vines */
|
|
||||||
state->block == block_vine ||
|
|
||||||
/* lily pads */
|
|
||||||
state->block == block_waterlily ||
|
|
||||||
/* doublePlant grass & ferns */
|
/* doublePlant grass & ferns */
|
||||||
(state->block == block_double_plant && (state->block_data == 2 || state->block_data == 3)) ||
|
(state->block == block_double_plant && (state->block_data == 2 || state->block_data == 3)) ||
|
||||||
/* doublePlant grass & ferns tops */
|
/* doublePlant grass & ferns tops */
|
||||||
@@ -125,18 +127,21 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (state->block) {
|
switch (state->block) {
|
||||||
case 2:
|
case block_grass:
|
||||||
/* grass */
|
case block_tallgrass:
|
||||||
|
case block_pumpkin_stem:
|
||||||
|
case block_melon_stem:
|
||||||
|
case block_vine:
|
||||||
|
case block_waterlily:
|
||||||
|
case block_double_plant:
|
||||||
color_table = self->grasscolor;
|
color_table = self->grasscolor;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case block_flowing_water:
|
||||||
case 9:
|
case block_water:
|
||||||
/* water */
|
|
||||||
color_table = self->watercolor;
|
color_table = self->watercolor;
|
||||||
break;
|
break;
|
||||||
case 18:
|
case block_leaves:
|
||||||
case 161:
|
case block_leaves2:
|
||||||
/* leaves */
|
|
||||||
color_table = self->foliagecolor;
|
color_table = self->foliagecolor;
|
||||||
if (state->block_data == 2)
|
if (state->block_data == 2)
|
||||||
{
|
{
|
||||||
@@ -145,30 +150,6 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
|||||||
flip_xy = 1;
|
flip_xy = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 31:
|
|
||||||
/* tall grass */
|
|
||||||
color_table = self->grasscolor;
|
|
||||||
break;
|
|
||||||
case 104:
|
|
||||||
/* pumpkin stem */
|
|
||||||
color_table = self->grasscolor;
|
|
||||||
break;
|
|
||||||
case 105:
|
|
||||||
/* melon stem */
|
|
||||||
color_table = self->grasscolor;
|
|
||||||
break;
|
|
||||||
case 106:
|
|
||||||
/* vines */
|
|
||||||
color_table = self->grasscolor;
|
|
||||||
break;
|
|
||||||
case 111:
|
|
||||||
/* lily pads */
|
|
||||||
color_table = self->grasscolor;
|
|
||||||
break;
|
|
||||||
case 175:
|
|
||||||
/* doublePlant grass & ferns */
|
|
||||||
color_table = self->grasscolor;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "../overviewer.h"
|
#include "../overviewer.h"
|
||||||
#include "../mc_id.h"
|
#include "../mc_id.h"
|
||||||
|
#include "../block_class.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float opacity;
|
float opacity;
|
||||||
@@ -35,16 +36,17 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
|
|||||||
PrimitiveEdgeLines *self = (PrimitiveEdgeLines *)data;
|
PrimitiveEdgeLines *self = (PrimitiveEdgeLines *)data;
|
||||||
|
|
||||||
/* Draw some edge lines! */
|
/* Draw some edge lines! */
|
||||||
if (state->block == block_stone_slab || state->block == block_snow_layer || !is_transparent(state->block)) {
|
if (block_class_is_subset(state->block,(mc_block_t[]){block_stone_slab,block_snow_layer},2)
|
||||||
|
|| !is_transparent(state->block)) {
|
||||||
Imaging img_i = imaging_python_to_c(state->img);
|
Imaging img_i = imaging_python_to_c(state->img);
|
||||||
unsigned char ink[] = {0, 0, 0, 255 * self->opacity};
|
unsigned char ink[] = {0, 0, 0, 255 * self->opacity};
|
||||||
unsigned short side_block;
|
unsigned short side_block;
|
||||||
int x = state->x, y = state->y, z = state->z;
|
int x = state->x, y = state->y, z = state->z;
|
||||||
|
|
||||||
int increment=0;
|
int increment=0;
|
||||||
if ((state->block == block_stone_slab || state->block == block_wooden_slab) && ((state->block_data & 0x8) == 0 )) // half-steps BUT no upsidown half-steps
|
if (block_class_is_subset(state->block,(mc_block_t[]){block_wooden_slab,block_stone_slab},2) && ((state->block_data & 0x8) == 0 )) // half-steps BUT no upsidown half-steps
|
||||||
increment=6;
|
increment=6;
|
||||||
else if ((state->block == block_snow_layer) || (state->block == block_unpowered_repeater) || (state->block == block_powered_repeater)) // snow, redstone repeaters (on and off)
|
else if (block_class_is_subset(state->block,(mc_block_t[]){block_snow_layer,block_unpowered_repeater,block_powered_repeater},3)) // snow, redstone repeaters (on and off)
|
||||||
increment=9;
|
increment=9;
|
||||||
|
|
||||||
/* +X side */
|
/* +X side */
|
||||||
@@ -52,9 +54,9 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
|
|||||||
if (side_block != state->block && (is_transparent(side_block) || render_mode_hidden(state->rendermode, x+1, y, z)) &&
|
if (side_block != state->block && (is_transparent(side_block) || render_mode_hidden(state->rendermode, x+1, y, z)) &&
|
||||||
/* WARNING: ugly special case approaching */
|
/* WARNING: ugly special case approaching */
|
||||||
/* if the block is a slab and the side block is a stair don't draw anything, it can give very ugly results */
|
/* if the block is a slab and the side block is a stair don't draw anything, it can give very ugly results */
|
||||||
!((state->block == block_stone_slab || state->block == block_wooden_slab) && ((side_block == block_oak_stairs) || (side_block == block_stone_stairs) || (side_block == block_brick_stairs) ||
|
!(block_class_is_subset(state->block,(mc_block_t[]){block_wooden_slab,block_stone_slab},2)
|
||||||
(side_block == block_stone_brick_stairs) || (side_block == block_nether_brick_stairs) || (side_block == block_sandstone_stairs) || (side_block == block_spruce_stairs) || (side_block == block_birch_stairs) ||
|
&& (block_class_is_subset(side_block,block_class_stair,block_class_stair_len))
|
||||||
(side_block == block_jungle_stairs)))) {
|
)) {
|
||||||
ImagingDrawLine(img_i, state->imgx+12, state->imgy+1+increment, state->imgx+22+1, state->imgy+5+1+increment, &ink, 1);
|
ImagingDrawLine(img_i, state->imgx+12, state->imgy+1+increment, state->imgx+22+1, state->imgy+5+1+increment, &ink, 1);
|
||||||
ImagingDrawLine(img_i, state->imgx+12, state->imgy+increment, state->imgx+22+1, state->imgy+5+increment, &ink, 1);
|
ImagingDrawLine(img_i, state->imgx+12, state->imgy+increment, state->imgx+22+1, state->imgy+5+increment, &ink, 1);
|
||||||
}
|
}
|
||||||
@@ -64,9 +66,10 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
|
|||||||
if (side_block != state->block && (is_transparent(side_block) || render_mode_hidden(state->rendermode, x, y, z-1)) &&
|
if (side_block != state->block && (is_transparent(side_block) || render_mode_hidden(state->rendermode, x, y, z-1)) &&
|
||||||
/* WARNING: ugly special case approaching */
|
/* WARNING: ugly special case approaching */
|
||||||
/* if the block is a slab and the side block is a stair don't draw anything, it can give very ugly results */
|
/* if the block is a slab and the side block is a stair don't draw anything, it can give very ugly results */
|
||||||
!((state->block == block_stone_slab || state->block == block_wooden_slab) && ((side_block == block_oak_stairs) || (side_block == block_stone_stairs) || (side_block == block_brick_stairs) ||
|
!(
|
||||||
(side_block == block_stone_brick_stairs) || (side_block == block_nether_brick_stairs) || (side_block == block_sandstone_stairs) || (side_block == block_spruce_stairs) || (side_block == block_birch_stairs) ||
|
block_class_is_subset(state->block,(mc_block_t[]){block_stone_slab,block_wooden_slab},2)
|
||||||
(side_block == block_jungle_stairs)))) {
|
&& (block_class_is_subset(side_block,block_class_stair,block_class_stair_len))
|
||||||
|
)) {
|
||||||
ImagingDrawLine(img_i, state->imgx, state->imgy+6+1+increment, state->imgx+12+1, state->imgy+1+increment, &ink, 1);
|
ImagingDrawLine(img_i, state->imgx, state->imgy+6+1+increment, state->imgx+12+1, state->imgy+1+increment, &ink, 1);
|
||||||
ImagingDrawLine(img_i, state->imgx, state->imgy+6+increment, state->imgx+12+1, state->imgy+increment, &ink, 1);
|
ImagingDrawLine(img_i, state->imgx, state->imgy+6+increment, state->imgx+12+1, state->imgy+increment, &ink, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "../overviewer.h"
|
#include "../overviewer.h"
|
||||||
#include "../mc_id.h"
|
#include "../mc_id.h"
|
||||||
|
#include "../block_class.h"
|
||||||
#include "lighting.h"
|
#include "lighting.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -139,7 +140,7 @@ estimate_blocklevel(RenderPrimitiveLighting *self, RenderState *state,
|
|||||||
blocklevel = get_data(state, BLOCKLIGHT, x, y, z);
|
blocklevel = get_data(state, BLOCKLIGHT, x, y, z);
|
||||||
|
|
||||||
/* no longer a guess */
|
/* no longer a guess */
|
||||||
if (!(block == block_stone_slab || block == block_oak_stairs || block == block_stone_stairs || block == block_brick_stairs || block == block_stone_brick_stairs || block == block_red_sandstone_stairs || block == block_stone_slab2 || block == block_purpur_slab ) && authoratative) {
|
if (!block_class_is_subset(block,block_class_alt_height,block_class_alt_height_len) && authoratative) {
|
||||||
*authoratative = 1;
|
*authoratative = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,9 +161,7 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
|
|||||||
|
|
||||||
/* special half-step handling, stairs handling */
|
/* special half-step handling, stairs handling */
|
||||||
/* Anvil also needs to be here, blockid 145 */
|
/* Anvil also needs to be here, blockid 145 */
|
||||||
if (block == block_stone_slab || block == block_oak_stairs || block == block_stone_stairs || block == block_brick_stairs || block == block_stone_brick_stairs || block == block_nether_brick_stairs ||
|
if ( block_class_is_subset(block,block_class_alt_height,block_class_alt_height_len) || block == block_anvil) {
|
||||||
block == block_sandstone_stairs || block == block_spruce_stairs || block == block_birch_stairs || block == block_jungle_stairs || block == block_anvil || block == block_quartz_stairs ||
|
|
||||||
block == block_acacia_stairs || block == block_dark_oak_stairs || block == block_red_sandstone_stairs || block == block_stone_slab2 || block == block_purpur_stairs || block == block_purpur_slab ) {
|
|
||||||
unsigned int upper_block;
|
unsigned int upper_block;
|
||||||
|
|
||||||
/* stairs and half-blocks take the skylevel from the upper block if it's transparent */
|
/* stairs and half-blocks take the skylevel from the upper block if it's transparent */
|
||||||
@@ -171,10 +170,7 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
|
|||||||
do {
|
do {
|
||||||
upper_counter++;
|
upper_counter++;
|
||||||
upper_block = get_data(state, BLOCKS, x, y + upper_counter, z);
|
upper_block = get_data(state, BLOCKS, x, y + upper_counter, z);
|
||||||
} while (upper_block == block_stone_slab || upper_block == block_oak_stairs || upper_block == block_stone_stairs || upper_block == block_brick_stairs ||
|
} while (block_class_is_subset(upper_block,block_class_alt_height,block_class_alt_height_len));
|
||||||
upper_block == block_stone_brick_stairs || upper_block == block_nether_brick_stairs || upper_block == block_sandstone_stairs || upper_block == block_spruce_stairs ||
|
|
||||||
upper_block == block_birch_stairs || upper_block == block_jungle_stairs || upper_block == block_quartz_stairs || upper_block == block_acacia_stairs ||
|
|
||||||
upper_block == block_dark_oak_stairs || upper_block == block_red_sandstone_stairs || upper_block == block_stone_slab2 || upper_block == block_purpur_stairs || upper_block == block_purpur_slab );
|
|
||||||
if (is_transparent(upper_block)) {
|
if (is_transparent(upper_block)) {
|
||||||
skylevel = get_data(state, SKYLIGHT, x, y + upper_counter, z);
|
skylevel = get_data(state, SKYLIGHT, x, y + upper_counter, z);
|
||||||
} else {
|
} else {
|
||||||
@@ -187,7 +183,7 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block == block_flowing_lava || block == block_lava) {
|
if (block_class_is_subset(block,(mc_block_t[]){block_flowing_lava,block_lava},2)) {
|
||||||
/* lava blocks should always be lit! */
|
/* lava blocks should always be lit! */
|
||||||
*r = 255;
|
*r = 255;
|
||||||
*g = 255;
|
*g = 255;
|
||||||
@@ -306,7 +302,7 @@ lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyO
|
|||||||
self = (RenderPrimitiveLighting *)data;
|
self = (RenderPrimitiveLighting *)data;
|
||||||
x = state->x, y = state->y, z = state->z;
|
x = state->x, y = state->y, z = state->z;
|
||||||
|
|
||||||
if ((state->block == block_flowing_water) || (state->block == block_water)) { /* special case for water */
|
if (block_class_is_subset(state->block,(mc_block_t[]){block_flowing_water,block_water},2)) { /* special case for water */
|
||||||
/* looks like we need a new case for lighting, there are
|
/* looks like we need a new case for lighting, there are
|
||||||
* blocks that are transparent for occlusion calculations and
|
* blocks that are transparent for occlusion calculations and
|
||||||
* need per-face shading if the face is drawn. */
|
* need per-face shading if the face is drawn. */
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "../overviewer.h"
|
#include "../overviewer.h"
|
||||||
#include "../mc_id.h"
|
#include "../mc_id.h"
|
||||||
|
#include "../block_class.h"
|
||||||
#include "nether.h"
|
#include "nether.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -36,7 +37,7 @@ walk_chunk(RenderState *state, RenderPrimitiveNether *data) {
|
|||||||
|
|
||||||
for (y = NETHER_ROOF-1; y>=0; y--) {
|
for (y = NETHER_ROOF-1; y>=0; y--) {
|
||||||
id = get_data(state, BLOCKS, x, y - (state->chunky * 16), z);
|
id = get_data(state, BLOCKS, x, y - (state->chunky * 16), z);
|
||||||
if (id == block_bedrock || id == block_netherrack || id == block_quartz_ore || id == block_lava)
|
if (block_class_is_subset(id,(mc_block_t[]){block_bedrock,block_netherrack,block_quartz_ore,block_lava},4))
|
||||||
data->remove_block[x+1][y][z+1] = 1;
|
data->remove_block[x+1][y][z+1] = 1;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user