-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15d6d4f
commit ca615dc
Showing
23 changed files
with
437 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include "BedrockTextureData.hpp" | ||
|
||
struct BedrockTexture { | ||
public: | ||
std::shared_ptr<BedrockTextureData> bedrockTextureData; | ||
|
||
BedrockTexture() = default; | ||
|
||
BedrockTexture(const BedrockTextureData& data) { | ||
bedrockTextureData = std::make_shared<BedrockTextureData>(data); | ||
} | ||
|
||
void unload() { | ||
if(bedrockTextureData != nullptr) { | ||
bedrockTextureData.reset(); | ||
|
||
int newState = bedrockTextureData->textureLoadState & ~TextureLoadState::LoadedBit; | ||
bedrockTextureData->textureLoadState = static_cast<TextureLoadState>(newState); | ||
|
||
bedrockTextureData->isMissingTexture = IsMissingTexture::No; | ||
} | ||
} | ||
|
||
bool operator==(const BedrockTexture& other) const { | ||
if(bedrockTextureData == other.bedrockTextureData) return true; | ||
return bedrockTextureData->clientTexture == other.bedrockTextureData->clientTexture; | ||
} | ||
|
||
bool operator!=(const BedrockTexture& other) const { | ||
if(bedrockTextureData != other.bedrockTextureData) return true; | ||
return bedrockTextureData->clientTexture != other.bedrockTextureData->clientTexture; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include "TexturePtr.hpp" | ||
#include "Textures/mceTextureDescription.hpp" | ||
#include "Textures/ClientTexture.hpp" | ||
#include "Textures/IsMissingTexture.hpp" | ||
#include "Textures/TextureLoadState.hpp" | ||
#include "Textures/TextureSetImageDescription.hpp" | ||
|
||
struct BedrockTextureData { | ||
public: | ||
mce::ClientTexture clientTexture; | ||
mce::TextureDescription textureDescription; | ||
IsMissingTexture isMissingTexture; | ||
TextureLoadState textureLoadState; | ||
cg::TextureSetImageDescription textureSetDescription; | ||
|
||
~BedrockTextureData() { | ||
clientTexture.resourcePointerBlock.reset(); | ||
textureSetDescription.layerInfo.clear(); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
enum ResourceFileSystem : int32_t { | ||
UserPackage = 0x0000, | ||
AppPackage = 0x0001, | ||
Raw = 0x0002, | ||
RawPersistent = 0x0003, | ||
SettingsDir = 0x0004, | ||
ExternalDir = 0x0005, | ||
ServerPackage = 0x0006, | ||
DataDir = 0x0007, | ||
UserDir = 0x0008, | ||
ScreenshotsDir = 0x0009, | ||
StoreCache = 0x000a, | ||
Invalid = 0x000b, | ||
}; | ||
|
||
class ResourceLocation { | ||
public: | ||
ResourceFileSystem fileSystem; | ||
std::string filePath; | ||
uint64_t pathHash{}; | ||
uint64_t fullHash{}; | ||
|
||
ResourceLocation(const std::string& filePath, bool external) { | ||
this->filePath = filePath; | ||
if (external) | ||
this->fileSystem = ResourceFileSystem::Raw; | ||
else this->fileSystem = ResourceFileSystem::UserPackage; | ||
|
||
_computeHashes(); | ||
}; | ||
|
||
bool operator==(const ResourceLocation& other) const { | ||
if(this->fileSystem != other.fileSystem || this->pathHash != other.pathHash) return false; | ||
return this->filePath == other.filePath; | ||
} | ||
|
||
bool operator<(const ResourceLocation& other) const { | ||
return this->filePath < other.filePath; | ||
} | ||
|
||
private: | ||
void _computeHashes() | ||
{ | ||
const uint64_t FNV_OFFSET_BASIS = 0xCBF29CE484222325u; | ||
const uint64_t FNV_PRIME = 0x100000001B3u; | ||
|
||
uint64_t _pathHash = FNV_OFFSET_BASIS; | ||
if (!this->filePath.empty()) { | ||
for (char c : this->filePath) { | ||
_pathHash *= FNV_PRIME; | ||
_pathHash ^= c; | ||
} | ||
} else { | ||
_pathHash = 0; | ||
} | ||
|
||
uint64_t fileSystemHash = FNV_OFFSET_BASIS ^ static_cast<uint8_t>(this->fileSystem); | ||
fileSystemHash *= FNV_PRIME; | ||
|
||
this->pathHash = _pathHash; | ||
this->fullHash = _pathHash ^ fileSystemHash; | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
#include "ResourceLocation.hpp" | ||
#include "../../../Utils/Memory/Game/SignatureAndOffsetManager.hpp" | ||
#include "libhat/Access.hpp" | ||
#include "BedrockTexture.hpp" | ||
|
||
class TextureGroup { | ||
public: | ||
std::map<ResourceLocation, BedrockTexture>& getLoadedTextures() { | ||
return hat::member_at<std::map<ResourceLocation, BedrockTexture>>(this, GET_OFFSET("TextureGroup::base") + GET_OFFSET("TextureGroup::loadedTextures")); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <utility> | ||
#include "ResourceLocation.hpp" | ||
#include "BedrockTextureData.hpp" | ||
|
||
|
||
class TexturePtr { | ||
public: | ||
std::shared_ptr<BedrockTextureData> clientTexture; | ||
std::shared_ptr<ResourceLocation> resourceLocation; | ||
|
||
TexturePtr() = default; | ||
|
||
[[nodiscard]] std::string GetFilePath() const { | ||
return resourceLocation->filePath; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
namespace mce { | ||
enum BindFlagsBit : uint32_t { | ||
NoBindFlags = 0x0000, | ||
VertexBufferBit = 0x0001, | ||
IndexBufferBit = 0x0002, | ||
ConstantBufferBit = 0x0004, | ||
ShaderResourceBit = 0x0008, | ||
StreamOutputBit = 0x0010, | ||
RenderTargetBit = 0x0020, | ||
DepthStencilBit = 0x0040, | ||
UnorderedAccessBit = 0x0080, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <variant> | ||
#include <string> | ||
|
||
namespace mce { | ||
class ClientTexture { | ||
public: | ||
std::shared_ptr<class data> resourcePointerBlock; | ||
public: | ||
virtual ~ClientTexture() = default; | ||
|
||
bool operator==(const ClientTexture& other) const { | ||
return resourcePointerBlock == other.resourcePointerBlock; | ||
} | ||
|
||
bool operator!=(const ClientTexture& other) const { | ||
return resourcePointerBlock != other.resourcePointerBlock; | ||
} | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
namespace mce { | ||
class Color { // MCCColor | ||
float r; | ||
float g; | ||
float b; | ||
float a; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
class ColorChannel { | ||
float value; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include "TextureFormat.hpp" | ||
|
||
namespace cg { | ||
struct ImageDescription { | ||
uint32_t width; | ||
uint32_t height; | ||
mce::TextureFormat textureFormat; | ||
uint32_t arraySize; | ||
}; | ||
} |
Oops, something went wrong.