Fix some model errors, add texture atlas debug info.
parent
797d9f19a6
commit
32f4a9414c
|
@ -27,10 +27,10 @@ void CraftItemDef::createModel(TextureAtlas& atlas) {
|
|||
for (unsigned int i = 0; i <= 1; i++) {
|
||||
float xx = xo * (i == 1 ? -1 : 1);
|
||||
std::vector<EntityVertex> myVerts = {
|
||||
{{xx, -0.5, -0.5}, {ref->uv.x, ref->uv.w, 0, 0}, {1, 1, 1}, true, {(i == 1 ? -1 : 1), 0, 0}, {}, {}},
|
||||
{{xx, 0.5, -0.5}, {ref->uv.x, ref->uv.y, 0, 0}, {1, 1, 1}, true, {(i == 1 ? -1 : 1), 0, 0}, {}, {}},
|
||||
{{xx, 0.5, 0.5}, {ref->uv.z, ref->uv.y, 0, 0}, {1, 1, 1}, true, {(i == 1 ? -1 : 1), 0, 0}, {}, {}},
|
||||
{{xx, -0.5, 0.5}, {ref->uv.z, ref->uv.w, 0, 0}, {1, 1, 1}, true, {(i == 1 ? -1 : 1), 0, 0}, {}, {}}
|
||||
{{xx, -0.5, -0.5}, {ref->uv.x, ref->uv.w, 0, 1}, {1, 1, 1}, true, {(i == 1 ? -1 : 1), 0, 0}, {}, {}},
|
||||
{{xx, 0.5, -0.5}, {ref->uv.x, ref->uv.y, 0, 1}, {1, 1, 1}, true, {(i == 1 ? -1 : 1), 0, 0}, {}, {}},
|
||||
{{xx, 0.5, 0.5}, {ref->uv.z, ref->uv.y, 0, 1}, {1, 1, 1}, true, {(i == 1 ? -1 : 1), 0, 0}, {}, {}},
|
||||
{{xx, -0.5, 0.5}, {ref->uv.z, ref->uv.w, 0, 1}, {1, 1, 1}, true, {(i == 1 ? -1 : 1), 0, 0}, {}, {}}
|
||||
};
|
||||
vertices.insert(vertices.end(), myVerts.begin(), myVerts.end());
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ TextureAtlas::TextureAtlas(unsigned int width, unsigned int height) :
|
|||
tileSize(pixelSize.x / 16, pixelSize.y / 16),
|
||||
atlasData(new unsigned char[pixelSize.x * 4 * pixelSize.y]) {
|
||||
|
||||
maxTextureSlots = tileSize.x * tileSize.y;
|
||||
|
||||
// int maxTexSize, texUnits;
|
||||
//
|
||||
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
|
||||
|
@ -110,6 +112,8 @@ std::shared_ptr<AtlasRef> TextureAtlas::addImage(unsigned char *data, const std:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
textureSlotsUsed += tileWidth * tileHeight;
|
||||
|
||||
ref->tileX = static_cast<int>(space.x);
|
||||
ref->tileY = static_cast<int>(space.y);
|
||||
|
||||
|
@ -311,6 +315,8 @@ void TextureAtlas::deleteImage(std::shared_ptr<AtlasRef> ref) {
|
|||
//updateAtlas(ref->tileX, ref->tileY, ref->width, ref->height, data);
|
||||
//delete[] data;
|
||||
|
||||
textureSlotsUsed -= ref->tileWidth * ref->tileHeight;
|
||||
|
||||
for (float i = ref->tileX; i < ref->tileX + ref->tileWidth; i++) {
|
||||
for (float j = ref->tileY; j < ref->tileY + ref->tileHeight; j++) {
|
||||
empty[j * tileSize.x + i] = true;
|
||||
|
|
|
@ -41,6 +41,9 @@ public:
|
|||
|
||||
Texture atlasTexture {};
|
||||
unsigned char* atlasData = nullptr;
|
||||
|
||||
unsigned int textureSlotsUsed = 0;
|
||||
unsigned int maxTextureSlots = 0;
|
||||
private:
|
||||
std::shared_ptr<AtlasRef> generateTexture(std::string req);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ void BlockCrackEntity::addFaces(unsigned int &indOffset, std::vector<EntityVerte
|
|||
for (const BlockModelVertex &vertex : mp.vertices) {
|
||||
glm::vec3 pushed_pos = vertex.pos;
|
||||
pushed_pos += glm::normalize(vertex.nml) * 0.003f;
|
||||
glm::vec4 tex = {uv.x + (uv.z - uv.x) * vertex.texUVs.x, uv.y + ((uv.w - uv.y) * vertex.texUVs.y), 0, 0};
|
||||
glm::vec4 tex = {uv.x + (uv.z - uv.x) * vertex.texUVs.x, uv.y + ((uv.w - uv.y) * vertex.texUVs.y), 0, 1};
|
||||
|
||||
vertices.push_back({
|
||||
pushed_pos,
|
||||
|
|
|
@ -137,6 +137,9 @@ void DebugGui::update(Player& player, LocalWorld& world, LocalDefs& defs, double
|
|||
str << "Standing On: " << on << std::endl;
|
||||
str << "Biome: " << biome << std::endl << std::endl;
|
||||
|
||||
str << "Texture Slots: " << defs.textures.textureSlotsUsed << " / " << defs.textures.maxTextureSlots
|
||||
<< " (" << round(defs.textures.textureSlotsUsed / static_cast<float>(defs.textures.maxTextureSlots) * 100) << "%)" << std::endl << std::endl;
|
||||
|
||||
PointedThing thing = player.getPointedThing();
|
||||
if (thing.thing == PointedThing::Thing::BLOCK) {
|
||||
Dir faceDir = thing.target.block.face;
|
||||
|
|
Loading…
Reference in New Issue