Fix grid layers with z_index=0 rendering on top of entities, closes #257
Layers with z_index <= 0 now render below entities (ground level), and only layers with z_index > 0 render above entities. Previously z_index=0 was treated as "above entities" which was unintuitive -- entities stand on ground level (z=0) with their feet, so z=0 layers should be beneath. Changed in both UIGrid.cpp and UIGridView.cpp render methods: - "z_index >= 0" to "z_index > 0" for break condition - "z_index < 0" to "z_index <= 0" for skip condition Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e58b44ef82
commit
9ca79baec8
3 changed files with 9 additions and 9 deletions
|
|
@ -30,7 +30,7 @@ public:
|
||||||
|
|
||||||
GridLayerType type;
|
GridLayerType type;
|
||||||
std::string name; // #150 - Layer name for GridPoint property access
|
std::string name; // #150 - Layer name for GridPoint property access
|
||||||
int z_index; // Negative = below entities, >= 0 = above entities
|
int z_index; // <= 0 = below entities (ground level), > 0 = above entities
|
||||||
int grid_x, grid_y; // Dimensions
|
int grid_x, grid_y; // Dimensions
|
||||||
GridData* parent_grid; // Parent grid reference (#252: GridData, not UIGrid)
|
GridData* parent_grid; // Parent grid reference (#252: GridData, not UIGrid)
|
||||||
bool visible; // Visibility flag
|
bool visible; // Visibility flag
|
||||||
|
|
|
||||||
|
|
@ -182,10 +182,10 @@ void UIGrid::render(sf::Vector2f offset, sf::RenderTarget& target)
|
||||||
if (y_limit > grid_h) y_limit = grid_h;
|
if (y_limit > grid_h) y_limit = grid_h;
|
||||||
|
|
||||||
// #150 - Layers are now the sole source of grid rendering (base layer removed)
|
// #150 - Layers are now the sole source of grid rendering (base layer removed)
|
||||||
// Render layers with z_index < 0 (below entities)
|
// Render layers with z_index <= 0 (below entities)
|
||||||
sortLayers();
|
sortLayers();
|
||||||
for (auto& layer : layers) {
|
for (auto& layer : layers) {
|
||||||
if (layer->z_index >= 0) break; // Stop at layers that go above entities
|
if (layer->z_index > 0) break; // Stop at layers that go above entities (#257)
|
||||||
layer->render(*activeTexture, left_spritepixels, top_spritepixels,
|
layer->render(*activeTexture, left_spritepixels, top_spritepixels,
|
||||||
left_edge, top_edge, x_limit, y_limit, zoom, cell_width, cell_height);
|
left_edge, top_edge, x_limit, y_limit, zoom, cell_width, cell_height);
|
||||||
}
|
}
|
||||||
|
|
@ -222,9 +222,9 @@ void UIGrid::render(sf::Vector2f offset, sf::RenderTarget& target)
|
||||||
Resources::game->metrics.totalEntities += totalEntities;
|
Resources::game->metrics.totalEntities += totalEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #147 - Render dynamic layers with z_index >= 0 (above entities)
|
// #147 - Render dynamic layers with z_index > 0 (above entities)
|
||||||
for (auto& layer : layers) {
|
for (auto& layer : layers) {
|
||||||
if (layer->z_index < 0) continue; // Skip layers below entities
|
if (layer->z_index <= 0) continue; // Skip layers at or below entities (#257)
|
||||||
layer->render(*activeTexture, left_spritepixels, top_spritepixels,
|
layer->render(*activeTexture, left_spritepixels, top_spritepixels,
|
||||||
left_edge, top_edge, x_limit, y_limit, zoom, cell_width, cell_height);
|
left_edge, top_edge, x_limit, y_limit, zoom, cell_width, cell_height);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,10 +167,10 @@ void UIGridView::render(sf::Vector2f offset, sf::RenderTarget& target)
|
||||||
int y_limit = top_edge + height_sq + 2;
|
int y_limit = top_edge + height_sq + 2;
|
||||||
if (y_limit > grid_data->grid_h) y_limit = grid_data->grid_h;
|
if (y_limit > grid_data->grid_h) y_limit = grid_data->grid_h;
|
||||||
|
|
||||||
// Render layers below entities (z_index < 0)
|
// Render layers below entities (z_index <= 0)
|
||||||
grid_data->sortLayers();
|
grid_data->sortLayers();
|
||||||
for (auto& layer : grid_data->layers) {
|
for (auto& layer : grid_data->layers) {
|
||||||
if (layer->z_index >= 0) break;
|
if (layer->z_index > 0) break; // #257: z_index=0 is ground level (below entities)
|
||||||
layer->render(*activeTexture, left_spritepixels, top_spritepixels,
|
layer->render(*activeTexture, left_spritepixels, top_spritepixels,
|
||||||
left_edge, top_edge, x_limit, y_limit, zoom, cell_width, cell_height);
|
left_edge, top_edge, x_limit, y_limit, zoom, cell_width, cell_height);
|
||||||
}
|
}
|
||||||
|
|
@ -191,9 +191,9 @@ void UIGridView::render(sf::Vector2f offset, sf::RenderTarget& target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render layers above entities (z_index >= 0)
|
// Render layers above entities (z_index > 0)
|
||||||
for (auto& layer : grid_data->layers) {
|
for (auto& layer : grid_data->layers) {
|
||||||
if (layer->z_index < 0) continue;
|
if (layer->z_index <= 0) continue; // #257: skip ground-level and below
|
||||||
layer->render(*activeTexture, left_spritepixels, top_spritepixels,
|
layer->render(*activeTexture, left_spritepixels, top_spritepixels,
|
||||||
left_edge, top_edge, x_limit, y_limit, zoom, cell_width, cell_height);
|
left_edge, top_edge, x_limit, y_limit, zoom, cell_width, cell_height);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue