diff options
author | UIS <uis9936@gmail.com> | 2020-09-19 23:59:00 +0200 |
---|---|---|
committer | LaG1924 <lag1924@gmail.com> | 2021-06-24 10:48:13 +0200 |
commit | 70c3ade4dd87907506ab40eb8e1cf04e4db3779a (patch) | |
tree | 885d07468197500b03ad9839619f25199b71b7a7 | |
parent | Use 12+4 bits for BlockId, GetBlockInfo return pointer instead value (diff) | |
download | AltCraft-70c3ade4dd87907506ab40eb8e1cf04e4db3779a.tar AltCraft-70c3ade4dd87907506ab40eb8e1cf04e4db3779a.tar.gz AltCraft-70c3ade4dd87907506ab40eb8e1cf04e4db3779a.tar.bz2 AltCraft-70c3ade4dd87907506ab40eb8e1cf04e4db3779a.tar.lz AltCraft-70c3ade4dd87907506ab40eb8e1cf04e4db3779a.tar.xz AltCraft-70c3ade4dd87907506ab40eb8e1cf04e4db3779a.tar.zst AltCraft-70c3ade4dd87907506ab40eb8e1cf04e4db3779a.zip |
-rw-r--r-- | cwd/assets/altcraft/shaders/vert/face.vs | 8 | ||||
-rw-r--r-- | src/Block.cpp | 4 | ||||
-rw-r--r-- | src/Block.hpp | 2 |
3 files changed, 6 insertions, 8 deletions
diff --git a/cwd/assets/altcraft/shaders/vert/face.vs b/cwd/assets/altcraft/shaders/vert/face.vs index 044c012..30ae0d7 100644 --- a/cwd/assets/altcraft/shaders/vert/face.vs +++ b/cwd/assets/altcraft/shaders/vert/face.vs @@ -22,11 +22,9 @@ uniform mat4 projView; vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer) { float x = TextureAtlasCoords.x; float y = TextureAtlasCoords.y; - float w = TextureAtlasCoords.z; +// float w = TextureAtlasCoords.z; float h = TextureAtlasCoords.w; - vec2 A = vec2(x, 1 - y - h); - vec2 B = vec2(x + w, 1 - y); - vec2 transformed = A + UvCoords * (B - A); + vec2 transformed = vec2(x, 1 - y - h) + UvCoords * TextureAtlasCoords.zw; return vec3(transformed.x, transformed.y, Layer); } @@ -42,7 +40,7 @@ void main() texturePos.w = frameHeight; texturePos.y = texturePos.y + currentFrame * frameHeight; - vs_out.UvPosition = vec2(UvCoordinates.x,UvCoordinates.y); + vs_out.UvPosition = UvCoordinates; vs_out.Texture = TransformTextureCoord(texturePos,UvCoordinates,TextureLayer); vs_out.Color = color; vs_out.Light = light; diff --git a/src/Block.cpp b/src/Block.cpp index b81a762..85870f6 100644 --- a/src/Block.cpp +++ b/src/Block.cpp @@ -11,12 +11,12 @@ static std::map<BlockId, size_t> staticBlockInfo; BlockInfo WTFBlock{ true, "", "" }; void RegisterStaticBlockInfo(BlockId blockId, BlockInfo blockInfo) { - //NOTE: It can be made thread-safe using incrementer + //NOTE: It can be made thread-safe by using atomic incrementer staticBlockInfo[blockId] = blocks.size(); blocks.push_back(blockInfo); } -BlockInfo* GetBlockInfo(BlockId blockId, Vector blockPos) { +BlockInfo* GetBlockInfo(BlockId blockId) { auto it = staticBlockInfo.find(blockId); if (it != staticBlockInfo.end()) return &blocks.data()[it->second]; diff --git a/src/Block.hpp b/src/Block.hpp index a9fd881..0fd0e89 100644 --- a/src/Block.hpp +++ b/src/Block.hpp @@ -49,4 +49,4 @@ struct BlockInfo { void RegisterStaticBlockInfo(BlockId blockId, BlockInfo blockInfo); -BlockInfo* GetBlockInfo(BlockId blockId, Vector blockPos = Vector(0,0,0)); +BlockInfo* GetBlockInfo(BlockId blockId); |