fix block solidity property

This commit is contained in:
MihailRis 2025-07-13 22:56:06 +03:00
parent 325f0b1f02
commit 5fdff1f8f6
3 changed files with 18 additions and 8 deletions

View File

@ -28,13 +28,17 @@ std::unique_ptr<Content> ContentBuilder::build() {
// Generating runtime info
def.rt.id = blockDefsIndices.size();
def.rt.emissive = *reinterpret_cast<uint32_t*>(def.emission);
def.rt.solid = def.defaults.model.type == BlockModelType::BLOCK; // FIXME
def.rt.extended = def.size.x > 1 || def.size.y > 1 || def.size.z > 1;
const float EPSILON = 0.01f;
if (def.rt.extended && glm::i8vec3(def.hitboxes[0].size() + EPSILON) == def.size) {
def.rt.solid = true;
// TODO: refactor
def.defaults.rt.solid = def.defaults.model.type == BlockModelType::BLOCK;
if (def.variants) {
for (auto& variant : def.variants->variants) {
variant.rt.solid = variant.model.type == BlockModelType::BLOCK;
}
}
const float EPSILON = 0.01f;
def.rt.solid = glm::i8vec3(def.hitboxes[0].size() + EPSILON) == def.size;
def.rt.extended = def.size.x > 1 || def.size.y > 1 || def.size.z > 1;
if (def.rotatable) {
for (uint i = 0; i < BlockRotProfile::MAX_COUNT; i++) {

View File

@ -130,8 +130,9 @@ class BlocksRenderer {
return false;
}
const auto& block = *blockDefsCache[vox.id];
uint8_t otherDrawGroup = block.getVariant(vox.state.userbits).drawGroup;
if ((otherDrawGroup && (otherDrawGroup != variant.drawGroup)) || !block.rt.solid) {
const auto& blockVariant = block.getVariant(vox.state.userbits);
uint8_t otherDrawGroup = blockVariant.drawGroup;
if ((otherDrawGroup && (otherDrawGroup != variant.drawGroup)) || !blockVariant.rt.solid) {
return true;
}
if ((variant.culling == CullingMode::DISABLED ||

View File

@ -153,6 +153,11 @@ struct Variant {
CullingMode culling = CullingMode::DEFAULT;
/// @brief Influences visible block sides for transparent blocks
uint8_t drawGroup = 0;
struct {
/// @brief is the block completely opaque for render
bool solid = true;
} rt;
};
struct Variants {
@ -258,7 +263,7 @@ public:
/// @brief block runtime integer id
blockid_t id;
/// @brief is the block completely opaque for render and raycast
/// @brief is the block completely opaque for raycast
bool solid = true;
/// @brief does the block emit any lights