Skip to content

Commit

Permalink
Merge pull request mrkite#81 from EtlamGit/Fix-Entity-Rendering-Depth
Browse files Browse the repository at this point in the history
fix Entity rendering depth
  • Loading branch information
mrkite committed May 24, 2016
2 parents 4e077eb + ebe0f6f commit 033c411
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ QSharedPointer<OverlayItem> Entity::TryParse(Tag* tag)
bool Entity::intersects(const Point& min, const Point& max) const
{
return min.x <= pos.x && max.x >= pos.x &&
min.y <= pos.y && max.y >= pos.y &&
min.z <= pos.z && max.z >= pos.z;
min.y <= pos.y && max.y >= pos.y &&
min.z <= pos.z && max.z >= pos.z;
}

void Entity::draw(double offsetX, double offsetZ, double scale, QPainter& canvas) const
{
QPoint center((pos.x - offsetX) * scale,
(pos.z - offsetZ) * scale);
(pos.z - offsetZ) * scale);

QColor penColor = extraColor;
penColor.setAlpha(192);
QPen pen = canvas.pen();
pen.setColor(penColor);
pen.setWidth(2);
canvas.setPen(pen);

QColor brushColor = color();
brushColor.setAlpha(128);
canvas.setBrush(brushColor);
Expand Down
4 changes: 2 additions & 2 deletions mapview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ void MapView::redraw()
{
//don't show entities above our depth
int entityY = (*it)->midpoint().y;
if (entityY < depth)
if (entityY < depth+1) // everything below the current block, but also inside the current block
{
int entityX = ((int)(*it)->midpoint().x) & 0x0f;
int entityZ = ((int)(*it)->midpoint().z) & 0x0f ;
int index = entityX + (entityZ<<4);
int highY = chunk->depth[index];
if ( (entityY+10 >= highY) ||
(entityY+10 >= depth) )
(entityY+10 >= depth) )
(*it)->draw(x1, z1, zoom, canvas);
}
}
Expand Down

0 comments on commit 033c411

Please sign in to comment.