From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/Stitcher.h | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Minecraft.Client/Stitcher.h (limited to 'Minecraft.Client/Stitcher.h') diff --git a/Minecraft.Client/Stitcher.h b/Minecraft.Client/Stitcher.h new file mode 100644 index 00000000..1e5b28c1 --- /dev/null +++ b/Minecraft.Client/Stitcher.h @@ -0,0 +1,60 @@ +#pragma once +using namespace std; + +class StitchSlot; +class Texture; +#include "TextureHolder.h" + +class Stitcher +{ +public: + static const int STITCH_SUCCESS = 0; + static const int STITCH_RETRY = 1; + static const int STITCH_ABORT = 2; + + static const int MAX_MIPLEVEL = 0; // This should be 4 again later when we *ACTUALLY* mipmap + static const int MIN_TEXEL = 1 << MAX_MIPLEVEL; + +private: + set texturesToBeStitched; // = new HashSet(256); + vector storage; // = new ArrayList(256); + int storageX; + int storageY; + + int maxWidth; + int maxHeight; + bool forcePowerOfTwo; + int forcedScale; + + Texture *stitchedTexture; + + wstring name; + + void _init(const wstring &name, int maxWidth, int maxHeight, bool forcePowerOfTwo, int forcedScale); + +public: + Stitcher(const wstring &name, int maxWidth, int maxHeight, bool forcePowerOfTwo); + Stitcher(const wstring &name, int maxWidth, int maxHeight, bool forcePowerOfTwo, int forcedScale); + + int getWidth(); + int getHeight(); + void addTexture(TextureHolder *textureHolder); + Texture *constructTexture(bool mipmap = true); // 4J Added mipmap param + void stitch(); + vector *gatherAreas(); + +private: + // Based on: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 + int smallestEncompassingPowerOfTwo(int input); + + bool addToStorage(TextureHolder *textureHolder); + + /** + * Expand the current storage to take in account the new texture. + * This should only be called if it didn't fit anywhere. + * + * @param textureHolder + * @return Boolean indicating if it could accommodate for the growth + */ + bool expand(TextureHolder *textureHolder); +}; \ No newline at end of file -- cgit v1.2.3