summaryrefslogtreecommitdiffstats
path: root/src/AssetManager.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2022-12-15 16:41:06 +0100
committerGitHub <noreply@github.com>2022-12-15 16:41:06 +0100
commitd2b2f223cc62a1cc6e9d41d32020ef94d229a581 (patch)
treede0685c59a55557893d8d6d64bad01e9c98d206a /src/AssetManager.cpp
parentMerge pull request #82 from LaG1924/fix/sdl-wayland-build (diff)
parentAdded liquid rendering pass (diff)
downloadAltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar.gz
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar.bz2
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar.lz
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar.xz
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar.zst
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.zip
Diffstat (limited to 'src/AssetManager.cpp')
-rw-r--r--src/AssetManager.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp
index 3e3f677..09f5209 100644
--- a/src/AssetManager.cpp
+++ b/src/AssetManager.cpp
@@ -573,6 +573,52 @@ BlockFaces &AssetManager::GetBlockModelByBlockId(BlockId block) {
return it->second;
BlockInfo *blockInfo = GetBlockInfo(block);
+ if (blockInfo->blockstate == "@liquid") {
+ BlockFaces blockFaces;
+ blockFaces.isBlock = false;
+ blockFaces.isLiquid = true;
+ blockFaces.transform = glm::mat4(1.0f);
+ blockFaces.ambientOcclusion = false;
+ for (size_t i = 0; i < FaceDirection::none; i++) {
+ blockFaces.faceDirectionVector[i] = FaceDirectionVector[i];
+ }
+
+ const auto& liquidInfo = GetBlockLiquidInfo(BlockId{ block.id, 0 });
+
+ {
+ AssetTexture* assetTexture = AssetManager::GetAsset<AssetTexture>("minecraft/textures/" + liquidInfo.flowTexture);
+ if (!assetTexture)
+ return errorFaces;
+ TextureCoord texture = atlas->GetTexture(assetTexture->id);
+ float textureFrames = assetTexture->frames;
+ blockFaces.faces.emplace_back(ParsedFace{
+ FaceDirection::none,
+ glm::translate(glm::mat4(1.0f), glm::vec3{0.0f, 1.0f, 0.0f}),
+ glm::vec4{ texture.x,texture.y,texture.w,texture.h },
+ static_cast<float>(texture.layer),
+ static_cast<float>(assetTexture->frames),
+ glm::vec3(1.0f),
+ });
+ }
+
+ {
+ AssetTexture* assetTexture = AssetManager::GetAsset<AssetTexture>("minecraft/textures/" + liquidInfo.stillTexture);
+ if (!assetTexture)
+ return errorFaces;
+ TextureCoord texture = atlas->GetTexture(assetTexture->id);
+ float textureFrames = assetTexture->frames;
+ blockFaces.faces.emplace_back(ParsedFace{
+ FaceDirection::none,
+ glm::translate(glm::mat4(1.0f), glm::vec3{0.0f, 1.0f, 0.0f}),
+ glm::vec4{ texture.x,texture.y,texture.w,texture.h },
+ static_cast<float>(texture.layer),
+ static_cast<float>(assetTexture->frames),
+ glm::vec3(1.0f),
+ });
+ }
+
+ return blockIdToBlockFaces.insert(std::make_pair(block, blockFaces)).first->second;
+ }
AssetBlockState *asset = GetAsset<AssetBlockState>("/minecraft/blockstates/" + blockInfo->blockstate);
if (!asset)
return errorFaces;
@@ -595,6 +641,7 @@ BlockFaces &AssetManager::GetBlockModelByBlockId(BlockId block) {
blockFaces.faces = assetModel->blockModel.parsedFaces;
blockFaces.isBlock = assetModel->blockModel.IsBlock;
blockFaces.ambientOcclusion = assetModel->blockModel.AmbientOcclusion;
+ blockFaces.isLiquid = false;
glm::mat4 transform = glm::mat4(1.0);
if (model.y != 0) {