refactor Content

This commit is contained in:
MihailRis
2024-06-25 22:37:53 +03:00
parent f3c5afa1ab
commit ee9f1639e9
25 changed files with 180 additions and 209 deletions
+2 -2
View File
@@ -123,7 +123,7 @@ std::unique_ptr<Atlas> BlocksPreview::build(
const Content* content
) {
auto indices = content->getIndices();
size_t count = indices->countBlockDefs();
size_t count = indices->blocks.count();
size_t iconSize = ITEM_ICON_SIZE;
auto shader = assets->get<Shader>("ui3d");
@@ -153,7 +153,7 @@ std::unique_ptr<Atlas> BlocksPreview::build(
fbo.bind();
for (size_t i = 0; i < count; i++) {
auto def = indices->getBlockDef(i);
auto def = indices->blocks.get(i);
atlas->getTexture()->bind();
builder.add(def->name, draw(cache, shader, &fbo, &batch, def, iconSize));
}
+1 -1
View File
@@ -40,7 +40,7 @@ BlocksRenderer::BlocksRenderer(
CHUNK_W + voxelBufferPadding*2,
CHUNK_H,
CHUNK_D + voxelBufferPadding*2);
blockDefsCache = content->getIndices()->getBlockDefs();
blockDefsCache = content->getIndices()->blocks.getDefs();
}
BlocksRenderer::~BlocksRenderer() {
+4 -4
View File
@@ -179,7 +179,7 @@ void WorldRenderer::renderLevel(
{
auto inventory = player->getInventory();
ItemStack& stack = inventory->getSlot(player->getChosenSlot());
auto item = indices->getItemDef(stack.getItemId());
auto item = indices->items.get(stack.getItemId());
float multiplier = 0.5f;
shader->uniform3f("u_torchlightColor",
item->emission[0] / 15.0f * multiplier,
@@ -202,11 +202,11 @@ void WorldRenderer::renderLevel(
skybox->unbind();
}
void WorldRenderer::renderBlockSelection(Camera* camera, Shader* linesShader) {
void WorldRenderer::renderBlockSelection() {
const auto& selection = player->selection;
auto indices = level->content->getIndices();
blockid_t id = selection.vox.id;
auto block = indices->getBlockDef(id);
auto block = indices->blocks.get(id);
const glm::ivec3 pos = player->selection.position;
const glm::vec3 point = selection.hitPosition;
const glm::vec3 norm = selection.normal;
@@ -230,7 +230,7 @@ void WorldRenderer::renderLines(Camera* camera, Shader* linesShader) {
linesShader->use();
linesShader->uniformMatrix("u_projview", camera->getProjView());
if (player->selection.vox.id != BLOCK_VOID) {
renderBlockSelection(camera, linesShader);
renderBlockSelection();
}
if (player->debug) {
level->entities->renderDebug(*lineBatch);
+3 -2
View File
@@ -45,10 +45,11 @@ class WorldRenderer {
void drawChunks(Chunks* chunks, Camera* camera, Shader* shader);
/// @brief Render block selection lines
void renderBlockSelection();
/// @brief Render lines (selection and debug)
/// @param camera active camera
/// @param linesShader shader used
void renderBlockSelection(Camera* camera, Shader* linesShader);
void renderLines(Camera* camera, Shader* linesShader);
/// @brief Render all debug lines (chunks borders, coord system guides)