mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 06:21:50 +00:00
fix custom model blocks render (with some conditions)
This commit is contained in:
parent
6b580d23c6
commit
e0be7a8d8c
3 changed files with 15 additions and 8 deletions
|
|
@ -26,17 +26,18 @@ std::unique_ptr<Content> ContentBuilder::build() {
|
||||||
def.rt.tags.insert(tags.add(tag));
|
def.rt.tags.insert(tags.add(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto isSolid = [](const Variant& variant) {
|
||||||
|
return variant.model.type == BlockModelType::BLOCK ||
|
||||||
|
variant.culling == CullingMode::OPTIONAL;
|
||||||
|
};
|
||||||
|
|
||||||
if (def.variants) {
|
if (def.variants) {
|
||||||
for (auto& variant : def.variants->variants) {
|
for (auto& variant : def.variants->variants) {
|
||||||
variant.rt.solid =
|
variant.rt.solid = isSolid(variant) || def.explictlySolid;
|
||||||
variant.model.type == BlockModelType::BLOCK ||
|
|
||||||
def.explictlySolid;
|
|
||||||
}
|
}
|
||||||
def.defaults = def.variants->variants.at(0);
|
def.defaults = def.variants->variants.at(0);
|
||||||
} else {
|
} else {
|
||||||
def.defaults.rt.solid =
|
def.defaults.rt.solid = isSolid(def.defaults) || def.explictlySolid;
|
||||||
def.defaults.model.type == BlockModelType::BLOCK ||
|
|
||||||
def.explictlySolid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const float EPSILON = 0.01f;
|
const float EPSILON = 0.01f;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ void ContentGfxCache::refreshVariant(
|
||||||
uint8_t variantIndex,
|
uint8_t variantIndex,
|
||||||
const Atlas& atlas
|
const Atlas& atlas
|
||||||
) {
|
) {
|
||||||
|
std::unordered_map<std::string, std::string> optionalTextures;
|
||||||
bool denseRender = settings.denseRender.get();
|
bool denseRender = settings.denseRender.get();
|
||||||
for (uint side = 0; side < 6; side++) {
|
for (uint side = 0; side < 6; side++) {
|
||||||
std::string tex = variant.textureFaces[side];
|
std::string tex = variant.textureFaces[side];
|
||||||
|
|
@ -43,6 +44,7 @@ void ContentGfxCache::refreshVariant(
|
||||||
texOpaque = tex;
|
texOpaque = tex;
|
||||||
} else if (variant.culling == CullingMode::OPTIONAL && !denseRender) {
|
} else if (variant.culling == CullingMode::OPTIONAL && !denseRender) {
|
||||||
tex = texOpaque;
|
tex = texOpaque;
|
||||||
|
optionalTextures[variant.textureFaces[side]] = texOpaque;
|
||||||
}
|
}
|
||||||
size_t index = getRegionIndex(def.rt.id, variantIndex, side, false);
|
size_t index = getRegionIndex(def.rt.id, variantIndex, side, false);
|
||||||
sideregions[index] = atlas.get(tex);
|
sideregions[index] = atlas.get(tex);
|
||||||
|
|
@ -56,7 +58,12 @@ void ContentGfxCache::refreshVariant(
|
||||||
if (pos == std::string::npos) {
|
if (pos == std::string::npos) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (auto region = atlas.getIf(mesh.texture.substr(pos+1))) {
|
std::string texture = mesh.texture.substr(pos+1);
|
||||||
|
const auto& found = optionalTextures.find(texture);
|
||||||
|
if (found != optionalTextures.end()) {
|
||||||
|
texture = found->second;
|
||||||
|
}
|
||||||
|
if (auto region = atlas.getIf(texture)) {
|
||||||
for (auto& vertex : mesh.vertices) {
|
for (auto& vertex : mesh.vertices) {
|
||||||
vertex.uv = region->apply(vertex.uv);
|
vertex.uv = region->apply(vertex.uv);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -538,7 +538,6 @@ void BlocksRenderer::render(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BlockModelType::CUSTOM: {
|
case BlockModelType::CUSTOM: {
|
||||||
if (!denseRender)
|
|
||||||
blockCustomModel(
|
blockCustomModel(
|
||||||
{x, y, z},
|
{x, y, z},
|
||||||
def,
|
def,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue