Skip to content

Commit

Permalink
Bugfix: don't highlight air nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
RealBadAngel committed Sep 18, 2014
1 parent 58e6d25 commit 86a0f56
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions src/content_mapblock.cpp
Expand Up @@ -193,41 +193,43 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
(p.Z >= 0) & (p.Z < MAP_BLOCKSIZE)) {

MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes + p);
// Get selection mesh light level
static const v3s16 dirs[7] = {
v3s16( 0, 0, 0),
v3s16( 0, 1, 0),
v3s16( 0,-1, 0),
v3s16( 1, 0, 0),
v3s16(-1, 0, 0),
v3s16( 0, 0, 1),
v3s16( 0, 0,-1)
};
if(n.getContent() != CONTENT_AIR) {

This comment has been minimized.

Copy link
@sfan5

sfan5 Sep 18, 2014

Member

what about airlike nodes?

// Get selection mesh light level
static const v3s16 dirs[7] = {
v3s16( 0, 0, 0),
v3s16( 0, 1, 0),
v3s16( 0,-1, 0),
v3s16( 1, 0, 0),
v3s16(-1, 0, 0),
v3s16( 0, 0, 1),
v3s16( 0, 0,-1)
};

u16 l = 0;
u16 l1 = 0;
for (u8 i = 0; i < 7; i++) {
MapNode n1 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p + dirs[i]);
l1 = getInteriorLight(n1, -4, nodedef);
if (l1 > l)
l = l1;
}
video::SColor c = MapBlock_LightColor(255, l, 0);
data->m_highlight_mesh_color = c;
std::vector<aabb3f> boxes = n.getSelectionBoxes(nodedef);
TileSpec h_tile;
h_tile.material_flags |= MATERIAL_FLAG_HIGHLIGHTED;
h_tile.texture = tsrc->getTexture("halo.png",&h_tile.texture_id);
v3f pos = intToFloat(p, BS);
f32 d = 0.05 * BS;
for(std::vector<aabb3f>::iterator
i = boxes.begin();
i != boxes.end(); i++)
{
aabb3f box = *i;
box.MinEdge += v3f(-d, -d, -d) + pos;
box.MaxEdge += v3f(d, d, d) + pos;
makeCuboid(&collector, box, &h_tile, 1, c, NULL);
u16 l = 0;
u16 l1 = 0;
for (u8 i = 0; i < 7; i++) {
MapNode n1 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p + dirs[i]);
l1 = getInteriorLight(n1, -4, nodedef);
if (l1 > l)
l = l1;
}
video::SColor c = MapBlock_LightColor(255, l, 0);
data->m_highlight_mesh_color = c;
std::vector<aabb3f> boxes = n.getSelectionBoxes(nodedef);
TileSpec h_tile;
h_tile.material_flags |= MATERIAL_FLAG_HIGHLIGHTED;
h_tile.texture = tsrc->getTexture("halo.png",&h_tile.texture_id);
v3f pos = intToFloat(p, BS);
f32 d = 0.05 * BS;
for(std::vector<aabb3f>::iterator
i = boxes.begin();
i != boxes.end(); i++)
{
aabb3f box = *i;
box.MinEdge += v3f(-d, -d, -d) + pos;
box.MaxEdge += v3f(d, d, d) + pos;
makeCuboid(&collector, box, &h_tile, 1, c, NULL);
}
}
}

Expand Down

1 comment on commit 86a0f56

@ShadowNinja
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing that you're not pointing at should be highlighted, that includes pointable = false nodes like air.

Please sign in to comment.