Fix #160 with suggestions from @A-lex-Ra
This commit is contained in:
@@ -39,8 +39,13 @@ ImageData* BlocksPreview::draw(
|
||||
glm::vec4(1.0f), !def->rt.emissive);
|
||||
break;
|
||||
case BlockModel::aabb:
|
||||
batch->blockCube(def->hitbox.size() * glm::vec3(size * 0.63f),
|
||||
texfaces, glm::vec4(1.0f), !def->rt.emissive);
|
||||
{
|
||||
glm::vec3 hitbox = glm::vec3();
|
||||
for (const auto& box : def->hitboxes)
|
||||
hitbox = glm::max(hitbox, box.size());
|
||||
batch->blockCube(hitbox * glm::vec3(size * 0.63f),
|
||||
texfaces, glm::vec4(1.0f), !def->rt.emissive);
|
||||
}
|
||||
break;
|
||||
case BlockModel::custom:
|
||||
case BlockModel::xsprite: {
|
||||
@@ -99,7 +104,10 @@ std::unique_ptr<Atlas> BlocksPreview::build(
|
||||
|
||||
glm::vec3 offset(0.1f, 0.5f, 0.1f);
|
||||
if (def->model == BlockModel::aabb) {
|
||||
offset.y += (1.0f - def->hitbox.size()).y * 0.5f;
|
||||
glm::vec3 size = glm::vec3(0, 0, 0);
|
||||
for (const auto& box : def->hitboxes)
|
||||
size = glm::max(size, box.size());
|
||||
offset.y += (1.0f - size).y * 0.5f;
|
||||
}
|
||||
atlas->getTexture()->bind();
|
||||
shader->uniformMatrix("u_apply", glm::translate(glm::mat4(1.0f), offset));
|
||||
|
||||
@@ -191,18 +191,9 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool hudVisible
|
||||
const vec3 point = PlayerController::selectedPointPosition;
|
||||
const vec3 norm = PlayerController::selectedBlockNormal;
|
||||
|
||||
std::vector<AABB> hitboxes;
|
||||
if (!block->hitboxExplicit) {
|
||||
hitboxes = block->modelBoxes;
|
||||
} else {
|
||||
hitboxes = { block->hitbox };
|
||||
}
|
||||
if (block->rotatable) {
|
||||
auto states = PlayerController::selectedBlockStates;
|
||||
for (auto& hitbox: hitboxes) {
|
||||
block->rotations.variants[states].transform(hitbox);
|
||||
}
|
||||
}
|
||||
std::vector<AABB>& hitboxes = block->rotatable
|
||||
? block->rt.hitboxes[PlayerController::selectedBlockStates]
|
||||
: block->hitboxes;
|
||||
|
||||
linesShader->use();
|
||||
linesShader->uniformMatrix("u_projview", camera->getProjView());
|
||||
|
||||
Reference in New Issue
Block a user