Minor Tweaks

This commit is contained in:
TheBrokenRail 2024-10-30 00:22:02 -04:00
parent a0a566f594
commit 419ad9c98c
2 changed files with 17 additions and 7 deletions

View File

@ -20,6 +20,17 @@ static int get_atlas_key(Item *item, const int data) {
} }
static std::unordered_map<int, std::pair<int, int>> atlas_key_to_pos; static std::unordered_map<int, std::pair<int, int>> atlas_key_to_pos;
static std::unordered_map<int, std::vector<std::pair<int, int>>> tile_texture_to_atlas_pos; static std::unordered_map<int, std::vector<std::pair<int, int>>> tile_texture_to_atlas_pos;
static bool is_flat_tile(const int id) {
// Check If An Item Is A Tile
if (id < 256) {
Tile *tile = Tile::tiles[id];
// Check If It Renders Without A Model ("Flat" Rendering)
if (tile && !TileRenderer::canRender(tile->getRenderShape())) {
return true;
}
}
return false;
}
static void render_atlas(Textures *textures) { static void render_atlas(Textures *textures) {
int x = 0; int x = 0;
int y = 0; int y = 0;
@ -61,13 +72,10 @@ static void render_atlas(Textures *textures) {
media_glPopMatrix(); media_glPopMatrix();
// Store // Store
atlas_key_to_pos[key] = {x, y}; atlas_key_to_pos[key] = {x, y};
if (id < 256) { if (is_flat_tile(id)) {
Tile *tile = Tile::tiles[id];
if (tile && !TileRenderer::canRender(tile->getRenderShape())) {
int icon = item->getIcon(data); int icon = item->getIcon(data);
tile_texture_to_atlas_pos[icon].push_back(atlas_key_to_pos[key]); tile_texture_to_atlas_pos[icon].push_back(atlas_key_to_pos[key]);
} }
}
// Advance To Next Slot // Advance To Next Slot
x++; x++;
if (x >= ATLAS_SIZE) { if (x >= ATLAS_SIZE) {

View File

@ -32,9 +32,11 @@ static void Minecraft_tick_injection(const Minecraft *minecraft) {
media_glTexSubImage2D_with_scaling(data, x_offset, y_offset, 16, 16, 256, 256, texture->pixels); media_glTexSubImage2D_with_scaling(data, x_offset, y_offset, 16, 16, 256, 256, texture->pixels);
} }
} }
if (textures->current_texture == textures->loadTexture("terrain.png", true)) {
atlas_update_tile(textures, texture->texture_index, texture->pixels); atlas_update_tile(textures, texture->texture_index, texture->pixels);
} }
} }
}
} }
// Scale Texture (Remember To Free) // Scale Texture (Remember To Free)