mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-14 07:21:51 +00:00
fix: model-primitives texture regions are broken
This commit is contained in:
parent
2e2233a489
commit
7e41439e1a
1 changed files with 33 additions and 10 deletions
|
|
@ -8,6 +8,22 @@
|
|||
#include "debug/Logger.hpp"
|
||||
#include "core_defs.hpp"
|
||||
|
||||
inline constexpr uint FACE_WEST = FACE_MX;
|
||||
inline constexpr uint FACE_EAST = FACE_PX;
|
||||
inline constexpr uint FACE_BOTTOM = FACE_MY;
|
||||
inline constexpr uint FACE_TOP = FACE_PY;
|
||||
inline constexpr uint FACE_SOUTH = FACE_MZ;
|
||||
inline constexpr uint FACE_NORTH = FACE_PZ;
|
||||
|
||||
inline constexpr std::array<uint8_t, 6> LEGACY_CUSTOM_MODEL_TEXTURE_ORDER = {
|
||||
FACE_WEST,
|
||||
FACE_EAST,
|
||||
FACE_BOTTOM,
|
||||
FACE_TOP,
|
||||
FACE_SOUTH,
|
||||
FACE_NORTH,
|
||||
};
|
||||
|
||||
static debug::Logger logger("models-generator");
|
||||
|
||||
static void configure_textures(
|
||||
|
|
@ -49,6 +65,21 @@ static inline UVRegion get_region_for(
|
|||
return texreg.region;
|
||||
}
|
||||
|
||||
static inline void map_legacy_box_textures(
|
||||
const std::vector<std::string>& modelTextures,
|
||||
size_t offset,
|
||||
UVRegion (&boxtexfaces)[6],
|
||||
const Assets& assets
|
||||
) {
|
||||
for (size_t i = 0; i < 6; ++i) {
|
||||
const auto legacyFace = LEGACY_CUSTOM_MODEL_TEXTURE_ORDER[i];
|
||||
boxtexfaces[legacyFace] = get_region_for(modelTextures[offset + i], assets);
|
||||
}
|
||||
boxtexfaces[FACE_TOP].scale(glm::vec2(-1, 1));
|
||||
boxtexfaces[FACE_EAST].scale(glm::vec2(-1, 1));
|
||||
boxtexfaces[FACE_NORTH].scale(glm::vec2(-1, 1));
|
||||
}
|
||||
|
||||
void ModelsGenerator::prepareModel(
|
||||
Assets& assets, const Block& def, Variant& variant, uint8_t variantId
|
||||
) {
|
||||
|
|
@ -120,16 +151,8 @@ model::Model ModelsGenerator::fromCustom(
|
|||
for (size_t i = 0; i < modelBoxes.size(); i++) {
|
||||
auto& mesh = model.addMesh("blocks:");
|
||||
mesh.shading = lighting;
|
||||
UVRegion boxtexfaces[6] = {
|
||||
get_region_for(modelTextures[i * 6 + 5], assets),
|
||||
get_region_for(modelTextures[i * 6 + 4], assets),
|
||||
get_region_for(modelTextures[i * 6 + 3], assets),
|
||||
get_region_for(modelTextures[i * 6 + 2], assets),
|
||||
get_region_for(modelTextures[i * 6 + 1], assets),
|
||||
get_region_for(modelTextures[i * 6 + 0], assets)
|
||||
};
|
||||
boxtexfaces[2].scale(glm::vec2(-1));
|
||||
boxtexfaces[5].scale(glm::vec2(-1, 1));
|
||||
UVRegion boxtexfaces[6] = {};
|
||||
map_legacy_box_textures(modelTextures, i * 6, boxtexfaces, assets);
|
||||
|
||||
bool enabled[6] {1,1,1,1,1,1};
|
||||
mesh.addBox(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue