diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2019-01-27 13:36:47 +0100 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2019-01-27 15:06:36 +0100 |
commit | b0c6462ca1959a27038f67d5b692f43a8e50decc (patch) | |
tree | b6b1ee958f0877191fb67d0dd92cf46c4ce2abaa /src | |
parent | Added portal blockstate (diff) | |
download | AltCraft-b0c6462ca1959a27038f67d5b692f43a8e50decc.tar AltCraft-b0c6462ca1959a27038f67d5b692f43a8e50decc.tar.gz AltCraft-b0c6462ca1959a27038f67d5b692f43a8e50decc.tar.bz2 AltCraft-b0c6462ca1959a27038f67d5b692f43a8e50decc.tar.lz AltCraft-b0c6462ca1959a27038f67d5b692f43a8e50decc.tar.xz AltCraft-b0c6462ca1959a27038f67d5b692f43a8e50decc.tar.zst AltCraft-b0c6462ca1959a27038f67d5b692f43a8e50decc.zip |
Diffstat (limited to '')
-rw-r--r-- | src/AssetManager.cpp | 18 | ||||
-rw-r--r-- | src/AssetManager.hpp | 1 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp index 3765f02..9fd49bb 100644 --- a/src/AssetManager.cpp +++ b/src/AssetManager.cpp @@ -154,6 +154,14 @@ void ParseAssetTexture(AssetTreeNode &node) { std::memcpy(asset->textureData.data(), data, dataLen); asset->realWidth = w; asset->realHeight = h; + bool foundAnimationFile = false; + for (const auto &it : node.parent->childs) + if (it->name == node.name + ".png") { + foundAnimationFile = true; + break; + } + asset->frames = foundAnimationFile ? _max(w, h) / _min(w, h) : 1; + stbi_image_free(data); @@ -485,6 +493,7 @@ void ParseBlockModels() { } parsedFace.transform = faceTransform; TextureCoord texture; + unsigned int textureFrames = 1; textureName = face.second.texture; if (model.Textures.empty()) { texture = AssetManager::GetTexture("minecraft/textures/error"); @@ -496,11 +505,10 @@ void ParseBlockModels() { textureName = textureIt != model.Textures.end() ? textureIt->second : "minecraft/textures/error"; } textureName.insert(0, "minecraft/textures/"); - texture = AssetManager::GetTexture(textureName); - if (textureName.find("water_flow") != std::string::npos) - texture.h /= 32.0f; - if (textureName.find("lava_flow") != std::string::npos) - texture.h /= 16.0f; + AssetTexture *assetTexture = AssetManager::GetAsset<AssetTexture>(textureName); + texture = atlas->GetTexture(assetTexture->id); + textureFrames = assetTexture->frames; + texture.h /= textureFrames; if (!(face.second.uv == BlockModel::ElementData::FaceData::Uv{ 0,16,0,16 }) && !(face.second.uv == BlockModel::ElementData::FaceData::Uv{ 0,0,0,0 }) && !(face.second.uv == BlockModel::ElementData::FaceData::Uv{ 0,0,16,16 })) { diff --git a/src/AssetManager.hpp b/src/AssetManager.hpp index 852378f..6c5cb49 100644 --- a/src/AssetManager.hpp +++ b/src/AssetManager.hpp @@ -158,6 +158,7 @@ struct AssetBlockState : Asset { struct AssetTexture : Asset { std::vector<unsigned char> textureData; unsigned int realWidth, realHeight; + unsigned int frames; size_t id; }; |