Version 0.2.0
Fixed Size/UV Issues Atlas builder Calculate UVS during Packing Fix File loader loading height into width Set Atlas Size on File load Push Entries on File load Only build palladium, if it is not in build space Add functionality to d7rc-make to check files and create files Fix Palladium Submodule Integration
This commit is contained in:
@@ -40,9 +40,6 @@ bool Atlas::AppendImage(PD::Image::Ref img, const std::string& name) {
|
||||
e.iImg = img;
|
||||
e.iPos = PD::ivec2(it.x, it.y);
|
||||
e.Size = PD::ivec2(img->Width(), img->Height());
|
||||
e.UV = PD::fvec4((float)it.x / (float)Size.x, (float)it.y / (float)Size.y,
|
||||
(float)(it.x + img->Width()) / (float)Size.x,
|
||||
(float)(it.x + img->Height()) / (float)Size.y);
|
||||
Entries.push_back(e);
|
||||
#ifdef DEBUG
|
||||
std::cout << std::format("Created Image {} ({})\n", name,
|
||||
@@ -86,6 +83,7 @@ void Atlas::Pack() {
|
||||
if (!PD::BitUtil::IsSingleBit(Max.y)) {
|
||||
Size.y = PD::BitUtil::GetPow2(Max.y);
|
||||
}
|
||||
pCreateUVs();
|
||||
Img.resize(Size.x * Size.y * 4);
|
||||
for (auto& it : Entries) {
|
||||
for (int i = 0; i < it.Size.x; i++) {
|
||||
@@ -128,4 +126,13 @@ PD::Li::Texture::Ref Atlas::Get(const std::string& name) {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Atlas::pCreateUVs() {
|
||||
for (auto& e : Entries) {
|
||||
e.UV = PD::fvec4((float)e.iPos.x / (float)Size.x,
|
||||
1.f - (float)e.iPos.y / (float)Size.y,
|
||||
(float)(e.iPos.x + e.Size.x) / (float)Size.x,
|
||||
1.f - (float)(e.iPos.y + e.Size.y) / (float)Size.y);
|
||||
}
|
||||
}
|
||||
} // namespace D7RC
|
||||
@@ -107,6 +107,7 @@ void File::Read(Atlas& atlas, const std::string& path) {
|
||||
hdr.Read(iff);
|
||||
pReadTab(iff, atlas);
|
||||
atlas.Img.resize(hdr.DataSize);
|
||||
atlas.Size = PD::ivec2(hdr.Width, hdr.Height);
|
||||
iff.read(reinterpret_cast<char*>(atlas.Img.data()), hdr.DataSize);
|
||||
iff.close();
|
||||
}
|
||||
@@ -118,11 +119,12 @@ void File::pReadTab(std::ifstream& iff, Atlas& atlas) {
|
||||
PD::u32 namelen = 0;
|
||||
iff.read(reinterpret_cast<char*>(&e.UV), sizeof(e.UV));
|
||||
iff.read(reinterpret_cast<char*>(&w), sizeof(w));
|
||||
iff.read(reinterpret_cast<char*>(&w), sizeof(h));
|
||||
iff.read(reinterpret_cast<char*>(&h), sizeof(h));
|
||||
iff.read(reinterpret_cast<char*>(&namelen), sizeof(PD::u32));
|
||||
e.Name.resize(namelen);
|
||||
iff.read(e.Name.data(), namelen);
|
||||
e.Size = PD::ivec2(w, h);
|
||||
atlas.Entries.push_back(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user